/* ============================================================
   PilotDECODER — shared design system
   Single source of truth for tokens, chrome, and components.
   Load in every page with a RELATIVE path (works from Finder and server):
     homepage:   <link rel="stylesheet" href="assets/site.css?v=1">
     tool pages: <link rel="stylesheet" href="../assets/site.css?v=1">
   Pages add ONLY page-specific styles in their own inline <style>.
   Layer order below: 1 tokens → 2 base → 3 chrome → 4 components.
   ============================================================ */

/* ---------- 1. DESIGN TOKENS ---------- */
:root {
  --white:       #ffffff;
  --wash:        #daf1f3;
  --accent:      #b8e4e9;
  --mid:         #2a7680;
  --brand:       #14555e;
  --brand-deep:  #0e3f46;
  --ink:         #0a2e33;
  --ink-soft:    #45696f;
  --rule:        #c4e5e9;
  --card-bd:     #a3c4c8;
  --ifr:         #e23b3b;
  --placeholder: #a1a8ae;
  --input-ink:   #474d54;
  --focus-ring:  rgba(42,118,128,0.25);
  --btn-shadow:  rgba(20,85,94,0.26);
  --surface:     #ffffff;
  --err-bg:      #fdeced;
  --err-fg:      #8f2222;
  --brand-ink:   var(--brand);
  color-scheme: light;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Consolas, Menlo, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
[data-theme="blue"] {
  --wash: #f4fafe; --accent: #a3d8f7; --mid: #0f649c; --brand: #0d6eac; --brand-deep: #0a5787;
  --ink: #0b2c44; --ink-soft: #45688a; --rule: #cfe7f7; --card-bd: #c6e2f5; --ifr: #d2232a;
  --focus-ring: rgba(15,100,156,0.28); --btn-shadow: rgba(13,110,172,0.26);
}

/* ---------- 2. BASE ---------- */
* { box-sizing: border-box; }
/* overflow-x: clip (not hidden) — hidden silently disables position: sticky */
html, body { margin: 0; padding: 0; overflow-x: clip; }
html { background: var(--surface); -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans); color: var(--ink); background: var(--surface);
  line-height: 1.55; -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; min-height: 100vh;
}
main { flex: 1 0 auto; }
.wrap { max-width: 880px; margin: 0 auto; padding: 0 20px; width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--wash); color: var(--brand-ink); padding: 1px 6px; border-radius: 4px; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--mid); outline-offset: 2px; }
main a { color: var(--mid); text-decoration: underline; text-underline-offset: 3px; }
main a:hover { color: var(--brand); }

/* ---------- 3. SITE CHROME ---------- */
/* Top bar */
.topbar { background: var(--brand); height: 48px; flex-shrink: 0; }
.topbar .wrap { display: flex; justify-content: space-between; align-items: center; }
.brand { display: inline-block; line-height: 48px; font-family: var(--mono); font-weight: 700; font-size: 19px; letter-spacing: 0.03em; color: var(--white); text-decoration: none; }
.brand span { color: var(--accent); }
#theme-btn { box-sizing: border-box; position: relative; width: 36px; height: 20px; border-radius: 999px; background: rgba(255,255,255,0.22); border: 1px solid rgba(255,255,255,0.5); cursor: pointer; padding: 0; }
#theme-btn:hover { background: rgba(255,255,255,0.32); }
#theme-btn::after { content: ""; position: absolute; inset: -8px; } /* enlarges the tap target to ~52x36 without changing the visual */
#theme-btn .knob { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--white); transition: transform .15s ease; }
[data-theme="blue"] #theme-btn .knob { transform: translateX(16px); }

/* Masthead */
.masthead { background: var(--surface); color: var(--ink); border-bottom: 3px solid transparent; border-image: linear-gradient(90deg, var(--mid), var(--accent)) 1; padding: 32px 0 20px; }
.crumbs { font-size: 13px; color: var(--ink-soft); margin: 0 0 18px; }
.crumbs a { color: var(--mid); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; text-underline-offset: 3px; }
.crumbs .sep { margin: 0 7px; color: var(--ink-soft); }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; }
.masthead p { margin: 0; max-width: 56ch; color: var(--ink-soft); font-size: 16px; }
.masthead-desc { margin-top: 10px !important; font-size: 14px !important; }
.eyebrow { font-family: var(--sans); font-size: clamp(24px, 5vw, 31px); font-weight: 800; letter-spacing: -0.01em; line-height: 1.15; color: var(--ink); margin: 0 0 10px; }
.intro-note { margin: 0; font-size: 15px; color: var(--ink); max-width: 62ch; line-height: 1.6; }
.intro-note a { color: var(--mid); text-decoration: underline; text-underline-offset: 3px; }
.intro-note a:hover { color: var(--brand); }

