/* ===== Quota Watch - Electric Blue Theme ===== */

:root {
  /* Electric Blue palette */
  --eb-50:  #e6f5ff;
  --eb-100: #cce8ff;
  --eb-200: #99d1ff;
  --eb-300: #66b9ff;
  --eb-400: #33a2ff;
  --eb-500: #008aff;
  --eb-600: #006ee0;
  --eb-700: #0055b3;
  --eb-800: #003d80;
  --eb-900: #00244d;

  /* Semantic */
  --peak-fill:        rgba(160, 165, 175, 0.22);
  --peak-stroke:      #9ca3af;
  --off-peak-fill:    rgba(0, 138, 255, 0.22);
  --off-peak-stroke:  var(--eb-400);
  --surge-fill:       rgba(255, 60, 90, 0.32);
  --surge-stroke:     #ff3c5a;
  --now-line:         #ff2d55;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Spacing ladder: 4 / 8 / 12 / 16 / 24 / 32 / 48 / 64 */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  /* Radii */
  --r-1: 6px;
  --r-2: 12px;
  --r-3: 18px;

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(0,0,0,0.18);
  --shadow-2: 0 8px 24px rgba(0,0,0,0.28);
  --shadow-3: 0 24px 48px rgba(0,0,0,0.4);

  /* Layout */
  --timeline-h: 64px;
  --lane-h: 56px;
  --hours: 24;
}

/* Dark theme (default) */
:root,
[data-theme="dark"] {
  --bg-0: #050912;
  --bg-1: #0a1224;
  --bg-2: #0f1c36;
  --bg-3: #142547;
  --fg-0: #e8f1ff;
  --fg-1: #c5d6ee;
  --fg-2: #8aa3c4;
  --fg-3: #5a7396;
  --border-1: rgba(102, 185, 255, 0.18);
  --border-2: rgba(102, 185, 255, 0.34);
  --accent-glow: 0 0 24px rgba(51, 162, 255, 0.45);
  --header-grad: radial-gradient(120% 140% at 0% 0%, rgba(0,138,255,0.30), transparent 60%),
                 radial-gradient(120% 140% at 100% 0%, rgba(0,85,179,0.25), transparent 60%);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg-0: #f3f7fc;
  --bg-1: #ffffff;
  --bg-2: #e8f0fa;
  --bg-3: #d9e7f7;
  --fg-0: #001f3d;
  --fg-1: #0a3a6b;
  --fg-2: #365e8a;
  --fg-3: #6188b2;
  --border-1: rgba(0, 110, 224, 0.20);
  --border-2: rgba(0, 110, 224, 0.40);
  --peak-fill:       rgba(140, 150, 165, 0.18);
  --off-peak-fill:   rgba(0, 138, 255, 0.14);
  --surge-fill:      rgba(255, 60, 90, 0.18);
  --accent-glow: 0 0 18px rgba(0, 110, 224, 0.18);
  --header-grad: radial-gradient(120% 140% at 0% 0%, rgba(0,138,255,0.18), transparent 60%),
                 radial-gradient(120% 140% at 100% 0%, rgba(0,85,179,0.15), transparent 60%);
  color-scheme: light;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  background: var(--bg-0);
  color: var(--fg-0);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
select, input { font-family: inherit; font-size: 1rem; }

a { color: var(--eb-400); }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--eb-400);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden, .skip-link {
  position: absolute; left: -10000px; top: auto;
}
.skip-link:focus {
  left: var(--sp-4); top: var(--sp-4); padding: var(--sp-2) var(--sp-3);
  background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--r-1);
  z-index: 1000;
}

