/* Look en feel volgens het website-concept (versie 2): donker, 's avonds op de snelweg.
   Lettertypes: de systeemfonts van het apparaat. Een eigen font zou een extern of zelf gehost
   bestand vragen; de CSP staat alleen 'self' toe en dit scheelt een download per bezoeker. */
:root {
  --night: #0b0d17;
  --panel: #141826;
  --panel-2: #1b2033;
  --line: #2a2f45;
  --foreground: #f4f1ea;
  --muted: #b9b6c8;
  --dim: #8f8ca3;
  --red: #da291c;
  --brand: #ff5a4a;
  --accent: #ffc72c;
  --green: #3ddc97;
  --background: var(--night);
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-head: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --touch: 2.75rem; /* aanraakdoel van minstens 44 px */
  --content-width: 72.5rem; /* ± 1160 px */
  color-scheme: light dark;
}

/* De website is donker; de countdownpagina houdt `light dark`, zodat zijn schuifbalken in lichte modus licht blijven. */
:root:not(:has(body.countdown-body)) { color-scheme: dark; }

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 5rem; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-body);
  line-height: 1.4;
}

/* De website-layout: voettekst onderaan, ruimere regelafstand. De countdownpagina
   (body.countdown-body) houdt zijn eigen opmaak. */
body:not(.countdown-body) {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0; }
body:not(.countdown-body) :is(h1, h2, h3, .big, .logo) { font-family: var(--font-head); }
/* .big (de heldkop) heeft zijn eigen grootte; daarom :not(.big). */
body:not(.countdown-body) h1:not(.big) { font-size: 1.75rem; line-height: 1.15; }
p { margin: 0; }

.muted { color: var(--muted); }
.label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.eyebrow { color: var(--accent); }
.big { font-size: 2rem; font-weight: 700; line-height: 1.1; margin-top: 0.25rem; }
.title { font-size: 1.125rem; font-weight: 600; }
.note { font-size: 0.875rem; color: var(--muted); margin-top: 0.75rem; }

.container {
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 1rem;
}

/* Kop met logo en menu */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgb(11 13 23 / 0.95);
  border-bottom: 1px solid var(--line);
}
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  min-height: 4rem;
}
.logo {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch);
  font-size: 1.375rem;
  font-weight: 700;
  color: #ffffff;
  text-decoration: none;
}
.logo span { color: var(--brand); }

.menu { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; }
.menu ul { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: 0; padding: 0; list-style: none; }
.menu a,
.menu .link-button {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch);
  padding: 0 0.875rem;
  border-radius: 0.5rem;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
}
.menu a:hover,
.menu a[aria-current="page"] { color: #ffffff; background: var(--panel); }
.menu .login { color: var(--accent); }
.menu form { margin: 0; }
.menu .link-button { background: none; border: none; font-family: inherit; cursor: pointer; }
.menu .link-button:hover { color: #ffffff; background: var(--panel); }
.account { display: flex; align-items: center; gap: 0.25rem; margin-left: 0.5rem; padding-left: 0.5rem; border-left: 1px solid var(--line); }

/* De menuknop bestaat alleen met JavaScript (static/menu.js); zonder staat het menu open. */
.burger {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: var(--touch);
  min-height: var(--touch);
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  background: transparent;
  color: var(--foreground);
  cursor: pointer;
}

a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 47.99rem) {
  .menu { width: 100%; flex-direction: column; align-items: stretch; padding-bottom: 0.75rem; }
  .menu ul { flex-direction: column; }
  .account { margin: 0; padding: 0.5rem 0 0; border-left: none; border-top: 1px solid var(--line); flex-wrap: wrap; }
  .js .burger { display: inline-flex; }
  .js .menu { display: none; }
  .js .menu.open { display: flex; }
}

/* Pagina */
.page {
  flex: 1;
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  display: grid;
  gap: 1.5rem;
  align-content: start;
}
.narrow { width: 100%; max-width: 36rem; margin: 0 auto; display: grid; gap: 1.5rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1.25rem;
}

/* Secties van de homepage */
.block { padding-top: 1.75rem; border-top: 1px solid var(--line); }
.block h2 { font-size: 1.5rem; margin: 0 0 1rem; }

.live-hero { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
.hero-card { display: flex; flex-direction: column; gap: 0.875rem; }
.next-card { border-color: rgb(255 90 74 / 0.5); display: flex; flex-direction: column; gap: 0.5rem; justify-content: center; }
.next-card .label { color: var(--brand); }
.next-card .next-name { font-family: var(--font-head); font-size: 1.5rem; font-weight: 700; line-height: 1.15; }

progress {
  width: 100%;
  height: 0.75rem;
  appearance: none;
  border: none;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line);
}
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--red), var(--accent)); }
progress::-moz-progress-bar { background: linear-gradient(90deg, var(--red), var(--accent)); }

