/* Santa tracker. One stylesheet for the public map, the driver page and the stops page. */
:root {
  --night: #0f2440;
  --ink: #14233a;
  --snow: #ffffff;
  --frost: #eaf2fb;
  --red: #c61f30;
  --fir: #1e6b4a;
  --lamp: #f5b83d;
  --muted: #55657c;
  --line: #d3dfee;
  --display: 'Fredoka', ui-rounded, 'Arial Rounded MT Bold', system-ui, sans-serif;
  --body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --lift: 0 6px 22px rgba(15, 36, 64, 0.28);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--body); color: var(--ink); background: var(--night); font-size: 16px; line-height: 1.45; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0; line-height: 1.15; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--lamp); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- public map ---------- */
#map { position: fixed; inset: 0; background: #dfe8f2; }

.status {
  position: fixed; z-index: 1000; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px;
  max-width: 420px; background: var(--snow); border-radius: 18px; box-shadow: var(--lift);
  padding: 12px 16px 13px; display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center;
  border-bottom: 5px solid var(--red);
}
.status[data-state='off'] { border-bottom-color: var(--night); }
.status[data-state='stale'], .status[data-state='error'] { border-bottom-color: var(--lamp); }
.status h1 { font-size: 1.32rem; }
.status p { margin: 2px 0 0; color: var(--muted); font-size: 0.94rem; grid-column: 2; }
.beacon { width: 14px; height: 14px; border-radius: 50%; background: var(--red); grid-row: span 2; position: relative; }
.status[data-state='off'] .beacon { background: var(--night); }
.status[data-state='stale'] .beacon, .status[data-state='error'] .beacon { background: var(--lamp); }
.status[data-state='live'] .beacon::after {
  content: ''; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--red);
  animation: ring 2s ease-out infinite;
}
@keyframes ring { from { transform: scale(0.6); opacity: 0.9; } to { transform: scale(1.5); opacity: 0; } }

.find {
  position: fixed; z-index: 1000; right: 12px; top: calc(max(12px, env(safe-area-inset-top)) + 86px);
  background: var(--red); color: var(--snow); border: 0; border-radius: 999px; padding: 10px 18px;
  font-family: var(--display); font-weight: 600; font-size: 1rem; box-shadow: var(--lift);
}

