/* styles.css */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --kb-safe-area: 0px;
  /* updated by JS */
  --nav-height: calc(70px + env(safe-area-inset-bottom, 0px));
}

html {
  height: 100%;
}

body {
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #f2f2f2;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  color: #161616;
  line-height: 1.6;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body.app-ready #tt-loading,
body.app-ready .tt-loading,
body.app-ready .tiktok-loading,
body.app-ready .app-loading,
body.app-ready [data-testid="loading"],
body[data-app-ready="true"] #tt-loading {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

#cf-message {
  /* when focused, ensure the browser can scroll past it */
  scroll-margin-bottom: 120px;
}

/* Container */
.container {
  max-width: 430px;
  margin: 0 auto;
  background: #fff;
  min-height: 100vh;
  height: 100%;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: calc(36px + var(--nav-height));
  overflow: visible;
}

/* Hero */
.hero-section {
  width: 100%;
  position: relative;
  overflow: hidden;
}

.hero-section,
.social-row,
.section-divider {
  flex-shrink: 0;
}

.hero-image {
  position: relative;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  height: 150px;
  max-height: 150px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 20px 24px;
  z-index: 1;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: transparent;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 20px 24px;
}

.profile-info {
  text-align: left;
  color: #fff;
  z-index: 2;
}

.profile-name {
  font-size: 32px;
  font-weight: 600;
  margin-bottom: 4px;
  text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.9), 0 0 10px rgba(0, 0, 0, 0.7);
  letter-spacing: -0.02em;
}

.profile-username {
  font-size: 18px;
  opacity: .95;
  font-weight: 400;
  color: #f0f0f0;
  text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.8), 0 0 6px rgba(0, 0, 0, 0.6);
}

/* Social row */
.social-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 6px;
  background: #fff;
  position: relative;
  z-index: 2;
}

.section-divider {
  margin: 0;
  border: none;
  border-top: 1px solid #e0e0e0;
}

.content-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 0 24px calc(32px + var(--nav-height));
  background: #fff;
  align-items: stretch;
  flex: 1 1 auto;
  position: relative;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 98, 254, 0.35) rgba(15, 98, 254, 0.08);
  scroll-padding-bottom: calc(var(--nav-height) + 140px);
}

.content-layout::-webkit-scrollbar {
  width: 6px;
  background-color: transparent;
}

.content-layout::-webkit-scrollbar-track {
  background: rgba(15, 98, 254, 0.05);
  border-radius: 999px;
}

.content-layout::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(15, 98, 254, 0.65), rgba(15, 98, 254, 0.4));
  border-radius: 999px;
}

.content-layout::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(15, 98, 254, 0.85), rgba(15, 98, 254, 0.55));
}

.sidebar-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 460px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -18px 36px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(12px);
  z-index: 20;
  flex-wrap: nowrap;
}

.sidebar-nav__item {
  flex: 1 1 0;
  min-width: 0;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 14px;
  color: #4d4d4d;
  cursor: pointer;
  transition: color .18s ease, background .18s ease, transform .18s ease, box-shadow .18s ease;
  touch-action: manipulation;
}

.sidebar-nav__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 22px;
  line-height: 1;
}

.sidebar-nav__item:hover {
  background: rgba(15, 98, 254, 0.08);
  color: #0f62fe;
}

.sidebar-nav__item:focus-visible {
  outline: 2px solid #0f62fe;
  outline-offset: 3px;
}

.sidebar-nav__item.is-active {
  background: #0f62fe;
  color: #fff;
  box-shadow: 0 6px 18px rgba(15, 98, 254, 0.28);
  transform: translateY(-2px);
}

.sidebar-nav__item.is-active .sidebar-nav__icon {
  color: inherit;
}


.content-area {
  flex: 1 1 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.page-container {
  width: 100%;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--nav-height) + 120px);
  min-height: 0;
}

.page {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  padding-bottom: calc(var(--nav-height) + 160px);
}

.page.is-active {
  display: block;
}

