/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --bg:          #080e1a;
  --surface:     #0f1929;
  --surface-2:   #162236;
  --surface-3:   #1d2d45;
  --border:      rgba(255,255,255,0.07);
  --border-mid:  rgba(255,255,255,0.12);
  --text:        #e8f0fe;
  --text-muted:  #7a90aa;
  --text-dim:    #4a607a;
  --blue:        #3b82f6;
  --cyan:        #06b6d4;
  --teal:        #14b8a6;
  --green:       #22c55e;
  --amber:       #f59e0b;
  --red:         #ef4444;
  --nav-h:       60px;
  --radius:      8px;
  --max-w:       1140px;
}

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

html { height: 100%; }

body {
  min-height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body.page-map { height: 100%; overflow: hidden; }

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
img { max-width: 100%; }

/* ── Site Nav ────────────────────────────────────────────────────────────────── */
.site-nav {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--nav-h);
  background: rgba(8,14,26,0.90);
  backdrop-filter: blur(20px) saturate(1.6);
  border-bottom: 1px solid var(--border);
  z-index: 900;
}

.nav-inner {
  height: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  flex-shrink: 0;
  margin-right: 0.5rem;
}

.nav-brand-icon {
  width: 24px;
  height: 24px;
  color: var(--cyan);
  flex-shrink: 0;
}

.nav-brand-title {
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(130deg, #06b6d4 0%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.05rem;
  flex: 1;
  min-width: 0;
}

.nav-link {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.nav-link:hover  { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--cyan); background: rgba(6,182,212,0.1); }

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* ── Status dot ─────────────────────────────────────────────────────────────── */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
  transition: background 0.4s, box-shadow 0.4s;
}
.status-dot.connected {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.2);
  animation: breathe 2.4s ease-in-out infinite;
}
.status-dot.error { background: var(--red); }

@keyframes breathe {
  0%,100% { box-shadow: 0 0 0 2px rgba(34,197,94,0.15); }
  50%      { box-shadow: 0 0 0 6px rgba(34,197,94,0.04); }
}

/* ── Page layout ────────────────────────────────────────────────────────────── */
.page-wrap {
  padding-top: var(--nav-h);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.25rem;
  width: 100%;
}

/* ── Footer ─────────────────────────────────────────────────────────────────── */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 2rem 1.25rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.site-footer a { color: var(--text-muted); text-decoration: underline; }
.site-footer a:hover { color: var(--text); }

/* ════════════════════════════════════════════════════════════════════════════
   HOMEPAGE
   ════════════════════════════════════════════════════════════════════════════ */

/* Hero */
.hero {
  padding: 4.5rem 1.25rem 3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(6,182,212,0.14), transparent),
    radial-gradient(ellipse 50% 40% at 15% 110%, rgba(59,130,246,0.09), transparent);
  pointer-events: none;
}

.hero-icon {
  font-size: 3.5rem;
  margin-bottom: 1.1rem;
  display: block;
  filter: drop-shadow(0 0 24px rgba(6,182,212,0.55));
  animation: float 3.5s ease-in-out infinite;
}

@keyframes float {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

.hero-title {
  font-size: clamp(2.2rem, 7vw, 3.8rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #e8f0fe 0%, #06b6d4 55%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
}

.hero-sub {
  font-size: clamp(0.92rem, 2.5vw, 1.1rem);
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 auto 2.5rem;
  line-height: 1.65;
}

.hero-cta {
  display: flex;
  gap: 0.875rem;
  justify-content: center;
  flex-wrap: wrap;
}

.hero-karlovac {
  padding-bottom: 2.4rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); }

.btn-primary {
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  color: #fff;
  box-shadow: 0 4px 16px rgba(6,182,212,0.28);
}
.btn-primary:hover { box-shadow: 0 8px 28px rgba(6,182,212,0.4); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-mid);
}
.btn-secondary:hover { box-shadow: 0 8px 24px rgba(0,0,0,0.35); }

/* River cards section */
.river-section {
  padding: 0 1.25rem 3rem;
  max-width: var(--max-w);
  margin: 0 auto;
  width: 100%;
}

.section-heading {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.section-heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.river-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.river-grid-fixed {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.river-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--rc, var(--cyan));
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.river-card:hover {
  transform: translateY(-4px);
  border-color: var(--rc, var(--cyan));
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
  background: var(--surface-2);
}

.rc-temp {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1;
  color: var(--rc, var(--cyan));
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
}

.rc-kicker {
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 0.45rem;
}
.rc-temp-unit {
  font-size: 1.3rem;
  font-weight: 600;
  vertical-align: super;
  opacity: 0.8;
}

.rc-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.rc-name-large {
  font-size: 1.18rem;
  margin-bottom: 0.95rem;
}

.rc-verdict {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
  flex: 1;
}

.rc-test {
  align-self: flex-start;
  font-size: 0.68rem;
  font-weight: 700;
  color: #fbbf24;
  background: rgba(245,158,11,0.12);
  border: 1px solid rgba(245,158,11,0.28);
  border-radius: 999px;
  padding: 0.16rem 0.48rem;
  margin-bottom: 0.45rem;
}

.rc-ago {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 0.8rem;
}

.rc-arrow {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  font-size: 0.85rem;
  color: var(--rc, var(--cyan));
  opacity: 0;
  transition: opacity 0.18s, right 0.15s;
}
.river-card:hover .rc-arrow { opacity: 1; right: 0.8rem; }

.sponsor-section {
  border-top: 1px solid var(--border);
  padding: 2.5rem 1.25rem 3rem;
  max-width: var(--max-w);
  margin: 0 auto;
  width: 100%;
}

.sponsor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
}

