/* Coach Bhai — free calculator tools (/tools/).
   Loads AFTER /blog/blog.css and only adds tokens/components; every colour,
   radius, shadow and container token from blog.css is reused as-is so these
   pages read as a sibling of the blog, not a rebrand.
   Spec: docs/seo-calculators-design-spec.md */

:root {
  /* Result-tone system — same semantic family as the app's dark-theme
     success/warning/error tokens, re-tuned darker for 4.5:1+ text contrast on
     light surfaces. Deliberately NOT --accent-gold: that colour means
     "clickable" on this site, and a warning that looks like a link is worse
     than no colour at all. */
  --tone-low:       #3355CC;  /* underweight / below-range — blue */
  --tone-low-bg:    #EEF1FC;
  --tone-good:      #167A47;  /* healthy / fit — green */
  --tone-good-bg:   #EAF6EF;
  --tone-warn:      #8A5A00;  /* overweight / average / elevated risk — amber */
  --tone-warn-bg:   #FBF2DE;
  --tone-high:      #C81E3A;  /* obese / high risk — crimson, never the brand ember */
  --tone-high-bg:   #FBEAED;

  /* The one flourish: the result numeral. Bebas Neue is already loaded by the
     same Google Fonts link the blog pages use. */
  --font-display:   'Bebas Neue', 'Oswald', Impact, sans-serif;

  --max-tool: 560px;   /* calculators are single-column instruments, not prose */

  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-7: 32px; --space-8: 48px;
  --space-9: 64px;

  --ease-out-spring: cubic-bezier(0.22, 1, 0.36, 1); /* critically damped, no overshoot */
}

/* `hidden` must win over the component display rules below — a hidden ft/in
   input pair that still lays out is two calculators stacked on top of each
   other, which is exactly what shipped in the first render. */
[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;
}

/* ── Containers ─────────────────────────────────────────────────────── */
.tool-shell { max-width: var(--max-tool); margin: 0 auto; padding: 24px 20px 0; }
.tool-prose { max-width: var(--max); margin: 0 auto; padding: 0 20px; }
.tool-wide  { max-width: var(--max-wide); margin: 0 auto; padding: 0 20px; }

/* ── Hero ───────────────────────────────────────────────────────────── */
.tool-hero { padding-bottom: var(--space-4); }
.tool-hero h1 { font-size: 28px; margin: 6px 0 10px; }
.tool-hero-sub { display: inline-block; font-size: 0.6em; font-weight: 500; color: var(--text-muted); }
.tool-hero-lede { font-size: 17px; color: var(--text-secondary); margin: 0 0 var(--space-3); }
.page-note {
  font-size: 13px; line-height: 1.6; color: var(--text-muted);
  background: var(--bg-cream); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px; margin: 0;
}
@media (min-width: 1024px) {
  .tool-hero h1 { font-size: 40px; line-height: 1.15; }
}

/* ── Calculator card ────────────────────────────────────────────────── */
.calc-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: var(--space-6) var(--space-5);
  margin-top: var(--space-4);
}
.field-group + .field-group { margin-top: var(--space-5); }
.field-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); margin-bottom: 6px; flex-wrap: wrap;
}
.field-group label.field-label,
.field-group legend.field-label {
  font-size: 14px; font-weight: 700; color: var(--text-primary); line-height: 1.4;
  padding: 0;
}

.input-wrap { position: relative; }
.input-wrap input {
  width: 100%; height: 52px; font-size: 17px; font-family: inherit;
  color: var(--text-primary); background: var(--bg-surface);
  border: 1.5px solid var(--border); border-radius: 10px;
  padding: 0 44px 0 14px; -moz-appearance: textfield;
}
.input-wrap input::-webkit-outer-spin-button,
.input-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-wrap input:hover { border-color: var(--border-strong); }
.input-suffix {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  font-size: 14px; color: var(--text-muted); pointer-events: none;
}
.input-wrap--split { display: flex; gap: var(--space-3); }
.input-wrap--split .split-part { position: relative; flex: 1; min-width: 0; }

