/**
 * style.css — Layout and component styles
 * Visual tokens imported from tokens.css
 */

@import url('tokens.css');

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

/* ---- Base ---- */
html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--size-body);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
}

/* ---- App Shell ---- */
#app {
  position: relative;
  width: var(--viewport-width);
  height: var(--viewport-height);
  overflow: hidden;
}

/* ---- Progress Bar ---- */
#progress-bar {
  position: fixed;
  top: var(--progress-top-margin);
  left: var(--slide-padding);
  right: var(--slide-padding);
  display: flex;
  gap: var(--progress-section-gap);
  z-index: 100;
  height: var(--progress-height);
}

.progress-section {
  display: flex;
  gap: var(--progress-gap);
  flex: 1;
  transition: flex var(--transition-normal);
}

.progress-section.collapsed {
  flex: 0.15;
}

.progress-section.active {
  flex: 1;
}

.progress-segment {
  flex: 1;
  height: var(--progress-height);
  background: var(--color-progress-bg);
  border-radius: 2px;
  overflow: hidden;
  transition: opacity var(--transition-fast);
}

.progress-section.collapsed .progress-segment {
  opacity: 0.5;
}

.progress-segment-fill {
  height: 100%;
  width: 0%;
  background: var(--color-progress-fill);
  border-radius: 2px;
  transition: width var(--transition-fast);
}

.progress-segment.complete .progress-segment-fill {
  width: 100%;
}

.progress-segment.current .progress-segment-fill {
  width: var(--segment-progress, 0%);
}

/* ---- Slide Area ---- */
#slide-area {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  padding: var(--slide-padding);
  padding-top: calc(var(--progress-top-margin) + var(--progress-height) + var(--space-xl));
}

.slide {
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
}

.slide.active {
  display: flex;
}

/* ---- Layout: Title ---- */
.slide.layout-title {
  justify-content: center;
  gap: var(--space-lg);
}

.slide.layout-title .slide-title {
  font-size: var(--size-title);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
}

.slide.layout-title .slide-heading {
  font-size: var(--size-heading);
  font-weight: var(--weight-regular);
  color: var(--color-text-muted);
}

/* ---- Layout: Bullets + Images ---- */
.slide.layout-bullets-left-images-right {
  flex-direction: row;
  gap: var(--space-xl);
}

.slide-content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: var(--space-md);
}

.slide-image-area {
  flex: 1;
  position: relative;
}

/* ---- Layout: Two Column Compare ---- */
.slide.layout-two-column-compare {
  flex-direction: row;
  gap: var(--space-xl);
  align-items: center;
}

.compare-column {
  flex: 1;
  padding: var(--space-xl);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--image-radius);
  text-align: center;
  font-size: var(--size-body);
  line-height: var(--leading-loose);
  overflow-wrap: break-word;
}

.compare-column strong {
  display: block;
  font-size: var(--size-heading);
  margin-bottom: var(--space-md);
}

/* Cascade reveal for compare columns */
.compare-reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--transition-reveal), transform var(--transition-reveal);
}

.compare-reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ---- Layout: Diagram ---- */
.slide.layout-diagram {
  flex-direction: column;
  gap: var(--space-lg);
}

/* ---- Layout: Workshop ---- */
.slide.layout-workshop {
  justify-content: center;
  align-items: center;
  gap: var(--space-xl);
  text-align: center;
  background: var(--color-workshop-bg);
}

.workshop-link {
  display: inline-block;
  padding: var(--space-md) var(--space-xl);
  background: var(--color-workshop-accent);
  color: var(--color-bg);
  text-decoration: none;
  border-radius: var(--image-radius);
  font-weight: var(--weight-bold);
  font-size: var(--size-body);
  transition: opacity var(--transition-fast);
}

.workshop-link:hover {
  opacity: 0.85;
}

/* ---- Layout: Video ---- */
.slide.layout-video {
  justify-content: center;
  align-items: center;
  gap: var(--space-lg);
}

.video-player {
  max-width: 80%;
  max-height: 60vh;
  border-radius: var(--image-radius);
}

/* ---- Layout: Bibliography ---- */
.slide.layout-bibliography {
  overflow-y: auto;
  gap: var(--space-md);
}

/* ---- Layout: Bibliography Two-Column ---- */
.slide.layout-bibliography-two-column {
  overflow-y: auto;
  gap: var(--space-md);
}

.bibliography-columns {
  display: flex;
  gap: var(--space-xl);
  flex: 1;
  overflow-y: auto;
}

.bibliography-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.bibliography-column-title {
  font-size: var(--size-body);
  font-weight: var(--weight-bold);
  color: var(--color-accent);
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.bibliography-item {
  font-size: var(--size-caption);
  color: var(--color-text-muted);
  line-height: var(--leading-normal);
  padding-left: var(--space-sm);
}

.bibliography-item em,
.bibliography-item strong {
  color: var(--color-text);
}

/* ---- Diagram System ---- */
.diagram-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md) 0;
}

