/* =====================================================================
   style.css — Civ-2 / retro pixel-game theme.
   ===================================================================== */

:root {
  --stone:    #8a7a58;
  --stone-lt: #c9b483;
  --stone-dk: #4a3c22;
  --panel:    #e8dcb8;
  --panel-lt: #fff7de;
  --panel-dk: #7c6a45;
  --ink:      #2a2016;
  --ink2:     #5a4632;
  --gold:     #a9752a;
  --void:     #23301a;
  --pix: "VT323", "Courier New", monospace;
  --bevel-out: 3px solid; /* colours set per element */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; color: var(--ink);
  font-family: var(--pix); font-size: 20px; }

#map { position: absolute; inset: 0; background: #14313a; }
/* the void beyond the island reads like a dark, dithered sea */
#map::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(45deg, #102830 25%, transparent 25%),
    linear-gradient(-45deg, #102830 25%, transparent 25%),
    repeating-linear-gradient(0deg, rgba(90,150,160,0.05) 0 2px, transparent 2px 8px);
  background-size: 8px 8px, 8px 8px, 100% 8px; opacity: 0.7;
}
/* CRT scanline sheen over everything */
#map::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 401;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,0.06) 0 2px, transparent 2px 4px);
}

/* crisp pixels for the base image-overlays and sprites */
.pixel-base, .leaflet-image-layer { image-rendering: pixelated; image-rendering: crisp-edges; }
.psprite { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }

.leaflet-container { background: transparent; font-family: var(--pix); }

/* ---- shared bevel panel ---- */
.bevel {
  background: var(--panel);
  border: 3px solid; border-color: var(--panel-lt) var(--stone-dk) var(--stone-dk) var(--panel-lt);
}
.bevel-in { border-color: var(--stone-dk) var(--panel-lt) var(--panel-lt) var(--stone-dk); }

/* ---- Leaflet zoom control as pixel buttons ---- */
.leaflet-control-zoom { border: none !important; box-shadow: none !important; }
.leaflet-control-zoom a {
  background: var(--panel); color: var(--ink);
  border: 3px solid !important; border-color: var(--panel-lt) var(--stone-dk) var(--stone-dk) var(--panel-lt) !important;
  border-radius: 0 !important; font-size: 22px; font-weight: normal; margin-bottom: 4px; width: 34px; height: 34px; line-height: 30px;
}
.leaflet-control-zoom a:active { border-color: var(--stone-dk) var(--panel-lt) var(--panel-lt) var(--stone-dk) !important; }

/* ---- scale bar (pixel-styled ruler) ---- */
.leaflet-control-scale { margin: 8px 0 0 10px !important; }
.leaflet-control-scale-line {
  background: var(--panel); color: var(--ink); font-family: var(--pix); font-size: 15px; letter-spacing: 1px;
  border: 2px solid var(--ink); border-top: none; border-radius: 0; padding: 0 6px 1px; line-height: 1.25;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.28); text-shadow: none;
}
.leaflet-control-scale-line:not(:first-child) { border-top: 2px solid var(--ink); border-bottom: none; margin-top: -2px; }

/* ---- title bar ---- */
#title {
  position: absolute; top: 10px; left: 10px; z-index: 500;
  background: var(--stone); padding: 4px 12px 2px;
  border: 3px solid; border-color: var(--stone-lt) var(--stone-dk) var(--stone-dk) var(--stone-lt);
}
#title h1 { margin: 0; font-size: 26px; letter-spacing: 3px; color: #241a0f; text-shadow: 1px 1px 0 var(--stone-lt); line-height: 1; }
#title p { margin: 0; font-size: 15px; letter-spacing: 1px; color: #3a2c14; }

