/* 4:3 Curved Silver-Screen Picture Tube & Storyboard Reel */
.crt-bezel {
  background: linear-gradient(180deg, #1b1512 0%, #0e0b09 100%);
  padding: 0.95rem;
  border-radius: 22px;
  border: 3px solid var(--brass-mid);
  box-shadow:
    inset 0 0 24px rgba(0, 0, 0, 0.95),
    0 6px 20px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.crt-stage-shell {
  position: relative;
}

.crt-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 26px / 22px;
  overflow: hidden;
  background: #090909;
  box-shadow: inset 0 0 55px rgba(0, 0, 0, 0.88);
  isolation: isolate;
}

.crt-stage-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(100%) contrast(1.12) brightness(0.98);
  opacity: 0;
  transform: scale(1.02);
  transition: opacity 0.55s ease-out;
  will-change: opacity, transform;
  @media (prefers-reduced-motion: reduce) {
    transition: opacity 0.2s linear;
    animation: none !important;
    transform: none !important;
  }
}

.crt-stage-layer.is-active {
  opacity: 1;
}

/* Compositor-friendly Ken Burns & Sitcom Camera Blocking */
@media (prefers-reduced-motion: no-preference) {
  .crt-stage-layer.is-active.kb-zoom-slow {
    animation: kbZoomSlow 9s ease-out forwards;
  }
  .crt-stage-layer.is-active.kb-zoom-in {
    animation: kbZoomIn 10s ease-in-out forwards;
  }
  .crt-stage-layer.is-active.kb-zoom-out {
    animation: kbZoomOut 10s ease-out forwards;
  }
  .crt-stage-layer.is-active.kb-pan-right {
    animation: kbPanRight 11s ease-in-out forwards;
  }
  .crt-stage-layer.is-active.kb-pan-left-fast {
    animation: kbPanLeftFast 10s linear forwards;
  }
  .crt-stage-layer.is-active.kb-panic-shake {
    animation: kbPanicShake 0.48s ease-in-out infinite alternate;
  }
  .crt-stage-layer.is-active.kb-jolt {
    animation: kbJolt 0.65s ease-out 1 forwards;
  }
  .crt-stage-layer.is-active.kb-iris-end {
    animation: kbZoomSlow 10s ease-out forwards;
  }
}

@keyframes kbZoomSlow {
  from { transform: scale(1.01); }
  to { transform: scale(1.08); }
}
@keyframes kbZoomIn {
  from { transform: scale(1.02) translate(0, 0); }
  to { transform: scale(1.11) translate(0, -1.5%); }
}
@keyframes kbZoomOut {
  from { transform: scale(1.1); }
  to { transform: scale(1.01); }
}
@keyframes kbPanRight {
  from { transform: scale(1.08) translate(-2.2%, 0); }
  to { transform: scale(1.08) translate(2.2%, 0); }
}
@keyframes kbPanLeftFast {
  from { transform: scale(1.09) translate(2.5%, 0); }
  to { transform: scale(1.12) translate(-2.5%, -1%); }
}
@keyframes kbPanicShake {
  from { transform: scale(1.09) translate(-0.8%, -0.5%); }
  to { transform: scale(1.11) translate(0.8%, 0.6%); }
}
@keyframes kbJolt {
  0% { transform: scale(1.14) translate(0, 1.8%); }
  45% { transform: scale(1.03) translate(-1%, -0.8%); }
  100% { transform: scale(1.05) translate(0, 0); }
}

/* CRT Glass Scanlines, Vignette & Sitcom Iris Mask */
.crt-scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  background:
    radial-gradient(circle at 50% 48%, transparent 58%, rgba(0, 0, 0, 0.68) 100%),
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.03) 0px,
      rgba(255, 255, 255, 0.03) 1px,
      rgba(0, 0, 0, 0.14) 2px,
      rgba(0, 0, 0, 0.14) 3px
    );
}

.crt-fx-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.crt-fx-overlay.cocoa-burst {
  opacity: 1;
  background: radial-gradient(circle at 52% 38%, rgba(235, 232, 224, 0.34) 0%, rgba(160, 155, 145, 0.12) 42%, transparent 70%);
}

.crt-fx-overlay.belt-speed {
  opacity: 1;
  background: radial-gradient(circle at 50% 50%, transparent 64%, rgba(255, 255, 255, 0.1) 100%);
}

