/* whereismitch.com — milestone 2 dark map theme.
   Full-bleed Leaflet map with a floating hero band. */

:root {
  color-scheme: dark;
  --bg: #0b0e13;
  --panel: #11151c;
  --panel-edge: #232a36;
  --text: #e9edf4;
  --muted: #8a94a6;
  --accent: #f4b942;      /* sighting amber — warm, silly, easy on the dark map */
  --accent-ink: #1a1206;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;                 /* the map owns the scroll/pan */
  overscroll-behavior: none;
}

/* --- Full-bleed map ------------------------------------------------------ */
#map {
  position: fixed;
  inset: 0;
  height: 100%;
  width: 100%;
  background: var(--bg);            /* shows through before tiles load */
  z-index: 0;
}

/* --- Floating hero band -------------------------------------------------- */
#hero {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  margin: clamp(0.6rem, 2vw, 1.1rem);
  padding: 0.7rem 1rem 0.8rem;
  max-width: min(92vw, 30rem);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  pointer-events: none;            /* clicks pass through to the map */
}
#hero h1 {
  margin: 0;
  font-size: clamp(1.4rem, 4.5vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}
#hero h1 .tld { color: var(--accent); }
#hero .tagline {
  margin: 0.35rem 0 0;
  font-size: clamp(0.85rem, 2.6vw, 1rem);
  color: var(--muted);
}
#hero .counter-slot { margin: 0; }   /* filled in milestone 5 */

