/* =========================
   RESET + BASE
   ========================= */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

/* Honour reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  font-weight: 300;
  line-height: 1.6;
  overflow-x: hidden;
}

/* =========================
   SKIP LINK — WCAG 2.4.1
   ========================= */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 9999;
  background: var(--primary);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 0;
  outline: var(--focus-ring);
}

/* =========================
   GLOBAL FOCUS STYLES — WCAG 2.4.7 / 2.4.11
   Visible, high-contrast, offset from element
   ========================= */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 4px;
}

/* Remove focus ring only for mouse users */
:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}

/* =========================
   AMBIENT GLOW (decorative)
   ========================= */
.ambient,
.ambient-2 {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  aria-hidden: true;
}
.ambient {
  width: 700px;
  height: 700px;
  background: radial-gradient(
    circle,
    rgba(194, 65, 12, 0.08) 0%,
    transparent 70%
  );
  top: -200px;
  right: -200px;
}
.ambient-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(
    circle,
    rgba(29, 78, 216, 0.08) 0%,
    transparent 70%
  );
  bottom: -100px;
  left: -100px;
}

/* =========================
   Breadcrumb (Premium, compact, accessible)
   Uses your :root tokens
   ========================= */

.breadcrumb {
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}

.breadcrumb .container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.breadcrumb-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.3;
}

/* each crumb */
.breadcrumb-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* divider */
.breadcrumb-item:not(:last-child)::after {
  content: "›";
  color: var(--muted-2);
  font-size: 14px;
  line-height: 1;
  transform: translateY(-0.5px);
}

/* links */
.breadcrumb-item a {
  color: var(--link);
  text-decoration: none;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 10px;
  transition:
    background var(--transition),
    color var(--transition),
    box-shadow var(--transition);
  outline: none;
  white-space: nowrap;
}

.breadcrumb-item a:hover {
  color: var(--link-hover);
  background: var(--primary-soft);
}

.breadcrumb-item a:focus-visible {
  box-shadow: var(--focus-ring);
}

/* active crumb */
.breadcrumb-item.active {
  color: var(--text);
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

/* Optional: make it feel "premium" on desktop */
@media (min-width: 768px) {
  .breadcrumb {
    padding: 16px 0;
  }
  .breadcrumb-list {
    font-size: 14px;
  }
}

/* Optional: tighter on small screens, prevents overflow */
@media (max-width: 480px) {
  .breadcrumb {
    padding: 12px 0;
  }
  .breadcrumb-list {
    gap: 6px;
  }
  .breadcrumb-item a,
  .breadcrumb-item.active {
    padding: 6px 8px;
    border-radius: 12px;
  }
}
/* =========================
   HERO
   ========================= */
.hero {
  position: relative;
  z-index: 1;
  padding: clamp(3rem, 8vw, 7rem) clamp(1rem, 5vw, 4rem) 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.hero-label {
  font-family: "DM Mono", monospace;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.hero-label::before {
  content: "";
  display: inline-block;
  width: 24px;
  height: 2px; /* Slightly thicker for visibility */
  background: var(--accent);
  flex-shrink: 0;
}

/* Headings */
h1 {
  font-family: "Syne", sans-serif;
  font-weight: 800;
  font-size: clamp(2.4rem, 6vw, 5.2rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
}
h1 .unit {
  color: var(--text);
  display: inline-block;
  position: relative;
}
h1 .arrow {
  color: var(--muted-2);
  font-weight: 800;
  font-size: 0.7em;
  padding: 0 0.15em;
}
h1 .unit-b {
  /* Gradient text — provide fallback color for high-contrast mode */
  color: var(--accent);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
/* Forced colors / Windows High Contrast mode */
@media (forced-colors: active) {
  h1 .unit-b {
    -webkit-text-fill-color: ButtonText;
    background: none;
    color: ButtonText;
  }
}

.hero-sub {
  max-width: 560px;
  color: var(--muted);
  font-size: 1.05rem;
  font-weight: 400; /* Bumped from 300 — thin weight ≤ 300 can fail readability */
  line-height: 1.75;
  margin-bottom: 3rem;
}
/* =========================
   INTRO (compact, premium)
   Uses your :root tokens
   ========================= */

#intro .intro-wrap {
  margin-top: 14px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}

#intro .intro-lead {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 1.02rem;
  line-height: 1.6;
}

#intro .intro-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 14px;
  padding: 0;
}

#intro .intro-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.82rem;
}

#intro .intro-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 6px 0 14px;
}

#intro .intro-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  text-decoration: none;
  font-weight: 800;
  transition:
    transform var(--transition),
    background var(--transition),
    color var(--transition),
    border-color var(--transition),
    box-shadow var(--transition);
  user-select: none;
}

