/*
 * BodyCalc website — styles mirror the iOS app's design system
 * (bmi-bmr-app-last: constants/gradients.ts, constants/calculatorThemes.ts,
 * app/index.tsx home styles, app/settings.tsx list styles).
 *
 * Only app palette colors are used. Two deliberate deviations for web
 * accessibility: secondary text on white uses rgba(0,0,0,0.65) instead of the
 * app's 0.4/0.35/0.25 greys, and helper text on the gradient uses
 * rgba(255,255,255,0.9) instead of 0.58, so small text keeps readable contrast.
 */

:root {
  color-scheme: light;

  /* Ink & surfaces (Settings screen) */
  --ink: #0A0A0A;
  --ink-2: rgba(0, 0, 0, 0.65);
  --ink-3: rgba(0, 0, 0, 0.35);
  --surface: #F5F6FA;
  --card: #FFFFFF;
  --divider: rgba(0, 0, 0, 0.05);
  --tint: #3B8EFF;
  --tint-bg: rgba(59, 142, 255, 0.1);
  /* Text-sized blue: #3B8EFF is 3.2:1 on white, so text uses the BMI accentDeep */
  --tint-ink: #0845CC;

  /* Home gradient (HOME_GRADIENT + HOME_GRADIENT_LOCATIONS) */
  --home-gradient: linear-gradient(180deg,
    #FFFFFF 0%, #D4E8FF 15%, #3B8EFF 35%, #A855F7 55%, #FF7A2E 78%, #CC4200 100%);
  /* Phones: the hero is taller than one screen, so the white head is pinned to
     the top bar (as the app's status-bar zone) instead of 15% of the hero. */
  --home-gradient-tall: linear-gradient(180deg,
    #FFFFFF 0, #D4E8FF 64px, #3B8EFF 220px, #A855F7 55%, #FF7A2E 78%, #CC4200 100%);
  /* The same stops without the white/soft head, for surfaces that carry white text */
  --home-gradient-deep: linear-gradient(135deg,
    #3B8EFF 0%, #A855F7 42%, #FF7A2E 78%, #CC4200 100%);

  /* Glass tiles on the gradient (home grid) */
  --glass: rgba(255, 255, 255, 0.10);
  --glass-hi: rgba(255, 255, 255, 0.14);
  --on-gradient-2: rgba(255, 255, 255, 0.9);

  /* Shape & depth */
  --r-card: 18px;
  --r-tile: 20px;
  --r-icon: 10px;
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.05);
  --shadow-btn: 0 2px 8px rgba(0, 0, 0, 0.08);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --gutter: 20px;
  --max: 1160px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3, p, ul, ol { margin: 0; }

:focus-visible {
  outline: 2px solid var(--tint);
  outline-offset: 3px;
  border-radius: 6px;
}

.skip {
  position: absolute;
  left: 12px;
  top: -80px;
  z-index: 10;
  padding: 10px 16px;
  border-radius: 20px;
  background: var(--card);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-btn);
  text-decoration: none;
}
.skip:focus { top: 12px; }

.container {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.icon { width: 20px; height: 20px; flex: none; }

/* ─── Top bar: brand + round white buttons (home settings button) ─── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.brand img {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  box-shadow: var(--shadow-btn);
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.topbar-link {
  display: none;
  padding: 8px 12px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--ink);
  text-decoration: none;
}
.topbar-link:hover { background: var(--card); }

/* 40px white circle / pill with the app's button shadow */
.round-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border-radius: 20px;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-btn);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
  text-decoration: none;
  transition: transform 0.15s ease;
}
.round-btn.is-circle { padding: 0; width: 40px; }
.round-btn:hover { transform: translateY(-1px); }
.round-btn:active { transform: scale(0.97); }

/* ─── Home hero: the app's Home screen on the web ─── */

.hero {
  position: relative;
  background: var(--home-gradient-tall);
  border-radius: 0 0 32px 32px;
  color: #FFFFFF;
  overflow: hidden;
}

.hero-inner {
  display: grid;
  gap: 28px;
  padding-top: 112px;
  padding-bottom: 32px;
}

.hero-copy { display: grid; gap: 10px; align-content: end; }

.hero h1 {
  font-size: 38px;
  line-height: 44px;
  font-weight: 800;
  letter-spacing: -1.2px;
  max-width: 13ch;
}

.hero .lede {
  font-size: 17px;
  line-height: 1.5;
  color: #FFFFFF;
  max-width: 34ch;
}
.hero h1, .hero .lede { text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
.hero-actions .cta { display: none; }

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.store-badge { display: inline-block; border-radius: 10px; }
.store-badge img { height: 52px; width: auto; }

/* App CTA: white pill, 56 tall, radius 28, 17/600 ink label */
.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 56px;
  padding: 0 26px;
  border-radius: 28px;
  background: #FFFFFF;
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  text-decoration: none;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.cta:hover { transform: translateY(-1px); }
.cta:active { opacity: 0.82; }

/* Glass calculator tiles (home grid) */
.tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  list-style: none;
  padding: 0;
}
.tiles li { flex: 1 1 47%; display: flex; }

.tile {
  position: relative;
  flex: 1;
  display: grid;
  gap: 8px;
  padding: 16px;
  border-radius: var(--r-tile);
  background: var(--glass);
  color: #FFFFFF;
  text-decoration: none;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.tile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tile-label {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.6px;
  line-height: 1.2;
}
.tile-detail {
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0.1px;
  color: var(--on-gradient-2);
}
.tile-dot {
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: #FFFFFF;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.tile:hover, .tile:focus-visible, .tile.is-selected {
  background: var(--glass-hi);
  box-shadow: inset 0 0 0 1.5px #FFFFFF;
}
.tile:hover .tile-dot, .tile:focus-visible .tile-dot, .tile.is-selected .tile-dot {
  opacity: 1;
  transform: scale(1);
}

/* ─── Sections on the light Settings surface ─── */

.section { padding: 64px 0 0; }
.section:last-of-type { padding-bottom: 72px; }

.section-head { display: grid; gap: 8px; margin-bottom: 24px; max-width: 640px; }

/* Settings section label: 12/600 uppercase, tracked */
.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--ink-2);
}

