:root {
  color-scheme: dark;
  --ink: #f8f1e7;
  --muted: rgba(248, 241, 231, 0.67);
  --accent: #d8ad79;
  --paper: #efe4d3;
  --night: #17110f;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--night);
}

body {
  color: var(--ink);
  font-family: "DM Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

#experience {
  position: relative;
  width: 100%;
  height: 100%;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 34%, #3a2922 0, transparent 45%),
    linear-gradient(145deg, #1c1512, #0e0b0a);
}

#ambient {
  position: absolute;
  z-index: -4;
  inset: -9%;
  opacity: 0;
  background-position: center;
  background-size: cover;
  filter: blur(52px) saturate(0.75) brightness(0.42);
  transform: scale(1.14);
  transition:
    opacity 1.6s ease,
    background-image 1.4s ease;
}

.vignette {
  position: absolute;
  z-index: 20;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(10, 7, 6, 0.28), transparent 20%, transparent 76%, rgba(8, 5, 4, 0.55)),
    radial-gradient(circle, transparent 42%, rgba(7, 4, 3, 0.5) 122%);
}

.grain {
  position: absolute;
  z-index: 21;
  inset: -50%;
  width: 200%;
  height: 200%;
  pointer-events: none;
  opacity: 0.105;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.93' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.75'/%3E%3C/svg%3E");
  animation: grain-shift 0.25s steps(2) infinite;
}

@keyframes grain-shift {
  0% { transform: translate3d(0, 0, 0); }
  25% { transform: translate3d(2%, -3%, 0); }
  50% { transform: translate3d(-3%, 2%, 0); }
  75% { transform: translate3d(3%, 4%, 0); }
  100% { transform: translate3d(-2%, -2%, 0); }
}

#stage,
#frames,
.frame {
  position: absolute;
  inset: 0;
}

#stage {
  z-index: 2;
}

#frames {
  perspective: 1400px;
  transform-style: preserve-3d;
}

.frame {
  display: grid;
  place-items: center;
  padding: clamp(4.5rem, 8vw, 8rem) clamp(2rem, 8vw, 10rem);
  opacity: 0;
  transform: scale(1.025);
  transition:
    opacity 1.2s ease,
    transform 1.8s var(--ease-out),
    filter 1.1s ease;
  will-change: transform, opacity;
}

.frame.is-active {
  opacity: 1;
  transform: scale(1);
}

.frame.is-leaving {
  opacity: 0;
  transform: scale(0.985);
  filter: blur(3px);
}

.media-card {
  position: relative;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  background: #261d19;
  box-shadow:
    0 35px 85px rgba(0, 0, 0, 0.42),
    0 4px 18px rgba(0, 0, 0, 0.24);
  transform: translate3d(var(--x, 0), var(--y, 0), var(--z, 0)) rotate(var(--r, 0));
  transition: transform 8s linear;
}

.is-active .media-card {
  transform: translate3d(var(--x-end, var(--x, 0)), var(--y-end, var(--y, 0)), var(--z-end, var(--z, 0))) rotate(var(--r-end, var(--r, 0)));
}

.media-card::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.13);
}

.media-card img,
.media-card video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--focus, center);
  transform: scale(var(--media-scale, 1.04));
  animation: breathe var(--moment-duration, 8s) linear both;
}

.media-card.contain img,
.media-card.contain video {
  object-fit: contain;
  background:
    radial-gradient(circle at center, rgba(92, 68, 55, 0.5), transparent 72%),
    #160f0d;
}

@keyframes breathe {
  from { transform: scale(var(--media-scale, 1.04)); }
  to { transform: scale(calc(var(--media-scale, 1.04) + 0.055)); }
}

.layout-hero .media-card {
  width: min(70vw, 980px);
  height: min(74vh, 760px);
  border-radius: 3px;
}

.layout-portrait .media-card {
  width: min(45vw, 570px);
  height: min(76vh, 790px);
  border: clamp(6px, 0.7vw, 11px) solid var(--paper);
  border-bottom-width: clamp(18px, 2.1vw, 30px);
}

.layout-wide .media-card {
  width: min(82vw, 1250px);
  height: min(67vh, 720px);
  border-radius: 4px;
}

.layout-finale {
  padding: 0;
}

.layout-finale .media-card {
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.layout-finale::after {
  position: absolute;
  z-index: 2;
  inset: 0;
  background:
    radial-gradient(circle at center, rgba(12, 8, 6, 0.15), rgba(8, 5, 4, 0.58) 88%),
    linear-gradient(to bottom, rgba(8, 5, 4, 0.28), rgba(8, 5, 4, 0.46));
  content: "";
  pointer-events: none;
}

.layout-duet {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1rem, 2.6vw, 3rem);
  padding-inline: clamp(3rem, 12vw, 14rem);
}

