/* =========================================================
   TOKENS
   ========================================================= */
:root{
  --ink-deep: #05060a;
  --ink: #0b0e14;
  --ink-soft: #12151d;
  --cream: #f3ede2;
  --cream-dim: rgba(243,237,226,0.72);
  --cream-faint: rgba(243,237,226,0.4);
  --gold: #d8b787;
  --gold-soft: rgba(216,183,135,0.55);
  --gold-faint: rgba(216,183,135,0.22);

  --font-serif: "Cormorant Garamond", "Georgia", serif;
  --font-jp: "Shippori Mincho", "Georgia", serif;
  --font-script: "Marck Script", "Cormorant Garamond", cursive;

  --ease: cubic-bezier(.19,.63,.24,1);
  --ease-slow: cubic-bezier(.12,.4,.14,1);

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);

  /* phone frame — vertical ~9:19.5 mobile composition, everywhere */
  --phone-ratio: 0.4615; /* 9 / 19.5 */
  --phone-max-w: 430px;
  --phone-max-h: 932px;
}

*{ box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body{
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--ink-deep);
  overscroll-behavior: none;
}

body{
  position: fixed;
  inset: 0;
  font-family: var(--font-serif);
  color: var(--cream);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* stage: centers the phone-shaped viewport, letterboxing on wide screens */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* =========================================================
   PHONE FRAME — the whole experience always renders as a
   fixed vertical mobile screen, centered on wider viewports.
   On an actual phone-width viewport it fills the screen exactly.
   ========================================================= */
.phone-frame{
  position: relative;
  overflow: hidden;
  background: var(--ink-deep);
  width: min(100vw, calc(100dvh * var(--phone-ratio)), var(--phone-max-w));
  height: min(100dvh, calc(100vw / var(--phone-ratio)), var(--phone-max-h));
  container-type: size;
  container-name: phone;
  border-radius: 34px;
  box-shadow:
    0 40px 100px rgba(0,0,0,0.65),
    0 0 0 1px rgba(216,183,135,0.09),
    0 0 60px rgba(0,0,0,0.4);
}

@media (max-width: 520px){
  .phone-frame{
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
  }
}

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

/* =========================================================
   ATMOSPHERE LAYERS
   ========================================================= */
.grain{
  position: absolute;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  opacity: 0.045;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 160px 160px;
  animation: grainShift 9s steps(6) infinite;
}
@keyframes grainShift{
  0%{ transform: translate(0,0); }
  100%{ transform: translate(-3%,2%); }
}

.vignette{
  position: absolute;
  inset: 0;
  z-index: 998;
  pointer-events: none;
  background: radial-gradient(120% 100% at 50% 45%, transparent 42%, rgba(3,3,5,0.62) 100%);
}

/* shared photo layer — one <img>, reused from scene 2 onward */
.photo-layer{
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  transition: opacity 2.4s var(--ease-slow);
  pointer-events: none;
}
.photo-layer.is-visible{ opacity: 1; }

#photo-img{
  position: absolute;
  inset: -4%;
  width: 108%;
  height: 108%;
  object-fit: cover;
  object-position: 50% 42%;
  filter: saturate(0.92) brightness(0.86) contrast(1.03);
  transform: scale(1);
  transition: object-position 2.6s var(--ease-slow), filter 2.6s var(--ease-slow), transform 2.6s var(--ease-slow);
  animation: slowDrift 26s ease-in-out infinite;
}
@keyframes slowDrift{
  0%{ transform: scale(1.02) translate3d(0,0,0); }
  50%{ transform: scale(1.07) translate3d(-0.6%, -0.4%, 0); }
  100%{ transform: scale(1.02) translate3d(0,0,0); }
}

/* per-scene photo treatment */
#photo-img.crop-two{ object-position: 50% 40%; }
#photo-img.crop-three{ object-position: 62% 48%; filter: saturate(0.98) brightness(0.9) contrast(1.05); }
#photo-img.crop-four{ object-position: 38% 55%; filter: saturate(0.88) brightness(0.8) contrast(1.0); }
#photo-img.crop-final{ object-position: 50% 46%; filter: saturate(0.7) brightness(0.55) contrast(0.98); }