.section h2 {
  font-size: 30px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -1px;
}
.section-head p { color: var(--ink-2); font-size: 17px; }

/* Screenshot gallery */
.gallery {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 230px;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 4px var(--gutter) 20px;
  margin: 0 calc(var(--gutter) * -1);
  list-style: none;
  scrollbar-width: none;
}
.gallery::-webkit-scrollbar { display: none; }
.gallery li { scroll-snap-align: center; }
.gallery img {
  width: 100%;
  height: auto;
  aspect-ratio: 1242 / 2688;
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow-card);
}

/* Calculator cards */
.calc-grid {
  display: grid;
  gap: 16px;
  list-style: none;
  padding: 0;
}
.card {
  background: var(--card);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
}
.calc-card { overflow: hidden; display: flex; flex-direction: column; scroll-margin-top: 24px; }
.calc-card:target { box-shadow: var(--shadow-card), 0 0 0 2px var(--accent); }
.calc-band {
  height: 72px;
  display: flex;
  align-items: flex-end;
  padding: 14px 16px;
  background: linear-gradient(90deg, var(--soft) 0%, var(--accent) 60%, var(--deep) 100%);
}
.calc-band span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--deep);
  box-shadow: var(--shadow-btn);
}
.calc-body { display: grid; gap: 6px; padding: 16px 16px 18px; }
.calc-body h3 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.6px;
  color: var(--deep);
}
.calc-body h3 small {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.1px;
  color: var(--ink-2);
}
.calc-body p { font-size: 15px; line-height: 1.5; }
.calc-body .method { font-size: 13px; color: var(--ink-2); margin-top: 4px; }

