/* ==========================================================================
   BIG LAP NAVIGATOR — Design Tokens
   Palette inferred from the Australian outback & coast:
   ochre/rust (red earth) primary accent, deep teal (reef & southern ocean)
   secondary accent, warm sand neutrals, eucalyptus green for success states.
   ========================================================================== */

:root,
[data-theme='light'] {
  /* Surfaces */
  --color-bg: #faf6ee;
  --color-surface: #ffffff;
  --color-surface-2: #fdfbf6;
  --color-surface-offset: #f2e9d8;
  --color-surface-offset-2: #ece0c9;
  --color-divider: #e6dac0;
  --color-border: #ddcda9;

  /* Text */
  --color-text: #2b2013;
  --color-text-muted: #6f6046;
  --color-text-faint: #a99a7b;
  --color-text-inverse: #faf6ee;

  /* Primary accent — Ochre / burnt rust */
  --color-primary: #c1440e;
  --color-primary-hover: #9e3609;
  --color-primary-active: #7a2a07;
  --color-primary-highlight: #f2d9c6;

  /* Secondary accent — Deep teal (coast / reef) */
  --color-secondary: #0f6e77;
  --color-secondary-hover: #0b565d;
  --color-secondary-active: #084146;
  --color-secondary-highlight: #cfe4e3;

  /* Severity / semantic */
  --color-warning: #b8860b;
  --color-warning-hover: #93690a;
  --color-warning-highlight: #ecdcb8;
  --color-error: #a3241b;
  --color-error-hover: #7f1c15;
  --color-error-highlight: #ecd0cc;
  --color-success: #4c7a3d;
  --color-success-hover: #3a5e2f;
  --color-success-highlight: #d7e4cf;

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1.25rem;
  --radius-full: 9999px;

  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  --shadow-sm: 0 1px 2px rgba(43, 32, 19, 0.08);
  --shadow-md: 0 6px 16px rgba(43, 32, 19, 0.1);
  --shadow-lg: 0 16px 40px rgba(43, 32, 19, 0.16);

  --content-default: 1180px;
  --content-narrow: 720px;

  --font-display: 'Clash Display', 'Georgia', sans-serif;
  --font-body: 'General Sans', 'Helvetica Neue', sans-serif;

  /* Hero illustration */
  --color-hero-sky-top: #f7cf9a;
  --color-hero-sky-bottom: #fbe6c8;
  --color-hero-sun: #f3a24d;
  --color-hero-dune-far: #e6b585;
  --color-hero-dune-near: #c1440e;
  --color-hero-road: #3a2c1c;
  --color-hero-road-dash: #f2d9c6;
  --color-hero-vehicle: #faf6ee;
  --color-hero-vehicle-dark: #2b2013;
}

[data-theme='dark'] {
  --color-bg: #1b140d;
  --color-surface: #221a11;
  --color-surface-2: #271e13;
  --color-surface-offset: #2f2416;
  --color-surface-offset-2: #392c1a;
  --color-divider: #3a2d1b;
  --color-border: #473721;

  --color-text: #f2e9d8;
  --color-text-muted: #bfae8d;
  --color-text-faint: #7d6f56;
  --color-text-inverse: #2b2013;

  --color-primary: #ea8144;
  --color-primary-hover: #f2985f;
  --color-primary-active: #f7ac7c;
  --color-primary-highlight: #4a3324;

  --color-secondary: #56b6bd;
  --color-secondary-hover: #79c7cd;
  --color-secondary-active: #9ad7dc;
  --color-secondary-highlight: #234143;

  --color-warning: #e0b23f;
  --color-warning-hover: #ecc568;
  --color-warning-highlight: #4a3d20;
  --color-error: #e0685c;
  --color-error-hover: #e88a80;
  --color-error-highlight: #4a2620;
  --color-success: #8fbf7a;
  --color-success-hover: #a6cf95;
  --color-success-highlight: #2f3d26;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);

  --color-hero-sky-top: #241a10;
  --color-hero-sky-bottom: #362715;
  --color-hero-sun: #ea8144;
  --color-hero-dune-far: #3a2c1c;
  --color-hero-dune-near: #472e18;
  --color-hero-road: #100b07;
  --color-hero-road-dash: #ea8144;
  --color-hero-vehicle: #f2e9d8;
  --color-hero-vehicle-dark: #100b07;
}

/* ==========================================================================
   Type scale
   ========================================================================== */
:root {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.25rem);
  --text-3xl: clamp(2.5rem, 1rem + 4vw, 4.5rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;
}

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

html {
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}

body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  transition: background-color var(--transition-interactive), color var(--transition-interactive);
}

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

h1, h2, h3, h4 { font-family: var(--font-display); text-wrap: balance; line-height: 1.1; font-weight: 600; }
p, li { text-wrap: pretty; }

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

button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
input, select { font: inherit; color: inherit; }

