/* Ontario electricity rates — page styles. Tokens come from tokens.css. */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--color-bg-app);
}

.container {
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 16px;
  height: 16px;
  flex: none;
}

/* ---------- Header / hero ---------------------------------------------- */

.site-header {
  position: relative;
  overflow: hidden;
  background: var(--uos-blue);
  padding-bottom: var(--space-12);
}

/* Light-blue glow behind the hero — exact treatment from utilityos.com */
.site-header::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 62% 48% at 50% 36%, rgba(37, 163, 217, 0.30), transparent 70%);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-top: var(--space-6);
  padding-bottom: var(--space-6);
}

.logo-wrap { position: relative; display: inline-block; border-bottom: none; }

.wordmark { height: 56px; display: block; }

.logo-wrap .tm {
  position: absolute;
  bottom: 4px;
  right: -17px;
  font-size: 9px;
  font-weight: 300;
  letter-spacing: 0.03em;
  line-height: 1;
  color: rgba(255, 255, 255, 0.45);
}

.header-badge {
  font-size: var(--fs-caption);
  color: var(--color-fg-on-brand);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  white-space: nowrap;
}

.hero { padding-top: var(--space-10); }

.hero h1 {
  margin-bottom: var(--space-4);
  color: var(--color-fg-on-brand);
}

.hero-sub {
  font-size: var(--fs-h4);
  color: rgba(255, 255, 255, 0.9);
  max-width: 46ch;
  margin-bottom: var(--space-6);
}

.live-line {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
  font-size: var(--fs-body-sm);
  color: var(--color-fg-on-brand);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-pill);
  padding: 6px 14px 6px 12px;
}

/* Live dot: colour follows the current TOU period (same scale as the cards
   and legend). The white ring keeps the ultra-low blue visible on the hero. */
.live-dot {
  position: relative;
  width: 9px;
  height: 9px;
  flex: none;
  /* Optically centre on the first text line (line-height 20.3px) so the dot
     stays put when the pill wraps to two lines on narrow screens. */
  margin-top: 6px;
}

.live-dot::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  animation: live-pulse 2.8s var(--ease-standard) infinite;
}

.live-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--live-dot-color, var(--uos-green));
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.85);
}

@keyframes live-pulse {
  0%        { transform: scale(1);   opacity: 0.7; }
  70%, 100% { transform: scale(2.6); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot::before { animation: none; opacity: 0; }
}

.live-line .ll-sep { color: rgba(255, 255, 255, 0.45); }

.live-line .ll-date { color: rgba(255, 255, 255, 0.78); }

.live-line .ll-time {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ---------- Live rate cards --------------------------------------------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
  margin-top: calc(-1 * var(--space-8));
  margin-bottom: var(--space-4);
  /* The header is position:relative (for its gradient), which paints it above
     in-flow content — lift the overlapping cards back on top. */
  position: relative;
  z-index: 1;
}

.card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.rate-card {
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-top: 4px solid var(--period-color, var(--color-border));
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  /* Paper ring: the top border is the current period's colour, which can be
     the same blue as the hero it overlaps (ultra-low overnight). */
  box-shadow: 0 0 0 2px var(--color-bg-card), var(--shadow-sm);
}

.rate-card .plan-name {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}

.rate-card .price-now {
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 500;
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
  color: var(--color-fg);
}

.rate-card .price-now .unit {
  font-size: var(--fs-h4);
  font-weight: 400;
  color: var(--color-fg-muted);
  margin-left: 2px;
}

.period-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  background: var(--badge-bg, var(--uos-surface));
  color: var(--badge-fg, var(--color-fg));
}

.period-badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dot-color, currentColor);
}

.rate-card .other-rates {
  margin: 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border-soft);
  font-size: var(--fs-caption);
  color: var(--color-fg-muted);
  line-height: var(--lh-relaxed);
}

.rate-card .other-rates strong {
  color: var(--color-fg);
  font-weight: 500;
}

/* ---------- Sections ---------------------------------------------------- */