.t-bmi     { --soft: #D4E8FF; --accent: #3B8EFF; --deep: #0845CC; }
.t-whtr    { --soft: #D4D5FE; --accent: #7172FB; --deep: #3335CF; }
.t-bmr     { --soft: #FFE0C4; --accent: #FF7A2E; --deep: #CC4200; }
.t-tdee    { --soft: #E5CCFD; --accent: #A855F7; --deep: #7E22CE; }
.t-bodyfat { --soft: #F6CCE1; --accent: #E0559B; --deep: #AD1E6E; }
.t-lbm     { --soft: #FAD2D1; --accent: #F06865; --deep: #C73A31; }
.t-ffmi    { --soft: #F2CAB5; --accent: #D64D09; --deep: #992F00; }

/* Settings-style list: card of rows with 36px tinted icon squares */
.list { list-style: none; padding: 0; }
/* Divider inset past the icon square, as in Settings (marginLeft 66) */
.list > li + li { position: relative; }
.list > li + li::before {
  content: "";
  position: absolute;
  top: 0;
  left: 66px;
  right: 0;
  height: 1px;
  background: var(--divider);
}
.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  color: var(--ink);
  text-decoration: none;
}
.row-icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-icon);
  background: var(--tint-bg);
  color: var(--tint);
}
.row-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row-label { font-size: 15px; font-weight: 600; letter-spacing: -0.2px; line-height: 1.35; }
.row-detail { font-size: 13px; line-height: 1.4; color: var(--ink-2); overflow-wrap: anywhere; }
.row-chevron { flex: none; color: var(--ink-3); }
a.row:hover .row-label { color: var(--tint-ink); }

.feature-grid { display: grid; gap: 16px; }

/* Gradient call-to-action card */
.cta-card {
  display: grid;
  justify-items: start;
  gap: 14px;
  padding: 32px 24px;
  border-radius: 28px;
  background: var(--home-gradient-deep);
  color: #FFFFFF;
}
.cta-card img.app-icon {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}
.cta-card h2 { font-size: 30px; line-height: 1.15; font-weight: 800; letter-spacing: -1px; }
.cta-card p { font-size: 17px; color: #FFFFFF; max-width: 40ch; }

/* ─── Document pages (Privacy, Terms, Support): the Settings screen ─── */

.doc-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}
.doc-bar .doc-bar-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-bar .topbar-actions { justify-self: end; }

.doc {
  display: grid;
  gap: 24px;
  padding-top: 20px;
  padding-bottom: 72px;
}

.doc-hero { display: grid; gap: 10px; max-width: 720px; }
.doc-hero h1 {
  font-size: 34px;
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -1.1px;
}
.doc-hero .meta { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.doc-hero p { font-size: 17px; }
.doc-hero p + p { color: var(--ink-2); }

.toc { padding: 4px 0; }
.toc-side { display: none; }
.toc-side h2 {
  padding: 12px 16px 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--ink-2);
}
.toc summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}
.toc summary::-webkit-details-marker { display: none; }
.toc summary .icon { color: var(--ink-3); transition: transform 0.2s ease; transform: rotate(90deg); }
.toc[open] summary .icon { transform: rotate(-90deg); }
.toc ol {
  list-style: none;
  padding: 0 0 8px;
  margin: 0;
  counter-reset: toc;
}
.toc li a {
  display: flex;
  gap: 10px;
  padding: 7px 16px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink-2);
  text-decoration: none;
}
.toc li a:hover { color: var(--tint-ink); }
.toc li a .n { flex: none; min-width: 20px; font-variant-numeric: tabular-nums; color: var(--tint-ink); font-weight: 600; }

.doc-layout { display: grid; gap: 16px; }
.doc-sections { display: grid; gap: 16px; min-width: 0; }
.doc-section { scroll-margin-top: 24px; }
.doc-section .card { padding: 20px 18px; }
.doc-section h2 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 19px;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-bottom: 10px;
}
.doc-section h2 .n {
  flex: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--tint-ink);
  font-variant-numeric: tabular-nums;
}

