/* 
  Map 1 (Canon): Blood Snow PSA poster (v3)
  User tweaks:
  - Bagel-Nation style: title upper-left, no header band
  - Stage fills viewport on mobile + desktop (fix half-height issues)
  - No rounded "pill" backgrounds behind non-popup text (use shadows/ink effects instead)
  - Play/Pause moved bottom-right above sources
  - Splats + bottles will fade (seep) after appearing (handled in JS)
*/

:root{
  --paper: #f3efe6;
  --paper2:#efe7d7;
  --ink: #151515;
  --blood: #8c0f1a;
  --ice: #8ea2b1;
  --muted: rgba(21,21,21,.66);
  --shadow: rgba(0,0,0,.18);
}

*{ box-sizing: border-box; }

html, body{
  min-height: 100%;
  height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* Robust viewport height across platforms */
#app{
  position: fixed;
  inset: 0;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Stage is the entire poster canvas */
#stage{
  position: relative;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--paper);
}

/* The map panel fills almost all stage, leaving a margin for poster feel */
#mapPanel{
  position: absolute;
  inset: 12px 12px 12px 12px;
  border-radius: 18px;
  box-shadow: 0 16px 42px var(--shadow);
  background: var(--paper2);
  overflow: hidden; /* ensures rounded corners clip the SVG */
}

#viz{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  /* panel background lives on #mapPanel now */
  background:
    radial-gradient(1100px 760px at 50% 24%, rgba(255,255,255,.56), rgba(255,255,255,0) 58%),
    linear-gradient(180deg, rgba(0,0,0,.06), rgba(0,0,0,0));
}


/* Title block (upper-left) */
#titleBlock{
  position: absolute;
  left: 18px;
  top: 18px;
  z-index: 5;
  max-width: min(520px, 74vw);
  pointer-events: none; /* doesn’t block map taps */
}

#title{
  margin: 0;
  line-height: .92;
  font-family: Oswald, Impact, sans-serif;
  letter-spacing: .02em;
  text-transform: uppercase;
  transform: rotate(-1.4deg);
  transform-origin: left top;
  font-size: clamp(30px, 6.2vw, 56px);
  /* subtle “safety bulletin ink” */
  filter: drop-shadow(0 2px 0 rgba(255,255,255,.35)) drop-shadow(0 10px 18px rgba(0,0,0,.12));
}

#title .misreg{
  display: block;
  text-shadow: 1.1px 1.1px 0 var(--ice);
}

/* blood-red blurred backprint behind title for emphasis (no box) */
#title::before{
  content:"";
  position: absolute;
  left: -10px;
  top: 8px;
  width: 78%;
  height: 42%;
  background: rgba(140,15,26,.22);
  filter: blur(12px);
  transform: rotate(-1deg);
  z-index: -1;
}

#subtitle{
  margin: 10px 0 0 0;
  font-weight: 800;
  color: rgba(21,21,21,.64);
  font-size: clamp(13px, 3.2vw, 16px);
  max-width: 46ch;
  text-shadow: 0 1px 0 rgba(255,255,255,.35);
}

/* HUD: year in upper-left below title; play bottom-right */
#hud{
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none; /* HUD containers don't block taps except buttons */
}

#yearBox{
  position: absolute;
  left: 18px;
  text-align: left;
  pointer-events: none;
  filter: drop-shadow(0 10px 20px rgba(0,0,0,.14));
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
}

#yearBox .label{
  font-family: Oswald, Impact, sans-serif;
  letter-spacing: .18em;
  font-size: 14px;
  color: rgba(21,21,21,.58);
  text-shadow: 0 1px 0 rgba(255,255,255,.35);
}

#yearValue{
  font-family: Oswald, Impact, sans-serif;
  font-size: clamp(30px, 6.6vw, 40px);
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255,255,255,.35), 0 12px 24px rgba(0,0,0,.10);
}

