/* ==========================================================================
   Baige · Reminiscence — Large/Medium Format Film & Prism Flare Aesthetic
   Inspired by "Home - Patterns ft. @wisteriairoha" (vclaylien)
   ========================================================================== */

:root {
  --void: #0b0a09;
  --film-base: #100e0c;
  --gold-script: #ebd678;
  --gold-serif: #cbb982;
  --ivory: #efe7d6;
  --ivory-muted: rgba(239, 231, 214, 0.46);
  --rebate-orange: #e47232;

  --font-script-en: 'Alex Brush', 'Brush Script MT', cursive;
  --font-serif-en: 'Cormorant Garamond', 'Georgia', serif;
  --font-serif-cn: 'Noto Serif SC', 'Songti SC', 'STSong', serif;
  --font-hand-cn: 'Zhi Mang Xing', 'Kaiti SC', 'STKaiti', cursive;
  --font-rebate: 'JetBrains Mono', ui-monospace, monospace;

  --ease-soft: cubic-bezier(0.22, 1, 0.36, 1);
  --beat: 0;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--void);
  color: var(--ivory);
  font-family: var(--font-serif-cn);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* ---------- Ambient Canvases ---------- */
#flare-canvas,
#grain-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#flare-canvas {
  z-index: 52;
  mix-blend-mode: screen;
}

#grain-canvas {
  z-index: 56;
  opacity: 0.075;
  mix-blend-mode: overlay;
}

/* ---------- Signature Rainbow Scanline Prism Diffraction Flare (demo2 / demo5) ---------- */
.prism-layer {
  position: fixed;
  inset: 0;
  z-index: 54;
  pointer-events: none;
  overflow: hidden;
}

.prism-flare {
  position: absolute;
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity 1.8s var(--ease-soft), transform 4.5s ease-in-out;
  /* Horizontal raster scanlines + spectral dispersion (royal blue -> cyan -> yellow -> vermilion) like demo2 / demo5 */
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.96) 0px,
      rgba(255, 255, 255, 0.96) 1.5px,
      rgba(0, 0, 0, 0.12) 1.5px,
      rgba(0, 0, 0, 0.12) 3.6px
    ),
    radial-gradient(
      ellipse 58% 44% at 52% 54%,
      rgba(246, 218, 108, 0.62) 0%,
      rgba(92, 206, 248, 0.56) 34%,
      rgba(68, 118, 245, 0.44) 56%,
      rgba(232, 104, 48, 0.24) 72%,
      transparent 92%
    );
  background-blend-mode: multiply, screen;
  filter: blur(1.2px) saturate(1.28);
  mask-image: radial-gradient(ellipse 56% 42% at 52% 54%, #000 8%, rgba(0, 0, 0, 0.52) 44%, transparent 74%);
  -webkit-mask-image: radial-gradient(ellipse 56% 42% at 52% 54%, #000 8%, rgba(0, 0, 0, 0.52) 44%, transparent 74%);
}

.prism-br {
  right: -8vw;
  bottom: -9vh;
  width: clamp(320px, 42vw, 640px);
  height: clamp(210px, 28vh, 380px);
  transform: scale(calc(1 + var(--beat) * 0.1));
}

.prism-tl {
  left: -9vw;
  top: -8vh;
  width: clamp(300px, 38vw, 560px);
  height: clamp(190px, 25vh, 340px);
  transform: scale(calc(1 + var(--beat) * 0.1));
}

.prism-flare.on {
  opacity: calc(0.68 + var(--beat) * 0.26);
}

/* Warm Film Shutter Flash on Cuts */
.shutter-flash {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(
    ellipse at 65% 45%,
    rgba(255, 226, 158, 0.42) 0%,
    rgba(232, 122, 54, 0.22) 45%,
    transparent 82%
  );
  mix-blend-mode: screen;
}

.shutter-flash.pulse {
  animation: shutterPulse 0.95s var(--ease-soft) forwards;
}

@keyframes shutterPulse {
  0%   { opacity: 0; }
  20%  { opacity: 0.72; }
  100% { opacity: 0; }
}

/* ---------- Authentic 120 / 4x5 Film Rebate Markings & Gate Notches ---------- */
.rebate-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px;
  height: 22px;
  font-family: var(--font-rebate);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--rebate-orange);
  text-shadow: 0 0 6px rgba(232, 108, 42, 0.62), 0 0 14px rgba(232, 82, 24, 0.28);
  opacity: 0.86;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Authentic Camera Film Gate Corner Tabs (exact match to demo1 / demo6 / demo7) */
