/* =========================================================
   BMI Calculator — style.css
   Design language: "instrument readout" — a digital scale
   display paired with a measuring-tape tick rhythm.
   ========================================================= */

/* ---------- Design tokens ---------- */
:root {
  /* Brand colors */
  --ink: #14213D;          /* primary text, dark navy */
  --teal: #1F6F6B;         /* primary brand color */
  --teal-dark: #164F4C;
  --amber: #F2A93B;        /* accent — CTA, gauge marker */
  --amber-dark: #D98F1F;

  /* Neutrals */
  --paper: #F5F7F4;        /* page background */
  --surface: #FFFFFF;      /* card surface */
  --line: #DDE3DE;         /* hairline borders */
  --muted: #5B6B66;        /* secondary text */

  /* Category colors (never used alone — always paired with text/icon) */
  --cat-under: #3E7CB8;
  --cat-normal: #2E8F63;
  --cat-over: #D98F1F;
  --cat-obese: #C0503F;

  /* Type */
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;

  /* Layout */
  --maxw: 1120px;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 10px rgba(20, 33, 61, 0.06), 0 12px 32px rgba(20, 33, 61, 0.06);
  --header-h: 72px;

  color-scheme: light;
}

[data-theme="dark"] {
  --ink: #E7ECEF;
  --teal: #4FBDB6;
  --teal-dark: #2E8A84;
  --amber: #F2B75C;
  --amber-dark: #D99A2E;

  --paper: #0F1720;
  --surface: #182430;
  --line: #2A3946;
  --muted: #9DB0AC;

  --cat-under: #6FA8DC;
  --cat-normal: #5FBF8E;
  --cat-over: #E3A94A;
  --cat-obese: #E07A68;

  --shadow: 0 2px 12px rgba(0, 0, 0, 0.35), 0 20px 40px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

/* ---------- Reset ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img, svg { display: block; max-width: 100%; }
button { font-family: inherit; }
ul { margin: 0; padding: 0; }

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

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
  overflow-x: hidden;
}

a { color: var(--teal-dark); text-decoration: none; }
[data-theme="dark"] a { color: var(--teal); }
a:hover { text-decoration: underline; }

h1, h2, h3 {
  font-family: var(--font-display);
  color: var(--ink);
  line-height: 1.15;
  margin: 0 0 0.5em;
  font-optical-sizing: auto;
}

h1 { font-size: clamp(2.2rem, 4.5vw, 3.4rem); font-weight: 600; }
h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); font-weight: 600; }
h3 { font-size: 1.15rem; font-weight: 600; }

p { margin: 0 0 1em; color: var(--ink); }
.muted { color: var(--muted); }

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Focus visibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--amber-dark);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Tick-rule divider — the site's recurring measurement motif */
.tick-rule {
  height: 14px;
  background-image: repeating-linear-gradient(
    to right,
    var(--line) 0, var(--line) 1px, transparent 1px, transparent 12px
  );
  background-position: bottom;
  background-size: 100% 10px;
  background-repeat: repeat-x;
  border-bottom: 1px solid var(--line);
  margin: 0 0 48px;
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  z-index: 200;
  border-radius: 0 0 8px 0;
}
.skip-link:focus {
  left: 0;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  height: var(--header-h);
  display: flex;
  align-items: center;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--ink);
}
.brand:hover { text-decoration: none; }
.brand svg { width: 34px; height: 34px; flex-shrink: 0; }
.brand .brand-compact { display: none; }

.main-nav {
  display: flex;
  align-items: center;
  gap: 28px;
}
.main-nav a {
  color: var(--ink);
  font-size: 0.97rem;
  font-weight: 500;
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
}
.main-nav a:hover,
.main-nav a[aria-current="page"] {
  border-bottom-color: var(--amber);
  text-decoration: none;
}

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

.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink);
  transition: transform 0.2s ease, background-color 0.2s ease;
}
.theme-toggle:hover { transform: rotate(15deg); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.nav-toggle svg { width: 20px; height: 20px; color: var(--ink); }

@media (max-width: 820px) {
  .main-nav {
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px 24px 16px;
    display: none;
    box-shadow: var(--shadow);
  }
  .main-nav.open { display: flex; }
  .main-nav a {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
  }
  .nav-toggle { display: inline-flex; }
  .brand .brand-full { display: none; }
  .brand .brand-compact { display: inline; }
}

/* ---------- Hero ---------- */
.hero {
  padding: 64px 0 40px;
}
.hero .container {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
  align-items: center;
}
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal-dark);
  background: rgba(31, 111, 107, 0.08);
  padding: 6px 12px;
  border-radius: 999px;
  margin-bottom: 18px;
}
[data-theme="dark"] .hero-eyebrow { color: var(--teal); background: rgba(79, 189, 182, 0.12); }

