/* ── DARK THEME (default) ─────────────────────────────── */
:root {
  --cream:          #0E1C28;
  --parchment:      #142232;
  --ink:            #EAE3D8;
  --ink-mid:        #BDB3A4;
  --stone:          #7A93A8;
  --border:         #1E3347;
  --border-light:   #172B3C;
  --pool:           #1B8F9C;
  --pool-mid:       #4EC8D4;
  --pool-pale:      #0E3A44;
  --pool-faint:     rgba(78,200,212,0.10);
  --wellness:       #9E6828;
  --wellness-mid:   #E8A84E;
  --wellness-pale:  #3A2208;
  --wellness-faint: rgba(232,168,78,0.10);
  --live-green:     #4EC98C;
  --accent:         #E8644A;
  /* derived */
  --glass-heavy:    rgba(14,28,40,0.92);
  --glass-soft:     rgba(14,28,40,0.60);
  --live-pulse-0:   rgba(78,201,140,0.55);
  --live-pulse-1:   rgba(78,201,140,0);
  --busy-low-bg:    rgba(78,201,140,0.13);
  --busy-mid-bg:    rgba(232,168,78,0.13);
  --busy-high-bg:   rgba(232,100,74,0.13);
  --chip-hover-bg:  rgba(78,200,212,0.09);
  --label-tint-bg:  rgba(27,143,156,0.08);
}

/* ── LIGHT THEME ──────────────────────────────────────── */
@media (prefers-color-scheme: light) {
  :root {
    --cream:          #F3EDE1;
    --parchment:      #FBF7EF;
    --ink:            #1C1510;
    --ink-mid:        #483D30;
    --stone:          #8C7D6A;
    --border:         #DDD0BB;
    --border-light:   #EDE5D8;
    --pool:           #1A6E75;
    --pool-mid:       #3A9DA8;
    --pool-pale:      #B4DBE0;
    --pool-faint:     rgba(58,157,168,0.10);
    --wellness:       #7A4E2D;
    --wellness-mid:   #BF834E;
    --wellness-pale:  #E8C9A0;
    --wellness-faint: rgba(191,131,78,0.10);
    --live-green:     #4CB87A;
    --accent:         #C45A3A;
    /* derived */
    --glass-heavy:    rgba(251,247,239,0.92);
    --glass-soft:     rgba(251,247,239,0.60);
    --live-pulse-0:   rgba(76,184,122,0.55);
    --live-pulse-1:   rgba(76,184,122,0);
    --busy-low-bg:    rgba(76,184,122,0.13);
    --busy-mid-bg:    rgba(191,131,78,0.13);
    --busy-high-bg:   rgba(196,90,58,0.13);
    --chip-hover-bg:  rgba(58,157,168,0.09);
    --label-tint-bg:  rgba(26,110,117,0.04);
  }
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  font-weight: 300;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23g)' opacity='0.045'/%3E%3C/svg%3E");
  background-size: 200px;
  opacity: 0.5;
}

/* ── HEADER ───────────────────────────────────────────── */
.header {
  background: var(--pool);
  position: relative;
  padding: 52px 60px 0;
  overflow: hidden;
}
.header-deco { position: absolute; border-radius: 50%; pointer-events: none; }
.header-deco-1 { width: 520px; height: 520px; top: -280px; right: -160px; background: rgba(255,255,255,0.035); }
.header-deco-2 { width: 320px; height: 320px; bottom: -180px; left: -80px; background: rgba(255,255,255,0.025); }
.header-deco-3 { width: 180px; height: 180px; top: 20px; left: 40%; background: rgba(255,255,255,0.02); }
.header-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 24px; position: relative; z-index: 1;
}
.brand-eyebrow {
  font-size: 0.68rem; font-weight: 500; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--pool-pale); opacity: 0.8; margin-bottom: 10px;
}
.brand-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(3.2rem, 9vw, 6rem); font-weight: 700;
  color: #fff; line-height: 0.88; letter-spacing: -0.02em;
}
.brand-title em { font-style: italic; font-weight: 300; color: var(--pool-pale); }
.brand-subtitle {
  font-size: 0.8rem; font-weight: 300; color: rgba(255,255,255,0.45);
  letter-spacing: 0.1em; text-transform: uppercase; margin-top: 14px;
}
.header-right {
  display: flex; flex-direction: column; align-items: flex-end;
  gap: 12px; align-self: flex-start; margin-top: 6px;
}
.live-pill {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.10); border: 1px solid rgba(255,255,255,0.18);
  border-radius: 100px; padding: 7px 16px 7px 12px;
  font-size: 0.78rem; font-weight: 400; color: rgba(255,255,255,0.82);
  letter-spacing: 0.03em; white-space: nowrap; backdrop-filter: blur(4px);
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--live-green); flex-shrink: 0;
  animation: pulse-live 2.4s ease-in-out infinite;
}
@keyframes pulse-live {
  0%, 100% { box-shadow: 0 0 0 0 var(--live-pulse-0); }
  50%       { box-shadow: 0 0 0 7px var(--live-pulse-1); }
}
.refresh-note { font-size: 0.7rem; color: rgba(255,255,255,0.32); letter-spacing: 0.04em; }
.header-wave { display: block; width: 100%; height: 64px; margin-top: -1px; position: relative; z-index: 1; }
.header-wave-fill { fill: var(--cream); }