.gate-notch {
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--void);
  z-index: 4;
  pointer-events: none;
}

.gn-tl { top: -1px; left: -1px; clip-path: polygon(0 0, 100% 0, 42% 38%, 0 100%); }
.gn-tr { top: -1px; right: -1px; clip-path: polygon(0 0, 100% 0, 100% 100%, 58% 38%); }
.gn-bl { bottom: -1px; left: -1px; clip-path: polygon(0 0, 42% 62%, 100% 100%, 0 100%); }
.gn-br { bottom: -1px; right: -1px; clip-path: polygon(58% 62%, 100% 0, 100% 100%, 0 100%); }

/* 4x5 Sheet Film Tactile Notch Code on Top-Right Edge */
.sheet-notch {
  position: absolute;
  top: -1px;
  right: 26px;
  width: 28px;
  height: 5px;
  z-index: 5;
  background: var(--void);
  clip-path: polygon(0 0, 26% 0, 34% 100%, 48% 100%, 56% 0, 72% 0, 80% 100%, 92% 100%, 100% 0);
}

/* ---------- 1. Minimalist Editorial Opening UI ("回忆") ---------- */
.cover {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: var(--void);
  transition: opacity 1.4s var(--ease-soft), visibility 1.4s var(--ease-soft);
}

.cover.out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.cover-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 34px;
  padding: 24px;
  animation: quietIn 1.6s var(--ease-soft) both;
}

.cover-gate-wrap {
  width: clamp(210px, 23vw, 295px);
  background: #080706;
  padding: 4px 10px;
  cursor: pointer;
}

.cover-aperture {
  position: relative;
  aspect-ratio: 1 / 1.04;
  overflow: hidden;
  background: #0d0b09;
}

.cover-aperture img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(1.2px) contrast(1.04) saturate(1.08) sepia(0.14) brightness(0.86);
  transform: scale(1.06);
  transition: transform 6s var(--ease-soft), filter 1.2s ease;
}

.cover-gate-wrap:hover .cover-aperture img {
  transform: scale(1.11);
  filter: blur(0.3px) contrast(1.06) saturate(1.12) sepia(0.1) brightness(0.95);
}

.cover-typo {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cover-for {
  font-family: var(--font-serif-en);
  font-size: 13px;
  letter-spacing: 0.28em;
  color: var(--gold-serif);
  opacity: 0.78;
  margin-bottom: 4px;
}

.cover-script {
  font-family: var(--font-script-en);
  font-weight: 400;
  font-size: clamp(2.8rem, 5.6vw, 4.3rem);
  color: var(--gold-script);
  line-height: 1.05;
  margin-bottom: 26px;
  text-shadow: 0 0 28px rgba(235, 214, 120, 0.24);
}

/* Minimalist "回忆" Trigger (No AI Box!) */
.enter-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 8px 20px;
  color: var(--ivory);
}

.enter-cn {
  font-family: var(--font-serif-cn);
  font-weight: 300;
  font-size: 17px;
  letter-spacing: 0.55em;
  padding-left: 0.55em;
  color: var(--ivory);
  transition: color 0.45s ease, text-shadow 0.45s ease;
}

.enter-line {
  width: 28px;
  height: 1px;
  background: rgba(235, 214, 120, 0.45);
  transition: width 0.55s var(--ease-soft), background 0.45s ease;
}

.enter-en {
  font-family: var(--font-serif-en);
  font-style: italic;
  font-size: 12px;
  letter-spacing: 0.24em;
  color: rgba(203, 185, 130, 0.58);
  transition: color 0.45s ease;
}

.enter-btn:hover .enter-cn {
  color: var(--gold-script);
  text-shadow: 0 0 18px rgba(235, 214, 120, 0.38);
}

.enter-btn:hover .enter-line {
  width: 72px;
  background: var(--gold-script);
}

