/* Opmaak in de stijl van Google Maps / Material Design 3:
   kaart over het hele scherm, zwevend paneel links (op de telefoon een paneel onderin). */
:root {
  --surface: #ffffff;
  --surface-2: #f1f3f4;
  --text: #202124;
  --muted: #5f6368;
  --line: #dadce0;
  --accent: #1a73e8;
  --accent-weak: #e8f0fe;
  --on-accent: #ffffff;
  --walk: #1a73e8;
  --car: #e37400;
  --visited: #188038;
  --danger: #d93025;
  --idle: #9aa0a6;
  --shadow: 0 1px 2px rgba(60, 64, 67, .3), 0 2px 6px 2px rgba(60, 64, 67, .15);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface: #202124;
    --surface-2: #303134;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --line: #3c4043;
    --accent: #8ab4f8;
    --accent-weak: rgba(138, 180, 248, .16);
    --on-accent: #202124;
    --walk: #8ab4f8;
    --car: #fcad70;
    --visited: #81c995;
    --danger: #f28b82;
    --idle: #80868b;
    --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 4px 8px 3px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --surface: #202124;
  --surface-2: #303134;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --line: #3c4043;
  --accent: #8ab4f8;
  --accent-weak: rgba(138, 180, 248, .16);
  --on-accent: #202124;
  --walk: #8ab4f8;
  --car: #fcad70;
  --visited: #81c995;
  --danger: #f28b82;
  --idle: #80868b;
  --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 4px 8px 3px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--surface-2);
  overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- kaart en paneel ---------- */
#map { position: fixed; inset: 0; }
#panel {
  position: absolute; z-index: 1100;
  top: 12px; left: 12px; bottom: 12px; width: 400px;
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow);
  overflow-y: auto; padding: 20px 20px 24px;
}
h1 { font-size: 22px; font-weight: 500; margin: 0 0 4px; letter-spacing: -.2px; }
h2 { font-size: 16px; font-weight: 500; margin: 20px 0 8px; }
.sub, .hint { color: var(--muted); margin: 0 0 12px; font-size: 13px; }

/* ---------- velden ---------- */
label { display: block; margin-bottom: 12px; font-size: 12px; color: var(--muted); }
input, select {
  display: block; width: 100%; min-width: 0; margin-top: 4px; padding: 10px 12px;
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row > label { min-width: 0; }
fieldset { border: 0; border-top: 1px solid var(--line); margin: 0; padding: 12px 0 0; }
legend { font-size: 14px; font-weight: 500; color: var(--text); padding: 0 8px 0 0; }

.simple > label { font-size: 13px; font-weight: 500; color: var(--text); }
.field { margin: 16px 0 8px; }
.flabel { display: block; font-size: 13px; font-weight: 500; margin-bottom: 8px; }
.flabel b { float: right; color: var(--accent); font-weight: 500; }

/* filterchips voor het tempo */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg button {
  padding: 8px 4px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-weight: 500; font-size: 14px; cursor: pointer;
}
.seg button:hover { background: var(--surface-2); }
.seg button small { display: block; font-weight: 400; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.seg button.on { background: var(--accent-weak); border-color: transparent; color: var(--accent); }
.seg button.on small { color: var(--accent); }

input[type=range] { padding: 0; border: 0; background: none; accent-color: var(--accent); box-shadow: none; }

/* Material-schakelaar */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 20px 0 4px; font-size: 14px; font-weight: 500; color: var(--text); cursor: pointer; }
.switch span { order: -1; }
.switch input {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0; padding: 0;
  width: 52px; height: 32px; border-radius: 16px; border: 2px solid var(--idle);
  background: var(--surface-2); position: relative; cursor: pointer; transition: background .15s, border-color .15s;
}
.switch input::after {
  content: ""; position: absolute; top: 6px; left: 6px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--idle); transition: all .15s;
}
.switch input:checked { background: var(--accent); border-color: var(--accent); box-shadow: none; }
.switch input:checked::after { left: 24px; top: 2px; width: 24px; height: 24px; background: var(--on-accent); }

/* knoppen */
button.big {
  display: block; width: 100%; margin-top: 20px; padding: 10px 24px; min-height: 44px;
  font: inherit; font-size: 15px; font-weight: 500; letter-spacing: .1px;
  color: var(--on-accent); background: var(--accent); border: 0; border-radius: 22px; cursor: pointer;
}
button.big:hover { box-shadow: var(--shadow); }
button:disabled { opacity: .7; cursor: progress; }

#progress { height: 4px; border-radius: 2px; background: var(--accent-weak); margin-top: 10px; overflow: hidden; }
#progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .25s linear; }
#status { margin-top: 8px; font-size: 13px; color: var(--muted); }
#status .err { color: var(--danger); }