/* ---- era readout ---- */
#readout {
  position: absolute; top: 10px; right: 10px; z-index: 500; width: min(260px, 52vw);
  background: var(--panel); padding: 7px 11px 9px;
  border: 3px solid; border-color: var(--panel-lt) var(--stone-dk) var(--stone-dk) var(--panel-lt);
}
.era-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
#era-name { font-size: 26px; letter-spacing: 2px; color: #5a2d12; line-height: 1; }
#era-year { font-size: 22px; color: var(--gold); white-space: nowrap; }
#era-sub { font-size: 16px; color: var(--ink2); letter-spacing: 1px; }
#era-ruler { font-size: 18px; letter-spacing: 1px; color: #7a3f12; margin-top: 2px; }
#era-ruler:empty { display: none; }
#era-pop { font-size: 16px; color: var(--ink2); margin-top: 1px; }
#era-blurb { font-size: 17px; line-height: 1.15; margin: 5px 0 0; color: var(--ink); }

/* ---- round pixel buttons (locate / reset / key) ---- */
#locate, #reset, #key-btn, #list-btn {
  position: absolute; z-index: 500; background: var(--panel); color: var(--ink);
  border: 3px solid; border-color: var(--panel-lt) var(--stone-dk) var(--stone-dk) var(--panel-lt);
  cursor: pointer; display: grid; place-items: center; font-family: var(--pix);
}
#locate, #reset { right: 12px; width: 44px; height: 44px; }
#locate { bottom: 132px; } #reset { bottom: 186px; }
#key-btn, #list-btn { left: 12px; font-size: 20px; letter-spacing: 2px; padding: 5px 14px 3px; }
#key-btn { bottom: 132px; } #list-btn { bottom: 186px; }
#locate:active, #reset:active, #key-btn:active, #list-btn:active { border-color: var(--stone-dk) var(--panel-lt) var(--panel-lt) var(--stone-dk); }