.social-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #f4f4f4;
  border: 1px solid #e0e0e0;
  transition: all .2s ease;
  text-decoration: none;
}

.social-icon:hover {
  background: #e0e0e0;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.social-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

/* Categories */
.categories {
  width: 100%;
  display: grid;
  gap: 28px;
  padding: 28px 20px 24px;
}

.category {
  width: 100%;
  display: grid;
  gap: 18px;
}

.category h3 {
  font-size: 20px;
  font-weight: 600;
  color: #161616;
  text-align: left;
  letter-spacing: -0.02em;
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 8px;
}

.category-description {
  font-size: 15px;
  color: #4d4d4d;
  text-align: left;
  line-height: 1.5;
}

.category-links {
  display: grid;
  gap: 14px;
  width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.category-subheading {
  grid-column: 1 / -1;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6f6f6f;
  border-top: 1px solid #e6e6e6;
  padding-top: 6px;
  margin-top: 4px;
}

.link-card {
  --card-media-height: clamp(76px, 20vw, 120px);
  display: grid;
  grid-template-rows: var(--card-media-height) auto;
  width: 100%;
  background: #f8f8f8;
  border: 1px solid #e0e0e0;
  text-decoration: none;
  color: #161616;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
  border-radius: 14px;
  overflow: hidden;
}

.link-card:hover {
  background: #fff;
  color: #0f62fe;
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.12);
  border-color: rgba(15, 98, 254, 0.28);
}

.card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 12px 18px;
  background: linear-gradient(135deg, rgba(15, 98, 254, 0.08), rgba(15, 98, 254, 0.02));
  border-bottom: 1px solid rgba(15, 98, 254, 0.12);
}

.card-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-content {
  display: grid;
  gap: 6px;
  padding: 16px 18px 18px;
  align-content: start;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-subtitle {
  font-size: 13px;
  color: #5f5f5f;
  line-height: 1.45;
}

.category--carousel .carousel-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.carousel-viewport {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: transparent;
  touch-action: pan-y;
}

.carousel-track {
  display: flex;
  will-change: transform;
  transition: transform 260ms cubic-bezier(0.33, 1, 0.68, 1);
}

.carousel-slide {
  flex: 0 0 100%;
  display: flex;
  justify-content: center;
  padding: 0;
}

.carousel-card {
  --carousel-media-height: clamp(120px, 32vw, 168px);
  display: grid;
  grid-template-rows: var(--carousel-media-height) auto;
  width: 100%;
  max-width: 320px;
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid #e4e4e4;
  color: #161616;
  text-decoration: none;
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.carousel-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.14);
  border-color: rgba(15, 98, 254, 0.32);
}

.carousel-card-image {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: #f4f4f4;
  border-bottom: 1px solid rgba(15, 98, 254, 0.14);
}

.carousel-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.carousel-card-body {
  display: grid;
  gap: 10px;
  padding: 18px 20px 20px;
}

.carousel-card-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.carousel-card-description {
  font-size: 14px;
  color: #4d4d4d;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.carousel-card-divider {
  width: 100%;
  border: none;
  border-top: 1px solid #e5e5e5;
  margin: 6px 0 0;
}

.carousel-card-cta {
  margin-top: 12px;
  display: inline-flex;
  align-self: flex-start;
  font-weight: 500;
  font-size: 14px;
  color: #0f62fe;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.carousel-card:hover .carousel-card-cta {
  color: #093dc2;
}

.carousel-card:focus-visible {
  outline: 2px solid #0f62fe;
  outline-offset: 4px;
}

.carousel-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: #d0d0d0;
  padding: 0;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.carousel-dot.is-active {
  background: #0f62fe;
  transform: scale(1.3);
}

.carousel-dot:focus-visible {
  outline: 2px solid #0f62fe;
  outline-offset: 2px;
}

/* Contact section (always visible) */
.contact-section {
  padding: 28px 24px;
  border-top: 1px solid #e0e0e0;
  background: #fff;
  overflow: visible;
  min-height: calc(100vh - var(--nav-height) + 160px);
  padding-bottom: calc(200px + var(--safe-bottom) + var(--kb-safe-area));
}

