/* ============================================================
   THE ARCHIVE — projection screen + film effects + overlay
   ============================================================ */

.screen-frame {
  position: relative;
  flex: 0 0 auto;
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  height: clamp(132px, 50vh, 720px);
  width: auto;
  max-width: 94vw;
  z-index: 10;
  padding: 14px;
  border-radius: 6px;
  background:
    linear-gradient(180deg, #2a2018 0%, #160f09 100%);
  box-shadow:
    inset 0 2px 3px rgba(255,210,150,0.18),
    inset 0 -8px 16px rgba(0,0,0,0.7),
    0 30px 60px rgba(0,0,0,0.6);
}
.screen-frame::before {
  /* tripod/stand hint */
  content: "";
  position: absolute;
  left: 50%; bottom: -2px;
  width: 60%; height: 8px;
  transform: translateX(-50%);
  background: radial-gradient(60% 100% at 50% 0%, rgba(0,0,0,0.5), transparent 70%);
}

.screen {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 3px;
  overflow: hidden;
  background: #0a0806;
  box-shadow: inset 0 0 60px rgba(0,0,0,0.9);
  container-type: size;
}

/* the matte projection surface (visible when dark) */
.screen-matte {
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(180deg, rgba(255,255,255,0.012) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, #15110d, #0c0907);
  opacity: 1;
  transition: opacity 0.6s;
}

/* warm illuminated blank state */
.screen-glow-layer {
  position: absolute; inset: 0;
  background: radial-gradient(80% 80% at 50% 45%, #f6ecd6, #d8c79e 60%, #b09c6e 100%);
  opacity: 0;
  transition: opacity 0.7s var(--ease-soft);
}
.screen[data-phase="warm"] .screen-glow-layer,
.screen[data-phase="focus"] .screen-glow-layer { opacity: 0.9; }
.screen[data-phase="playing"] .screen-glow-layer { opacity: 0; }

/* media (video or procedural placeholder) */
.screen-media {
  position: absolute; inset: 0;
  opacity: 0;
  transition: opacity 0.8s var(--ease-soft);
  filter: blur(0px);
}
.screen[data-phase="focus"] .screen-media { opacity: 0.6; filter: blur(7px) brightness(1.3); transform: scale(1.04); }
.screen[data-phase="playing"] .screen-media { opacity: 1; filter: blur(0); }
.screen-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.screen-media video.is-standby { visibility: hidden; }
.screen-media video[data-whole] { object-fit: contain; }
.screen-media video[data-side] { object-position: 80% 50%; }
/* behind a clip shown whole: its own first frame, dimmed and out of focus */
.screen-fill {
  position: absolute; inset: -6%;
  background: #0b0705 center / cover no-repeat;
  filter: blur(22px) brightness(0.36) saturate(0.85);
}

/* procedural placeholder scene — a low sun over hills on aged warm stock, so an
   empty template still reads as footage rather than a flat colour */
.film-scene {
  position: absolute; inset: -8%;
  background:
    radial-gradient(90% 70% at 62% 34%, hsla(calc(var(--tint,30) - 8), 72%, 62%, 0.5), transparent 62%),
    linear-gradient(180deg, hsl(calc(var(--tint,30) - 10), 36%, 30%) 0%, hsl(calc(var(--tint,30) - 6), 40%, 18%) 52%, hsl(var(--tint,30), 34%, 7%) 100%);
  animation: kenburns 26s ease-in-out infinite alternate;
}
.film-sun {
  position: absolute; left: 62%; top: 34%;
  width: 22cqmin; height: 22cqmin;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, hsla(calc(var(--tint,30) + 18), 95%, 86%, 0.95) 0 38%, hsla(calc(var(--tint,30) + 12), 90%, 70%, 0.35) 62%, transparent 72%);
}
.film-hills {
  position: absolute; left: 0; right: 0; bottom: 0; height: 56%;
  background-repeat: no-repeat;
  background-image:
    radial-gradient(70% 62% at 20% 100%, hsl(var(--tint,30), 44%, 7%) 98%, transparent 100%),
    radial-gradient(80% 48% at 78% 100%, hsl(calc(var(--tint,30) - 6), 40%, 10%) 98%, transparent 100%),
    radial-gradient(120% 74% at 50% 100%, hsl(calc(var(--tint,30) - 12), 36%, 15%) 98%, transparent 100%);
}
@keyframes kenburns {
  0%   { transform: scale(1) translate(-1.5%, -1%); }
  100% { transform: scale(1.08) translate(1.5%, 1%); }
}
.film-label {
  position: absolute;
  top: calc(8% + 12px); right: calc(8% + 14px);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.3em;
  color: rgba(255,240,215,0.6);
  text-transform: uppercase;
  z-index: 3;
}

/* ---- film grain ---- */
.grain {
  position: absolute; inset: -50%;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  mix-blend-mode: overlay;
  transition: opacity 0.6s;
}
.screen[data-phase="playing"] .grain { opacity: 0.32; animation: grainShift 0.5s steps(4) infinite; }
@keyframes grainShift {
  0% { transform: translate(0,0); }
  25% { transform: translate(-6%, 4%); }
  50% { transform: translate(4%, -5%); }
  75% { transform: translate(-3%, 6%); }
  100% { transform: translate(5%, -3%); }
}

/* projection bloom + flicker */
.screen-bloom {
  position: absolute; inset: 0;
  z-index: 5; pointer-events: none;
  background: radial-gradient(70% 60% at 50% 45%, rgba(255,240,210,0.18), transparent 70%);
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity 0.6s;
}
.screen[data-phase="playing"] .screen-bloom { opacity: 1; animation: bloomFlicker 5.5s ease-in-out infinite; }
@keyframes bloomFlicker {
  0%,100% { opacity: 0.9; }
  43% { opacity: 1; }
  47% { opacity: 0.7; }
  49% { opacity: 1; }
  72% { opacity: 0.85; }
  74% { opacity: 1; }
}

/* gate weave / soft vertical wobble during focus */
.screen[data-phase="focus"] .screen-media { animation: gateWeave 0.9s ease-in-out infinite; }
@keyframes gateWeave {
  0%,100% { transform: translateY(0) scale(1.04); }
  50% { transform: translateY(-1.5px) scale(1.045); }
}

/* screen vignette + texture overlay */
.screen-vig {
  position: absolute; inset: 0; z-index: 6; pointer-events: none;
  background:
    radial-gradient(120% 100% at 50% 45%, transparent 55%, rgba(0,0,0,0.55) 100%),
    repeating-linear-gradient(180deg, rgba(0,0,0,0.05) 0 2px, transparent 2px 4px);
  mix-blend-mode: multiply;
}

/* a line thrown straight onto the screen */
.screen-line {
  position: absolute; inset: 0; z-index: 8;
  display: flex; align-items: center; justify-content: center;
  padding: 0 8%;
  text-align: center; text-wrap: balance;
  font-family: var(--serif); font-weight: 300; font-style: italic;
  font-size: clamp(22px, 9cqmin, 56px);
  line-height: 1.15;
  color: var(--ivory);
  opacity: 0;
  filter: blur(5px);
  transition: opacity 0.7s var(--ease-soft), filter 0.9s var(--ease-soft);
  pointer-events: none;
}
.screen-line.show { opacity: 1; filter: blur(0); }
.screen-line.ink { color: #33210f; }

/* how far through this memory we are: a hairline, transform-only */
.screen-progress {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 9;
  height: 2px;
  background: var(--gold);
  opacity: 0.75;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.1s linear;
  pointer-events: none;
}
.screen:not([data-phase="playing"]) .screen-progress { opacity: 0; }

/* ---------- text overlay ---------- */
.overlay {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 7;
  padding: clamp(34px, 12cqh, 90px) clamp(16px, 5cqw, 44px) clamp(14px, 6cqh, 44px);
  text-align: left;
  /* footage can be any colour, so the caption brings its own dark ground */
  background: linear-gradient(0deg, rgba(10,7,5,0.94) 0%, rgba(10,7,5,0.8) 55%, rgba(10,7,5,0.42) 82%, transparent 100%);
  opacity: 0;
  transition: opacity 0.7s var(--ease-soft);
}
.overlay.show { opacity: 1; }
/* beside a clip shown whole: no dark ground needed, and nothing over the picture */
.screen[data-side] .overlay {
  right: auto; top: 0;
  width: var(--side-w);
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 0 clamp(14px, 3.4cqw, 34px) clamp(14px, 6cqh, 44px);
  background: none;
}
.overlay-num {
  font-family: var(--mono);
  font-size: clamp(9px, 2.2cqh, 11px);
  letter-spacing: 0.34em;
  color: var(--champagne);
  margin-bottom: clamp(3px, 1cqh, 6px);
}
.overlay-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(25px, 9cqh, 50px);
  line-height: 1.04;
  letter-spacing: 0.01em;
  color: var(--ivory);
  margin: 0 0 clamp(3px, 1.2cqh, 8px) 0;
  text-wrap: balance;
}
.overlay-date {
  font-family: var(--mono);
  font-size: clamp(9px, 2.2cqh, 11px);
  letter-spacing: 0.26em;
  color: var(--ivory-dim);
  margin-bottom: clamp(6px, 2.2cqh, 12px);
}
.overlay-passage {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(15px, 4cqh, 22px);
  line-height: 1.34;
  color: rgba(239,231,214,0.94);
  max-width: 58ch;
  text-wrap: pretty;
}
.overlay > * {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.8s var(--ease-soft), transform 0.8s var(--ease-soft);
}
.overlay.show > * { opacity: 1; transform: translateY(0); }
.overlay.show .overlay-title { transition-delay: 0.12s; }
.overlay.show .overlay-date { transition-delay: 0.24s; }
.overlay.show .overlay-passage { transition-delay: 0.36s; }