/* Focus ring — ember-tinted, never removed. */
.input-wrap input:focus-visible,
.unit-toggle button:focus-visible,
.seg-toggle button:focus-visible,
.calc-btn:focus-visible,
.share-btn:focus-visible,
.who-info:focus-visible,
.optin-form input:focus-visible,
.optin-form button:focus-visible,
.activity-card input:focus-visible + .activity-body {
  outline: none;
  box-shadow: 0 0 0 3px rgba(232, 65, 10, 0.28), 0 0 0 1.5px var(--accent-gold) inset;
}

.field-group[data-invalid="true"] .input-wrap input { border-color: var(--tone-high); }
.field-error {
  display: flex; align-items: flex-start; gap: 6px;
  font-size: 13px; color: var(--tone-high); margin: 6px 0 0; line-height: 1.4;
}
.field-error svg { flex: 0 0 auto; margin-top: 2px; }

/* ── Segmented toggles (unit + gender) ──────────────────────────────── */
.unit-toggle, .seg-toggle {
  display: inline-flex; background: var(--bg-cream);
  border-radius: 999px; padding: 3px; gap: 2px;
}
.unit-toggle button, .seg-toggle button {
  min-width: 52px; min-height: 32px; border: none; border-radius: 999px;
  background: transparent; font-size: 13px; font-weight: 700;
  font-family: inherit; color: var(--text-muted); cursor: pointer; padding: 0 12px;
  transition: background 150ms, color 150ms;
}
.unit-toggle button[aria-checked="true"], .seg-toggle button[aria-checked="true"] {
  background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-sm);
}
.seg-toggle { display: flex; width: 100%; }
.seg-toggle button { flex: 1; min-height: 44px; font-size: 15px; }

/* ── Activity radio-cards (TDEE) ────────────────────────────────────── */
.activity-group { border: none; margin: 0; padding: 0; }
.activity-group .field-label { display: block; margin-bottom: var(--space-3); }
.activity-card { display: block; position: relative; cursor: pointer; }
.activity-card + .activity-card { margin-top: var(--space-2); }
.activity-card input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.activity-body {
  display: flex; align-items: flex-start; gap: var(--space-3);
  min-height: 56px; padding: 12px 16px;
  border: 1.5px solid var(--border); border-radius: 12px;
  background: var(--bg-surface); transition: border-color 150ms, background 150ms;
}
.activity-card:hover .activity-body { border-color: var(--border-strong); }
.activity-card input:checked + .activity-body {
  border-color: var(--accent-gold); background: rgba(232, 65, 10, 0.05);
}
.activity-dot {
  flex: 0 0 auto; width: 18px; height: 18px; margin-top: 3px;
  border: 2px solid var(--border-strong); border-radius: 50%; background: var(--bg-surface);
}
.activity-card input:checked + .activity-body .activity-dot {
  border-color: var(--accent-gold); box-shadow: inset 0 0 0 4px var(--accent-gold);
}
.activity-text { display: flex; flex-direction: column; gap: 2px; }
.activity-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.activity-desc { font-size: 13px; color: var(--text-muted); line-height: 1.45; }

/* ── Calculate button ───────────────────────────────────────────────── */
.calc-btn {
  width: 100%; min-height: 52px; margin-top: var(--space-6);
  border: none; border-radius: 12px; cursor: pointer;
  background: var(--grad-ember); color: #FFFFFF;
  font-family: inherit; font-weight: 700; font-size: 16px;
  box-shadow: 0 4px 14px rgba(255, 90, 22, 0.30);
  transition: transform 150ms var(--ease-out-spring), opacity 150ms;
}
.calc-btn:active:not(:disabled) { transform: scale(0.98); }
.calc-btn:disabled {
  background: var(--border-strong); box-shadow: none;
  color: var(--text-muted); cursor: not-allowed; opacity: 0.6;
}