.section { margin-top: var(--space-12); }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.section-head h2 {
  margin-bottom: var(--space-2);
  position: relative;
  z-index: 0;
  color: var(--uos-blue);
  font-weight: 500;
}

/* Brand accent glyph (Ü fragment) tucked behind the first letter.
   The SVG ships white-filled, so it's applied as a mask and tinted
   with a brand token. */
.section-head h2::before {
  content: "";
  position: absolute;
  z-index: -1;
  width: 96px;
  height: 79px;
  top: -22px;
  left: -26px;
  /* Logo gradient at 16% — exact treatment from utilityos.com */
  background: linear-gradient(90deg, #13578c, var(--uos-lightblue));
  opacity: 0.16;
  -webkit-mask: url('../assets/utilityos-accent.svg') no-repeat center / contain;
  mask: url('../assets/utilityos-accent.svg') no-repeat center / contain;
}

.section-sub {
  margin: 0;
  font-size: var(--fs-body-sm);
  color: var(--color-fg-muted);
  max-width: 52ch;
}

/* ---------- Season toggle ----------------------------------------------- */

.season-toggle {
  display: inline-flex;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
}

.season-toggle button {
  font-family: var(--font-body);
  font-size: var(--fs-body-sm);
  color: var(--color-fg-muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius-pill);
  padding: 6px 16px;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}

.season-toggle button .toggle-sub {
  font-size: var(--fs-micro);
  color: inherit;
  opacity: 0.75;
  margin-left: 4px;
}

.season-toggle button[aria-selected="true"] {
  background: var(--color-accent);
  color: var(--color-fg-on-brand);
}

.season-toggle button:focus-visible {
  outline: none;
  box-shadow: var(--shadow-ring);
}

/* ---------- Legend ------------------------------------------------------ */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  margin-bottom: var(--space-4);
  font-size: var(--fs-caption);
  color: var(--color-fg-muted);
}

.legend .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend .swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

/* ---------- Schedule charts --------------------------------------------- */

.schedule-card {
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}

.schedule-card .schedule-title {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}

.schedule-card h3 { margin: 0; }

.schedule-card .schedule-note {
  font-size: var(--fs-caption);
  color: var(--color-fg-subtle);
}

.schedule-card .blurb {
  margin: 0 0 var(--space-4);
  font-size: var(--fs-body-sm);
  color: var(--color-fg-muted);
  max-width: 72ch;
}

.day-row {
  display: grid;
  grid-template-columns: 132px 1fr;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-2);
  padding-top: 16px; /* headroom for the "now" chip above the bar */
}

.day-row .day-label {
  font-size: var(--fs-caption);
  color: var(--color-fg-muted);
  text-align: right;
  line-height: var(--lh-snug);
}

.day-row .day-label .today-chip {
  display: inline-block;
  margin-top: 2px;
  font-size: var(--fs-micro);
  font-weight: 500;
  color: var(--color-accent);
}

.hour-bar {
  position: relative;
  display: flex;
  height: 44px;
}

/* 4px rounded data-ends on the outer corners; gaps stay square */
.hour-bar .segment:first-child { border-radius: 4px 0 0 4px; }
.hour-bar .segment:last-child { border-radius: 0 4px 4px 0; }

.hour-bar .segment {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  border: 0;
  padding: 0;
  cursor: default;
  font-family: var(--font-body);
}

/* 2px surface gap between adjacent fills */
.hour-bar .segment + .segment { margin-left: 2px; }

.hour-bar .segment .seg-label {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
}

.hour-bar .segment:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 3px rgba(19, 21, 23, 0.55);
}

/* ---------- Schedule clocks (TOU / ULO 24-hour dials) -------------------- */

.clock-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2) var(--space-10);
}

.clock-fig {
  flex: 1 1 240px;
  max-width: 320px;
}

.clock {
  display: block;
  width: 100%;
  height: auto;
}

/* 2px surface gap between adjacent arcs (the stroke paints in card colour) */
.clock-seg {
  stroke: var(--color-bg-card);
  stroke-width: 2;
  cursor: default;
}