.crt-fx-overlay.iris-open,
.crt-fx-overlay.iris-close {
  opacity: 1;
  background: radial-gradient(circle at 50% 50%, transparent 52%, rgba(0, 0, 0, 0.86) 84%);
}

.crt-hud-top {
  position: absolute;
  top: 0.85rem;
  left: 0.95rem;
  right: 0.95rem;
  z-index: 6;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.crt-pill {
  padding: 0.28rem 0.68rem;
  border-radius: 999px;
  background: rgba(12, 12, 12, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.24);
  font-family: "Courier New", Courier, monospace;
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--phosphor-white);
  letter-spacing: 0.06em;
}

/* Closed-Caption Broadcast Subtitle Box */
.crt-caption-bar {
  position: absolute;
  left: 0.9rem;
  right: 0.9rem;
  bottom: 0.85rem;
  z-index: 6;
  padding: 0.65rem 0.95rem;
  border-radius: 12px;
  background: rgba(10, 10, 10, 0.84);
  border: 1px solid rgba(242, 240, 234, 0.26);
  backdrop-filter: blur(4px);
  text-align: center;
  min-height: 3.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.18rem;
}

.caption-speaker {
  font-family: "Courier New", Courier, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brass-bright);
}

.caption-line {
  margin: 0;
  font-size: clamp(0.92rem, 1.55vw, 1.12rem);
  line-height: 1.35;
  color: var(--phosphor-white);
}

/* Scrubber & Timecode */
.timeline-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.15rem 0.25rem 0;
}

.timeline-bar input[type="range"] {
  flex: 1;
  accent-color: var(--brass-bright);
  cursor: pointer;
}

.timecode-text {
  font-family: "Courier New", Courier, monospace;
  font-size: 0.78rem;
  color: var(--phosphor-muted);
  min-width: 92px;
  text-align: right;
}

/* 8-Shot Filmstrip Storyboard Strip */
.filmstrip-section {
  width: min(1140px, 100%);
  margin-top: 1.15rem;
  padding: 0.95rem 1.1rem;
  border-radius: 16px;
  background: rgba(24, 17, 13, 0.88);
  border: 1px solid rgba(227, 190, 108, 0.25);
}

.filmstrip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.82rem;
  color: var(--phosphor-muted);
}

.filmstrip-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(112px, 1fr));
  gap: 0.6rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.reel-card {
  appearance: none;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #120e0b;
  color: var(--cream-paper);
  text-align: left;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.reel-card.is-current {
  border-color: var(--brass-bright);
  box-shadow: 0 0 0 2px rgba(227, 190, 108, 0.35);
}

.reel-card img {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  filter: grayscale(100%) contrast(1.1);
  display: block;
}

@media (max-width: 640px) {
  .crt-hud-top {
    top: 0.5rem;
    left: 0.55rem;
    right: 0.55rem;
  }
  .crt-pill {
    font-size: 0.62rem;
    padding: 0.2rem 0.5rem;
  }
  .crt-caption-bar {
    position: static;
    margin-top: 0.55rem;
    background: rgba(16, 13, 10, 0.95);
  }
}

.reel-card-label {
  display: block;
  margin-top: 0.32rem;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Native Modal Teleplay Dialog (Modern Web Guidance compliant) */
dialog:modal {
  overscroll-behavior: contain;
  width: min(820px, 92vw);
  max-height: 86vh;
  padding: 0;
  border-radius: 16px;
  border: 2px solid var(--brass-mid);
  background: var(--cream-paper);
  color: var(--ink-dark);
  box-shadow: var(--shadow-heavy);
}

dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background-color: rgba(10, 7, 5, 0.76);
  backdrop-filter: blur(3px);
}

.teleplay-sheet {
  padding: 1.5rem 1.75rem;
  font-family: "Courier New", Courier, monospace;
}

.teleplay-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  border-bottom: 2px solid var(--ink-dark);
  padding-bottom: 0.9rem;
  margin-bottom: 1.1rem;
}

.teleplay-scene {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px dashed rgba(29, 25, 22, 0.3);
}

.teleplay-slug {
  font-weight: 700;
  text-transform: uppercase;
  margin: 0 0 0.35rem;
}

.teleplay-direction {
  font-style: italic;
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
}

.teleplay-dialogue {
  margin: 0.35rem 0 0.35rem 1.5rem;
  font-size: 0.92rem;
}
