/* GeoHydroWatch - dark "deep space" theme, sized for screen recording */

@font-face { font-family: "Barlow Condensed"; font-weight: 500; src: url(fonts/barlow-condensed-500.woff2) format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; src: url(fonts/barlow-condensed-700.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 400; src: url(fonts/barlow-400.woff2) format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; src: url(fonts/barlow-600.woff2) format("woff2"); }

:root {
  --bg: #030409;
  --text: #f0f0fa;
  --muted: #9aa0b4;
  --line: rgba(240, 240, 250, 0.18);
  --panel: rgba(12, 14, 24, 0.72);
  --accent: #4fc3ff;
  --green: #2ecc71;
  --amber: #ffb020;
  --red: #ff3b30;
  --head: "Barlow Condensed", "Nirmala UI", "Arial Narrow", sans-serif;
  --body: "Barlow", "Nirmala UI", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 19px/1.5 var(--body);
  overflow-x: hidden;
}
/* Malayalam script needs a font that has its letters */
html[lang="ml"] body { --head: "Nirmala UI", "Barlow Condensed", sans-serif; }

#stars { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

h1, h2, h3 { font-family: var(--head); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; margin: 0; }
h2 { font-size: 34px; margin-bottom: 16px; }
h3 { font-size: 22px; color: var(--muted); font-weight: 500; letter-spacing: 0.08em; margin-bottom: 10px; }

/* ---------- SAMPLE banner ---------- */
#sample-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
  background: #d10000; color: #fff; text-align: center;
  font: 700 54px/1.3 var(--head); letter-spacing: 0.06em; padding: 10px;
  box-shadow: 0 0 40px #f00;
}
#sample-banner[hidden] { display: none; }