/* ---- sites list panel ---- */
#listpanel {
  position: absolute; z-index: 1200; background: var(--panel); display: flex; flex-direction: column;
  border: 3px solid; border-color: var(--panel-lt) var(--stone-dk) var(--stone-dk) var(--panel-lt);
  transition: transform 0.22s ease;
}
@media (min-width: 561px) {
  #listpanel { top: 0; right: 0; bottom: 0; width: 360px; transform: translateX(105%); }
  #listpanel.open { transform: translateX(0); }
}
@media (max-width: 560px) {
  #listpanel { left: 0; right: 0; bottom: 0; height: 82vh; transform: translateY(103%); }
  #listpanel.open { transform: translateY(0); }
}
.list-head { padding: 9px 12px 8px; background: var(--stone); border-bottom: 3px solid var(--stone-dk); }
.list-titlebar { display: flex; justify-content: space-between; align-items: center; }
.list-title { font-size: 24px; letter-spacing: 2px; color: #241a0f; text-shadow: 1px 1px 0 var(--stone-lt); }
#list-close { border: none; background: none; font-size: 26px; color: #241a0f; cursor: pointer; font-family: var(--pix); line-height: 1; }
#list-search {
  width: 100%; margin-top: 8px; font-family: var(--pix); font-size: 18px; letter-spacing: 1px;
  color: var(--ink); background: var(--panel-lt); padding: 4px 9px;
  border: 2px solid; border-color: var(--stone-dk) var(--panel-lt) var(--panel-lt) var(--stone-dk);
  border-radius: 0; outline: none; -webkit-appearance: none;
}
#list-search::placeholder { color: var(--ink2); opacity: 0.8; }
.lnone { padding: 20px 14px; font-size: 18px; color: var(--ink2); font-style: italic; }
.sort { display: flex; align-items: center; gap: 6px; margin-top: 7px; }
.sort-lbl { font-size: 16px; color: #2a2016; }
.sort button {
  font-family: var(--pix); font-size: 16px; letter-spacing: 1px; padding: 2px 11px 1px; cursor: pointer; color: var(--ink);
  background: var(--panel); border: 2px solid; border-color: var(--panel-lt) var(--stone-dk) var(--stone-dk) var(--panel-lt);
}
.sort button.on { background: var(--stone-lt); border-color: var(--stone-dk) var(--panel-lt) var(--panel-lt) var(--stone-dk); }
.sort button:disabled { opacity: 0.45; cursor: default; }
#list-sub { font-size: 15px; color: #3a2c14; margin-top: 4px; min-height: 15px; font-style: italic; }
#listrows { overflow-y: auto; flex: 1; padding: 2px 0 10px; }
.lrow {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer; font-family: var(--pix); color: var(--ink);
  background: none; border: none; border-bottom: 2px solid rgba(90, 70, 45, 0.16); padding: 6px 12px;
}
.lrow:hover { background: #f5eed8; }
.lrow:active { background: #eadfbf; }
.lspr { width: 34px; height: 38px; image-rendering: pixelated; flex: 0 0 auto; }
.ltext { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.lname { font-size: 20px; letter-spacing: 1px; line-height: 1.05; }
.lmeta { font-size: 15px; color: var(--ink2); }
.lblurb {
  font-size: 15px; color: var(--ink2); line-height: 1.12; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.lstatus.standing { color: #2f5f1c; } .lstatus.ruin { color: #8a4a1c; } .lstatus.gone { color: #6b5836; }
.lsecret { color: #7a3f8a; }
.lmoment { color: #9c3535; }
.ldist { font-size: 18px; color: var(--gold); white-space: nowrap; flex: 0 0 auto; align-self: flex-start; margin-top: 2px; }
#locate-msg {
  position: absolute; right: 64px; bottom: 138px; z-index: 500; max-width: 210px;
  font-size: 16px; color: var(--ink); background: var(--panel); padding: 3px 8px;
  border: 2px solid; border-color: var(--panel-lt) var(--stone-dk) var(--stone-dk) var(--panel-lt);
  opacity: 0; transition: opacity 0.2s; line-height: 1.1;
}
#locate-msg:not(:empty) { opacity: 1; }

/* ---- time control (bottom bar) ---- */
#control {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 500;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--stone);
  border-top: 3px solid var(--stone-lt);
}
#chips { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 7px; scrollbar-width: none; }
#chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; font-family: var(--pix); font-size: 17px; letter-spacing: 1px;
  padding: 3px 10px 1px; cursor: pointer; white-space: nowrap; color: var(--ink);
  background: var(--panel); border: 2px solid; border-color: var(--panel-lt) var(--stone-dk) var(--stone-dk) var(--panel-lt);
}
.chip:active { border-color: var(--stone-dk) var(--panel-lt) var(--panel-lt) var(--stone-dk); }

input#time {
  -webkit-appearance: none; appearance: none; width: 100%; height: 16px; margin: 3px 0 5px;
  background: #2c2416; border: 3px solid; border-color: var(--stone-dk) var(--stone-lt) var(--stone-lt) var(--stone-dk);
  background-image: repeating-linear-gradient(90deg, #8a6d3b 0 8px, #a9843f 8px 16px);
  outline: none;
}
input#time::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 16px; height: 28px; margin-top: -3px;
  background: var(--panel); border: 3px solid; border-color: var(--panel-lt) var(--stone-dk) var(--stone-dk) var(--panel-lt);
  cursor: pointer;
}
input#time::-moz-range-thumb {
  width: 16px; height: 28px; border-radius: 0; background: var(--panel);
  border: 3px solid; border-color: var(--panel-lt) var(--stone-dk) var(--stone-dk) var(--panel-lt); cursor: pointer;
}
.scale { display: flex; justify-content: space-between; font-size: 15px; letter-spacing: 1px; color: #efe6c8; text-shadow: 1px 1px 0 var(--stone-dk); }

/* ---- monument sprites ---- */
.mon-ico { background: transparent; border: none; }
.psprite { transition: transform 0.08s steps(2), filter 0.6s ease; transform-origin: 50% 82%; }
.mon-ico:hover { z-index: 1000 !important; }
.mon-ico:hover .psprite { transform: scale(1.25); }
/* "new this era" — a soft gold glow on sites that first appear at the current slider point */
/* era-now = a clear box outline framing the sites that belong to the era in view */
.mon-ico { transition: box-shadow 0.2s ease, background-color 0.2s ease; }
.mon-ico.era-now {
  background-color: rgba(242, 207, 88, 0.16); border-radius: 3px;
  box-shadow: inset 0 0 0 2px rgba(242, 207, 88, 0.95), 0 0 0 1px rgba(74, 56, 38, 0.6);
}

/* ---- tooltips = pixel banners ---- */
.mon-tip, .leaflet-tooltip {
  background: var(--panel); color: var(--ink); font-family: var(--pix); font-size: 16px; letter-spacing: 1px;
  border: 2px solid; border-color: var(--panel-lt) var(--stone-dk) var(--stone-dk) var(--panel-lt);
  border-radius: 0; box-shadow: 2px 2px 0 rgba(0,0,0,0.3); padding: 1px 7px; line-height: 1.2;
}
.mon-tip::before, .leaflet-tooltip::before { display: none !important; }
.leaflet-map-pane:has(.leaflet-popup) .leaflet-tooltip { display: none !important; }

/* ---- popups ---- */
.rome-popup .leaflet-popup-content-wrapper {
  background: var(--panel); color: var(--ink); border-radius: 0;
  border: 3px solid; border-color: var(--panel-lt) var(--stone-dk) var(--stone-dk) var(--panel-lt);
  box-shadow: 4px 4px 0 rgba(0,0,0,0.35);
}
.rome-popup .leaflet-popup-content { margin: 10px 12px; }
.rome-popup .leaflet-popup-tip { background: var(--panel); border-radius: 0; }
.rome-popup .leaflet-popup-close-button { color: var(--ink2); font-size: 20px; }
.pop h3 { margin: 0 0 1px; font-size: 23px; letter-spacing: 1px; color: #5a2d12; line-height: 1.05; }
.pop .date { font-size: 17px; color: var(--gold); margin-bottom: 5px; }
.pop .badge {
  display: inline-block; font-size: 15px; letter-spacing: 1px; margin-bottom: 6px; padding: 1px 8px;
  border: 2px solid; border-radius: 0;
}
.pop .badge.standing { background: #dcecc9; color: #2f5f1c; border-color: #a9cf88 #4d7327 #4d7327 #a9cf88; }
.pop .badge.ruin     { background: #f2ddc4; color: #8a4a1c; border-color: #d9b489 #93571f #93571f #d9b489; }
.pop .badge.gone     { background: #ddd3c0; color: #5a4632; border-color: #c1b49a #6b5836 #6b5836 #c1b49a; }
.pop .badge.moment   { background: #f4e0d3; color: #8a3320; border-color: #e8c6ac #8a4020 #8a4020 #e8c6ac; }
.pop .secret-tag {
  display: inline-block; font-size: 15px; letter-spacing: 1px; margin-bottom: 7px; padding: 1px 8px;
  color: #6a2d7a; background: #efe0f4; border: 2px solid; border-color: #e4c9ec #6a3a78 #6a3a78 #e4c9ec;
}
.pop p { margin: 0 0 8px; font-size: 18px; line-height: 1.18; }
.pop .links { display: flex; gap: 7px; flex-wrap: wrap; }
.pop .links a {
  font-size: 16px; letter-spacing: 1px; color: #234f7c; text-decoration: none;
  padding: 2px 9px; background: #d7e6f2; border: 2px solid; border-color: #eaf3fb #2b5a86 #2b5a86 #eaf3fb;
}
.pop .links a:active { border-color: #2b5a86 #eaf3fb #eaf3fb #2b5a86; }

/* ---- GPS "you are here" ---- */
.you-icon { image-rendering: pixelated; }
.you-dot {
  width: 14px; height: 14px; background: #2f6fae; border: 3px solid #eaf3ff; box-shadow: 0 0 0 2px #234f7c;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { background: #63a6dd; } }

/* ---- district labels = engraved banners ---- */
.map-label { background: transparent !important; border: none !important; }
.map-label span {
  display: inline-block; white-space: nowrap; font-family: var(--pix);
  font-size: 18px; letter-spacing: 3px; color: #f3ead0; text-transform: uppercase;
  text-shadow: 1px 1px 0 #2a2016, -1px 0 0 #2a2016, 0 1px 0 #2a2016;
}

/* ---- map key ---- */
#legend {
  position: absolute; left: 12px; bottom: 240px; z-index: 600; width: 264px; max-width: calc(100vw - 24px);
  background: var(--panel); padding: 9px 12px 12px;
  border: 3px solid; border-color: var(--panel-lt) var(--stone-dk) var(--stone-dk) var(--panel-lt);
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity 0.15s, transform 0.15s;
}
#legend.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
#legend h3 { margin: 0 0 6px; font-size: 21px; letter-spacing: 2px; color: #5a2d12; }
#legend-close { position: absolute; top: 4px; right: 9px; border: none; background: none; font-size: 22px; color: var(--ink2); cursor: pointer; font-family: var(--pix); }
.legend-group { margin-top: 6px; }
.legend-group + .legend-group { border-top: 2px solid var(--panel-dk); padding-top: 6px; }
.lg-title { font-size: 14px; letter-spacing: 1px; color: var(--ink2); text-transform: uppercase; margin-bottom: 3px; }
.lg-row { display: flex; align-items: center; gap: 8px; font-size: 17px; line-height: 1.35; }
.lg-row .dot { width: 12px; height: 12px; flex: 0 0 auto; border: 2px solid var(--ink); image-rendering: pixelated; }
.lg-row .dot.standing { background: #c9a24b; } .lg-row .dot.ruin { background: #cf8b52; } .lg-row .dot.gone { background: var(--panel); border-style: dashed; }
.lg-row .sw { width: 16px; height: 12px; flex: 0 0 auto; }
.lg-row .sw.river { height: 5px; background: #356fae; } .lg-row .sw.city { background: #a85e3e; }
.lg-row .sw.hill { background: #3a6a25; } .lg-row .sw.wall { height: 6px; background: #9a9179; border-top: 2px solid #c2b99f; }
.lg-row .sw.aqued { height: 6px; background: #b8935a; border-bottom: 2px solid #7c5c33; }
.lg-row .sw.road { height: 5px; background: #cdb079; }
.lg-row .sw.park { background: #5c9a31; border-top: 3px solid #2c5730; }

/* ---- intro card ---- */
#intro { position: absolute; inset: 0; z-index: 900; background: rgba(20,14,6,0.7); display: grid; place-items: center; padding: 18px; transition: opacity 0.3s; }
#intro.hidden { opacity: 0; pointer-events: none; }
#intro .card { position: relative; max-width: 420px; width: 100%; background: var(--panel);
  border: 4px solid; border-color: var(--panel-lt) var(--stone-dk) var(--stone-dk) var(--panel-lt); padding: 20px 22px; }
#intro h2 { margin: 0 0 8px; font-size: 32px; letter-spacing: 3px; color: #5a2d12; }
#intro p { font-size: 19px; line-height: 1.25; margin: 0 0 10px; }
#intro ul { list-style: none; padding: 0; margin: 0 0 14px; font-size: 18px; line-height: 1.5; }
#intro-close { position: absolute; top: 6px; right: 12px; border: none; background: none; font-size: 26px; color: var(--ink2); cursor: pointer; font-family: var(--pix); }
#intro-start { font-family: var(--pix); font-size: 20px; letter-spacing: 2px; padding: 7px 18px 5px; cursor: pointer;
  color: #241a0f; background: var(--stone-lt); border: 3px solid; border-color: #efe4c2 var(--stone-dk) var(--stone-dk) #efe4c2; }
#intro-start:active { border-color: var(--stone-dk) #efe4c2 #efe4c2 var(--stone-dk); }

/* ---- responsive ---- */
@media (max-width: 560px) {
  #title { display: none; }
  #readout { width: 58vw; top: 8px; right: 8px; }
  #era-name { font-size: 21px; } #era-blurb { display: none; }
  #locate, #reset { width: 40px; height: 40px; }
  #locate { bottom: 126px; } #reset { bottom: 172px; }
  #key-btn { bottom: 126px; } #list-btn { bottom: 172px; }
  #legend { bottom: 224px; }
}
