@import url("/web-styles.css");

:root {
  color: #222c44;
  background: #e1ebf8;
}

* { box-sizing: border-box; }
body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  margin: 0;
}
body.tracking-embedded { grid-template-rows: minmax(0, 1fr); }
[hidden] { display: none !important; }

.tracking-view {
  --stop-green: #1b7045;
  --santa-red: #ad2440;
  --santa-tint: #f7e1e6;
  --santa-tint-border: #eac6ce;
  --inset: 20px;
  --card-width: min(350px, calc(100% - 104px));
  position: relative;
  min-height: 0;
  overflow: hidden;
}

#map { position: absolute; inset: 0; font-family: inherit; }

.floating-card {
  position: absolute;
  left: max(var(--inset), env(safe-area-inset-left));
  width: var(--card-width);
  padding: 14px 18px;
  background: #fffdf8f5;
  border: 1px solid #ddd8e8;
  border-radius: 16px;
  box-shadow: 0 5px 25px #242c5625;
}

.overview { top: max(var(--inset), env(safe-area-inset-top)); }
.journey {
  bottom: max(30px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  max-height: 38%;
  overflow: hidden;
}

.floating-card h2, .floating-card h3 {
  margin: 0;
}

.floating-card p { margin: .35rem 0 0; font-size: var(--font-body); }
.floating-card .eyebrow {
  margin: 0 0 .35rem;
  color: #77516f;
  font-size: .7rem;
  font-weight: 750;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.map-actions {
  position: absolute;
  top: max(var(--inset), env(safe-area-inset-top));
  right: max(var(--inset), env(safe-area-inset-right));
  display: grid;
  gap: 8px;
}

button, select { font: inherit; }
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
a:focus-visible, button:focus-visible { outline: 3px solid #704399; outline-offset: 2px; }
.map-actions a, .map-actions button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: inherit;
  background: #fffefa;
  border: 1px solid #d5d7d4;
  border-radius: 50%;
  box-shadow: 0 3px 12px #242c561b;
  padding: 0;
  text-decoration: none;
}

.map-actions #fit, .map-actions [aria-pressed="true"] { background: var(--santa-tint); }
.map-actions button:disabled { opacity: .55; cursor: default; }

.map-actions svg { width: 20px; }
.journey ol { margin: .5rem 0 0; padding-inline-start: 2rem; }
.journey li::marker { color: var(--stop-green); font-weight: 750; }
.journey li:has(.is-visited-stop)::marker { color: var(--santa-red); }
.journey button {
  min-height: 32px;
  padding: 6px 4px 2px;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 4px;
}

#stops button {
  width: 100%;
  justify-content: space-between;
  gap: .5rem;
  color: var(--stop-green);
}

#stops button.is-next-stop { font-weight: 700; }
#stops button.is-visited-stop { color: var(--santa-red); }

.stop-status {
  flex: none;
  font-size: .75rem;
  font-weight: 700;
}

.journey button:hover:not(:disabled) { text-decoration: underline; }
.journey button:disabled { cursor: default; }

.stop-marker {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 50%;
}

.stop-marker span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: white;
  background: var(--stop-green);
  border: 2px solid white;
  padding-top: .22em;
  line-height: 1;
  border-radius: 50%;
  box-shadow: 0 2px 6px #242c5660;
  font-weight: 750;
}

@media (max-width: 680px) {
  .tracking-view { --inset: 12px; --card-width: min(260px, calc(100% - 76px)); }
  .floating-card { padding: 10px 12px; }
  .journey { width: calc(100% - max(12px, env(safe-area-inset-left)) - max(12px, env(safe-area-inset-right))); }
  .journey button { min-height: 44px; }
}

#map { z-index: 0; }
.floating-card, .map-actions { z-index: 1; }

.map-actions {
  max-height: calc(100% - max(var(--inset), env(safe-area-inset-top)) - 26px);
  overflow-y: auto;
  padding: 4px;
  margin: -4px;
}

dialog {
  max-width: min(30rem, calc(100% - 2rem));
  padding: 1.25rem;
  color: inherit;
  background: #fffdf8;
  border: 1px solid #ddd8e8;
  border-radius: 16px;
}

