:root {
  --bg: #041824;
  --panel: rgba(7, 31, 53, 0.92);
  --panel-soft: rgba(10, 43, 73, 0.82);
  --panel-border: rgba(157, 225, 255, 0.18);
  --text: #eff9ff;
  --muted: #9fc0d4;
  --accent: #72e6ff;
  --accent-strong: #ff7b00;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
  
}

body {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 1.4s ease-out, transform 1.4s ease-out;
}

body.loaded {
  opacity: 1;
  transform: translateY(0);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(114, 230, 255, 0.15), transparent 30%),
    radial-gradient(circle at bottom right, rgba(255, 123, 0, 0.12), transparent 28%),
    linear-gradient(180deg, #03101a 0%, #08263c 100%);
  color: var(--text);
  overflow-x: hidden;
  cursor: url("./custom-cursor.png") 16 16, auto;
}
.panel-card:hover{
  cursor: url("./custom-cursor.png") 16 16, auto;
}


/* ─── ANIMATED BACKGROUND CANVAS ─── */
#bgCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
}

/* ─── SCANLINE OVERLAY ─── */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.04) 2px,
    rgba(0, 0, 0, 0.04) 4px
  );
  pointer-events: none;
  z-index: 1;
}

.page-shell {
  position: relative;
  z-index: 2;
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 40px;
}

/* ─── HERO ─── */
.hero {
  margin-bottom: 28px;
  position: relative;
  padding: 0;
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  background: rgba(7, 31, 53, 0.72);
}

/* Decorative sonar ring behind the title */
.hero::before {
  content: "";
  position: absolute;
  top: -60px;
  right: -80px;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  border: 1px solid rgba(114, 230, 255, 0.07);
  box-shadow:
    0 0 0 30px rgba(114, 230, 255, 0.04),
    0 0 0 70px rgba(114, 230, 255, 0.025),
    0 0 0 130px rgba(114, 230, 255, 0.012);
  pointer-events: none;
  animation: sonarPulse 6s ease-in-out infinite;
}

@keyframes sonarPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.04); opacity: 0.6; }
}

.eyebrow,
.panel-label,
.metric-label,
.report-stats dt {
  font-family: "IBM Plex Mono", monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow,
.panel-label {
  color: var(--accent);
  font-size: 0.78rem;
}

/* Eyebrow with blinking cursor */
.eyebrow::after {
  content: "_";
  animation: blink 1.1s step-end infinite;
  color: var(--accent);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.hero h1 {
  margin: 10px 0 12px;
  font-size: clamp(2.3rem, 5vw, 4.6rem);
  line-height: 0.95;
  background: linear-gradient(135deg, #eff9ff 0%, #72e6ff 50%, #2fb4d6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 30px rgba(114, 230, 255, 0.25));
}

.hero-copy {
  width: min(820px, 100%);
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--muted);
}

/* ─── CONCENTRATION LEGEND BAR ─── */
.concentration-legend {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 20px 0 28px;
  height: 6px;
  border-radius: 999px;
  overflow: visible;
  position: relative;
  width: min(520px, 100%);
}

.concentration-legend-track {
  display: flex;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: 0 0 14px rgba(114, 230, 255, 0.2);
}

.concentration-legend-track span {
  flex: 1;
  transition: flex 0.3s ease;
}

.concentration-legend-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  width: min(520px, 100%);
}

/* ─── HERO IMAGE SECTION ─── */
.hero {
  display: flex;
  flex-direction: column;
}

.hero-content {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 24px 28px 22px;
  display: block;
  background: linear-gradient(180deg, rgba(5, 22, 34, 0.34) 0%, rgba(5, 22, 34, 0.74) 100%);
  backdrop-filter: blur(10px);
}

.hero-image-container {
  width: 100%;
  overflow: hidden;
  background: rgba(4, 24, 36, 0.12);
}

.hero-image {
  display: block;
  width: 100%;
  height: auto;
}

.footer-banner {
  width: 100%;
  overflow: hidden;
  margin-top: 32px;
}

.footer-banner-image {
  display: block;
  width: 100%;
  height: auto;
}

/* ─── WORKSPACE ─── */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(340px, 1fr);
  gap: 24px;
  align-items: start;
}