.clock-seg:focus-visible {
  outline: none;
  stroke: rgba(19, 21, 23, 0.55);
  stroke-width: 3;
}

.clock-tick {
  stroke: var(--uos-line);
  stroke-width: 1.5;
}

.clock-tick.minor {
  stroke-width: 1;
  opacity: 0.6;
}

.clock-axis {
  font-family: var(--font-body);
  font-size: 10.5px;
  fill: var(--color-fg-subtle);
}

.clock-price {
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 500;
  pointer-events: none;
}

.clock-center {
  font-family: var(--font-body);
  font-size: 12.5px;
  fill: var(--color-fg-muted);
  text-anchor: middle;
}

.clock-today {
  font-family: var(--font-body);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  fill: var(--color-accent);
  text-anchor: middle;
}

.clock-now-line {
  stroke: var(--uos-ink);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

/* Paper halo keeps "now" legible when it lands on an axis label */
.clock-now-text {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  fill: var(--uos-ink);
  paint-order: stroke;
  stroke: var(--color-bg-card);
  stroke-width: 3;
  pointer-events: none;
}

.axis-row {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: var(--space-4);
}

.hour-axis {
  position: relative;
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-micro);
  color: var(--color-fg-subtle);
  padding-top: 2px;
}

/* Intermediate axis label (e.g. the tier threshold) — out of the flex flow
   so the 0 / max endpoints keep their space-between positions. */
.hour-axis .axis-tick {
  position: absolute;
  top: 2px;
  transform: translateX(-50%);
}

/* Tier 2 has no upper bound; the ∞ glyph needs a bump above micro size. */
.hour-axis .axis-infinity {
  font-size: 14px;
  line-height: 1;
}

/* Tiered threshold graphic */

.tier-bar-wrap { margin-top: var(--space-2); }

.tier-scale {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: var(--space-4);
  font-size: var(--fs-micro);
  color: var(--color-fg-subtle);
}

/* ---------- Tooltip ------------------------------------------------------ */

.chart-tooltip {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  background: var(--uos-ink);
  color: var(--color-fg-on-dark);
  font-size: var(--fs-caption);
  line-height: var(--lh-snug);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  box-shadow: var(--shadow-md);
  max-width: 260px;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-standard);
}

.chart-tooltip.visible { opacity: 1; }

.chart-tooltip .tip-title { font-weight: 500; }

.chart-tooltip .tip-sub { color: rgba(255, 255, 255, 0.75); }

/* ---------- Estimator ---------------------------------------------------- */

.estimator { padding: var(--space-6); }

.estimator-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--color-border-soft);
  margin-bottom: var(--space-6);
}

.control label,
.control .control-label {
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-fg-muted);
  margin-bottom: var(--space-2);
}

.kwh-readout {
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  font-weight: 500;
  margin-bottom: var(--space-3);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: var(--radius-pill);
  background: linear-gradient(to right, var(--color-accent) var(--fill, 20%), var(--uos-line) var(--fill, 20%));
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-bg);
  border: 2px solid var(--color-accent);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-bg);
  border: 2px solid var(--color-accent);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

input[type="range"]:focus-visible { box-shadow: var(--shadow-ring); }

.slider-scale {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-micro);
  color: var(--color-fg-subtle);
  margin-top: var(--space-2);
}

.profile-toggle {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.profile-toggle .profile-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  font-family: var(--font-body);
  font-size: var(--fs-body-sm);
  color: var(--color-fg);
  text-align: left;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-standard), background var(--dur-fast) var(--ease-standard);
}

.profile-toggle .profile-option .profile-note {
  font-size: var(--fs-caption);
  color: var(--color-fg-subtle);
}

.profile-toggle .profile-option[aria-checked="true"] {
  border-color: var(--color-accent);
  background: var(--uos-blue-30);
  color: #0e3f5a;
}

.profile-toggle .profile-option[aria-checked="true"] .profile-note {
  color: #0e3f5a;
  opacity: 0.8;
}