.two { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
.empty { color: var(--muted); }
.empty-title { color: var(--foreground); font-weight: 600; }

.provinces {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.625rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.province {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-height: 4.5rem;
  padding: 0.75rem;
  background: var(--panel);
  border-radius: 0.75rem;
}
.province b { font-size: 0.875rem; }
.province span { font-size: 0.75rem; color: var(--muted); }
.province.done { background: rgb(255 199 44 / 0.12); outline: 1px solid rgb(255 199 44 / 0.5); }
.province.done span { color: var(--accent); }
.province.next { outline: 2px solid var(--brand); }
.province.next span { color: var(--brand); }

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1rem;
}
.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
}
.list li + li { border-top: 1px solid var(--line); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  padding: 0 1.25rem;
  border-radius: 0.75rem;
  background: var(--accent);
  color: #1a1400;
  font-weight: 600;
  text-decoration: none;
}
.button.ghost { background: transparent; color: var(--foreground); border: 1px solid var(--line); }

/* Voettekst */
.site-foot { border-top: 1px solid var(--line); padding: 1.5rem 0; color: var(--dim); font-size: 0.8125rem; }

/* Offlinepagina (static/offline.html) */
.offline { align-content: center; text-align: center; justify-items: center; }

/* Inloggen en account */
.link-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
}

.passkey-button {
  display: block;
  width: 100%;
  min-height: 3rem;
  margin-top: 1rem;
  border: none;
  border-radius: 0.75rem;
  background: var(--red);
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.passkey-button:disabled { opacity: 0.6; cursor: wait; }

.form { display: grid; gap: 0.5rem; margin-top: 0.75rem; }
.form label, .form .label-text { font-size: 0.875rem; color: var(--muted); }
.form input,
.form select,
.form textarea,
.invite-link {
  min-height: var(--touch);
  padding: 0 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--night);
  color: var(--foreground);
  font: inherit;
}
.form textarea { padding: 0.5rem 0.75rem; resize: vertical; }
.invite-link { width: 100%; margin-top: 0.5rem; }
.form-error { color: var(--brand); font-weight: 600; margin-top: 0.75rem; }
.form-ok { color: var(--green); font-weight: 600; }

/* Inchecken (/beheer/stops): grote knoppen, makkelijk te raken in de auto. */
.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0 1.25rem;
  border: none;
  border-radius: 0.75rem;
  background: var(--red);
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.action-button.secondary { background: transparent; color: var(--foreground); border: 1px solid var(--line); }
.action-button:disabled { opacity: 0.6; cursor: wait; }
.action-button[hidden] { display: none; }
.stop-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.next-card .stop-actions { flex-direction: column; margin-top: 0.5rem; }
.next-card .stop-actions form,
.next-card .action-button { width: 100%; }
.checkin-form { margin-top: 0; }
.stop-row { flex-wrap: wrap; }
.stop-row.is-next { background: rgb(255 90 74 / 0.08); }
.confirm-card { border-color: var(--accent); display: grid; gap: 0.75rem; }

/* Aankomstvoorstel (#31): valt op boven de rest, knoppen over de volle breedte op een telefoon. */
.arrival-card { border: 2px solid var(--accent); background: rgb(255 199 44 / 0.1); display: grid; gap: 0.75rem; margin-bottom: 1.5rem; }
.arrival-title { margin: 0; font-family: var(--font-head); font-size: 1.35rem; line-height: 1.2; color: var(--accent); }
.arrival-card .stop-actions form { flex: 1 1 10rem; }
.arrival-card .action-button { width: 100%; }

.receipt-thumb { display: block; max-width: 8rem; max-height: 8rem; margin-top: 0.5rem; border-radius: 0.5rem; }