.hero p.lead {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 46ch;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 1rem;
  padding: 14px 26px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
  font-family: var(--font-body);
}
.btn-primary {
  background: var(--amber);
  color: #1A1204;
}
.btn-primary:hover { background: var(--amber-dark); transform: translateY(-1px); }
.btn-secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-secondary:hover { border-color: var(--teal); color: var(--teal-dark); }
[data-theme="dark"] .btn-secondary:hover { color: var(--teal); }

.hero-actions { display: flex; gap: 14px; margin-top: 8px; flex-wrap: wrap; }

/* Hero dial illustration */
.hero-dial-wrap { display: flex; justify-content: center; }
.hero-dial { width: min(320px, 100%); height: auto; }
.dial-needle {
  transform-origin: 160px 160px;
  animation: needle-settle 1.6s cubic-bezier(.2,.9,.25,1) 0.2s both;
}
@keyframes needle-settle {
  0% { transform: rotate(-70deg); }
  60% { transform: rotate(28deg); }
  100% { transform: rotate(14deg); }
}
@media (prefers-reduced-motion: reduce) {
  .dial-needle { animation: none; transform: rotate(14deg); }
}

@media (max-width: 900px) {
  .hero .container { grid-template-columns: 1fr; text-align: left; }
  .hero-dial-wrap { order: -1; margin-bottom: 8px; }
  .hero-dial { width: 200px; }
}

/* ---------- Ad slots ---------- */
.ad-slot {
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 18px;
  margin: 32px auto;
}
.ad-slot-banner { max-width: var(--maxw); min-height: 90px; margin-left: 24px; margin-right: 24px; }
.ad-slot-inline { min-height: 100px; }
.ad-slot-sidebar { min-height: 250px; }

/* ---------- Calculator ---------- */
.calculator-section { padding: 8px 0 56px; }
.calculator-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.unit-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  background: var(--paper);
  margin-bottom: 24px;
}
.unit-switch button {
  border: none;
  background: transparent;
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
}
.unit-switch button[aria-pressed="true"] {
  background: var(--teal);
  color: #fff;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}
.field .hint { font-size: 0.78rem; color: var(--muted); }

.input-row { display: flex; gap: 10px; }
.input-suffix-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}
input[type="number"], input[type="text"], select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  font-family: var(--font-body);
  transition: border-color 0.15s ease;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { margin-left: 4px; }
input:focus, select:focus { border-color: var(--teal); }
.input-suffix {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.82rem;
  color: var(--muted);
  pointer-events: none;
}

fieldset.field {
  border: none;
  padding: 0;
  margin: 0;
}
.radio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-pill {
  position: relative;
}
.radio-pill input {
  position: absolute;
  opacity: 0;
  width: 100%; height: 100%;
  cursor: pointer;
  margin: 0;
}
.radio-pill span {
  display: inline-flex;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.88rem;
  color: var(--ink);
  cursor: pointer;
}
.radio-pill input:checked + span {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}
.radio-pill input:focus-visible + span {
  outline: 3px solid var(--amber-dark);
  outline-offset: 2px;
}

.field-error {
  font-size: 0.8rem;
  color: var(--cat-obese);
  min-height: 1.1em;
}
input[aria-invalid="true"] { border-color: var(--cat-obese); }

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 26px;
  flex-wrap: wrap;
}

/* ---------- Results ---------- */
.results-panel {
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  display: none;
}
.results-panel.visible {
  display: block;
  animation: fade-up 0.35s ease both;
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.readout {
  display: flex;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
  background: var(--ink);
  border-radius: var(--radius);
  padding: 24px 28px;
  color: var(--paper);
}
[data-theme="dark"] .readout { background: #0B1116; }
.readout-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(245, 247, 244, 0.6);
  margin-bottom: 6px;
}
.readout-value {
  font-family: var(--font-mono);
  font-size: clamp(2.6rem, 8vw, 4.2rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--amber);
  line-height: 1;
}
.readout-category {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: #fff;
}
.readout-category .cat-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 8px;
}

