/*
  MapMaster: what its four screens need on top of site.css. The start page is
  startGame.blade.php, a round is mapmaker.blade.php, the results are score.blade.php
  and the leaderboard is leaderboard.blade.php.
*/

/* ── Pieces more than one screen uses ───────────────────── */

/* Six short bars, one per round. */
.pips { display: flex; align-items: center; gap: 5px; }
.pip { width: 22px; height: 5px; border-radius: 3px; background: var(--line-strong); transition: background .3s; }
.pip.done { background: color-mix(in srgb, var(--accent) 45%, var(--line-strong)); }
.pip.active { background: var(--accent); }

/* A card whose rows run edge to edge, under a small heading row. */
.card.is-flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 14px clamp(16px, 2.4vw, 22px);
  border-bottom: 1px solid var(--line);
}

/* The leaderboard list (partials/leaderboard.blade.php). */
.board { margin: 0; padding: 0; list-style: none; }
.board-row { display: flex; align-items: center; gap: 14px; min-height: 54px; padding: 8px clamp(16px, 2.4vw, 22px); border-bottom: 1px solid var(--line); }
.board-row:last-child { border-bottom: 0; }
.board-row.is-me { background: var(--accent-soft); }
.board-pos {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  color: var(--ink-3);
  font: 500 .8rem/1 var(--mono);
  font-variant-numeric: tabular-nums;
}
.board-pos.is-top { background: var(--surface-2); color: var(--ink); }
.board-row:first-child .board-pos.is-top { background: var(--accent); color: var(--accent-ink); }
.board-name { flex: 1; min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
.board-you { margin-left: 8px; color: var(--accent); font: 500 .65rem/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.board-score { flex-shrink: 0; font: 500 .95rem/1 var(--mono); font-variant-numeric: tabular-nums; }
.board-empty { padding: 40px 20px; color: var(--ink-3); text-align: center; }

/* ═══ The start page ═══════════════════════════════════════ */
.start {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 420px);
  gap: clamp(28px, 6vw, 80px);
  align-items: center;
  width: 100%;
  max-width: 1080px;
  margin-inline: auto;
  padding: clamp(28px, 7vw, 96px) clamp(16px, 4vw, 32px) 0;
}
.start-intro .display { margin-top: 12px; }
.start-intro .lede { max-width: 46ch; margin-top: 16px; }

.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: clamp(24px, 4vw, 36px); border-top: 1px solid var(--line); }
.fact { padding: 16px 14px 0 0; }
.fact + .fact { padding-left: 14px; border-left: 1px solid var(--line); }
.fact dd { margin-top: 6px; font: 600 1.15rem/1.2 var(--serif); }

.start-card { animation: rise .45s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.start-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.start-card-head h2 { font: 600 1.4rem/1.2 var(--serif); letter-spacing: -.02em; }
.start-card .alert { margin-bottom: 16px; }

.name-wrap { position: relative; }
.name-wrap .input { padding-right: 62px; }
.char-count { position: absolute; top: 50%; right: 14px; color: var(--ink-3); font: 400 .72rem/1 var(--mono); transform: translateY(-50%); pointer-events: none; }
.start-card .captcha { margin: 16px 0; }
.start-btn.loading { opacity: .8; }
.start-foot { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: .875rem; text-align: center; }
.start-foot a { font-weight: 500; }

@media (max-width: 860px) {
  .start { grid-template-columns: minmax(0, 1fr); align-items: start; max-width: 560px; }
}
@media (max-width: 420px) {
  .fact dd { font-size: 1rem; }
}

/* ═══ The leaderboard page ═════════════════════════════════ */
.board-page { width: 100%; max-width: 720px; margin-inline: auto; padding: clamp(28px, 6vw, 72px) clamp(16px, 4vw, 32px) 0; }
.board-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: clamp(20px, 3vw, 28px); }
.board-page-head .display { margin-top: 12px; }
.board-page-head .lede { margin-top: 10px; }

/* ═══ The results ══════════════════════════════════════════ */
.results { width: 100%; max-width: 1080px; margin-inline: auto; padding: clamp(20px, 4vw, 44px) clamp(16px, 4vw, 32px) 0; }
.results > * + * { margin-top: 20px; }

