/* DiggerWatch app styles ("Toybox"). Every colour, size, radius and shadow is a
   token from tokens.css (imported as is), so the Sun and Dusk themes both work
   without any per-theme rules here. Rules: docs/v2/design-system/README.md. */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ground);
  color: var(--ink);
  font: 500 17px/24px var(--font-sans);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.icon { display: block; width: var(--icon-sm); height: var(--icon-sm); flex: none; }

/* ---------- Shared controls ---------------------------------------------- */

/* Every control is a solid object: ink outline + hard lift; pressed drops it. */
.btn {
  display: flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--tap-primary); padding: 0 var(--space-5);
  border: var(--edge) solid var(--ink); border-radius: var(--radius-pill);
  box-shadow: var(--lift); background: var(--ground); color: var(--ink);
  font: 700 21px/1 var(--font-round);
  transition: transform 60ms, box-shadow 60ms;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: none; }
.btn:disabled { opacity: .45; }
.btn.go { background: var(--sign-green); color: var(--on-sign); }
.btn.hivis { background: var(--hivis); color: var(--on-hivis); }
.btn.ink { background: var(--ink); color: var(--ground); }
.btn.danger { background: var(--danger); color: var(--on-sign); }
.btn.small { min-height: var(--tap-min); font-size: 17px; padding: 0 var(--space-4); }
.btn.block { width: 100%; }
.link-btn {
  min-height: var(--tap-min); display: flex; align-items: center; justify-content: center;
  border: 0; background: none; color: var(--sign-blue); font: 700 17px/1 var(--font-round);
  text-decoration: none;
}
.round-btn {
  width: var(--tap-min); height: var(--tap-min); flex: none; border-radius: 50%;
  border: var(--edge) solid var(--ink); background: var(--ground); color: var(--ink);
  box-shadow: var(--lift); display: flex; align-items: center; justify-content: center;
  font: 700 22px/1 var(--font-round);
}
.round-btn:active { transform: translateY(4px); box-shadow: none; }
.round-btn .icon { width: 24px; height: 24px; }

/* ---------- App frame and map ------------------------------------------- */

#app { position: fixed; inset: 0; overflow: hidden; background: var(--map-land); }
#map { position: absolute; inset: 0; background: var(--map-land); }
.leaflet-container { font: inherit; background: var(--map-land); }
[data-theme="dusk"] .leaflet-tile-pane { filter: none; }

.attribution {
  position: absolute; left: var(--space-2); bottom: calc(4px + env(safe-area-inset-bottom));
  z-index: 500; padding: 2px 6px; border-radius: 6px;
  background: var(--ground); color: var(--ink-2); font: 600 11px/14px var(--font-sans);
  opacity: .9;
}
.attribution a { color: inherit; }
.demo-badge {
  position: absolute; top: calc(env(safe-area-inset-top) + 72px); left: 50%; transform: translateX(-50%);
  z-index: 600; padding: 2px 10px; border-radius: var(--radius-pill);
  border: 2px solid var(--ink); background: var(--ground); font: 600 14px/18px var(--font-sans);
}