/* Play/Pause - bottom right above sources */
#playPause{
  position: absolute;
  right: 18px;
  bottom: 18px;
  pointer-events: auto;
  appearance: none;
  border: none;
  background: none;
  padding: 8px 10px;
  font-weight: 900;
  font-size: 14px;
  color: rgba(21,21,21,.78);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  filter: drop-shadow(0 10px 18px rgba(0,0,0,.12));
  padding-bottom: calc(env(safe-area-inset-bottom) + 0px);
  padding-right: env(safe-area-inset-right);
}
#playPause:active{ transform: translateY(1px); }

/* Attribution (no background) */
#attribution{
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 6;
  font-size: 12px;
  color: rgba(21,21,21,.62);
  text-shadow: 0 1px 0 rgba(255,255,255,.35), 0 10px 18px rgba(0,0,0,.10);
  pointer-events: auto;
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
}

#attribution a{
  color: rgba(21,21,21,.72);
  text-decoration: none;
  border-bottom: 1px dotted rgba(21,21,21,.38);
}
#attribution a:hover{ color: var(--ink); border-bottom-color: var(--ink); }

/* Loading */
#loading{
  position: absolute;
  inset: 12px 12px 12px 12px; /* same as mapPanel */
  z-index: 20;
  display: grid;
  place-content: center;
  gap: 10px;
  border-radius: 18px;
  background: rgba(243,239,230,.74);
  backdrop-filter: blur(6px);
}

.spinner{
  width: 26px; height: 26px;
  border-radius: 999px;
  border: 3px solid rgba(21,21,21,.18);
  border-top-color: rgba(21,21,21,.62);
  animation: spin 1s linear infinite;
  justify-self: center;
}
.loadingText{ font-weight: 900; color: rgba(21,21,21,.72); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Popup bottom sheet (allowed to have background) */
#popup{
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  border-radius: 16px;
  background: rgba(243,239,230,.96);
  border: 1px solid rgba(21,21,21,.18);
  box-shadow: 0 16px 40px rgba(0,0,0,.24);
  padding: 12px 12px 14px 12px;
}
#popup.hidden{ display: none; }

#popupClose{
  position: absolute;
  right: 10px;
  top: 8px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(21,21,21,.18);
  background: rgba(255,255,255,.55);
  font-size: 22px;
  line-height: 0;
}

#popupBody{ padding-right: 40px; color: rgba(21,21,21,.86); }

#popupBody .kicker{
  font-family: Oswald, Impact, sans-serif;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-size: 12px;
  color: rgba(21,21,21,.62);
}
#popupBody .big{ font-weight: 900; font-size: 16px; margin-top: 2px; }
#popupBody .desc{ margin-top: 8px; font-size: 14px; line-height: 1.35; color: rgba(21,21,21,.82); }
#popupBody .tags{ margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.tag{
  font-size: 12px;
  font-weight: 900;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid rgba(21,21,21,.18);
  background: rgba(255,255,255,.52);
}

/* SVG styling */
.county{
  fill: rgba(21,21,21,.012);
  stroke: rgba(21,21,21,.14);
  stroke-width: 0.75;
}
.stateOutline{
  fill: none;
  stroke: rgba(21,21,21,.40);
  stroke-width: 1.7;
}
.splat{
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.22));
  cursor: pointer;
}
.splat .blood{ fill: var(--blood); }
.bottle{
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.18));
  opacity: .92;
  pointer-events: none;
}
.bottle .glass{ fill: rgba(21,21,21,.72); }
.bottle .crack{ stroke: rgba(243,239,230,.75); stroke-width: 1.2; stroke-linecap: round; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}


/* Subtle snowy grain (mid-century printed stock vibe) */
#mapPanel::after{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.10  0 0 0 0 0.10  0 0 0 0 0.10  0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='260' height='260' filter='url(%23n)' opacity='.45'/%3E%3C/svg%3E");
  background-size: 240px 240px;
  opacity: .10; /* keep it very subtle */
  mix-blend-mode: multiply;
}


/* Keep title clear of the year in narrow layouts */
@media (max-width: 520px){
  #titleBlock{ padding-right: 96px; }
}
