/* ============================================
   PODCAST FLIPBOOK STORYBOOK - STYLES
   Comic-style interactive flipbook
   ============================================ */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
  /* Colors - Dark Theme */
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-page: #f5f0e1;
  --bg-page-alt: #faf7f0;

  /* Accent Colors */
  --accent-primary: #4361ee;
  --accent-secondary: #7209b7;
  --accent-highlight: #f72585;

  /* Speaker Colors */
  --rob-bubble: #3a86ff;
  --rob-bubble-light: #a2c4ff;
  --rob-text: #0a1628;
  --jennifer-bubble: #ffbe0b;
  --jennifer-bubble-light: #ffe066;
  --jennifer-text: #2d1f00;
  --speaker3-bubble: #06d6a0;
  --speaker3-text: #0a2820;
  --narrator-bubble: #6c757d;
  --narrator-text: #fff;

  /* Panel Colors */
  --panel-border: #2d2d44;
  --panel-shadow: rgba(0, 0, 0, 0.4);

  /* Typography */
  --font-comic: 'Bangers', 'Comic Sans MS', 'Chalkboard SE', cursive;
  --font-body: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Consolas', 'Monaco', monospace;

  /* Dimensions */
  --page-width: min(42vw, 380px);
  --page-height: min(75vh, 580px);
  --spine-width: 16px;
  --border-radius: 4px;

  /* Animation */
  --flip-duration: 0.6s;
  --flip-easing: cubic-bezier(0.645, 0.045, 0.355, 1);
  --hover-transition: 0.2s ease;

  /* Z-indices */
  --z-book: 1;
  --z-page-back: 10;
  --z-page-front: 20;
  --z-flipping: 100;
  --z-controls: 200;
  --z-toolbar: 300;
  --z-modal: 400;
}

/* ============================================
   CSS RESET & BASE
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: #fff;
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Background pattern */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 50%, rgba(67, 97, 238, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 50%, rgba(114, 9, 183, 0.1) 0%, transparent 50%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(255, 255, 255, 0.02) 2px,
      rgba(255, 255, 255, 0.02) 4px
    );
  pointer-events: none;
  z-index: -1;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-primary);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius);
  z-index: 9999;
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  top: 1rem;
}

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

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

  .page.flipping {
    transition: none !important;
  }
}

/* Focus styles */
:focus-visible {
  outline: 3px solid var(--accent-highlight);
  outline-offset: 2px;
}

button:focus:not(:focus-visible) {
  outline: none;
}

/* ============================================
   TOOLBAR
   ============================================ */
.toolbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(180deg, var(--bg-secondary) 0%, rgba(26, 26, 46, 0.95) 100%);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: var(--z-toolbar);
  border-bottom: 2px solid var(--panel-border);
}

.toolbar-left {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.logo {
  font-family: var(--font-comic);
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-highlight));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 1px;
}

.subtitle {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.toolbar-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.page-indicator {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.1);
  padding: 0.4rem 1rem;
  border-radius: 20px;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Mode Toggle */
.mode-toggle {
  display: flex;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 25px;
  padding: 3px;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 20px;
  transition: all var(--hover-transition);
}

.mode-btn:hover {
  color: #fff;
}

.mode-btn.active {
  background: var(--accent-primary);
  color: #fff;
}

.mode-icon {
  font-size: 1rem;
}

/* Sound Toggle Button */
.sound-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.8rem;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 20px;
  transition: all var(--hover-transition);
  margin-right: 0.75rem;
}

.sound-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.sound-btn[aria-pressed="true"] {
  background: rgba(6, 214, 160, 0.2);
  color: #06d6a0;
}

.sound-btn[aria-pressed="false"] {
  background: rgba(255, 107, 107, 0.2);
  color: #ff6b6b;
}

.sound-icon {
  font-size: 1rem;
}

.sound-label {
  font-size: 0.75rem;
}

/* ============================================
   FLIPBOOK CONTAINER
   ============================================ */
.flipbook-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 80px 1rem 100px;
}

.book-wrapper {
  perspective: 2500px;
  perspective-origin: center center;
}

/* ============================================
   BOOK STRUCTURE
   ============================================ */
.book {
  position: relative;
  width: calc(var(--page-width) * 2 + var(--spine-width));
  height: var(--page-height);
  display: flex;
  transform-style: preserve-3d;
}