/* ── Result region ──────────────────────────────────────────────────── */
.result {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: var(--space-6) var(--space-5);
  margin-top: var(--space-4);
  /* Reserve the populated footprint so the reveal never shifts layout (CLS). */
  min-height: 268px;
  display: flex; flex-direction: column; justify-content: center;
}
.result-empty { text-align: center; color: var(--text-muted); }
.result-empty svg { color: var(--border-strong); }
.result-empty p { margin: var(--space-3) 0 0; font-size: 15px; }
/* Set when every field passed its own bounds but the numbers cannot coexist —
   the same red the field-level errors use, so it reads as a correction and not
   as the neutral "waiting for input" prompt. */
.result-empty[data-tone="error"] p { color: var(--tone-high); font-weight: 600; }

.scale { position: relative; padding-top: 22px; margin: var(--space-2) 0 var(--space-6); }
.scale-track {
  height: 14px; border-radius: 999px; display: flex; overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}
/* An explicit percentage basis, not flex-grow: grow factors summing to under 1
   only absorb that fraction of the track (see renderScale's comment). Widths
   are handed in already normalised to 100%, so no grow and no shrink. */
.scale-seg { flex: 0 0 var(--seg-weight, 100%); }
.scale-seg[data-tone="low"]  { background: var(--tone-low); }
.scale-seg[data-tone="good"] { background: var(--tone-good); }
.scale-seg[data-tone="warn"] { background: var(--tone-warn); }
.scale-seg[data-tone="high"] { background: var(--tone-high); }
.scale-marker {
  position: absolute; top: 0; left: var(--pos, 0%); transform: translateX(-50%);
  width: 22px; height: 22px; border-radius: 50%;
  background: #FFFFFF; border: 3px solid var(--text-primary);
  box-shadow: var(--shadow-md);
  transition: left 800ms var(--ease-out-spring);
}
.scale-marker::after {
  content: ''; position: absolute; left: 50%; top: 22px; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--text-primary);
}
.scale-legend {
  display: flex; justify-content: space-between;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted); margin-top: 8px;
}

.result-headline { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.result-number {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(3.5rem, 18vw, 4.75rem); line-height: 0.9;
  letter-spacing: -0.01em; color: var(--text-primary);
}
.result-unit {
  font-size: 15px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-muted);
}
@media (min-width: 1024px) { .result-number { font-size: 4.75rem; } }

.result-badge {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 32px; padding: 5px 13px; border-radius: 999px;
  font-size: 14px; font-weight: 700; margin-top: var(--space-4);
  border: 1px solid currentColor;
}
.result-badge[data-tone="low"]  { color: var(--tone-low);  background: var(--tone-low-bg); }
.result-badge[data-tone="good"] { color: var(--tone-good); background: var(--tone-good-bg); }
.result-badge[data-tone="warn"] { color: var(--tone-warn); background: var(--tone-warn-bg); }
.result-badge[data-tone="high"] { color: var(--tone-high); background: var(--tone-high-bg); }

.result-verdict {
  font-size: 16px; line-height: 1.5; font-weight: 500;
  color: var(--text-secondary); margin: var(--space-3) 0 0;
}
.result-formula { font-size: 13px; color: var(--text-muted); margin: var(--space-3) 0 0; }

/* Reveal choreography: badge + verdict land 150ms after the number starts. */
.result-badge, .result-verdict {
  opacity: 0; transform: translateY(8px);
  transition: opacity 250ms ease-out 150ms, transform 250ms ease-out 150ms;
}
.result-populated[data-revealed="true"] .result-badge,
.result-populated[data-revealed="true"] .result-verdict { opacity: 1; transform: none; }

