/* =========
   Global
   ========= */
:root{
  --ink:#111;
  --paper:#faf7ee;
  --paper2:#fff8e6;
  --uiShadow: 0 10px 30px rgba(0,0,0,.18);
  --uiShadowSoft: 0 6px 18px rgba(0,0,0,.14);
  --panelRadius: 14px;
  --stroke: rgba(0,0,0,.25);
}

*{ box-sizing:border-box; }
html, body { height: 100%; margin:0; background: #0b0b0b; }
body { font-family: "News Cycle", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; color: var(--ink); }

#app { height:100%; width:100%; display:flex; flex-direction:column; }

/* =========
   Top bar
   ========= */
#topbar{
  position: relative;
  z-index: 2000;
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 16px;
  padding: 14px 14px 10px;
  background: linear-gradient(180deg, rgba(250,247,238,.96), rgba(250,247,238,.88));
  border-bottom: 1px solid rgba(0,0,0,.06);
  backdrop-filter: blur(6px);
}

.splash-title{
  line-height: 1;
  user-select:none;
}
.title-main{
  font-family: "Bangers", system-ui, sans-serif;
  font-size: clamp(28px, 3.6vw, 46px);
  letter-spacing: .5px;
  text-transform: uppercase;

  /* Action-comics vibe (subtle) */
  text-shadow:
    0 2px 0 rgba(0,0,0,.15),
    2px 4px 0 rgba(0,0,0,.06);
}
.title-sub{
  margin-top: 6px;
  font-size: 13px;
  font-weight: 700;
  opacity: .8;
}

.controls{
  display:flex;
  align-items:center;
  gap: 10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

select#eventSelect{
  height: 36px;
  max-width: min(46vw, 360px);
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.12);
  padding: 0 12px;
  background: rgba(255,255,255,.65);
  box-shadow: var(--uiShadowSoft);
  font-weight: 700;
}

.btn{
  height: 36px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.12);
  cursor:pointer;
  font-weight: 800;
  letter-spacing: .2px;
  box-shadow: var(--uiShadowSoft);
  transition: transform .08s ease, filter .12s ease;
}
.btn:active{ transform: translateY(1px); filter: brightness(.98); }

.btn-solid{
  background: rgba(255,255,255,.82);
}
.btn-ghost{
  background: rgba(255,255,255,.45);
}

.walk-controls{
  display:flex;
  align-items:center;
  gap: 8px;
}

.hidden{ display:none !important; }

.sr-only{
  position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); border:0;
}

/* =========
   Map shell
   ========= */
#main{ position: relative; flex: 1; min-height: 0; }
#map{ position:absolute; inset: 0; }

/* =========
   Legend
   ========= */
.legend-shell{
  position:absolute;
  right: 14px;
  top: 14px;
  z-index: 1500; /* above map tiles & markers */
  pointer-events:none;
}

.legend-toggle{
  pointer-events:auto;
  font-family: "Bangers", system-ui, sans-serif;
  font-size: 18px;
  height: 44px;
  padding: 0 14px;
  border-radius: 14px;
}

.legend-panel{
  pointer-events:auto;
  margin-top: 10px;
  width: min(320px, 82vw);
  background: rgba(250,247,238,.92);
  border-radius: var(--panelRadius);
  box-shadow: var(--uiShadow);
  border: 1px solid rgba(0,0,0,.10);
  overflow:hidden;
}

.legend-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 10px 10px 6px 12px;
  border-bottom: 1px dashed rgba(0,0,0,.12);
}
.legend-title{
  font-family: "Bangers", system-ui, sans-serif;
  font-size: 22px;
  letter-spacing: .4px;
}
.legend-close{ height: 34px; padding: 0 10px; }

.legend-body{
  padding: 10px 12px 12px;
  display:flex;
  flex-direction:column;
  gap: 8px;
}
.legend-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  border-radius: 12px;
  padding: 8px 10px;
  border: 1px solid rgba(0,0,0,.08);
  background: rgba(255,255,255,.55);
  cursor:pointer;
  user-select:none;
}
.legend-item:hover{ filter: brightness(1.02); }
.legend-left{
  display:flex; align-items:center; gap: 10px;
}
.legend-swatch{
  width: 18px; height: 18px; border-radius: 6px;
  border: 2px solid rgba(0,0,0,.18);
}
.legend-name{
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .3px;
  font-size: 13px;
}
.legend-count{
  font-weight: 900;
  opacity:.8;
  font-size: 12px;
}
.legend-foot{
  padding: 0 12px 12px;
  font-size: 12px;
  opacity:.75;
}

