/* ==========================================================================
   CalculateVolume.org — Global Design System
   Vanilla CSS. No frameworks. Light + dark mode.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --bg-primary: #FAFBFC;
  --bg-surface: #FFFFFF;
  --bg-elevated: #F6F8FA;
  --text-primary: #1F2328;
  --text-secondary: #656D76;
  --accent-primary: #0E7C66;
  --accent-primary-hover: #0A6553;
  --accent-contrast: #FFFFFF;
  --accent-gradient: linear-gradient(135deg, #0E7C66, #2563EB);
  --result-bg: #ECFDF5;
  --result-border: #A7F3D0;
  --border: #D0D7DE;
  --error: #CF222E;
  --focus-ring: #0E7C6640;
  --shadow-sm: 0 1px 2px rgba(31, 35, 40, 0.06);
  --shadow-md: 0 4px 12px rgba(31, 35, 40, 0.08);
  --font-sans: 'Inter', 'Inter Fallback', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'JetBrains Mono Fallback', ui-monospace, 'Cascadia Code', Consolas, monospace;
  --radius: 8px;
  --radius-lg: 12px;
  --max-width: 1120px;
  --content-width: 760px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary: #0D1117;
    --bg-surface: #161B22;
    --bg-elevated: #21262D;
    --text-primary: #E6EDF3;
    --text-secondary: #8B949E;
    --accent-primary: #2DD4A8;
    --accent-primary-hover: #4AE0BA;
    --accent-contrast: #06281F;
    --result-bg: #0B2E24;
    --result-border: #1C5A47;
    --border: #30363D;
    --error: #F85149;
    --focus-ring: #2DD4A860;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg-primary: #0D1117;
  --bg-surface: #161B22;
  --bg-elevated: #21262D;
  --text-primary: #E6EDF3;
  --text-secondary: #8B949E;
  --accent-primary: #2DD4A8;
  --accent-primary-hover: #4AE0BA;
  --accent-contrast: #06281F;
  --result-bg: #0B2E24;
  --result-border: #1C5A47;
  --border: #30363D;
  --error: #F85149;
  --focus-ring: #2DD4A860;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

/* ---------- Metric-matched webfont fallbacks ----------
   The webfonts arrive from Google Fonts after first paint, so text initially
   renders in a fallback and then swaps. Without matched metrics that swap
   reflows the page — measured at CLS 0.081, uncomfortably near Google's 0.1
   limit before you even account for a slow connection.

   These faces re-shape a locally installed font to occupy exactly the space
   the webfont will. Values are derived from each webfont's own metrics,
   divided by the size-adjust factor so the two agree:
     Inter          ascender 2728/2816 = 96.88%, descender 680/2816 = 24.15%
                    96.88 / 1.0712 = 90.44%   ·   24.15 / 1.0712 = 22.54%
     JetBrains Mono ascender 1020/1000, descender 300/1000; its 0.6em advance
                    already matches Courier New, so no size-adjust is needed.
   Nothing is downloaded for these — src is local() only. */
@font-face {
  font-family: 'Inter Fallback';
  /* Arial and Liberation Sans only — they are metrically identical, so the
     overrides below stay calibrated. Helvetica Neue is deliberately excluded:
     its metrics differ enough that it would mis-tune the adjustment. If none
     resolve, this face is simply skipped and the stack falls through to
     -apple-system exactly as before. */
  src: local('Arial'), local('Liberation Sans');
  size-adjust: 107.12%;
  ascent-override: 90.44%;
  descent-override: 22.54%;
  line-gap-override: 0%;
}
@font-face {
  font-family: 'JetBrains Mono Fallback';
  src: local('Courier New'), local('Liberation Mono');
  ascent-override: 102%;
  descent-override: 30%;
  line-gap-override: 0%;
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-primary);
  background: var(--bg-primary);
}

img, svg { max-width: 100%; height: auto; }

h1, h2, h3, h4 {
  line-height: 1.25;
  font-weight: 700;
  margin: 0 0 0.6em;
}
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.35rem, 3vw, 1.75rem); margin-top: 2em; letter-spacing: -0.01em; }
h3 { font-size: 1.2rem; margin-top: 1.5em; }

p { margin: 0 0 1em; }

a { color: var(--accent-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code, .mono { font-family: var(--font-mono); font-size: 0.95em; }

:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent-primary);
  color: var(--accent-contrast);
  padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius) 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---------- Layout ---------- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
}

