/* ============================================================
   MilePilot — design system v1
   Inter (variable, self-hosted). Light + dark via system setting.
   Used by the homepage first; other pages migrate later.
   ============================================================ */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-latin-wght.woff2') format('woff2');
}

:root {
  --bg: #F5F6F8; --surface: #FFFFFF; --surface-2: #EEF0F4; --line: #E1E5EB;
  --ink: #0B1220; --ink-2: #434C5E; --ink-3: #586174;
  --accent: #2457FF; --accent-ink: #FFFFFF; --accent-soft: #E7EDFF;
  --good: #0B7F52; --good-soft: #E1F5EC;
  --warn-bg: #FFF6E0; --warn-line: #F0D9A0; --warn-ink: #6B4B00;
  --shadow: 0 1px 2px rgba(11,18,32,.04), 0 8px 24px rgba(11,18,32,.06);
  --r-s: 10px; --r-m: 14px; --r-l: 22px;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23586174' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #070B14; --surface: #0F1624; --surface-2: #151D2E; --line: #222C41;
    --ink: #F2F5FA; --ink-2: #B1BACB; --ink-3: #8F9AAF;
    --accent: #7B96FF; --accent-ink: #060B1F; --accent-soft: #17224D;
    --good: #3DDC97; --good-soft: #0F2A22;
    --warn-bg: #2A2208; --warn-line: #5C4A12; --warn-ink: #F2D98A;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.35);
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238F9AAF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    color-scheme: dark;
  }
}

/* Aliases so article/blog styles share the new tokens */
:root {
  --color-text-primary: var(--ink); --color-text-secondary: var(--ink-2); --color-text-tertiary: var(--ink-3);
  --color-border: var(--line); --color-border-strong: #C3CAD6;
  --color-bg: var(--surface); --color-bg-secondary: var(--surface-2); --color-accent: var(--accent);
  --border-radius-lg: var(--r-m);
}
@media (prefers-color-scheme: dark) { :root { --color-border-strong: #34405A; } }

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}
h1, h2, h3, p, dl, dd, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ── Layout ── */
.wrap, .container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 32px; }
@media (max-width: 640px) { .wrap, .container { padding: 0 20px; } }

/* ── Header ── */
.nav { display: flex; align-items: center; justify-content: space-between; height: 68px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; letter-spacing: -.02em; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; flex: none; }
.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-links a { padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--ink-2); text-decoration: none; }
.nav-links a:hover { background: var(--surface-2); color: var(--ink); }
@media (max-width: 640px) { .nav-links a:not(.keep) { display: none; } }

/* ── Type ── */
.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: .02em; color: var(--accent); }
.h-display { font-size: clamp(38px, 6vw, 60px); line-height: 1.02; letter-spacing: -.035em; font-weight: 650; }
.h-section { font-size: clamp(24px, 3vw, 30px); line-height: 1.15; letter-spacing: -.025em; font-weight: 650; }
.lead { font-size: 18px; line-height: 1.5; color: var(--ink-2); }
.muted { color: var(--ink-3); }
.label { font-size: 12px; font-weight: 600; color: var(--ink-3); letter-spacing: .03em; text-transform: uppercase; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -.03em; font-weight: 700; }

/* ── Buttons ── */
.btn, .cta-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 22px; border-radius: 999px; border: 1px solid transparent;
  font: 600 15px/1 'Inter', sans-serif; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--accent-ink); transition: filter .15s, transform .05s;
}
.btn:hover, .cta-button:hover { filter: brightness(1.08); }
.btn:active, .cta-button:active { transform: translateY(1px); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); filter: none; }
.btn-sm { height: 38px; padding: 0 16px; font-size: 14px; }
.btn-block { width: 100%; }
button.cta-button.btn-block { height: 56px; font-size: 16px; }