dialog::backdrop { background: #222c4466; }
dialog h2 { margin-top: 0; }
dialog button { min-height: 44px; }

/* M0 beacon. The original Santa/Rudolph artwork is clipped to Santa's head. */
.sample-santa {
  z-index: 4;
  display: grid;
  place-items: center;
  width: 57px;
  height: 57px;
  background: #eee7f5;
  border: 3px solid #ad2440;
  border-radius: 50%;
  box-shadow: 0 0 0 5px #ad244018, 0 4px 12px #242c5630;
  pointer-events: none;
}

.sample-santa::before {
  position: absolute;
  inset: 0;
  background: #eee7f5;
  border-radius: 50%;
  content: '';
}

.santa-heading {
  position: absolute;
  inset: 0;
  transform: rotate(var(--santa-heading, 0deg));
}

.santa-heading::before {
  position: absolute;
  top: -12px;
  left: calc(50% - 5px);
  border: 5px solid transparent;
  border-bottom: 7px solid #ad2440;
  border-top: 0;
  content: '';
}

.santa-head {
  position: relative;
  width: 40px;
  height: 46px;
  overflow: hidden;
  transform: rotate(-25deg) scale(.94);
}

.santa-head img {
  position: absolute;
  top: -27%;
  left: -50%;
  width: 244%;
  height: auto;
  clip-path: polygon(28% 14%, 39% 14%, 44% 18%, 56% 20%, 60% 27%, 60% 42%, 55% 44%, 55% 49%, 56% 55%, 53% 61%, 46% 64%, 37% 63%, 28% 58%, 23% 52%, 23% 44%, 26% 39%, 33% 35%, 34% 30%, 27% 26%, 27% 20%);
}

.santa-ripples {
  position: absolute;
  inset: -3px;
  z-index: -1;
}

.santa-ripples span {
  position: absolute;
  inset: 0;
  background: #ad2440;
  border-radius: 50%;
  opacity: 0;
  will-change: transform, opacity;
  backface-visibility: hidden;
}

.sample-santa.is-playing .santa-ripples span { animation: santa-ripple 6s linear infinite; }
.sample-santa.is-playing .santa-ripples span:nth-child(2) { animation-delay: -2s; }
.sample-santa.is-playing .santa-ripples span:nth-child(3) { animation-delay: -4s; }

@keyframes santa-ripple {
  from { transform: scale(1); opacity: .22; }
  to { transform: scale(3); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .sample-santa.is-playing .santa-ripples span { animation: none; }
}

.stop-marker { z-index: 2; }
.stop-marker:focus-visible { z-index: 3; }
.stop-marker.is-visited span, .endpoint.is-traveled span { background: var(--santa-red); }

.endpoint {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  pointer-events: none;
}

.endpoint span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding-block-start: .2em;
  color: #fff;
  background: #704399;
  border-radius: 50%;
  box-shadow: 0 0 0 3px #fffdf8, 0 2px 7px #17204930;
  font-size: var(--font-caption);
  font-weight: 750;
  line-height: 1;
}

#recenter {
  position: absolute;
  z-index: 2;
  left: 50%;
  min-height: 44px;
  padding: 12px 18px 8px;
  color: inherit;
  background: #fffdf8;
  border: 1px solid #d5cee2;
  border-radius: 24px;
  box-shadow: 0 3px 14px #17204924;
  font-weight: 700;
  transform: translateX(-50%);
}

#map .maplibregl-canvas-container,
#map .maplibregl-canvas { touch-action: none; }


.playback-cue {
  display: flex;
  align-items: center;
  gap: .65rem;
}

#cue-icon, .visit-number {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
}

#cue-icon {
  padding: 6px;
  color: #222c44;
  background: var(--santa-tint);
  border-radius: 8px;
}

.visit-number {
  display: grid;
  place-items: center;
  line-height: 1;
  padding-block-start: .25em;
  color: #fff;
  background: #ad2440;
  border-radius: 50%;
  font-weight: 750;
}

.overview.is-at-stop { border-color: #1b7045; }

#gps-status {
  position: absolute;
  inset-inline-end: 14px;
  bottom: 12px;
  display: grid;
  place-items: center;
  color: #4c5567;
}

#gps-status[data-signal="live"] { color: var(--stop-green); }
#gps-status:is([data-signal="stale"], [data-signal="disconnected"], [data-signal="unavailable"]) {
  color: var(--santa-red);
}

