/* =============================================================================
   Particle Analysis Dashboard — static site theme
   Mirrors the THEMES dict of streamlit_beaching_dashboard.py (dark default).
   ============================================================================= */

:root, [data-theme="dark"] {
  --bg: #0e1b22; --surface: #16252e; --input-bg: #1b2c36;
  --text: #e6eef2; --muted: #9fb3bd; --border: #273a45;
  --heading: #7fd1e0; --primary: #2a93a8; --primary-hover: #37a9bf;
  --primary-text: #06141a; --shadow: rgba(0, 0, 0, 0.45);
  --plot-face: #16252e; --plot-text: #e6eef2; --plot-grid: #3a4f5a;
}
[data-theme="light"] {
  --bg: #ffffff; --surface: #ffffff; --input-bg: #f3f6f8;
  --text: #1a2b34; --muted: #5a727d; --border: #e3eaee;
  --heading: #0f3d4d; --primary: #1f6f8b; --primary-hover: #155366;
  --primary-text: #ffffff; --shadow: rgba(15, 61, 77, 0.08);
  --plot-face: #ffffff; --plot-text: #1a2b34; --plot-grid: #cdd8de;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px; line-height: 1.55;
}
.container { max-width: 1240px; margin: 0 auto; padding: 1.2rem 1.4rem 3rem; }

h1, h2, h3 {
  font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  letter-spacing: -0.01em; color: var(--heading);
}
h2 { font-size: 1.45rem; margin: 1.4rem 0 0.3rem; }
a { color: var(--primary); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); font-size: 0.92rem; margin-top: 0.2rem; }
.small { font-size: 0.8rem; }
.hidden { display: none !important; }
hr { border: none; border-top: 1px solid var(--border); }

/* ---------- header row ---------- */
.header-row {
  display: flex; justify-content: space-between; align-items: center;
  min-height: 54px; gap: 20px; flex-wrap: wrap;
}
.logos { display: flex; align-items: center; gap: 26px; }
.logos img { display: block; width: auto; }

.theme-toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.theme-toggle input { display: none; }
.theme-toggle .switch {
  width: 40px; height: 22px; border-radius: 11px; background: var(--input-bg);
  border: 1px solid var(--border); position: relative; transition: background .15s;
}
.theme-toggle .switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--muted); transition: left .15s, background .15s;
}
.theme-toggle input:checked + .switch { background: var(--primary); }
.theme-toggle input:checked + .switch::after { left: 20px; background: var(--primary-text); }
.toggle-label { color: var(--muted); font-weight: 500; font-size: 0.92rem; }