table { border-collapse: collapse; width: 100%; }

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  padding: var(--space-3) var(--space-4);
  z-index: 200;
  border-radius: var(--radius-sm);
}
.skip-link:focus { left: var(--space-4); top: var(--space-4); }

.container {
  max-width: var(--content-default);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-divider);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-block: var(--space-3);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-base);
}
.logo:hover { text-decoration: none; color: var(--color-primary); }
.logo svg { color: var(--color-primary); flex-shrink: 0; }

.site-nav {
  display: flex;
  gap: var(--space-6);
  font-size: var(--text-sm);
  font-weight: 500;
}
.site-nav a { color: var(--color-text-muted); }
.site-nav a:hover { color: var(--color-primary); text-decoration: none; }

@media (max-width: 720px) {
  .site-nav { display: none; }
}

.theme-toggle {
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--color-surface-offset); }

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
  position: relative;
  overflow: hidden;
  padding-top: clamp(var(--space-16), 8vw, var(--space-24));
  background: var(--color-hero-sky-bottom);
}

.hero-illustration {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.hero-illustration svg { width: 100%; height: 100%; }

.hero-content {
  position: relative;
  z-index: 1;
  padding-bottom: clamp(var(--space-16), 8vw, var(--space-24));
  max-width: 780px;
}

.eyebrow {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-primary);
  margin-bottom: var(--space-4);
}

.hero h1 {
  font-size: var(--text-2xl);
  color: var(--color-text);
  margin-bottom: var(--space-5);
}

.hero .lede {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  max-width: 62ch;
  margin-bottom: var(--space-10);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-6);
  background: color-mix(in srgb, var(--color-surface) 88%, transparent);
  backdrop-filter: blur(6px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
}

.stat { display: flex; flex-direction: column; gap: var(--space-1); }
.stat-value { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600; color: var(--color-primary); }
.stat-label { font-size: var(--text-xs); color: var(--color-text-muted); }

@media (max-width: 720px) {
  .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { padding-top: var(--space-10); }
  .hero h1 { font-size: var(--text-xl); margin-bottom: var(--space-3); }
  .hero .lede { font-size: var(--text-sm); max-width: 42ch; margin-bottom: var(--space-6); }
  .hero-content { padding-bottom: var(--space-8); }
  .hero-stats { padding: var(--space-4); gap: var(--space-4); }
  .hero-caravan { display: none; }
  .hero-sun { r: 50; }
}

/* ==========================================================================
   Sections shared
   ========================================================================== */
main > section {
  padding-block: clamp(var(--space-12), 6vw, var(--space-20));
}

.section-heading { max-width: 62ch; margin-bottom: var(--space-8); }
.section-heading h2 { font-size: var(--text-xl); margin-bottom: var(--space-3); }
.section-heading p { color: var(--color-text-muted); font-size: var(--text-base); }

/* ==========================================================================
   Travel notes callout
   ========================================================================== */
.notes-section { background: var(--color-surface-offset); border-radius: var(--radius-xl); }

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-5);
}

.note-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-warning);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  box-shadow: var(--shadow-sm);
}
.note-card.severity-high { border-left-color: var(--color-error); }
.note-card.severity-medium { border-left-color: var(--color-warning); }

.note-card h3 { font-family: var(--font-body); font-weight: 600; font-size: var(--text-base); }
.note-card p { color: var(--color-text-muted); font-size: var(--text-sm); }
.note-card a { font-size: var(--text-sm); font-weight: 600; white-space: nowrap; }

/* ==========================================================================
   Map section
   ========================================================================== */
.map-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-5);
}

.month-filter {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.month-btn {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
}
.month-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.month-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-inverse);
}

.layer-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: center;
}

.layer-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
}
.layer-toggle input { accent-color: var(--color-primary); width: 1rem; height: 1rem; }

.swatch { width: 0.85rem; height: 0.85rem; border-radius: var(--radius-full); display: inline-block; flex-shrink: 0; }
.swatch-route { background: var(--color-primary); }
.swatch-highlight { background: var(--color-secondary); }
.swatch-fuel { background: var(--color-warning); }
.swatch-risk { background: var(--color-error); }

.map-frame {
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
}

.map-canvas {
  width: 100%;
  height: 640px;
  background: var(--color-surface-offset);
}
@media (max-width: 720px) {
  .map-canvas { height: 460px; }
}