.content {
  max-width: var(--content-width);
  margin: 0 auto;
}

main { padding-bottom: 3rem; }

/* ---------- Header ---------- */
.site-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-primary);
  white-space: nowrap;
}
.logo:hover { text-decoration: none; }
.logo svg { flex-shrink: 0; }
.logo .logo-org { color: var(--accent-primary); }

.main-nav { display: flex; align-items: center; gap: 0.25rem; }

.main-nav a {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius);
}
.main-nav a:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
  text-decoration: none;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.55rem;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
  font-size: 1rem;
}
.theme-toggle:hover { background: var(--bg-elevated); }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 1.1rem;
  line-height: 1;
}

@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .main-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 1rem 1rem;
    box-shadow: var(--shadow-md);
  }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 0.7rem 0.75rem; font-size: 1rem; }
}

/* ---------- Breadcrumbs ---------- */
.breadcrumbs {
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 0.9rem 0 0;
}
.breadcrumbs ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.breadcrumbs li + li::before {
  content: "›";
  margin-right: 0.35rem;
  color: var(--text-secondary);
}
.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs a:hover { color: var(--accent-primary); }
.breadcrumbs [aria-current="page"] { color: var(--text-primary); font-weight: 500; }

/* ---------- Hero (gradient band) ---------- */
.hero-band {
  background: var(--accent-gradient);
  color: #FFFFFF;
  padding: 3rem 0 5.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero-band::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.14) 1px, transparent 1px);
  background-size: 26px 26px;
  pointer-events: none;
}
.hero-band > .container { position: relative; }
.hero-band h1 {
  color: #FFFFFF;
  margin-bottom: 0.5rem;
  text-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.hero-band .tagline {
  color: rgba(255,255,255,0.92);
  font-size: clamp(1rem, 2.5vw, 1.15rem);
  max-width: 680px;
  margin: 0 auto 1.25rem;
}
.hero-eyebrow {
  display: inline-block;
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.35);
  color: #FFFFFF;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  margin-bottom: 1rem;
}

/* Trust badges */
.trust-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.trust-badges li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.28);
  color: #FFFFFF;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}
.trust-badges .badge-check { color: #7CF5D4; font-weight: 700; }

/* Calculator overlapping the hero band */
.hero-overlap { margin-top: -4rem; position: relative; z-index: 2; }

/* Legacy simple hero (inner pages) */
.hero { padding: 1.5rem 0 0.5rem; text-align: center; }
.hero h1 { margin-bottom: 0.4rem; }
.hero .tagline {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 620px;
  margin: 0 auto 1rem;
}

/* ---------- Calculator card ---------- */
.calc-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.25rem;
  margin: 1rem 0 1.5rem;
}

@media (min-width: 720px) {
  .calc-card { padding: 1.75rem; }
  .calc-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1.75rem;
    align-items: start;
  }
}

/* Shape selector */
.shape-selector {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.shape-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.6rem 0.25rem;
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.shape-btn svg { width: 34px; height: 34px; }
.shape-btn:hover { border-color: var(--accent-primary); color: var(--text-primary); }
.shape-btn[aria-pressed="true"] {
  border-color: var(--accent-primary);
  background: var(--result-bg);
  color: var(--text-primary);
  font-weight: 600;
}

/* Inputs */
.calc-inputs { display: flex; flex-direction: column; gap: 0.9rem; }

.input-row { display: flex; flex-direction: column; gap: 0.3rem; }

.input-row label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.input-group { display: flex; gap: 0.5rem; }

.input-group input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 500;
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-primary);
  color: var(--text-primary);
}
.input-group input:focus {
  border-color: var(--accent-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.input-group input[aria-invalid="true"] { border-color: var(--error); }

/* Inputs placed directly in an .input-row (the self-contained calculators:
   spherical cap, truncated pyramid, surface area, ABV) previously inherited
   nothing and rendered at the browser default 13.3px / 21px tall. That is
   under the 24px tap-target minimum, and any input below 16px makes iOS
   Safari zoom on focus. Match .input-group input so they behave the same. */
.input-row > input[type="number"],
.input-row > input[type="text"],
.input-row > input[type="search"],
.input-row > select {
  width: 100%;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 500;
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-primary);
  color: var(--text-primary);
}
.input-row > input:focus,
.input-row > select:focus {
  border-color: var(--accent-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.input-group select,
.result-unit-select {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 0.5rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text-primary);
  cursor: pointer;
}

.input-error {
  font-size: 0.8rem;
  color: var(--error);
  min-height: 1.1em;
  margin: 0;
}

.input-hint {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin: 0.1rem 0 0;
}

.calc-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.25rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary { background: var(--accent-primary); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-primary-hover); }
.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--accent-primary); }