.enter-btn:hover .enter-en {
  color: var(--gold-serif);
}

/* ---------- 2. Main MV Cinema Stage & 3 Film Gate Modes ---------- */
.cinema {
  position: fixed;
  inset: 0;
  z-index: 10;
  transition: opacity 1.5s var(--ease-soft);
}

.cinema.dimmed {
  opacity: 0;
  pointer-events: none;
}

.frame-stage {
  position: absolute;
  inset: 0;
}

.frame-slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 1.35s var(--ease-soft);
  pointer-events: none;
}

.frame-slide.active {
  opacity: 1;
}

/* Mode A: Centered Intimate Medium-Format Gate (demo1 / 01:08) */
.frame-slide.gate-sm .lf-holder {
  width: clamp(250px, 29vw, 410px);
}

.frame-slide.gate-sm .lf-aperture {
  aspect-ratio: 1 / 1.02;
}

/* Mode B: Right-Anchored Large-Format Gate (demo6 / demo7 / 00:40 / 02:56) */
.frame-slide.gate-right {
  justify-content: flex-start;
  padding-left: clamp(24px, 34vw, 560px);
}

.frame-slide.gate-right .lf-holder.landscape {
  width: clamp(320px, 52vw, 760px);
}

.frame-slide.gate-right .lf-holder.portrait {
  width: clamp(260px, 36vw, 480px);
}

.frame-slide.gate-right .lf-holder.landscape .lf-aperture {
  aspect-ratio: 4 / 3.1;
}

.frame-slide.gate-right .lf-holder.portrait .lf-aperture {
  aspect-ratio: 4 / 4.8;
}

/* Mode C: Full-Bleed Cinema Immersion (demo3 / demo5 / 01:36) */
.frame-slide.full-bleed .lf-holder {
  width: 100vw;
  height: 100vh;
  padding: 0;
  background: transparent;
}

.frame-slide.full-bleed .rebate-bar,
.frame-slide.full-bleed .gate-notch,
.frame-slide.full-bleed .sheet-notch,
.frame-slide.full-bleed .lf-mood {
  display: none;
}

.frame-slide.full-bleed .lf-aperture {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
}

/* Physical Film Holder & Soft Focus-Pull Halation */
.lf-holder {
  position: relative;
  background: #080706;
  padding: 4px 12px 6px;
}

.lf-aperture {
  position: relative;
  overflow: hidden;
  background: #0c0a09;
}

.lf-aperture img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: blur(2.4px) contrast(1.03) saturate(1.08) sepia(0.12) brightness(0.86);
  transform: scale(1.08);
  transition: transform 9s linear, filter 1.6s var(--ease-soft);
}

.frame-slide.active .lf-aperture img {
  filter: blur(0.25px) contrast(1.04) saturate(1.1) sepia(0.1) brightness(0.92);
  transform: scale(1.02);
}

.frame-slide.full-bleed.active .lf-aperture img {
  filter: blur(1.1px) contrast(1.03) saturate(1.12) sepia(0.12) brightness(0.76);
}

/* Warm Halation Rim Inside Film Gate */
.lf-aperture::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 22% 18%, rgba(255, 196, 118, 0.18), transparent 55%),
    radial-gradient(circle at 50% 50%, transparent 56%, rgba(8, 7, 6, 0.42) 100%);
  mix-blend-mode: screen;
}

.lf-mood {
  position: absolute;
  right: 12px;
  bottom: -22px;
  font-family: var(--font-serif-cn);
  font-weight: 200;
  font-size: 11.5px;
  letter-spacing: 0.28em;
  color: rgba(239, 231, 214, 0.38);
}

/* ---------- Minimalist Intro / Interlude Whispers (demo1 / demo3 / demo5) ---------- */
.whisper-box {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  opacity: 0;
  transition: opacity 1.1s var(--ease-soft);
}

.whisper-box.on {
  opacity: 1;
}

.whisper-box.below-gate {
  justify-content: flex-end;
  padding-bottom: clamp(42px, 11vh, 110px);
}

.whisper-script {
  font-family: var(--font-script-en);
  font-size: clamp(3.4rem, 8.2vw, 6.6rem);
  color: var(--gold-script);
  line-height: 1.02;
  text-shadow: 0 0 34px rgba(235, 214, 120, 0.34);
}