/* Top of the screen is for reading: level chip, crew, filter chips. */
.top-row {
  position: absolute; z-index: 600; left: var(--space-4); right: var(--space-4);
  top: calc(env(safe-area-inset-top) + var(--space-4));
  display: flex; align-items: center; gap: var(--space-3);
}
.level-chip {
  flex: 1; min-width: 0; height: 60px; display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-4) 0 6px; border: var(--edge) solid var(--ink); border-radius: var(--radius-pill);
  background: var(--ground); box-shadow: var(--lift); text-align: left;
}
.level-chip .disc {
  width: 46px; height: 46px; flex: none; border-radius: 50%; background: var(--hivis);
  color: var(--on-hivis); border: var(--edge) solid var(--ink);
  display: flex; align-items: center; justify-content: center; font: 900 22px/1 var(--font-sans);
}
.level-chip .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.level-chip .line { display: flex; justify-content: space-between; gap: var(--space-2); }
.level-chip .name { font: 600 17px/20px var(--font-round); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.level-chip .xp { font: 800 15px/20px var(--font-sans); color: var(--ink-2); white-space: nowrap; }
.bar { height: 12px; border-radius: var(--radius-pill); border: 2px solid var(--ink); background: var(--ground-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--hivis); }
.crew-btn {
  width: 60px; height: 60px; flex: none; border-radius: 50%; border: var(--edge) solid var(--ink);
  background: var(--ground); box-shadow: var(--lift); font: 600 15px/1 var(--font-round);
}

.chip-row {
  position: absolute; z-index: 600; left: 0; right: 0;
  top: calc(env(safe-area-inset-top) + 92px);
  display: flex; gap: var(--space-2); overflow-x: auto; padding: 0 var(--space-4) 8px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: var(--tap-min); display: flex; align-items: center; gap: var(--space-2);
  padding: 0 var(--space-4) 0 8px; border: var(--edge) solid var(--ink); border-radius: var(--radius-pill);
  background: var(--ground); box-shadow: var(--lift); font: 600 17px/20px var(--font-round);
}
.chip.text-only { padding: 0 var(--space-4); }
.chip[aria-pressed="true"] { background: var(--hivis); color: var(--on-hivis); }
.chip .sticker {
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--ink); background: var(--ground-2);
  display: flex; align-items: center; justify-content: center; color: var(--ink);
}
.chip[aria-pressed="true"] .sticker { background: var(--ground); }
.chip .sticker .icon { width: 26px; height: 26px; }

/* Bottom row: Dex (left), SPOTTO! (centre, ~96px above the edge), Me (right). */
.bottom-row {
  position: absolute; z-index: 600; left: var(--space-4); right: var(--space-4);
  bottom: calc(env(safe-area-inset-bottom) + 40px); height: var(--spotto);
  display: flex; align-items: center; justify-content: space-between; pointer-events: none;
}
.bottom-row > * { pointer-events: auto; }
.side-btn {
  width: var(--side-button); height: var(--side-button); border-radius: var(--radius-md);
  border: var(--edge) solid var(--ink); background: var(--ground); box-shadow: var(--lift);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font: 600 14px/16px var(--font-round);
}
.side-btn:active { transform: translateY(4px); box-shadow: none; }
.side-btn .icon { width: 32px; height: 32px; }

.spotto {
  width: var(--spotto); height: var(--spotto); border-radius: 50%;
  border: var(--edge-heavy) solid var(--ink); background: var(--hivis); color: var(--on-hivis);
  box-shadow: var(--lift-lg); text-transform: uppercase;
  font-family: var(--font-round); font-size: 22px; line-height: 22px; font-weight: 700; letter-spacing: .01em;
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 8px;
  transition: transform 60ms, box-shadow 60ms;
}
.spotto:active { transform: translateY(6px); box-shadow: none; }
.spotto.moving {
  background: var(--ground); color: var(--ink); text-transform: none; font-size: 19px; line-height: 21px;
}

/* ---------- Map pins ---------------------------------------------------- */

.pin-host { background: none; border: 0; }
.pin-spot {
  width: 52px; height: 52px; border-radius: 16px; background: var(--sign-blue); color: var(--on-sign);
  border: var(--edge) solid var(--ground); box-shadow: 0 0 0 2px var(--sign-blue), var(--lift);
  display: flex; align-items: center; justify-content: center;
}
.pin-spot .icon { width: 34px; height: 34px; }
.pin-label {
  position: absolute; left: 50%; top: 58px; transform: translateX(-50%); white-space: nowrap;
  padding: 1px 8px; border-radius: var(--radius-pill); background: var(--sign-blue); color: var(--on-sign);
  font: 700 13px/18px var(--font-sans);
}
.pin-activity {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
}
.pin-activity::before {
  content: ""; position: absolute; width: 36px; height: 36px; border-radius: 8px; transform: rotate(45deg);
  background: var(--orange); border: var(--edge) solid var(--ink); box-shadow: var(--lift);
}
.pin-activity .icon { position: relative; width: 26px; height: 26px; color: var(--on-hivis); }
.pin-sighting {
  width: 44px; height: 44px; border-radius: 50%; background: var(--hivis); color: var(--on-hivis);
  border: var(--edge) solid var(--ink); display: flex; align-items: center; justify-content: center;
}
.pin-sighting .icon { width: 30px; height: 30px; }
.pin-age {
  position: absolute; left: 50%; top: 48px; transform: translateX(-50%); white-space: nowrap;
  padding: 0 8px; border-radius: var(--radius-pill); border: 2px solid var(--ink);
  background: var(--ground); color: var(--ink); font: 700 14px/20px var(--font-sans);
}
/* Leaflet writes fill/stroke as attributes; these CSS properties win, so the
   circle takes the theme's tokens. Leaflet's opacity attributes do the fade. */