/* Mobile: legend becomes a big obvious button; panel auto-hides */
@media (max-width: 720px){
  #topbar{ align-items:flex-start; }
  .legend-shell{ left: 14px; right: auto; top: 64px; }
  .legend-toggle{ width: auto; }
}

/* =========
   Loading
   ========= */
.loading{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  z-index: 2500;
  background: radial-gradient(circle at 20% 10%, rgba(250,247,238,.92), rgba(250,247,238,.78));
  backdrop-filter: blur(6px);
}
.loading-card{
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(0,0,0,.10);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: var(--uiShadow);
  display:flex;
  align-items:center;
  gap: 12px;
}
.spinner{
  width: 18px; height: 18px;
  border-radius: 999px;
  border: 3px solid rgba(0,0,0,.12);
  border-top-color: rgba(0,0,0,.55);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text{ font-weight: 900; }

/* =========
   Modal
   ========= */
.modal-backdrop{
  position:fixed;
  inset:0;
  z-index: 3000;
  background: rgba(0,0,0,.35);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 18px;
}
.modal{
  width: min(680px, 94vw);
  max-height: min(74vh, 760px);
  overflow:auto;
  background: rgba(250,247,238,.95);
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.5);
  box-shadow: 0 22px 70px rgba(0,0,0,.35);
}
.modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 12px 14px;
  border-bottom: 1px dashed rgba(0,0,0,.15);
}
.modal-title{
  font-family: "Bangers", system-ui, sans-serif;
  font-size: 24px;
  letter-spacing: .4px;
}
.modal-body{ padding: 14px 16px 18px; }
.small-note{ opacity:.75; font-size: 12px; }

/* =========
   Marker (DivIcon)
   ========= */
.riot-marker{
  width: 34px; height: 34px;
  border-radius: 999px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 900;
  font-size: 14px;
  color: rgba(0,0,0,.88);
  text-shadow: 0 1px 0 rgba(255,255,255,.35);
  border: 3px solid rgba(0,0,0,.20);
  box-shadow: 0 10px 22px rgba(0,0,0,.18);
  transform: translateZ(0);
}
.riot-marker.selected{
  border-color: rgba(255,255,255,.92);
  box-shadow: 0 0 0 4px rgba(0,0,0,.20), 0 12px 24px rgba(0,0,0,.22);
}

/* Cluster tweaks (keep subtle) */
.marker-cluster{
  border-radius: 999px !important;
  box-shadow: 0 10px 22px rgba(0,0,0,.18);
}
.marker-cluster div{
  border-radius: 999px !important;
  font-weight: 900;
  font-family: "News Cycle", system-ui, sans-serif;
}

/* =========
   Popups (comic / tabloid)
   ========= */
.leaflet-popup{ margin-bottom: 26px; }
.leaflet-popup-content-wrapper{
  border-radius: 16px;
  border: none !important;
  box-shadow: none !important; /* we do our own via inner container */
  background: transparent !important;
}
.leaflet-popup-tip{
  border: none !important;
  background: transparent !important;
}

/* Inner popup "comic box" */
.comic-popup{
  border-radius: 16px;
  padding: 10px 12px 12px;
  position: relative;
  transform: rotate(-0.6deg); /* subtle ink-overrun vibe */
}

.comic-popup::before{
  content:"";
  position:absolute;
  inset: -3px;
  border-radius: 18px;
  background: rgba(255,255,255,.08);
  filter: blur(1px);
  pointer-events:none;
}

.comic-title{
  font-family: "Bangers", system-ui, sans-serif;
  font-size: 22px;
  letter-spacing: .4px;
  text-transform: uppercase;
  margin: 0 0 2px;
  color: rgba(0,0,0,.92);
}
.comic-time{
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 900;
  opacity: .82;
}
.comic-desc{
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.25;
  font-weight: 700;
}
.comic-source{
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  opacity: .72;
}

/* Added by Ian to include images */

/* --- Comic illustration panel in popup --- */
.comic-ill-wrap{
  margin: 0 0 10px 0;
}

.comic-ill{
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  box-shadow: 0 10px 22px rgba(0,0,0,0.18);
  outline: 2px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.08);
}

.comic-ill-caption{
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.2;
  opacity: 0.85;
  letter-spacing: 0.2px;
}