/* ── MAIN ─────────────────────────────────────────────── */
.main { max-width: 1200px; margin: 0 auto; padding: 0 60px 80px; }

@media (max-width: 840px) {
  .header { padding: 40px 24px 0; }
  .main   { padding: 0 20px 60px; }
  .header-right { align-items: flex-start; }
}

.section-eyebrow {
  font-size: 0.68rem; font-weight: 500; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--stone); margin-bottom: 8px;
  display: flex; align-items: center; gap: 10px;
}
.section-eyebrow::after {
  content: ''; flex: 1; height: 1px; background: var(--border); max-width: 60px;
}
.sec-divider { border: none; border-top: 1px solid var(--border-light); margin: 0 0 56px; }

/* ── GAUGES ───────────────────────────────────────────── */
.gauges-section { margin-top: -18px; margin-bottom: 20px; }
.gauges-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 560px) { .gauges-grid { grid-template-columns: 1fr; } }

.gauge-card {
  background: var(--parchment);
  border: 1px solid var(--border);
  border-radius: 22px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.gauge-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.28);
}
.gauge-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 4px; z-index: 3;
  border-radius: 22px 0 0 22px;
}
.gauge-card.gc-pool::before     { background: linear-gradient(180deg, var(--pool-mid), var(--pool)); }
.gauge-card.gc-wellness::before { background: linear-gradient(180deg, var(--wellness-mid), var(--wellness)); }

/* Body: text left, ring right */
.gauge-body {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 26px 22px 38px;
}

.gauge-text-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.gc-zone-label {
  font-size: 0.58rem; font-weight: 500;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--stone); margin-bottom: 10px;
}

.gauge-num {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 700; font-size: 5.5rem; font-style: italic;
  line-height: 0.82; letter-spacing: -0.04em;
  display: block; transition: color 0.5s ease;
}
.gauge-num.gauge-num-1digit { letter-spacing: 0; }
.gc-pool    .gauge-num { color: var(--pool); }
.gc-wellness .gauge-num { color: var(--wellness); }

.gauge-unit-lbl {
  font-size: 0.7rem; font-weight: 400;
  color: var(--stone); letter-spacing: 0.05em; margin-top: 8px;
}

/* Busyness pill */
.gc-busyness {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 14px; font-size: 0.63rem; font-weight: 600;
  letter-spacing: 0.15em; text-transform: uppercase;
  padding: 5px 12px 5px 8px; border-radius: 100px;
  width: fit-content; min-height: 26px;
  transition: color 0.45s ease, background 0.45s ease;
}
.gc-busyness:not(:empty)::before {
  content: ''; width: 6px; height: 6px;
  border-radius: 50%; background: currentColor; flex-shrink: 0;
  animation: status-blink 2.2s ease-in-out infinite;
}
@keyframes status-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.busy-low  { color: var(--live-green);   background: var(--busy-low-bg); }
.busy-mid  { color: var(--wellness-mid); background: var(--busy-mid-bg); }
.busy-high { color: var(--accent);       background: var(--busy-high-bg); }

/* Occupancy color overrides */
.gauge-card.occ-low  .gauge-arc { stroke: var(--live-green) !important; }
.gauge-card.occ-mid  .gauge-arc { stroke: var(--wellness-mid) !important; }
.gauge-card.occ-high .gauge-arc { stroke: var(--accent) !important; }
.gauge-card.occ-low  .gauge-num { color: var(--live-green) !important; }
.gauge-card.occ-mid  .gauge-num { color: var(--wellness-mid) !important; }
.gauge-card.occ-high .gauge-num { color: var(--accent) !important; }