/* Beheer: subnavigatie in dezelfde pillen als het hoofdmenu */
.subnav { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.75rem; }
.subnav a {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0 0.875rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
}
@media (max-width: 29.99rem) { .subnav a { padding: 0 0.5rem; font-size: 0.8125rem; } }
.subnav a:hover, .subnav a[aria-current="page"] { color: #ffffff; background: var(--panel); }
.narrow > .block { padding-top: 1.5rem; }
.narrow > .block h2 { font-size: 1.25rem; }
/* Lijst binnen een kaart (kostentotalen): geen kaart-in-kaart */
.card .list { background: none; border: none; border-radius: 0; margin-top: 0.75rem; }
.card .list li { padding: 0.625rem 0; }
.form select { padding-right: 2rem; }
.file-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.file-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-button {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0 0.875rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--panel);
  color: var(--foreground);
  font-weight: 500;
  cursor: pointer;
}
.file-button:hover { border-color: var(--accent); }
.file-pick input:focus-visible + .file-button { outline: 2px solid var(--brand); outline-offset: 2px; }
.list .link-button:hover { color: var(--brand); }
/* Inchecken: alleen de volgende stop krijgt rode knoppen; in de lijst zijn ze rustig */
.stop-row .action-button { min-height: 2.5rem; padding: 0 0.875rem; background: transparent; border: 1px solid var(--line); color: var(--foreground); font-size: 0.875rem; }
.stop-row .action-button:hover { border-color: var(--accent); }
/* Breed scherm: kaart en uitleg naast elkaar, zes provincietegels per rij */
@media (min-width: 48rem) {
  .container, .page { padding-left: 2rem; padding-right: 2rem; }
  body:not(.countdown-body) h1:not(.big) { font-size: 2rem; }
  .live-hero { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: stretch; }
  .big { font-size: 2.75rem; }
  .two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .provinces { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (min-width: 30rem) and (max-width: 47.99rem) {
  .provinces { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Kaart (/kaart). isolation houdt de lagen van Leaflet onder de vaste navigatie (en onder de
   pil van kaart.css). De rest van de kaartstijl staat in kaart.css. */
.map {
  height: 60vh;
  min-height: 18rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  overflow: hidden;
  isolation: isolate;
}

/* Homepage: de sectie Kaart (concept scherm B): kaart en uitleg naast elkaar op een breed scherm,
   onder elkaar op een telefoon. */
.map-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
/* 25rem: op 375 px past de hele route op zoom 7 met ruimte voor de pil en de zoomknoppen (#43). */
.home-map { height: 25rem; min-height: 0; }
.map-side { display: flex; flex-direction: column; gap: 0.5rem; align-self: start; }
.map-side .note { margin-top: 0; }
@media (min-width: 48rem) {
  .map-grid { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
  .home-map { height: 26rem; }
}

/* Cijferrij in de kop van de homepage (concept scherm B): twee kolommen op een telefoon, vier op
   een breed scherm. Het accublok (static/live.js) verdwijnt als tracking uit staat. */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.625rem; margin: 0; padding: 0; list-style: none; }
.stat { background: var(--night); border-radius: 0.75rem; padding: 0.75rem 0.875rem; }
.stat b { display: block; font-family: var(--font-head); font-size: 1.375rem; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.stat span { font-size: 0.8125rem; color: var(--muted); }
.stat:has(> [data-live-stats][hidden]) { display: none; }
.stat[data-live]:not([data-freshness="actueel"]) b { color: var(--muted); }
@media (min-width: 48rem) {
  /* auto-fit: zonder accublok vullen de andere drie de rij. */
  .stats { grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); }
  .stat b { font-size: 1.5rem; }
}

/* Stand van de auto (sectie "Nu" en onder de kaart, static/live.js). Verouderd of onbekend:
   gedimd, zodat het niet als live leest. */
.car-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.625rem; margin: 0; }
.car-stats[hidden] { display: none; } /* tracking staat uit: geen telemetrie */
.car-stats div { background: var(--panel-2); border-radius: 0.75rem; padding: 0.625rem 0.75rem; }
.car-stats dd { margin: 0.125rem 0 0; font-family: var(--font-head); font-size: 1.25rem; font-weight: 700; }
.car-updated { margin-top: 0.625rem; }
.car-live[data-freshness="actueel"] .car-updated::before { content: "● "; color: var(--green); }
.car-live:not([data-freshness="actueel"]) .car-stats dd { color: var(--muted); }
@media (min-width: 30rem) {
  .car-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Statistieken (/statistieken en de kop van de homepage) */
.stat-grid { display: grid; grid-template-columns: 1fr; gap: 0.75rem; margin: 0; }
.stat-grid .card { margin: 0; }
.stat-grid dd { margin: 0; }
.stat-grid .big { font-size: 1.75rem; }
@media (min-width: 30rem) {
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Vestiging bewerken (/beheer/stops/{id}/bewerken) */
.field-error { color: var(--brand); font-size: 0.875rem; font-weight: 600; margin: 0; }
.form input[aria-invalid="true"] { border-color: var(--brand); }
.help-card ul { margin: 0; padding-left: 1.125rem; display: grid; gap: 0.5rem; }

/* Foutpagina (404, 500, 503): een kaart in het midden, ook op een smal scherm. */
.error-page { max-width: 32rem; margin: 2rem auto; text-align: center; }
.error-page h1 { margin: 0.25rem 0 0.75rem; }

/* Deelknop "Deel de roadtrip" (#49, static/share.js): onopvallend, verborgen zonder JavaScript. */
.share-button {
  align-self: flex-start;
  min-height: var(--touch);
  padding: 0 0.875rem;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  color: var(--muted);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}
.share-button:hover { color: var(--foreground); border-color: var(--accent); }
.share-button[hidden] { display: none; }
.share-status { font-size: 0.875rem; color: var(--accent); }
.share-status:empty { display: none; }
/* Op de countdown staat de knop onderaan, onder de kaart. */
.share-corner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
}
.share-copy-field { position: fixed; top: 0; left: -9999px; }
.share-corner .share-button { align-self: center; }