/* ── Secondary stat chips (TDEE targets, WHO annotation, Devine, waist) ── */
.stat-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-3); margin-top: var(--space-5);
}
.stat-chip {
  background: var(--bg-cream); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px;
}
.stat-chip .stat-label {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted);
}
.stat-chip .stat-value {
  display: block; font-family: var(--font-display); font-size: 2rem;
  line-height: 1.1; color: var(--text-primary); margin-top: 2px;
}
.stat-chip .stat-note { display: block; font-size: 12px; color: var(--text-muted); }

.result-sub {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  margin-top: var(--space-4); font-size: 14px; color: var(--text-secondary);
}
.result-sub .sub-value { font-family: var(--font-display); font-size: 1.6rem; color: var(--text-primary); }

/* WHO annotation (BMI page) — a footnote to the headline, not a peer. */
.who-annotation {
  display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap;
  background: var(--bg-cream); border-radius: 10px; padding: 10px 14px;
  margin-top: var(--space-4); font-size: 14px;
}
.who-label { color: var(--text-secondary); font-weight: 600; }
.who-badge {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 24px; padding: 2px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 700; border: 1px solid currentColor;
}
.who-badge[data-tone="low"]  { color: var(--tone-low);  background: var(--tone-low-bg); }
.who-badge[data-tone="good"] { color: var(--tone-good); background: var(--tone-good-bg); }
.who-badge[data-tone="warn"] { color: var(--tone-warn); background: var(--tone-warn-bg); }
.who-badge[data-tone="high"] { color: var(--tone-high); background: var(--tone-high-bg); }
.who-info {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: none; padding: 4px 6px; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 700; color: var(--accent-gold);
  border-radius: 6px;
}
.who-info svg { transition: transform 200ms ease; }
.who-info[aria-expanded="true"] svg { transform: rotate(180deg); }
.who-explainer {
  margin-top: var(--space-3); background: var(--bg-cream);
  border-radius: 10px; padding: 12px 14px;
}
.who-explainer p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--text-secondary); }

/* ── Share row ──────────────────────────────────────────────────────── */
.share-row {
  display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap;
  margin-top: var(--space-5);
}
.share-btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 18px; cursor: pointer;
  background: var(--bg-surface); color: var(--accent-gold);
  border: 1.5px solid var(--accent-gold); border-radius: 10px;
  font-family: inherit; font-size: 15px; font-weight: 700;
}
.share-btn:hover { background: rgba(232, 65, 10, 0.06); }
.print-link {
  background: none; border: none; padding: 8px 4px; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 600; color: var(--text-muted);
  text-decoration: underline;
}
.print-link:hover { color: var(--accent-gold); }