.book-spine {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: var(--spine-width);
  height: 100%;
  background: linear-gradient(90deg,
    #1a1a2e 0%,
    #2d2d44 20%,
    #3d3d5c 50%,
    #2d2d44 80%,
    #1a1a2e 100%
  );
  border-radius: 2px;
  box-shadow:
    inset 0 0 10px rgba(0, 0, 0, 0.5),
    0 0 20px rgba(0, 0, 0, 0.3);
  z-index: var(--z-book);
}

/* ============================================
   PAGE STYLES
   ============================================ */
.page {
  position: absolute;
  width: var(--page-width);
  height: 100%;
  transform-style: preserve-3d;
  transition: transform var(--flip-duration) var(--flip-easing);
  cursor: pointer;
}

/* Left pages (even numbered in spread) */
.page.left-page {
  left: 0;
  transform-origin: right center;
}

/* Right pages (odd numbered in spread) */
.page.right-page {
  right: 0;
  transform-origin: left center;
}

/* Page faces */
.page-front,
.page-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  background: var(--bg-page);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.2),
    inset 0 0 30px rgba(0, 0, 0, 0.05);
}

.page-front {
  z-index: var(--z-page-front);
}

.page-back {
  transform: rotateY(180deg);
  z-index: var(--z-page-back);
}

/* Page texture overlay */
.page-front::before,
.page-back::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0px,
      transparent 1px,
      rgba(0, 0, 0, 0.02) 1px,
      rgba(0, 0, 0, 0.02) 2px
    );
  pointer-events: none;
}

/* Flipping animation */
.page.flipping-forward {
  z-index: var(--z-flipping);
  transform: rotateY(-180deg);
}

.page.flipping-backward {
  z-index: var(--z-flipping);
  transform: rotateY(0deg);
}

/* Page shadow during flip */
.page.flipping-forward::after,
.page.flipping-backward::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.2) 0%,
    transparent 20%,
    transparent 80%,
    rgba(0, 0, 0, 0.1) 100%
  );
  pointer-events: none;
}

/* Flipped state */
.page.flipped {
  transform: rotateY(-180deg);
}

/* ============================================
   PAGE CONTENT
   ============================================ */
.page-content {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Scrollbar styling */
.page-content::-webkit-scrollbar {
  width: 4px;
}

.page-content::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}

.page-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 2px;
}

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--panel-border);
}