#intro .intro-btn:hover {
  transform: translateY(-1px);
}

#intro .intro-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

#intro .intro-btn.primary {
  background: var(--primary);
  border-color: rgba(0, 0, 0, 0.08);
  color: #fff;
}

#intro .intro-btn.primary:hover {
  background: var(--primary-hover);
}

#intro .intro-btn.ghost {
  background: var(--surface);
  color: var(--link);
}

#intro .intro-btn.ghost:hover {
  background: var(--primary-soft);
  color: var(--link-hover);
}

#intro .intro-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 4px;
}

#intro .intro-fact {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  font-size: 0.95rem;
  line-height: 1.4;
}

@media (max-width: 900px) {
  #intro .intro-facts {
    grid-template-columns: 1fr;
  }
}
/* =========================
   CALCULATOR CARD
   ========================= */
.calc-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem;
  max-width: 640px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.calc-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--accent),
    var(--accent2),
    transparent
  );
  aria-hidden: true;
}

.calc-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: center;
}

.input-group,
.output-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Labels: explicitly associated with inputs via <label for=""> in HTML */
.input-label {
  font-family: "DM Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 500;
}

.input-wrap {
  position: relative;
}

/* Input: clear border, sufficient contrast, readable size */
.temp-input {
  width: 100%;
  background: var(--surface2);
  border: 2px solid var(--border); /* 2px visible border — 3:1 on bg ✓ */
  border-radius: 12px;
  color: var(--text);
  font-family: "Syne", sans-serif;
  font-size: 2.2rem;
  font-weight: 700;
  padding: 1rem 3rem 1rem 1.2rem;
  outline: none;
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
  -moz-appearance: textfield;
  appearance: textfield;
  min-height: 44px; /* Touch target */
}
.temp-input::-webkit-inner-spin-button,
.temp-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
}
.temp-input:hover {
  border-color: var(--border-strong);
}
.temp-input:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
/* Invalid state */
.temp-input[aria-invalid="true"] {
  border-color: var(--danger-700);
}
.temp-input[aria-invalid="true"]:focus {
  box-shadow:
    0 0 0 3px #fff,
    0 0 0 5px var(--danger-700);
}

.input-unit {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: "DM Mono", monospace;
  font-size: 1.1rem;
  color: var(--accent);
  font-weight: 500;
  /* Decorative; unit label should also be in the visible <label> text */
  pointer-events: none;
}

.calc-arrow {
  font-size: 1.8rem;
  color: var(--muted);
  text-align: center;
  padding-top: 1.4rem;
  aria-hidden: true; /* Decorative arrow, conversion conveyed in output label */
}

/* Output box */
.output-box {
  background: rgba(194, 65, 12, 0.06);
  border: 2px solid rgba(194, 65, 12, 0.22);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.output-value {
  font-family: "Syne", sans-serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent); /* Solid fallback */
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  transition: all 0.3s;
}
@media (forced-colors: active) {
  .output-value {
    -webkit-text-fill-color: ButtonText;
    background: none;
    color: ButtonText;
  }
}
.output-unit {
  font-family: "DM Mono", monospace;
  font-size: 1.1rem;
  color: var(--text); /* 7.5:1 — AAA ✓ */
  font-weight: 500;
  z-index: 100;
}

/* Copy button — ≥44px tap target */
.copy-btn {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
  font-family: "DM Mono", monospace;
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  min-height: 36px; /* Reasonable within tight context */
  transition: all var(--transition);
  font-weight: 500;

  pointer-events: auto;
  z-index: 10;
}
.copy-btn:hover {
  color: var(--accent);
  background: rgba(194, 65, 12, 0.1);
  border-color: var(--accent);
}
.copy-btn.copied {
  color: var(--success-700);
  border-color: var(--success-700);
  background: var(--success-50);
}

/* Hint block */
.calc-hint {
  margin-top: 1.4rem;
  padding: 0.9rem 1.1rem;
  background: var(--surface2);
  border-radius: 10px;
  border-left: 4px solid var(--accent); /* Stronger indicator */
  font-family: "DM Mono", monospace;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.7;
}
.calc-hint .formula {
  color: var(--accent-700);
  font-weight: 500;
}

/* =========================
   TEMPERATURE CONTEXT BADGE
   ========================= */
