/* Fill viewport */
html, body, #map { height: 100%; margin: 0; }

/* Root layout: side panel + map */
.app {
  height: 100vh; width: 100vw; overflow: hidden;
  display: grid; grid-template-columns: 320px 1fr; /* left panel + map */
}
@media (max-width: 900px){
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
}
aside.panel { overflow: auto; }
/* Map must fill its grid area */
#map, .leaflet-container { width: 100%; height: 100%; }

/* ── London Eye loading overlay (image-based) ───────────────────────────── */
#loadingOverlay{
  position: fixed; inset: 0;
  display: none; align-items: center; justify-content: center; flex-direction: column;
  background: #fff;
  z-index: 100000;
  font-family: system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  text-align: center;
}
body.is-loading #loadingOverlay{ display:flex; }

/* Keep map measurable during load (fix tiny top-left issue) */
body.is-loading #map{ visibility:hidden; }  /* not display:none */
body.is-loading .panel,
body.is-loading .badge{ display:none; }

/* Loader layout: square box that scales responsively */
.eye-loader{
  position: relative;
  width: clamp(140px, 22vmin, 260px);
  aspect-ratio: 1 / 1;
}
.eye-loader img{
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  user-select: none; -webkit-user-drag: none;
  image-rendering: auto;
}

/* Wheel rotates smoothly around its center */
.eye-wheel{
  transform-origin: 50% 50%;
  animation: eyeSpin 30s linear infinite;
  will-change: transform;
}
@keyframes eyeSpin { to { transform: rotate(360deg); } }

#loadingOverlay .msg{
  margin-top: 10px; color:#111; font-size:14px; letter-spacing:.2px;
}

/* ── Panel at TOP-RIGHT, translucent until hover ────────────────────────── */
.panel{
  position: fixed;
  top: 12px;
  right: 12px;
  left: auto;
  bottom: auto;

  width: 300px;
  max-width: calc(100% - 15px);

  /* no height collapsing — show full panel */
  max-height: none;
  overflow: visible;

  /* visuals */
  background: rgba(255,255,255, .55);
  border: 1px solid rgba(0,0,0, .12);
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,.10);
  backdrop-filter: saturate(1.05) blur(6px);

  /* fade in on hover/focus */
  opacity: .28;
  transition:
    opacity .75s ease,
    background-color .75s ease,
    border-color .75s ease,
    box-shadow .75s ease;

  padding: 12px 14px;
  font: 13px/1.4 system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
  color: #222;

  z-index: 9999;
  cursor: default;
}

/* Fully visible on hover or when any child receives focus (keyboard) */
.panel:hover,
.panel:focus-within{
  opacity: 1;
  background: rgba(255,255,255, .98);
  border-color: #ddd;
  box-shadow: 0 12px 28px rgba(0,0,0,.16);
}

/* Inner styles */
.panel h3{ margin:0 0 8px; font-size:15px; }

.row{
  display:grid;
  grid-template-columns: 120px minmax(0,1fr) 90px;
  gap:8px; align-items:center; margin:8px 0;
}

.row input[type="range"]{ width:100%; box-sizing:border-box; margin-right:4px; }

/* Number / select container */
.num{
  display:inline-flex; align-items:center; justify-content:flex-end;
  gap:6px;
  min-width:80px; padding:4px 8px; text-align:right;
  background:#f7f7f7; border:1px solid #e4e4e4; border-radius:6px;
  font-variant-numeric:tabular-nums;
}

/* Normalize controls for mobile alignment */
.panel select,
.panel input[type="checkbox"]{
  font: inherit;
  line-height: 1.2;
}

/* Dropdown styling (mobile-friendly height & box) */
.panel .num select{
  width: 100%;
  height: 32px;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
  background: #fff;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  box-sizing: border-box;
}

