/* ============================================
   R-Zero ODCV Scrollytelling - Styles
   ============================================ */

/* --- CSS Variables (R-Zero Brand) --- */
:root {
  --rz-blue: #1796ff;
  --rz-teal: #2e86ab;
  --rz-dark: #222222;
  --rz-medium: #434343;
  --rz-light: #666666;
  --rz-white: #ffffff;
  --rz-bg: #f8f9fa;
  --rz-bg-alt: #f1f5f9;
  --rz-waste-red: #ef4444;
  --rz-waste-orange: #f97316;
  --rz-savings-blue: #1796ff;
  --rz-savings-teal: #2e86ab;
  --rz-border: #e2e8f0;
  --rz-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --rz-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

  --font-primary: 'Poppins', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Menlo', 'Consolas', monospace;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-primary);
  color: var(--rz-dark);
  background: var(--rz-bg);
  line-height: 1.6;
  overflow-x: hidden;
}

/* --- Header --- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rz-border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.site-header .logo {
  height: 28px;
  width: auto;
}

.site-header .header-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--rz-medium);
  letter-spacing: 0.02em;
}

/* --- Scrollytelling Layout --- */
.scroll-container {
  margin-top: 56px; /* header height */
}

.scroll-section {
  position: relative;
  min-height: 100svh;
}

/* Sticky figure panel */
.scroll-section .graphic-panel {
  position: sticky;
  top: 56px; /* below header */
  height: calc(100svh - 56px);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: 1;
  background: var(--rz-white);
}

/* Steps that scroll over the sticky graphic */
.scroll-section .steps-container {
  position: relative;
  z-index: 2;
  pointer-events: none;
}

.scroll-section .step {
  min-height: 80svh;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 0 24px 10svh;
  pointer-events: auto;
}

.scroll-section .step:first-child {
  padding-top: 30svh;
}

.scroll-section .step:last-child {
  min-height: 50svh;
}

.step-card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--rz-border);
  border-radius: 12px;
  padding: 24px 28px;
  max-width: 380px;
  box-shadow: var(--rz-shadow);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.step-card h2 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--rz-dark);
  margin-bottom: 8px;
  line-height: 1.3;
}

.step-card h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--rz-blue);
  margin-bottom: 6px;
}

.step-card p {
  font-size: 0.875rem;
  color: var(--rz-medium);
  line-height: 1.55;
}

.step-card .highlight {
  color: var(--rz-blue);
  font-weight: 600;
}

.step-card .highlight-red {
  color: var(--rz-waste-red);
  font-weight: 600;
}

.step.is-active .step-card {
  opacity: 1;
  transform: translateY(0);
}

/* --- Graphic Panel Layouts --- */
.graphic-panel .panel-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* Building view */
.building-view {
  display: flex;
  align-items: center;
  gap: 32px;
  height: 100%;
}

.building-svg-container {
  flex: 0 0 auto;
  height: 90%;
  display: flex;
  align-items: center;
}

.building-svg {
  height: 100%;
  width: auto;
  max-height: 100%;
}

.building-info-panel {
  flex: 1;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- SVG Styles --- */
.svg-title {
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: 700;
  fill: var(--rz-dark);
}

.svg-temp-label {
  font-family: var(--font-primary);
  font-size: 11px;
  font-weight: 600;
}

.svg-temp-label.outside {
  fill: var(--rz-waste-red);
}

.svg-temp-label.supply {
  fill: var(--rz-savings-teal);
}

.svg-floor-label {
  font-family: var(--font-primary);
  font-size: 7px;
  font-weight: 500;
  fill: var(--rz-light);
}

.svg-ahu-label {
  font-family: var(--font-mono);
  font-size: 7px;
  font-weight: 600;
  fill: var(--rz-medium);
}

.svg-zone-label {
  font-family: var(--font-primary);
  font-size: 7px;
  font-weight: 500;
  fill: var(--rz-light);
}

.svg-cfm-label {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 600;
}

.airflow-particle {
  will-change: cx, opacity;
}

/* Medium building (sections 3-4) */
.medium-building {
  height: 100%;
  width: auto;
  max-height: 100%;
}

.mini-building {
  height: 100%;
  width: auto;
  max-height: 100%;
}

/* --- Dashboard Components --- */

/* Gauge */
.gauge-container {
  text-align: center;
}

.gauge-svg {
  width: 160px;
  height: 100px;
}

.gauge-label {
  font-size: 0.75rem;
  color: var(--rz-light);
  margin-top: 4px;
}

/* Counters */
.counter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.counter-card {
  background: var(--rz-white);
  border: 1px solid var(--rz-border);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  box-shadow: var(--rz-shadow);
}

.counter-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--rz-dark);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.counter-value.savings {
  color: var(--rz-savings-blue);
}

