@font-face {
  font-family: "Beausite Classic";
  src: url("./fonts/BeausiteClassicWeb-Regular.woff2") format("woff2"),
       url("./fonts/BeausiteClassicWeb-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Beausite Classic";
  src: url("./fonts/BeausiteClassicWeb-RegularItalic.woff2") format("woff2"),
       url("./fonts/BeausiteClassicWeb-RegularItalic.woff") format("woff");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Beausite Classic";
  src: url("./fonts/BeausiteClassicWeb-Medium.woff2") format("woff2"),
       url("./fonts/BeausiteClassicWeb-Medium.woff") format("woff");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Beausite Classic";
  src: url("./fonts/BeausiteClassicWeb-Semibold.woff2") format("woff2"),
       url("./fonts/BeausiteClassicWeb-Semibold.woff") format("woff");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Beausite Classic";
  src: url("./fonts/BeausiteClassicWeb-Bold.woff2") format("woff2"),
       url("./fonts/BeausiteClassicWeb-Bold.woff") format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Beausite Classic", system-ui, -apple-system, sans-serif;
}

#container { position: relative; width: 100%; height: 100%; }
#map { position: absolute; inset: 0; }
#deck-canvas { position: absolute; inset: 0; pointer-events: auto; touch-action: none; }

#left-panel {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#controls {
  background: rgba(255,255,255,0.95);
  color: #333;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

#controls label { margin-right: 8px; cursor: pointer; }
#controls input { margin-right: 4px; }
#controls input:disabled { opacity: 0.5; cursor: not-allowed; }
#controls label:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }

.metric-panel-label {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(0,0,0,0.4);
  padding: 6px 10px 2px;
}

#metric-icons {
  background: rgba(255,255,255,0.95);
  border-radius: 8px;
  padding: 0 6px 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-self: flex-start;
}

.metric-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 9px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 7px 10px;
  border-radius: 6px;
  color: rgba(0,0,0,0.35);
  transition: color 0.15s, background 0.15s;
  font-family: inherit;
  text-align: left;
}

.metric-btn:hover:not(:disabled) {
  color: rgba(0,0,0,0.75);
  background: rgba(0,0,0,0.05);
}

.metric-btn.active {
  color: #1565c0;
  background: rgba(30,136,229,0.12);
}

.metric-btn:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

.metric-icon {
  width: 36px;
  height: 36px;
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  background-color: currentColor;
  flex-shrink: 0;
}

.metric-btn span {
  font-size: 11px;
  line-height: 1.3;
  text-align: left;
  letter-spacing: 0.01em;
}

#map-tooltip {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  display: none;
  background: #1d2935;
  color: #eef3f7;
  border-radius: 8px;
  font: 11.5px/1.45 system-ui,-apple-system,sans-serif;
  max-width: 280px;
  padding: 8px 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
  white-space: pre-wrap;
}

.legend{
  position:absolute;
  left:12px;
  bottom:12px;
  z-index:10;
  background:rgba(255,255,255,0.95);
  color:#333;
  font:12px/1.2 sans-serif;
  padding:10px 10px 8px;
  border-radius:8px;
  max-width:260px;
  box-shadow:0 2px 8px rgba(0,0,0,0.2);
}

.legend .title{font-weight:600; margin-bottom:8px; display:flex; justify-content:space-between; align-items:center;}
.legend .row{display:flex; align-items:center; margin:4px 0;}
.legend .swatch{width:14px; height:14px; border-radius:3px; margin-right:8px; flex:0 0 auto; border:1px solid rgba(0,0,0,0.3);}
.legend input{width:72px; margin:0 6px; background:#f0f0f0; color:#333; border:1px solid #ccc; border-radius:4px; padding:2px 4px;}
.legend button:not(.legend-toggle){margin-top:8px; width:100%; padding:6px 8px; border:0; border-radius:6px; cursor:pointer; background:#1e88e5; color:#fff; font-size:14px; font-family:"Beausite Classic",system-ui,sans-serif; font-weight:500; transition:background 0.15s;}
.legend button:not(.legend-toggle):hover{background:#1565c0;}
.legend-toggle{background:none; border:none; color:#333; cursor:pointer; font-size:13px; padding:0 0 0 8px; line-height:1; opacity:0.5; flex:0 0 auto;}
.legend-toggle:hover{opacity:1;}
.legend .recent-since{font-size:10px; opacity:0.6; margin:-4px 0 6px; font-style:italic;}
.legend.collapsed .legend-body{display:none;}
.legend.collapsed{padding-bottom:10px;}

#trend-panel {
  display: none;
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 580px;
  max-width: calc(100vw - 40px);
  background: #fff;
  color: #333;
  border-radius: 10px 10px 0 0;
  padding: 14px 16px 12px;
  z-index: 100;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.3);
}

#trend-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

#trend-panel-title {
  font-weight: 600;
  font-size: 13px;
  flex: 1;
}

#trend-panel-filters {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: #555;
  align-items: center;
}

#trend-panel-filters label { display: flex; align-items: center; gap: 4px; }