.map-legend {
  position: absolute;
  bottom: var(--space-3);
  left: var(--space-3);
  background: color-mix(in srgb, var(--color-surface) 92%, transparent);
  backdrop-filter: blur(6px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  max-width: 220px;
}

/* Popup styling to match theme */
.maplibregl-popup-content {
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-4);
  font-family: var(--font-body);
  max-width: 260px;
}
.maplibregl-popup-tip { border-top-color: var(--color-surface) !important; border-bottom-color: var(--color-surface) !important; }
.maplibregl-popup-close-button { color: var(--color-text-muted); font-size: 1.1rem; }
.map-popup-title { font-family: var(--font-display); font-weight: 600; font-size: var(--text-sm); margin-bottom: var(--space-1); }
.map-popup-meta { font-size: var(--text-xs); color: var(--color-text-faint); margin-bottom: var(--space-2); }
.map-popup-desc { font-size: var(--text-xs); color: var(--color-text-muted); margin-bottom: var(--space-2); }
.map-popup-link { font-size: var(--text-xs); font-weight: 600; }
.map-popup-severity { display: inline-block; font-size: 0.65rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; padding: 0.1rem 0.5rem; border-radius: var(--radius-full); margin-bottom: var(--space-2); }
.map-popup-severity.high { background: var(--color-error-highlight); color: var(--color-error); }
.map-popup-severity.medium { background: var(--color-warning-highlight); color: var(--color-warning); }
.map-popup-severity.low { background: var(--color-success-highlight); color: var(--color-success); }

/* Month detail panel */
.month-detail {
  margin-top: var(--space-6);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}
.month-detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-4); margin-bottom: var(--space-4); flex-wrap: wrap; }
.month-detail-header h3 { font-size: var(--text-lg); }
.month-detail-header .meta { color: var(--color-text-muted); font-size: var(--text-sm); }
.month-detail-close { color: var(--color-text-muted); font-size: var(--text-sm); font-weight: 600; }

.month-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-6);
}
.month-detail-grid h4 { font-size: var(--text-sm); font-weight: 600; margin-bottom: var(--space-3); color: var(--color-text); }
.month-detail-grid ul { list-style: none; display: flex; flex-direction: column; gap: var(--space-2); }
.month-detail-grid li { font-size: var(--text-sm); color: var(--color-text-muted); }
.month-detail-grid li a { font-weight: 600; }

.risk-pill { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-xs); font-weight: 700; padding: 0.15rem 0.55rem; border-radius: var(--radius-full); margin-right: var(--space-2); }
.risk-pill.high { background: var(--color-error-highlight); color: var(--color-error); }
.risk-pill.medium { background: var(--color-warning-highlight); color: var(--color-warning); }
.risk-pill.low { background: var(--color-success-highlight); color: var(--color-success); }

/* ==========================================================================
   Itinerary table
   ========================================================================== */
.table-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.search-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1 1 280px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding-inline: var(--space-3);
}
.search-field svg { color: var(--color-text-faint); flex-shrink: 0; }
.search-field input {
  border: none;
  outline: none;
  background: transparent;
  padding-block: var(--space-3);
  width: 100%;
  font-size: var(--text-sm);
  color: var(--color-text);
}

#table-month-filter {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  font-size: var(--text-sm);
  color: var(--color-text);
}

.table-scroll-hint {
  display: none;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-2);
}

.table-wrap {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

@media (max-width: 720px) {
  .table-scroll-hint { display: block; }
}

#itinerary-table { min-width: 760px; }
#itinerary-table th {
  text-align: left;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  background: var(--color-surface-offset);
  padding: var(--space-3) var(--space-4);
  position: sticky;
  top: 0;
}
#itinerary-table td {
  padding: var(--space-4);
  border-top: 1px solid var(--color-divider);
  font-size: var(--text-sm);
  vertical-align: top;
}
#itinerary-table tr:hover td { background: var(--color-surface-offset); }

.month-cell { display: flex; flex-direction: column; gap: 0.15rem; }
.month-cell .month-name { font-weight: 600; font-family: var(--font-display); }
.month-cell .month-num { font-size: var(--text-xs); color: var(--color-text-faint); }

.distance-cell { font-weight: 600; white-space: nowrap; }
.distance-cell .distance-note { display: block; font-weight: 400; font-size: var(--text-xs); color: var(--color-text-faint); }

.mustsee-list { display: flex; flex-direction: column; gap: var(--space-1); }
.mustsee-list details summary { cursor: pointer; font-size: var(--text-xs); color: var(--color-secondary); font-weight: 600; margin-top: var(--space-1); list-style: none; }
.mustsee-list details summary::-webkit-details-marker { display: none; }
.mustsee-list a { display: block; }

.booking-list { display: flex; flex-direction: column; gap: var(--space-1); }
.booking-list a { font-weight: 600; white-space: nowrap; }

.table-empty { text-align: center; padding: var(--space-10); color: var(--color-text-muted); }

/* ==========================================================================
   Sources section
   ========================================================================== */
.sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-6);
}
.source-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}
.source-card h3 { font-size: var(--text-base); margin-bottom: var(--space-3); }
.source-card p, .source-card li { font-size: var(--text-sm); color: var(--color-text-muted); }
.source-card ul { list-style: none; display: flex; flex-direction: column; gap: var(--space-2); }
.source-card a { font-weight: 600; }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  border-top: 1px solid var(--color-divider);
  padding-block: var(--space-8);
}
.footer-inner { font-size: var(--text-xs); color: var(--color-text-faint); max-width: 70ch; }
