/* Wescraigs Santa Tracker viewer. Visual reference: docs/design/live.html and before.html. */

@font-face {
  font-family: 'Atkinson Hyperlegible'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(vendor/fonts/atkinson-hyperlegible-400-latin.woff2) format('woff2');
}
@font-face {
  font-family: 'Atkinson Hyperlegible'; font-style: normal; font-weight: 700; font-display: swap;
  src: url(vendor/fonts/atkinson-hyperlegible-700-latin.woff2) format('woff2');
}
@font-face {
  font-family: 'Bricolage Grotesque'; font-style: normal; font-weight: 800; font-display: swap;
  src: url(vendor/fonts/bricolage-grotesque-800-latin.woff2) format('woff2');
}

:root {
  --ink: #0E1A2B; --ink-2: #1C2C44; --line: #2E4566; --muted: #B7C2D3;
  --red: #D42A2A; --red-dark: #BC2020; --green: #3DD68C; --amber: #F5B83D; --off: #46597A;
  --gap: 12px;
  --sheet-h: 0px;   /* set from JS so map controls sit above the sheet */
  --banner-h: 0px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font: 16px/1.4 'Atkinson Hyperlegible', system-ui, sans-serif;
  color: #fff; background: #F2EFE9;
  touch-action: none; /* only the map pans and zooms, never the page */
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

#map { position: fixed; inset: 0; height: 100dvh; background: #F2EFE9; }
.dim { position: fixed; inset: 0; z-index: 500; background: rgba(14, 26, 43, .35); pointer-events: none; display: none; }

/* ---- Banner ---- */
.banner {
  position: fixed; z-index: 1000;
  top: calc(var(--gap) + env(safe-area-inset-top));
  left: calc(var(--gap) + env(safe-area-inset-left));
  right: calc(var(--gap) + env(safe-area-inset-right));
  max-width: 560px; margin: 0 auto;
  background: var(--ink); border-radius: 16px; padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 4px 14px rgba(14, 26, 43, .25);
}
.badge { width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px; background: var(--red); display: grid; place-items: center; }
.banner-text { min-width: 0; }
.title { margin: 0; font: 800 18px/1.2 'Bricolage Grotesque', sans-serif; letter-spacing: -.2px; }
.status { margin: 0; display: flex; flex-wrap: wrap; align-items: center; column-gap: 6px; font-size: 16px; color: var(--muted); }
.status b { color: #fff; white-space: nowrap; }
/* Organiser messages can be up to 140 chars: wrap, but never more than three lines. */
#status-detail {
  min-width: 0; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
}
.dot { width: 8px; height: 8px; flex-shrink: 0; border-radius: 50%; background: var(--off); }
.state-live .dot { background: var(--green); }
.state-pre .dot, .state-paused .dot, .is-stale .dot, .is-reconnecting .dot { background: var(--amber); }

/* Wee link to the organiser page, tucked under the banner's right edge. */
.elf {
  position: fixed; z-index: 1000;
  top: calc(var(--banner-h) + 8px);
  right: max(calc(var(--gap) + env(safe-area-inset-right)), calc((100vw - 560px) / 2));
  height: 30px; padding: 0 10px; border-radius: 999px;
  background: var(--ink); color: #fff; text-decoration: none;
  font: 700 16px/1 'Atkinson Hyperlegible', sans-serif;
  display: flex; align-items: center; gap: 4px;
  box-shadow: 0 2px 8px rgba(14, 26, 43, .25);
  touch-action: manipulation;
}
/* Looks small, but the tap area is still 44 px tall. */
.elf::before { content: ''; position: absolute; inset: -7px 0; }
.elf:hover { background: var(--ink-2); }

/* Short note above the sheet, e.g. after a failed Elf admin login. Tap to dismiss. */
.toast {
  position: fixed; z-index: 1100; left: 24px; right: 24px; max-width: 420px; margin: 0 auto;
  bottom: calc(var(--sheet-h) + 16px + env(safe-area-inset-bottom));
  background: var(--ink); color: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 16px; font-size: 16px; text-align: center;
  box-shadow: 0 8px 24px rgba(14, 26, 43, .35);
  opacity: 0; transform: translateY(8px); visibility: hidden;
  transition: opacity .25s, transform .25s, visibility 0s .25s;
}
.toast.show { opacity: 1; transform: none; visibility: visible; transition: opacity .25s, transform .25s; }

/* ---- Card (before / after) ---- */
.card {
  position: fixed; z-index: 1000; left: 24px; right: 24px; top: 30%; max-width: 420px; margin: 0 auto;
  background: var(--ink); border-radius: 20px; padding: 24px 22px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  box-shadow: 0 8px 24px rgba(14, 26, 43, .35);
}
.card .disc { width: 64px; height: 64px; border-radius: 50%; background: #fff; border: 3px solid var(--red); display: grid; place-items: center; }
.card h2 { margin: 0; font: 800 26px/1.15 'Bricolage Grotesque', sans-serif; }
.card p { margin: 0; font-size: 16px; line-height: 1.45; color: var(--muted); }
.card p b { color: #fff; }

/* ---- Bottom sheet ---- */
.sheet {
  position: fixed; z-index: 1000; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto;
  background: var(--ink); border-radius: 22px 22px 0 0;
  padding: 16px calc(16px + env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 -4px 16px rgba(14, 26, 43, .2);
}
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.btn {
  min-height: 52px; padding: 0 10px; border-radius: 14px; background: var(--ink-2); border: 1px solid var(--line);
  color: #fff; font: 700 16px 'Atkinson Hyperlegible', sans-serif;
  display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  touch-action: manipulation;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .give:focus-visible, .elf:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
.switch { width: 38px; height: 22px; flex-shrink: 0; border-radius: 11px; background: var(--off); padding: 2px; display: flex; transition: background .2s; }
.switch span { width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.btn[aria-pressed="true"] .switch { background: var(--green); }
.btn[aria-pressed="true"] .switch span { transform: translateX(16px); }
.give {
  min-height: 56px; border-radius: 14px; background: var(--red); color: #fff; text-decoration: none;
  font-size: 17px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 10px;
  touch-action: manipulation;
}
.give:hover { background: var(--red-dark); }

/* ---- State visibility ---- */
.live-only { display: none; }
.state-live .live-only { display: grid; }
.state-pre .dim, .state-ended .dim { display: block; }
.state-pre .leaflet-control-zoom, .state-ended .leaflet-control-zoom { display: none; } /* map is locked */

/* ---- Leaflet ---- */
.leaflet-container { font: 12px/1.4 'Atkinson Hyperlegible', system-ui, sans-serif; }
.leaflet-control-attribution { font-size: 12px; }
.leaflet-bottom { bottom: var(--sheet-h); }
.leaflet-top { top: var(--banner-h); }

/* Santa marker: ~40 px icon in a red-ringed disc, fixed size at every zoom. */
.santa { display: flex; flex-direction: column; align-items: center; }
.santa .pulse { width: 76px; height: 76px; border-radius: 50%; background: rgba(212, 42, 42, .18); display: grid; place-items: center; animation: pulse 2s ease-in-out infinite; }
.santa .disc { width: 54px; height: 54px; border-radius: 50%; background: #fff; border: 3px solid var(--red); display: grid; place-items: center; box-shadow: 0 2px 6px rgba(14, 26, 43, .3); }
.santa img { width: 40px; height: 40px; display: block; transition: transform .3s; }
.santa.face-left img { transform: scaleX(-1); }
.santa .tag { margin-top: -12px; padding: 3px 10px; border-radius: 999px; background: var(--ink); color: #fff; font: 700 13px 'Atkinson Hyperlegible', sans-serif; }
/* Glide between fixes. Leaflet's own zoom-animation rule is more specific, so it wins while zooming. */
.santa-icon { transition: transform 2s ease-in-out; }
:where(.no-glide) .santa-icon { transition: none; }
@keyframes pulse { 50% { background: rgba(212, 42, 42, .30); } }

@media (prefers-reduced-motion: reduce) {
  .santa .pulse { animation: none; }
  .santa-icon, .santa img, .switch, .switch span, .toast, .toast.show { transition: none; }
}

/* Short landscape phones: sheet moves to the bottom-right corner. */
@media (orientation: landscape) and (max-height: 500px) {
  .banner { right: auto; width: min(420px, calc(100% - 2 * var(--gap))); margin: 0; }
  .elf { top: calc(var(--gap) + env(safe-area-inset-top)); right: calc(var(--gap) + env(safe-area-inset-right)); }
  .sheet {
    left: auto; right: calc(var(--gap) + env(safe-area-inset-right)); bottom: calc(var(--gap) + env(safe-area-inset-bottom));
    width: 340px; border-radius: 18px; padding: 14px;
  }
  .card { top: auto; bottom: calc(var(--gap) + env(safe-area-inset-bottom)); left: calc(var(--gap) + env(safe-area-inset-left)); right: auto; width: min(420px, calc(100% - 340px - 3 * var(--gap))); margin: 0; padding: 18px; gap: 8px; }
  .card .disc { display: none; }
  .card h2 { font-size: 22px; }
  .leaflet-bottom { bottom: 0; }
  .leaflet-bottom.leaflet-right { right: calc(340px + 2 * var(--gap) + env(safe-area-inset-right)); }
}