/* ===== Topbar ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-5);
  padding: var(--sp-4) var(--sp-6);
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
  border-bottom: 1px solid var(--border-1);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: var(--sp-3); }
.brand-mark {
  width: 44px; height: 44px;
  border-radius: var(--r-2);
  background: linear-gradient(135deg, var(--eb-500), var(--eb-700));
  display: grid; place-items: center;
  color: white;
  box-shadow: var(--accent-glow);
}
.brand h1 {
  font-size: 1.125rem;
  color: var(--fg-0);
}
.brand-subtitle {
  font-size: 0.78rem;
  color: var(--fg-2);
  margin-top: 2px;
}

.topbar-controls { display: flex; align-items: center; gap: var(--sp-3); }
.control { display: flex; flex-direction: column; gap: 2px; }
.control select {
  appearance: none;
  background: var(--bg-2);
  color: var(--fg-0);
  border: 1px solid var(--border-2);
  border-radius: var(--r-1);
  padding: 8px 32px 8px 12px;
  font-weight: 500;
  background-image: linear-gradient(45deg, transparent 50%, var(--eb-400) 50%),
                    linear-gradient(135deg, var(--eb-400) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  min-width: 220px;
}

.theme-toggle {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  background: var(--bg-2);
  color: var(--fg-0);
  border: 1px solid var(--border-2);
  border-radius: var(--r-1);
  padding: 8px 14px;
  font-weight: 500;
  transition: background 0.18s ease, transform 0.18s ease;
}
.theme-toggle:hover { background: var(--bg-3); }
.theme-toggle:active { transform: scale(0.98); }
.theme-icon { display: inline-flex; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark { display: none; }

/* ===== Hero ===== */
.hero {
  padding: var(--sp-7) var(--sp-6) var(--sp-5);
  background: var(--header-grad);
  border-bottom: 1px solid var(--border-1);
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--sp-6);
  align-items: center;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--eb-400);
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: var(--sp-2);
}
.hero h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  color: var(--fg-0);
  display: flex; align-items: baseline; gap: var(--sp-3);
  flex-wrap: wrap;
}
#hero-now-time {
  font-family: var(--font-mono);
  color: var(--eb-300);
  text-shadow: var(--accent-glow);
}
.hero-tz-label {
  font-size: 1rem;
  font-weight: 500;
  color: var(--fg-2);
}
.hero-summary {
  margin-top: var(--sp-3);
  font-size: 1rem;
  color: var(--fg-1);
  max-width: 60ch;
}
.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}
.hero-stat {
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
}
.hero-stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-3);
}
.hero-stat-value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--eb-300);
  margin-top: 4px;
}

@media (max-width: 720px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-stats { grid-template-columns: 1fr 1fr; }
  .topbar { flex-wrap: wrap; }
}

/* ===== Legend ===== */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-6);
  border-bottom: 1px solid var(--border-1);
  background: var(--bg-1);
}
.legend-item {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-size: 0.85rem;
  color: var(--fg-1);
}
.swatch {
  width: 22px; height: 12px;
  border-radius: 4px;
  border: 1px solid currentColor;
  display: inline-block;
}
.swatch-peak   { background: var(--peak-fill);      color: var(--peak-stroke); }
.swatch-offpeak{ background: var(--off-peak-fill);  color: var(--off-peak-stroke); }
.swatch-surge  { background: var(--surge-fill);     color: var(--surge-stroke); }
.swatch-now {
  width: 3px; height: 16px;
  background: var(--now-line);
  box-shadow: 0 0 8px var(--now-line);
  border-radius: 2px;
}

.last-updated {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 11px;
  line-height: 1.3;
  color: var(--fg-2);
  letter-spacing: 0.02em;
}
.last-updated-label {
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.08em;
  opacity: 0.7;
}
.last-updated time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-1);
  font-variant-numeric: tabular-nums;
}

/* ===== Timeline ===== */
.timeline-wrap {
  padding: var(--sp-5) var(--sp-6) var(--sp-6);
  background: var(--bg-1);
}
.timeline-scroll {
  overflow-x: auto;
  overflow-y: visible;
  padding-bottom: var(--sp-2);
}
.timeline {
  min-width: 920px;
  display: grid;
  grid-template-columns: 220px 1fr;
  row-gap: var(--sp-2);
  position: relative;
}