.profile-toggle .profile-option:focus-visible {
  outline: none;
  box-shadow: var(--shadow-ring);
}

.estimator-results {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.result-row {
  display: grid;
  grid-template-columns: 160px 1fr 110px;
  align-items: center;
  gap: var(--space-4);
  /* Tall enough for the two-line plan label with the "Lowest cost" chip, so
     rows don't shift as the chip moves between plans. */
  min-height: 44px;
}

.result-row .result-plan {
  font-size: var(--fs-body-sm);
  color: var(--color-fg);
  text-align: right;
  line-height: var(--lh-snug);
}

.result-row .cheapest-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  font-size: var(--fs-micro);
  font-weight: 500;
  color: #3d5f12;
  background: var(--uos-green-30);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
}

.result-row .bar-track { position: relative; height: 20px; }

.result-row .cost-bar {
  height: 100%;
  border-radius: 0 4px 4px 0;
  background: var(--color-accent);
  min-width: 2px;
  transition: width var(--dur-slow) var(--ease-emphasis);
}

.result-row .result-value {
  font-family: var(--font-display);
  font-size: var(--fs-h4);
  font-weight: 500;
  white-space: nowrap;
}

.result-row .result-value .per-month {
  font-size: var(--fs-caption);
  font-weight: 400;
  color: var(--color-fg-muted);
}

.assumptions {
  margin: var(--space-5) 0 0;
  font-size: var(--fs-caption);
  color: var(--color-fg-subtle);
  max-width: 78ch;
}

/* ---------- Footer ------------------------------------------------------- */

.site-footer {
  margin-top: var(--space-16);
  padding: var(--space-8) 0 var(--space-10);
  background: var(--uos-blue);
  font-size: var(--fs-body-sm);
  color: rgba(255, 255, 255, 0.85);
  text-align: center;
}

.site-footer a {
  color: var(--color-fg-on-brand);
  border-bottom-color: rgba(255, 255, 255, 0.4);
}

.site-footer a:hover {
  color: var(--color-fg-on-brand);
  border-bottom-color: currentColor;
}

.site-footer .fine {
  margin: 0;
  font-size: var(--fs-caption);
  color: rgba(255, 255, 255, 0.65);
}

.site-footer .copyright {
  margin-top: var(--space-4);
}

/* Icon mark above the footer text — exact treatment from utilityos.com */
.site-footer a.footer-mark-wrap {
  display: block;
  position: relative;
  width: 62px;
  margin: 0 auto 30px;
  border-bottom: none;
}

.site-footer .footer-mark {
  display: block;
  width: 62px;
  height: 90px;
  background: rgba(255, 255, 255, 0.9);
  -webkit-mask: url('../assets/UtilityOS_Icon_4C.svg') no-repeat center / contain;
  mask: url('../assets/UtilityOS_Icon_4C.svg') no-repeat center / contain;
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.28));
}

.site-footer .footer-mark-wrap::after {
  content: "\2122";
  position: absolute;
  bottom: 2px;
  right: -16px;
  font-size: 15px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1;
}

/* ---------- Responsive ---------------------------------------------------- */

@media (max-width: 860px) {
  .card-grid { grid-template-columns: 1fr; margin-top: calc(-1 * var(--space-6)); }
  .estimator-controls { grid-template-columns: 1fr; gap: var(--space-6); }
  .result-row { grid-template-columns: 100px 1fr 90px; }
  .result-row .result-plan { text-align: left; }
}

@media (max-width: 560px) {
  .container { padding-left: var(--space-4); padding-right: var(--space-4); }
  .day-row, .axis-row, .tier-scale { grid-template-columns: 1fr; gap: var(--space-1); }
  .day-row .day-label { text-align: left; }
  .wordmark { height: 36px; }
  .header-badge { white-space: normal; }
  .hero h1 { font-size: var(--fs-h2); }
  .rate-card .price-now { font-size: 36px; }
  .hour-bar .segment .seg-label { display: none; } /* tooltip + cards still carry prices */
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
