/* ============================================
   BMI Calculator – SaaS-style static styles
   Mobile-first, CSS variables, light/dark
   ============================================ */

:root {
  --font: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 12px 40px rgba(15, 23, 42, 0.08);
  --shadow-hover: 0 4px 12px rgba(15, 23, 42, 0.08), 0 20px 50px rgba(15, 23, 42, 0.12);
  --header-h: 56px;
  --color-bg: #f4f6fb;
  --color-surface: #ffffff;
  --color-text: #0f172a;
  --color-muted: #64748b;
  --color-border: #e2e8f0;
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-accent: #06b6d4;
  --bmi-under: #38bdf8;
  --bmi-normal: #22c55e;
  --bmi-over: #f59e0b;
  --bmi-obese: #ef4444;
  --focus-ring: 0 0 0 3px rgba(79, 70, 229, 0.35);
}

[data-theme="dark"] {
  --color-bg: #0b1120;
  --color-surface: #151e32;
  --color-text: #f1f5f9;
  --color-muted: #94a3b8;
  --color-border: #243045;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 40px rgba(0, 0, 0, 0.45);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.35), 0 24px 56px rgba(0, 0, 0, 0.5);
  --color-primary: #818cf8;
  --color-primary-hover: #a5b4fc;
  --focus-ring: 0 0 0 3px rgba(129, 140, 248, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  transition: background 0.25s ease, color 0.25s ease;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  padding: 0.75rem 1rem;
  background: var(--color-primary);
  color: #fff;
  z-index: 1000;
  border-radius: var(--radius-sm);
}
.skip-link:focus {
  left: 1rem;
  top: 1rem;
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ----- Header ----- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--color-surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  transition: background 0.25s ease, border-color 0.25s ease;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
  font-weight: 700;
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  color: #fff;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.logo-text {
  font-size: 1.05rem;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}
.theme-toggle:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow);
}
.theme-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.theme-icon--moon {
  display: none;
}
[data-theme="dark"] .theme-icon--sun {
  display: none;
}
[data-theme="dark"] .theme-icon--moon {
  display: inline;
}

/* ----- Layout ----- */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
}

.hero {
  text-align: center;
  padding: 1.5rem 0 2rem;
}

.hero h1 {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 0.75rem;
  font-weight: 700;
}

.hero-lead {
  margin: 0 auto 0.75rem;
  max-width: 38rem;
  color: var(--color-muted);
  font-size: 1.05rem;
}

.text-link {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.text-link:hover {
  text-decoration-thickness: 2px;
}

.layout-grid {
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 900px) {
  .layout-grid {
    grid-template-columns: 1fr 280px;
    align-items: start;
  }
}

/* ----- Cards ----- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  transition: box-shadow 0.25s ease, border-color 0.25s ease, transform 0.2s ease;
}

.calculator-card:hover {
  box-shadow: var(--shadow-hover);
}

.card__header {
  margin-bottom: 1.25rem;
}

.card__title {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
  font-weight: 700;
}

.card__subtitle {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.95rem;
}

/* ----- Ad slots ----- */
.ad-slot {
  margin: 1.25rem 0;
  min-height: 90px;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--color-bg) 80%, var(--color-surface));
}

.ad-slot--top {
  min-height: 90px;
  margin-top: 0;
}

.ad-slot--inline {
  min-height: 250px;
}

.ad-slot__label {
  font-size: 0.8rem;
  color: var(--color-muted);
  text-align: center;
  padding: 0.5rem;
}

/* ----- Form ----- */
.bmi-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  margin: 0;
  padding: 0;
  border: none;
}

.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.unit-toggle {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  margin-bottom: 0.75rem;
}

.toggle-btn {
  border: none;
  background: transparent;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.toggle-btn:hover {
  color: var(--color-text);
}
.toggle-btn.is-active {
  background: var(--color-surface);
  color: var(--color-primary);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}
.toggle-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.input-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
  color: var(--color-muted);
}

input[type="number"],
input[type="email"] {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: inherit;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input::placeholder {
  color: color-mix(in srgb, var(--color-muted) 65%, transparent);
}

input:hover {
  border-color: color-mix(in srgb, var(--color-primary) 45%, var(--color-border));
}

input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--focus-ring);
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.is-hidden,
[hidden] {
  display: none !important;
}