.counter-value.waste {
  color: var(--rz-waste-red);
}

.counter-unit {
  font-size: 0.75rem;
  color: var(--rz-light);
  margin-top: 2px;
}

.counter-label {
  font-size: 0.75rem;
  color: var(--rz-medium);
  margin-top: 4px;
  font-weight: 500;
}

/* --- Timeline Bar --- */
.timeline-bar {
  width: 100%;
  height: 40px;
  background: var(--rz-bg-alt);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--rz-border);
}

.timeline-progress {
  height: 100%;
  background: linear-gradient(90deg, var(--rz-teal), var(--rz-blue));
  border-radius: 8px 0 0 8px;
  transition: width 0.1s linear;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  min-width: 60px;
}

.timeline-time {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--rz-white);
  white-space: nowrap;
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.625rem;
  color: var(--rz-light);
  margin-top: 4px;
  padding: 0 4px;
}

/* --- Charts --- */
.chart-container {
  background: var(--rz-white);
  border: 1px solid var(--rz-border);
  border-radius: 10px;
  padding: 16px;
  box-shadow: var(--rz-shadow);
}

.chart-container canvas {
  width: 100% !important;
  max-height: 260px;
}

.chart-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--rz-dark);
  margin-bottom: 8px;
}

/* --- Side by Side --- */
.side-by-side {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0;
  width: 100%;
  height: 100%;
  align-items: stretch;
}

.side-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  position: relative;
}

.side-panel.baseline-side {
  background: linear-gradient(135deg, #fef2f2, #fff);
}

.side-panel.odcv-side {
  background: linear-gradient(135deg, #eff6ff, #fff);
}

.side-panel-title {
  font-size: 0.875rem;
  font-weight: 700;
  margin-bottom: 16px;
  padding: 6px 16px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.baseline-side .side-panel-title {
  background: #fecaca;
  color: var(--rz-waste-red);
}

.odcv-side .side-panel-title {
  background: #bfdbfe;
  color: var(--rz-blue);
}

.savings-divider {
  width: 140px;
  background: var(--rz-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 8px;
  border-left: 2px solid var(--rz-border);
  border-right: 2px solid var(--rz-border);
}

.savings-divider .divider-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--rz-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.savings-divider .savings-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--rz-savings-teal);
  font-variant-numeric: tabular-nums;
}

.savings-divider .savings-unit {
  font-size: 0.625rem;
  color: var(--rz-light);
}

/* --- Sparkline Container (per-AHU occupancy chart) --- */
.sparkline-container {
  height: 70px;
  width: 100%;
  position: relative;
}

/* --- Monthly Report --- */
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 900px;
}

.report-card {
  background: var(--rz-white);
  border: 1px solid var(--rz-border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  box-shadow: var(--rz-shadow);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.report-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.report-card .card-icon {
  width: 32px;
  height: 32px;
  margin: 0 auto 8px;
}

.report-card .card-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--rz-savings-teal);
  line-height: 1.2;
}

.report-card .card-unit {
  font-size: 0.75rem;
  color: var(--rz-light);
}

.report-card .card-label {
  font-size: 0.8125rem;
  color: var(--rz-medium);
  margin-top: 4px;
  font-weight: 500;
}

.report-card.highlight-card {
  border-color: var(--rz-blue);
  border-width: 2px;
  background: linear-gradient(135deg, #f0f9ff, var(--rz-white));
}

/* --- Report Flow Layout (non-sticky section 6) --- */
.report-flow {
  min-height: auto;
}

.report-flow .graphic-panel {
  display: none;
}

.report-flow-content {
  padding: 80px 24px 60px;
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.report-header {
  text-align: center;
  min-height: auto;
  padding: 0;
  display: block;
}

.report-section-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--rz-dark);
  margin-bottom: 8px;
}

.report-section-subtitle {
  font-size: 1rem;
  color: var(--rz-light);
  max-width: 600px;
  margin: 0 auto;
}

.report-explanation,
.report-bottomline {
  text-align: center;
  max-width: 700px;
  margin: 0 auto;
  min-height: auto;
  padding: 0;
  display: block;
}

.report-explanation p,
.report-bottomline p {
  font-size: 0.9375rem;
  color: var(--rz-medium);
  line-height: 1.6;
}

.report-flow .report-grid {
  min-height: auto;
  padding: 0;
  display: grid;
  pointer-events: auto;
}

.report-flow .report-charts {
  min-height: auto;
  padding: 0;
  pointer-events: auto;
}

/* CTA */
.cta-section {
  text-align: center;
  padding: 48px 24px;
  max-width: 600px;
  margin: 0 auto;
}

.cta-section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--rz-dark);
  margin-bottom: 12px;
}

