/* ================================================================
   Skolkoll — Slide-based Visualization Layout
   ================================================================ */

/* ── Reset & base ─────────────────────────────────────────── */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

/* ── Slide deck (scroll-snap container) ───────────────────── */
.slide-deck {
  width: 100%;
  height: 100vh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* ── Individual slides ────────────────────────────────────── */
.slide {
  width: 100%;
  height: 100vh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.slide-content {
  width: 100%;
  max-width: 1200px;
  height: calc(100vh - 130px);
  padding: 0.5rem 2rem 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.slide-content--hero {
  justify-content: center;
  align-items: center;
  text-align: center;
  overflow-y: auto;
}

/* ── Hero slide ───────────────────────────────────────────── */
.slide-hero {
  background: linear-gradient(160deg, var(--surface) 0%, var(--brand-soft, #e0f3ed) 100%);
}

.slide-hero .eyebrow {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--brand);
  margin-bottom: 0.5rem;
}

.slide-hero h1 {
  font-family: "Sora", system-ui, sans-serif;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  color: var(--ink);
  margin: 0 0 0.75rem;
  line-height: 1.1;
}

.slide-hero .lead {
  font-size: 1.1rem;
  color: var(--ink-secondary);
  max-width: 50ch;
  margin: 0 auto 2rem;
  line-height: 1.5;
}

.viz-hero-logo {
  display: block;
  width: clamp(200px, 35vw, 380px);
  height: auto;
  margin: 0 auto 0.5rem;
}

/* ── Table of Contents grid ───────────────────────────────── */
.slide-toc {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.25rem;
  text-align: left;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.slide-toc-group h3 {
  font-family: "Sora", system-ui, sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.4rem;
}

.slide-toc-btn {
  display: block;
  width: 100%;
  padding: 0.4rem 0.65rem;
  margin-bottom: 2px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: "Sora", system-ui, sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-secondary);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  line-height: 1.35;
}

.slide-toc-btn:hover {
  background: var(--brand-soft, #e0f3ed);
  color: var(--brand-strong, #064d3e);
}

/* ── Top navigation bar ───────────────────────────────────── */
.slide-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  font-family: "Sora", system-ui, sans-serif;
  transition: opacity 0.3s ease;
}

.slide-topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.slide-logo {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: -0.01em;
}

.slide-title {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
}

.slide-topbar-center {
  display: flex;
  align-items: center;
  gap: 5px;
}

.slide-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.slide-dot:hover {
  background: var(--muted);
  transform: scale(1.3);
}

.slide-dot.active {
  background: var(--brand);
  transform: scale(1.3);
}

.slide-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.slide-topbar-link {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-secondary);
  text-decoration: none;
  transition: color 0.15s ease;
}

.slide-topbar-link:hover {
  color: var(--brand);
}

/* ── Bottom navigation ────────────────────────────────────── */
.slide-nav {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  box-shadow: var(--shadow-lg, 0 10px 25px rgba(0,0,0,0.1));
  font-family: "Sora", system-ui, sans-serif;
}

.slide-nav-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--surface-dim);
  color: var(--ink);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.slide-nav-btn:hover {
  background: var(--brand);
  color: #fff;
}

.slide-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

.slide-counter {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  min-width: 60px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ── Loading ──────────────────────────────────────────────── */
.viz-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: var(--muted);
  gap: 1rem;
}

.viz-loading.hidden { display: none; }

.viz-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Viz panels (side-by-side: text left, chart right) ───── */
.viz-panel {
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: auto 1fr;
  gap: 0 1.5rem;
  animation: rise-in var(--duration-slow, 0.4s) var(--ease-out, ease-out) both;
  overflow: hidden;
}

.viz-panel--hero {
  border: 2px solid var(--brand-muted, #b2d8ce);
  border-radius: var(--radius-lg, 12px);
  padding: 1.25rem;
  background: linear-gradient(135deg, var(--surface) 0%, var(--brand-soft, #e0f3ed) 100%);
}

/* Text column — left side, spans both rows */
.viz-panel-head {
  grid-column: 1;
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-right: 1rem;
  border-right: 1px solid var(--line, #dfe5e2);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.viz-panel-head h3 {
  margin: 0 0 0.3rem;
  font-size: 1rem;
  line-height: 1.25;
}

.viz-panel-head .muted {
  font-size: 0.78rem;
  margin: 0 0 0.5rem;
  color: var(--muted);
}

.viz-panel-head .viz-narrative {
  font-family: 'Literata', Georgia, serif;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--ink-sec, #475569);
  margin: 0;
  font-style: italic;
}

.viz-panel-head .viz-narrative strong {
  font-style: normal;
  color: var(--ink, #1e293b);
}

/* Controls row — above chart */
.viz-panel .viz-controls {
  grid-column: 2;
  grid-row: 1;
}

/* Chart — fills remaining space */
.viz-chart {
  grid-column: 2;
  grid-row: 2;
  width: 100%;
  min-height: 0;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.viz-chart svg {
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
  display: block;
}

.viz-chart .viz-legend,
.viz-chart .viz-color-legend {
  flex-shrink: 0;
}

/* ── Controls ─────────────────────────────────────────────── */
.viz-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
  min-height: 0;
}

.viz-controls:empty { display: none; }

.viz-controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.viz-controls select {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}

/* ── D3 SVG Defaults ──────────────────────────────────────── */
.viz-chart text {
  font-family: "Sora", system-ui, sans-serif;
  fill: var(--ink-secondary);
}

.viz-chart .axis text {
  font-size: 11px;
  fill: var(--muted);
}

.viz-chart .axis line,
.viz-chart .axis path {
  stroke: var(--line);
}

.viz-chart .axis-label {
  font-size: 12px;
  font-weight: 600;
  fill: var(--ink-secondary);
}

.viz-chart .grid line {
  stroke: var(--line-soft);
  stroke-dasharray: 2 3;
}

.viz-chart .grid path {
  stroke: none;
}

/* ── Tooltip ──────────────────────────────────────────────── */
.viz-tooltip {
  position: fixed;
  pointer-events: none;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 0.6rem 0.8rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--ink);
  max-width: 280px;
  opacity: 0;
  transition: opacity var(--duration-fast, 0.12s) ease;
}

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

.viz-tooltip strong {
  display: block;
  font-weight: 700;
  margin-bottom: 0.2rem;
  color: var(--ink);
}

.viz-tooltip .tt-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.viz-tooltip .tt-label { color: var(--muted); }

.viz-tooltip .tt-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ── Legend ────────────────────────────────────────────────── */
.viz-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.viz-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.viz-legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.viz-gradient-legend {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.viz-gradient-bar {
  width: 180px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid var(--line);
}

/* ── Specific chart overrides ─────────────────────────────── */

.viz-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.viz-split-label {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.bump-line {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.7;
  transition: opacity var(--duration-fast, 0.12s) ease, stroke-width var(--duration-fast, 0.12s) ease;
}

.bump-line:hover,
.bump-line.highlighted {
  opacity: 1;
  stroke-width: 4;
}

.radar-polygon {
  fill-opacity: 0.15;
  stroke-width: 2;
  transition: fill-opacity var(--duration-fast, 0.12s) ease;
}

.radar-polygon:hover {
  fill-opacity: 0.3;
}

.sankey-link {
  fill: none;
  stroke-opacity: 0.3;
  transition: stroke-opacity var(--duration-fast, 0.12s) ease;
}

.sankey-link:hover {
  stroke-opacity: 0.6;
}

.sunburst-arc {
  stroke: var(--surface);
  stroke-width: 1;
  cursor: pointer;
  transition: opacity var(--duration-fast, 0.12s) ease;
}

.sunburst-arc:hover {
  opacity: 0.8;
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 960px) {
  .viz-panel {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    gap: 0.5rem 0;
  }

  .viz-panel-head {
    grid-column: 1;
    grid-row: 1;
    border-right: none;
    border-bottom: 1px solid var(--line, #dfe5e2);
    padding-right: 0;
    padding-bottom: 0.5rem;
    overflow-y: visible;
  }

  .viz-panel .viz-controls {
    grid-column: 1;
    grid-row: 2;
  }

  .viz-chart {
    grid-column: 1;
    grid-row: 3;
  }

  .slide-content {
    padding: 0 1rem;
    height: calc(100vh - 130px);
    overflow-y: auto;
  }

  .slide-toc {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
  }

  .slide-topbar-center {
    display: none;
  }

  .viz-split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .slide-content {
    padding: 0 0.75rem;
    height: calc(100vh - 130px);
  }

  .slide-hero h1 {
    font-size: 1.75rem;
  }

  .slide-topbar-right {
    gap: 0.4rem;
  }

  .slide-topbar-link {
    font-size: 0.68rem;
  }
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
  html, body {
    overflow: visible;
    height: auto;
  }

  .slide-deck {
    overflow: visible;
    height: auto;
    scroll-snap-type: none;
  }

  .slide {
    height: auto;
    min-height: 0;
    scroll-snap-align: none;
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 2rem;
  }

  .slide-topbar,
  .slide-nav {
    display: none;
  }

  .viz-controls {
    display: none;
  }
}

/* ── Rise-in animation (fallback) ─────────────────────────── */
@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ================================================================
   Kiosk mode — ?kiosk=1
   ================================================================ */

/* Hide all interactive chrome */
.kiosk-mode .slide-topbar,
.kiosk-mode .slide-nav {
  display: none;
}

.kiosk-mode .viz-controls {
  display: none;
}

/* Give slides the full viewport since topbar/bottom nav are gone */
.kiosk-mode .slide-content {
  height: calc(100vh - 24px);
  padding-top: 1rem;
}

/* ── Progress bar (thin line at very bottom) ─────────────── */
.kiosk-progress {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(0, 0, 0, 0.06);
  z-index: 300;
}

.kiosk-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--brand, #0a6b56);
  border-radius: 0 2px 2px 0;
}

/* ── Subtle branding + slide label in bottom-right ───────── */
.kiosk-indicator {
  position: fixed;
  bottom: 10px;
  right: 16px;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: "Sora", system-ui, sans-serif;
  opacity: 0.4;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.kiosk-logo {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--brand, #0a6b56);
}

.kiosk-slide-label {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--muted, #64787e);
}

.kiosk-counter {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--muted, #64787e);
  font-variant-numeric: tabular-nums;
}

/* ── Fullscreen overlay (click to enter fullscreen) ──────── */
.kiosk-fs-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
  animation: kiosk-fade-in 0.4s ease both;
}

.kiosk-fs-overlay-inner {
  text-align: center;
  color: #fff;
  font-family: "Sora", system-ui, sans-serif;
}

.kiosk-fs-overlay-inner h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.kiosk-fs-overlay-inner p {
  font-size: 0.9rem;
  opacity: 0.7;
  margin: 0;
}

@keyframes kiosk-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Pause indicator ─────────────────────────────────────── */
.kiosk-paused-badge {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 300;
  font-family: "Sora", system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted, #64787e);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line, #dfe5e2);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.kiosk-paused-badge.visible {
  opacity: 1;
}

/* ── Drill-down link from dropdowns ────────────────────── */
.viz-drilldown {
  margin-left: 0.5rem;
  font-size: 0.78rem;
  color: var(--brand, #0a6b56);
  text-decoration: none;
  white-space: nowrap;
}
.viz-drilldown:hover {
  text-decoration: underline;
}
