/**
 * blog/css/stage.css
 * Styles for COSYlanguages Stage Mode presentation viewer, 16:9 viewport, camera transforms,
 * spotlighting, lower-third captions, controls, word card magnifier,
 * and Teleprompter Script Mode (?script=1).
 */

body.stage-mode-active,
body.script-mode-active {
  margin: 0;
  padding: 0;
  background-color: #0b0f19;
  color: #f8fafc;
  font-family: 'Commissioner', sans-serif;
}

body.stage-mode-active {
  overflow: hidden;
}

/* Hide header, navigation, footer, and reading view wrapper in stage mode or script mode */
body.stage-mode-active header,
body.stage-mode-active footer,
body.stage-mode-active #cosy-nav,
body.stage-mode-active .nav-container,
body.stage-mode-active .nav-bar,
body.stage-mode-active .site-footer,
body.stage-mode-active .gazette-wrapper,
body.script-mode-active header,
body.script-mode-active footer,
body.script-mode-active #cosy-nav,
body.script-mode-active .nav-container,
body.script-mode-active .nav-bar,
body.script-mode-active .site-footer,
body.script-mode-active .gazette-wrapper {
  display: none !important;
}

/* 16:9 Aspect Frame Container */
.stage-frame-16-9 {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #0d1117;
  overflow: hidden;
}

