/* ============================================================
   VACCINE QUEST — 8-bit pixel-art stylesheet
   90s console palette, hard edges, CRT scanlines, pixel fonts.
   ============================================================ */

:root {
  /* Retro console palette */
  --bg-deep:   #0a0a23;   /* deep space navy */
  --bg-mid:    #1a1042;   /* purple */
  --ink:       #0b1e3a;   /* near-black outline */
  --paper:     #10163a;   /* panel fill */

  --nes-yellow: #ffd23f;
  --nes-red:    #ff3864;
  --nes-cyan:   #3fe0d0;
  --nes-green:  #6bd968;
  --nes-orange: #ff9f1c;
  --nes-blue:   #4d9de0;
  --nes-pink:   #ff6ac1;
  --white:      #f4f4f8;
  --mute:       #9aa7d0;

  /* Exemption categories (map fill colors) */
  --cat-med:  #ff3864;    /* medical only - strictest = hot red */
  --cat-rel:  #ffd23f;    /* medical + religious = yellow */
  --cat-phil: #6bd968;    /* + philosophical = green (most permissive) */

  --tile: clamp(30px, 5.2vw, 58px);   /* responsive tile size */
  --gap: 4px;
  --edge: 3px;            /* pixel border thickness */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--bg-deep); }

body {
  font-family: 'VT323', monospace;
  background:
    radial-gradient(circle at 50% 0%, #241463 0%, var(--bg-deep) 60%),
    var(--bg-deep);
  color: var(--white);
  min-height: 100vh;
  image-rendering: pixelated;
  overflow-x: hidden;
  padding-bottom: 40px;
}

/* CRT scanline overlay */
.scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 9999;
  background: repeating-linear-gradient(
    0deg, rgba(0,0,0,0.16) 0px, rgba(0,0,0,0.16) 1px, transparent 1px, transparent 3px);
  mix-blend-mode: multiply;
}

/* Pixel-font helper */
.pixel { font-family: 'Press Start 2P', monospace; }

/* ---------- HUD header ---------- */
.hud {
  display: flex; align-items: center; gap: 16px;
  padding: 16px clamp(12px, 4vw, 40px);
  background: var(--ink);
  border-bottom: var(--edge) solid #000;
  box-shadow: 0 var(--edge) 0 #2a1b6b;
}
.hud-badge svg { image-rendering: pixelated; display:block; }
.hud-title { flex: 1; }
.hud-title h1 {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(14px, 3.2vw, 26px);
  color: var(--nes-yellow);
  letter-spacing: 1px;
  text-shadow: 3px 3px 0 var(--nes-red), 6px 6px 0 #000;
  line-height: 1.3;
}
.subtitle {
  font-size: clamp(14px, 2.4vw, 20px);
  color: var(--nes-cyan);
  margin-top: 6px;
  letter-spacing: 1px;
}
.hud-score { text-align: center; }
.score-label { display:block; font-size: 13px; color: var(--mute); letter-spacing:1px; }
.score-value {
  font-family:'Press Start 2P', monospace;
  font-size: clamp(16px,3vw,26px); color: var(--nes-green);
  text-shadow: 2px 2px 0 #000;
}

/* ---------- Stage ---------- */
.stage { max-width: 1000px; margin: 0 auto; padding: 24px clamp(8px, 3vw, 24px); }

.instructions {
  text-align:center; font-size: clamp(15px,2.6vw,21px);
  color: var(--nes-yellow); margin-bottom: 18px; letter-spacing:1px;
  animation: blink 1.6s steps(2, jump-none) infinite;
}
@keyframes blink { 50% { opacity: .55; } }

