/* ────────────────────────────────────────────────────────────
   Thirty-Four Frames — scrolling photo roll
   ──────────────────────────────────────────────────────────── */

:root{
  --ink:      #07070a;
  --ink-2:    #0c0c11;
  --paper:    #f3f0e9;
  --dim:      rgba(243,240,233,.55);
  --faint:    rgba(243,240,233,.28);
  --hair:     rgba(243,240,233,.14);
  --accent:   #e3b379;

  --display: 'Instrument Serif', 'Playfair Display', Georgia, 'Times New Roman', serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --pad: clamp(18px, 3.2vw, 44px);
}

*{ box-sizing: border-box; }

:root{ color-scheme: dark; }   /* Safari: draw its own chrome dark */

html, body{ margin:0; padding:0; }

html{
  background-color: #07070a;   /* iOS paints the overscroll / safe-area with this */
  background: var(--ink);
  scroll-behavior: auto;   /* JS drives smooth moves explicitly (replay button) */
  -webkit-text-size-adjust: 100%;
}

body{
  background-color: #07070a;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-weight: 300;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

body[data-loading="true"]{ overflow: hidden; height: 100dvh; }

img{ display:block; max-width:100%; }
button{ font: inherit; color: inherit; background:none; border:0; cursor:pointer; }

::selection{ background: var(--accent); color:#0a0a0c; }

/* film grain overlay -------------------------------------------------- */
.grain{
  position: fixed; inset: -50%;
  z-index: 900;
  pointer-events: none;
  opacity: .05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
  animation: grainShift .9s steps(4) infinite;
  will-change: transform;
}
@keyframes grainShift{
  0%{ transform: translate3d(0,0,0); }
  25%{ transform: translate3d(-2%, 1.5%, 0); }
  50%{ transform: translate3d(1.5%, -1%, 0); }
  75%{ transform: translate3d(-1%, -2%, 0); }
  100%{ transform: translate3d(2%, 1%, 0); }
}

/* loader -------------------------------------------------------------- */
.loader{
  position: fixed; inset:0; z-index: 1000;
  display: grid; place-content: center; justify-items: center; gap: 26px;
  background: var(--ink);
  transition: opacity .9s cubic-bezier(.16,1,.3,1), visibility .9s;
}
.loader.is-done{ opacity:0; visibility:hidden; }

.loader__num{
  font-family: var(--display); font-size: clamp(46px, 8vw, 78px);
  line-height: 1; letter-spacing: -.02em; color: var(--paper);
  font-variant-numeric: tabular-nums;
}
.loader__bar{
  width: min(280px, 52vw); height: 1px; background: var(--hair); overflow: hidden;
}
.loader__bar i{
  display:block; height:100%; width:0%;
  background: var(--accent);
  transition: width .35s ease-out;
}
.loader__label{
  font-size: 10px; letter-spacing: .34em; text-transform: uppercase; color: var(--faint);
}

/* ───────────────────────── hero ───────────────────────── */
.hero{
  position: relative;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: clamp(28px, 6vh, 70px);
  padding: calc(var(--pad) + env(safe-area-inset-top)) calc(var(--pad) + env(safe-area-inset-right))
           calc(var(--pad) + env(safe-area-inset-bottom)) calc(var(--pad) + env(safe-area-inset-left));
  padding-bottom: calc(clamp(28px, 5vh, 56px) + env(safe-area-inset-bottom));
  isolation: isolate;
  overflow: hidden;
}
.hero::before{
  content:"";
  position:absolute; inset:0; z-index:-1;
  background:
    radial-gradient(120% 85% at 50% 0%, rgba(227,179,121,.10) 0%, transparent 58%),
    radial-gradient(80% 60% at 50% 120%, rgba(90,120,180,.10) 0%, transparent 60%),
    var(--ink);
}

.hero__top{ display:flex; justify-content:space-between; gap:16px; }

.tag{
  display:inline-flex; align-items:center; gap:9px;
  font-size: 10px; letter-spacing:.26em; text-transform:uppercase; color: var(--dim);
}
.tag--right{ justify-content:flex-end; }
.tag__dot{
  width:5px; height:5px; border-radius:50%; background: var(--accent);
  box-shadow: 0 0 0 0 rgba(227,179,121,.55);
  animation: pulse 2.6s ease-out infinite;
}
@keyframes pulse{
  0%{ box-shadow:0 0 0 0 rgba(227,179,121,.5); }
  70%{ box-shadow:0 0 0 9px rgba(227,179,121,0); }
  100%{ box-shadow:0 0 0 0 rgba(227,179,121,0); }
}

.hero__mid{ display:flex; align-items:center; }

.hero__title{
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(3.1rem, 10.4vw, 9.6rem);
  line-height: .9;
  letter-spacing: -.025em;
}
.hero__title em{
  font-style: italic;
  color: var(--accent);
}
.hero__title .line{
  display:block; overflow:hidden;
  padding-bottom:.16em; margin-bottom:-.16em;   /* room for descenders */
}
.hero__title .line > span{
  display:block;
  transform: translate3d(0, 118%, 0) rotate(2deg);
  transition: transform 1.15s cubic-bezier(.16,1,.3,1);
}
body:not([data-loading="true"]) .hero__title .line > span{ transform:none; }
body:not([data-loading="true"]) .hero__title .line:nth-child(2) > span{ transition-delay:.09s; }
body:not([data-loading="true"]) .hero__title .line:nth-child(3) > span{ transition-delay:.18s; }

.hero__bottom{
  display:flex; align-items:flex-end; justify-content:space-between; gap: clamp(20px, 5vw, 70px);
}
.hero__sub{
  margin:0; max-width: 42ch;
  font-size: clamp(11px, 1.05vw, 13px); line-height:1.85;
  color: var(--dim);
  opacity:0; transform: translateY(12px);
  transition: opacity 1s ease .45s, transform 1s cubic-bezier(.16,1,.3,1) .45s;
}
body:not([data-loading="true"]) .hero__sub{ opacity:1; transform:none; }

.hero__cue{
  display:flex; flex-direction:column; align-items:center; gap:12px;
  font-size:9.5px; letter-spacing:.3em; text-transform:uppercase; color: var(--faint);
  white-space: nowrap;
  opacity:0; transition: opacity 1s ease .7s;
}
body:not([data-loading="true"]) .hero__cue{ opacity:1; }
.hero__cueLine{
  display:block; width:1px; height:56px;
  background: linear-gradient(to bottom, var(--faint), transparent);
  position:relative; overflow:hidden;
}
.hero__cueLine::after{
  content:""; position:absolute; top:-56px; left:0; width:1px; height:56px;
  background: linear-gradient(to bottom, transparent, var(--accent));
  animation: cueDrop 2.4s cubic-bezier(.6,0,.4,1) infinite;
}
@keyframes cueDrop{
  0%{ transform: translateY(0); opacity:0; }
  25%{ opacity:1; }
  100%{ transform: translateY(112px); opacity:0; }
}

/* ───────────────────────── reel / stage ───────────────────────── */
.reel{
  position: relative;
  /* height is set by JS: N * step */
  background: #07070a;   /* same ink as html/body → iOS bars match */
}

.stage{
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;
  background: #07070a;
  perspective: 1400px;
}

.frames{ position:absolute; inset:0; }

.frame{
  position:absolute; inset:0;
  margin:0;
  display: grid; place-items: center;
  will-change: transform, opacity, filter;
  backface-visibility: hidden;
  transform-origin: 50% 50%;
  opacity: 0;
  visibility: hidden;
}
.frame img{
  max-width: min(86vw, 1180px);
  max-height: 74svh;
  width:auto; height:auto;
  object-fit: contain;
  border-radius: 2px;
  outline: 1px solid rgba(243,240,233,.10);
  outline-offset: -1px;
  box-shadow:
    0 2px 0 rgba(255,255,255,.05) inset,
    0 30px 70px -20px rgba(0,0,0,.9),
    0 70px 150px -60px rgba(0,0,0,1);
  -webkit-box-reflect: below 2px
    -webkit-gradient(linear, left top, left bottom,
      from(rgba(0,0,0,0)), to(rgba(0,0,0,.14)));
}
.frame.is-pending img{
  background: linear-gradient(120deg, #101015, #17171d 40%, #101015);
  width: 46vw; height: 46vh; max-height: 46vh;
}
.frame.is-pending::after{
  content: attr(data-n);
  position:absolute; top:50%; left:50%; transform:translate(-50%,-50%);
  font-family: var(--display); font-size: 56px; color: rgba(243,240,233,.07);
}

.vignette{
  position:absolute; inset:0; z-index:5; pointer-events:none;
  background:
    radial-gradient(85% 70% at 50% 50%, transparent 30%, rgba(0,0,0,.55) 100%),
    linear-gradient(to bottom, rgba(0,0,0,.55), transparent 22%, transparent 76%, rgba(0,0,0,.7));
}
.scan{
  position:absolute; inset:0; z-index:6; pointer-events:none; opacity:.35;
  background: repeating-linear-gradient(
    0deg, rgba(0,0,0,.22) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}

/* HUD ----------------------------------------------------------------- */
.hud{
  position:absolute; inset:0; z-index:20; pointer-events:none;
  padding: calc(var(--pad) + env(safe-area-inset-top)) var(--pad)
           calc(var(--pad) + 16px + env(safe-area-inset-bottom)) var(--pad);
  display:flex; flex-direction:column; justify-content:space-between;
}
.hud__row{ display:flex; align-items:flex-start; justify-content:space-between; gap:18px; }
.hud__row--bottom{ align-items:flex-end; }

.hud__tag{
  font-size:9.5px; letter-spacing:.3em; text-transform:uppercase; color: rgba(243,240,233,.45);
}
.hud__count{
  font-size: 11px; letter-spacing:.12em; color: rgba(243,240,233,.5);
  font-variant-numeric: tabular-nums;
}
.hud__count b{ color: var(--paper); font-weight:400; }
.hud__count i{ margin:0 4px; font-style:normal; opacity:.5; }

.date{ display:flex; align-items:flex-end; gap:14px; }
.date__day{
  font-family: var(--display);
  font-size: clamp(44px, 6.4vw, 76px);
  line-height:.82; letter-spacing:-.03em;
  font-variant-numeric: tabular-nums;
}
.date__meta{
  display:grid; gap:1px;
  padding-bottom: 4px;
  font-size: 10.5px; letter-spacing:.24em; text-transform:uppercase; color: rgba(243,240,233,.78);
}
.date__meta b{ font-weight:400; color: var(--paper); }
.date__meta em{
  font-style:normal; color: rgba(243,240,233,.45); letter-spacing:.14em; font-size:9.5px;
}

.file{
  display:flex; align-items:center; gap:8px;
  font-size:10px; letter-spacing:.2em; text-transform:uppercase; color: rgba(243,240,233,.5);
  font-variant-numeric: tabular-nums;
}
.file em{ font-style:normal; opacity:.5; }

/* flip animation when the frame changes */
.flip{ animation: flipIn .5s cubic-bezier(.16,1,.3,1) both; }
@keyframes flipIn{
  from{ opacity:0; transform: translateY(9px); filter: blur(3px); }
  to{ opacity:1; transform:none; filter:none; }
}

/* rail --------------------------------------------------------------- */
.rail{
  position:absolute; left:0; right:0; bottom: env(safe-area-inset-bottom); height:2px; z-index:25;
  background: rgba(243,240,233,.08);
}
.rail__fill{
  position:absolute; inset:0 auto 0 0; width:0%;
  background: linear-gradient(90deg, rgba(227,179,121,.25), var(--accent));
  box-shadow: 0 0 14px rgba(227,179,121,.5);
}
.rail__ticks{
  position:absolute; inset:0; display:flex; gap:0;
}
.rail__ticks i{
  flex:1 1 0; border-right:1px solid rgba(243,240,233,.10);
}
.rail__ticks i:last-child{ border-right:0; }

/* ───────────────────────── outro ───────────────────────── */
.outro{
  position: relative;
  min-height: 100svh;
  display: grid; place-items: center;
  padding: clamp(60px, 12vh, 130px) var(--pad);
  overflow: hidden;
  isolation: isolate;
}
.outro__glow{
  position:absolute; inset:0; z-index:-1;
  background:
    radial-gradient(70% 55% at 50% 100%, rgba(227,179,121,.16), transparent 70%),
    radial-gradient(60% 50% at 20% 0%, rgba(120,90,200,.10), transparent 70%);
}
.outro::before{
  content:""; position:absolute; inset:0; z-index:-1;
  background: linear-gradient(to bottom, #050507, #0a0909 55%, #0c0a08);
}
.outro__inner{ max-width: 760px; text-align:center; }

.outro__eyebrow{
  margin:0 0 clamp(22px,4vh,38px);
  font-size:9.5px; letter-spacing:.34em; text-transform:uppercase; color: var(--faint);
}
.outro__title{
  margin:0 0 clamp(24px,4vh,40px);
  font-family: var(--display); font-weight:400;
  font-size: clamp(2.2rem, 6.4vw, 4.9rem);
  line-height:1.02; letter-spacing:-.02em;
}
.outro__title em{ font-style:italic; color: var(--accent); }
.outro__title .line{
  display:block; overflow:hidden;
  padding-bottom:.16em; margin-bottom:-.16em;
}
.outro__title .line > span{
  display:block; transform: translateY(115%);
  transition: transform 1.1s cubic-bezier(.16,1,.3,1);
}
.outro.in .outro__title .line > span{ transform:none; }
.outro.in .outro__title .line:nth-child(2) > span{ transition-delay:.1s; }

.outro__body{
  margin: 0 auto clamp(34px,6vh,52px);
  max-width: 65ch;
  font-size: clamp(11.5px, 1.15vw, 14px); line-height: 2;
  color: var(--dim);
  opacity:0; transform: translateY(14px);
  transition: opacity 1s ease .28s, transform 1s cubic-bezier(.16,1,.3,1) .28s;
}
.outro.in .outro__body{ opacity:1; transform:none; }
.outro__eyebrow{
  opacity:0; transition: opacity .9s ease;
}
.outro.in .outro__eyebrow{ opacity:1; }

.outro__btn{
  display:inline-flex; align-items:center; gap:14px;
  padding: 15px 26px;
  border:1px solid var(--hair);
  border-radius: 999px;
  font-size:10px; letter-spacing:.26em; text-transform:uppercase; color: var(--paper);
  opacity:0; transform: translateY(12px);
  transition: opacity 1s ease .45s, transform 1s cubic-bezier(.16,1,.3,1) .45s,
              border-color .4s, background .4s, gap .3s;
}
.outro.in .outro__btn{ opacity:1; transform:none; }
.outro__btn:hover{ border-color: rgba(227,179,121,.6); background: rgba(227,179,121,.07); gap:20px; }
.outro__btn i{ font-style:normal; color: var(--accent); }

/* ───────────────────────── responsive ───────────────────────── */
@media (max-width: 860px){
  .hero{ gap: 26px; }
  .hero__bottom{ flex-direction: column; align-items: flex-start; gap:22px; }
  .hero__cue{ flex-direction: row; align-items:center; }
  .hero__cueLine{ height:1px; width:56px; }
  .hero__cueLine::after{
    top:0; left:-56px; width:56px; height:1px;
    background: linear-gradient(to right, transparent, var(--accent));
    animation: cueSweep 2.4s cubic-bezier(.6,0,.4,1) infinite;
  }
  @keyframes cueSweep{
    0%{ transform: translateX(0); opacity:0; }
    25%{ opacity:1; }
    100%{ transform: translateX(112px); opacity:0; }
  }
  .frame img{ max-width: 88vw; max-height: 66svh; }
  .vignette{
    background:
      radial-gradient(90% 70% at 50% 50%, transparent 34%, rgba(0,0,0,.6) 100%),
      linear-gradient(to bottom, rgba(0,0,0,.6), transparent 20%, transparent 74%, rgba(0,0,0,.78));
  }
  .file{ font-size:9.5px; letter-spacing:.16em; }
  .date__day{ font-size: clamp(40px, 13vw, 60px); }
}

@media (max-width: 520px){
  .hero__title{ font-size: clamp(2.6rem, 13.5vw, 4rem); }
  .tag--right{ display:none; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce){
  html{ scroll-behavior: auto; }
  .grain{ animation:none; }
  .hero__title .line > span{ transition: opacity .6s ease; transform:none; }
  .hero__cueLine::after{ animation:none; }
  .frame img{ -webkit-box-reflect: none; }
  .scan{ display:none; }
}