.temp-badge {
  margin-top: 1.2rem;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.4s ease;
  border: 2px solid;
}
.temp-badge.visible {
  opacity: 1;
}
.temp-badge.cold {
  background: rgba(29, 78, 216, 0.1);
  border-color: rgba(29, 78, 216, 0.3);
  color: var(--info-700); /* 4.7:1 ✓ */
}
.temp-badge.warm {
  background: rgba(146, 64, 14, 0.1);
  border-color: rgba(146, 64, 14, 0.26);
  color: var(--warning-700); /* 5.6:1 ✓ */
}
.temp-badge.hot {
  background: rgba(194, 65, 12, 0.1);
  border-color: rgba(194, 65, 12, 0.26);
  color: var(--accent); /* 5.85:1 ✓ */
}
.temp-badge.freezing {
  background: rgba(29, 78, 216, 0.08);
  border-color: rgba(29, 78, 216, 0.2);
  color: #1d4ed8; /* 4.7:1 ✓ */
}
.temp-badge.body {
  background: rgba(154, 52, 18, 0.1);
  border-color: rgba(154, 52, 18, 0.24);
  color: var(--accent-700); /* 7.5:1 ✓ */
}

/* =========================
   SECTIONS
   ========================= */
.section {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(2.5rem, 5vw, 5rem) clamp(1rem, 5vw, 4rem);
}
.section-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 2.5rem;
}
.section-num {
  font-family: "DM Mono", monospace;
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.1em;
  font-weight: 500;
}

h2 {
  font-family: "Syne", sans-serif;
  font-weight: 700;
  font-size: clamp(1.5rem, 3.5vw, 2.2rem);
  letter-spacing: -0.02em;
  color: var(--text);
}

.divider {
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
  margin: 0 clamp(1rem, 5vw, 4rem);
  /* Not a thematic break — kept decorative. Use <hr> in HTML for semantic dividers */
}

/* =========================
   FORMULA SECTION
   ========================= */
.formula-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.formula-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
}
.formula-card:hover {
  border-color: rgba(194, 65, 12, 0.26);
  box-shadow: var(--shadow-md);
}
.formula-card h3 {
  font-family: "Syne", sans-serif;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 1rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.big-formula {
  font-family: "DM Mono", monospace;
  font-size: clamp(1.1rem, 2.5vw, 1.6rem);
  color: var(--text);
  background: var(--surface2);
  padding: 1rem 1.4rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
  word-break: break-all;
  /* Ensure formula is readable as text, not just visual */
  overflow-x: auto;
}
.big-formula .op {
  color: var(--muted-2);
}
.big-formula .num {
  color: var(--accent-700); /* 7.5:1 ✓ */
}
.big-formula .var {
  color: var(--accent); /* 5.85:1 ✓ */
}

.steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1.2rem;
}
.steps li {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.6;
}
.step-num {
  width: 24px;
  height: 24px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "DM Mono", monospace;
  font-size: 0.65rem;
  color: var(--accent);
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 1px;
  aria-hidden: true; /* Number is decorative; order conveyed by list */
}

.example-calc {
  background: var(--surface2);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  padding: 1.4rem;
  font-family: "DM Mono", monospace;
  font-size: 0.85rem;
  line-height: 2;
  color: var(--muted);
}
.example-calc .eg-highlight {
  color: var(--accent);
  font-weight: 500;
}
.example-calc .eg-result {
  color: var(--accent-700); /* 7.5:1 ✓ */
  font-size: 1rem;
  font-weight: 500;
}

.mental-math {
  background: linear-gradient(
    135deg,
    rgba(146, 64, 14, 0.08),
    rgba(194, 65, 12, 0.05)
  );
  border: 1px solid rgba(146, 64, 14, 0.2);
  border-radius: 12px;
  padding: 1.2rem 1.4rem;
  margin-top: 1.5rem;
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.7;
}
.mental-math strong {
  color: var(--accent-700); /* 7.5:1 ✓ */
}

/* =========================
   QUICK REFERENCE GRID
   ========================= */
.quick-ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

/* Cards with hover — ensure not sole interaction signal */
.qr-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.2rem;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.qr-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(194, 65, 12, 0.07), transparent);
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}
.qr-card:hover {
  border-color: rgba(194, 65, 12, 0.32);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.qr-card:hover::after {
  opacity: 1;
}
/* Cards are interactive — show focus clearly */
.qr-card:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.qr-c {
  font-family: "DM Mono", monospace;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--cold); /* 4.7:1 ✓ */
  line-height: 1;
  margin-bottom: 0.3rem;
}
.qr-f {
  font-family: "Syne", sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent); /* 5.85:1 ✓ */
  margin-bottom: 0.5rem;
}
.qr-tag {
  font-size: 0.74rem;
  color: var(--muted); /* 7.35:1 ✓ */
  font-weight: 400;
  line-height: 1.4;
}
.qr-card.highlight-card {
  border-color: rgba(194, 65, 12, 0.28);
  border-width: 2px;
}

