/* ==========================================================
   LabBench Calculations — stylesheet
   Palette: navy, white, teal
   ========================================================== */

:root {
  --navy-900: #071a33;
  --navy-800: #0b2545;
  --navy-700: #13315c;
  --navy-600: #1d4373;
  --teal-600: #0d9488;
  --teal-500: #14b8a6;
  --teal-100: #ccfbf1;
  --teal-50: #f0fdfa;
  --white: #ffffff;
  --grey-50: #f6f8fb;
  --grey-100: #eef2f7;
  --grey-200: #dde3ec;
  --grey-500: #64748b;
  --grey-700: #334155;
  --text: #1e293b;
  --error: #b91c1c;
  --error-bg: #fef2f2;
  --warning: #92400e;
  --warning-bg: #fffbeb;
  --success: #047857;
  --success-bg: #ecfdf5;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(11, 37, 69, 0.06), 0 4px 16px rgba(11, 37, 69, 0.06);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  --header-h: 64px;
}

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

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { color: var(--navy-800); line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: clamp(2rem, 4.5vw, 3rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); letter-spacing: -0.01em; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
a { color: var(--teal-600); }
sub { font-size: 0.7em; }

.container { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 20px; }
.container.narrow { max-width: 860px; }

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

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  background: var(--teal-500); color: var(--navy-900); padding: 8px 14px;
  border-radius: var(--radius-sm); font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 12px; }

:focus-visible { outline: 3px solid var(--teal-500); outline-offset: 2px; }

/* ---------- Disclaimer bar ---------- */
.disclaimer-bar {
  background: var(--navy-900);
  color: #cbd5e1;
  font-size: 0.85rem;
  text-align: center;
  padding: 8px 16px;
  line-height: 1.45;
}
.disclaimer-bar strong { color: var(--teal-100); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--navy-800);
  color: var(--white);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  min-height: var(--header-h);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--white); text-decoration: none; font-weight: 700; font-size: 1.15rem;
}
.brand-icon { width: 34px; height: 34px; color: var(--navy-600); flex-shrink: 0; }
.brand-accent { color: var(--teal-500); }

.site-nav ul { list-style: none; display: flex; gap: 4px; margin: 0; padding: 0; }
.site-nav a {
  display: block; padding: 8px 14px; border-radius: var(--radius-sm);
  color: #dbe4f0; text-decoration: none; font-weight: 500; font-size: 0.98rem;
}
.site-nav a:hover, .site-nav a:focus-visible { background: var(--navy-700); color: var(--white); }