.cta-section p {
  font-size: 1rem;
  color: var(--rz-medium);
  margin-bottom: 24px;
}

.cta-button {
  display: inline-block;
  background: var(--rz-blue);
  color: var(--rz-white);
  font-family: var(--font-primary);
  font-size: 1rem;
  font-weight: 600;
  padding: 14px 32px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.1s ease;
}

.cta-button:hover {
  background: #0d7ae0;
}

.cta-button:active {
  transform: scale(0.98);
}

/* --- Section Backgrounds --- */
.section-building { background: var(--rz-white); }
.section-daylife { background: var(--rz-bg); }
.section-without { background: #fffbf7; }
.section-with { background: #f0f9ff; }
.section-sidebyside { background: var(--rz-white); }
.section-report { background: var(--rz-bg); }

/* --- Stacked Panel Layout (Sections 3-4) --- */
.stacked-panel {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px;
  overflow-y: auto;
  max-height: 100%;
}

.stacked-row-compact {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

/* Prominent AHU schematic (full-width, sections 3-4) */
.ahu-prominent {
  max-width: 960px;
  max-height: 520px;
  aspect-ratio: auto;
  flex-shrink: 0;
}

/* Counter strip: 4 columns in one compact row */
.counter-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  flex-shrink: 0;
}

.counter-strip .counter-card {
  padding: 10px 8px;
}

.counter-strip .counter-value {
  font-size: 1.125rem;
}

.counter-strip .counter-unit {
  font-size: 0.6875rem;
}

.counter-strip .counter-label {
  font-size: 0.6875rem;
}

/* Sparkline container for per-AHU occupancy */
.sparkline-container {
  width: 100%;
  height: 70px;
  flex-shrink: 0;
}

.sparkline-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* --- AHU Schematic --- */
.ahu-schematic-container {
  width: 100%;
  max-width: 960px;
  aspect-ratio: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ahu-compact-container {
  max-width: 560px;
  aspect-ratio: auto;
}

.ahu-schematic {
  width: 100%;
  height: auto;
  max-height: 100%;
}

.ahu-full {
  max-width: 960px;
}

.ahu-compact {
  max-width: 560px;
}

/* AHU casing */
.ahu-casing rect {
  transition: fill 0.3s ease;
}

/* Damper blades - smooth rotation */
.oa-blade,
.ra-blade {
  transition: transform 0.4s ease-out;
  will-change: transform;
}

/* Mixing plenum gradient transition */
.mix-box {
  transition: opacity 0.3s ease;
}

/* Coil visual transitions */
.coil-bg {
  transition: opacity 0.4s ease;
}

.coil-fin {
  transition: opacity 0.3s ease;
}

.coil-tube {
  transition: opacity 0.3s ease;
}

.coil-glow-rect {
  transition: opacity 0.5s ease;
}

/* Occupant figures fade in/out */
.occupant-figure {
  transition: opacity 0.4s ease;
}

/* Space grid pattern */
.space-group line {
  pointer-events: none;
}

/* AHU selector dropdown */
.ahu-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--rz-medium);
}

.ahu-selector label {
  font-weight: 600;
  white-space: nowrap;
}

.ahu-select {
  font-family: var(--font-primary);
  font-size: 0.8125rem;
  padding: 6px 28px 6px 10px;
  border: 1px solid var(--rz-border);
  border-radius: 6px;
  background: var(--rz-white);
  color: var(--rz-dark);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M3 5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  min-width: 220px;
}

.ahu-select:focus {
  outline: 2px solid var(--rz-blue);
  outline-offset: 1px;
}

/* Supply fan blades spin animation (constant speed!) */
@keyframes fan-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.supply-fan-blades {
  animation: fan-spin 2s linear infinite;
}

/* Mini fan blades inside building tower AHU icons */
.mini-fan-blades {
  animation: fan-spin 3s linear infinite;
}

/* Temperature color utilities */
.temp-hot { color: var(--rz-waste-red); }
.temp-warm { color: var(--rz-waste-orange); }
.temp-mixed { color: #f59e0b; }
.temp-cool { color: #38bdf8; }
.temp-cold { color: var(--rz-savings-blue); }

/* Waste pulse for baseline OA labels */
@keyframes waste-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.waste-pulse {
  animation: waste-pulse 2s ease-in-out infinite;
}

/* Pulse glow animation for counter cards */
@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-color: #e2e8f0;
  }
  50% {
    box-shadow: 0 0 16px rgba(23, 150, 255, 0.35);
    border-color: #1796ff;
  }
}

.pulse-glow {
  animation: pulse-glow 1.5s ease-in-out infinite;
}

/* Condensation drop animation */
.condensation-drop {
  will-change: transform, opacity;
}

/* Exhaust particle */
.ex-particle {
  will-change: cx, cy, opacity;
}

/* OA/RA/Supply/Recirculation particles */
.oa-particle,
.ra-particle,
.sup-particle,
.recirc-particle {
  will-change: cx, cy, opacity;
}

/* --- Utility --- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.fade-in {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .site-header {
    padding: 10px 16px;
    height: 48px;
  }

  .site-header .logo {
    height: 22px;
  }

  .scroll-container {
    margin-top: 48px;
  }

  .scroll-section .graphic-panel {
    top: 48px;
    height: calc(100svh - 48px);
  }

  .step-card {
    max-width: 300px;
    padding: 16px 20px;
  }

  .step-card h2 {
    font-size: 1rem;
  }

  .step-card p {
    font-size: 0.8125rem;
  }

  .building-view {
    flex-direction: column;
    gap: 12px;
  }

  .building-svg-container {
    height: 50%;
  }

  .building-info-panel {
    max-width: 100%;
  }

  .side-by-side {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto 1fr;
  }

  .savings-divider {
    width: 100%;
    flex-direction: row;
    gap: 16px;
    border-left: none;
    border-right: none;
    border-top: 2px solid var(--rz-border);
    border-bottom: 2px solid var(--rz-border);
    padding: 12px 16px;
  }

  .report-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .report-card .card-value {
    font-size: 1.375rem;
  }

  .counter-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .ahu-schematic-container {
    max-width: 100%;
    aspect-ratio: auto;
    max-height: 360px;
  }

  .ahu-compact-container {
    max-height: 260px;
  }

  .ahu-selector {
    flex-direction: column;
    gap: 4px;
  }

  .ahu-select {
    min-width: 180px;
  }

  .stacked-row-compact {
    flex-direction: column;
    gap: 8px;
  }

  .counter-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .ahu-prominent {
    max-height: 340px;
  }
}

@media (max-width: 480px) {
  .report-grid {
    grid-template-columns: 1fr;
  }

  .counter-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .counter-grid {
    grid-template-columns: 1fr;
  }
}

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

  .airflow-particle animate {
    dur: 0.01ms;
  }

  .report-card {
    opacity: 1;
    transform: none;
  }

  .fade-in {
    opacity: 1;
    transform: none;
  }

  .supply-fan-blades {
    animation: none;
  }

  .mini-fan-blades {
    animation: none;
  }

  .condensation-drop {
    display: none;
  }

  .oa-particle,
  .ra-particle,
  .sup-particle,
  .ex-particle,
  .recirc-particle {
    display: none;
  }

  .oa-blade,
  .ra-blade {
    transition: none;
  }
}

/* --- Print --- */
@media print {
  .site-header { display: none; }
  .scroll-section .step { min-height: auto; }
  .scroll-section .graphic-panel { position: relative; height: auto; }
}