.prose { font-size: 16px; line-height: 1.6; overflow-wrap: break-word; }
.prose > * + * { margin-top: 12px; }
.prose ul, .prose ol { padding-left: 0; list-style: none; display: grid; gap: 6px; }
.prose ul > li { position: relative; padding-left: 18px; }
.prose ul > li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.62em;
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: var(--tint);
}
.prose ol { counter-reset: step; }
.prose ol > li { position: relative; padding-left: 30px; counter-increment: step; }
.prose ol > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.1em;
  width: 22px;
  height: 22px;
  border-radius: 11px;
  background: var(--tint-bg);
  color: var(--tint-ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
}
.prose a { color: var(--tint-ink); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.prose strong { font-weight: 600; }
.prose .note {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--tint-bg);
  font-size: 15px;
}

.quick { margin-top: 4px; }

/* ─── Footer ─── */

.footer {
  border-top: 1px solid var(--divider);
  padding: 32px 0 max(32px, env(safe-area-inset-bottom));
  font-size: 13px;
  color: var(--ink-2);
}
.footer-inner { display: grid; gap: 18px; }
.footer-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.footer nav ul { display: flex; flex-wrap: wrap; gap: 6px 18px; list-style: none; padding: 0; }
.footer nav a { color: var(--ink); font-weight: 600; font-size: 14px; text-decoration: none; }
.footer nav a:hover { color: var(--tint-ink); }
.footer .brand { font-size: 15px; }
.footer .brand img { width: 28px; height: 28px; border-radius: 7px; }
.footer p { max-width: 72ch; }

/* ─── 404 ─── */

.page-404 {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  background: var(--home-gradient);
  padding: 24px var(--gutter);
}
.page-404 main { display: grid; gap: 14px; justify-items: center; text-align: center; color: #FFFFFF; max-width: 520px; }
.page-404 h1 { font-size: 38px; line-height: 44px; font-weight: 800; letter-spacing: -1.2px; }
.page-404 p { font-size: 17px; color: #FFFFFF; }
.page-404 .app-icon { width: 88px; height: 88px; border-radius: 20px; box-shadow: var(--shadow-btn); }
.page-404 .actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 8px; }

/* ─── Larger screens ─── */

@media (min-width: 700px) {
  :root { --gutter: 32px; }
  .topbar-link { display: inline-flex; }
  .hero-actions .cta { display: inline-flex; }
  .hero h1 { font-size: 52px; line-height: 1.05; letter-spacing: -1.8px; }
  .gallery {
    grid-auto-flow: row;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow: visible;
    padding: 4px 0 0;
    margin: 0;
  }
  .calc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* The odd seventh card (FFMI) closes the grid full width, like the app's home grid */
  .calc-grid > li:last-child { grid-column: 1 / -1; }
  .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .cta-card { padding: 48px; grid-template-columns: auto 1fr auto; align-items: center; column-gap: 28px; }
  .cta-card .cta-text { display: grid; gap: 8px; }
  .doc-section .card { padding: 24px 26px; }
  .doc-hero h1 { font-size: 44px; letter-spacing: -1.5px; }
}

@media (min-width: 1024px) {
  .hero { background: var(--home-gradient); }
  .hero-inner {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    align-items: center;
    column-gap: 64px;
    min-height: 760px;
    padding-top: 150px;
    padding-bottom: 72px;
  }
  .hero h1 { font-size: 64px; letter-spacing: -2.2px; }
  .hero .lede { font-size: 19px; }
  .calc-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .doc-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 32px;
    align-items: start;
  }
  .doc-layout .toc-side { display: block; position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow: auto; }
  .doc-layout .toc-inline { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