.score-hero { position: relative; overflow: hidden; padding-block: clamp(28px, 5vw, 48px); text-align: center; animation: rise .45s var(--ease) both; }
/* Faint lines of latitude and longitude behind the score. */
.score-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, var(--line) 0 1px, transparent 1px 56px),
    repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 56px);
  opacity: .55;
  -webkit-mask-image: radial-gradient(ellipse 75% 85% at 50% 0%, #000 0%, transparent 72%);
  mask-image: radial-gradient(ellipse 75% 85% at 50% 0%, #000 0%, transparent 72%);
  pointer-events: none;
}
.score-hero > * { position: relative; }
.score-number { margin-top: 10px; color: var(--accent); font: 600 clamp(3.6rem, 12vw, 5.6rem)/1 var(--serif); font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.score-max { margin-top: 6px; color: var(--ink-3); font-size: .9rem; }
.score-player { margin-top: 16px; font: 600 1.3rem/1.2 var(--serif); overflow-wrap: anywhere; }
.rank-badge { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; margin-top: 12px; padding: 0 14px; border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .85rem; font-weight: 600; }
.score-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 24px; }

.results-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 760px) {
  .results-grid { grid-template-columns: minmax(0, 1fr); }
  .score-actions .btn { flex: 1 1 160px; }
}

/* One round: its number, where it was, how far off, and the points. */
.round-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) 72px auto; align-items: center; gap: 12px; padding: 13px clamp(16px, 2.4vw, 22px); border-bottom: 1px solid var(--line); transition: background .12s; }
.round-row:last-child { border-bottom: 0; }
.round-row:hover, .round-row.active { background: var(--surface-2); }
.round-num { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); color: var(--ink-3); font: 500 .8rem/1 var(--mono); }
.round-num.best { background: var(--accent-soft); color: var(--accent); }
.round-info { min-width: 0; }
.round-location { overflow: hidden; font-size: .92rem; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.round-dist { margin-top: 2px; color: var(--ink-3); font-size: .8rem; }
.round-dist.timeout { color: var(--danger); font-style: italic; }
.dist-bar-track { height: 4px; overflow: hidden; border-radius: 2px; background: var(--line); }
.dist-bar-fill { height: 100%; border-radius: 2px; background: var(--ok); transition: width 1s cubic-bezier(.22, 1, .36, 1); }
.dist-bar-fill.mid { background: var(--warn); }
.dist-bar-fill.far { background: var(--danger); }
.round-pts { min-width: 36px; font: 500 1rem/1 var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.round-pts.zero { color: var(--ink-3); }
.round-pts.best { color: var(--accent); }
@media (max-width: 420px) {
  .round-row { grid-template-columns: 30px minmax(0, 1fr) auto; }
  .dist-bar-wrap { display: none; }
}

/* The map of guesses. Its pins keep the same colours in light and dark, because the
   map underneath is always a light one. */
.map-card { isolation: isolate; }
#results-map { width: 100%; height: clamp(320px, 52vw, 460px); background: var(--surface-2); }
/* In the dark look the map's own colours are turned down, so it doesn't glare. */
html[data-theme="dark"] #results-map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.95) contrast(.9) saturate(.7); }
.leaflet-container .leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 82%, transparent); color: var(--ink-3); font-size: 10px; }
.leaflet-container .leaflet-control-attribution a { color: var(--ink-2); }
.map-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 12px clamp(16px, 2.4vw, 22px); border-top: 1px solid var(--line); }
.legend-item { display: flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: .8rem; }
.legend-dot { width: 12px; height: 12px; flex-shrink: 0; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(14, 27, 43, .25); }
.legend-line { width: 20px; height: 0; flex-shrink: 0; border-top: 2px dashed var(--ink-3); }

.leaflet-container { font-family: var(--sans); }
.leaflet-bar { border: 1px solid var(--line-strong) !important; border-radius: 10px !important; box-shadow: var(--shadow) !important; overflow: hidden; }
.leaflet-control-zoom a { border-color: var(--line) !important; background: var(--surface) !important; color: var(--ink) !important; }
.leaflet-control-zoom a:hover { background: var(--surface-2) !important; }
.leaflet-popup-content-wrapper { padding: 0 !important; border: 1px solid var(--line-strong) !important; border-radius: 12px !important; background: var(--surface) !important; box-shadow: var(--shadow-lg) !important; color: var(--ink) !important; font-family: var(--sans) !important; }
.leaflet-popup-content { margin: 0 !important; }
.leaflet-popup-tip-container { display: none !important; }
.leaflet-container a.leaflet-popup-close-button { color: var(--ink-3) !important; }
.map-popup { min-width: 190px; padding: 12px 14px; }
.map-popup-stage { margin-bottom: 4px; color: var(--ink-3); font: 500 .62rem/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.map-popup-label { margin-bottom: 6px; font: 600 1rem/1.25 var(--serif); }
.map-popup-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-top: 1px solid var(--line); color: var(--ink-3); font-size: .8rem; }
.map-popup-row span:last-child { color: var(--ink); font-weight: 500; }
.map-popup-pts { color: var(--accent) !important; }
.map-popup-timeout { padding-bottom: 4px; color: var(--danger); font-size: .8rem; font-style: italic; }

