/* ──────────────────────────────────────────────────────────
   BMI Calculator — Premium Dark Styles
   Mobile-first, accessible, fast
   ────────────────────────────────────────────────────────── */

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

:root {
  --bg: #0b0f19;
  --surface: #111827;
  --surface-2: #1a2236;
  --surface-3: #1e293b;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #22c55e;
  --accent-soft: #16a34a;
  --accent-glow: rgba(34, 197, 94, 0.25);
  --border: rgba(148, 163, 184, 0.15);
  --error: #ef4444;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 40px rgba(0,0,0,0.4);
  --shadow-sm: 0 4px 16px rgba(0,0,0,0.2);
  --transition: 0.2s ease;

  /* BMI gauge colours */
  --bmi-blue: #3b82f6;
  --bmi-green: #22c55e;
  --bmi-yellow: #eab308;
  --bmi-orange: #f97316;
  --bmi-red: #ef4444;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 16px;
  background: var(--accent);
  color: #000;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  z-index: 1000;
  transition: var(--transition);
}
.skip-link:focus { top: 16px; }

/* Container */
.container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 20px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11,15,25,0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.5px;
}
.logo:hover { color: var(--accent); }

.nav-links {
  display: flex;
  gap: 32px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: var(--transition);
}
.nav-link:hover { color: var(--text); }

/* Hero */
.hero {
  padding: 72px 0 48px;
  text-align: center;
  background:
    radial-gradient(ellipse 60% 60% at 50% 0%, rgba(34,197,94,0.08), transparent 70%),
    radial-gradient(ellipse 40% 40% at 60% 60%, rgba(59,130,246,0.04), transparent 70%);
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -1.5px;
  margin: 0 0 16px;
  line-height: 1.1;
}

.hero-subtitle {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto;
}

/* Calculator layout */
.calculator-grid {
  display: grid;
  gap: 32px;
  padding-bottom: 48px;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .calculator-grid {
    grid-template-columns: 340px 1fr;
    padding-bottom: 72px;
  }
}

/* Input panel */
.input-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: max-content;
}

.field-group { display: flex; flex-direction: column; gap: 6px; }

.field-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input, .select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 1rem;
  font-family: inherit;
  transition: var(--transition);
  width: 100%;
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Toggle row */
.toggle-row {
  display: flex;
  gap: 8px;
}
.toggle-btn {
  flex: 1;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: var(--transition);
}
.toggle-btn:hover { color: var(--text); }
.toggle-btn.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

/* Split row (ft/in) */
.split-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-hint {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: -2px;
}

.hidden { display: none !important; }

/* Calculate button */
.btn-calculate {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 4px;
}
.btn-calculate:hover {
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.btn-calculate:active { transform: translateY(0); }

/* Output panel */
.output-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

.result-header {
  text-align: center;
  margin-bottom: 28px;
}

.result-bmi-wrap {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 28px 20px;
}

.result-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.result-bmi {
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 800;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: 8px;
}

.result-category {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
}
.result-category.cat-blue  { color: var(--bmi-blue); }
.result-category.cat-green { color: var(--bmi-green); }
.result-category.cat-yellow{ color: var(--bmi-yellow); }
.result-category.cat-orange{ color: var(--bmi-orange); }
.result-category.cat-red   { color: var(--bmi-red); }

/* Gauge */
.gauge-wrap {
  margin-bottom: 28px;
}

.gauge-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  padding: 0 2px;
}