/* Compact activity ring — self-contained, top-right */
.gauge-dial-bg {
  flex-shrink: 0;
  align-self: flex-start;
  padding-top: 2px;
}
.gauge-svg {
  display: block; width: 84px; height: 84px;
  transform: rotate(-90deg);
}
.gauge-track { fill: none; stroke: var(--border); stroke-width: 16; }
.gauge-arc {
  fill: none; stroke-width: 16; stroke-linecap: round;
  transition: stroke-dasharray 1.1s cubic-bezier(0.34, 1.4, 0.64, 1), stroke 0.5s ease;
}
.gc-pool    .gauge-arc { stroke: var(--pool-mid); }
.gc-wellness .gauge-arc { stroke: var(--wellness-mid); }

/* Open/closed overlay */
.gc-closed-badge {
  display: none; position: absolute; inset: 0;
  background: var(--glass-heavy); border-radius: 22px;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; z-index: 10; backdrop-filter: blur(4px);
}
.gauge-card.gc-closed .gc-closed-badge { display: flex; }
.gc-closed-text {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.9rem; font-weight: 500; color: var(--stone);
}
.gc-closed-sub { font-size: 0.74rem; color: var(--stone); opacity: 0.6; }

.gauge-footer {
  border-top: 1px solid var(--border-light);
  padding: 11px 26px 15px 38px;
  display: flex; justify-content: space-between; align-items: center;
}
.gauge-time  { font-size: 0.72rem; color: var(--stone); }
.gauge-delta { font-size: 0.72rem; font-weight: 500; }
.delta-up   { color: var(--accent); }
.delta-down { color: #4EC98C; }
.delta-same { color: var(--stone); }

@media (max-width: 560px) {
  .gauge-body   { padding: 22px 20px 18px 28px; }
  .gauge-footer { padding: 10px 20px 14px 28px; }
  .gauge-num    { font-size: 4.5rem; }
  .gauge-svg    { width: 72px; height: 72px; }
}

/* ── BEST TIMES STRIP ─────────────────────────────────── */
.best-times {
  background: var(--parchment);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  margin-bottom: 20px;
}

.best-times-label {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 22px 26px;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  min-width: 122px;
  background: var(--label-tint-bg);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--ink-mid);
  line-height: 1.8;
}
.best-times-label::before {
  content: '≈';
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.7rem;
  font-weight: 300;
  color: var(--pool-mid);
  line-height: 1;
  display: block;
  margin-bottom: 8px;
}

#best-times-content {
  flex: 1;
  padding: 10px 14px !important;
  align-items: stretch !important;
  gap: 8px !important;
}

.best-time-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 20px;
  flex: 1;
  min-width: 82px;
  gap: 4px;
  background: var(--cream);
  border-radius: 12px;
  border: 1px solid var(--border-light);
  transition: background 0.17s ease, transform 0.17s ease, border-color 0.17s ease;
  cursor: default;
}
.best-time-chip:hover {
  background: var(--chip-hover-bg);
  border-color: var(--pool-pale);
  transform: translateY(-2px);
}
.best-time-chip strong {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2.3rem;
  font-weight: 700;
  color: var(--pool);
  line-height: 1;
  letter-spacing: -0.02em;
}
.best-time-chip small {
  font-size: 0.67rem;
  color: var(--stone);
  letter-spacing: 0.05em;
}
.best-times-none { font-size: 0.82rem; color: var(--stone); font-style: italic; }

@media (max-width: 600px) {
  .best-times { flex-wrap: wrap; }
  .best-times-label {
    flex-direction: row; align-items: center;
    gap: 12px; width: 100%;
    min-width: unset;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 14px 20px;
  }
  .best-times-label::before { margin-bottom: 0; font-size: 1.3rem; }
  #best-times-content { width: 100%; }
  .best-time-chip strong { font-size: 1.9rem; }
}

/* ── CHART CARDS ──────────────────────────────────────── */
.chart-section { margin-bottom: 56px; }
.chart-card {
  background: var(--parchment); border: 1px solid var(--border);
  border-radius: 22px; padding: 32px 32px 24px;
}
.chart-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 16px; margin-bottom: 24px;
}
.chart-title {
  font-family: 'Cormorant Garamond', serif; font-size: 1.5rem;
  font-weight: 500; color: var(--ink); line-height: 1.15;
}
.chart-subtitle { font-size: 0.75rem; font-weight: 300; color: var(--stone); margin-top: 3px; line-height: 1.5; }
.chart-body { position: relative; }
.chart-canvas-wrap { position: relative; height: 270px; }