/* ── Card ── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow); }
.panel { padding: 28px; }
@media (max-width: 640px) { .panel { padding: 20px; } }
.panel > h2 { font-size: 22px; font-weight: 650; letter-spacing: -.02em; margin-bottom: 20px; }

/* ── Form controls ── */
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; min-width: 0; }
.form-row label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.form-row input, .form-row select, .form-row textarea,
.fare-currency {
  width: 100%; height: 52px; padding: 0 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-m);
  font: 500 16px 'Inter', sans-serif; color: var(--ink);
}
.form-row textarea { height: auto; padding: 14px 16px; resize: vertical; line-height: 1.5; }
.form-row select, .fare-currency {
  appearance: none; -webkit-appearance: none; padding-right: 44px;
  background-image: var(--chevron); background-repeat: no-repeat; background-position: right 16px center;
}
.form-row input::placeholder, .form-row textarea::placeholder { color: var(--ink-3); font-weight: 400; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus, .fare-currency:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}
.field-hint, .form-hint { font-size: 13px; line-height: 1.45; color: var(--ink-3); }
.form-hint:empty { display: none; }
.fare-input-group { display: flex; gap: 10px; }
.fare-input-group #fare { flex: 1; min-width: 0; }
.fare-currency { width: 120px; flex: none; }

.warning-note {
  margin-bottom: 16px; padding: 14px 16px; border-radius: var(--r-m); font-size: 14px; line-height: 1.5;
  background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn-ink);
}
.warning-note a { color: inherit; font-weight: 600; text-underline-offset: 2px; }

/* ── Mode toggle (JS toggles .active) ── */
.mode-toggle-row { margin-bottom: 20px; }
@media (max-width: 640px) { .mode-toggle { display: flex; } .mode-btn { flex: 1; padding: 0 8px; } }
.mode-toggle { display: inline-flex; padding: 4px; background: var(--surface-2); border-radius: 999px; gap: 2px; align-self: flex-start; }
.mode-btn { white-space: nowrap; height: 36px; padding: 0 18px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2); font: 600 14px/1 'Inter', sans-serif; cursor: pointer; }
.mode-btn:hover { color: var(--ink); }
.mode-btn.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(11,18,32,.14); }

/* ── Segments (markup generated by main.js) ── */
.segment { position: relative; background: var(--surface-2); border-radius: var(--r-m); padding: 16px 16px 2px; margin-bottom: 16px; display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }
.segment > .segment-header { grid-column: 1 / -1; }
@media (max-width: 640px) { .segment { grid-template-columns: 1fr; } }
.segment-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.segment-header-label { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.segment-remove { width: 32px; height: 32px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-3); font-size: 20px; line-height: 1; cursor: pointer; }
.segment-remove:hover { background: var(--surface); color: var(--ink); }
.segment-remove.hidden { display: none; }
.add-segment-row { margin-bottom: 20px; }
.add-segment-btn {
  height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: transparent;
  color: var(--ink); font: 600 14px/1 'Inter', sans-serif; cursor: pointer;
}
.add-segment-btn:hover { background: var(--surface-2); }

/* Airport autocomplete */
.autocomplete-wrapper { position: relative; z-index: 10; }
.autocomplete-wrapper:focus-within { z-index: 50; }
.autocomplete-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 200;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m);
  max-height: 260px; overflow-y: auto; box-shadow: var(--shadow); padding: 4px;
}
.autocomplete-result { padding: 10px 12px; cursor: pointer; font-size: 14px; border-radius: 8px; color: var(--ink); }
.autocomplete-result:hover { background: var(--surface-2); }