/* Checkbox + label alignment */
.panel label{
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Remove tiny Y nudge so checkbox aligns cleanly */
.row input[type="checkbox"]{
  justify-self:start;
  transform: none;
  margin: 0;
}

/* Legend */
.legend{ margin-top:8px; border-top:1px dashed #ddd; padding-top:8px; }
.legend-bar{
  height:10px; border-radius:6px; margin:6px 0; border:1px solid #ddd;
  background: linear-gradient(90deg, #44ce1b 0%, #f7e379 50%, #e51f1f 100%);
}
.legend-scale{ display:flex; justify-content:space-between; font-size:12px; color:#555; }

/* Data freshness hint */
.hint { opacity:.9; font-size:12px; margin-top:6px; }
.hint .ago { color:#666; margin-left:2px; }
.hint.fresh { color:#222; }
.hint.stale { color:#a66b00; }
.hint.very-stale { color:#353535; }

/* Badge bottom-right */
.badge{
  position:absolute; bottom:12px; right:12px; z-index:9999;
  background:rgba(0,0,0,.68); color:#fff; padding:6px 8px;
  border-radius:8px; font-size:12px;
}

/* Touch devices don’t have hover — make panel fully visible (desktop behavior overridden by .mobile-ui below) */
@media (hover: none){
  .panel{ opacity: 1; background: rgba(255,255,255, .98); }
}

/* Responsive stack (desktop default) */
@media (max-width: 420px){
  .panel{ width:auto; }
  .row{ grid-template-columns: 1fr; }
  .row label{ margin-bottom:4px; }
  .num{ justify-self:end; }
}

/* Mild tile sharpening/color on supported browsers */
.leaflet-layer.tiles-boost img{
  filter: contrast(1.06) brightness(1.06) saturate(2.04);
  image-rendering: -webkit-optimize-contrast;
  overflow: hidden;
}

/* ==== Hamburger button =================================================== */
#menuBtn{
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 10001; /* above .panel */
  width: 40px;
  height: 40px;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 10px;
  background: rgba(255,255,255,.95);
  box-shadow: 0 6px 18px rgba(0,0,0,.10);
  display: none;           /* enabled via .mobile-ui */
  align-items: center;
  justify-content: center;
  padding: 8px;
  cursor: pointer;
}

#menuBtn span{
  display: block;
  width: 100%;
  height: 2px;
  margin: 3px 0;
  background: #222;
  border-radius: 2px;
}

/* Enable hamburger in mobile UI */
body.mobile-ui #menuBtn{ display: inline-flex; }

/* ==== Mobile-specific panel behavior ==================================== */
/* On phones/tablets we open/close the panel instead of using translucency */
body.mobile-ui .panel{
  opacity: 1;
  background: rgba(255,255,255,.98);
}

/* Keep "Show hotspots" row tidy on phones */
body.mobile-ui .row{
  grid-template-columns: auto 1fr auto;
  align-items: center;
}

/* Hidden state when mobile menu is closed */
.panel.mobile-hidden{ display: none; }

/* ===== Date range controls (minimal) ==================================== */
#dateControls{
  display: grid;
  grid-template-columns: 1fr 1fr;     /* From | To */
  gap: 8px 12px;
  align-items: center;
}
#dateControls label{
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Minimal "chips" look for date inputs */
#dateControls input[type="text"],
#dateControls input[type="date"],
#dateControls input[type="datetime-local"]{
  width: 100%;
  height: 30px;
  padding: 2px 10px;
  border-radius: 14px;
  border: 1px solid #e2e2e2;
  background: #fff;
  box-sizing: border-box;
  font-size: 13px;
}

/* Muted state for disabled groups */
.muted{ opacity: .55; pointer-events: none; }

/* ===== Flatpickr minimalist overrides =================================== */
.flatpickr-calendar{
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  border: 1px solid #eaeaea;
  border-radius: 10px;
}
.flatpickr-months{
  align-items: center;
  padding: 4px 6px;
}
.flatpickr-current-month{
  display: flex;
  align-items: center;
  gap: 6px;
}
.flatpickr-current-month .numInputWrapper{
  display: none;  /* hide native numeric year input (we replace it) */
}

/* Month dropdown (built-in via monthSelectorType:'dropdown') */
.flatpickr-monthDropdown-months{
  border: 1px solid #e1e1e1;
  border-radius: 12px;
  padding: 2px 10px;
  height: 28px;
  font-size: 13px;
  background: #fff;
}

/* Year dropdown (our custom select) */
.fp-year-select{
  border: 1px solid #e1e1e1;
  border-radius: 12px;
  padding: 2px 10px;
  height: 28px;
  font-size: 13px;
  background: #fff;
  margin-left: 6px;
}

/* Reduce arrow button dominance */
.flatpickr-prev-month, .flatpickr-next-month{
  opacity: .6;
}
.flatpickr-prev-month:hover, .flatpickr-next-month:hover{
  opacity: 1;
}