/* Diagram panel */
.calc-diagram {
  text-align: center;
  padding: 0.5rem 0;
}
.calc-diagram svg {
  width: 100%;
  max-width: 280px;
  height: auto;
}
.diagram-caption {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* Dimension highlight (linked to focused input) */
.dim-label { transition: opacity 0.15s; }
.dim-highlight .dim-line { stroke: var(--accent-primary); stroke-width: 2.5; }
.dim-highlight .dim-text { fill: var(--accent-primary); font-weight: 700; }

/* Result panel — fixed min-height so CLS = 0 */
.result-panel {
  margin-top: 1.25rem;
  background: var(--result-bg);
  border: 1.5px solid var(--result-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  min-height: 148px;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.result-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.result-value {
  font-family: var(--font-mono);
  font-size: clamp(1.35rem, 4vw, 1.6rem);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0.35rem 0;
  overflow-wrap: anywhere;
}
.result-value .result-unit { font-size: 0.7em; color: var(--text-secondary); font-weight: 500; }

.result-secondary {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  margin: 0;
}

.result-placeholder { color: var(--text-secondary); font-size: 0.95rem; margin: 0.75rem 0 0; }

/* Live formula display */
.formula-live {
  margin-top: 0.9rem;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.92rem;
  overflow-x: auto;
  white-space: nowrap;
  min-height: 2.9em;
}
.formula-live .formula-label {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 0.2rem;
}

/* ---------- Ad zones (reserved heights → zero CLS) ---------- */
.ad-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 1.5rem auto;
  overflow: hidden;
}
.ad-below-tool { min-height: 100px; max-width: 728px; }
.ad-in-content { min-height: 250px; max-width: 336px; }
.ad-sidebar { min-height: 600px; width: 300px; }

/* ---------- Content / editorial ---------- */
.section { margin: 2rem 0; }

.quick-answer {
  background: var(--bg-surface);
  border-left: 4px solid var(--accent-primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow-sm);
}
.quick-answer p:last-child { margin-bottom: 0; }

.formula-block {
  font-family: var(--font-mono);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin: 1rem 0;
  overflow-x: auto;
  font-size: 1rem;
}

/* Tables */
.table-wrap { overflow-x: auto; margin: 1.25rem 0; }

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
th, td {
  text-align: left;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
}
th {
  background: var(--bg-elevated);
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-elevated); }
td.num, th.num { text-align: right; font-family: var(--font-mono); font-size: 0.88em; }

/* FAQ */
.faq-list { margin: 1rem 0; }
.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.6rem;
  background: var(--bg-surface);
}
.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.85rem 1.1rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--accent-primary);
  flex-shrink: 0;
  line-height: 1;
}
.faq-item[open] summary::after { content: "−"; }
.faq-item .faq-answer { padding: 0 1.1rem 1rem; color: var(--text-primary); }
.faq-item .faq-answer p:last-child { margin-bottom: 0; }

/* Hub cards / related calculators */
.card-grid {
  display: grid;
  /* auto-fit (not auto-fill) so a 2-card row expands instead of leaving
     phantom tracks and dead space on the right.
     300px min: after the icon + padding the title still gets ~215px, which
     keeps most calculator names on a single line. */
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0.9rem;
  margin: 1.1rem 0 0;
  padding: 0;
  list-style: none;
}
@media (max-width: 460px) {
  .card-grid { grid-template-columns: 1fr; }
}