/* Footer */
footer { flex-shrink: 0; background: var(--wash); border-top: 1px solid var(--rule); padding: 28px 0 0; font-size: 13px; color: var(--ink-soft); margin-top: auto; }
footer a { color: var(--mid); text-decoration: none; }
footer a:hover { text-decoration: underline; }
.source { margin: 0 0 12px; font-size: 12px; color: var(--ink-soft); line-height: 1.6; }
.source-list { margin: 4px 0 12px; padding-left: 20px; list-style: disc outside; }
.source-list li { margin: 2px 0; }
.disclaimer { margin: 0 0 14px; font-size: 12px; color: var(--ink-soft); line-height: 1.6; }
.copyright { margin-top: 24px; background: var(--brand); color: var(--white); padding: 14px 0; font-size: 13px; }
.copyright a { color: var(--white); text-decoration: underline; text-underline-offset: 3px; }
.copyright a:hover { color: var(--accent); }

/* ---------- 4. SHARED COMPONENTS ---------- */
/* Section headings */
.sec-label { font-family: var(--sans); font-size: 20px; font-weight: 700; color: #000000; margin: 34px 0 0; }
.calc-head { font-family: var(--sans); font-size: 21px; font-weight: 700; color: var(--ink); margin: 44px 0 0; padding-bottom: 10px; border-bottom: 3px solid transparent; border-image: linear-gradient(90deg, var(--mid), var(--accent)) 1; }
.block-head, .block h2, .step h3 { font-family: var(--sans); font-size: 16.5px; font-weight: 700; color: var(--brand); margin: 0 0 6px; padding-bottom: 8px; border-bottom: 1px solid var(--rule); }

/* Input panel (full-bleed wash band) */
.panel { background: var(--wash); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 26px 0 30px; }
.panel-label { display: block; font-family: var(--sans); font-size: 14px; font-weight: 700; color: var(--brand); margin-bottom: 6px; }

/* Form fields */
.field-grid { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 4px; }
.field { flex: 1 1 180px; min-width: 170px; }
.field label { display: flex; align-items: flex-end; min-height: 26px; line-height: 1.3; font-family: var(--sans); font-size: 13px; font-weight: 600; color: var(--mid); margin-bottom: 6px; }
.field input, .field select, select.select, textarea.text-input {
  width: 100%; background: var(--surface); color: var(--input-ink);
  border: 1px solid var(--card-bd); border-radius: 8px; padding: 10px 14px;
  font-family: var(--mono); font-size: 16px; line-height: 1.5;
}
textarea.text-input { min-height: 110px; resize: vertical; padding: 12px 14px; line-height: 1.6; letter-spacing: 0.01em; }
/* inputs stay 16px on touch screens (smaller triggers iOS auto-zoom on focus);
   on desktop, 14px mono sits proportionate with the surrounding text */
@media (min-width: 700px) {
  .field input, .field select, select.select, textarea.text-input { font-size: 14px; }
}
.field input::placeholder, textarea.text-input::placeholder { color: var(--placeholder); }
.field input:focus, .field select:focus, select.select:focus, textarea.text-input:focus { outline: none; border-color: var(--mid); box-shadow: 0 0 0 3px var(--focus-ring); }
.field .hint { margin: 6px 0 0; font-size: 12px; color: var(--ink-soft); line-height: 1.5; }
.field .hint a { color: var(--mid); text-decoration: underline; text-underline-offset: 3px; }
.field .hint a:hover { color: var(--brand); }
input[type="range"] { accent-color: var(--mid); }

/* Buttons */
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 16px; }
.btn-primary { font-family: var(--sans); font-size: 13.5px; font-weight: 700; color: var(--white); background: var(--brand); border: none; border-radius: 6px; padding: 8px 16px; cursor: pointer; transition: transform .06s ease, background .15s ease, box-shadow .15s ease; box-shadow: 0 6px 16px var(--btn-shadow); }
.btn-primary:hover { background: var(--brand-deep); }
.btn-primary:active { transform: translateY(1px); }
.btn-secondary { font-family: var(--sans); font-size: 13px; font-weight: 600; color: var(--ink); background: var(--surface); border: 1px solid var(--card-bd); border-radius: 7px; padding: 8px 11px; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.btn-secondary:hover { border-color: var(--mid); color: var(--brand); }
.btn-secondary:active { transform: translateY(1px); }
.btn-secondary.active, .btn-secondary[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--white); }
.btn-secondary[disabled] { opacity: .45; cursor: default; }
.btn-sm { font-size: 12px; padding: 5px 9px; }
.link-btn { background: none; border: none; color: var(--ink-soft); font-family: var(--sans); font-size: 13px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; padding: 6px 2px; }
.link-btn:hover { color: var(--brand); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--card-bd); border-radius: 10px; padding: 14px 16px; }
.tool-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.tool-card { position: relative; display: block; border: 1px solid var(--card-bd); border-radius: 10px; padding: 9px 44px 10px 14px; text-decoration: none; background: var(--surface); transition: border-color .15s ease, box-shadow .15s ease; }
.tool-card::after { content: "\2192"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 18px; color: var(--mid); transition: transform .15s ease; }
.tool-card:hover { border-color: var(--mid); box-shadow: 0 6px 16px var(--btn-shadow); }
.tool-card:hover::after { transform: translateY(-50%) translateX(3px); }
.tool-card:focus-visible { outline: none; border-color: var(--mid); box-shadow: 0 0 0 3px var(--focus-ring); }
.tool-name { font-family: var(--sans); font-weight: 700; font-size: 15.5px; color: var(--brand); margin: 0 0 1px; }
.tool-desc { margin: 0; font-size: 13.5px; color: var(--ink-soft); line-height: 1.45; }