.diagram-side-by-side {
  gap: var(--space-xl);
}

.diagram-wrapper {
  flex: 1;
  max-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.diagram-wrapper svg {
  width: 100%;
  height: auto;
  max-height: 55vh;
}

/* ---- Audio Player ---- */
.slide-audio-player {
  position: absolute;
  bottom: calc(var(--subtitle-bottom) + 80px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 85;
}

.slide-audio-player audio {
  height: 32px;
  border-radius: 16px;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

.slide-audio-player audio:hover {
  opacity: 1;
}

/* ---- Layout: Fullscreen ---- */
.slide.layout-fullscreen {
  justify-content: center;
  align-items: center;
}

.slide.layout-fullscreen .image-container {
  width: 100%;
  height: 100%;
}

/* ---- Bullets ---- */
.slide-bullets {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.slide-bullet {
  font-size: var(--size-bullet);
  line-height: var(--leading-loose);
  padding-left: var(--space-md);
  border-left: 2px solid var(--color-bullet-marker);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--transition-reveal), transform var(--transition-reveal);
}

.slide-bullet.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ---- Slide Title / Headings ---- */
.slide-title {
  font-size: var(--size-heading);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
}

.slide-heading {
  font-size: var(--size-body);
  color: var(--color-text-muted);
  line-height: var(--leading-normal);
}

/* ---- Image System ---- */
.image-container {
  position: relative;
  width: 100%;
  height: 100%;
}

.image-frame {
  opacity: 0;
  transform: scale(0.92);
  transition: opacity var(--transition-reveal), transform var(--transition-reveal);
}

.image-frame.revealed {
  opacity: 1;
  transform: scale(1);
}

.image-frame img {
  display: block;
  max-width: 100%;
  border-radius: var(--image-radius);
  box-shadow: var(--image-shadow);
}

.image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 200px;
  background: var(--color-image-placeholder);
  border-radius: var(--image-radius);
  color: var(--color-text-muted);
  font-size: var(--size-caption);
}

/* Layout: columns */
.layout-columns-3,
.layout-columns-4 {
  display: grid;
  gap: var(--space-md);
  align-content: start;
}

.layout-columns-3 { grid-template-columns: repeat(3, 1fr); }
.layout-columns-4 { grid-template-columns: repeat(4, 1fr); }

/* Layout: clockwise */
.layout-clockwise .image-frame {
  position: absolute;
  width: var(--image-clockwise-size);
}

/* Layout: default / left-right grid */
.layout-default {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  align-content: start;
}

/* ---- Subtitle Bar ---- */
#subtitle-bar {
  position: fixed;
  bottom: var(--subtitle-bottom);
  left: 50%;
  transform: translateX(-50%);
  max-width: var(--subtitle-max-width);
  width: calc(100% - 4rem);
  padding: var(--subtitle-padding);
  background: var(--color-subtitle-bg);
  backdrop-filter: blur(12px);
  border-radius: var(--subtitle-radius);
  font-size: var(--size-subtitle);
  color: var(--color-subtitle-text);
  line-height: var(--leading-loose);
  z-index: 90;
  opacity: 1;
  transition: opacity var(--transition-normal);
}

#subtitle-bar.hidden {
  opacity: 0;
  pointer-events: none;
}

#subtitle-bar:not(.active) {
  opacity: 0;
  pointer-events: none;
}

.subtitle-word {
  opacity: 0.2;
  transition: opacity var(--transition-fast);
}

.subtitle-word.revealed {
  opacity: 1;
}

/* ---- Controls Overlay ---- */
#controls-hint {
  position: fixed;
  bottom: var(--space-sm);
  right: var(--space-md);
  font-size: var(--size-caption);
  color: var(--color-text-muted);
  opacity: 0.5;
  z-index: 80;
  pointer-events: none;
}

/* ---- Status Indicators ---- */
.status-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-surface);
  border-radius: var(--image-radius);
  font-size: var(--size-body);
  color: var(--color-text);
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: 200;
  pointer-events: none;
}

.status-toast.visible {
  opacity: 1;
}

/* ---- Section Overview (Escape key) ---- */
#section-overview {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 300;
  display: none;
  padding: var(--slide-padding);
  overflow-y: auto;
}

#section-overview.visible {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--space-lg);
  align-content: start;
}

.overview-section {
  cursor: pointer;
  padding: var(--space-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--image-radius);
  transition: border-color var(--transition-fast);
}

.overview-section:hover {
  border-color: rgba(255, 255, 255, 0.4);
}

.overview-section-title {
  font-size: var(--size-body);
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-sm);
}

.overview-section-slides {
  font-size: var(--size-caption);
  color: var(--color-text-muted);
}

/* ---- Fullscreen ---- */
:fullscreen #app {
  width: 100vw;
  height: 100vh;
}