.link-card {
  display: block;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem;
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.link-card:hover {
  text-decoration: none;
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.link-card .card-title {
  font-weight: 600;
  color: var(--accent-primary);
  display: block;
  margin-bottom: 0.25rem;
}
.link-card .card-desc {
  font-size: 0.87rem;
  color: var(--text-secondary);
  margin: 0;
}

/* Notes & disclaimers */
.note {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  font-size: 0.9rem;
  margin: 1.25rem 0;
}
.note strong:first-child { color: var(--accent-primary); }

.page-meta {
  font-size: 0.83rem;
  color: var(--text-secondary);
  margin: 0.5rem 0 1.5rem;
}

/* References */
.references {
  font-size: 0.88rem;
  color: var(--text-secondary);
}
.references ol { padding-left: 1.25rem; }
.references li { margin-bottom: 0.4rem; }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  margin-top: 3rem;
  padding: 2.5rem 0 1.5rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.footer-grid h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  margin: 0 0 0.75rem;
}
.footer-grid ul { list-style: none; margin: 0; padding: 0; }
.footer-grid li { margin-bottom: 0.45rem; }
.footer-grid a { color: var(--text-secondary); }
.footer-grid a:hover { color: var(--accent-primary); }

/* Footer links are standalone (not inline in prose), so WCAG 2.2 SC 2.5.8
   applies: a 24x24 minimum target. They rendered ~16px tall on mobile.
   inline-block + vertical padding lifts the hit area without moving anything
   visually, since the padding replaces the old li margin. */
@media (max-width: 640px) {
  .footer-grid li { margin-bottom: 0; }
  .footer-grid a {
    display: inline-block;
    padding: 0.28rem 0;
    min-height: 24px;
  }
  .footer-bottom a {
    display: inline-block;
    padding: 0.28rem 0;
    min-height: 24px;
  }
  .breadcrumbs a {
    display: inline-block;
    padding: 0.2rem 0;
    min-height: 24px;
  }
  /* A link alone in a table cell is a standalone target too — the formula
     reference tables link each shape to its calculator. */
  td > a:only-child {
    display: inline-block;
    padding: 0.25rem 0;
    min-height: 24px;
  }
}

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
}

/* ==========================================================================
   Professional component layer
   ========================================================================== */

/* Shape quick-links strip (homepage) */
.shape-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 1.25rem 0;
  padding: 1rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.shape-links-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-right: 0.25rem;
}
.shape-links a {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  transition: border-color 0.15s, background 0.15s;
}
.shape-links a:hover {
  text-decoration: none;
  border-color: var(--accent-primary);
  background: var(--result-bg);
}
.shape-links .shape-links-all {
  background: var(--accent-primary);
  color: var(--accent-contrast);
  border-color: var(--accent-primary);
  font-weight: 600;
}
.shape-links .shape-links-all:hover { background: var(--accent-primary-hover); }

/* Section headers with eyebrow */
.section-header { text-align: center; max-width: 640px; margin: 0 auto 1.75rem; }
.eyebrow {
  display: inline-block;
  color: var(--accent-primary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}
.section-header h2 { margin-top: 0; }
.section-header .section-sub { color: var(--text-secondary); margin: 0; }

/* Stats strip */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
  padding: 0;
  list-style: none;
  text-align: center;
}
.stats-strip li {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 0.75rem;
}
.stat-number {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--accent-primary);
  line-height: 1.2;
}
.stat-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Numbered step cards */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.steps-grid li {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  counter-increment: step;
}
.steps-grid li::before {
  content: counter(step);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--accent-primary);
  color: var(--accent-contrast);
  font-family: var(--font-mono);
  font-weight: 700;
  margin-bottom: 0.6rem;
}
.steps-grid strong { display: block; margin-bottom: 0.25rem; }
.steps-grid p { margin: 0; font-size: 0.9rem; color: var(--text-secondary); }

/* Feature grid (why trust us) */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
  padding: 0;
  list-style: none;
}
.feature-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 10px;
  background: var(--result-bg);
  border: 1px solid var(--result-border);
  font-size: 1.25rem;
  margin-bottom: 0.7rem;
}
.feature-card strong { display: block; margin-bottom: 0.3rem; font-size: 1rem; }
.feature-card p { margin: 0; font-size: 0.9rem; color: var(--text-secondary); }

/* Hub cards (enhanced) */
.hub-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.3rem 1.3rem 1.1rem;
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  height: 100%;
}
.hub-card:hover {
  text-decoration: none;
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}
.hub-card .hub-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 10px;
  background: var(--result-bg);
  border: 1px solid var(--result-border);
  font-size: 1.35rem;
  margin-bottom: 0.75rem;
}
.hub-card .card-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
  margin-bottom: 0.3rem;
}
.hub-card .card-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin: 0 0 0.9rem;
  flex-grow: 1;
}
.hub-card .card-count {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-primary);
}
.hub-card .card-count::after { content: " →"; }