.sponsor-card {
  min-height: 144px;
  background: rgba(15, 25, 41, 0.72);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
}

.sponsor-card:hover {
  border-color: var(--border-mid);
  background: var(--surface-2);
}

.sponsor-logo {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.5rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.28);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
}

.sponsor-logo-image {
  width: clamp(9rem, 42vw, 13rem);
  height: auto;
  aspect-ratio: 1 / 1;
  background: #02060d;
  overflow: hidden;
}

.sponsor-logo-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.sponsor-name {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.35;
  font-weight: 600;
}

.sponsor-card-featured .sponsor-name {
  color: var(--text);
}

/* ════════════════════════════════════════════════════════════════════════════
   MAP PAGE
   ════════════════════════════════════════════════════════════════════════════ */

body.page-map .page-wrap { padding-top: 0; min-height: 0; }

.map-container {
  position: fixed;
  inset: var(--nav-h) 0 0 0;
}

#map {
  width: 100%;
  height: 100%;
  background: #07111f;
}

/* Dark OSM tiles — invert so land goes dark, rivers stay blue */
.leaflet-tile {
  filter: invert(1) hue-rotate(180deg) saturate(1.6) contrast(0.88);
}

/* Temperature marker */
.t-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.22);
  box-shadow: 0 4px 16px rgba(0,0,0,0.55);
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: var(--mc, #06b6d4);
  line-height: 1;
  user-select: none;
  transition: transform 0.18s, box-shadow 0.18s;
}
.t-marker:hover {
  transform: scale(1.12);
  box-shadow: 0 6px 22px rgba(0,0,0,0.7);
}
.t-marker.is-stale {
  border-color: rgba(245,158,11,0.55);
}
.t-marker.is-offline {
  color: #d1d5db;
  border-color: rgba(148,163,184,0.45);
  box-shadow: 0 3px 12px rgba(0,0,0,0.45);
  opacity: 0.72;
  filter: saturate(0.2);
}
.t-marker.is-testing {
  border-style: dashed;
  border-color: rgba(251,191,36,0.82);
}

.marker-val { font-size: 0.9rem; }

/* Cluster bubble */
.cluster-bubble {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(15,25,41,0.92);
  border: 2px solid var(--cyan);
  box-shadow: 0 0 0 4px rgba(6,182,212,0.18), 0 4px 16px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--cyan);
  cursor: pointer;
  transition: transform 0.18s;
}
.cluster-bubble:hover { transform: scale(1.1); }


/* ════════════════════════════════════════════════════════════════════════════
   RIVER DETAIL PAGES
   ════════════════════════════════════════════════════════════════════════════ */

.river-page {
  gap: 1.25rem;
  padding-bottom: 3rem;
}

.river-hero {
  width: min(var(--max-w), calc(100% - 2.5rem));
  margin: 2.75rem auto 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 1.25rem;
  align-items: stretch;
}

.river-copy {
  padding: 1.25rem 0;
}

.river-copy h1 {
  font-size: clamp(2.4rem, 7vw, 4.2rem);
  line-height: 1.02;
  font-weight: 800;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #e8f0fe 0%, var(--river-color, #06b6d4) 70%, #f8fafc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.river-copy p {
  max-width: 560px;
  color: var(--text-muted);
  line-height: 1.7;
  font-size: 1rem;
}

.river-reading {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01)), var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--river-color, var(--cyan));
  border-radius: var(--radius);
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 260px;
}

.river-temp {
  color: var(--river-color, var(--cyan));
  font-size: clamp(3.4rem, 11vw, 5.8rem);
  font-weight: 800;
  line-height: 0.92;
  letter-spacing: -0.03em;
}

.river-temp span:last-child {
  font-size: 0.34em;
  vertical-align: super;
  font-weight: 700;
  opacity: 0.8;
}

.river-verdict {
  margin-top: 0.85rem;
  color: var(--text);
  font-size: 1.02rem;
  font-weight: 700;
}