.nav-toggle {
  display: none; background: none; border: 0; padding: 10px; cursor: pointer;
  border-radius: var(--radius-sm);
}
.nav-toggle span {
  display: block; width: 24px; height: 2px; background: var(--white);
  margin: 5px 0; transition: transform 0.2s, opacity 0.2s;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 10px 22px; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; font-size: 1rem; text-decoration: none;
  cursor: pointer; border: 2px solid transparent; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-primary { background: var(--teal-600); color: var(--white); }
.btn-primary:hover { background: #0f766e; }
.btn-ghost { background: transparent; color: var(--navy-800); border-color: var(--grey-200); }
.btn-ghost:hover { border-color: var(--navy-600); }
.btn-link {
  background: none; border: 0; color: var(--teal-600); padding: 10px 8px;
  text-decoration: underline; text-underline-offset: 3px; min-height: 0;
}
.btn-link:hover { color: var(--navy-700); }

/* ---------- Hero ---------- */
.hero {
  background:
    radial-gradient(circle at 85% 20%, rgba(20, 184, 166, 0.18), transparent 45%),
    linear-gradient(160deg, var(--navy-800) 0%, var(--navy-700) 100%);
  color: var(--white);
  padding: 72px 0 80px;
}
.hero-inner { display: grid; grid-template-columns: 1.3fr 1fr; gap: 48px; align-items: center; }
.hero h1 { color: var(--white); }
.hero .lead { font-size: 1.15rem; color: #d3deec; max-width: 38em; }
.eyebrow {
  text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.8rem;
  font-weight: 700; color: var(--teal-600); margin-bottom: 0.6em;
}
.hero .eyebrow { color: var(--teal-500); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.hero .btn-ghost { color: var(--white); border-color: rgba(255, 255, 255, 0.35); }
.hero .btn-ghost:hover { border-color: var(--white); }

.hero-card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  padding: 28px;
}
.formula-display {
  font-family: var(--font-mono); font-size: clamp(1.6rem, 3.4vw, 2.3rem);
  font-weight: 700; color: var(--teal-500); text-align: center;
  padding: 14px 0 22px; border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}
.formula-key { margin: 18px 0 0; display: grid; gap: 10px; }
.formula-key div { display: flex; gap: 14px; align-items: baseline; }
.formula-key dt { font-family: var(--font-mono); font-weight: 700; color: var(--white); min-width: 2.5em; }
.formula-key dd { margin: 0; color: #c3d0e2; }

/* ---------- Sections ---------- */
.section { padding: 72px 0; }
.section-alt { background: var(--grey-50); border-top: 1px solid var(--grey-100); border-bottom: 1px solid var(--grey-100); }
.section-head { max-width: 760px; margin-bottom: 32px; }
.section-head p:last-child { color: var(--grey-700); }

.features { padding: 0; margin-top: -40px; position: relative; }

/* ---------- Cards ---------- */
.card {
  background: var(--white); border: 1px solid var(--grey-200);
  border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow);
}
.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.feature-card p { color: var(--grey-700); margin: 0; }
.feature-icon {
  width: 48px; height: 48px; border-radius: 10px; display: grid; place-items: center;
  background: var(--teal-50); color: var(--teal-600); margin-bottom: 14px;
}
.feature-icon svg { width: 26px; height: 26px; }

/* ---------- Calculator ---------- */
.calc-layout { display: grid; grid-template-columns: 1fr 1.1fr; gap: 24px; align-items: start; }

.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; color: var(--navy-800); margin-bottom: 6px; }
.input-group { display: flex; }
.input-group input,
.input-group select,
.answer-row input {
  font: inherit; font-size: 1rem; min-height: 48px; padding: 10px 14px;
  border: 1.5px solid var(--grey-200); background: var(--white); color: var(--text);
}
.input-group input {
  flex: 1 1 auto; min-width: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.input-group select {
  flex: 0 0 auto; width: 9.5rem; max-width: 45%; border-left: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--grey-50); cursor: pointer;
}
.input-group input:focus,
.input-group select:focus,
.answer-row input:focus { outline: none; border-color: var(--teal-500); box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.2); }
.input-group input[aria-invalid="true"],
.input-group select[aria-invalid="true"] { border-color: var(--error); background: var(--error-bg); }

.field-error { color: var(--error); font-size: 0.9rem; margin: 6px 0 0; min-height: 0; }
.field-error:empty { display: none; }

.hint { font-size: 0.93rem; color: var(--grey-700); background: var(--teal-50); border-left: 3px solid var(--teal-500); padding: 10px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.form-error {
  background: var(--error-bg); color: var(--error); border: 1px solid #fecaca;
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 16px; font-size: 0.95rem;
}
.form-error ul { margin: 6px 0 0; padding-left: 20px; }

.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.result-card { min-height: 100%; }
.result-empty { text-align: center; color: var(--grey-500); padding: 40px 10px; }
.result-empty svg { width: 56px; height: 56px; color: var(--grey-200); margin-bottom: 10px; }

.result-values { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.result-value {
  background: var(--navy-800); color: var(--white); border-radius: var(--radius-sm);
  padding: 14px; display: flex; flex-direction: column; gap: 4px;
}
.result-value:nth-child(2) { background: var(--navy-700); }
.result-value:nth-child(3) { background: var(--teal-600); }
.result-label { font-size: 0.82rem; color: #d3deec; }
.result-value:nth-child(3) .result-label { color: var(--teal-50); }
.result-number { font-size: 1.35rem; font-weight: 700; word-break: break-word; }
.result-summary { background: var(--teal-50); border: 1px solid var(--teal-100); padding: 12px 14px; border-radius: var(--radius-sm); }

.steps { padding-left: 22px; margin: 0 0 1em; }
.steps li { margin-bottom: 10px; }
.steps .math, .math {
  display: block; font-family: var(--font-mono); background: var(--grey-50);
  border: 1px solid var(--grey-100); border-radius: 6px; padding: 6px 10px; margin-top: 4px;
  font-size: 0.95rem; overflow-x: auto;
}
.result-note { background: var(--warning-bg); color: var(--warning); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 0.95rem; }

/* ---------- Worked example ---------- */
.example-question { font-size: 1.08rem; background: var(--grey-50); padding: 14px 16px; border-radius: var(--radius-sm); }
.example-steps { counter-reset: step; list-style: none; padding: 0; margin: 24px 0; }
.example-steps li {
  counter-increment: step; position: relative; padding: 0 0 18px 52px;
  border-left: 2px solid var(--teal-100); margin-left: 17px;
}
.example-steps li:last-child { border-left-color: transparent; }
.example-steps li::before {
  content: counter(step); position: absolute; left: -18px; top: -2px;
  width: 34px; height: 34px; border-radius: 50%; background: var(--teal-600); color: var(--white);
  display: grid; place-items: center; font-weight: 700; font-size: 0.95rem;
}
.example-steps h3 { font-size: 1.05rem; margin-bottom: 4px; }
.example-steps p { margin-bottom: 6px; }

.callout { border-radius: var(--radius-sm); padding: 14px 16px; margin-top: 14px; background: var(--success-bg); border: 1px solid #a7f3d0; }
.callout-tip { background: var(--teal-50); border-color: var(--teal-100); }
.callout-warning { background: var(--warning-bg); border-color: #fde68a; color: var(--warning); }

.tick-list { list-style: none; padding: 0; }
.tick-list li { position: relative; padding-left: 28px; margin-bottom: 8px; }
.tick-list li::before { content: "✓"; position: absolute; left: 4px; color: var(--teal-600); font-weight: 700; }

/* ---------- Practice ---------- */
.score-bar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
  background: var(--navy-800); color: var(--white); border-radius: var(--radius-sm);
  padding: 8px 8px 8px 18px; margin-bottom: 20px;
}
.score-bar .btn-link { color: var(--teal-100); }
.questions { display: grid; gap: 18px; }
.question { padding: 24px; }
.question-head { display: flex; gap: 12px; align-items: baseline; margin-bottom: 6px; flex-wrap: wrap; }
.question-num { font-weight: 700; color: var(--teal-600); }
.question-topic {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em;
  background: var(--grey-100); color: var(--grey-700); padding: 2px 10px; border-radius: 99px;
}
.question-text { font-weight: 500; }
.answer-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.answer-row label { width: 100%; font-size: 0.9rem; color: var(--grey-700); font-weight: 600; }
.answer-row input { width: 11rem; max-width: 100%; border-radius: var(--radius-sm); }
.answer-unit { color: var(--grey-700); font-weight: 600; }
.feedback { margin: 12px 0 0; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 0.95rem; }
.feedback:empty { display: none; }
.feedback.correct { background: var(--success-bg); color: var(--success); }
.feedback.incorrect { background: var(--error-bg); color: var(--error); }
.feedback.info { background: var(--warning-bg); color: var(--warning); }
.solution { margin-top: 12px; background: var(--grey-50); border: 1px solid var(--grey-100); border-radius: var(--radius-sm); padding: 14px 16px; }
.solution p:last-child { margin-bottom: 0; }

/* ---------- Footer ---------- */
.site-footer { background: var(--navy-900); color: #b6c3d6; padding: 40px 0; font-size: 0.93rem; }
.footer-inner { text-align: center; }
.footer-brand { color: var(--white); font-weight: 700; font-size: 1.1rem; }
.footer-small { color: #7f90a8; margin: 0; }

/* ==========================================================
   Responsive
   ========================================================== */
@media (max-width: 900px) {
  .hero-inner { grid-template-columns: 1fr; gap: 32px; }
  .calc-layout { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .features { margin-top: -28px; }
}

/* Five nav links need more room than the single-page version, so the
   menu collapses at 880px (was 760px). */
@media (max-width: 880px) {
  .nav-toggle { display: block; }
  .site-nav {
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--navy-800); border-top: 1px solid var(--navy-700);
    display: none; box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
  }
  .site-nav.open { display: block; }
  .site-nav ul { flex-direction: column; padding: 8px 12px 14px; }
  .site-nav a { padding: 12px 14px; }
}

@media (max-width: 560px) {
  body { font-size: 1rem; }
  .container { padding: 0 16px; }
  .hero { padding: 48px 0 64px; }
  .section { padding: 52px 0; }
  .card { padding: 20px; }
  .question { padding: 20px; }
  .hero-actions .btn { width: 100%; }
  .result-values { grid-template-columns: 1fr; }
  .result-value { flex-direction: row; justify-content: space-between; align-items: center; }
  .input-group select { width: 8rem; }
  .form-actions .btn-primary, .form-actions .btn-ghost { flex: 1 1 auto; }
  .example-steps li { padding-left: 36px; }
  .brand { font-size: 1.02rem; }
}

/* ==========================================================
   Multi-page additions
   ========================================================== */

/* Current page / section in the main navigation */
.site-nav a[aria-current] {
  background: var(--navy-700); color: var(--white);
  box-shadow: inset 0 -2px 0 var(--teal-500);
}

/* Inner-page header */
.page-hero {
  background:
    radial-gradient(circle at 90% 10%, rgba(20, 184, 166, 0.16), transparent 40%),
    linear-gradient(160deg, var(--navy-800) 0%, var(--navy-700) 100%);
  color: var(--white);
  padding: 36px 0 48px;
}
.page-hero h1 { color: var(--white); font-size: clamp(1.8rem, 4vw, 2.6rem); margin-bottom: 0.35em; }
.page-hero .lead { color: #d3deec; font-size: 1.12rem; max-width: 44em; margin: 0; }
.page-hero .eyebrow { color: var(--teal-500); }

/* Breadcrumbs */
.breadcrumb ol {
  list-style: none; display: flex; flex-wrap: wrap; padding: 0; margin: 0 0 20px;
  font-size: 0.9rem;
}
.breadcrumb li { color: #c3d0e2; }
.breadcrumb li + li::before { content: "/"; margin: 0 8px; color: #7f90a8; }
.breadcrumb a { color: var(--teal-100); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb [aria-current] { color: var(--white); }

/* Cards that are links */
.link-card {
  display: block; text-decoration: none; color: inherit;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.link-card:hover { border-color: var(--teal-500); transform: translateY(-2px); }
.link-card h3 { color: var(--navy-800); }
.card-link-text { display: inline-block; margin-top: 14px; color: var(--teal-600); font-weight: 600; }
.link-card:hover .card-link-text { text-decoration: underline; text-underline-offset: 3px; }

/* Numbered "how it works" cards */
.step-num {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--teal-600); color: var(--white); font-weight: 700; margin-bottom: 12px;
}
.step-card p { color: var(--grey-700); margin: 0; }

/* Calculator directory */
.directory-card { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: start; }
.directory-card .feature-icon { margin: 0; width: 56px; height: 56px; }
.directory-card .feature-icon svg { width: 30px; height: 30px; }
.directory-card h2 { font-size: 1.45rem; margin-bottom: 0.3em; }
.directory-formula { font-family: var(--font-mono); color: var(--teal-600); font-weight: 700; margin-bottom: 0.6em; }
.directory-card ul { margin: 0 0 18px; padding-left: 20px; color: var(--grey-700); }
.directory-card li { margin-bottom: 4px; }
.muted { color: var(--grey-500); font-size: 0.95rem; }

/* Learning centre */
.toc ol { margin: 0; padding-left: 22px; columns: 2; column-gap: 32px; }
.toc li { margin-bottom: 6px; break-inside: avoid; }
.toc h2 { font-size: 1.15rem; }
.topics { display: grid; gap: 24px; margin-top: 24px; }
.topic h2 { font-size: clamp(1.35rem, 2.6vw, 1.7rem); }
.topic h3 { margin-top: 1.2em; }
.topic-actions { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--grey-100); }
.topic-actions a { font-weight: 600; }

.table-wrap { overflow-x: auto; margin: 0 0 1em; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.data-table th,
.data-table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--grey-200); }
.data-table th { background: var(--grey-50); color: var(--navy-800); }

/* Call-to-action band */
.cta-band {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px;
  background: var(--teal-50); border: 1px solid var(--teal-100); border-radius: var(--radius);
  padding: 22px 24px; margin-top: 32px;
}
.cta-band p { margin: 0; font-weight: 600; color: var(--navy-800); }
.cta-band .btn-group { display: flex; flex-wrap: wrap; gap: 10px; }

/* Footer navigation */
.footer-nav ul {
  list-style: none; display: flex; flex-wrap: wrap; justify-content: center;
  gap: 4px 20px; padding: 0; margin: 0 0 16px;
}
.footer-nav a { color: #dbe4f0; text-decoration: none; }
.footer-nav a:hover { color: var(--teal-500); text-decoration: underline; }

@media (max-width: 700px) {
  .toc ol { columns: 1; }
}

@media (max-width: 560px) {
  .page-hero { padding: 28px 0 40px; }
  .directory-card { grid-template-columns: 1fr; gap: 14px; }
  .cta-band { padding: 18px; }
  .cta-band .btn-group, .cta-band .btn { width: 100%; }
  .directory-card .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

@media print {
  .site-header, .hero-actions, .form-actions, .nav-toggle, .breadcrumb, .cta-band, .footer-nav { display: none; }
  .disclaimer-bar { background: none; color: var(--text); border-bottom: 1px solid var(--grey-200); }
  .disclaimer-bar strong { color: var(--text); }
  .hero, .page-hero { background: none; color: var(--text); padding: 20px 0; }
  .hero h1, .page-hero h1 { color: var(--navy-800); }
  .page-hero .lead { color: var(--grey-700); }
  .card { box-shadow: none; }
}