.scene-title {
  font-family: var(--font-comic);
  font-size: 1rem;
  color: var(--bg-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  line-height: 1.2;
}

.timecode {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: #666;
  background: rgba(0, 0, 0, 0.1);
  padding: 0.2rem 0.5rem;
  border-radius: 10px;
  white-space: nowrap;
}

/* ============================================
   COMIC PANELS
   ============================================ */
.panel-container {
  margin-bottom: 0.75rem;
}

.comic-panel {
  position: relative;
  height: 100px;
  background: linear-gradient(135deg, #2d2d44 0%, #1a1a2e 100%);
  border: 3px solid var(--panel-border);
  border-radius: var(--border-radius);
  overflow: hidden;
  transform: rotate(-0.5deg);
  box-shadow:
    4px 4px 0 rgba(0, 0, 0, 0.3),
    inset 0 0 20px rgba(255, 255, 255, 0.05);
}

/* Halftone dot pattern */
.comic-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
  background-size: 4px 4px;
  pointer-events: none;
}

/* Panel type variations */
.comic-panel.studio {
  background: linear-gradient(135deg, #3a86ff 0%, #4361ee 50%, #7209b7 100%);
}

.comic-panel.street {
  background: linear-gradient(135deg, #2d2d44 0%, #495057 50%, #6c757d 100%);
}

.comic-panel.transport {
  background: linear-gradient(135deg, #f72585 0%, #b5179e 50%, #7209b7 100%);
}

.comic-panel.research {
  background: linear-gradient(135deg, #06d6a0 0%, #118ab2 50%, #073b4c 100%);
}

.comic-panel.emotional {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 50%, #c92a2a 100%);
}

.comic-panel.quiz {
  background: linear-gradient(135deg, #ffd60a 0%, #ffbe0b 50%, #fb8500 100%);
}

.comic-panel.vocab {
  background: linear-gradient(135deg, #8338ec 0%, #7209b7 50%, #560bad 100%);
}

.comic-panel.goodbye {
  background: linear-gradient(135deg, #4361ee 0%, #3a86ff 100%);
}

/* Panel caption */
.panel-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.4rem 0.6rem;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-family: var(--font-comic);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Panel icon/illustration placeholder */
.panel-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.5rem;
  opacity: 0.6;
}

/* ============================================
   DIALOGUE BUBBLES
   ============================================ */
.dialogue-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.dialogue {
  display: flex;
  gap: 0.5rem;
  animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Speaker label */
.speaker-label {
  flex-shrink: 0;
  width: 60px;
  font-family: var(--font-comic);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-top: 0.4rem;
}

.speaker-label.rob {
  color: var(--rob-bubble);
  text-align: left;
}

.speaker-label.jennifer {
  color: var(--jennifer-bubble);
  text-align: right;
}

.speaker-label.speaker3 {
  color: var(--speaker3-bubble);
  text-align: left;
}

/* Speech bubble */
.speech-bubble {
  position: relative;
  flex: 1;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.4;
  word-wrap: break-word;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.1);
}

/* Rob bubble - left aligned */
.dialogue.rob .speech-bubble {
  background: var(--rob-bubble);
  color: var(--rob-text);
  border-bottom-left-radius: 4px;
  margin-right: 60px;
}

.dialogue.rob .speech-bubble::before {
  content: '';
  position: absolute;
  left: -8px;
  bottom: 8px;
  border: 8px solid transparent;
  border-right-color: var(--rob-bubble);
  border-left: 0;
}

/* Jennifer bubble - right aligned */
.dialogue.jennifer {
  flex-direction: row-reverse;
}

.dialogue.jennifer .speech-bubble {
  background: var(--jennifer-bubble);
  color: var(--jennifer-text);
  border-bottom-right-radius: 4px;
  margin-left: 60px;
}

.dialogue.jennifer .speech-bubble::before {
  content: '';
  position: absolute;
  right: -8px;
  bottom: 8px;
  border: 8px solid transparent;
  border-left-color: var(--jennifer-bubble);
  border-right: 0;
}

/* Speaker 3 bubble */
.dialogue.speaker3 .speech-bubble {
  background: var(--speaker3-bubble);
  color: var(--speaker3-text);
  border-bottom-left-radius: 4px;
  margin-right: 60px;
  font-style: italic;
}

.dialogue.speaker3 .speech-bubble::before {
  content: '';
  position: absolute;
  left: -8px;
  bottom: 8px;
  border: 8px solid transparent;
  border-right-color: var(--speaker3-bubble);
  border-left: 0;
}

/* Narrator style */
.dialogue.narrator {
  justify-content: center;
}

.dialogue.narrator .speaker-label {
  display: none;
}

.dialogue.narrator .speech-bubble {
  background: var(--narrator-bubble);
  color: var(--narrator-text);
  text-align: center;
  max-width: 90%;
  margin: 0;
  font-style: italic;
}

.dialogue.narrator .speech-bubble::before {
  display: none;
}

/* ============================================
   VOCABULARY CHIPS
   ============================================ */
.vocab-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding-top: 0.5rem;
  border-top: 1px dashed rgba(0, 0, 0, 0.2);
}

.vocab-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: #fff;
  font-size: 0.65rem;
  font-family: var(--font-mono);
  text-transform: lowercase;
  border-radius: 12px;
  cursor: help;
  transition: transform var(--hover-transition);
}

.vocab-chip:hover {
  transform: scale(1.05);
}

/* Vocab hint tooltip - Study mode */
.vocab-hint {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  background: var(--bg-secondary);
  color: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: var(--border-radius);
  font-size: 0.7rem;
  font-family: var(--font-body);
  text-transform: none;
  white-space: nowrap;
  max-width: 200px;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.vocab-hint::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--bg-secondary);
}

/* Show hints in study mode */
body.study-mode .vocab-chip:hover .vocab-hint,
body.study-mode .vocab-chip:focus .vocab-hint {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
}

/* Hide hints in read mode */
body:not(.study-mode) .vocab-hint {
  display: none;
}

/* ============================================
   SPECIAL PAGE STYLES
   ============================================ */

/* Cover page */
.page-content.cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, #0f0f1a 100%);
  color: #fff;
  padding: 2rem;
}

.cover-title {
  font-family: var(--font-comic);
  font-size: 2rem;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-highlight));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.cover-subtitle {
  font-size: 1.2rem;
  color: var(--jennifer-bubble);
  margin-bottom: 1.5rem;
  font-weight: 600;
}

.cover-art {
  width: 150px;
  height: 150px;
  background: linear-gradient(135deg, #ff6b6b, #f72585, #7209b7);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 10px 40px rgba(247, 37, 133, 0.4);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.cover-info {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* TOC page */
.page-content.toc {
  background: var(--bg-page-alt);
}

.toc-page-title {
  font-family: var(--font-comic);
  font-size: 1.5rem;
  color: var(--bg-secondary);
  text-align: center;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.toc-list-page {
  list-style: none;
}

.toc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px dotted rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: background var(--hover-transition);
}

.toc-item:hover {
  background: rgba(67, 97, 238, 0.1);
}

.toc-item-title {
  font-size: 0.8rem;
  color: var(--bg-secondary);
}

.toc-item-page {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent-primary);
  background: rgba(67, 97, 238, 0.1);
  padding: 0.2rem 0.5rem;
  border-radius: 10px;
}

/* Back cover */
.page-content.back-cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, #0f0f1a 100%);
  color: #fff;
  padding: 2rem;
}

.back-cover-text {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  max-width: 250px;
  line-height: 1.6;
}

.back-cover-credits {
  margin-top: 1.5rem;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Recap page */
.page-content.recap {
  background: var(--bg-page-alt);
}

.recap-title {
  font-family: var(--font-comic);
  font-size: 1.2rem;
  color: var(--bg-secondary);
  text-align: center;
  margin-bottom: 1rem;
  text-transform: uppercase;
}

.recap-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.recap-item {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem;
  background: rgba(67, 97, 238, 0.05);
  border-radius: var(--border-radius);
  border-left: 3px solid var(--accent-primary);
}

.recap-term {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-primary);
  min-width: 80px;
  font-size: 0.75rem;
}

.recap-definition {
  font-size: 0.75rem;
  color: #444;
  line-height: 1.4;
}

/* ============================================
   NAVIGATION CONTROLS
   ============================================ */
.controls {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 1rem;
  z-index: var(--z-controls);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--bg-secondary);
  color: #fff;
  border: 2px solid var(--panel-border);
  border-radius: 30px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--hover-transition);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.nav-btn:hover:not(:disabled) {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
}

.nav-btn:active:not(:disabled) {
  transform: translateY(0);
}

.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.nav-icon {
  font-size: 1.1rem;
}

/* ============================================
   TOC MODAL
   ============================================ */
.toc-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
}