.contact-card {
  position: relative;
  margin-bottom: calc(200px + var(--nav-height));
}

/* Flip */
.flip {
  perspective: 1000px;
}

.flip-inner {
  position: relative;
  transform-style: preserve-3d;
  transition: transform 600ms cubic-bezier(0.2, 0, 0.2, 1);
  /* Height is driven by the tallest face; JS sets --flip-height */
  min-height: var(--flip-height, 340px);
}

.contact-card.flipped .flip-inner {
  transform: rotateY(180deg);
}

.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flip-face.front {
  display: block;
}

.flip-face.back {
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  /* ← stack h3 and p */
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  gap: 6px;
  /* optional: space between lines */
}

.flip-face.back h3 {
  margin: 0;
}

.flip-face.back p {
  margin: 0;
}

/* Contact form */
.contact-form {
  display: none;
  gap: 12px;
  grid-template-rows: auto auto auto auto auto;
}

.contact-form.is-active {
  display: grid;
}

.form-shell h3 {
  font-size: 18px;
  margin-bottom: 4px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 13px;
  color: #525252;
}

.field input,
.field textarea {
  border: 1px solid #c6c6c6;
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
  color: #161616;
  background: #fff;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: #0f62fe;
  box-shadow: 0 0 0 3px rgba(15, 98, 254, 0.15);
}

.helper {
  font-size: 12px;
  color: #a2191f;
  min-height: 16px;
}

.contact-forms {
  margin-top: 12px;
}

[data-contact-form][hidden] {
  display: none !important;
}

.contact-reason-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Actions */
.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
  align-items: center;
}

.btn-primary {
  appearance: none;
  border: none;
  border-radius: 6px;
  padding: 10px 14px;
  background: #0f62fe;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}

.btn-primary:hover {
  background: #0950d3;
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: .7;
  cursor: default;
  transform: none;
}

.submit-spinner {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(15, 98, 254, 0.25);
  border-top-color: #0f62fe;
  border-radius: 50%;
  animation: spinner-rotate 0.8s linear infinite;
  display: none;
}

.contact-form.is-submitting .submit-spinner {
  display: inline-block;
}

.contact-form.is-submitting [data-submit] {
  opacity: 0;
  pointer-events: none;
}

@keyframes spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive */
@media (max-width: 600px) {
  .container {
    margin: 0;
    max-width: 100%;
    border-radius: 0;
    min-height: 100vh;
    box-shadow: none;
  }

  .hero-image {
    height: 150px;
    max-height: 150px;
    padding: 16px 18px;
  }

  .hero-overlay {
    padding: 16px 18px;
  }

  .profile-info {
    width: 100%;
  }

  .profile-name {
    font-size: 24px;
  }

  .profile-username {
    font-size: 15px;
  }

  .social-row {
    padding: 16px;
    gap: 12px;
    flex-wrap: wrap;
  }

  .social-icon {
    width: 44px;
    height: 44px;
  }

  .content-layout {
    padding: 0 16px calc(24px + var(--nav-height));
    gap: 18px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-padding-bottom: calc(var(--nav-height) + 180px);
  }

  .content-layout::-webkit-scrollbar {
    display: none;
  }

  .sidebar-nav {
    width: 100%;
    max-width: 100%;
    padding: 8px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    gap: 10px;
    border-radius: 16px 16px 0 0;
    border-left: none;
    border-right: none;
  }

  .sidebar-nav__item {
    height: 44px;
  }

  .sidebar-nav__icon {
    width: 22px;
    height: 22px;
  }

  .categories {
    padding: 24px 12px 18px;
    gap: 20px;
  }

  .category {
    gap: 14px;
  }

  .category h3 {
    font-size: 18px;
  }

  .category-description {
    font-size: 14px;
  }

  .category-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .link-card {
    --card-media-height: clamp(84px, 32vw, 130px);
  }

  .card-icon {
    padding: 10px 14px;
  }

  .card-content {
    padding: 14px 16px 16px;
    gap: 6px;
  }

  .card-title {
    font-size: 14px;
  }

  .card-subtitle {
    font-size: 12px;
  }

  .page {
    padding-bottom: calc(var(--nav-height) + 200px);
  }

  .category--carousel .carousel-shell {
    gap: 14px;
  }

  .carousel-viewport {
    margin: 0 -16px;
    padding: 0 16px;
  }

  .carousel-card {
    max-width: 100%;
    --carousel-media-height: clamp(132px, 52vw, 180px);
  }

  .carousel-card-body {
    padding: 16px;
    gap: 10px;
  }

  .contact-section {
    padding: 26px 16px calc(160px + var(--safe-bottom) + var(--kb-safe-area));
    min-height: calc(100vh - var(--nav-height) + 140px);
  }

  .contact-card {
    margin-bottom: calc(260px + var(--safe-bottom) + var(--kb-safe-area));
  }

  .flip-inner {
    min-height: var(--flip-height, 340px);
  }
}

/* Toggle Styles */
.toggle-group {
  display: flex;
  background: #f4f4f4;
  border-radius: 8px;
  padding: 4px;
  gap: 4px;
  border: 1px solid #e0e0e0;
}

.toggle-option {
  flex: 1;
  position: relative;
  cursor: pointer;
  margin-bottom: 0;
  /* Override default label margin */
}

.toggle-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  color: #4d4d4d;
  transition: all 0.2s ease;
}