#gps-status-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}


#gps-reconnect {
  position: absolute;
  z-index: 1;
  inset-block-start: 38%;
  inset-inline-start: 50%;
  width: min(19rem, calc(100% - 32px));
  margin: 0;
  padding: 14px 18px 12px;
  border: 1px solid #ffffff30;
  border-radius: 14px;
  color: #fff;
  background: rgb(0 0 0 / 76%);
  box-shadow: 0 5px 25px #242c5625;
  font-size: var(--font-body);
  line-height: 1.35;
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

#gps-reconnect svg {
  display: block;
  margin: 0 auto 8px;
  animation: reconnect-fade 1.2s ease-in-out infinite alternate;
}

@keyframes reconnect-fade {
  from { opacity: 1; }
  to { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  #gps-reconnect svg { animation: none; }
}

.journey-metrics {
  display: flex;
  gap: 1.5rem;
  margin-top: .45rem;
  font-variant-numeric: tabular-nums;
}

.journey-metrics span, .next-stop strong { display: block; font-size: .75rem; }
.journey-metrics strong { display: block; font-size: 1.15rem; }
#route-progress { width: 100%; accent-color: var(--santa-red); }

#cue-street { color: #4c5567; font-size: 1rem; }
.journey-metrics { justify-content: space-between; gap: .5rem; }
.journey-metrics strong { white-space: nowrap; }
.journey-heading {
  display: flex;
  align-items: center;
  flex: none;
  gap: .25rem;
}

.journey #switch-journey-view {
  flex: none;
  margin-inline-start: auto;
  min-height: 0;
  height: calc(var(--font-h3) * 1.4);
  padding: .35em .65rem .05em;
  font-size: var(--font-caption);
  line-height: 1.2;
  border: 1px solid var(--santa-tint-border);
  border-radius: 8px;
  background: var(--santa-tint);
  font-weight: 700;
}

.journey #toggle-journey {
  flex: 0 0 34px;
  min-height: 36px;
  margin-inline-start: -7px;
  padding: 0;
}

#toggle-journey svg {
  flex: none;
  width: 24px;
  height: 24px;
}

#toggle-journey[aria-expanded="true"] path:first-child,
#toggle-journey[aria-expanded="false"] path:last-child { display: none; }

#journey-content {
  display: grid;
  grid-template-rows: 1fr;
  min-height: 0;
  transition: grid-template-rows 180ms ease-in-out;
}

#journey-content > div {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

#stops, #playback-summary {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

#compact-next {
  display: block;
  flex: none;
  max-height: 0;
  overflow: hidden;
  margin-inline-start: 31px;
  font-size: var(--font-caption);
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: max-height 180ms ease-in-out;
}

.journey.is-collapsed #journey-content { grid-template-rows: 0fr; }
.journey.is-collapsed #compact-next { max-height: 1.5em; }

@media (prefers-reduced-motion: reduce) {
  #journey-content, #compact-next { transition: none; }
}

.next-stop button { padding-left: 0; font-weight: 700; }
.next-stop #next-stop-distance { margin-top: 0; color: #4c5567; font-size: .875rem; }

@media (max-width: 360px) {
  .journey-metrics strong { font-size: .9rem; }
}

.map-actions #play-parade.is-playing { background: var(--santa-tint); }

#route-progress {
  height: 7px;
  margin-block: .65rem;
  overflow: hidden;
  appearance: none;
  background: color-mix(in srgb, var(--stop-green) 12%, white);
  border: 0;
  border-radius: 99px;
}

#route-progress::-webkit-progress-bar { background: color-mix(in srgb, var(--stop-green) 12%, white); }
#route-progress::-webkit-progress-value { background: var(--santa-red); border-radius: 99px; }
#route-progress::-moz-progress-bar { background: var(--santa-red); border-radius: 99px; }

.next-stop button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: .65rem;
}

.next-stop-number {
  display: grid;
  flex: 0 0 28px;
  height: 28px;
  place-items: center;
  color: var(--stop-green);
  background: color-mix(in srgb, var(--stop-green) 12%, white);
  border: 1px solid color-mix(in srgb, var(--stop-green) 24%, white);
  border-radius: 50%;
  font-size: .75rem;
}

.next-stop #next-stop-distance { margin-left: calc(28px + .65rem); }