/* ---------- HERO ---------- */
.hero {
  position: relative; min-height: 78vh;
  display: flex; align-items: center;
  padding: 40px 5vw;
}
main { position: relative; z-index: 1; }
.hero-text { position: relative; z-index: 2; max-width: 980px; width: 100%; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.eyebrow { font: 500 18px var(--head); letter-spacing: 0.3em; text-transform: uppercase; color: var(--accent); }
h1 {
  font-size: clamp(64px, 9vw, 150px); line-height: 0.92;
  letter-spacing: 0.02em; text-shadow: 0 0 40px rgba(79, 195, 255, 0.25);
}
.tagline { font: 500 clamp(24px, 2.4vw, 38px) var(--head); text-transform: uppercase; letter-spacing: 0.12em; margin: 10px 0 34px; color: #d7dcf0; }

/* glowing planet on the right, drawn with CSS only */
.planet {
  position: absolute; right: -6vw; top: 50%; transform: translateY(-50%);
  width: min(54vw, 74vh); height: min(54vw, 74vh); border-radius: 50%;
  background:
    radial-gradient(circle at 30% 35%, rgba(120, 200, 255, 0.55), transparent 45%),
    radial-gradient(circle at 40% 45%, #1b5e8c 0%, #0b2f4f 40%, #04101e 68%, #010308 80%);
  box-shadow: -10px 0 60px rgba(79, 195, 255, 0.35), inset -90px -20px 140px rgba(0, 0, 0, 0.9);
  opacity: 0.85; animation: drift 60s ease-in-out infinite alternate;
}
.planet::after { /* atmosphere rim */
  content: ""; position: absolute; inset: -2px; border-radius: 50%;
  box-shadow: inset 8px 0 18px rgba(140, 215, 255, 0.55);
}
@keyframes drift { to { transform: translateY(-52%) rotate(8deg); } }

.lang button {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  font: 600 16px var(--body); padding: 6px 14px; cursor: pointer;
}
.lang button.active { color: var(--bg); background: var(--text); }

/* ---------- inputs ---------- */
.controls { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.controls label { display: flex; flex-direction: column; font: 500 15px var(--head); letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); }
.controls input[type=number] {
  width: 170px; margin-top: 6px; padding: 12px 14px;
  background: rgba(0, 0, 0, 0.55); color: var(--text);
  border: 1px solid var(--line); font: 600 24px var(--body);
}
.controls #radius { width: 110px; }
.controls input:focus { outline: none; border-color: var(--accent); }
.btn-primary {
  padding: 14px 30px; background: rgba(0, 0, 0, 0.4); color: var(--text);
  border: 1px solid var(--text); font: 700 24px var(--head); letter-spacing: 0.18em; text-transform: uppercase;
  cursor: pointer; transition: background 0.25s, color 0.25s;
}
.btn-primary:hover:not(:disabled) { background: var(--text); color: var(--bg); }
.btn-primary:disabled { opacity: 0.5; cursor: wait; }
.btn-primary .arrow { display: inline-block; transition: transform 0.25s; }
.btn-primary:hover .arrow { transform: translateX(6px); }
.options { display: flex; gap: 22px; width: 100%; }
label.check { flex-direction: row !important; align-items: center; gap: 8px; cursor: pointer; font: 400 17px var(--body) !important; letter-spacing: 0 !important; text-transform: none !important; color: var(--text) !important; }
label.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- progress ---------- */
.progress { display: flex; gap: 0; list-style: none; padding: 0; margin: 28px 0 0; max-width: 900px; }
.progress[hidden] { display: none; }
.progress li {
  flex: 1; padding: 12px 8px 0; border-top: 4px solid var(--line);
  font: 500 18px var(--head); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
  transition: border-color 0.4s, color 0.4s;
}
.progress li.active { border-color: var(--accent); color: var(--text); animation: pulse 1s infinite alternate; }
.progress li.done { border-color: var(--accent); color: var(--accent); }
@keyframes pulse { to { border-color: rgba(79, 195, 255, 0.35); } }

.error { margin-top: 22px; padding: 16px 20px; border: 1px solid var(--red); background: rgba(255, 59, 48, 0.12); color: #ffb3ad; font-size: 20px; max-width: 900px; }
.error[hidden] { display: none; }

/* ---------- results ---------- */
main { padding: 0 5vw; }
section { margin-bottom: 48px; }
#results[hidden] { display: none; }
.results-head { display: flex; align-items: center; gap: 24px; margin-bottom: 18px; }
.results-head h2 { margin: 0; }

.badge { font: 700 20px var(--head); letter-spacing: 0.12em; text-transform: uppercase; padding: 8px 16px; border: 1px solid; }
.badge.live { color: #6dff9d; border-color: #6dff9d; background: rgba(46, 204, 113, 0.12); }
.badge.live::before { content: "\25CF  "; animation: blink 1.4s infinite; }
.badge.cached { color: var(--amber); border-color: var(--amber); background: rgba(255, 176, 32, 0.12); }
.badge.sample { color: #fff; border-color: #f00; background: #d10000; }
@keyframes blink { 50% { opacity: 0.2; } }

.panel { background: var(--panel); border: 1px solid var(--line); padding: 22px; backdrop-filter: blur(6px); }
.grid-top { display: grid; grid-template-columns: 2.2fr 1fr; gap: 22px; margin-bottom: 22px; }
.grid-charts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.grid-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }

/* map */
.map-panel { position: relative; padding: 0; }
#map { height: 62vh; min-height: 460px; background: #000; }
.osm-dark { filter: invert(1) hue-rotate(180deg) brightness(0.75) saturate(0.6); }
.map-overlay {
  position: absolute; top: 16px; left: 60px; z-index: 500; pointer-events: none;
  text-shadow: 0 2px 14px #000, 0 0 4px #000;
}
.ov-year { font: 700 96px/0.9 var(--head); }
.ov-water { font: 700 44px var(--head); color: var(--accent); }
.ov-water small { font-size: 24px; color: var(--text); }
.ov-note { font-size: 18px; color: var(--amber); max-width: 420px; }
.change-legend { position: absolute; top: 16px; right: 16px; z-index: 500; background: rgba(0, 0, 0, 0.75); padding: 10px 14px; display: flex; flex-direction: column; gap: 4px; font-size: 18px; }
.change-legend[hidden] { display: none; }
.change-legend i { display: inline-block; width: 16px; height: 16px; margin-right: 8px; vertical-align: -2px; }
.map-controls { display: flex; align-items: center; gap: 20px; padding: 14px 18px; border-top: 1px solid var(--line); }
#year-slider { flex: 1; accent-color: var(--accent); height: 28px; }
.btn-small { background: transparent; color: var(--text); border: 1px solid var(--text); font: 700 20px var(--head); letter-spacing: 0.12em; text-transform: uppercase; padding: 8px 18px; cursor: pointer; min-width: 120px; }
.btn-small:hover { background: var(--text); color: var(--bg); }
.small-warn { padding: 8px 18px; color: var(--amber); font-size: 16px; }
.small-warn[hidden] { display: none; }

/* status card */
.status-panel { display: flex; flex-direction: column; }
.status-word { font: 700 104px/1 var(--head); letter-spacing: 0.04em; margin: 10px 0; }
.status-word.GREEN { color: var(--green); text-shadow: 0 0 30px rgba(46, 204, 113, 0.5); }
.status-word.AMBER { color: var(--amber); text-shadow: 0 0 30px rgba(255, 176, 32, 0.5); }
.status-word.RED { color: var(--red); text-shadow: 0 0 30px rgba(255, 59, 48, 0.5); }
.status-detail { font: 600 28px var(--body); }
.status-year { color: var(--muted); margin-top: 6px; }
.status-year b { color: var(--text); }
.illustrative { font-size: 15px; color: var(--muted); font-style: italic; margin: 18px 0 8px; }
.legend-mini { display: flex; flex-wrap: wrap; gap: 6px 12px; font: 600 15px var(--body); }
.legend-mini .g { color: var(--green); } .legend-mini .a { color: var(--amber); } .legend-mini .r { color: var(--red); }
.legend-mini em { color: var(--muted); font-weight: 400; }
.meta { margin-top: auto; padding-top: 18px; font-size: 15px; color: var(--muted); line-height: 1.6; }

.caption { font-size: 14px; color: var(--muted); margin: 8px 0 0; }
.year-notes { margin-top: 14px; color: var(--amber); font-size: 17px; }

/* how it works */
.pipeline { display: flex; align-items: stretch; gap: 12px; }
.pipeline > div { flex: 1; border: 1px solid var(--line); background: var(--panel); padding: 18px; }
.pipeline b { display: block; font: 700 26px var(--head); text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
.pipeline small { font-size: 16px; color: var(--muted); }
.pipeline > span { align-self: center; font-size: 32px; color: var(--accent); }

/* SDGs */
.sdg { display: flex; gap: 16px; align-items: center; margin-bottom: 14px; }
.sdg-num { flex: none; width: 64px; height: 64px; display: grid; place-items: center; font: 700 36px var(--head); color: #fff; }
.sdg b { font: 700 22px var(--head); text-transform: uppercase; letter-spacing: 0.06em; }
.sdg p { margin: 2px 0 0; font-size: 17px; color: #cfd3e3; }

/* limits */
.limits { border-color: rgba(255, 176, 32, 0.45); }
.limits ul { margin: 0; padding-left: 22px; }
.limits li { margin-bottom: 10px; font-size: 19px; }

footer { padding: 26px 5vw 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 16px; }
.footer-sub { display: block; font-size: 13px; margin-top: 4px; }

/* leaflet tweaks for the dark theme */
.leaflet-container { font: 14px var(--body); }
.leaflet-control-attribution { background: rgba(0, 0, 0, 0.7) !important; color: #bbb !important; }
.leaflet-control-attribution a { color: var(--accent) !important; }

@media (max-width: 1100px) {
  .grid-top, .grid-charts, .grid-bottom { grid-template-columns: 1fr; }
  .pipeline { flex-direction: column; }
  .pipeline > span { transform: rotate(90deg); }
  .planet { opacity: 0.35; }
}
@media (prefers-reduced-motion: reduce) { .planet { animation: none; } }

/* before the first analysis: show just the map (for map-click) and a hint */
#results.nodata .needs-data { display: none !important; }
#results:not(.nodata) .only-nodata { display: none; }
#results.nodata .grid-top { grid-template-columns: 1fr; }
#results.nodata #map { height: 50vh; }
.hint { position: absolute; top: 16px; left: 60px; right: 16px; z-index: 500; pointer-events: none;
  font: 500 24px var(--head); letter-spacing: 0.08em; text-transform: uppercase; text-shadow: 0 2px 10px #000; }