.chart-loader {
  position: absolute; inset: 0;
  background: var(--glass-heavy);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px; z-index: 10; transition: opacity 0.30s ease;
}
.chart-loader.soft { background: var(--glass-soft); }
.chart-loader.gone { opacity: 0; pointer-events: none; }

.spin-ring {
  width: 26px; height: 26px; border: 2px solid var(--border);
  border-top-color: var(--pool-mid); border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── HEATMAP ──────────────────────────────────────────── */
.heatmap-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.heatmap-grid {
  display: grid; gap: 3px; min-width: 480px;
  /* columns set by JS: label + 17 hour cols; rows: header + 7 day rows */
}
.heatmap-cell {
  border-radius: 3px; cursor: default;
  transition: filter 0.15s, opacity 0.15s;
  min-height: 26px;
}
.heatmap-cell:hover { filter: brightness(1.18); }
.heatmap-day-lbl {
  font-size: 0.72rem; font-weight: 400; color: var(--stone);
  display: flex; align-items: center; padding-right: 10px;
  white-space: nowrap;
}
.heatmap-day-lbl.today { font-weight: 500; color: var(--ink-mid); }
.heatmap-hour-lbl {
  font-size: 0.63rem; color: var(--stone);
  display: flex; align-items: center; justify-content: center;
  padding-bottom: 4px;
}
.heatmap-empty { opacity: 0; pointer-events: none; }
.heatmap-no-data { background: var(--border-light); opacity: 0.35; }

.heatmap-tip {
  position: fixed; z-index: 200;
  background: var(--parchment); border: 1px solid var(--border);
  border-radius: 9px; padding: 6px 11px;
  font-size: 0.74rem; font-weight: 400; color: var(--ink);
  white-space: nowrap; pointer-events: none;
  transform: translate(-50%, calc(-100% - 8px));
  opacity: 0; transition: opacity 0.1s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}
.heatmap-tip.visible { opacity: 1; }

/* ── FILTERS ──────────────────────────────────────────── */
.filters {
  display: flex; flex-wrap: wrap; gap: 20px;
  padding-bottom: 20px; margin-bottom: 22px;
  border-bottom: 1px solid var(--border-light);
}
.fg { display: flex; flex-direction: column; gap: 6px; }
.fg-label {
  font-size: 0.63rem; font-weight: 500; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--stone);
}
.fg-row { display: flex; gap: 4px; flex-wrap: wrap; }
.fbtn {
  background: transparent; border: 1px solid var(--border); color: var(--ink-mid);
  padding: 5px 13px; border-radius: 7px; cursor: pointer;
  font-size: 0.78rem; font-family: 'DM Sans', sans-serif; font-weight: 400;
  letter-spacing: 0.01em; transition: background 0.13s, border-color 0.13s, color 0.13s;
  white-space: nowrap;
}
.fbtn:hover { border-color: var(--pool-mid); color: var(--pool); }
.fbtn.on    { background: var(--ink); border-color: var(--ink); color: var(--cream); }

.fg-slider-row { display: flex; align-items: center; gap: 10px; }
.range-slider {
  -webkit-appearance: none; width: 130px; height: 3px;
  background: var(--border); border-radius: 2px; outline: none; cursor: pointer;
}
.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--pool); cursor: pointer; transition: transform 0.15s;
}
.range-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.range-slider::-moz-range-thumb {
  width: 15px; height: 15px; border: none; border-radius: 50%;
  background: var(--pool); cursor: pointer;
}
.slider-val { font-size: 0.8rem; color: var(--ink-mid); min-width: 14px; }

/* ── ENTRANCE ANIMATIONS ──────────────────────────────── */
.fade-in {
  opacity: 0; transform: translateY(18px);
  animation: fade-in 0.55s ease forwards;
}
@keyframes fade-in { to { opacity: 1; transform: none; } }
.delay-1 { animation-delay: 0.08s; }
.delay-2 { animation-delay: 0.16s; }
.delay-3 { animation-delay: 0.24s; }
.delay-4 { animation-delay: 0.32s; }
.delay-5 { animation-delay: 0.40s; }
.delay-6 { animation-delay: 0.48s; }

/* ── FOOTER ───────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border-light); padding: 22px 60px;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px;
}
.site-footer p { font-size: 0.74rem; color: var(--stone); }
#refresh-cd { font-variant-numeric: tabular-nums; }

@media (max-width: 840px) {
  .site-footer { padding: 20px 24px; }
  .chart-card  { padding: 24px 20px 18px; }
}