.sighting-circle { fill: var(--sighting-fill); stroke: var(--sighting-edge); stroke-width: 2; stroke-dasharray: 6 5; }
.user-dot {
  width: 22px; height: 22px; border-radius: 50%; background: var(--sign-blue);
  border: 4px solid var(--ground); box-shadow: 0 0 0 23px color-mix(in srgb, var(--sign-blue) 16%, transparent);
}

/* ---------- Sheets and overlays ----------------------------------------- */

.scrim {
  position: fixed; inset: 0; z-index: 900; background: var(--scrim);
  animation: fade-in 120ms ease-out;
}
.sheet {
  position: fixed; z-index: 901; left: 0; right: 0; bottom: 0;
  max-height: calc(100dvh - 72px); overflow-y: auto;
  padding: var(--space-3) var(--space-4) calc(var(--space-5) + env(safe-area-inset-bottom));
  background: var(--ground-2); color: var(--ink);
  border-top: var(--edge) solid var(--ink); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--float);
  animation: sheet-up 180ms ease-out;
}
.sheet .grabber { width: 44px; height: 6px; border-radius: 3px; background: var(--ink); margin: 0 auto var(--space-3); }
.sheet-head { display: flex; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-3); }
.sheet-head h2 { flex: 1; margin: 0; font: 700 30px/34px var(--font-round); }
.sheet-sub { margin: -6px 0 var(--space-3); color: var(--ink-2); font: 600 17px/22px var(--font-sans); display: flex; align-items: center; gap: 6px; }
.sheet .caption { color: var(--ink-3); text-align: center; margin: var(--space-3) 0 0; }
.sheet-actions { display: flex; flex-direction: column; gap: var(--space-3); margin-top: var(--space-4); }
.dot-green { width: 10px; height: 10px; border-radius: 50%; background: var(--sign-green); display: inline-block; }

@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Picker: 3 x 3 grid of TypeTiles, 12px gaps. */
.tile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); }
.tile {
  position: relative; aspect-ratio: 1 / 1; max-height: var(--tile); min-height: 96px;
  border: var(--edge) solid var(--ink); border-radius: var(--radius-md); background: var(--ground);
  box-shadow: var(--lift); color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font: 600 17px/20px var(--font-round); padding: 4px;
}
.tile .icon { width: var(--icon-md); height: var(--icon-md); }
.tile:active:not(:disabled), .tile.flash { background: var(--hivis); color: var(--on-hivis); transform: translateY(4px); box-shadow: none; }
.tile .likely { position: absolute; top: 8px; right: 8px; width: 12px; height: 12px; border-radius: 50%; background: var(--sign-green); }
.tile.more { border-style: dashed; background: var(--ground-2); box-shadow: none; }
.tile.more .count { font: 900 28px/1 var(--font-sans); }
.tile-grid.locked { opacity: .38; pointer-events: none; }

/* Location explainer rows. */
.explain { display: flex; flex-direction: column; gap: var(--space-3); margin: var(--space-3) 0; }
.explain div { display: grid; grid-template-columns: 96px 1fr; gap: var(--space-3); align-items: baseline; }
.explain b { font: 600 17px/22px var(--font-round); }
.explain span { color: var(--ink-2); }
.hero-disc {
  width: 64px; height: 64px; flex: none; border-radius: 50%; background: var(--hivis); color: var(--on-hivis);
  border: var(--edge) solid var(--ink); display: flex; align-items: center; justify-content: center;
}
.hero-disc .icon { width: 44px; height: 44px; }
.fuzz-demo {
  position: relative; height: 130px; border-radius: var(--radius-md); border: var(--edge) solid var(--ink);
  background: var(--map-land); overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.fuzz-demo .ring {
  width: 104px; height: 104px; border-radius: 50%; background: var(--sighting-fill);
  border: 2px dashed var(--sighting-edge); display: flex; align-items: center; justify-content: center;
}
.fuzz-demo .pill {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); padding: 0 8px;
  border-radius: var(--radius-pill); border: 2px solid var(--ink); background: var(--ground);
  font: 700 14px/20px var(--font-sans);
}