.playback-timeline {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: .5rem;
  width: min(300px, calc(100% - 98px));
  height: 44px;
  padding-inline: 12px;
  background: #fffdf8;
  border: 1px solid #ddd8e8;
  border-radius: 24px;
  box-shadow: 0 3px 14px #17204924;
  transform: translateY(-50%);
  animation: slide-timeline 220ms ease-out;
}

.playback-timeline:has(#simulation-speeds:not([hidden])) {
  flex-wrap: wrap;
  width: min(340px, calc(100% - 98px));
  height: auto;
  gap: 0 .5rem;
  padding-block: 4px 8px;
  border-radius: 16px;
}

#simulation-speeds {
  display: flex;
  flex: 0 0 100%;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .25rem .5rem;
  font-size: .75rem;
}

#simulation-speeds label {
  display: flex;
  align-items: center;
  gap: .4rem;
}

#simulation-speeds select {
  appearance: none;
  min-height: 36px;
  min-width: 4.75rem;
  padding: .4em 1.6rem .1em .65rem;
  color: inherit;
  font-size: .875rem;
  line-height: 1.3;
  border: 1px solid var(--santa-tint-border);
  border-radius: 8px;
  background:
    linear-gradient(45deg, transparent 50%, currentColor 50%) right 13px center / 4px 4px no-repeat,
    linear-gradient(135deg, currentColor 50%, transparent 50%) right 9px center / 4px 4px no-repeat,
    var(--santa-tint);
  cursor: pointer;
}

.playback-timeline input {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  margin: 0;
  accent-color: var(--stop-green);
  cursor: pointer;
  touch-action: none;
}

#playback-percent {
  white-space: nowrap;
  font-size: .75rem;
  font-variant-numeric: tabular-nums;
}

@keyframes slide-timeline {
  from { opacity: 0; transform: translate(18px, -50%); }
}

@media (prefers-reduced-motion: reduce) {
  .playback-timeline { animation: none; }
}

.tracking-view { --journey-bottom: max(30px, env(safe-area-inset-bottom)); }
.journey { bottom: var(--journey-bottom); }

#preview-title {
  margin-bottom: .5rem;
  color: #ad2440;
}

#cue-icon {
  flex-basis: 52px;
  width: 52px;
  height: 52px;
  padding: 9px;
}

.playback-cue .turn-distance {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 750;
  line-height: 1.15;
}

#open-help svg { width: 24px; }
#close-timeline svg, #recenter svg { width: 1em; height: 1em; }
#recenter { gap: .35em; }

#close-timeline {
  display: grid;
  flex: 0 0 36px;
  height: 36px;
  place-items: center;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 50%;
  font-size: 1.45rem;
  line-height: 1;
}

#close-timeline:hover { background: var(--santa-tint); }



#map-tools-toggle { display: none; }
#map-tools-toggle svg { width: 22px; }

#inspect-next-stop { width: 100%; }
#next-stop {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 680px) {
  #map-tools-toggle {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    position: absolute;
    z-index: 3;
    top: 12px;
    right: max(12px, env(safe-area-inset-right));
    color: inherit;
    background: #fffefa;
    border: 1px solid #d5d7d4;
    border-radius: 50%;
    box-shadow: 0 3px 12px #242c561b;
  }
  #map-tools-toggle[aria-expanded="true"] { background: var(--santa-tint); }
  .map-actions { top: 64px; max-height: calc(100% - 90px); z-index: 2; }
  #map-tools-toggle[aria-expanded="false"] ~ :is(.map-actions, .playback-timeline) { display: none; }

  .overview {
    width: calc(100% - max(12px, env(safe-area-inset-left)) - max(12px, env(safe-area-inset-right)));
  }
  .overview #preview-title { padding-right: 46px; }
  .overview #overview-copy { padding-right: 42px; }
  .tracking-view:has(#map-tools-toggle[aria-expanded="true"]) .overview { padding-right: 60px; }
}

.tracking-view { --card-width: min(455px, calc(100% - 104px)); }
.playback-cue > div { min-width: 0; }
#cue-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#recenter, #current-road { bottom: var(--control-bottom, 30px); }

