/* Cinematic Ken Burns overlay — fullscreen image pan/zoom with crossfade */

#cinematic-overlay {
  /* fixed (not absolute) anchors to the viewport so the overlay always fills
   * the phone screen even if a future positioned ancestor is added to #main. */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  z-index: 50;
  display: none;
}

#cinematic-overlay.active {
  display: block;
}

/* BG111 A4: Skip button -- always visible, top-right corner */
.cinematic-skip-btn {
  position: absolute;
  top: 16px;
  right: 20px;
  z-index: 60;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(232, 224, 208, 0.3);
  border-radius: 4px;
  color: rgba(232, 224, 208, 0.7);
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
  padding: 5px 14px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.cinematic-skip-btn:hover {
  background: rgba(0, 0, 0, 0.8);
  color: #e8e0d0;
  border-color: rgba(232, 224, 208, 0.5);
}

/* D-0442: small EN | DE switch, top-left, faint until hovered */
.cinematic-lang-switch {
  position: absolute;
  top: 18px;
  left: 20px;
  z-index: 60;
  display: none;
  align-items: center;
  gap: 4px;
  font-family: "Courier New", Courier, monospace;
  font-size: 11px;
  color: rgba(232, 224, 208, 0.25);
  opacity: 0.45;
  transition: opacity 0.2s;
  user-select: none;
}
.cinematic-lang-switch.visible {
  display: flex;
}
.cinematic-lang-switch:hover {
  opacity: 1;
}
.cinematic-lang-btn {
  background: none;
  border: none;
  padding: 2px 3px;
  font: inherit;
  letter-spacing: 0.08em;
  color: rgba(232, 224, 208, 0.55);
  cursor: pointer;
}
.cinematic-lang-btn:hover {
  color: #e8e0d0;
}
.cinematic-lang-btn.current {
  color: #e8e0d0;
  text-decoration: underline;
  cursor: default;
}

/* Two stacked images for double-buffered crossfade */
.cinematic-frame-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  will-change: transform, opacity;
  opacity: 0;
  transition: opacity 1.5s ease-in-out;
  transform-origin: center center;
}

.cinematic-frame-img.visible {
  opacity: 1;
}

/* Text overlay at bottom with gradient backdrop */
.cinematic-text-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 48px 40px 28px;
  /* Softer bottom scrim — was 0.95/0.85/0.65/0.35/0.10; reduced so the
   * image's bottom third isn't swallowed by a near-solid black band.
   * Text readability preserved via text-shadow on .cinematic-text-content. */
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.72) 0%,
    rgba(0, 0, 0, 0.58) 20%,
    rgba(0, 0, 0, 0.38) 40%,
    rgba(0, 0, 0, 0.18) 60%,
    rgba(0, 0, 0, 0.05) 80%,
    transparent 100%
  );
  z-index: 51;
}

.cinematic-text-content {
  color: #f1ece0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  line-height: 1.7;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.95), 0 0 20px rgba(0, 0, 0, 0.8);
  /* width: 100% ensures a definite 800px block from the first typed character
   * so the left edge stays stable during typewriter reveal. Without it the
   * box is shrink-to-fit and the left edge jumps as text fills to max-width. */
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  white-space: pre-wrap;
  /* Kill line-break orphans ("... a drink. Not" with "Not" stranded at the
   * right edge, user 2026-07-18): `pretty` optimizes break points against
   * short last lines and end-of-line sentence starts. Chosen over `balance`
   * because balance re-flows the whole block on every typewriter tick;
   * pretty only tunes the tail. No-op on browsers without support. */
  text-wrap: pretty;
  /* Dark scrim panel directly behind the text block so it stays legible over
   * BRIGHT frames (e.g. the pale cream exodus image), where the bottom
   * gradient + text-shadow alone weren't enough. box-sizing keeps the 800px
   * cap stable while padding is added. */
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.5);
  padding: 22px 30px;
  border-radius: 12px;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

/* Typewriter cursor blink */
.cinematic-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: #e8e0d0;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: cinematic-blink 0.8s step-end infinite;
}

@keyframes cinematic-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Advance hint at bottom */
.cinematic-advance-hint {
  color: #aaa;
  font-size: 16px;
  text-align: center;
  margin-top: 12px;
  font-style: italic;
  opacity: 0;
  transition: opacity 0.5s ease-in;
}

.cinematic-advance-hint.visible {
  opacity: 1;
}

/* Fade-in for overlay entry */
#cinematic-overlay.entering {
  animation: cinematic-fade-in 0.8s ease-out;
}

@keyframes cinematic-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Fade-out for overlay exit */
#cinematic-overlay.exiting {
  animation: cinematic-fade-out 0.8s ease-in forwards;
}

@keyframes cinematic-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Input field at bottom of cinematic */
.cinematic-input-form {
  width: 100%;
  max-width: 800px;
  margin: 12px auto 0;
}

.cinematic-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(232, 224, 208, 0.3);
  color: #e8e0d0;
  font-family: "Courier New", Courier, monospace;
  font-size: 14px;
  padding: 6px 0;
  outline: none;
  caret-color: #e8e0d0;
}

.cinematic-input::placeholder {
  color: rgba(232, 224, 208, 0.3);
  font-style: italic;
}

.cinematic-input:focus {
  border-bottom-color: rgba(232, 224, 208, 0.5);
}

/* Mobile: the fixed 22px body text + 48/40 padding is oversized on a phone,
 * and the skip button is below a comfortable touch target. Scale them down and
 * pad controls out of the notch / home indicator (safe-area insets). */
@media (max-width: 600px) {
  .cinematic-text-overlay {
    padding: 24px 16px max(16px, env(safe-area-inset-bottom));
  }
  .cinematic-text-content {
    font-size: 16px;
    line-height: 1.5;
    padding: 14px 16px;
  }
  .cinematic-skip-btn {
    top: max(16px, env(safe-area-inset-top));
    right: max(20px, env(safe-area-inset-right));
    font-size: 15px;
    padding: 10px 18px;
  }
  .cinematic-lang-switch {
    top: max(18px, env(safe-area-inset-top));
    left: max(20px, env(safe-area-inset-left));
    font-size: 13px;
  }
  .cinematic-lang-btn {
    padding: 8px 6px;
  }
}

/* Compact laptop screens (short height): trim the cinematic body text so the
   slides don't overflow / feel oversized on a small panel. Width-based rule
   above still wins on phones. */
@media (max-height: 820px) {
  .cinematic-text-content { font-size: 18px; }
}
@media (max-height: 700px) {
  .cinematic-text-content { font-size: 16px; line-height: 1.45; }
}