.timeline-hours {
  grid-column: 2;
  display: grid;
  grid-template-columns: repeat(var(--hours), 1fr);
  height: var(--timeline-h);
  border-bottom: 1px solid var(--border-2);
  position: sticky; top: 64px;
  background: var(--bg-1);
  z-index: 5;
}
.timeline-hours > .now-line {
  grid-column: 1 / -1;
  grid-row: 1;
  z-index: 6;
}
.hour-tick {
  border-left: 1px dashed var(--border-1);
  padding: 6px 6px 0;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--fg-2);
  position: relative;
}
.hour-tick:first-child { border-left: none; }
.hour-tick.major { color: var(--fg-1); font-weight: 600; }
.hour-tick .tick-num { display: block; }
.hour-tick .tick-day { font-size: 0.6rem; color: var(--fg-3); display: block; }

.provider-header {
  grid-column: 1;
  display: flex; flex-direction: column; justify-content: center;
  padding-right: var(--sp-3);
  border-right: 1px solid var(--border-2);
  background: var(--bg-1);
}
.provider-header h3 {
  font-size: 0.95rem;
  color: var(--fg-0);
}
.provider-header .provider-meta {
  font-size: 0.72rem;
  color: var(--fg-2);
  font-family: var(--font-mono);
}

.lane {
  grid-column: 2;
  position: relative;
  height: var(--lane-h);
  background:
    repeating-linear-gradient(90deg,
      transparent 0,
      transparent calc(100% / var(--hours) - 1px),
      rgba(102, 185, 255, 0.08) calc(100% / var(--hours) - 1px),
      rgba(102, 185, 255, 0.08) calc(100% / var(--hours)));
  border-radius: var(--r-1);
  overflow: hidden;
}
.lane-block {
  position: absolute;
  top: 6px; bottom: 6px;
  border-radius: 6px;
  border: 1px solid;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.lane-block:hover {
  filter: brightness(1.2);
  transform: translateY(-1px);
  z-index: 2;
}
.lane-block.peak    { background: var(--peak-fill);     color: var(--peak-stroke);     border-color: var(--peak-stroke); }
.lane-block.offpeak { background: var(--off-peak-fill); color: var(--off-peak-stroke); border-color: var(--off-peak-stroke); }
.lane-block.surge   { background: var(--surge-fill);    color: var(--surge-stroke);    border-color: var(--surge-stroke); }

.now-line {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--now-line);
  box-shadow: 0 0 12px var(--now-line);
  pointer-events: none;
  z-index: 4;
}
.now-line::before {
  content: 'NOW';
  position: absolute;
  top: -22px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: white;
  background: var(--now-line);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.now-line::after {
  content: '';
  position: absolute;
  top: -6px; left: -4px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--now-line);
  box-shadow: 0 0 12px var(--now-line);
}

/* ===== Provider cards ===== */
.provider-detail {
  padding: var(--sp-6) var(--sp-6) var(--sp-5);
  border-top: 1px solid var(--border-1);
  background: var(--bg-0);
}
.section-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}
.section-header h2 {
  font-size: 1.4rem;
  color: var(--fg-0);
}
.section-sub {
  font-size: 0.85rem;
  color: var(--fg-2);
  margin-top: var(--sp-1);
}
.search input {
  background: var(--bg-2);
  color: var(--fg-0);
  border: 1px solid var(--border-2);
  border-radius: var(--r-1);
  padding: 10px 14px;
  min-width: 260px;
}
.search input::placeholder { color: var(--fg-3); }