.map-panel,
.panel-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.map-panel {
  padding: 20px;
  position: relative;
}

/* Corner decorations on map panel */
.map-panel::before,
.map-panel::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--accent);
  border-style: solid;
  opacity: 0.4;
}
.map-panel::before {
  top: 12px;
  left: 12px;
  border-width: 2px 0 0 2px;
  border-radius: 4px 0 0 0;
}
.map-panel::after {
  bottom: 12px;
  right: 12px;
  border-width: 0 2px 2px 0;
  border-radius: 0 0 4px 0;
}

.panel-card {
  padding: 20px;
}

.panel-card--muted {
  background: var(--panel-soft);
}

/* ─── PANEL HEADER ─── */
.panel-header,
.legend,
.coordinate-grid,
.report-stats,
.map-footnote {
  display: flex;
}

.panel-header {
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-header h2,
.info-panel h3 {
  margin: 6px 0 0;
}

.legend {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 14px;
  font-size: 0.88rem;
  color: var(--muted);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  display: inline-block;
}

.legend-swatch--sample {
  background: var(--accent-strong);
  box-shadow: 0 0 8px var(--accent-strong);
}

.legend-swatch--click {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* ─── MAP FRAME ─── */
.map-frame {
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
}

/* Subtle vignette over map edges */
.map-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(4, 24, 36, 0.55) 100%);
  pointer-events: none;
  z-index: 400;
}

#mapStage {
  width: 100%;
  height: min(74vh, 780px);
  min-height: 520px;
  background: #d7edf5;
}

/* ─── MAP FOOTNOTE ─── */
.map-footnote {
  justify-content: space-between;
  gap: 20px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.map-footnote p {
  margin: 0;
  max-width: 46ch;
  line-height: 1.55;
}

/* Glowing count badge */
#datasetCount {
  color: var(--accent);
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.1em;
  filter: drop-shadow(0 0 6px rgba(114, 230, 255, 0.6));
}

/* ─── INFO PANEL ─── */
.info-panel {
  display: grid;
  gap: 18px;
}

.widget-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.widget-row--below-map {
  margin-top: 24px;
  width: 100%;
}

/* Flicker animation on update */
@keyframes flickerIn {
  0%   { opacity: 0.2; }
  15%  { opacity: 0.9; }
  30%  { opacity: 0.4; }
  50%  { opacity: 1; }
  70%  { opacity: 0.7; }
  85%  { opacity: 1; }
  100% { opacity: 1; }
}

.flicker-update {
  animation: flickerIn 0.5s ease forwards;
}

/* ─── COORDINATE GRID ─── */
.coordinate-grid,
.report-stats {
  gap: 16px;
  flex-wrap: wrap;
}

.coordinate-grid {
  margin-top: 12px;
}

.coordinate-grid > div,
.report-stats > div {
  min-width: 120px;
  flex: 1 1 140px;
}

.metric-label,
.report-stats dt {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.coordinate-grid strong,
.report-stats dd {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.45;
}

/* ─── CONCENTRATION CLASS BADGE ─── */
#classTextValue {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 600;
  transition: background 0.4s, color 0.4s, box-shadow 0.4s;
}

#classTextValue[data-class="Very High"] {
  background: rgba(142, 43, 43, 0.3);
  color: #ff6b6b;
  box-shadow: 0 0 12px rgba(214, 40, 40, 0.4);
}
#classTextValue[data-class="High"] {
  background: rgba(247, 127, 0, 0.2);
  color: #f77f00;
  box-shadow: 0 0 10px rgba(247, 127, 0, 0.35);
}
#classTextValue[data-class="Medium"] {
  background: rgba(255, 209, 102, 0.15);
  color: #ffd166;
  box-shadow: 0 0 8px rgba(255, 209, 102, 0.25);
}
#classTextValue[data-class="Low"] {
  background: rgba(128, 237, 153, 0.12);
  color: #80ed99;
}
#classTextValue[data-class="Very Low"] {
  background: rgba(91, 192, 235, 0.12);
  color: #5bc0eb;
}