/* CTA band */
.cta-band {
  background: var(--accent-gradient);
  border-radius: var(--radius-lg);
  color: #FFFFFF;
  text-align: center;
  padding: 2.25rem 1.5rem;
  margin: 3rem 0 1rem;
}
.cta-band h2 { color: #FFFFFF; margin: 0 0 0.5rem; }
.cta-band p { color: rgba(255,255,255,0.9); max-width: 560px; margin: 0 auto 1.25rem; }
.btn-light {
  background: #FFFFFF;
  color: #0E7C66;
  border: none;
}
.btn-light:hover { background: #ECFDF5; }

/* Tool page hero (compact, gradient) */
.tool-hero {
  background: var(--accent-gradient);
  color: #FFFFFF;
  padding: 1.75rem 0 4.5rem;
  position: relative;
  overflow: hidden;
}
.tool-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.12) 1px, transparent 1px);
  background-size: 26px 26px;
  pointer-events: none;
}
.tool-hero > .container { position: relative; }
.tool-hero h1 { color: #FFFFFF; margin-bottom: 0.35rem; font-size: clamp(1.6rem, 3.5vw, 2.1rem); }
.tool-hero .tagline { color: rgba(255,255,255,0.92); max-width: 700px; margin: 0 0 0.5rem; font-size: 1rem; }
.tool-hero .breadcrumbs,
.tool-hero .breadcrumbs a,
.tool-hero .breadcrumbs li + li::before { color: rgba(255,255,255,0.85); }
.tool-hero .breadcrumbs [aria-current="page"] { color: #FFFFFF; }
.tool-hero .trust-badges { justify-content: flex-start; margin-top: 0.75rem; }

/* Footer brand row */
.footer-brand {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem;
  justify-content: space-between;
  padding-bottom: 1.75rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}
.footer-brand .logo { font-size: 1.05rem; }
.footer-brand p { max-width: 420px; margin: 0.5rem 0 0; font-size: 0.85rem; }

/* Related calculators strip */
.related-section { margin-top: 2.5rem; }

/* Pillar page tool cards
   Layout note: the icon sits on a header row WITH the title, and the
   description spans the full card width beneath. An older version nested
   the text beside the icon, which left titles ~145px to wrap into. */
.tool-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.05rem 1.15rem 1.15rem;
  color: var(--text-primary);
  height: 100%;
  overflow: hidden;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}
/* accent rail that wipes in on hover */
.tool-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent-primary);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 0.18s ease;
}
.tool-card:hover,
.tool-card:focus-visible {
  text-decoration: none;
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.tool-card:hover::before,
.tool-card:focus-visible::before { transform: scaleY(1); }

.tool-card .tool-card-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}
.tool-card .tool-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.3rem;
  height: 2.3rem;
  font-size: 1.15rem;
  line-height: 1;
  border-radius: 9px;
  background: var(--result-bg);
  border: 1px solid var(--result-border);
  color: var(--accent-primary);
  transition: transform 0.16s ease;
}
.tool-card:hover .tool-icon { transform: scale(1.06); }
.tool-card .tool-icon svg { width: 22px; height: 22px; }

.tool-card .card-title {
  font-weight: 600;
  font-size: 0.97rem;
  line-height: 1.35;
  color: var(--accent-primary);
  display: block;
  min-width: 0;
  text-wrap: balance;
}
.tool-card .card-desc {
  font-size: 0.855rem;
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0;
  text-wrap: pretty;
}
/* pushes the meta row to the card bottom so rows align */
.tool-card .card-meta {
  margin-top: auto;
  padding-top: 0.15rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--accent-primary);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.tool-card:hover .card-meta,
.tool-card:focus-visible .card-meta { opacity: 1; transform: translateX(0); }
@media (hover: none) {
  .tool-card .card-meta { opacity: 1; transform: none; }
}

/* ==========================================================================
   Hub directory — search, filter chips, section headers, empty state
   Used by the five category hubs. Progressive enhancement: with JS off the
   toolbar is hidden and every card stays visible.
   ========================================================================== */
.hub-directory { margin-top: 0; }

/* hidden until the `js` class lands, so no-JS users never see a dead control */
.hub-toolbar { display: none; }
.js .hub-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding-bottom: 1.15rem;
  margin-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