.provider-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: var(--sp-4);
}
.provider-card {
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  padding: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-3);
  transition: border-color 0.18s ease, transform 0.18s ease;
}
.provider-card:hover { border-color: var(--border-2); transform: translateY(-2px); }
.provider-card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-3);
}
.provider-card-head h3 { font-size: 1.05rem; color: var(--fg-0); }
.provider-card-head .badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--r-1);
  background: linear-gradient(135deg, var(--eb-500), var(--eb-700));
  color: white;
  white-space: nowrap;
  box-shadow: var(--accent-glow);
}
.provider-card-summary {
  font-size: 0.85rem;
  color: var(--fg-1);
}
.provider-card-meta {
  display: flex; flex-wrap: wrap; gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--fg-2);
}
.provider-card-meta span {
  padding: 4px 8px;
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-1);
}
.provider-card-models {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
  font-size: 0.8rem;
}
.provider-card-model {
  display: flex; flex-direction: column;
  padding: var(--sp-2);
  background: var(--bg-2);
  border-radius: var(--r-1);
  border: 1px solid var(--border-1);
}
.provider-card-model-name { font-weight: 600; color: var(--fg-0); }
.provider-card-model-price {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--eb-300);
}
.provider-card-model-price .strike {
  color: var(--fg-3);
  text-decoration: line-through;
  margin-right: 4px;
}

.provider-card-discounts {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2);
  font-size: 0.72rem;
}
.provider-card-discounts div {
  padding: 6px 8px;
  border-radius: var(--r-1);
  background: var(--bg-2);
  border: 1px solid var(--border-1);
}
.provider-card-discounts strong { color: var(--eb-300); display: block; }
.provider-card-discounts span { color: var(--fg-2); }
.provider-card-link a {
  color: var(--eb-300);
  font-size: 0.8rem;
  text-decoration: none;
  font-weight: 500;
}
.provider-card-link a:hover { text-decoration: underline; }

.provider-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.provider-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--fg-2);
  border: 1px solid var(--border-1);
}

/* ===== Calculator ===== */
.calculator {
  padding: var(--sp-6);
  border-top: 1px solid var(--border-1);
  background: var(--bg-1);
}
.calc-form {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, 1fr);
  gap: var(--sp-4);
  align-items: end;
}
.calc-field { display: flex; flex-direction: column; gap: 6px; }
.calc-field span {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-3);
}
.calc-field input, .calc-field select {
  background: var(--bg-2);
  color: var(--fg-0);
  border: 1px solid var(--border-2);
  border-radius: var(--r-1);
  padding: 10px 12px;
}
.calc-field input[type="checkbox"] {
  width: 22px; height: 22px;
  accent-color: var(--eb-500);
}
.calc-result {
  grid-column: 1 / -1;
  padding: var(--sp-4);
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-2);
  font-family: var(--font-mono);
}
.calc-result-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-3);
}
.calc-result-cell strong {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-3);
  margin-bottom: 4px;
  font-weight: 500;
}
.calc-result-cell .value { font-size: 1.1rem; color: var(--eb-300); }
.calc-result-cell.savings .value { color: #4ade80; }
.calc-result-cell.surge .value { color: var(--surge-stroke); }

@media (max-width: 720px) {
  .calc-form { grid-template-columns: 1fr 1fr; }
  .calc-result { grid-column: 1 / -1; }
}

/* ===== Footer ===== */
.page-footer {
  padding: var(--sp-5) var(--sp-6);
  border-top: 1px solid var(--border-1);
  background: var(--bg-0);
  font-size: 0.78rem;
  color: var(--fg-3);
  text-align: center;
}
.page-footer .disclaimer { margin-top: var(--sp-2); color: var(--fg-3); opacity: 0.7; }
.page-footer .credit { margin-top: var(--sp-2); }
.page-footer .credit {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  background: linear-gradient(90deg, #ff0000, #ff9900, #ffff00, #33ff00, #0099ff, #6633ff, #ff0000);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: rainbow-shimmer 4s linear infinite;
}
.page-footer .credit a {
  color: transparent;
  text-decoration: underline;
  text-decoration-color: var(--fg-3);
  text-underline-offset: 2px;
}
.nyan-cat { flex: none; animation: nyan-bob 0.6s ease-in-out infinite alternate; }
@keyframes rainbow-shimmer {
  from { background-position: 0% 0; }
  to { background-position: 300% 0; }
}
@keyframes nyan-bob {
  from { transform: translateY(2px); }
  to { transform: translateY(-2px); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