.toc-modal[hidden] {
  display: none;
}

.toc-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.toc-content {
  position: relative;
  width: 90%;
  max-width: 400px;
  max-height: 80vh;
  background: var(--bg-page);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--bg-secondary);
  color: #fff;
}

.toc-header h2 {
  font-family: var(--font-comic);
  font-size: 1.2rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.toc-close {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--hover-transition);
}

.toc-close:hover {
  background: var(--accent-highlight);
}

.toc-list {
  padding: 1rem;
  max-height: calc(80vh - 60px);
  overflow-y: auto;
}

.toc-list button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  cursor: pointer;
  text-align: left;
  transition: background var(--hover-transition);
  font-family: var(--font-body);
}

.toc-list button:hover {
  background: rgba(67, 97, 238, 0.1);
}

.toc-list button:last-child {
  border-bottom: none;
}

.toc-scene-title {
  font-size: 0.9rem;
  color: var(--bg-secondary);
}

.toc-scene-page {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-primary);
  background: rgba(67, 97, 238, 0.1);
  padding: 0.2rem 0.6rem;
  border-radius: 10px;
}

/* TOC Trigger button */
.toc-trigger {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  width: 50px;
  height: 50px;
  background: var(--bg-secondary);
  border: 2px solid var(--panel-border);
  border-radius: 50%;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: var(--z-controls);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--hover-transition);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.toc-trigger:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  transform: scale(1.1);
}

/* ============================================
   KEYBOARD HELP
   ============================================ */