/* ─── STATS CHART ─── */
.stats-chart-wrapper {
  position: relative;
  height: 150px;
  margin-top: 16px;
}

/* ─── REPORT SUMMARY & LISTS ─── */
.report-summary {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.stack-list {
  margin: 12px 0 0;
  padding-left: 18px;
  list-style: disc;
  display: grid;
  gap: 10px;
  color: var(--muted);
  line-height: 1.55;
}

/* ─── CHAT FORM ─── */
.chat-form {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.chat-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 110px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(157, 225, 255, 0.2);
  background: rgba(4, 24, 36, 0.65);
  color: var(--text);
  font: inherit;
  transition: border-color 0.2s;
}

.chat-form textarea:focus {
  outline: none;
  border-color: rgba(114, 230, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(114, 230, 255, 0.08);
}

.chat-form select {
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(157, 225, 255, 0.2);
  background: rgba(4, 24, 36, 0.65);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.chat-form button {
  justify-self: start;
  border: 0;
  border-radius: 999px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #72e6ff 0%, #2fb4d6 100%);
  color: #052032;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 18px rgba(114, 230, 255, 0.3);
}

.chat-form button::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.25) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.2s;
}

.chat-form button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(114, 230, 255, 0.45);
}

.chat-form button:hover::after {
  opacity: 1;
}

.chat-form button:active {
  transform: translateY(0);
}

.chat-form button:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.chat-answer {
  margin-top: 12px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(4, 24, 36, 0.55);
  border: 1px solid rgba(157, 225, 255, 0.12);
  color: var(--text);
  line-height: 1.65;
  white-space: pre-wrap;
}

/* ─── PREDICTION FORM ─── */
.prediction-form {
  margin-top: 16px;
}

/* ─── DEPTH DIVIDER ─── */
.depth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 10px;
  opacity: 0.4;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.depth-divider::before,
.depth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

/* ─── LEAFLET OVERRIDES ─── */
.leaflet-container {
  font: inherit;
  cursor: url("./custom-cursor.png") 16 16, auto !important;

}

.leaflet-control-attribution {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  background: rgba(4, 24, 36, 0.7) !important;
  color: var(--muted) !important;
}

.leaflet-control-zoom a {
  background: rgba(7, 31, 53, 0.9) !important;
  color: var(--accent) !important;
  border-color: rgba(114, 230, 255, 0.2) !important;
}

.leaflet-popup-content-wrapper {
  background: rgba(7, 31, 53, 0.95) !important;
  color: var(--text) !important;
  border: 1px solid rgba(114, 230, 255, 0.2) !important;
  border-radius: 14px !important;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4) !important;
}

.leaflet-popup-tip {
  background: rgba(7, 31, 53, 0.95) !important;
}

.continent-label-marker {
  background: transparent;
  border: 0;
}

.continent-label {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(4, 24, 36, 0.58);
  border: 1px solid rgba(157, 225, 255, 0.18);
  color: rgba(239, 249, 255, 0.88);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
}

/* ─── RESPONSIVE ─── */
@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .map-footnote {
    flex-direction: column;
  }

  .widget-row {
    grid-template-columns: 1fr;
  }

  .widget-row--below-map {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 20px;
  }
  .map-panel,
  .panel-card {
    border-radius: 18px;
  }
  .map-panel {
    padding: 14px;
  }
  .panel-header {
    flex-direction: column;
  }
  #mapStage {
    min-height: 420px;
  }
  .hero {
    padding: 0;
  }
  .hero-content {
    padding: 18px 16px 14px;
  }

  .hero-image-container {
    width: 100%;
  }
}