/* search field */
.hub-search { position: relative; display: flex; align-items: center; }
.hub-search .hub-search-icon {
  position: absolute;
  left: 0.85rem;
  width: 17px;
  height: 17px;
  color: var(--text-secondary);
  pointer-events: none;
}
.hub-search input[type="search"] {
  width: 100%;
  padding: 0.72rem 2.6rem 0.72rem 2.5rem;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.hub-search input[type="search"]::-webkit-search-cancel-button { display: none; }
.hub-search input[type="search"]::placeholder { color: var(--text-secondary); }
.hub-search input[type="search"]:focus {
  outline: none;
  background: var(--bg-surface);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 4px var(--focus-ring);
}
.hub-search-clear {
  position: absolute;
  right: 0.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.hub-search-clear:hover { background: var(--border); color: var(--text-primary); }
.hub-search-clear[hidden] { display: none; }

/* filter chips */
.hub-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.hub-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  font-family: inherit;
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.hub-chip:hover { color: var(--text-primary); border-color: var(--accent-primary); }
.hub-chip:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }
.hub-chip .chip-n {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  padding: 0.05rem 0.38rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}
.hub-chip.is-active {
  color: var(--accent-contrast);
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  font-weight: 600;
}
.hub-chip.is-active .chip-n {
  background: rgba(255, 255, 255, 0.22);
  color: var(--accent-contrast);
}

.hub-count {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.hub-count strong { color: var(--text-primary); font-weight: 600; }

/* section headers inside a hub */
.hub-section { margin-top: 1.9rem; }
.hub-section:first-of-type { margin-top: 1.4rem; }
.hub-section[hidden] { display: none; }
.hub-section-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.55rem;
}
.hub-section-head h2 {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.3;
  scroll-margin-top: 5rem;
}
.hub-section-head .section-n {
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.hub-section-desc {
  margin: 0.3rem 0 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
  max-width: 64ch;
}

/* empty state */
.hub-empty {
  display: none;
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-secondary);
}
.hub-empty.is-visible { display: block; }
.hub-empty .hub-empty-icon { font-size: 1.7rem; display: block; margin-bottom: 0.5rem; }
.hub-empty p { margin: 0 0 0.9rem; }
.hub-empty button {
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--accent-primary);
  background: transparent;
  border: 1px solid var(--accent-primary);
  border-radius: 999px;
  padding: 0.42rem 1rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.hub-empty button:hover { background: var(--accent-primary); color: var(--accent-contrast); }

/* search term highlight */
.tool-card mark {
  background: var(--result-bg);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .tool-card, .tool-card::before, .tool-icon, .card-meta { transition: none !important; }
  .tool-card:hover { transform: none; }
}

/* ---------- Tank calculator extras ---------- */
.tank-selector {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.tank-selector .shape-btn { font-size: 0.72rem; }

.fill-row {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--border);
}
.fill-row label { color: var(--accent-primary); }

.fill-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.6rem;
  margin-top: 0.9rem;
}
.fill-stat {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.7rem;
}
.fill-stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}
.fill-stat-value {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.fill-gauge { margin-top: 0.9rem; }
.fill-gauge-track {
  height: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.fill-gauge-bar {
  height: 100%;
  width: 0%;
  background: var(--accent-gradient);
  border-radius: 999px;
  transition: width 0.2s ease;
}
.fill-gauge-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.35rem;
  font-family: var(--font-mono);
}

/* ---------- Medical calculator extras ---------- */
.med-group-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-primary);
  margin: 0.6rem 0 0.1rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border);
}
.calc-inputs .med-group-label:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.med-interpretation {
  margin-top: 0.85rem;
  padding: 0.6rem 0.85rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.9rem;
}

.med-disclaimer {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 4px solid var(--error);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.2rem;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}
.med-disclaimer strong:first-child { color: var(--error); }
.med-disclaimer p:last-child { margin-bottom: 0; }

.med-citation {
  font-size: 0.85rem;
  color: var(--text-secondary);
  border-left: 3px solid var(--border);
  padding-left: 0.9rem;
  margin: 1rem 0;
}

/* ---------- Utility ---------- */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }

@media print {
  .site-header, .site-footer, .ad-zone, .theme-toggle, .nav-toggle { display: none; }
}