details summary { cursor: pointer; color: var(--accent); font-size: 14px; font-weight: 500; padding: 8px 0; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::after { content: " ▾"; }
details[open] > summary::after { content: " ▴"; }
details#advanced { margin-top: 12px; }

/* ---------- resultaat ---------- */
#summary:empty { display: none; }
#summary { border-top: 1px solid var(--line); margin-top: 16px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font-size: 22px; font-weight: 500; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 12px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
ul.areas { list-style: none; padding: 0; margin: 0 0 8px; }
ul.areas li { padding: 8px 0; border-bottom: 1px solid var(--line); }
ul.areas li b { font-weight: 500; }
span.ok, b.ok { color: var(--visited); font-weight: 500; }
span.bad, td.bad, b.bad { color: var(--danger); font-weight: 500; }
td.warn, b.warn { color: var(--car); }
details.more { margin-top: 4px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
th { font-weight: 500; color: var(--muted); }

/* ---------- routestappen (zoals een routebeschrijving) ---------- */
#schedule:empty { display: none; }
ol.steps { list-style: none; margin: 0; padding: 0; }
ol.steps li { position: relative; padding-left: 44px; }
ol.steps li.stop { padding-top: 6px; padding-bottom: 6px; }
ol.steps .badge {
  position: absolute; left: 4px; top: 6px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 500; color: #fff;
  background: var(--visited); box-shadow: 0 0 0 2px var(--surface);
}
ol.steps .badge.end { background: var(--text); color: var(--surface); }
ol.steps .time { float: right; color: var(--muted); font-size: 13px; margin-left: 8px; }
ol.steps .name { font-weight: 500; }
ol.steps .addr { color: var(--muted); font-size: 12.5px; }
ol.steps li.leg, ol.steps li.rest { color: var(--muted); font-size: 13px; padding-top: 10px; padding-bottom: 10px; }
ol.steps li.leg::before, ol.steps li.rest::before {
  content: ""; position: absolute; left: 16px; top: 0; bottom: 0; border-left: 3px dotted var(--idle);
}
ol.steps li.leg.walk::before { border-left: 3px solid var(--walk); }
ol.steps li.leg.car::before { border-left: 3px dashed var(--car); }
ol.steps li.leg.car { color: var(--car); }
ol.steps li.leg a { margin-left: 6px; font-size: 12.5px; }

/* ---------- kaartelementen ---------- */
.leaflet-container { font: inherit; background: var(--surface-2); }
.leaflet-bar { border: 0 !important; box-shadow: var(--shadow) !important; border-radius: 8px !important; overflow: hidden; }
.leaflet-bar a { background: var(--surface) !important; color: var(--muted) !important; border-color: var(--line) !important; }
.leaflet-tooltip { border-radius: 8px; border: 0; box-shadow: var(--shadow); padding: 6px 10px; }
.num-icon { border-radius: 50%; color: #fff; font: 500 11px/22px Roboto, system-ui, sans-serif; text-align: center; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); background: var(--visited); }
.num-icon.end { background: #202124; color: #fff; }

/* ---------- telefoon: paneel onderin ---------- */
@media (max-width: 720px) {
  #panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto;
    height: var(--sheet-h, 55vh); max-height: none;
    border-radius: 16px 16px 0 0; padding: 0 16px 24px;
    transition: height .22s ease;
  }
  #panel.dragging { transition: none; }
  #panel.peek { overflow: hidden; }
  .sheet-handle {
    display: block; position: sticky; top: 0; z-index: 3; height: 28px; margin: 0 -16px;
    background: var(--surface); cursor: grab; touch-action: none;
  }
  .sheet-handle::before {
    content: ""; position: absolute; left: 50%; top: 10px; width: 36px; height: 4px; margin-left: -18px;
    border-radius: 2px; background: var(--line);
  }
  .tabs { top: 28px; }
  #collapseBtn { display: none; }
  .leaflet-bottom.leaflet-right { bottom: var(--sheet-h, 55vh); transition: bottom .22s ease; }
}


/* ---------- tabbladen in het paneel ---------- */
.tabs {
  display: flex; position: sticky; top: -20px; z-index: 2;
  margin: 4px -20px 16px; padding: 0 12px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.tabs button {
  flex: 1; padding: 12px 8px 10px; background: none; border: 0; border-bottom: 3px solid transparent;
  font: inherit; font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer;
}
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs button:disabled { opacity: .45; cursor: default; }
.tabpane[data-pane=route] #summary { border-top: 0; margin-top: 0; }
button.text { background: none; border: 0; padding: 12px 0 0; font: inherit; font-weight: 500; color: var(--accent); cursor: pointer; }
@media (max-width: 720px) {
  .tabs { top: -12px; margin: 4px -16px 12px; padding: 0 8px; }
}

/* uitleg bij hover of tik */
.info { position: relative; display: inline-block; color: var(--accent); cursor: help; font-weight: 400; outline: none; }
.info::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%);
  width: 240px; padding: 8px 10px; border-radius: 8px; z-index: 10;
  background: #3c4043; color: #fff; font-size: 12.5px; font-weight: 400; line-height: 1.4;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .12s;
}
.info:hover::after, .info:focus::after { opacity: 1; }
/* uitleg spant de alinea, zodat hij nooit buiten het paneel valt */
#summary p { position: relative; }
.info { position: static; }
.info::after { left: 0; right: 0; width: auto; transform: none; }

/* namen van de deelgebieden op de kaart */
.area-label { background: none; border: 0; }
.area-label span {
  display: block; text-align: center; font-size: 12px; font-weight: 500; letter-spacing: .3px; text-transform: uppercase;
  text-shadow: 0 0 3px var(--surface), 0 0 3px var(--surface), 0 0 3px var(--surface); white-space: nowrap;
}
.leaflet-control-layers { border: 0 !important; border-radius: 8px !important; box-shadow: var(--shadow) !important; background: var(--surface); color: var(--text); }

/* stap oplichten na klik op een groep op de kaart */
ol.steps li.stop.flash { animation: flash 1.6s ease-out; border-radius: 8px; }
@keyframes flash { 0%, 30% { background: var(--accent-weak); } 100% { background: transparent; } }
.leaflet-marker-icon.num-icon { cursor: pointer; }

/* auto-icoon op een autosprong */
.car-icon {
  display: grid; place-items: center; color: #fff;
  background: var(--car); border: 2px solid #fff; border-radius: 50%; box-shadow: var(--shadow);
}
.car-icon svg { display: block; }
svg.mi { vertical-align: -3px; margin-right: 4px; flex: none; }
.car-icon svg.mi { margin: 0; vertical-align: 0; }

/* themaknop rechtsboven in het paneel */
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
#themeBtn {
  flex: none; width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; background: none; color: var(--muted);
}
#themeBtn:hover { background: var(--surface-2); color: var(--text); }
#themeBtn svg.mi { margin: 0; vertical-align: 0; }

/* grafiek: tempo over de dag */
.speed-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin: -2px 0 4px; }
.speed-legend i { display: inline-block; vertical-align: middle; margin-right: 6px; }
.sw-line { width: 14px; height: 2px; background: var(--walk); border-radius: 1px; }
.sw-car, .sw-rest { width: 10px; height: 10px; border-radius: 2px; }
.sw-car { background: var(--car); opacity: .45; }
.sw-rest { background: var(--idle); opacity: .45; }
.speed-chart { position: relative; }
.speed-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.speed-chart .ax { font-size: 9.5px; fill: var(--muted); }
.speed-chart .sc-hit { cursor: crosshair; }
.sc-tip {
  position: absolute; top: -6px; transform: translate(-50%, -100%); pointer-events: none; z-index: 5;
  background: var(--surface); color: var(--text); border-radius: 8px; box-shadow: var(--shadow);
  padding: 6px 10px; font-size: 12px; line-height: 1.4; white-space: nowrap;
}
.sc-tip .muted { color: var(--muted); }
.speed-chart .ax.day { font-weight: 500; fill: var(--text); }

