/* ======================================================
   Vannstanden i Norge — Modern Design
   ====================================================== */
:root {
  --primary:      #1565c0;
  --primary-dark: #0d47a1;
  --secondary:    #0288d1;
  --bg:           #f0f4f8;
  --surface:      #ffffff;
  --surface-alt:  #f5f7fa;
  --border:       #dde3ef;
  --text:         #1a2332;
  --text-muted:   #607080;
  --danger:       #c62828;
  --radius:       8px;
  --radius-sm:    4px;
  --shadow:       0 2px 12px rgba(0,0,0,0.10);
  --shadow-sm:    0 1px 4px rgba(0,0,0,0.07);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
          'Helvetica Neue', Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* ── Site Header ──────────────────────────────── */
.site-header {
  background: linear-gradient(135deg, #0d47a1 0%, #0288d1 100%);
  color: white;
  padding: 0.8rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  flex-shrink: 0;
}
.site-header h1 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.header-icon { font-size: 1.4rem; line-height: 1; }

.header-nav {
  margin-left: auto;
  display: flex;
  gap: 1.25rem;
  align-items: center;
}
.header-nav a {
  color: rgba(255,255,255,0.88);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s;
}
.header-nav a:hover { color: #fff; }

/* ── Main Container ───────────────────────────── */
main.container {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  flex: 1;
}

/* ── Breadcrumb ───────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: #b0bec5; }

/* ── Alerts ───────────────────────────────────── */
.alert {
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.alert-danger  { background: #ffebee; color: #b71c1c; border-left: 4px solid #c62828; }
.alert-warning { background: #fff8e1; color: #e65100; border-left: 4px solid #ff9800; }

/* ── Card ─────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.card-header {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.card-body { padding: 1rem; }

/* ── Station Overview (index) ─────────────────── */
.overview-wrap {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
}
.overview-table-wrap { flex: 1; min-width: 0; overflow-x: auto; }
.overview-sidebar { width: 400px; flex-shrink: 0; display: flex; flex-direction: column; gap: 1rem; }

.stn-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.stn-table thead th {
  background: var(--primary);
  color: white;
  padding: 0.55rem 0.85rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-right: 1px solid rgba(255,255,255,0.15);
}
.stn-table thead th:first-child { text-align: left; border-right: 1px solid rgba(255,255,255,0.15); }
.stn-table tbody td { padding: 0.2rem 0.35rem; border-bottom: 1px solid var(--border); }
.stn-table tbody tr:last-child td { border-bottom: none; }
.stn-table tbody tr:hover td { filter: brightness(0.96); }

.stn-btn {
  display: block; width: 100%; padding: 0.3rem 0.65rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; font-family: var(--font);
  font-size: 0.82rem; text-align: left; transition: background 0.15s, border-color 0.15s;
}
.stn-btn:hover { background: #e8f0fe; border-color: var(--primary); }

.fc-cell {
  display: block; width: 100%; height: 26px; min-width: 60px;
  border: none; border-radius: var(--radius-sm); cursor: pointer; transition: filter 0.15s;
}
.fc-cell:hover { filter: brightness(0.82); }

/* ── Modell page ──────────────────────────────── */
.modell-content {
  display: grid;
  grid-template-columns: minmax(300px, 70%) 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
  align-items: start;
}
.modell-plot {
  grid-column: 1; grid-row: 1;
  display: flex; flex-direction: column; gap: 0.75rem;
}
.modell-plot img { width: 100%; height: auto; display: block; border-radius: var(--radius); cursor: zoom-in; }

/* ── Image lightbox ───────────────────────────── */
#img-lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.88);
  display: none; align-items: flex-start; justify-content: center;
  padding: 2rem; overflow-y: auto; cursor: zoom-out;
}
#img-lightbox img {
  max-width: min(90vw, 1400px); width: auto; height: auto;
  border-radius: var(--radius); box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  margin-top: 0;
}
.modell-nav {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
}
.modell-nav-top {
  margin-bottom: 1.5rem;
}
.modell-right { grid-column: 2; grid-row: 1 / 3; display: flex; flex-direction: column; gap: 1rem; }
.modell-selectors { display: flex; flex-direction: column; gap: 0.9rem; }
.modell-hourly { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; font-size: 0.82rem; }
.modell-hourly .table-scroll { overflow-y: auto; overflow-x: auto; max-height: 480px; }
.modell-hourly .data-table th,
.modell-hourly .data-table td { white-space: nowrap; padding: 0.3rem 0.5rem; }
.selector-group { display: flex; flex-direction: column; gap: 0.3rem; }
.sel-label {
  font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-muted);
}
.form-select {
  width: 100%; padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--surface); font-family: var(--font);
  font-size: 0.85rem; color: var(--text); cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-select:hover { border-color: var(--primary); }
.form-select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21,101,192,0.15);
}

/* ── Radio button groups ──────────────────────── */
.control-group { min-width: 170px; }
.control-group .group-label {
  font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-muted); margin-bottom: 0.35rem;
}
.radio-list { display: flex; flex-direction: column; gap: 0.1rem; }
.radio-list label {
  display: flex; align-items: center; gap: 0.45rem;
  padding: 0.3rem 0.6rem; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 0.82rem; transition: background 0.15s; white-space: nowrap; user-select: none;
}
.radio-list label:hover { background: #e8f0fe; }
.radio-list input[type=radio] { accent-color: var(--primary); cursor: pointer; }
.radio-list label:has(input:checked) {
  background: #e3eefe; color: var(--primary); font-weight: 600;
}

/* ── Data tables ──────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.data-table th {
  background: var(--surface-alt); padding: 0.45rem 0.6rem; text-align: center;
  font-weight: 700; font-size: 0.74rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border); position: sticky; top: 0; z-index: 1;
}
.data-table td { padding: 0.35rem 0.6rem; text-align: center; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface-alt); }

/* ── Buttons ──────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.45rem 1rem; border-radius: var(--radius); border: none;
  cursor: pointer; font-family: var(--font); font-size: 0.82rem;
  font-weight: 500; text-decoration: none;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-dark); color: white; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-secondary { background: var(--surface); color: var(--primary); border: 1.5px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); background: #eef2ff; }

/* ── Info page ────────────────────────────────── */
.info-grid {
  display: grid; grid-template-columns: minmax(260px, 320px) 1fr minmax(260px, 320px); gap: 1rem; align-items: start;
}
.info-grid .card-body { overflow-x: auto; }
.info-grid .data-table { font-size: 0.76rem; }
.info-grid .data-table th { padding: 0.3rem 0.4rem; font-size: 0.7rem; }
.info-grid .data-table td { padding: 0.25rem 0.4rem; }
.info-images { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.info-images img { max-height: 460px; width: auto; flex: 1; min-width: 200px; border-radius: var(--radius); }

/* ── Tooltip ──────────────────────────────────── */
.tooltip {
  position: relative; display: inline-block; cursor: help;
  border-bottom: 1px dotted var(--text-muted);
}
.tooltip .tooltiptext {
  visibility: hidden; width: 260px; background: #263238; color: #fff;
  font-size: 0.78rem; text-align: left; padding: 0.5rem 0.7rem;
  border-radius: var(--radius-sm); position: absolute; z-index: 20;
  bottom: 130%; left: 50%; transform: translateX(-50%);
  box-shadow: var(--shadow); opacity: 0; transition: opacity 0.2s;
  pointer-events: none; line-height: 1.45;
}
.tooltip:hover .tooltiptext { visibility: visible; opacity: 1; }

/* ── Forklaring / Feil pages ──────────────────── */
.article-body { max-width: 820px; }
.article-body h3 { margin: 1.25rem 0 0.35rem; color: var(--primary-dark); font-size: 0.95rem; }
.article-body p { margin-bottom: 0.75rem; font-size: 0.9rem; }

.formula-table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
.formula-table th, .formula-table td {
  padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.formula-table th {
  background: var(--surface-alt); font-weight: 700; font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); text-align: left;
}
.formula-table td:first-child { width: 140px; }
.formula-table img { display: block; }

/* ── Footer ───────────────────────────────────── */
.site-footer {
  text-align: center; padding: 1rem 1.5rem;
  color: var(--text-muted); font-size: 0.78rem;
  border-top: 1px solid var(--border); background: var(--surface); flex-shrink: 0;
}

/* ── Responsive ───────────────────────────────── */
@media (max-width: 1050px) {
  .modell-content { grid-template-columns: 1fr; }
  .modell-plot,
  .modell-right,
  .modell-hourly { grid-column: 1; grid-row: auto; }
  .modell-selectors { flex-direction: row; flex-wrap: wrap; gap: 1rem; }
  .selector-group { min-width: 180px; flex: 1; }
}
@media (max-width: 900px) {
  .info-grid { grid-template-columns: 1fr; }
  .overview-wrap { flex-direction: column; }
  .overview-sidebar { width: 100%; }
}
@media (max-width: 600px) {
  main.container { padding: 0.75rem; }
  .site-header h1 { font-size: 1rem; }
  .header-nav { display: none; }
  .modell-selectors { flex-direction: column; }
}