#trend-panel-filters input {
  font-size: 11px;
  padding: 2px 4px;
  border: 1px solid #bbb;
  border-radius: 4px;
  background: #f5f5f5;
  color: #333;
}

#trend-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: #888;
  padding: 0;
  line-height: 1;
}

#trend-close:hover { color: #333; }

#trend-legend {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: #555;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
#trend-legend span { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
#trend-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
#trend-canvas-wrap { height: 220px; }
#trend-canvas { width: 100% !important; height: 220px !important; }

#discharge-strip { display: none; margin-top: 2px; }
#discharge-canvas { width: 100% !important; height: 42px !important; display: block; }

@media (max-width: 480px) {
  #trend-panel { width: 100%; border-radius: 8px 8px 0 0; }
  #trend-panel-filters { display: none; }
}

@media (max-width: 640px) {
  /* Collapse to active-only; tap to expand */
  #metric-icons:not(.expanded) .metric-btn:not(.active) {
    display: none;
  }
  /* Chevron hint when collapsed */
  #metric-icons:not(.expanded) .metric-btn.active::after {
    content: " ▾";
    font-size: 10px;
    opacity: 0.55;
  }
}

@media (max-width: 480px) {
  .legend { max-width: calc(100vw - 24px); font-size: 11px; }
  #controls { font-size: 12px; }
  .metric-btn { padding: 6px 8px; }
  .metric-btn span { font-size: 10px; }
}

/* ── Welcome / onboarding modal ─────────────────────────────── */
#welcome-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.65);
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

#welcome-card {
  background: #fff;
  border-radius: 12px;
  padding: 48px 28px 20px;
  max-width: 500px;
  width: 100%;
  position: relative;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

#welcome-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 18px;
  color: #aaa;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
#welcome-close:hover { color: #333; }

#welcome-slides {
  display: grid;
}
/* All slides occupy the same grid cell; inactive ones are invisible but still contribute height */
.welcome-slide {
  grid-area: 1 / 1;
  visibility: hidden;
  pointer-events: none;
}
.welcome-slide.active {
  visibility: visible;
  pointer-events: auto;
}

.welcome-screenshot {
  width: 100%;
  display: block;
  border-radius: 8px;
  margin-bottom: 10px;
  border: 1px solid rgba(0,0,0,0.08);
}

.welcome-map-legend {
  display: flex;
  gap: 10px 16px;
  flex-wrap: wrap;
  font-size: 11px;
  color: #555;
  margin-bottom: 12px;
  align-items: center;
}
.welcome-map-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.welcome-map-legend--cso {
  margin-top: 4px;
  margin-bottom: 4px;
}
.welcome-map-legend-section {
  color: #777;
  font-style: italic;
}
.wml-hex {
  width: 12px;
  height: 13.86px;
  flex-shrink: 0;
  display: block;
}
.wml-catch {
  width: 13px;
  height: 10px;
  background: rgba(30,136,229,0.12);
  border: 1.5px solid rgba(30,136,229,0.7);
  flex-shrink: 0;
}
.wml-river {
  width: 16px;
  height: 3px;
  background: rgba(10,100,210,0.86);
  flex-shrink: 0;
}
.wml-cso {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(160,110,60,0.65);
  border: 1.5px solid rgba(160,90,30,0.7);
  flex-shrink: 0;
}
.wml-cso--discharging {
  background: rgba(210,30,30,0.9);
  border-color: rgba(255,255,255,0.8);
  animation: wml-pulse 1.9s ease-in-out infinite;
}
.wml-cso--recent {
  background: rgba(255,140,0,0.85);
  border-color: rgba(160,90,30,0.8);
}
@keyframes wml-pulse {
  0%, 100% { opacity: 0.65; transform: scale(0.85); }
  50%       { opacity: 1;    transform: scale(1.15); }
}
.wml-rain {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(30,100,200,0.86);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(30,100,200,0.4);
  flex-shrink: 0;
}

#welcome-card h2 {
  font-size: 18px;
  font-weight: 600;
  color: #222;
  margin: 0 0 8px;
  font-family: "Beausite Classic", system-ui, sans-serif;
}

#welcome-card p {
  font-size: 14px;
  color: #555;
  margin: 0 0 12px;
  line-height: 1.55;
}

#welcome-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #eee;
}

.welcome-dots { display: flex; gap: 6px; align-items: center; }
.welcome-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ddd;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background 0.2s;
}
.welcome-dots .dot.active { background: #1e88e5; }

.welcome-btns {
  display: flex;
  gap: 8px;
}
.welcome-btns button {
  background: #1e88e5;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 22px;
  font-size: 14px;
  font-family: "Beausite Classic", system-ui, sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.welcome-btns button:hover { background: #1565c0; }
#welcome-back {
  background: #f0f0f0;
  color: #555;
}
#welcome-back:hover { background: #e0e0e0; }

@media (max-width: 480px) {
  #welcome-card { padding: 20px 16px 16px; border-radius: 10px 10px 0 0; }
  #welcome-card h2 { font-size: 16px; }
  #welcome-modal { align-items: flex-end; padding: 0; }
}