.layout-duet .media-card {
  width: 100%;
  height: min(62vh, 650px);
  border: clamp(5px, 0.55vw, 9px) solid var(--paper);
  border-bottom-width: clamp(14px, 1.5vw, 24px);
}

.layout-duet .media-card:first-child {
  --r: -2.2deg;
  --r-end: -0.7deg;
  --y: 2.2vh;
  --y-end: 0;
}

.layout-duet .media-card:last-child {
  --r: 2.1deg;
  --r-end: 0.5deg;
  --y: -1.5vh;
  --y-end: 0.5vh;
}

.layout-triptych {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: clamp(0.7rem, 1.7vw, 1.7rem);
  padding-inline: clamp(2rem, 7vw, 8rem);
}

.layout-triptych .media-card {
  width: 100%;
  height: min(58vh, 610px);
  border: clamp(4px, 0.45vw, 8px) solid var(--paper);
  border-bottom-width: clamp(12px, 1.25vw, 21px);
}

.layout-triptych .media-card:nth-child(1) {
  --r: -3deg;
  --r-end: -1.2deg;
  --y: 2.5vh;
}

.layout-triptych .media-card:nth-child(2) {
  z-index: 2;
  height: min(66vh, 690px);
  --z: 30px;
}

.layout-triptych .media-card:nth-child(3) {
  --r: 3deg;
  --r-end: 1.1deg;
  --y: 1.7vh;
}

.layout-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: clamp(0.65rem, 1.2vw, 1.2rem);
  padding: clamp(5rem, 9vh, 7rem) clamp(3rem, 15vw, 17rem);
}

.layout-grid .media-card {
  width: 100%;
  height: 100%;
  border: clamp(4px, 0.4vw, 7px) solid var(--paper);
  border-bottom-width: clamp(10px, 1vw, 16px);
}

.layout-grid .media-card:nth-child(odd) {
  --r: -1deg;
  --r-end: -0.25deg;
}

.layout-grid .media-card:nth-child(even) {
  --r: 1deg;
  --r-end: 0.25deg;
}

.layout-gallery-five {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: clamp(0.65rem, 1.15vw, 1.15rem);
  padding: clamp(5rem, 9vh, 7rem) clamp(2.5rem, 10vw, 11rem) clamp(8rem, 15vh, 11rem);
}

.layout-gallery-five .media-card {
  width: 100%;
  height: 100%;
  border: clamp(4px, 0.4vw, 7px) solid var(--paper);
  border-bottom-width: clamp(10px, 1vw, 16px);
}

.layout-gallery-five .media-card:nth-child(1) {
  grid-column: span 2;
  --r: -1deg;
  --r-end: -0.2deg;
}

.layout-gallery-five .media-card:nth-child(2) {
  grid-column: span 4;
  --r: 0.6deg;
  --r-end: 0.1deg;
}

.layout-gallery-five .media-card:nth-child(n + 3) {
  grid-column: span 2;
}

.layout-gallery-five .media-card:nth-child(3) {
  --r: -0.8deg;
}

.layout-gallery-five .media-card:nth-child(5) {
  --r: 0.8deg;
}

.layout-stack .media-card {
  position: absolute;
  width: min(40vw, 540px);
  height: min(64vh, 660px);
  border: clamp(6px, 0.6vw, 10px) solid var(--paper);
  border-bottom-width: clamp(17px, 1.8vw, 28px);
}

.layout-stack .media-card:nth-child(1) {
  z-index: 3;
  --r: -1.4deg;
  --r-end: 0deg;
  --x: -2vw;
  --x-end: -1vw;
}

.layout-stack .media-card:nth-child(2) {
  z-index: 2;
  --r: 8deg;
  --r-end: 6deg;
  --x: 24vw;
  --x-end: 20vw;
  --y: 2vh;
}

.layout-stack .media-card:nth-child(3) {
  z-index: 1;
  --r: -9deg;
  --r-end: -6deg;
  --x: -24vw;
  --x-end: -20vw;
  --y: 3vh;
}

.frame.transition-portal {
  overflow: hidden;
}

.frame.transition-portal .media-card {
  transform: scale(1);
  animation: portal-dive var(--moment-duration, 6s) var(--ease-out) both;
}

@keyframes portal-dive {
  0% { transform: scale(0.96); filter: brightness(0.78); }
  42% { transform: scale(1.08); filter: brightness(0.98); }
  82% { transform: scale(3.5); filter: brightness(0.6) blur(1px); }
  100% { transform: scale(7); filter: brightness(0) blur(8px); }
}