.river-updated {
  margin-top: 0.45rem;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.river-status.is-stale,
.river-status.is-offline {
  filter: saturate(0.55);
}

.river-info-grid,
.river-node-section,
.river-history {
  width: min(var(--max-w), calc(100% - 2.5rem));
  margin: 0 auto;
}

.river-info-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.river-info {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  min-width: 0;
}

.river-info span {
  display: block;
  color: var(--text-dim);
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.35rem;
}

.river-info strong {
  display: block;
  color: var(--text);
  font-size: 0.96rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.river-map-link {
  color: var(--cyan);
  font-size: 0.96rem;
  font-weight: 700;
  line-height: 1.35;
}

.river-map-link:hover {
  text-decoration: underline;
}

.river-map-link.is-disabled {
  color: var(--text-dim);
  pointer-events: none;
  text-decoration: none;
}

.river-node-section {
  display: grid;
  gap: 0.65rem;
}

.river-node-option {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "name temp"
    "meta meta";
  gap: 0.25rem 0.8rem;
  align-items: center;
  text-align: left;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem 0.95rem;
}

.river-node-option:hover,
.river-node-option.active {
  border-color: var(--river-color, var(--cyan));
  background: var(--surface-2);
}

.river-node-option span {
  grid-area: name;
  min-width: 0;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.river-node-option strong {
  grid-area: temp;
  color: var(--river-color, var(--cyan));
  font-size: 1rem;
  white-space: nowrap;
}

.river-node-option small {
  grid-area: meta;
  color: var(--text-dim);
  font-size: 0.72rem;
}

.river-history {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.inline-drawer-header {
  margin-bottom: 1rem;
}

.chart-wrap-inline {
  min-height: 320px;
  max-height: none;
}


/* ════════════════════════════════════════════════════════════════════════════
   HISTORY DRAWER  (shared by map + sensors pages)
   ════════════════════════════════════════════════════════════════════════════ */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  z-index: 1100;
  pointer-events: none;
  transition: background 0.3s;
}
.drawer-overlay.open {
  background: rgba(0,0,0,0.55);
  pointer-events: auto;
}

.history-drawer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 1200;
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  padding: 1.5rem 1.5rem 2rem;
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.32,0.72,0,1);
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.history-drawer.open { transform: translateY(0); }

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.drawer-title-block { flex: 1; min-width: 0; }

.drawer-title-block h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.drawer-meta { font-size: 0.72rem; color: var(--text-muted); }

.drawer-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* Range tabs */
.range-tabs {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.rtab {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.25rem 0.6rem;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.rtab:hover  { color: var(--text); }
.rtab.active { background: var(--surface-3); color: var(--text); }

/* Close button */
.btn-close {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s;
  color: var(--text-muted);
}
.btn-close svg { width: 16px; height: 16px; }
.btn-close:hover { background: var(--border-mid); color: var(--text); }

/* Chart */
.chart-wrap {
  position: relative;
  flex: 1;
  min-height: 200px;
  max-height: 280px;
}

/* Stats row */
.drawer-stats {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.stat { display: flex; flex-direction: column; gap: 0.2rem; }

.stat-label {
  font-size: 0.64rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.stat-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--cyan);
}


/* ════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 520px) {
  .nav-inner       { padding: 0 0.55rem; gap: 0.3rem; }
  .nav-brand       { gap: 0.35rem; margin-right: 0.1rem; }
  .nav-brand-title { display: none; }
  .nav-brand-icon  { width: 22px; height: 22px; }
  .nav-links       {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-link        { font-size: 0.74rem; padding: 0.3rem 0.42rem; }
  .nav-right       { display: none; }
  .hero            { padding: 2.5rem 1rem 2rem; }
  .river-grid      { grid-template-columns: 1fr 1fr; }
  .river-hero,
  .river-info-grid,
  .river-node-section,
  .river-history   { width: calc(100% - 2rem); }
  .river-temp      { font-size: 3.3rem; }
  .river-info-grid { grid-template-columns: 1fr; }
  .inline-drawer-header {
    flex-direction: column;
    align-items: stretch;
  }
  .range-tabs      { width: 100%; }
  .rtab            { flex: 1; }
  .chart-wrap-inline { min-height: 250px; }
}

@media (max-width: 820px) {
  .river-hero {
    grid-template-columns: 1fr;
    margin-top: 2rem;
  }
  .river-copy {
    padding-bottom: 0;
  }
}

@media (min-width: 700px) {
  /* Drawer slides in from the right on desktop */
  .history-drawer {
    left: auto;
    right: 0;
    top: var(--nav-h);
    bottom: 0;
    width: 440px;
    max-height: none;
    border-radius: 0;
    border-right: none;
    border-top: none;
    border-bottom: none;
    transform: translateX(100%);
  }
  .history-drawer.open  { transform: translateX(0); }
  .drawer-overlay.open  { background: rgba(0,0,0,0.25); }
}

@media (min-width: 900px) {
  .river-grid { grid-template-columns: repeat(4, 1fr); }
  .sponsor-grid { grid-template-columns: repeat(2, 1fr); }
  .sponsor-card { flex-direction: column; justify-content: center; text-align: center; }
}