.light-veil{
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 2.2s var(--ease-slow);
  background:
    radial-gradient(70% 55% at 50% 18%, rgba(216,183,135,0.16), transparent 60%),
    linear-gradient(to bottom, rgba(5,6,10,0.15) 0%, rgba(5,6,10,0.05) 35%, rgba(5,6,10,0.55) 100%);
}
.light-veil.is-visible{ opacity: 1; }

.particles{
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 2.4s var(--ease-slow);
  overflow: hidden;
}
.particles.is-visible{ opacity: 1; }
.mote{
  position: absolute;
  bottom: -6px;
  border-radius: 50%;
  background: var(--gold-soft);
  opacity: 0;
  animation: moteRise linear infinite;
  filter: blur(0.2px);
}
@keyframes moteRise{
  0%{ opacity: 0; transform: translateY(0) translateX(0); }
  8%{ opacity: 0.5; }
  85%{ opacity: 0.28; }
  100%{ opacity: 0; transform: translateY(-108cqh) translateX(var(--drift, 18px)); }
}

/* =========================================================
   SCENE FRAMEWORK
   ========================================================= */
#app{
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.scene{
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: calc(7cqh + var(--safe-t)) 8cqw calc(6cqh + var(--safe-b));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(1.015);
  filter: blur(6px);
  transition:
    opacity 1.6s var(--ease-slow),
    transform 1.9s var(--ease-slow),
    filter 1.9s var(--ease-slow),
    visibility 0s linear 1.6s;
}
.scene.is-active{
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: scale(1);
  filter: blur(0px);
  transition:
    opacity 1.6s var(--ease-slow),
    transform 1.9s var(--ease-slow),
    filter 1.9s var(--ease-slow),
    visibility 0s linear 0s;
}

.scene-content{
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* =========================================================
   SCENE 1 — video
   ========================================================= */
.scene--video{ padding: 0; justify-content: flex-end; }

.scene1-video{
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scene1-overlay{
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(to bottom, rgba(4,5,8,0.32) 0%, rgba(4,5,8,0.1) 30%, rgba(4,5,8,0.2) 62%, rgba(3,4,7,0.72) 100%);
}

.scene--video .scene-content{
  padding: 0 8cqw calc(8cqh + var(--safe-b));
  justify-content: center;
  gap: clamp(2.4rem, 8cqh, 3.6rem);
  flex: 1;
}

.jp-block{
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 2s var(--ease-slow), transform 2s var(--ease-slow);
}
.jp-block.is-in{ opacity: 1; transform: translateY(0); }

.jp-main{
  margin: 0;
  font-family: var(--font-jp);
  font-weight: 500;
  font-size: clamp(2rem, 9cqw, 2.7rem);
  letter-spacing: 0.14em;
  color: var(--cream);
  text-shadow: 0 0 30px rgba(0,0,0,0.5);
}
.jp-sub{
  margin: 0.7rem 0 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 0.78rem;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: var(--cream-faint);
  text-transform: uppercase;
}

/* =========================================================
   next-gate — minimal transition button, all scenes
   ========================================================= */
.next-gate{
  background: none;
  border: none;
  padding: 0.5rem 0.2rem;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  color: var(--cream-dim);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 1.8s var(--ease-slow), transform 1.8s var(--ease-slow);
}
.next-gate.is-visible{ opacity: 1; transform: translateY(0); pointer-events: auto; }

.next-gate__line{
  width: 1px;
  height: 26px;
  background: linear-gradient(to bottom, transparent, var(--gold-soft));
}
.next-gate__jp{
  font-family: var(--font-jp);
  font-weight: 500;
  font-size: 1rem;
  letter-spacing: 0.1em;
  color: var(--cream);
}
.next-gate__ru{
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--cream-faint);
}
.next-gate:active .next-gate__jp{ opacity: 0.7; }

/* =========================================================
   SCENES 2–4 — photo + story text
   ========================================================= */
.scene--photo{ justify-content: space-between; }

.scene-content--text{
  flex: 1;
  justify-content: center;
  gap: clamp(3rem, 10cqh, 4.4rem);
  padding-top: 4cqh;
}

.story-text{
  display: flex;
  flex-direction: column;
  gap: clamp(1.6rem, 5cqh, 2.4rem);
}

.story-line{
  margin: 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.15rem, 5.2cqw, 1.45rem);
  line-height: 1.55;
  color: var(--cream-dim);
  opacity: 0;
  transform: translateY(12px);
  filter: blur(2px);
  transition: opacity 2.2s var(--ease-slow), transform 2.2s var(--ease-slow), filter 2.2s var(--ease-slow);
}
.story-line.is-in{
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}
.story-line--emph{
  font-family: var(--font-jp);
  font-style: normal;
  font-weight: 500;
  font-size: clamp(1.5rem, 6.6cqw, 1.9rem);
  color: var(--cream);
  letter-spacing: 0.02em;
}