/* ── Calculator layout ── */
.calc-layout { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.calc-main { flex: 999 1 640px; min-width: 0; }
.calc-side { flex: 1 1 340px; min-width: 0; position: sticky; top: 24px; }
@media (max-width: 900px) { .calc-side { position: static; flex-basis: 100%; } }

/* ── Results ── */
.results-panel { padding: 28px; }
.results-panel h3 { font-size: 12px; font-weight: 600; color: var(--ink-3); letter-spacing: .03em; text-transform: uppercase; margin-bottom: 14px; }
.results-row { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 0; border-top: 1px solid var(--line); color: var(--ink-3); }
.results-row > span:last-child { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 17px; letter-spacing: -.02em; color: var(--ink); }
#bonus-miles { color: var(--good); }
.results-row.total { order: -1; border-top: 0; padding: 0 0 18px; flex-direction: row-reverse; justify-content: flex-end; gap: 10px; align-items: baseline; color: var(--ink-3); }
.results-row.total > span:last-child { font-size: clamp(48px, 6vw, 64px); line-height: 1; letter-spacing: -.035em; }
.results-row.total > span:first-child { font-size: 18px; font-weight: 500; }
#results { display: flex; flex-direction: column; }
#results.hidden { display: none; }
.results-empty { padding: 28px; display: flex; flex-direction: column; gap: 8px; }
.results-empty p { color: var(--ink-3); font-size: 15px; }
#results:not(.hidden) ~ .results-empty { display: none; }

.segment-breakdown { margin-top: 14px; background: var(--surface-2); border-radius: var(--r-m); }
.segment-breakdown > summary { padding: 14px 16px; font-size: 14px; font-weight: 500; cursor: pointer; list-style: none; }
.segment-breakdown > summary::-webkit-details-marker { display: none; }
.segment-breakdown-body { padding: 0 16px 8px; }
.segment-breakdown-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; font-size: 14px; border-top: 1px solid var(--line); }
.segment-breakdown-miles { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ── Compare results ── */
#compare-results { margin-top: 24px; padding: 8px 8px 0; overflow: hidden; }
#compare-results > h2 { padding: 18px 16px 6px; margin: 0; }
.compare-table-wrapper { overflow-x: auto; }
.compare-table { width: 100%; border-collapse: collapse; }
.compare-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); letter-spacing: .03em; text-transform: uppercase; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.compare-table td { padding: 14px 16px; border-bottom: 1px solid var(--line); font-size: 15px; font-weight: 500; }
.compare-table tr:last-child td { border-bottom: 0; }
.compare-table th.numeric, .compare-table td.numeric { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.compare-table tr.compare-best td { background: var(--accent-soft); }
.compare-table tr.compare-needs-fare td.numeric { font-size: 14px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; }
.compare-mode-tag { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); text-transform: capitalize; }
.compare-mode-tag.revenue { background: var(--accent-soft); color: var(--accent); }
.compare-best-badge { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; margin-left: 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--good-soft); color: var(--good); }

/* ── Sections ── */
.hero { padding-top: 56px; padding-bottom: 40px; }
.hero-inner { display: flex; flex-direction: column; gap: 20px; max-width: 760px; }
.hero .lead { max-width: 560px; }
.section { padding-bottom: 80px; }
.split { display: flex; flex-wrap: wrap; gap: 48px; }
.split > :first-child { flex: 1 1 280px; }
.split > :last-child { flex: 2 1 520px; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.chip { display: inline-flex; align-items: center; height: 32px; padding: 0 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--ink-2); }
.feature-grid { display: flex; flex-wrap: wrap; gap: 20px; }
.feature { flex: 1 1 300px; padding: 28px; box-shadow: none; }
.feature h3 { font-size: 19px; font-weight: 650; letter-spacing: -.01em; margin-bottom: 10px; }
.feature p { color: var(--ink-3); }

.qa { border-top: 1px solid var(--line); padding: 22px 0; }
.qa:last-child { border-bottom: 1px solid var(--line); }
.qa dt { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.qa dd { margin-top: 8px; color: var(--ink-2); }

.log li { display: flex; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); align-items: baseline; }
.log li:last-child { border-bottom: 1px solid var(--line); }
.log .ver { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); flex: none; }
.log li:first-child .ver { background: var(--accent-soft); color: var(--accent); }
.log .what { flex: 1; }
.log .when { color: var(--ink-3); white-space: nowrap; font-size: 14px; }

.feedback-grid { max-width: 640px; }

/* ── Footer ── */
.foot { border-top: 1px solid var(--line); padding: 32px 0; font-size: 14px; color: var(--ink-3); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; }
.foot nav { display: flex; gap: 20px; }
.foot a { text-decoration: none; }
.foot a:hover { color: var(--ink); }