/* ── Email opt-in card ──────────────────────────────────────────────── */
.cta-optin { margin: var(--space-4) 0 0; }
.cta-optin.is-pending { display: none; }
.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.optin-form { margin-top: var(--space-4); }
.optin-row { display: flex; flex-direction: column; gap: var(--space-3); }
.optin-row input[type="email"] {
  width: 100%; min-height: 48px; font-size: 16px; font-family: inherit;
  color: var(--text-primary); background: var(--bg-surface);
  border: 1.5px solid var(--border); border-radius: 10px; padding: 0 14px;
}
.optin-form .cta-btn {
  min-height: 48px; min-width: 168px; border: none; cursor: pointer;
  background: var(--grad-ember); color: #FFFFFF;
  font-family: inherit; font-weight: 700; font-size: 15px;
  border-radius: 10px; padding: 0 22px;
  box-shadow: 0 4px 12px rgba(255, 90, 22, 0.28);
}
.optin-form .cta-btn:disabled { opacity: 0.65; cursor: progress; }
@media (min-width: 560px) {
  .optin-row { flex-direction: row; }
  .optin-row input[type="email"] { flex: 1; min-width: 0; }
}
.optin-consent {
  display: flex; gap: 10px; align-items: flex-start;
  margin-top: var(--space-3); font-size: 13px; line-height: 1.55; color: var(--text-secondary);
}
.optin-consent input { width: 18px; height: 18px; margin: 2px 0 0; flex: 0 0 auto; accent-color: #E8410A; }
/* Explicit, not inherited: a consent link that renders browser-blue reads as
   unstyled and is invisible against the ember card. CLAUDE.md §6. */
.optin-consent a { color: var(--accent-gold); text-decoration: underline; }
.optin-status { margin: var(--space-3) 0 0; font-size: 14px; color: var(--tone-high); }
.optin-status[data-tone="good"] { color: var(--tone-good); }
.optin-success { display: flex; gap: var(--space-3); align-items: flex-start; margin-top: var(--space-4); }
.optin-success svg { flex: 0 0 auto; color: var(--tone-good); margin-top: 2px; }
.optin-success p { margin: 0; font-size: 15px; color: var(--text-secondary); }

/* ── SEO body, FAQ, related ─────────────────────────────────────────── */
.seo-content { margin-top: var(--space-8); }
.seo-content h2:first-child { margin-top: 0; }
.faq { margin-top: var(--space-8); }
.faq h2 { font-size: 24px; font-weight: 800; margin: 0 0 var(--space-4); }
.faq details {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 2px 16px; margin-bottom: var(--space-2);
}
.faq summary {
  cursor: pointer; padding: 14px 0; font-size: 16px; font-weight: 700;
  color: var(--text-primary); list-style: none; display: flex;
  justify-content: space-between; align-items: center; gap: var(--space-3);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: '+'; font-size: 22px; font-weight: 400; color: var(--accent-gold); flex: 0 0 auto;
}
.faq details[open] summary::after { content: '\2212'; }
.faq summary h3 { margin: 0; font-size: 16px; font-weight: 700; }
.faq details p { margin: 0 0 14px; font-size: 16px; color: var(--text-secondary); line-height: 1.6; }

.sources { margin-top: var(--space-7); font-size: 14px; color: var(--text-muted); }
.sources h2 { font-size: 19px; }
.sources li { font-size: 14px; }

.related-tools { margin-top: var(--space-8); }
.related-tools h2 { font-size: 24px; font-weight: 800; margin: 0 0 var(--space-4); }
.related-tools .link-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.related-tools .link-row a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 8px 16px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 999px; font-size: 15px; font-weight: 600; color: var(--accent-gold);
}
.related-tools .link-row a:hover { text-decoration: none; border-color: var(--accent-gold); }

/* ── Hub tool cards ─────────────────────────────────────────────────── */
.tool-card .tool-card-icon {
  width: 80px; height: 80px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 20px 20px 0;
}
.tool-card .tool-card-icon[data-tone="low"]  { background: var(--tone-low-bg);  color: var(--tone-low); }
.tool-card .tool-card-icon[data-tone="good"] { background: var(--tone-good-bg); color: var(--tone-good); }
.tool-card .tool-card-icon[data-tone="warn"] { background: var(--tone-warn-bg); color: var(--tone-warn); }
.tool-card .tool-card-icon[data-tone="high"] { background: var(--tone-high-bg); color: var(--tone-high); }
.post-grid.tool-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ── Reduced motion: same information, arriving without motion ──────── */
@media (prefers-reduced-motion: reduce) {
  .scale-marker { transition: opacity 200ms ease; }
  .result-badge, .result-verdict {
    transition: opacity 200ms ease; transform: none !important;
  }
  .calc-btn, .who-info svg, .activity-body, .unit-toggle button { transition: none; }
}

/* ── Print: just the result, on clean white ─────────────────────────── */
@media print {
  .top-banner, .site-nav, .calc-card, .cta-optin, .share-row,
  .seo-content, .faq, .related-tools, .site-foot, .page-note, .breadcrumbs {
    display: none !important;
  }
  .result { box-shadow: none; border: 1px solid #000; min-height: 0; }
  .scale-marker { transition: none; }
  .result-badge, .result-verdict { opacity: 1 !important; transform: none !important; }
  body { background: #fff; color: #000; }
}