/* =========================
   TAB COMPONENT — WCAG 4.1.2 / keyboard nav
   In HTML: role="tablist", role="tab", role="tabpanel",
   aria-selected, aria-controls, tabindex
   ========================= */
.tab-row {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
  role: tablist;
}
.tab-btn {
  font-family: "DM Sans", sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: none;
  padding: 0.75rem 1.2rem;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  border-radius: 6px 6px 0 0;
  min-height: 44px; /* Touch target */
  position: relative;
}
.tab-btn.active,
.tab-btn[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.tab-btn:hover:not(.active):not([aria-selected="true"]) {
  color: var(--text);
  background: var(--surface2);
}
.tab-panel {
  display: none;
}
.tab-panel.active,
.tab-panel[hidden="false"] {
  display: block;
}

/* =========================
   CHART / TABLE — WCAG 1.3.1 Table Structure
   In HTML: use <thead>, <tbody>, <th scope="col/row">
   ========================= */
.chart-search {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.chart-search input {
  flex: 1;
  min-width: 200px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: "DM Mono", monospace;
  font-size: 0.9rem;
  padding: 0.6rem 1rem;
  outline: none;
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
  min-height: 44px;
}
.chart-search input:hover {
  border-color: var(--border-strong);
}
.chart-search input:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.chart-search input::placeholder {
  color: var(--muted-2); /* 5.3:1 ✓ */
  font-style: italic;
}

.chart-table-wrap {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  max-height: 420px;
  overflow-y: auto;
  background: var(--card-bg);
  box-shadow: var(--shadow-md);
}
/* Scrollbar — styled but accessible */
.chart-table-wrap::-webkit-scrollbar {
  width: 8px;
}
.chart-table-wrap::-webkit-scrollbar-track {
  background: var(--surface2);
}
.chart-table-wrap::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
  border: 1px solid var(--surface2);
}
.chart-table-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--muted-2);
}

.chart-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.chart-table thead tr {
  background: var(--surface2);
  position: sticky;
  top: 0;
  z-index: 2;
}
.chart-table th {
  font-family: "DM Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--muted); /* 7.35:1 ✓ */
  text-transform: uppercase;
  padding: 0.85rem 1.2rem;
  text-align: left;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
}
/* Sortable column headers */
.chart-table th[aria-sort] {
  cursor: pointer;
}
.chart-table th[aria-sort]:hover {
  background: var(--neutral-200);
}
.chart-table td {
  padding: 0.75rem 1.2rem;
  border-bottom: 1px solid var(--border);
  font-family: "DM Mono", monospace;
  transition: background var(--transition);
}
.chart-table tbody tr:hover td {
  background: rgba(194, 65, 12, 0.05);
}
/* Zebra striping for readability */
.chart-table tbody tr:nth-child(even) td {
  background: var(--surface2);
}
.chart-table tbody tr:nth-child(even):hover td {
  background: rgba(194, 65, 12, 0.06);
}
.chart-table tr:last-child td {
  border-bottom: none;
}

.td-c {
  color: var(--cold); /* 4.7:1 ✓ */
  font-weight: 500;
}
.td-f {
  color: var(--accent); /* 5.85:1 ✓ */
  font-weight: 500;
}
.td-tag {
  color: var(--muted); /* 7.35:1 ✓ */
  font-size: 0.78rem;
}

/* Band labels */
.band-label {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  font-family: "DM Mono", monospace;
  font-weight: 600;
  white-space: nowrap;
}
.band-freeze {
  background: rgba(29, 78, 216, 0.12);
  color: #1e40af; /* 6.5:1 ✓ */
}
.band-cold {
  background: rgba(29, 78, 216, 0.1);
  color: var(--info-700); /* 4.7:1 ✓ */
}
.band-mild {
  background: rgba(4, 120, 87, 0.12);
  color: var(--success-700); /* 4.54:1 ✓ */
}
.band-warm {
  background: rgba(146, 64, 14, 0.12);
  color: var(--warning-700); /* 5.6:1 ✓ */
}
.band-hot {
  background: rgba(194, 65, 12, 0.12);
  color: var(--accent); /* 5.85:1 ✓ */
}

/* =========================
   LANDMARK CARDS
   ========================= */