#contact-reason-general:checked~.contact-reason-group .toggle-option[for="contact-reason-general"] span,
#contact-reason-collab:checked~.contact-reason-group .toggle-option[for="contact-reason-collab"] span {
  background: #fff;
  color: #0f62fe;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  font-weight: 600;
}

#contact-reason-general:checked~.contact-forms [data-form-type="general"],
#contact-reason-collab:checked~.contact-forms [data-form-type="collab"] {
  display: grid;
}

#contact-reason-general:checked~.contact-forms [data-form-type="collab"],
#contact-reason-collab:checked~.contact-forms [data-form-type="general"] {
  display: none !important;
}

/* Stats Styles */
.collab-stats {
  margin-bottom: 16px;
  background: #f8f9fa;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #e0e0e0;
  animation: fadeIn 0.4s ease;
}

.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.stats-period-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6f6f6f;
  font-weight: 600;
}

.stats-period-range {
  font-size: 13px;
  color: #525252;
}

.stats-note {
  font-size: 11px;
  color: #8d8d8d;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e0e0e0;
}

.stat-row--extended {
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: #161616;
  display: block;
  line-height: 1.2;
}

.stat-label {
  font-size: 10px;
  color: #6f6f6f;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
  display: block;
}

.chart-section {
  margin-top: 16px;
}

.chart-title {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #4d4d4d;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bar-row {
  display: flex;
  align-items: center;
  font-size: 12px;
}

.bar-label {
  width: 65px;
  color: #525252;
  font-size: 11px;
}

.bar-track {
  flex: 1;
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
  margin: 0 8px;
}

.bar-fill {
  height: 100%;
  background: #0f62fe;
  border-radius: 3px;
  width: 0;
  transition: width 1s cubic-bezier(0.22, 1, 0.36, 1);
}

.bar-value {
  width: 32px;
  text-align: right;
  color: #161616;
  font-weight: 600;
  font-size: 11px;
}

/* Gender Donut (Simplified as bar for now or custom CSS) */
.gender-chart {
  display: flex;
  gap: 4px;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}

.gender-segment {
  height: 100%;
}

.gender-legend {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #525252;
}

.metric-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 6px;
}

.metric-list li {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #525252;
}

.metric-list strong {
  font-weight: 600;
  color: #161616;
}

.metric-note {
  font-size: 12px;
  color: #525252;
  margin-top: 8px;
}