/* --- Status / error toast ------------------------------------------------ */
.status {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 1000;
  margin: 0;
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.status.show { opacity: 1; }
.status.error { color: #ff9b9b; border-color: #5a2a2a; }

/* --- Leaflet dark overrides --------------------------------------------- */
.leaflet-container { background: var(--bg); font-family: inherit; }

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--panel-edge);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.leaflet-popup-content-wrapper { border-radius: 12px; }
.leaflet-popup-content { margin: 0.7rem 0.9rem; line-height: 1.45; }
.leaflet-popup-close-button { color: var(--muted) !important; }

.sighting-pop .cap {
  display: block;
  font-weight: 700;
  font-size: 0.98rem;
}
.sighting-pop .place {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.sighting-pop .cred {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.leaflet-control-attribution {
  background: rgba(11, 14, 19, 0.72) !important;
  color: var(--muted) !important;
  backdrop-filter: blur(4px);
}
.leaflet-control-attribution a { color: #9fb3d1 !important; }

.leaflet-bar a {
  background: var(--panel) !important;
  color: var(--text) !important;
  border-color: var(--panel-edge) !important;
}
.leaflet-bar a:hover { background: #1a2130 !important; }

/* --- Report modal -------------------------------------------------------- */
.modal { position: fixed; inset: 0; z-index: 2000; }
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 10, 0.6);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 26rem);
  max-height: 90vh;
  overflow: auto;
  padding: 1.2rem 1.3rem 1.3rem;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.modal-card h2 {
  margin: 0 2rem 0.15rem 0;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}
.modal-loc {
  margin: 0 0 0.9rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.7rem;
  width: 2rem;
  height: 2rem;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.modal-close:hover { color: var(--text); background: #1a2130; }

.field { display: block; margin: 0 0 0.85rem; }
.field > span { display: block; margin-bottom: 0.3rem; font-size: 0.9rem; font-weight: 600; }
.field > span em { color: var(--muted); font-weight: 400; font-style: normal; }
.field select,
.field input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  font: inherit;
  color: var(--text);
  background: #0d1119;
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  appearance: none;
}
.field select:focus,
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
}

.ts-widget { min-height: 1.5rem; margin: 0.2rem 0 0.9rem; }
.ts-missing { font-size: 0.82rem; color: #ff9b9b; }

.btn-primary {
  width: 100%;
  padding: 0.7rem 1rem;
  font: inherit;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.modal-error { margin: 0.6rem 0 0; min-height: 1em; font-size: 0.85rem; color: #ff9b9b; }

/* Off-screen Turnstile for per-action (vote/report) tokens. Positioned off
   canvas rather than display:none so the widget still executes. */
.action-ts { position: absolute; left: -9999px; top: 0; width: 300px; height: 65px; }

/* --- Popup vote / report row -------------------------------------------- */
.sighting-pop .vote-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.55rem;
}
.sighting-pop .vote-row .cred {
  margin: 0;
  flex: 1;
  white-space: nowrap;
}
.vote-btn,
.report-btn {
  font: inherit;
  color: var(--text);
  background: #0d1119;
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  cursor: pointer;
  line-height: 1;
}
.vote-btn {
  width: 1.9rem;
  height: 1.7rem;
  font-size: 0.8rem;
  padding: 0;
}
.vote-btn:hover { border-color: var(--accent); color: var(--accent); }
.report-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
  color: var(--muted);
}
.report-btn:hover { border-color: #5a2a2a; color: #ff9b9b; }

/* --- Hero counter (milestone 5) ----------------------------------------- */
#hero .counter-slot { display: block; margin-top: 0.7rem; }
#hero .big {
  display: block;
  font-size: clamp(2.2rem, 8vw, 3.4rem);
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
#hero .big-label { display: block; margin-top: 0.15rem; font-size: 0.8rem; color: var(--text); }
#hero .stat-line { display: block; margin-top: 0.45rem; font-size: 0.78rem; color: var(--muted); }

/* --- Leaderboard --------------------------------------------------------- */
.leaderboard {
  position: fixed;
  left: clamp(0.6rem, 2vw, 1.1rem);
  bottom: clamp(0.6rem, 2vw, 1.1rem);
  z-index: 1000;
  width: min(80vw, 15rem);
  background: color-mix(in srgb, var(--panel) 85%, transparent);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.leaderboard > summary {
  cursor: pointer;
  padding: 0.55rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  list-style: none;
}
.leaderboard > summary::-webkit-details-marker { display: none; }
.leaderboard > summary::after { content: '▾'; float: right; color: var(--muted); }
.leaderboard:not([open]) > summary::after { content: '▸'; }
.lb-list { margin: 0; padding: 0 0.5rem 0.55rem; list-style: none; }
.lb-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.28rem 0.3rem;
  font-size: 0.82rem;
  border-top: 1px solid color-mix(in srgb, var(--panel-edge) 60%, transparent);
}
.lb-list li:first-child { border-top: none; }
.lb-rank { width: 1.1rem; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-place { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-count { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.lb-empty { padding: 0.3rem; color: var(--muted); font-size: 0.8rem; }

/* --- Heatmap toggle (milestone 6) --------------------------------------- */
.heat-toggle {
  position: fixed;
  top: clamp(0.6rem, 2vw, 1.1rem);
  right: clamp(0.6rem, 2vw, 1.1rem);
  z-index: 1000;
  padding: 0.5rem 0.85rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  background: color-mix(in srgb, var(--panel) 85%, transparent);
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  cursor: pointer;
}
.heat-toggle:hover { border-color: var(--accent); }
.heat-toggle.on { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

/* --- Sightings feed ------------------------------------------------------ */
.feed {
  position: fixed;
  top: calc(clamp(0.6rem, 2vw, 1.1rem) + 3rem);
  right: clamp(0.6rem, 2vw, 1.1rem);
  z-index: 1000;
  width: min(84vw, 17rem);
  background: color-mix(in srgb, var(--panel) 85%, transparent);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.feed > summary {
  cursor: pointer;
  padding: 0.55rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  list-style: none;
}
.feed > summary::-webkit-details-marker { display: none; }
.feed > summary::after { content: '▾'; float: right; color: var(--muted); }
.feed:not([open]) > summary::after { content: '▸'; }
.feed-list {
  margin: 0;
  padding: 0 0.5rem 0.5rem;
  list-style: none;
  max-height: min(58vh, 32rem);
  overflow-y: auto;
}
.feed-item {
  padding: 0.5rem 0.35rem;
  border-top: 1px solid color-mix(in srgb, var(--panel-edge) 60%, transparent);
  cursor: pointer;
}
.feed-item:first-child { border-top: none; }
.feed-item:hover { background: color-mix(in srgb, var(--panel-edge) 30%, transparent); border-radius: 8px; }
.feed-cap { font-size: 0.85rem; font-weight: 600; line-height: 1.3; }
.feed-place { margin-top: 0.1rem; font-size: 0.76rem; color: var(--muted); }
.feed-item .vote-row { margin-top: 0.4rem; }
.feed-empty { padding: 0.4rem 0.35rem; color: var(--muted); font-size: 0.8rem; }

/* --- Mobile pass --------------------------------------------------------- */
@media (max-width: 640px) {
  #hero { max-width: min(70vw, 22rem); padding: 0.55rem 0.8rem 0.65rem; }
  #hero .big { font-size: clamp(2rem, 12vw, 2.6rem); }
  /* Side panels drop to the bottom corners as collapsible pills. */
  .feed {
    top: auto;
    bottom: 2rem;                 /* clear the Leaflet attribution row below */
    right: clamp(0.5rem, 2vw, 1rem);
    width: min(56vw, 15rem);
  }
  .feed-list { max-height: 42vh; }
  .leaderboard {
    left: clamp(0.5rem, 2vw, 1rem);
    bottom: 2rem;
    width: min(40vw, 12rem);
  }
  /* Keep the toast clear of the bottom pills. */
  .status { bottom: 5rem; }
}