.frame.transition-reveal .media-card {
  animation: memory-reveal 3.8s var(--ease-out) both;
}

@keyframes memory-reveal {
  from { opacity: 0; transform: scale(1.55); filter: blur(12px) brightness(0.35); }
  to { opacity: 1; transform: scale(1); filter: blur(0) brightness(1); }
}

.story-copy {
  position: absolute;
  z-index: 10;
  left: 50%;
  bottom: clamp(5rem, 10vh, 8rem);
  width: min(88vw, 980px);
  text-align: center;
  pointer-events: none;
  transform: translateX(-50%);
}

.story-copy::before {
  position: absolute;
  z-index: -1;
  inset: -1.5rem -4rem -1.8rem;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at center,
    rgba(12, 8, 7, 0.76) 0%,
    rgba(12, 8, 7, 0.5) 42%,
    transparent 74%
  );
  content: "";
  opacity: 0;
  filter: blur(5px);
  transition: opacity 0.8s ease;
}

.story-copy.is-visible::before {
  opacity: 1;
}

.story-copy.is-finale {
  top: 50%;
  bottom: auto;
  width: min(92vw, 1200px);
  transform: translate(-50%, -50%);
}

.story-copy.is-finale::before {
  inset: -2.5rem -3rem;
  border-radius: 2rem;
  background: radial-gradient(
    ellipse at center,
    rgba(10, 7, 5, 0.78) 0%,
    rgba(10, 7, 5, 0.54) 48%,
    transparent 78%
  );
}

.story-copy.is-finale #headline {
  font-size: clamp(4.5rem, 10vw, 10rem);
  line-height: 0.78;
}

.story-copy.is-finale .subline {
  max-width: 1000px;
  margin-top: clamp(1.4rem, 3vh, 2.4rem) !important;
  color: rgba(255, 255, 255, 0.96);
  font-size: clamp(1.45rem, 2.4vw, 2.5rem);
  font-weight: 500;
  line-height: 1.25;
  white-space: pre-line;
}

.story-copy > * {
  margin: 0;
  opacity: 0;
  transform: translateY(18px);
  text-shadow: 0 3px 26px rgba(0, 0, 0, 0.75);
  transition:
    opacity 0.9s ease,
    transform 1.1s var(--ease-out);
}

.story-copy.is-visible > * {
  opacity: 1;
  transform: translateY(0);
}

.story-copy.is-visible .subline {
  transition-delay: 0.12s;
}

.eyebrow {
  display: table;
  margin-bottom: 0.65rem !important;
  margin-inline: auto !important;
  padding: 0.42rem 0.72rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 100px;
  color: rgba(255, 255, 255, 0.74);
  background: rgba(14, 9, 7, 0.5);
  font-size: clamp(0.62rem, 0.75vw, 0.78rem);
  font-weight: 500;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
}

.eyebrow:empty {
  display: none;
}

#headline {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(2.8rem, 6.4vw, 7.1rem);
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 0.91;
}

.subline {
  max-width: 680px;
  margin: 1rem auto 0 !important;
  color: rgba(255, 255, 255, 0.82);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(1.1rem, 1.8vw, 1.65rem);
  font-style: italic;
  line-height: 1.3;
}

#chapter-indicator {
  position: absolute;
  z-index: 30;
  top: clamp(1.6rem, 4vw, 3.25rem);
  left: clamp(1.5rem, 4.5vw, 4.8rem);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  opacity: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.63rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  transition: opacity 1s ease;
}

.is-playing #chapter-indicator {
  opacity: 1;
}

.indicator-line {
  width: 2.5rem;
  height: 1px;
  background: rgba(255, 255, 255, 0.42);
}

.welcome {
  position: absolute;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(circle at 50% 38%, rgba(107, 68, 52, 0.42), transparent 39%),
    #17110f;
  transition:
    opacity 1.4s ease,
    visibility 1.4s;
}

.welcome::before,
.welcome::after {
  position: absolute;
  width: 24vw;
  height: 52vh;
  border: 1px solid rgba(255, 255, 255, 0.08);
  content: "";
  transform: rotate(12deg);
}

.welcome::before {
  left: -7vw;
  top: -15vh;
}

.welcome::after {
  right: -7vw;
  bottom: -15vh;
}

.welcome.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.welcome-inner {
  width: min(92vw, 760px);
  text-align: center;
}

.welcome-date {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  margin: 0 0 1.6rem;
  color: var(--accent);
  font-size: clamp(0.68rem, 0.8vw, 0.8rem);
  letter-spacing: 0.34em;
}

.welcome-date span {
  width: 2.8rem;
  height: 1px;
  background: currentColor;
}