/* Moving: passenger gate. */
.warn-card {
  border: var(--edge) solid var(--danger); border-radius: var(--radius-md); background: var(--ground);
  padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-4);
}
.warn-line { display: flex; gap: var(--space-3); align-items: flex-start; font: 600 19px/24px var(--font-sans); }
.warn-line .bang {
  width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--danger); color: var(--on-sign);
  display: flex; align-items: center; justify-content: center; font: 900 20px/1 var(--font-sans);
}
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  min-height: var(--tap-min); font: 600 19px/22px var(--font-round);
}
.switch {
  width: 72px; height: 40px; flex: none; position: relative; border-radius: var(--radius-pill);
  border: var(--edge) solid var(--ink); background: var(--ground-2);
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--ink); transition: left 120ms;
}
.switch[aria-checked="true"] { background: var(--sign-green); }
.switch[aria-checked="true"]::after { left: 35px; background: var(--ground); }
.slide {
  position: relative; height: 60px; border-radius: var(--radius-pill); border: var(--edge) solid var(--ink);
  background: var(--ground-2); display: flex; align-items: center; justify-content: center;
  font: 600 17px/1 var(--font-round); color: var(--ink-2); touch-action: none; user-select: none;
}
.slide[aria-disabled="true"] { opacity: .45; }
.slide .knob {
  position: absolute; left: 4px; top: 4px; width: 46px; height: 46px; border-radius: 50%;
  background: var(--sign-green); color: var(--on-sign); border: 2px solid var(--ink);
  display: flex; align-items: center; justify-content: center;
}
.slide .knob svg { width: 26px; height: 26px; }

/* XP moment. */
.xp-layer { position: fixed; inset: 0; z-index: 950; display: flex; flex-direction: column; justify-content: center; padding: var(--space-4); background: var(--scrim); }
.xp-card {
  position: relative; margin-top: 64px; padding: 92px var(--space-4) var(--space-4);
  border: var(--edge-heavy) solid var(--ink); border-radius: var(--radius-lg); background: var(--ground);
  box-shadow: var(--lift-lg); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.xp-card .big-disc {
  position: absolute; top: -75px; left: 50%; transform: translateX(-50%);
  width: 150px; height: 150px; border-radius: 50%; background: var(--hivis); color: var(--on-hivis);
  border: var(--edge-heavy) solid var(--ink); display: flex; align-items: center; justify-content: center;
}
.xp-card .big-disc .icon { width: 96px; height: 96px; }
.xp-card .new-sticker {
  position: absolute; top: -66px; right: 18%; transform: rotate(8deg); padding: 2px 12px;
  border-radius: var(--radius-pill); background: var(--orange); color: var(--on-hivis);
  border: var(--edge) solid var(--ink); font: 700 20px/26px var(--font-round);
}
.xp-card h2 { margin: 0; font: 700 44px/46px var(--font-round); }
.xp-card .what { font: 600 19px/24px var(--font-sans); }
/* RarityMark: tier colour + 1-4 pips + the word, never colour alone. */
.rarity {
  display: inline-flex; align-items: center; gap: 8px; padding: 2px 12px 2px 8px;
  border: 2px solid var(--ink); border-radius: var(--radius-pill); color: var(--on-sign);
  font-family: var(--font-mono); font-size: 14px; line-height: 18px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.rarity .pips { display: inline-flex; gap: 3px; }
.rarity .pips i { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid currentColor; }
.rarity .pips i.on { background: currentColor; }
.rarity.tier-everyday { background: var(--tier-everyday); }
.rarity.tier-common { background: var(--tier-common); }
.rarity.tier-special { background: var(--tier-special); }
.rarity.tier-rare { background: var(--tier-rare); color: var(--on-hivis); }
.xp-card .amount { font: 900 44px/44px var(--font-sans); font-variant-numeric: tabular-nums; }
.xp-card .breakdown { color: var(--ink-2); font: 600 14px/18px var(--font-sans); }
.xp-card .progress { width: 100%; display: flex; flex-direction: column; gap: 6px; margin-top: 6px; text-align: left; }
.xp-card .progress .line { display: flex; justify-content: space-between; font: 600 15px/18px var(--font-sans); }
.xp-card .progress .bar { height: 16px; }
.xp-card .toast-line { color: var(--ink-3); font: 600 14px/18px var(--font-sans); }
.extras {
  margin-top: var(--space-4); padding: var(--space-4); border: var(--edge) solid var(--ink);
  border-radius: var(--radius-md); background: var(--ground); display: flex; flex-direction: column; gap: var(--space-3);
}
.extras h3 { margin: 0; font: 600 17px/20px var(--font-round); }
.extras h3 small { color: var(--ink-3); font: 600 14px/18px var(--font-sans); }
.seg { display: flex; gap: var(--space-2); }
.seg button {
  flex: 1; min-height: var(--tap-min); padding: 0 6px; border: var(--edge) solid var(--ink);
  border-radius: var(--radius-pill); background: var(--ground); box-shadow: var(--lift);
  font: 600 16px/18px var(--font-round);
}
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--ground); box-shadow: none; transform: translateY(4px); }
.xp-hint { margin-top: var(--space-3); text-align: center; color: var(--ground); font: 600 15px/20px var(--font-sans); }
[data-theme="dusk"] .xp-hint { color: var(--ink); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 951; overflow: hidden; }
.confetti i {
  position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 4px;
  border: 2px solid var(--ink); animation: drop 1.6s ease-in forwards;
}
@keyframes drop { to { transform: translateY(105vh) rotate(540deg); } }