/* ---------- hero ---------- */
.hero {
  background: linear-gradient(135deg, #0f3d4d 0%, #1f6f8b 55%, #2a93a8 100%);
  border-radius: 16px; padding: 2.4rem 2.6rem; margin: 1.2rem 0 1.6rem;
  color: #fff; box-shadow: 0 10px 30px var(--shadow);
}
.hero h1 { font-size: 2.1rem; font-weight: 700; margin: 0; color: #fff; }
.hero p { margin: 0.5rem 0 0; font-size: 1.02rem; color: rgba(255,255,255,0.82); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 1.6rem; border-bottom: 1px solid var(--border); margin: 0.6rem 0 1rem; }
.tabs.sub { margin-top: 0.2rem; }
.tab {
  background: none; border: none; cursor: pointer; padding: 0.45rem 0.2rem;
  font-size: 1rem; font-weight: 500; color: var(--muted); font-family: inherit;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--heading); font-weight: 600; border-bottom-color: var(--primary); }

/* ---------- controls ---------- */
.controls { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; margin: 0.8rem 0 0.4rem; }
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field.grow { flex: 1 1 260px; }
.field label { font-size: 0.85rem; font-weight: 500; color: var(--muted); }
input[type="text"], input[type="number"], select {
  background: var(--input-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 0.55rem 0.8rem; font-size: 0.95rem; font-family: inherit;
  min-width: 130px;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

.slider-row { display: flex; gap: 0.9rem; align-items: center; }
.slider-row input[type="range"] { flex: 1; accent-color: var(--primary); min-width: 160px; }
.slider-row input[type="number"] { width: 110px; min-width: 90px; }

.radio-row { display: flex; gap: 1.4rem; flex-wrap: wrap; padding: 0.35rem 0; }
.radio-row label, .check {
  display: inline-flex; align-items: center; gap: 0.45rem;
  color: var(--text); font-size: 0.95rem; cursor: pointer;
}
.radio-row input, .check input { accent-color: var(--primary); }
.check { margin: 0.5rem 0; color: var(--muted); font-weight: 500; }

.btn {
  background: var(--primary); color: var(--primary-text); border: none;
  border-radius: 10px; font-weight: 600; padding: 0.62rem 1.4rem;
  font-size: 0.95rem; cursor: pointer; font-family: inherit;
  transition: background .15s;
}
.btn:hover { background: var(--primary-hover); }

.caption { color: var(--muted); font-size: 0.85rem; margin: 0.2rem 0 0.4rem; }

/* ---------- metrics ---------- */
.metrics {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.9rem; margin: 0.9rem 0;
}
.metric {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 1rem 1.2rem; box-shadow: 0 2px 8px var(--shadow);
}
.metric .label {
  color: var(--muted); font-weight: 500; font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.metric .value { color: var(--heading); font-weight: 700; font-size: 1.55rem; margin-top: 2px; }

/* ---------- map ---------- */
.map {
  height: 620px; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border); box-shadow: 0 2px 8px var(--shadow);
  background: var(--surface);
}
.grid-overlay { image-rendering: pixelated; }

.map-title-card {
  position: absolute; top: 14px; left: 60px; z-index: 999;
  background: rgba(255,255,255,0.94); padding: 10px 14px; border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.16);
  font-size: 13px; font-weight: 600; color: #0f3d4d; pointer-events: none;
}
.map-legend {
  position: absolute; bottom: 24px; right: 18px; z-index: 999;
  background: rgba(255,255,255,0.94); padding: 12px 14px 10px; border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18); width: 230px;
}
.map-legend .legend-title { font-size: 12px; font-weight: 600; color: #0f3d4d; margin-bottom: 8px; }
.map-legend .legend-bar { height: 12px; border-radius: 6px; border: 1px solid rgba(0,0,0,0.08); }
.map-legend .legend-ticks {
  display: flex; justify-content: space-between; margin-top: 5px;
  font-size: 10.5px; color: #5a727d;
}
.leaflet-popup-content { font-size: 12.5px; line-height: 1.5; color: #1a2b34; }
.leaflet-container { font-family: inherit; }

/* ---------- cards / expanders ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 2px 8px var(--shadow);
  padding: 1rem 1.2rem; margin: 1rem 0;
}
.chart-card canvas { width: 100%; height: auto; display: block; }

details.expander {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; margin: 0.8rem 0; overflow: hidden;
}
details.expander > summary {
  cursor: pointer; padding: 0.85rem 1.2rem; font-weight: 600; color: var(--heading);
  list-style: none;
}
details.expander > summary::-webkit-details-marker { display: none; }
details.expander > summary::before { content: "\25B8"; margin-right: 8px; color: var(--muted); }
details.expander[open] > summary::before { content: "\25BE"; }
details.expander .expander-body { padding: 0 1.2rem 1.2rem; }
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.charts-row canvas { width: 100%; height: auto; display: block; }
@media (max-width: 860px) { .charts-row { grid-template-columns: 1fr; } }

/* ---------- table ---------- */
.table-wrap {
  border: 1px solid var(--border); border-radius: 12px; overflow-x: auto;
  background: var(--surface); margin-top: 0.8rem;
}
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table-wrap th {
  text-align: left; padding: 11px 16px; color: var(--muted); font-weight: 600;
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table-wrap td { padding: 11px 16px; color: var(--text); border-bottom: 1px solid var(--border); }
.table-wrap tr:last-child td { border-bottom: none; }

/* ---------- progress / error ---------- */
.progress {
  height: 8px; border-radius: 4px; background: var(--input-bg);
  border: 1px solid var(--border); margin: 0.8rem 0; overflow: hidden;
}
.progress-bar { height: 100%; width: 0%; background: var(--primary); transition: width .12s; }
.error {
  background: rgba(209, 73, 91, 0.12); border: 1px solid #d1495b; color: #d1495b;
  border-radius: 10px; padding: 0.7rem 1rem; margin: 0.8rem 0; font-size: 0.92rem;
}
.success {
  background: rgba(42, 157, 143, 0.12); border: 1px solid #2a9d8f; color: #2a9d8f;
  border-radius: 10px; padding: 0.7rem 1rem; margin: 0.8rem 0; font-size: 0.92rem;
}

/* ---------- footer ---------- */
footer { margin-top: 2.4rem; }
footer p { font-size: 0.82rem; color: var(--muted); line-height: 1.6; padding-bottom: 1.5rem; }