/* ═══ A round: Street View fills the window ════════════════ */
body.is-round { overflow: hidden; background: #0b121d; }
/* Google's script puts "position: relative" on the box it draws in, which undoes any
   positioning given to that box here. So the frame around it fills the window, and the
   box only has to fill the frame. */
.street-view-frame { position: fixed; inset: 0; }
#street-view { width: 100%; height: 100%; }
/* Google's own controls that would give the place away, or aren't needed. */
.gm-bundled-control, .gm-svpc { display: none !important; }

.hud {
  position: fixed;
  top: 14px;
  left: 50%;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 24px);
  padding: 8px 16px 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  white-space: nowrap;
  transform: translateX(-50%);
}
.hud-brand { display: inline-flex; align-items: center; gap: 8px; font: 600 1rem/1 var(--serif); letter-spacing: -.01em; }
.hud-brand .brand-mark { width: 20px; height: 20px; }
.hud-divider { width: 1px; height: 16px; background: var(--line-strong); }
#timer { min-width: 2.2em; font: 500 .95rem/1 var(--mono); font-variant-numeric: tabular-nums; text-align: center; transition: color .3s; }
#timer.warn { color: var(--warn); }
#timer.danger { color: var(--danger); animation: pulse .6s ease infinite alternate; }
@keyframes pulse { to { opacity: .5; } }
@media (max-width: 480px) {
  .hud-brand span { display: none; }
  .hud .pip { width: 16px; }
}

.guess-btn { position: fixed; right: 24px; bottom: 24px; z-index: 100; border-radius: 999px; box-shadow: var(--shadow-lg); }
@media (max-width: 600px) {
  .guess-btn { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); left: 16px; }
}

/* The map slides up from the bottom to take a guess. */
.guess-panel {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  height: min(60vh, calc(100vh - 72px));
  height: min(60dvh, calc(100dvh - 72px));
  min-height: min(420px, calc(100vh - 72px));
  min-height: min(420px, calc(100dvh - 72px));
  border-top: 1px solid var(--line-strong);
  border-radius: 20px 20px 0 0;
  background: var(--surface);
  transform: translateY(100%);
  visibility: hidden;
  transition: transform .38s cubic-bezier(.32, .72, 0, 1), visibility 0s .38s;
}
.guess-panel.open { box-shadow: 0 -10px 50px rgba(0, 0, 0, .3); transform: translateY(0); visibility: visible; transition: transform .38s cubic-bezier(.32, .72, 0, 1); }
.panel-handle { width: 36px; height: 4px; flex-shrink: 0; margin: 10px auto 0; border-radius: 2px; background: var(--line-strong); }
.panel-header { display: flex; flex-shrink: 0; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; padding: 10px 16px 10px; }
.panel-hint { color: var(--ink-3); font-size: .8rem; }
#map-container { flex: 1; min-height: 0; margin: 0 12px; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface-2); }
.panel-footer { display: flex; flex-shrink: 0; align-items: center; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
.selected-coords { flex: 1; min-width: 0; overflow: hidden; color: var(--ink-3); font: 400 .8rem/1.3 var(--mono); font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.panel-footer .btn { flex-shrink: 0; min-height: 44px; padding: 0 18px; }
/* Confirm stays dim until a pin is on the map. */
#submit-btn { opacity: .45; cursor: not-allowed; }
#submit-btn.has-pin { opacity: 1; cursor: pointer; }
@media (max-width: 420px) {
  .selected-coords { display: none; }
  .panel-footer .btn { flex: 1; }
}

/* Out of time, or Street View has nothing to show. */
.round-overlay { position: fixed; inset: 0; z-index: 300; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(9, 16, 27, .7); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.round-overlay.show { display: flex; }
.round-overlay-card { width: 100%; max-width: 380px; padding: clamp(24px, 5vw, 34px); border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-lg); text-align: center; animation: pop .25s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.round-overlay-icon { color: var(--accent); }
.round-overlay-card h2 { margin-top: 10px; font: 600 1.6rem/1.15 var(--serif); letter-spacing: -.02em; }
.round-overlay-card p { margin: 8px 0 22px; color: var(--ink-2); font-size: .95rem; }