.field-error {
  min-height: 1.25rem;
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--bmi-obese);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: var(--color-primary);
  color: #fff;
}
.btn--primary:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--color-primary) 35%, transparent);
}

.btn--cta {
  background: linear-gradient(135deg, #0ea5e9, var(--color-primary));
  color: #fff;
  width: 100%;
  margin-top: 0.5rem;
}
.btn--cta:hover {
  filter: brightness(1.05);
  box-shadow: 0 8px 28px color-mix(in srgb, var(--color-primary) 40%, transparent);
}

.btn--full {
  width: 100%;
  margin-top: 0.75rem;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ----- Result ----- */
.result-panel {
  margin-top: 0.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
}

.result-panel.is-visible {
  animation: result-pop 0.55s cubic-bezier(0.34, 1.2, 0.64, 1) both;
}

@keyframes result-pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.result-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.result-bmi {
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.result-category {
  display: inline-flex;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}

.result-category.cat-under {
  color: var(--bmi-under);
  border-color: color-mix(in srgb, var(--bmi-under) 35%, var(--color-border));
}
.result-category.cat-normal {
  color: var(--bmi-normal);
  border-color: color-mix(in srgb, var(--bmi-normal) 35%, var(--color-border));
}
.result-category.cat-over {
  color: var(--bmi-over);
  border-color: color-mix(in srgb, var(--bmi-over) 35%, var(--color-border));
}
.result-category.cat-obese {
  color: var(--bmi-obese);
  border-color: color-mix(in srgb, var(--bmi-obese) 35%, var(--color-border));
}

.scale-wrap {
  margin-bottom: 1rem;
}

.scale-track {
  position: relative;
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.scale-segment {
  flex: 1;
}
.scale-segment--under {
  background: linear-gradient(90deg, var(--bmi-under), color-mix(in srgb, var(--bmi-under) 70%, white));
}
.scale-segment--normal {
  background: linear-gradient(90deg, var(--bmi-normal), color-mix(in srgb, var(--bmi-normal) 75%, white));
}
.scale-segment--over {
  background: linear-gradient(90deg, var(--bmi-over), color-mix(in srgb, var(--bmi-over) 75%, white));
}
.scale-segment--obese {
  background: linear-gradient(90deg, var(--bmi-obese), color-mix(in srgb, var(--bmi-obese) 75%, white));
}

.scale-marker {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 3px solid var(--color-text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transform: translateY(-50%);
  transition: left 0.45s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.scale-legend {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.75rem;
  color: var(--color-muted);
}

.scale-legend li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.swatch--under {
  background: var(--bmi-under);
}
.swatch--normal {
  background: var(--bmi-normal);
}
.swatch--over {
  background: var(--bmi-over);
}
.swatch--obese {
  background: var(--bmi-obese);
}

.result-message {
  margin: 0;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  font-size: 0.95rem;
  color: var(--color-text);
}

/* Sidebar / TOC */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.toc__title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.toc__list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.toc__list a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
}
.toc__list a:hover {
  text-decoration: underline;
}

.lead-card .card__title {
  font-size: 1.05rem;
}

/* Content sections */
.content-sections {
  margin-top: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.prose-section h2 {
  font-size: 1.35rem;
  margin: 0 0 0.75rem;
  letter-spacing: -0.02em;
}

.prose-section p {
  margin: 0 0 0.75rem;
  color: var(--color-muted);
  max-width: 65ch;
}

.prose-section p strong {
  color: var(--color-text);
}

.formula-box {
  margin: 1rem 0;
}

.formula {
  display: inline-block;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--color-text);
}

.formula-inline {
  font-weight: 600;
  color: var(--color-text);
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.bmi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.bmi-table th,
.bmi-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.bmi-table th {
  background: var(--color-bg);
  font-weight: 600;
  color: var(--color-text);
}

.bmi-table tbody tr:last-child td {
  border-bottom: none;
}

.faq-list {
  margin: 0;
}

.faq-q {
  font-weight: 700;
  color: var(--color-text);
  margin: 1.25rem 0 0.35rem;
  font-size: 1rem;
}

.faq-q:first-child {
  margin-top: 0;
}

.faq-a {
  margin: 0;
  color: var(--color-muted);
  padding-left: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--color-muted);
  border-top: 1px solid var(--color-border);
}

.site-footer p {
  margin: 0;
}