/* =========================================================
   FINAL SCENE
   ========================================================= */
.scene--final{ justify-content: center; }

.final-dim{
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--ink-deep);
  opacity: 0;
  transition: opacity 5s var(--ease-slow);
  pointer-events: none;
}
.final-dim.is-in{ opacity: 0.93; }

.scene-content--final{
  gap: clamp(3.2rem, 11cqh, 4.8rem);
}

.story-text--final .story-line{
  color: var(--cream-dim);
}

.finale-mark{
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 3.2s var(--ease-slow), transform 3.2s var(--ease-slow);
}
.finale-mark.is-in{ opacity: 1; transform: translateY(0); }

.finale-jp{
  margin: 0;
  font-family: var(--font-jp);
  font-weight: 600;
  font-size: clamp(2.2rem, 10cqw, 3rem);
  letter-spacing: 0.05em;
  color: var(--gold);
  text-shadow: 0 0 46px rgba(216,183,135,0.35);
}
.finale-pre{
  margin: 0.9rem 0 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 0.95rem;
  line-height: 1.6;
  letter-spacing: 0.03em;
  color: var(--cream-faint);
}

/* the emotional centerpiece of the whole site */
.finale-love{
  margin: clamp(1.6rem, 6cqh, 2.6rem) 0 0;
  padding: 0 4cqw;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  filter: blur(8px);
  transition:
    opacity 3.4s var(--ease-slow),
    transform 3.4s var(--ease-slow),
    filter 3.4s var(--ease-slow);
}
.finale-love.is-in{
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0);
}
.finale-love span{
  display: inline-block;
  font-family: var(--font-script);
  font-weight: 400;
  font-size: clamp(3.4rem, 15cqw, 4.6rem);
  line-height: 1.15;
  color: var(--gold);
  letter-spacing: 0.01em;
  text-shadow:
    0 0 18px rgba(216,183,135,0.55),
    0 0 46px rgba(216,183,135,0.35),
    0 0 90px rgba(216,183,135,0.18);
  animation: loveGlow 6s ease-in-out infinite;
  animation-play-state: paused;
}
.finale-love.is-in span{ animation-play-state: running; }
@keyframes loveGlow{
  0%, 100%{
    text-shadow:
      0 0 18px rgba(216,183,135,0.5),
      0 0 46px rgba(216,183,135,0.3),
      0 0 90px rgba(216,183,135,0.16);
  }
  50%{
    text-shadow:
      0 0 24px rgba(216,183,135,0.72),
      0 0 60px rgba(216,183,135,0.42),
      0 0 120px rgba(216,183,135,0.24);
  }
}

/* =========================================================
   SMALL SCREEN REFINEMENT
   ========================================================= */
@media (max-height: 700px){
  .story-text{ gap: clamp(1.2rem, 4cqh, 1.8rem); }
  .story-line{ font-size: clamp(1rem, 5cqw, 1.25rem); line-height: 1.45; }
  .scene-content--text{ gap: clamp(2rem, 7cqh, 3rem); }
  .finale-love span{ font-size: clamp(2.6rem, 13cqw, 3.6rem); }
}

@media (max-width: 340px){
  .story-line{ font-size: 1rem; }
  .jp-main{ font-size: 1.8rem; }
  .finale-love span{ font-size: clamp(2.4rem, 15cqw, 3.2rem); }
}