.whisper-serif {
  font-family: var(--font-serif-en);
  font-size: clamp(0.92rem, 1.45vw, 1.2rem);
  letter-spacing: 0.22em;
  color: var(--gold-serif);
  margin-top: 6px;
}

/* ---------- Home-MV Overlapping Handwritten + Serif Lyrics (demo6 / demo7) ---------- */
.lyric-wrap {
  position: fixed;
  z-index: 28;
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px);
  filter: blur(4px);
  transition: opacity 0.7s var(--ease-soft), transform 0.85s var(--ease-soft), filter 0.7s var(--ease-soft);
}

.lyric-wrap.on {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}

/* Signature Left-Bottom Overlap Bleeding Across Right Film Gate (demo7) */
.lyric-wrap.mode-overlap {
  left: clamp(24px, 7vw, 120px);
  bottom: clamp(64px, 14vh, 145px);
  max-width: min(68vw, 720px);
  text-align: left;
}

/* Full-Bleed Center Floating Script (demo3 / 01:36 / 02:32) */
.lyric-wrap.mode-center {
  left: 50%;
  top: 52%;
  transform: translate(-50%, -44%);
  width: min(88vw, 900px);
  text-align: center;
}

.lyric-wrap.mode-center.on {
  transform: translate(-50%, -50%);
}

/* Subtle Bottom-Left Ribbon While Browsing Full Archive (3:41 – 4:39) */
.lyric-wrap.mode-corner {
  left: clamp(20px, 4vw, 56px);
  bottom: 54px;
  max-width: min(76vw, 520px);
  text-align: left;
  background: linear-gradient(90deg, rgba(11, 10, 9, 0.78), transparent);
  padding: 10px 18px 10px 0;
}

.lyric-en {
  font-family: var(--font-script-en);
  font-weight: 400;
  font-size: clamp(2.4rem, 5.4vw, 4.7rem);
  line-height: 1.04;
  color: var(--gold-script);
  text-shadow:
    0 2px 24px rgba(0, 0, 0, 0.72),
    0 0 28px rgba(235, 214, 120, 0.3);
}

.lyric-wrap.mode-corner .lyric-en {
  font-size: clamp(1.7rem, 3vw, 2.4rem);
}

.lyric-cn {
  font-family: var(--font-serif-cn);
  font-weight: 300;
  font-size: clamp(0.92rem, 1.4vw, 1.16rem);
  letter-spacing: 0.28em;
  color: var(--gold-serif);
  margin-top: 6px;
  padding-left: 4px;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.85);
}

/* ---------- 3. Second-Half Full 16-Photo Large-Format Archive (3:41 – End) ---------- */
.archive {
  position: fixed;
  inset: 0;
  z-index: 18;
  background: rgba(11, 10, 9, 0.94);
  opacity: 0;
  visibility: hidden;
  transition: opacity 1.6s var(--ease-soft), visibility 1.6s var(--ease-soft);
}

.archive.open {
  opacity: 1;
  visibility: visible;
}

.archive-scroll {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: clamp(56px, 9vh, 96px) clamp(20px, 6vw, 96px) 130px;
  scroll-behavior: auto;
}

.archive-scroll::-webkit-scrollbar {
  width: 4px;
}

.archive-scroll::-webkit-scrollbar-thumb {
  background: rgba(203, 185, 130, 0.24);
}

.archive-head {
  text-align: center;
  margin-bottom: clamp(44px, 7vh, 76px);
}

.archive-script {
  font-family: var(--font-script-en);
  font-size: clamp(2.6rem, 5vw, 4rem);
  color: var(--gold-script);
  line-height: 1.05;
}

.archive-cn {
  font-family: var(--font-serif-cn);
  font-weight: 300;
  font-size: clamp(1.2rem, 2.2vw, 1.65rem);
  letter-spacing: 0.44em;
  padding-left: 0.44em;
  color: var(--ivory);
  margin-top: 4px;
}

.archive-dates {
  font-family: var(--font-rebate);
  font-size: 10.5px;
  letter-spacing: 0.28em;
  color: rgba(203, 185, 130, 0.48);
  margin-top: 14px;
}