#current-road {
  position: absolute;
  z-index: 2;
  left: 50%;
  margin: 0;
  padding: 11px 16px 7px;
  color: inherit;
  background: #fffdf8;
  border: 1px solid #d5cee2;
  border-radius: 24px;
  box-shadow: 0 3px 14px #17204924;
  font-weight: 700;
  transform: translateX(-50%);
}

@media (max-width: 680px) {
  #map-tools-toggle {
    top: auto;
    bottom: var(--control-bottom, 30px);
    color: #fff;
    background: #1b7045;
    border-color: #1b7045;
  }
  #map-tools-toggle[aria-expanded="true"] {
    color: var(--santa-red);
    background: var(--santa-tint);
    border-color: var(--santa-tint-border);
  }
  .map-actions {
    top: auto;
    bottom: calc(var(--control-bottom, 30px) + 52px);
    max-height: max(44px, calc(100% - var(--control-bottom, 30px) - 65px));
    z-index: 3;
  }

  .overview #preview-title, .overview #overview-copy,
  .tracking-view:has(#map-tools-toggle[aria-expanded="true"]) .overview { padding-right: 0; }
  .tracking-view:has(#map-tools-toggle[aria-expanded="true"]) .overview { padding-right: 12px; }
}

.tracking-view .overview:has(#gps-status:not([hidden])) { padding-inline-end: 64px; }

#quick-tour {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  color: #12243e;
  background: transparent;
  border: 0;
  border-radius: 0;
}

#quick-tour::backdrop { background: transparent; }
#quick-tour:has(#tour-spotlight[hidden]):has(#tour-route-highlight[hidden])::backdrop { background: #102039b8; }

#tour-spotlight {
  position: absolute;
  border: 2px solid #a8e1b9;
  border-radius: 16px;
  box-shadow: 0 0 0 100vmax #102039b8, 0 0 14px #a8e1b970;
  pointer-events: none;
}

#tour-card {
  position: absolute;
  width: min(22rem, calc(100% - 24px));
  max-height: calc(100% - 24px);
  padding: 1rem 1.15rem;
  overflow: auto;
  background: #fffdf8;
  border: 1px solid #d5e4d9;
  border-top: 4px solid #1b7045;
  border-radius: 16px;
  box-shadow: 0 14px 45px #091b3452;
}

#tour-title { margin: 0; }
#tour-title:focus { outline: none; }
#tour-copy { margin: .45rem 0 .8rem; font-size: .9rem; }
.tour-step {
  margin: 0 0 .4rem;
  color: #1b7045;
  font-size: .72rem;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

#tour-track {
  height: 4px;
  margin-bottom: .65rem;
  background: #e3eae3;
  border-radius: 8px;
}
#tour-track::before {
  display: block;
  width: var(--tour-progress);
  height: 100%;
  background: #1b7045;
  border-radius: inherit;
  content: '';
}

.tour-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .4rem; }
.tour-actions button {
  min-height: 44px;
  padding: .6rem .65rem .3rem;
  color: #1b523a;
  background: #f0f5ef;
  border: 1px solid #d5e4d9;
  border-radius: 8px;
  font-weight: 650;
}
#tour-skip { margin-right: auto; }
#tour-next, #tour-hide { color: #fff; background: #1b7045; border-color: #1b7045; }
#tour-route-highlight {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.tour-inline-icon {
  width: 1.05em;
  height: 1.05em;
  margin-inline: .1em;
  vertical-align: -.16em;
  color: #1b7045;
}

@media (max-width: 680px) {
  .journey { max-height: min(30%, 16rem); }

  .playback-timeline,
  .playback-timeline:has(#simulation-speeds:not([hidden])) {
    inset: auto 66px calc(var(--control-bottom, 30px) + 8px) 12px;
    width: auto;
    transform: none;
    animation: none;
  }

  #simulation-speeds {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  #simulation-speeds label {
    display: grid;
    min-width: 0;
    gap: 2px;
  }

  #simulation-speeds select {
    width: 100%;
    min-width: 0;
  }

  .tracking-view:has(.playback-timeline:not([hidden])):has(#map-tools-toggle[aria-expanded="true"]) #current-road,
  .tracking-view:has(.playback-timeline:not([hidden])):has(#map-tools-toggle[aria-expanded="true"]) #recenter {
    bottom: calc(var(--control-bottom, 30px) + 115px);
  }
}