/* ---------- Map frame ---------- */
.map-frame { position: relative; }
.map-wrap {
  background: linear-gradient(180deg,#0d1b46,#0a1230);
  border: var(--edge) solid #000;
  outline: var(--edge) solid #3a2a8f;
  outline-offset: 0;
  box-shadow: 0 8px 0 #000, 0 0 0 6px #1a0f4a inset;
  padding: clamp(10px, 3vw, 26px);
  border-radius: 2px;
}

.map {
  display: grid;
  grid-template-columns: repeat(12, var(--tile));
  grid-auto-rows: var(--tile);
  gap: var(--gap);
  justify-content: center;
}

/* Tile = one state/territory */
.tile {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  font-family:'Press Start 2P', monospace;
  font-size: clamp(7px, 1.4vw, 12px);
  color: #06111f;
  border: var(--edge) solid #000;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;   /* removes the 300ms tap delay / ghost clicks */
  -webkit-tap-highlight-color: transparent;
  transition: transform .06s steps(2), filter .06s;
  box-shadow: inset -3px -3px 0 rgba(0,0,0,0.28), inset 3px 3px 0 rgba(255,255,255,0.32);
  text-shadow: 1px 1px 0 rgba(255,255,255,0.35);
}
.tile.cat-medical_only                    { background: var(--cat-med); }
.tile.cat-medical_religious               { background: var(--cat-rel); }
.tile.cat-medical_religious_philosophical { background: var(--cat-phil); }

.tile:hover, .tile:focus-visible {
  transform: translate(-2px,-2px);
  filter: brightness(1.15) saturate(1.2);
  outline: var(--edge) solid var(--white);
  z-index: 5;
  box-shadow: 4px 4px 0 #000, inset -3px -3px 0 rgba(0,0,0,0.28), inset 3px 3px 0 rgba(255,255,255,0.4);
}
.tile.selected {
  outline: var(--edge) solid var(--nes-cyan);
  animation: pulse .5s steps(2) infinite;
}
@keyframes pulse { 50% { filter: brightness(1.35); } }

/* Territory band */
.tile.territory { border-style: solid; }
.tile.territory::after {
  content:''; position:absolute; inset:0;
  background: repeating-linear-gradient(45deg, rgba(0,0,0,0.14) 0 4px, transparent 4px 8px);
  pointer-events:none;
}

.territory-label {
  text-align:center; margin-top: 10px;
  font-family:'Press Start 2P', monospace; font-size: clamp(8px,1.6vw,12px);
  color: var(--nes-pink); letter-spacing:2px; text-shadow: 2px 2px 0 #000;
}

/* ---------- Hover tooltip ---------- */
.tooltip {
  position: fixed; z-index: 400; pointer-events: none;
  background: var(--ink);
  border: var(--edge) solid #000;
  outline: var(--edge) solid var(--nes-cyan);
  padding: 8px 10px; max-width: 260px;
  box-shadow: 4px 4px 0 #000;
}
.tooltip .tt-name {
  font-family:'Press Start 2P', monospace; font-size: 11px;
  color: var(--nes-yellow); margin-bottom: 6px; line-height:1.4;
}
.tooltip .tt-hint { font-size: 15px; color: var(--nes-cyan); margin-top: 2px; }

/* ---------- Legend ---------- */
.legend {
  margin-top: 22px; background: var(--ink);
  border: var(--edge) solid #000; outline: var(--edge) solid #3a2a8f;
  padding: 14px 18px; box-shadow: 0 6px 0 #000;
}
.legend-title {
  font-family:'Press Start 2P', monospace; font-size: 11px;
  color: var(--nes-yellow); margin-bottom: 12px; letter-spacing:1px;
}
.legend-list { list-style:none; display:flex; flex-wrap:wrap; gap: 10px 26px; }
.legend-list li { font-size: 19px; color: var(--white); display:flex; align-items:center; gap:8px; }
.legend-list em { color: var(--mute); font-style: normal; font-size: 16px; }
.chip {
  width: 20px; height: 20px; display:inline-block; border: var(--edge) solid #000;
  box-shadow: inset -2px -2px 0 rgba(0,0,0,0.28), inset 2px 2px 0 rgba(255,255,255,0.35);
}
.chip--med  { background: var(--cat-med); }
.chip--rel  { background: var(--cat-rel); }
.chip--phil { background: var(--cat-phil); }

/* ---------- Modal window ---------- */
.overlay {
  position: fixed; inset:0; z-index: 800;
  background: rgba(4,4,20,0.78);
  display:flex; align-items:center; justify-content:center;
  padding: 16px;
  animation: fadein .12s steps(2);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
@keyframes fadein { from { opacity:0; } to { opacity:1; } }
.overlay[hidden] { display:none; }

/* While the pop-up window is open, the map cannot receive any pointer/touch
   input. This is the definitive guard against mobile "ghost taps" leaking
   through the overlay to a tile behind it and opening the wrong state. */
body.modal-open .map { pointer-events: none; }
body.modal-open { overflow: hidden; }

.window {
  width: min(560px, 96vw); max-height: 88vh; display:flex; flex-direction:column;
  background: var(--paper);
  border: var(--edge) solid #000;
  outline: var(--edge) solid var(--nes-cyan);
  box-shadow: 8px 8px 0 #000, 0 0 0 6px #1a0f4a inset;
  animation: pop .14s steps(3);
}
@keyframes pop { from { transform: scale(.85); } to { transform: scale(1); } }

.window-bar {
  display:flex; align-items:center; gap:10px;
  background: var(--nes-red); border-bottom: var(--edge) solid #000;
  padding: 8px 10px;
}
.window-code {
  font-family:'Press Start 2P', monospace; font-size: 11px; color:#fff;
  background:#0b1e3a; border: 2px solid #000; padding: 4px 6px;
}
.window-title {
  flex:1; font-family:'Press Start 2P', monospace; font-size: clamp(11px,2.2vw,15px);
  color:#fff; text-shadow: 2px 2px 0 #000; letter-spacing:1px; line-height:1.4;
}
.window-close {
  font-family:'Press Start 2P', monospace; font-size: 12px;
  background: var(--nes-yellow); color:#000; border: 2px solid #000;
  width: 30px; height: 30px; cursor:pointer; box-shadow: 2px 2px 0 #000;
}
.window-close:hover { background:#fff; }
.window-close:active { transform: translate(2px,2px); box-shadow:none; }

.window-body {
  overflow-y: auto; padding: 16px; font-size: 19px; line-height: 1.5;
  scrollbar-width: thin; scrollbar-color: var(--nes-cyan) var(--ink);
}
.window-body::-webkit-scrollbar { width: 12px; }
.window-body::-webkit-scrollbar-track { background: var(--ink); }
.window-body::-webkit-scrollbar-thumb { background: var(--nes-cyan); border: 2px solid #000; }

.win-section { margin-bottom: 16px; }
.win-h {
  font-family:'Press Start 2P', monospace; font-size: 11px;
  color: var(--nes-cyan); margin-bottom: 8px; letter-spacing:1px;
  border-bottom: 2px dashed #3a2a8f; padding-bottom: 6px;
}
.win-summary { color: var(--white); }

.vax-list { list-style:none; display:flex; flex-direction:column; gap:6px; }
.vax-list li {
  background: var(--ink); border: 2px solid #000; padding: 6px 10px;
  color: var(--nes-green); position: relative; padding-left: 26px;
}
.vax-list li::before {
  content:'♦'; position:absolute; left:8px; color: var(--nes-yellow);
}

/* required badge row */
.req-badge {
  display:inline-block; font-family:'Press Start 2P', monospace; font-size: 10px;
  padding: 6px 8px; border: 2px solid #000; margin-bottom: 10px;
  background: var(--nes-orange); color:#0b1e3a; box-shadow: 2px 2px 0 #000;
}

.exempt-grid { display:flex; gap:8px; flex-wrap:wrap; margin-bottom: 10px; }
.exempt-tag {
  font-family:'Press Start 2P', monospace; font-size: 9px; padding: 6px 8px;
  border: 2px solid #000; box-shadow: 2px 2px 0 #000;
}
.exempt-tag.yes { background: var(--nes-green); color:#06210a; }
.exempt-tag.no  { background: #3a2140; color: var(--mute); }
.exempt-notes { color: var(--white); }

.win-link {
  display:inline-block; margin-top: 6px;
  font-family:'Press Start 2P', monospace; font-size: 11px;
  background: var(--nes-cyan); color:#04252b; text-decoration:none;
  padding: 8px 12px; border:2px solid #000; box-shadow: 3px 3px 0 #000;
}
.win-link:hover { background:#fff; }
.win-link:active { transform: translate(3px,3px); box-shadow:none; }

.win-sources { margin-top: 10px; font-size: 16px; color: var(--mute); }
.win-sources a { color: var(--nes-blue); word-break: break-all; }

.window-foot {
  border-top: var(--edge) solid #000; background: var(--ink);
  padding: 8px 12px;
}
.foot-note { font-size: 15px; color: var(--mute); }

/* ---------- Page footer ---------- */
.page-foot { text-align:center; padding: 24px 16px 0; }
.page-foot p { font-size: 16px; color: var(--mute); max-width: 660px; margin: 0 auto 10px; line-height:1.5; }
.page-foot strong { color: var(--nes-yellow); }
.page-foot .license-note {
  margin-top: 14px; padding-top: 12px; border-top: 2px dashed #3a2a8f;
  color: var(--white);
}
.page-foot .license-note a { color: var(--nes-cyan); text-decoration: none; }
.page-foot .license-note a:hover { color: #fff; text-decoration: underline; }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .hud { flex-wrap: wrap; }
  .hud-score { width: 100%; display:flex; justify-content:space-between; align-items:center; margin-top: 6px; }
  .score-label { display:inline; }
  .legend-list { flex-direction: column; gap: 8px; }
  .window-body { font-size: 18px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .instructions, .tile.selected, * { animation: none !important; }
  .tile { transition: none; }
}