/* tooltip bij hover op de route */
.leaflet-tooltip.route-tip { background: var(--surface); color: var(--text); font-size: 12.5px; line-height: 1.4; }
.leaflet-tooltip.route-tip::before { border-top-color: var(--surface); }

/* Jotihunt HQ */
.num-icon.hq, .num-icon.hq > div { background: #202124 !important; color: #fff; font-size: 10px; letter-spacing: .3px; }
.num-icon.hq { border-radius: 8px; line-height: 26px; }
.num-icon.hq > div { border-radius: 6px !important; }
ol.steps .badge.hq { background: #202124; color: #fff; font-size: 10px; border-radius: 6px; }

/* inklappen: telefoon = paneel onderin versleepbaar; desktop = zijpaneel wegschuiven */
@media (min-width: 721px) {
  .sheet-handle { display: none; }
  #collapseBtn { display: grid; }
}
#collapseBtn {
  flex: none; width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
  place-items: center; background: none; color: var(--muted);
}
#collapseBtn:hover { background: var(--surface-2); color: var(--text); }
#collapseBtn svg.mi { margin: 0; vertical-align: 0; }
@media (min-width: 721px) {
  #panel { transition: transform .22s ease; }
  body.panel-hidden #panel { transform: translateX(calc(-100% - 24px)); }
}
#openPanel {
  position: absolute; z-index: 1100; top: 12px; left: 12px; padding: 10px 16px; border: 0; border-radius: 20px;
  background: var(--surface); color: var(--accent); font: inherit; font-weight: 500; box-shadow: var(--shadow); cursor: pointer;
}

/* modus: Ultra of Normale vos */
.seg.mode { grid-template-columns: 1fr 1fr; margin-bottom: 16px; }
body[data-mode="vos"] .ultra-only, body:not([data-mode="vos"]) .vos-only { display: none; }