.gauge-wrap { margin-top: 28px; }
.gauge-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 6px;
}
.gauge-track {
  position: relative;
  height: 16px;
  border-radius: 999px;
  overflow: visible;
  display: flex;
}
.gauge-seg { height: 100%; }
.gauge-seg:first-child { border-radius: 999px 0 0 999px; }
.gauge-seg:last-child { border-radius: 0 999px 999px 0; }
.gauge-seg.under { background: var(--cat-under); flex: 18.5; }
.gauge-seg.normal { background: var(--cat-normal); flex: 6.4; }
.gauge-seg.over { background: var(--cat-over); flex: 5; }
.gauge-seg.obese { background: var(--cat-obese); flex: 10; }
.gauge-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--muted);
  font-family: var(--font-mono);
}
.gauge-marker {
  position: absolute;
  top: -10px;
  width: 3px;
  height: 34px;
  background: var(--ink);
  border-radius: 2px;
  transform: translateX(-50%);
  transition: left 0.4s cubic-bezier(.2,.9,.25,1);
}
[data-theme="dark"] .gauge-marker { background: #fff; }
.gauge-marker::after {
  content: attr(data-bmi);
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 24px;
}
.result-stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.result-stat .stat-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.result-stat .stat-value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.05rem;
}

.teen-notice {
  background: rgba(31, 111, 107, 0.08);
  border: 1px solid rgba(31, 111, 107, 0.25);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  margin-top: 20px;
}
[data-theme="dark"] .teen-notice { background: rgba(79,189,182,0.1); }

.result-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-ghost:hover { border-color: var(--teal); }
.btn-ghost svg { width: 16px; height: 16px; }

.status-msg {
  font-size: 0.85rem;
  color: var(--teal-dark);
  margin-top: 8px;
  min-height: 1.2em;
}
[data-theme="dark"] .status-msg { color: var(--teal); }

/* History */
.history-block { margin-top: 28px; }
.history-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin: 12px 0 0; }
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}
.history-empty { color: var(--muted); font-size: 0.88rem; }
.link-danger { color: var(--cat-obese); font-size: 0.82rem; background: none; border: none; cursor: pointer; padding: 0; }
.link-danger:hover { text-decoration: underline; }

/* ---------- Disclaimer callout ---------- */
.disclaimer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber-dark);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  font-size: 0.92rem;
  color: var(--muted);
  margin: 40px 0;
}
.disclaimer strong { color: var(--ink); }

/* ---------- Education sections ---------- */
.section { padding: 48px 0; }
.section-heading { max-width: 62ch; }

.bmi-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  font-size: 0.95rem;
}
.bmi-table caption { text-align: left; font-size: 0.85rem; color: var(--muted); margin-bottom: 8px; }
.bmi-table th, .bmi-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.bmi-table th { font-family: var(--font-mono); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.bmi-table td .cat-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; }

.two-col {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 40px;
  align-items: start;
}
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}

.limits-list { list-style: none; display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.limits-list li {
  padding-left: 26px;
  position: relative;
  color: var(--ink);
}
.limits-list li::before {
  content: "";
  position: absolute;
  left: 0; top: 8px;
  width: 12px; height: 2px;
  background: var(--amber-dark);
}

/* ---------- FAQ ---------- */
.faq-list { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.faq-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.faq-item summary {
  padding: 16px 18px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--teal-dark);
  transition: transform 0.2s ease;
  margin-left: 12px;
  flex-shrink: 0;
}
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-answer {
  padding: 0 18px 18px;
  color: var(--muted);
}
.faq-item[open] .faq-answer {
  animation: fade-up 0.25s ease both;
}

/* ---------- CTA banner ---------- */
.cta-banner {
  background: var(--teal);
  color: #fff;
  border-radius: var(--radius);
  padding: 36px;
  text-align: center;
  margin: 8px 0 0;
}
.cta-banner h2 { color: #fff; }
.cta-banner .btn-primary { }

/* ---------- Static content pages ---------- */
.page-hero { padding: 56px 0 24px; }
.content-block { max-width: 72ch; }
.content-block h2 { margin-top: 2em; }
.content-block ul, .content-block ol { margin: 0 0 1em 1.2em; }
.content-block li { margin-bottom: 0.4em; }
.placeholder-tag {
  background: rgba(242, 169, 59, 0.18);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.contact-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 480px;
  margin-top: 24px;
}
.contact-card .email-line {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  margin-top: 8px;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 40px 0 28px;
  margin-top: 24px;
}
.footer-top {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
}
.footer-brand svg { width: 26px; height: 26px; }
.footer-tagline { color: var(--muted); font-size: 0.88rem; margin-top: 4px; }
.footer-links {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  list-style: none;
}
.footer-links a { color: var(--muted); font-size: 0.9rem; }
.footer-links a:hover { color: var(--teal-dark); }
[data-theme="dark"] .footer-links a:hover { color: var(--teal); }
.footer-bottom {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .results-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .calculator-card { padding: 22px; }
  .footer-top { flex-direction: column; }
}
