/* The Real Santa Tracker, Style D: bold shapes, one flat shadow tone per object, few large details.
   Layout: a full-screen map; the countdown floats top centre on every screen; stats sit in a bottom sheet. */

@font-face { font-family: "Baloo 2"; font-weight: 600; font-display: swap; src: url("../fonts/baloo-2-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Baloo 2"; font-weight: 700; font-display: swap; src: url("../fonts/baloo-2-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 400; font-display: swap; src: url("../fonts/nunito-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 700; font-display: swap; src: url("../fonts/nunito-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 800; font-display: swap; src: url("../fonts/nunito-latin-800-normal.woff2") format("woff2"); }

:root {
  color-scheme: dark;
  --night: #141c4a;
  --ocean: #213f9a;
  --snow: #f7faff;
  --snow-shade: #c9d6f2;
  --red: #e0483f;
  --red-dark: #b93a36;
  --gold: #ffc94a;
  --gold-dark: #d99a1e;
  --green: #2f8f63;
  --green-dark: #1f6b4d;
  --blue: #3c7fd0;
  --blue-dark: #2b5fa6;
  --panel: #17245c;
  --panel-edge: #0b1238;
  --text: #eef2ff;
  --muted: #aab6e0;
  --display: "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  --body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--text); font-family: var(--body); overflow: hidden; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.app { position: fixed; inset: 0; }
.map { position: absolute; inset: 0; touch-action: none; cursor: grab; background: var(--ocean); }
.map.dragging { cursor: grabbing; }
.map > svg { display: block; width: 100%; height: 100%; }

/* A string of Christmas lights along the top of the screen. The two glow layers take turns. */
.garland { position: absolute; z-index: 6; left: 0; right: 0; top: calc(var(--safe-top) - 2px); height: 30px; pointer-events: none; background: url("../img/garland.svg") left top / 160px 30px repeat-x; }
.garland::before, .garland::after { content: ""; position: absolute; inset: 0; background: url("../img/garland-glow-a.svg") left top / 160px 30px repeat-x; animation: twinkle 1.8s steps(1) infinite; }
.garland::after { background-image: url("../img/garland-glow-b.svg"); animation-delay: -.9s; }
@keyframes twinkle { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* Gentle snowfall over the map, behind the panels. The flakes are made in main.js. */
.snowfall { position: absolute; inset: 0; z-index: 5; overflow: hidden; pointer-events: none; }
.flake { position: absolute; top: -12px; border-radius: 50%; background: var(--snow); opacity: .85; animation: fall linear infinite; will-change: transform; }
@keyframes fall { to { transform: translate3d(var(--drift, 20px), calc(100vh + 24px), 0); } }

/* Brand */
.brand { position: absolute; top: calc(14px + var(--safe-top)); left: 16px; display: flex; align-items: center; gap: 8px; pointer-events: none; }
.brand-mark { width: 34px; height: 34px; }
.brand { z-index: 8; top: calc(30px + var(--safe-top)); }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 1.2rem; line-height: 1; text-shadow: 0 2px 0 var(--panel-edge); }

/* Countdown: fixed, always in the same place */
.countdown {
  position: fixed; z-index: 30; top: calc(24px + var(--safe-top)); left: 50%; transform: translateX(-50%);
  background: var(--red); border-radius: 22px; padding: 13px 14px 10px;
  box-shadow: 0 5px 0 var(--red-dark), 0 10px 24px rgba(5, 8, 30, .35);
  text-align: center; min-width: 240px;
}
.countdown::before { content: ""; position: absolute; left: 6px; right: 6px; top: -8px; height: 22px; background: url("../img/snowcap.svg") center / 100% 100% no-repeat; pointer-events: none; }
.countdown-label { margin: 0 0 4px; font-family: var(--display); font-weight: 700; font-size: .95rem; line-height: 1.1; }
.countdown-units { display: flex; gap: 6px; justify-content: center; }
.unit { background: var(--snow); color: var(--night); border-radius: 12px; min-width: 52px; padding: 4px 6px 2px; box-shadow: 0 3px 0 var(--snow-shade); display: flex; flex-direction: column; align-items: center; }
.num { font-family: var(--display); font-weight: 700; font-size: 1.7rem; line-height: 1; font-variant-numeric: tabular-nums; }
.lbl { font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: #4a5590; }
.app[data-countdown="here"] .countdown { background: var(--green); box-shadow: 0 5px 0 var(--green-dark), 0 10px 24px rgba(5, 8, 30, .35); }

/* Buttons */
.corner-buttons { position: absolute; top: calc(30px + var(--safe-top)); right: 14px; display: flex; gap: 8px; z-index: 20; }
.round-btn { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--green); color: var(--snow); display: grid; place-items: center; box-shadow: 0 4px 0 var(--green-dark); font-family: var(--display); font-size: 1.5rem; line-height: 1; }
.round-btn svg { width: 24px; height: 24px; }
.round-btn.small { width: 42px; height: 42px; background: var(--snow); color: var(--night); box-shadow: 0 4px 0 var(--snow-shade); }
.round-btn[aria-pressed="true"] { background: var(--gold); color: var(--night); box-shadow: 0 4px 0 var(--gold-dark); }
.round-btn:active, .pill-btn:active { transform: translateY(2px); }
.pill-btn { border: 0; border-radius: 999px; padding: 10px 18px; background: var(--gold); color: var(--night); font-weight: 800; box-shadow: 0 4px 0 var(--gold-dark); }
.map-buttons { position: absolute; right: 14px; bottom: calc(var(--sheet-h, 200px) + 24px + var(--safe-bottom)); display: flex; flex-direction: column; align-items: flex-end; gap: 8px; z-index: 20; }

/* Banner for big moments */
.banner {
  position: absolute; z-index: 25; left: 50%; top: calc(142px + var(--safe-top)); transform: translateX(-50%);
  width: min(92vw, 440px); background: var(--snow); color: var(--night); border-radius: 20px; padding: 12px 18px;
  box-shadow: 0 5px 0 var(--snow-shade); text-align: center;
}
.banner-title { margin: 0; font-family: var(--display); font-weight: 700; font-size: 1.35rem; line-height: 1.15; }
.banner-text { margin: 2px 0 0; font-weight: 700; color: #3a4580; }
.banner.big { background: var(--gold); box-shadow: 0 5px 0 var(--gold-dark); }
.banner.big .banner-title { font-size: 1.8rem; }

/* Bottom sheet: a navy tray with a candy-cane edge, a snow-white place card and four bright tiles */
.sheet {
  position: absolute; z-index: 20; left: 50%; transform: translateX(-50%); bottom: calc(12px + var(--safe-bottom));
  width: min(calc(100vw - 24px), 720px); background: var(--panel); border-radius: 24px; padding: 16px 10px 10px;
  box-shadow: 0 5px 0 var(--panel-edge); display: flex; flex-direction: column; gap: 8px; overflow: hidden;
}
.sheet::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 8px; background: repeating-linear-gradient(120deg, var(--red) 0 12px, var(--snow) 12px 24px); }
.place { display: flex; gap: 12px; background: var(--snow); color: var(--night); border-radius: 16px; padding: 10px; box-shadow: 0 3px 0 var(--snow-shade); }
.place-pic { flex: 0 0 auto; width: 104px; height: 104px; border-radius: 12px; overflow: hidden; background: var(--ocean); box-shadow: 0 3px 0 var(--snow-shade); }
.place-pic svg, .place-pic img { display: block; width: 100%; height: 100%; object-fit: cover; }
.place-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; min-height: 104px; }
.place-kicker { margin: 0; font-weight: 800; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--red-dark); }
.place-name { margin: 0; font-family: var(--display); font-weight: 700; font-size: 1.4rem; line-height: 1.1; text-wrap: balance; }
.place-fact { margin: 2px 0 0; line-height: 1.35; font-size: .95rem; font-weight: 700; color: #2b3570; }
.place-credit { margin: 0; font-size: .7rem; color: #5a6699; }
.place-credit:empty { display: none; }
.place-credit a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.place.swap .place-pic, .place.swap .place-name { animation: swap .5s ease-out; }
@keyframes swap { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.stats { display: grid; grid-template-columns: 1.7fr 1.2fr 1fr 1.1fr; gap: 8px; }
.stat { background: var(--red); border-radius: 14px; padding: 6px 10px; box-shadow: 0 3px 0 var(--red-dark); display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; min-width: 0; }
.stat:nth-child(2) { background: var(--green); box-shadow: 0 3px 0 var(--green-dark); }
.stat:nth-child(3) { background: var(--gold); box-shadow: 0 3px 0 var(--gold-dark); color: var(--night); }
.stat:nth-child(4) { background: var(--blue); box-shadow: 0 3px 0 var(--blue-dark); }
.stat-ico { grid-row: 1 / 3; width: 26px; height: 26px; }
.stat-num { font-family: var(--display); font-weight: 700; font-size: 1.25rem; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.stat-lbl { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* Dialogs */
.card { border: 0; padding: 0; background: transparent; color: var(--night); max-width: min(92vw, 420px); width: 100%; }
.card::backdrop { background: rgba(8, 12, 40, .55); }
.card-inner { background: var(--snow); border-radius: 22px; padding: 18px 20px 20px; box-shadow: 0 6px 0 var(--snow-shade); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.card-kicker { margin: 0; font-weight: 800; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--red); }
.card-title { margin: 0; font-family: var(--display); font-weight: 700; font-size: 1.7rem; line-height: 1.1; text-wrap: balance; }
.card-meta { margin: 0; font-weight: 700; color: #4a5590; }
.card-fact { margin: 0; line-height: 1.5; }
.card-fact:empty { display: none; }
.field { display: flex; flex-direction: column; gap: 4px; width: 100%; font-weight: 700; }
.field select { padding: 8px 10px; border-radius: 10px; border: 2px solid var(--snow-shade); background: #fff; color: var(--night); }
.field.check { flex-direction: row; align-items: center; gap: 10px; }
.field.check input { width: 22px; height: 22px; accent-color: var(--red); }
.field.town input { padding: 9px 12px; border-radius: 10px; border: 2px solid var(--snow-shade); background: #fff; color: var(--night); font: inherit; font-weight: 600; }
.town-results { list-style: none; margin: 0; padding: 4px; border-radius: 12px; background: #fff; border: 2px solid var(--snow-shade); max-height: 236px; overflow-y: auto; }
.town-results button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--night); font: inherit; font-weight: 600; cursor: pointer; }
.town-results button:hover, .town-results button:focus-visible { background: #e8eefc; }
.town-results .none { padding: 8px 10px; color: #4a5590; }
.town-now { margin: 0; font-weight: 700; color: var(--green); }
.town-now:has(span:empty) { display: none; }
.link-btn { border: 0; background: none; padding: 0; color: var(--blue); font: inherit; text-decoration: underline; cursor: pointer; }
.fine { margin: 0; font-size: .85rem; color: #4a5590; }

/* Map pieces. The sleigh and the rings sit in their own layer above the map, so their
   animations never force the map itself to be redrawn. */
.actors { position: absolute; inset: 0; overflow: hidden; pointer-events: none; will-change: transform; contain: strict; }
.actors > * { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.santa svg { position: absolute; left: -90px; top: -50px; overflow: visible; }
.santa-bob { animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-3px); } }
.sparkle { animation: sparkle 1.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.sparkle.s2 { animation-delay: -.4s; }
.sparkle.s3 { animation-delay: -.8s; }
@keyframes sparkle { 0%, 100% { transform: scale(.3); opacity: 0; } 50% { transform: scale(1); opacity: 1; } }
.santa:not(.moving) .sparkle { animation: none; opacity: 0; }
/* The reindeer gallop while the sleigh is moving. */
.moving .santa-bob { animation-duration: .9s; }
.moving .deer { animation: gallop .44s ease-in-out infinite; }
.moving .deer.lead { animation-delay: -.22s; }
.moving .leg { animation: stride .44s ease-in-out infinite; }
.moving .leg.l2 { animation-delay: -.07s; }
.moving .leg.l3 { animation-delay: -.22s; }
.moving .leg.l4 { animation-delay: -.29s; }
@keyframes gallop { 50% { transform: translateY(-2.2px) rotate(-4deg); } }
@keyframes stride { 0%, 100% { transform: rotate(48deg); } 50% { transform: rotate(-44deg); } }
/* Santa throws a present: his arm swings up and the parcel flies out behind the sleigh. */
.toss { opacity: 0; }
.deliver .arm { animation: throw 1.4s ease-in-out; }
.deliver .toss { animation: toss 1.4s ease-in; }
.delivering .arm { animation: throw 1.4s ease-in-out infinite; }
.delivering .toss { animation: toss 1.4s ease-in infinite; }
@keyframes throw { 0%, 100% { transform: none; } 22% { transform: rotate(150deg); } 40% { transform: rotate(60deg); } }
@keyframes toss {
  0%, 20% { opacity: 0; transform: none; }
  24% { opacity: 1; transform: none; }
  45% { opacity: 1; transform: translate(10px, -12px) rotate(120deg); }
  90% { opacity: 1; transform: translate(22px, 40px) rotate(380deg) scale(.7); }
  100% { opacity: 0; transform: translate(23px, 44px) rotate(400deg) scale(.5); }
}
.ring { position: absolute; left: -13px; top: -13px; width: 26px; height: 26px; box-sizing: border-box; border: 3px solid var(--gold); border-radius: 50%; animation: ring 2s ease-out infinite; }
.ring.pop { border-color: var(--snow); animation: ring .75s ease-out 2; }
@keyframes ring { from { transform: scale(.4); opacity: .9; } to { transform: scale(1.6); opacity: 0; } }

/* Santa's village: shown instead of the tracker until the sleigh takes off. */
.village { display: none; position: absolute; inset: 0; background: linear-gradient(#141c4a 30%, #3a4a98); overflow: hidden; }
.village svg { position: absolute; left: 0; bottom: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.village-text { position: absolute; left: 50%; top: calc(150px + var(--safe-top)); transform: translateX(-50%); width: min(88vw, 520px); text-align: center; text-shadow: 0 2px 0 rgba(10, 14, 40, .5); }
.village-title { margin: 0 0 6px; font-family: var(--display); font-weight: 700; font-size: clamp(1.6rem, 6vw, 2.4rem); line-height: 1.1; color: var(--gold); }
.village-text p { margin: 0; font-weight: 700; line-height: 1.45; text-wrap: balance; }
.app[data-phase="before"] .village { display: block; }
.app[data-phase="before"] :is(.map, .sheet, .map-buttons, .banner) { display: none; }
.village .star { animation: twinkle-soft 3s ease-in-out infinite; }
.village .star:nth-child(2n) { animation-delay: -1s; }
.village .star:nth-child(3n) { animation-delay: -2s; }
.village .win, .village .glow { animation: twinkle-soft 4s ease-in-out infinite; }
.village .puff { display: none; }
@keyframes twinkle-soft { 50% { opacity: .55; } }
@media (orientation: landscape) and (max-height: 520px) { .village-text { display: none; } }
.app[data-countdown="done"] .countdown-units { display: none; }
.app[data-countdown="done"] .countdown-label { margin: 2px 4px 4px; font-size: 1.05rem; max-width: 16em; }

/* Rehearsal controls, only with ?rehearsal */
.rehearsal { position: absolute; z-index: 40; left: 12px; top: calc(136px + var(--safe-top)); background: rgba(10, 14, 40, .9); border: 2px dashed var(--gold); border-radius: 12px; padding: 8px 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; max-width: min(94vw, 520px); font-size: .85rem; }
.rehearsal input[type=range] { flex: 1 1 160px; }
.rehearsal button, .rehearsal select { background: var(--panel); border: 1px solid var(--muted); border-radius: 8px; padding: 3px 8px; }

@media (max-width: 560px) {
  .brand-name { display: none; }
  .brand { top: calc(32px + var(--safe-top)); left: 12px; }
  .countdown { min-width: 0; padding: 12px 10px 8px; }
  .unit { min-width: 44px; }
  .num { font-size: 1.45rem; }
  .corner-buttons { right: 10px; flex-direction: column; top: calc(30px + var(--safe-top)); }
  .round-btn { width: 42px; height: 42px; }
  .map-buttons { right: 10px; }
  .place { padding: 8px; gap: 10px; }
  .place-pic { width: 76px; height: 76px; }
  .place-text { min-height: 76px; }
  .place-name { font-size: 1.15rem; }
  .place-fact { font-size: .86rem; }
  .sheet { gap: 6px; padding: 14px 8px 8px; }
  .stats { gap: 6px; grid-template-columns: 1.6fr 1fr; }
  .stat { padding: 4px 8px; grid-template-columns: auto auto 1fr; align-items: baseline; column-gap: 6px; }
  .stat-ico { grid-row: auto; width: 16px; height: 16px; align-self: center; }
  .stat-num { font-size: 1rem; }
  .stat-lbl { font-size: .6rem; }
  .banner { top: calc(126px + var(--safe-top)); }
  .rehearsal { top: calc(124px + var(--safe-top)); }
}

@media (prefers-reduced-motion: reduce) {
  .santa-bob, .ring, .sparkle, .village .star, .village .win, .village .glow, .deer, .leg, .arm, .toss, .garland::before, .garland::after, .place.swap .place-pic, .place.swap .place-name { animation: none; }
  .snowfall { display: none; }
}

/* Names on the map: dark ink with a snowy outline, so they read on land and on the sea. */
#names text, .place { font-family: "Baloo 2", system-ui, sans-serif; font-weight: 700; text-anchor: middle; paint-order: stroke; stroke: #f7faff; stroke-width: .24em; stroke-linejoin: round; fill: #1b2a6b; pointer-events: none; }
#names .country { letter-spacing: .06em; dominant-baseline: central; fill: #33437f; }
.place { font-size: 8.5px; }