.landmark-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.2rem;
}
.landmark-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.4rem;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}
.landmark-card:hover {
  transform: translateY(-2px);
  border-color: rgba(194, 65, 12, 0.22);
  box-shadow: var(--shadow-md);
}
.landmark-temps {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}
.lm-c {
  font-family: "DM Mono", monospace;
  font-size: 1.1rem;
  color: var(--cold); /* 4.7:1 ✓ */
  font-weight: 500;
}
.lm-sep {
  color: var(--border-strong);
  font-size: 0.8rem;
}
.lm-f {
  font-family: "Syne", sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent); /* 5.85:1 ✓ */
}
.lm-unit {
  font-family: "DM Mono", monospace;
  font-size: 0.8rem;
  color: var(--accent-700); /* 7.5:1 ✓ */
  font-weight: 500;
}
.lm-label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
  color: var(--text);
}
.lm-note {
  font-size: 0.78rem;
  color: var(--muted); /* 7.35:1 ✓ */
}

/* =========================
   COOKING CARDS
   ========================= */
.cooking-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.cook-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.2rem;
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}
.cook-card:hover {
  border-color: rgba(190, 18, 60, 0.26);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.cook-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  aria-hidden: true;
}
.cook-c {
  font-family: "DM Mono", monospace;
  font-size: 0.85rem;
  color: var(--muted); /* 7.35:1 ✓ */
  margin-bottom: 0.2rem;
  font-weight: 500;
}
.cook-f {
  font-family: "Syne", sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.2rem;
}
.cook-f span {
  font-size: 1rem;
  color: var(--muted); /* 7.35:1 ✓ */
  font-weight: 400;
}
.cook-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-700); /* 7.5:1 ✓ */
  margin-bottom: 0.2rem;
}
.cook-note {
  font-size: 0.75rem;
  color: var(--muted); /* 7.35:1 ✓ */
}

/* =========================
   FAQ — WCAG 4.1.2 Widget Roles
   In HTML: use <button aria-expanded="true/false"
   aria-controls="faq-answer-id"> and hidden attribute on answers
   ========================= */

/* =========================
   ANIMATIONS
   ========================= */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Only animate if user hasn't requested reduced motion */
@media (prefers-reduced-motion: no-preference) {
  .anim-1 {
    animation: fadeUp 0.5s ease both;
  }
  .anim-2 {
    animation: fadeUp 0.5s 0.1s ease both;
  }
  .anim-3 {
    animation: fadeUp 0.5s 0.2s ease both;
  }
  .anim-4 {
    animation: fadeUp 0.5s 0.3s ease both;
  }

  .reveal {
    opacity: 0;
    transform: translateY(20px);
    transition:
      opacity 0.5s ease,
      transform 0.5s ease;
  }
  .reveal.visible {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fallback: always show content for reduced-motion users */
@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
  }
  .anim-1,
  .anim-2,
  .anim-3,
  .anim-4 {
    animation: none;
  }
}

/* =========================
   EMPTY STATE
   ========================= */
.no-results {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--muted); /* 7.35:1 ✓ */
  font-family: "DM Mono", monospace;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.no-results::before {
  content: "∅";
  font-size: 2rem;
  color: var(--border-strong);
}

/* =========================
   ERROR / STATUS MESSAGES
   ========================= */
.error-msg {
  color: var(--danger-700); /* 5.3:1 ✓ */
  font-size: 0.82rem;
  font-family: "DM Mono", monospace;
  margin-top: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* =========================
   RESPONSIVE
   ========================= */
@media (max-width: 720px) {
  .formula-grid {
    grid-template-columns: 1fr;
  }
  .calc-row {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .calc-arrow {
    padding-top: 0;
    font-size: 1.2rem;
    display: flex;
    justify-content: center;
  }
  /* .nav-links {
    display: none;
  } */
  .tab-row {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tab-row::-webkit-scrollbar {
    display: none;
  }
}

/* =========================
   HIGH CONTRAST MODE — Windows / Forced Colors
   ========================= */
@media (forced-colors: active) {
  .calc-card::before,
  .cook-bar,
  .ambient,
  .ambient-2 {
    display: none;
  }
  .temp-badge {
    border: 2px solid ButtonText;
  }
  .band-label {
    border: 1px solid ButtonText;
  }
  :focus-visible {
    outline: 3px solid Highlight;
    box-shadow: none;
  }
}

/* =========================
   PRINT
   ========================= */
@media print {
  .ambient,
  .ambient-2,
  body::before,
  nav,
  .copy-btn {
    display: none;
  }
  body {
    background: white;
    color: black;
  }
  .calc-card,
  .formula-card,
  .landmark-card,
  .cook-card {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }
  a {
    color: black;
    text-decoration: underline;
  }
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.75em;
  }
}
.popular-grid .qr-card {
  text-decoration: none;
  color: inherit;
}