.stops {
  position: fixed; z-index: 1000; left: 0; right: 0; bottom: 0; background: var(--night); color: var(--snow);
  border-radius: 20px 20px 0 0; box-shadow: 0 -6px 22px rgba(15, 36, 64, 0.3);
  padding-bottom: env(safe-area-inset-bottom); max-height: 52vh; display: flex; flex-direction: column;
}
.stops-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left;
  background: none; border: 0; color: inherit; padding: 14px 18px 12px;
}
.stops-head h2 { font-size: 1.12rem; }
.stops-head .next { display: block; font-family: var(--body); font-weight: 400; font-size: 0.92rem; color: #c7d6ea; margin-top: 2px; }
.stops-head .chev { width: 12px; height: 12px; border-right: 3px solid var(--lamp); border-bottom: 3px solid var(--lamp); transform: rotate(-135deg); transition: transform 0.2s; flex: none; margin-right: 4px; }
.stops.open .stops-head .chev { transform: rotate(45deg); }
.stops ol { list-style: none; margin: 0; padding: 0 10px 12px; overflow-y: auto; display: none; }
.stops.open ol { display: block; }
.stop { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; width: 100%; text-align: left; background: none; border: 0; color: inherit; padding: 9px 8px; border-radius: 12px; }
.stop:hover { background: rgba(255, 255, 255, 0.08); }
.stop .num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-weight: 600; background: var(--snow); color: var(--night); }
.stop .name { font-weight: 600; }
.stop .when { color: #c7d6ea; font-size: 0.9rem; white-space: nowrap; }
.stop[data-state='done'] .num { background: var(--fir); color: var(--snow); }
.stop[data-state='done'] .name { color: #c7d6ea; }
.stop[data-state='next'] .num { background: var(--lamp); }
.stop[data-state='next'] .when { color: var(--lamp); font-weight: 600; }

@media (min-width: 820px) {
  .status { left: 16px; top: 16px; width: 340px; right: auto; }
  .stops { left: 16px; right: auto; bottom: 16px; top: 118px; width: 340px; max-height: none; border-radius: 18px; }
  .stops ol { display: block; }
  .stops-head { cursor: default; }
  .stops-head .chev { display: none; }
  .find { top: 16px; right: 16px; }
}

/* On phones the stops sheet sits over the bottom of the map: lift the map credit above it and rely on pinch to zoom. */
@media (max-width: 819px) {
  .leaflet-bottom { bottom: 80px; }
  .leaflet-control-zoom { display: none; }
}

/* map furniture */
.leaflet-container { font-family: var(--body); }
.santa-pin { position: relative; width: 56px; height: 56px; }
.santa-pin .face {
  position: absolute; inset: 0; border-radius: 50%; background: var(--snow); border: 4px solid var(--red);
  display: grid; place-items: center; font-size: 30px; line-height: 1; box-shadow: 0 4px 12px rgba(15, 36, 64, 0.45);
}
.santa-pin.stale .face { border-color: var(--muted); filter: grayscale(0.6); }
.stop-pin {
  width: 30px; height: 30px; border-radius: 50%; background: var(--night); color: var(--snow); border: 3px solid var(--snow);
  display: grid; place-items: center; font-family: var(--display); font-weight: 600; font-size: 14px;
  box-shadow: 0 2px 8px rgba(15, 36, 64, 0.4);
}
.stop-pin.done { background: var(--fir); }
.stop-pin.next { background: var(--lamp); color: var(--night); }
.leaflet-popup-content { margin: 10px 14px; font-size: 0.95rem; }
.leaflet-popup-content strong { font-family: var(--display); font-weight: 600; font-size: 1.05rem; display: block; }

/* ---------- driver and stops pages ---------- */
body.staff { background: var(--frost); }
.page { max-width: 560px; margin: 0 auto; padding: 22px 18px 48px; }
.page > header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 18px; }
.page > header h1 { font-size: 1.5rem; color: var(--night); }
.page > header a { color: var(--night); font-size: 0.95rem; }
.card { background: var(--snow); border-radius: 18px; padding: 20px; box-shadow: 0 2px 10px rgba(15, 36, 64, 0.08); margin-bottom: 16px; }
.card h2 { font-size: 1.15rem; margin-bottom: 10px; color: var(--night); }
.card p { margin: 6px 0; }
.muted { color: var(--muted); }
.field { display: block; margin: 12px 0; }
.field span { display: block; font-weight: 600; margin-bottom: 4px; }
input[type='text'], input[type='password'], input[type='date'], input[type='time'], input[type='search'] {
  width: 100%; padding: 11px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--snow); min-height: 46px;
}
input:focus { border-color: var(--night); outline: none; }
.btn { border: 0; border-radius: 14px; padding: 13px 18px; font-family: var(--display); font-weight: 600; font-size: 1.05rem; background: var(--night); color: var(--snow); min-height: 48px; }
.btn.quiet { background: var(--frost); color: var(--night); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.go { background: var(--fir); }
.btn.stop-run { background: var(--red); }
.btn.big { width: 100%; font-size: 1.3rem; padding: 20px; border-radius: 18px; }
.msg { margin-top: 10px; font-weight: 600; }
.msg.bad { color: var(--red); }
.msg.good { color: var(--fir); }

.run-state { border-radius: 18px; padding: 20px; color: var(--snow); background: var(--night); margin-bottom: 16px; }
.run-state[data-live='yes'] { background: var(--fir); }
.run-state h2 { font-size: 1.6rem; color: inherit; }
.run-state p { margin: 6px 0 0; color: rgba(255, 255, 255, 0.86); }
.signal { display: grid; grid-template-columns: 16px 1fr; gap: 10px; align-items: start; }
.signal .dot { width: 14px; height: 14px; border-radius: 50%; margin-top: 4px; background: var(--muted); }
.signal[data-level='good'] .dot { background: var(--fir); }
.signal[data-level='warn'] .dot { background: var(--lamp); }
.signal[data-level='bad'] .dot { background: var(--red); }
ol.steps { margin: 0; padding-left: 22px; }
ol.steps li { margin: 7px 0; }

/* stops editor */
.editor { display: grid; grid-template-rows: 44vh auto; min-height: 100%; }
#adminMap { background: #dfe8f2; }
.editor .side { padding: 16px 16px 40px; background: var(--frost); }
.editor .side h1 { font-size: 1.4rem; color: var(--night); margin-bottom: 4px; }
.dates { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.dates button { border: 2px solid var(--line); background: var(--snow); border-radius: 999px; padding: 5px 12px; font-size: 0.9rem; }
.dates button[aria-pressed='true'] { background: var(--night); color: var(--snow); border-color: var(--night); }
.results { list-style: none; padding: 0; margin: 6px 0 0; background: var(--snow); border-radius: 12px; overflow: hidden; }
.results button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.results button:hover { background: var(--frost); }
.rows { list-style: none; padding: 0; margin: 12px 0; }
.rows li { background: var(--snow); border-radius: 14px; padding: 10px; margin-bottom: 8px; display: grid; grid-template-columns: 30px 1fr 132px; gap: 8px; align-items: center; }
.rows .num { width: 30px; height: 30px; border-radius: 50%; background: var(--night); color: var(--snow); display: grid; place-items: center; font-family: var(--display); font-weight: 600; }
.rows .tools { grid-column: 2 / -1; display: flex; gap: 6px; }
.rows .tools button { border: 0; background: var(--frost); border-radius: 10px; padding: 6px 12px; font-size: 0.9rem; }
.rows .tools button.del { color: var(--red); margin-left: auto; }
.savebar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
@media (min-width: 900px) {
  .editor { grid-template-rows: none; grid-template-columns: 420px 1fr; height: 100%; }
  .editor .side { order: -1; overflow-y: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