.welcome h1 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(3.6rem, 9.5vw, 8.4rem);
  font-weight: 400;
  letter-spacing: -0.055em;
  line-height: 0.73;
}

.welcome h1 em {
  color: #e5c29a;
  font-weight: 400;
}

.welcome-note {
  margin: 2.4rem 0 2rem;
  color: var(--muted);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(1.1rem, 1.8vw, 1.45rem);
  font-style: italic;
}

#start-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 220px;
  padding: 0.95rem 1.1rem 0.95rem 1.4rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transition:
    background 0.3s ease,
    color 0.3s ease,
    opacity 0.3s ease;
}

#start-button:not(:disabled):hover {
  color: #1b120e;
  background: var(--paper);
}

#start-button:disabled {
  cursor: wait;
  opacity: 0.48;
}

.button-arrow {
  margin-left: 1rem;
  font-size: 1rem;
}

.load-track {
  width: min(52vw, 270px);
  height: 1px;
  margin: 1.4rem auto 0;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
}

#load-progress {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.35s ease;
}

.load-status {
  margin: 0.65rem 0 0;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.controls {
  position: absolute;
  z-index: 40;
  right: clamp(1.5rem, 4vw, 4rem);
  bottom: clamp(1.3rem, 2.6vw, 2.4rem);
  left: clamp(1.5rem, 4vw, 4rem);
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 0.4s ease,
    transform 0.4s ease;
}

.is-playing .controls:hover,
.is-paused .controls {
  opacity: 1;
  transform: translateY(0);
}

.controls button {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  opacity: 0.75;
}

.progress-wrap {
  flex: 1;
}

.progress-time {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.35rem;
  color: rgba(255, 255, 255, 0.54);
  font-size: 0.58rem;
  font-variant-numeric: tabular-nums;
}

#scrubber {
  width: 100%;
  height: 2px;
  margin: 0;
  appearance: none;
  background: linear-gradient(to right, var(--paper) var(--played, 0%), rgba(255, 255, 255, 0.22) var(--played, 0%));
  cursor: pointer;
}

#scrubber::-webkit-slider-thumb {
  width: 8px;
  height: 8px;
  border: 0;
  border-radius: 50%;
  appearance: none;
  background: var(--paper);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.controls:hover #scrubber::-webkit-slider-thumb {
  opacity: 1;
}

.replay {
  position: absolute;
  z-index: 45;
  left: 50%;
  bottom: clamp(2rem, 5vh, 4rem);
  display: none;
  padding: 0.75rem 1.2rem;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 100px;
  background: rgba(15, 10, 8, 0.45);
  cursor: pointer;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
}

.is-ended .replay {
  display: block;
  animation: replay-in 1s 1.5s both;
}

@keyframes replay-in {
  from { opacity: 0; transform: translate(-50%, 15px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 700px) {
  .frame {
    padding-inline: 1.5rem;
  }

  .layout-duet,
  .layout-triptych,
  .layout-grid {
    grid-template-columns: 1fr;
    gap: 0.8rem;
    padding: 5.5rem 2.3rem 7rem;
  }

  .layout-duet .media-card,
  .layout-triptych .media-card,
  .layout-triptych .media-card:nth-child(2),
  .layout-grid .media-card {
    width: 100%;
    height: 26vh;
    border-width: 4px;
    border-bottom-width: 10px;
  }

  .layout-triptych .media-card {
    height: 20vh;
  }

  .layout-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }

  .layout-grid .media-card {
    height: 27vh;
  }

  .layout-gallery-five {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 1fr));
    gap: 0.65rem;
    padding: 5rem 1.4rem 7.5rem;
  }

  .layout-gallery-five .media-card,
  .layout-gallery-five .media-card:nth-child(1),
  .layout-gallery-five .media-card:nth-child(2),
  .layout-gallery-five .media-card:nth-child(n + 3) {
    grid-column: span 1;
    width: 100%;
    height: 18vh;
    border-width: 4px;
    border-bottom-width: 9px;
  }

  .layout-gallery-five .media-card:nth-child(5) {
    grid-column: 1 / -1;
  }

  .layout-stack .media-card {
    width: 66vw;
    height: 55vh;
  }

  .layout-stack .media-card:nth-child(2) {
    --x: 16vw;
    --x-end: 13vw;
  }

  .layout-stack .media-card:nth-child(3) {
    --x: -16vw;
    --x-end: -13vw;
  }

  .layout-hero .media-card,
  .layout-wide .media-card {
    width: 88vw;
    height: 63vh;
  }

  .layout-portrait .media-card {
    width: 76vw;
    height: 66vh;
  }

  #headline {
    font-size: clamp(2.6rem, 13vw, 4.8rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