/* Welcome (first run). */
.welcome {
  position: fixed; inset: 0; z-index: 1000; overflow-y: auto; background: var(--ground);
  padding: calc(env(safe-area-inset-top) + 40px) var(--space-4) calc(env(safe-area-inset-bottom) + 24px);
  display: flex; flex-direction: column; gap: var(--space-4);
}
.welcome h1 { margin: 0; font: 700 30px/34px var(--font-round); }
.welcome ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 14px; }
.welcome li { display: flex; gap: var(--space-3); align-items: flex-start; font: 500 17px/23px var(--font-sans); }
.welcome li .ring {
  width: 40px; height: 40px; flex: none; border-radius: 50%; border: var(--edge) solid var(--ink);
  background: var(--ground); display: flex; align-items: center; justify-content: center; color: var(--ink);
}
.welcome li .ring.hivis { background: var(--hivis); color: var(--on-hivis); font: 900 20px/1 var(--font-sans); }
.welcome li .ring .icon { width: 28px; height: 28px; }
.welcome .bottom { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.tick-row {
  display: flex; align-items: center; gap: 14px; min-height: var(--tap-primary); padding: 0 var(--space-4);
  border: var(--edge) solid var(--ink); border-radius: var(--radius-md); background: var(--ground-2);
  cursor: pointer; font: 600 19px/22px var(--font-round);
}
.tick-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tick-row .box {
  width: 36px; height: 36px; flex: none; border-radius: 10px; border: var(--edge) solid var(--ink);
  background: var(--ground); display: flex; align-items: center; justify-content: center; color: var(--on-hivis);
}
.tick-row .box svg { width: 24px; height: 24px; visibility: hidden; }
.tick-row input:checked + .box { background: var(--hivis); }
.tick-row input:checked + .box svg { visibility: visible; }
.tick-row input:focus-visible + .box { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Server trouble: stays until it's sorted, above Welcome, under the top row. */
.server-problem {
  position: fixed; z-index: 1050; left: var(--space-4); right: var(--space-4);
  top: calc(env(safe-area-inset-top) + 80px);
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  padding: var(--space-3) var(--space-4); border: var(--edge) solid var(--ink); border-radius: var(--radius-md);
  background: var(--ground); color: var(--ink); box-shadow: var(--lift); font: 600 17px/22px var(--font-sans);
}
.server-problem span { flex: 1 1 14em; }
.server-problem .btn { text-decoration: none; }

/* Toast. */
.toast {
  position: fixed; z-index: 1100; left: var(--space-4); right: var(--space-4);
  top: calc(env(safe-area-inset-top) + var(--space-4));
  padding: var(--space-3) var(--space-4); border: var(--edge) solid var(--ink); border-radius: var(--radius-md);
  background: var(--ground); box-shadow: var(--lift); font: 600 17px/22px var(--font-sans);
  transform: translateY(-140%); transition: transform 180ms;
}
.toast.show { transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
  .confetti { display: none; }
}