.gauge-track {
  position: relative;
  height: 18px;
  border-radius: 9px;
  overflow: hidden;
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.gauge-seg {
  height: 100%;
}
.gauge-seg.seg-under   { background: var(--bmi-blue);  flex: 3.5; }  /* 15–18.5  */
.gauge-seg.seg-normal  { background: var(--bmi-green); flex: 6.4; }  /* 18.5–25  */
.gauge-seg.seg-over    { background: var(--bmi-yellow);flex: 5.0; }  /* 25–30    */
.gauge-seg.seg-obese1  { background: var(--bmi-orange);flex: 5.0; }  /* 30–35    */
.gauge-seg.seg-obese2  { background: var(--bmi-red);    flex: 5.0; }  /* 35–40    */
.gauge-seg.seg-obese3  { background: var(--bmi-red);    flex: 2.5; }  /* 40–45    */

.gauge-marker {
  position: absolute;
  top: -4px;
  width: 4px;
  height: 26px;
  background: #fff;
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(255,255,255,0.6);
  transform: translateX(-50%);
  left: 0%; /* JS updates this */
  transition: left 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.gauge-legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.dot::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot-under::before   { background: var(--bmi-blue); }
.dot-normal::before  { background: var(--bmi-green); }
.dot-over::before    { background: var(--bmi-yellow); }
.dot-obese::before   { background: var(--bmi-red); }

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 28px;
}

@media (min-width: 600px) {
  .stats-row.bmi-stats { grid-template-columns: 1fr 1fr; }
}

.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: clamp(1rem, 2.5vw, 1.35rem);
  font-weight: 700;
  word-break: break-word;
}
.stat-value.accent { color: var(--accent); }
.stat-value.muted  { color: var(--text-muted); font-size: 0.95rem; }

/* Breakdown / category table */
.breakdown-details {
  margin-top: 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 16px;
}
.breakdown-details summary {
  cursor: pointer;
  padding: 16px 8px;
  font-weight: 600;
  color: var(--text-muted);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}
.breakdown-details summary:hover { color: var(--text); }
.breakdown-details summary::before {
  content: '▶';
  font-size: 0.7rem;
  display: inline-block;
  transition: transform 0.2s ease;
}
.breakdown-details[open] summary::before { transform: rotate(90deg); }

.table-wrap { padding: 8px 8px 16px; }
#category-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
#category-table th, #category-table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
#category-table th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.4px; }
#category-table tbody tr:hover { background: rgba(255,255,255,0.03); }
#category-table tbody tr:last-child td { border-bottom: none; }

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #000;
}
.pill-blue   { background: var(--bmi-blue); }
.pill-green  { background: var(--bmi-green); }
.pill-yellow { background: var(--bmi-yellow); }
.pill-orange { background: var(--bmi-orange); }
.pill-red    { background: var(--bmi-red); }

/* SEO Article */
.seo-article {
  max-width: 780px;
  padding: 48px 20px 64px;
}
.seo-article h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 16px;
}
.seo-article h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 32px 0 12px;
  color: var(--accent);
}
.seo-article p {
  color: var(--text-muted);
  margin: 0 0 16px;
}

.formula-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin: 16px 0;
  text-align: center;
  overflow-x: auto;
}
.formula-box code {
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  color: var(--accent);
  background: none;
  padding: 0;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  overflow: hidden;
}
.faq-item summary {
  cursor: pointer;
  padding: 16px 20px;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition);
}
.faq-item summary:hover { background: var(--surface-2); }
.faq-item summary::before {
  content: '+';
  font-size: 1.2rem;
  color: var(--accent);
  width: 20px;
  display: inline-block;
}
.faq-item[open] summary::before { content: '−'; }
.faq-item p {
  padding: 0 20px 16px;
  margin: 0;
  color: var(--text-muted);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 36px 0;
}
.footer-grid {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
}
.footer-links {
  display: flex;
  gap: 24px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.footer-links a { color: var(--text-muted); text-decoration: none; font-size: 0.9rem; }
.footer-links a:hover { color: var(--accent); }
.small { font-size: 0.85rem; color: var(--text-dim); }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .gauge-marker { transition: none; }
}

/* Print */
@media print {
  .site-header, .site-footer, .gauge-wrap, .breakdown-details, .cookie-banner { display: none; }
  body { background: #fff; color: #000; }
  .input-panel { border: 1px solid #ccc; }
}

/* Cookie banner */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  z-index: 200;
  transition: transform 0.3s ease;
}
.cookie-banner.hidden { transform: translateY(110%); }
.cookie-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.cookie-content span { font-size: 0.85rem; color: var(--text-muted); }
.cookie-content a { color: var(--accent); }
.btn-cookie {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 8px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}
.btn-cookie:hover { background: var(--accent-soft); }
