/* TideRef — VARØ Industries */

:root {
  --bg:           #050a14;
  --bg-card:      #0a1220;
  --bg-card-alt:  #0e1830;
  --border:       #16243e;
  --border-glow:  rgba(0, 180, 216, 0.3);
  --accent:       #00b4d8;
  --accent-dim:   rgba(0, 180, 216, 0.12);
  --accent-2:     #48cae4;
  --high:         #4d9fff;
  --low:          #00d4aa;
  --text:         #d0d8e8;
  --text-muted:   #5f6f95;
  --text-label:   #8fa0c0;
  --text-mono:    #7dd8f0;
  --danger:       #ff4466;
  --warning:      #ffaa00;
  --radius:       10px;
  --radius-sm:    6px;
  --font-ui:      'Inter', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
}

html[data-theme="light"] {
  --bg:           #f2f5f9;
  --bg-card:      #ffffff;
  --bg-card-alt:  #e8eef6;
  --border:       #cdd8e6;
  --border-glow:  rgba(0, 140, 170, 0.35);
  --accent:       #0090b0;
  --accent-dim:   rgba(0, 144, 176, 0.1);
  --accent-2:     #007a95;
  --high:         #1f6fd0;
  --low:          #009e80;
  --text:         #17263c;
  --text-muted:   #6a7a98;
  --text-label:   #48597a;
  --text-mono:    #006a85;
  --danger:       #d0002f;
  --warning:      #c07800;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

.hidden { display: none !important; }
.mono { font-family: var(--font-mono); }

.page-wrapper { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Header ── */
.site-header {
  background: linear-gradient(180deg, var(--bg-card-alt) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 1.5rem 1.75rem;
  text-align: center;
  position: relative;
}
.site-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(0,180,216,0.08) 0%, transparent 70%);
  pointer-events: none;
}
.header-top {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  position: relative;
}
.pill-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.05em;
}
.pill-btn:hover { border-color: var(--accent); color: var(--accent); }

.brand {
  font-family: var(--font-mono);
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
  text-shadow: 0 0 30px rgba(0,180,216,0.5);
}
.brand span { color: #5060d0; text-shadow: 0 0 20px rgba(80,96,208,0.6); }
.tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── Main ── */
main {
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  flex: 1;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.25rem;
  transition: border-color 0.3s;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-label);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Location ── */
.location-inputs {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}
.btn-primary {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary:hover { background: var(--accent); color: var(--bg); }
.or-divider { color: var(--text-muted); font-size: 0.8rem; }
.manual-location { position: relative; flex: 1; min-width: 230px; }
.manual-location input {
  width: 100%;
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s;
}
.manual-location input:focus { border-color: var(--accent); }

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 280px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.search-result {
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--accent-dim); color: var(--accent); }
.search-result .sr-state {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: 0.4rem;
}

.station-info { margin-top: 1rem; }
.station-name { font-weight: 600; font-size: 1.05rem; }
.station-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}
.station-meta a { color: var(--accent); text-decoration: none; }
.station-meta a:hover { text-decoration: underline; }

/* ── Loading / error ── */
.loading-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-box {
  background: rgba(255, 68, 102, 0.08);
  border: 1px solid rgba(255, 68, 102, 0.4);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  color: var(--danger);
  margin-bottom: 1.25rem;
}

/* ── Dial grid ── */
.dial-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 720px) { .dial-grid { grid-template-columns: 1fr; } }
.dial-card, .status-card { margin-bottom: 0; }

.dial-wrap { max-width: 320px; margin: 0 auto; }
.dial-wrap svg { width: 100%; height: auto; display: block; }
.dial-caption {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
}
.dial-caption strong { color: var(--accent); }

/* ── Right now ── */
.now-level { text-align: center; margin-bottom: 1.25rem; }
.now-height {
  font-family: var(--font-mono);
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--text-mono);
  line-height: 1.1;
}
.now-trend { font-size: 0.9rem; color: var(--text-muted); margin-top: 0.25rem; }
.now-trend.rising { color: var(--high); }
.now-trend.falling { color: var(--low); }

.next-events { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
@media (max-width: 380px) { .next-events { grid-template-columns: 1fr; } }
.next-event {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.9rem;
  text-align: center;
}
.next-event.next-up { border-color: var(--border-glow); box-shadow: 0 0 16px rgba(0,180,216,0.08); }
.next-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-label);
}
.next-time { font-weight: 600; font-size: 1.05rem; margin-top: 0.2rem; }
.next-countdown { font-size: 0.8rem; color: var(--accent); margin-top: 0.1rem; }
.next-height { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; }

.moon-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
}
.moon-emoji { font-size: 1.3rem; }

/* ── Today ── */
.today-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.9rem;
}
.tide-event {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.9rem;
  text-align: center;
}
.tide-event.past { opacity: 0.45; }
.tide-event .te-type { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.tide-event .te-type.h { color: var(--high); }
.tide-event .te-type.l { color: var(--low); }
.tide-event .te-time { font-weight: 600; font-size: 1.1rem; margin-top: 0.15rem; }
.tide-event .te-height { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-muted); margin-top: 0.1rem; }

/* ── Charts ── */
canvas { width: 100%; display: block; }

/* ── Week table ── */
.week-table { overflow-x: auto; }
.week-table table { width: 100%; border-collapse: collapse; font-size: 0.85rem; min-width: 560px; }
.week-table th {
  text-align: left;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-label);
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.week-table td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.week-table tr:last-child td { border-bottom: none; }
.week-table .day-cell { font-weight: 600; white-space: nowrap; }
.week-table .day-cell .dow { color: var(--text-muted); font-weight: 400; font-size: 0.75rem; }
.wt-event { white-space: nowrap; font-family: var(--font-mono); font-size: 0.78rem; }
.wt-event .h { color: var(--high); font-weight: 700; }
.wt-event .l { color: var(--low); font-weight: 700; }
.wt-event .wt-ht { color: var(--text-muted); }

/* ── History ── */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.1rem;
}
.stat-tile {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
}
.stat-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-label);
}
.stat-value { font-family: var(--font-mono); font-size: 1.05rem; font-weight: 700; color: var(--text-mono); margin-top: 0.1rem; }
.stat-sub { font-size: 0.7rem; color: var(--text-muted); }

.fine-print { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.8rem; }

/* ── Info ── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.1rem;
}
.info-item h4 { font-size: 0.9rem; margin-bottom: 0.3rem; color: var(--accent-2); }
.info-item p { font-size: 0.82rem; color: var(--text-muted); }

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

/* ── Cookie banner ── */
.cookie-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-card-alt);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding: 0.8rem 1rem;
  box-shadow: 0 -6px 20px rgba(0,0,0,0.35);
}
.cookie-inner {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.cookie-text { font-size: 0.8rem; color: var(--text-muted); }
.cookie-btns { display: flex; gap: 0.5rem; }
.cookie-accept {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: var(--bg);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.cookie-decline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* ── Static pages (privacy/terms) ── */
.static-page { max-width: 760px; margin: 0 auto; padding: 2rem 1rem 4rem; }
.static-page h2 { margin-bottom: 1rem; }
.static-page h3 { margin: 1.4rem 0 0.4rem; font-size: 1rem; color: var(--accent-2); }
.static-page p { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 0.6rem; }
.static-page a { color: var(--accent); }