/* Framed figure (charts, instruments, diagrams) */
.chart-frame { margin-top: 18px; border: 1px solid var(--rule); border-radius: 8px; padding: 14px 10px 8px; background: var(--surface); overflow-x: hidden; }

/* Callout (key point, result) */
.callout { margin: 14px 0; background: var(--wash); border: 1px solid var(--rule); border-left: 4px solid var(--brand); border-radius: 8px; padding: 14px 18px; }
.callout p { margin: 0; color: var(--ink); }

/* Lists */
.summary-list { margin: 12px 0 0; padding: 0; list-style: none; }
.summary-list li { position: relative; padding: 7px 0 7px 22px; font-size: 15.5px; }
.summary-list li::before { content: ""; position: absolute; left: 2px; top: 15px; width: 7px; height: 7px; border-radius: 50%; background: var(--mid); }
.note-line { margin: 10px 0 0; padding-left: 20px; list-style: disc outside; font-size: 12.5px; font-style: italic; color: var(--ink-soft); line-height: 1.5; }
.note-line li { display: list-item; margin: 1px 0; }
.res-list { list-style: disc outside; margin: 10px 0 0; padding: 0 0 0 22px; }
.res-list li { padding: 4px 0; font-size: 14px; line-height: 1.55; }
.res-list a { font-weight: 600; color: var(--ink); text-decoration: none; }
.res-list a:hover { text-decoration: underline; text-underline-offset: 3px; }
.res-desc { color: var(--ink-soft); }
.res-sublabel { font-family: var(--sans); font-size: 14.5px; font-weight: 700; color: #666666; margin: 20px 0 0; }
.res-sublabel:first-of-type { margin-top: 14px; }
.res-sublabel + .res-list { margin-top: 4px; }

/* Source hint under input panels */
.metar-source-hint { margin: 14px 0 0; font-size: 13.5px; color: var(--ink-soft); font-family: var(--sans); }
.metar-source-hint a { color: var(--mid); text-decoration: underline; text-underline-offset: 3px; }
.metar-source-hint a:hover { color: var(--brand); }

/* Feedback */
.error-note { margin: 26px 0 0; padding: 14px 18px; border-left: 3px solid var(--ifr); background: var(--err-bg); color: var(--err-fg); font-size: 15px; border-radius: 0 6px 6px 0; }
.range-warn { margin: 12px 0 0; font-size: 12.5px; color: var(--err-fg); background: var(--err-bg); border-radius: 6px; padding: 8px 12px; display: none; }
.range-warn.show { display: block; }

/* ---------- MOTION ---------- */
@media (prefers-reduced-motion: reduce) {
  #theme-btn .knob, .tool-card, .tool-card::after, .btn-primary { transition: none; }
}