/* Camera Viewport */
.stage-viewport {
  width: 90vw;
  height: 50.625vw; /* 16:9 ratio */
  max-width: 1600px;
  max-height: 900px;
  background: var(--gazette-paper-bg, #faf7f2);
  color: var(--gazette-ink-primary, #1e293b);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  position: relative;
}

/* Stage Content */
.stage-content {
  padding: 4rem;
  width: 100%;
  min-height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  transform-origin: 0 0;
  will-change: transform;
  transition: transform 0.1s linear;
}

/* Cover Art Opening Scene */
.stage-title-cover-art {
  max-width: 600px;
  max-height: 280px;
  margin: 0 auto 1.5rem auto;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.stage-title-cover-art svg {
  display: block;
  width: 100%;
  height: auto;
}

/* Stage Cards & Container */
.stage-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 2.5rem 3rem;
  margin-bottom: 3rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.06);
  transition: opacity 0.3s ease, filter 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  box-sizing: border-box;
  max-width: 100%;
  overflow-wrap: break-word;
}

.stage-title-card {
  text-align: center;
  padding: 3rem;
  background: linear-gradient(180deg, #ffffff 0%, var(--post-palette-bg, #faf7f2) 100%);
  border: 2px solid var(--post-palette-accent, #0d9488);
}

.stage-kicker {
  font-family: var(--post-font-display, 'Fraunces', serif);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--post-palette-accent, #0d9488);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 0.75rem;
}

.stage-main-title {
  font-family: var(--post-font-display, 'Fraunces', serif);
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--post-palette-text, #1e293b);
  margin: 0 0 1.25rem 0;
}

.stage-dek {
  font-family: var(--post-font-body, 'Commissioner', sans-serif);
  font-size: 1.35rem;
  color: var(--post-palette-text, #1e293b);
  opacity: 0.88;
  max-width: 850px;
  margin: 0 auto 1.5rem auto;
  line-height: 1.5;
}

.stage-byline-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  font-size: 0.95rem;
  color: var(--post-palette-text, #1e293b);
  opacity: 0.8;
}

.stage-badge-level {
  background: var(--post-palette-accent, #0d9488);
  color: #ffffff;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-weight: 800;
  font-size: 0.85rem;
}

/* Block Cards */
.stage-block {
  margin: 2.5rem 0;
}

.stage-heading-card {
  border-left: 6px solid var(--post-palette-accent, #0d9488);
  background: #ffffff;
}

.stage-heading {
  font-family: var(--post-font-display, 'Fraunces', serif);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--post-palette-text, #1e293b);
  margin: 0;
  line-height: 1.25;
}

.stage-paragraph-card {
  background: #ffffff;
}

.stage-paragraph {
  font-family: var(--post-font-body, 'Commissioner', sans-serif);
  font-size: 1.35rem;
  line-height: 1.65;
  color: var(--post-palette-text, #1e293b);
  margin: 0;
}

.stage-list-card {
  background: #ffffff;
}

.stage-list {
  font-family: var(--post-font-body, 'Commissioner', sans-serif);
  font-size: 1.25rem;
  line-height: 1.6;
  margin: 0;
  padding-left: 1.5rem;
}

.stage-list li {
  margin-bottom: 0.75rem;
}

.stage-pullquote {
  border-left: 8px solid var(--post-palette-highlight, #d69e2e);
  background: rgba(214, 158, 46, 0.08);
  padding: 2.5rem;
}

.pullquote-text {
  font-family: var(--post-font-display, 'Fraunces', serif);
  font-size: 1.75rem;
  font-style: italic;
  line-height: 1.4;
  color: var(--post-palette-text, #1e293b);
  margin: 0 0 1rem 0;
}

.pullquote-cite {
  font-family: var(--post-font-body, 'Commissioner', sans-serif);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--post-palette-accent, #0d9488);
  display: block;
  font-style: normal;
}

/* Table Cards */
.stage-table-container {
  margin: 2.5rem 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.stage-table-row-group {
  border-top: 4px solid var(--post-palette-accent, #0d9488);
  background: #ffffff;
  padding: 2rem 2.5rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.stage-table-group-header {
  margin-bottom: 1rem;
}

.stage-table-badge {
  font-family: var(--post-font-body, 'Commissioner', sans-serif);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--post-palette-accent, #0d9488);
  text-transform: uppercase;
}

.stage-table-headers {
  display: flex;
  width: 100%;
  box-sizing: border-box;
  font-family: var(--post-font-body, 'Commissioner', sans-serif);
  font-weight: 800;
  border-bottom: 2px solid var(--post-palette-accent, #0d9488);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  font-size: 1.15rem;
  color: var(--post-palette-text, #1e293b);
}

.stage-table-header {
  flex: 1;
  padding: 0 0.5rem;
}

.stage-table-row {
  display: flex;
  width: 100%;
  box-sizing: border-box;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.stage-table-row:last-child {
  border-bottom: none;
}

.stage-table-cell {
  flex: 1;
  padding: 0 0.5rem;
  font-family: var(--post-font-body, 'Commissioner', sans-serif);
  font-size: 1.2rem;
  line-height: 1.45;
  color: var(--post-palette-text, #1e293b);
  overflow-wrap: break-word;
  word-break: break-word;
}

.stage-table-cell.col-0 {
  font-weight: 700;
  color: var(--post-palette-accent, #0d9488);
}

/* Outro Card */
.stage-outro-card {
  text-align: center;
  background: linear-gradient(180deg, #ffffff 0%, var(--post-palette-bg, #faf7f2) 100%);
  border: 2px solid var(--post-palette-accent, #0d9488);
  padding: 3.5rem 3rem;
}

.stage-outro-badge {
  font-family: var(--post-font-display, 'Fraunces', serif);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--post-palette-accent, #0d9488);
  margin-bottom: 1rem;
}

.stage-outro-title {
  font-family: var(--post-font-display, 'Fraunces', serif);
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--post-palette-text, #1e293b);
  margin: 0 0 1rem 0;
}

.stage-outro-sub {
  font-family: var(--post-font-body, 'Commissioner', sans-serif);
  font-size: 1.3rem;
  color: var(--post-palette-text, #1e293b);
  opacity: 0.85;
  max-width: 650px;
  margin: 0 auto 2rem auto;
  line-height: 1.5;
}

.stage-outro-podcast-box {
  margin-bottom: 2rem;
}

.stage-outro-podcast-btn {
  display: inline-block;
  background: var(--post-palette-accent, #0d9488);
  color: #ffffff;
  font-weight: 700;
  font-size: 1.1rem;
  padding: 0.85rem 1.8rem;
  border-radius: 30px;
  text-decoration: none;
  box-shadow: 0 4px 15px rgba(13, 148, 136, 0.3);
  transition: transform 0.2s ease, background 0.2s ease;
}

.stage-outro-podcast-btn:hover {
  transform: translateY(-2px);
  background: #0f766e;
}

.stage-home-link {
  color: var(--post-palette-accent, #0d9488);
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
}

/* Spotlight Dim Effect */
.stage-spotlight-dim {
  opacity: 0.25;
  filter: blur(2px);
}

.stage-spotlight-active {
  opacity: 1;
  filter: none;
  box-shadow: 0 12px 35px rgba(13, 148, 136, 0.25);
}

/* Lower Third Captions */
.stage-lower-third {
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(8px);
  color: #ffffff;
  padding: 0.85rem 2rem;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  max-width: 80%;
  text-align: center;
  z-index: 100;
  transition: opacity 0.3s ease;
  max-height: 130px;
  overflow: hidden;
  box-sizing: border-box;
}

.lower-third-text {
  font-family: 'Commissioner', sans-serif;
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.4;
}

/* Progress Bar */
.stage-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  z-index: 101;
}

.stage-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #0d9488, #f59e0b);
  transition: width 0.3s ease;
}

/* Stage Controls Bar */
.stage-controls {
  position: absolute;
  top: 1.5rem;
  right: 2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  z-index: 102;
  transition: opacity 0.3s ease;
}

.stage-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 1rem;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.stage-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.beat-counter {
  font-size: 0.85rem;
  font-weight: 700;
  opacity: 0.8;
  padding: 0 0.5rem;
}

/* Clean Recording View Mode & Render Mode */
.hide-recording,
body.stage-render-mode #stage-controls,
body.stage-render-mode #stage-progress-bar {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

body.stage-render-mode *,
body.stage-render-mode *::before,
body.stage-render-mode *::after {
  animation-duration: 0s !important;
  transition-duration: 0s !important;
}

/* Magnified Word Card Modal for Reading Mode */
.cosy-word-magnifier-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.magnifier-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 2.5rem;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  position: relative;
  text-align: center;
}

.magnifier-close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
}

.magnifier-kicker {
  font-size: 0.75rem;
  font-weight: 800;
  color: #0d9488;
  letter-spacing: 0.1em;
}

.magnifier-word {
  font-family: 'Fraunces', serif;
  font-size: 2.5rem;
  margin: 0.5rem 0 1rem 0;
}

.magnifier-def {
  font-size: 1rem;
  opacity: 0.8;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.magnifier-link {
  display: inline-block;
  background: #0d9488;
  color: #ffffff;
  text-decoration: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 700;
  transition: background 0.2s ease;
}

.magnifier-link:hover {
  background: #0f766e;
}

/* ==========================================================================
   TELEPROMPTER SCRIPT MODE (?script=1) STYLES
   ========================================================================== */

.teleprompter-wrapper {
  min-height: 100vh;
  background: #090d16;
  color: #f1f5f9;
  display: flex;
  flex-direction: column;
  position: relative;
}

.teleprompter-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.teleprompter-back-btn {
  color: #0d9488;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  transition: color 0.2s ease;
}

.teleprompter-back-btn:hover {
  color: #14b8a6;
}

.teleprompter-title {
  font-family: 'Fraunces', serif;
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0.25rem 0;
  color: #ffffff;
}

.teleprompter-stats {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: #94a3b8;
  flex-wrap: wrap;
}

.teleprompter-badge {
  background: rgba(13, 148, 136, 0.2);
  color: #2dd4bf;
  border: 1px solid rgba(45, 212, 191, 0.3);
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.8rem;
}

/* Teleprompter Controls Bar */
.teleprompter-controls {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.ctrl-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.ctrl-group label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  font-weight: 700;
}

.btn-cluster {
  display: flex;
  align-items: center;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 2px;
}

.ctrl-val {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0 0.5rem;
  color: #f8fafc;
  min-width: 40px;
  text-align: center;
}

.tp-btn {
  background: transparent;
  border: none;
  color: #e2e8f0;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tp-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.tp-btn.active {
  background: #0d9488;
  color: #ffffff;
}

.tp-btn-primary {
  background: #0d9488;
  color: #ffffff;
}

.tp-btn-primary:hover {
  background: #0f766e;
}

.tp-btn-accent {
  background: rgba(217, 119, 6, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.tp-btn-accent:hover {
  background: rgba(217, 119, 6, 0.4);
}

/* Teleprompter Center Focus Reading Line */
.teleprompter-focus-line {
  position: fixed;
  top: 40%;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent, rgba(13, 148, 136, 0.6), transparent);
  pointer-events: none;
  z-index: 500;
}

/* Viewport & Scrolling Content */
.teleprompter-viewport {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 2rem 4rem;
  display: flex;
  justify-content: center;
}

.teleprompter-viewport.teleprompter-mirrored {
  transform: scaleX(-1);
}

.teleprompter-content {
  max-width: 900px;
  width: 100%;
  line-height: 1.6;
  font-weight: 500;
  transition: font-size 0.2s ease;
}

.teleprompter-padding-top {
  height: 25vh;
}

.teleprompter-padding-bottom {
  height: 40vh;
}

.teleprompter-beat {
  margin-bottom: 3rem;
  padding: 1.5rem 2rem;
  background: rgba(15, 23, 42, 0.6);
  border-left: 4px solid #0d9488;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.teleprompter-beat:hover {
  background: rgba(30, 41, 59, 0.8);
  border-left-color: #f59e0b;
}

.beat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: #94a3b8;
  font-family: monospace;
}

.beat-time-marker {
  color: #2dd4bf;
  font-weight: 700;
}

.beat-num-badge {
  background: rgba(255, 255, 255, 0.1);
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
}

.beat-dir-badge {
  color: #f59e0b;
  font-weight: 600;
}

.beat-ipa-badge {
  color: #a78bfa;
  font-weight: 600;
}

.beat-text {
  margin: 0;
  color: #f8fafc;
  font-size: 1em;
}

/* Foreign Language Word Highlights */
.teleprompter-foreign-word {
  background: rgba(245, 158, 11, 0.25);
  color: #fde68a;
  padding: 0 4px;
  border-radius: 3px;
  border-bottom: 2px solid #f59e0b;
}

.teleprompter-outro {
  text-align: center;
  padding: 3rem;
  color: #64748b;
  font-weight: 700;
  letter-spacing: 0.1em;
}

/* Print Styles for Teleprompter Script */
@media print {
  body.script-mode-active {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .teleprompter-header,
  .teleprompter-focus-line {
    display: none !important;
  }

  .teleprompter-viewport {
    padding: 0 !important;
    transform: none !important;
  }

  .teleprompter-beat {
    background: none !important;
    color: #000000 !important;
    border-left: 2px solid #000000 !important;
    page-break-inside: avoid;
  }

  .beat-text {
    color: #000000 !important;
  }
}

/* Reduced Motion Override */
@media (prefers-reduced-motion: reduce) {
  .stage-content,
  .stage-block,
  .stage-lower-third,
  .stage-progress-fill,
  .teleprompter-viewport {
    transition: none !important;
    animation: none !important;
  }
}

/* Stage mode: mistake-card */
.stage-mistake-card .stage-mc-wrong { color: #fb7185; }
.stage-mistake-card .stage-mc-right { color: #5eead4; font-weight: 600; }