.keyboard-help {
  position: fixed;
  bottom: 100px;
  right: 2rem;
  background: var(--bg-secondary);
  border: 2px solid var(--panel-border);
  border-radius: 12px;
  padding: 1rem;
  color: #fff;
  z-index: var(--z-controls);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.keyboard-help[hidden] {
  display: none;
}

.keyboard-help h3 {
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  color: var(--accent-primary);
}

.keyboard-help ul {
  list-style: none;
}

.keyboard-help li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.3rem 0;
  font-size: 0.8rem;
}

.keyboard-help kbd {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  min-width: 40px;
  text-align: center;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablet and below */
@media (max-width: 900px) {
  :root {
    --page-width: calc(100vw - 2rem);
    --page-height: calc(100vh - 160px);
  }

  .flipbook-container {
    padding: 60px 1rem 90px;
    min-height: 100vh;
  }

  .book-wrapper {
    perspective: none;
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .book {
    width: var(--page-width);
    height: var(--page-height);
    max-width: 500px;
    transform-style: flat;
    position: relative;
  }

  .book-spine {
    display: none;
  }

  /* Single page view - hide all pages by default */
  .page {
    position: absolute;
    width: 100% !important;
    height: 100% !important;
    left: 0 !important;
    right: 0 !important;
    top: 0 !important;
    transform: none !important;
    transform-origin: center center;
    display: none;
  }

  .page.left-page {
    display: none !important;
  }

  .page.right-page {
    width: 100% !important;
  }

  /* Only show active page */
  .page.active {
    display: block !important;
    position: relative;
    width: 100% !important;
    height: 100% !important;
  }

  .page.flipped {
    display: none !important;
  }

  /* Page faces full width */
  .page-front,
  .page-back {
    width: 100% !important;
    height: 100% !important;
    backface-visibility: visible;
  }

  .page-content {
    width: 100%;
    height: 100%;
    overflow-y: auto;
  }

  .toolbar {
    padding: 0 0.75rem;
    height: 50px;
  }

  .toolbar-left {
    flex: 1;
    min-width: 0;
  }

  .logo {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .subtitle {
    display: none;
  }

  .toolbar-center {
    position: static;
    transform: none;
    flex-shrink: 0;
  }

  .page-indicator {
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
  }

  .toolbar-right {
    flex-shrink: 0;
  }

  .mode-label {
    display: none;
  }

  .sound-label {
    display: none;
  }

  .mode-toggle {
    padding: 2px;
  }

  .mode-btn {
    padding: 0.3rem 0.5rem;
  }

  .sound-btn {
    padding: 0.3rem 0.5rem;
    margin-right: 0.4rem;
  }

  .controls {
    bottom: 1rem;
    gap: 0.75rem;
  }

  .nav-btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.85rem;
  }

  .nav-text {
    display: none;
  }

  .nav-icon {
    font-size: 1.2rem;
  }

  .toc-trigger {
    bottom: 1rem;
    left: 1rem;
    width: 44px;
    height: 44px;
    font-size: 1.3rem;
  }

  .keyboard-help {
    display: none !important;
  }

  /* Page content */
  .page-content {
    padding: 0.75rem;
  }

  .page-header {
    margin-bottom: 0.5rem;
    padding-bottom: 0.4rem;
  }

  .scene-title {
    font-size: 0.9rem;
  }

  .timecode {
    font-size: 0.65rem;
  }

  .comic-panel {
    height: 70px;
  }

  .panel-icon {
    font-size: 2rem;
  }

  .panel-caption {
    font-size: 0.65rem;
    padding: 0.3rem 0.5rem;
  }

  .dialogue-container {
    gap: 0.5rem;
  }

  .speaker-label {
    width: 50px;
    font-size: 0.6rem;
  }

  .speech-bubble {
    font-size: 0.8rem;
    padding: 0.5rem 0.6rem;
    line-height: 1.35;
  }

  .dialogue.rob .speech-bubble {
    margin-right: 50px;
  }

  .dialogue.jennifer .speech-bubble {
    margin-left: 50px;
  }

  .vocab-chip {
    font-size: 0.6rem;
    padding: 0.2rem 0.5rem;
  }

  .cover-title {
    font-size: 1.5rem;
  }

  .cover-subtitle {
    font-size: 1rem;
  }

  .cover-art {
    width: 100px;
    height: 100px;
    font-size: 3rem;
  }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .comic-panel::before {
    background-size: 3px 3px;
  }
}
/* Netlify deploy trigger -  3 фев 2026 г. 22:23:47 */