/* Masonry-like Asymmetrical Contact Sheet Grid */
.archive-grid {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 42px 34px;
  align-items: end;
}

.sheet-card {
  background: #070605;
  padding: 4px 10px 8px;
  border: 1px solid rgba(203, 185, 130, 0.08);
  cursor: pointer;
  transition: transform 0.55s var(--ease-soft), border-color 0.45s ease;
}

.sheet-card:hover {
  transform: translateY(-5px);
  border-color: rgba(235, 214, 120, 0.34);
}

.sheet-photo {
  position: relative;
  overflow: hidden;
  background: #0d0b09;
}

.sheet-card.landscape .sheet-photo {
  aspect-ratio: 16 / 10;
}

.sheet-card.portrait .sheet-photo {
  aspect-ratio: 4 / 4.6;
}

.sheet-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: contrast(1.04) saturate(1.06) sepia(0.1) brightness(0.9);
  transition: transform 0.8s var(--ease-soft), filter 0.5s ease;
}

.sheet-card:hover .sheet-photo img {
  transform: scale(1.04);
  filter: contrast(1.06) saturate(1.12) sepia(0.04) brightness(1);
}

.sheet-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding: 0 4px;
}

.sheet-mood {
  font-family: var(--font-serif-cn);
  font-weight: 300;
  font-size: 12.5px;
  letter-spacing: 0.24em;
  color: rgba(239, 231, 214, 0.72);
}

.sheet-date {
  font-family: var(--font-rebate);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: rgba(203, 185, 130, 0.45);
}

.archive-foot {
  margin-top: 72px;
  text-align: center;
}

/* ---------- Minimalist Auto-Hiding HUD ---------- */
.hud {
  position: fixed;
  left: clamp(16px, 4vw, 48px);
  right: clamp(16px, 4vw, 48px);
  bottom: 16px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  opacity: 0;
  transition: opacity 0.45s ease;
}

.hud.show,
.hud:hover {
  opacity: 1;
}

.hud-btn {
  background: none;
  border: none;
  color: rgba(239, 231, 214, 0.56);
  font-family: var(--font-rebate);
  font-size: 10px;
  letter-spacing: 0.22em;
  cursor: pointer;
  padding: 4px 2px;
  transition: color 0.3s ease;
}

.hud-btn:hover {
  color: var(--gold-script);
}

.hud-time {
  font-family: var(--font-rebate);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: rgba(239, 231, 214, 0.42);
}

.scrub {
  flex: 1;
  padding: 10px 0;
  cursor: pointer;
}

.scrub-track {
  height: 1.5px;
  background: rgba(239, 231, 214, 0.14);
  position: relative;
}

.scrub-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: var(--gold-script);
  box-shadow: 0 0 8px rgba(235, 214, 120, 0.5);
}

/* ---------- High-Res Large-Format Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(6, 5, 5, 0.95);
  display: grid;
  place-items: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.lightbox.open {
  opacity: 1;
  visibility: visible;
}

.lightbox-close {
  position: fixed;
  top: 20px;
  right: 28px;
  background: none;
  border: none;
  color: rgba(239, 231, 214, 0.65);
  font-size: 28px;
  font-weight: 200;
  cursor: pointer;
}

.lightbox-sheet {
  background: #080706;
  padding: 4px 12px 8px;
  max-width: 90vw;
}

.lightbox-img-wrap {
  position: relative;
}

.lightbox-img-wrap img {
  max-width: 86vw;
  max-height: 78vh;
  object-fit: contain;
  display: block;
}

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

/* ---------- Mobile Adaptation ---------- */
@media (max-width: 820px) {
  .frame-slide.gate-right {
    justify-content: center;
    padding-left: 0;
    padding-bottom: 12vh;
  }

  .frame-slide.gate-right .lf-holder.landscape {
    width: 88vw;
  }

  .frame-slide.gate-right .lf-holder.portrait,
  .frame-slide.gate-sm .lf-holder {
    width: min(74vw, 320px);
  }

  .lyric-wrap.mode-overlap {
    left: 22px;
    right: 22px;
    bottom: 68px;
  }

  .archive-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}
