/* =========================
   Base
========================= */

:root {
  --paper-base: #f3eee1;
  --paper-light: #faf7ef;
  --ink: #24211d;
  --ink-soft: rgba(36, 33, 29, 0.72);
  --scene-width: 1200px;
}

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

html {
  scroll-behavior: smooth;
  scrollbar-width: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;
}

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background-color: var(--paper-base);
  font-family: "Shippori Mincho", serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -4;
  content: "";

  background:
    linear-gradient(
      rgba(248, 244, 234, 0.55),
      rgba(239, 232, 216, 0.48)
    ),
    url("./images/washi.png") center / cover fixed;

  pointer-events: none;
}

body::after {
  position: fixed;
  inset: 0;
  z-index: -3;
  content: "";

  background:
    radial-gradient(
      circle at 15% 15%,
      rgba(255, 255, 255, 0.42),
      transparent 36%
    ),
    radial-gradient(
      circle at 80% 70%,
      rgba(191, 171, 132, 0.11),
      transparent 42%
    );

  pointer-events: none;
}

::selection {
  color: var(--paper-light);
  background: var(--ink);
}

/* =========================
   Main scenes
========================= */

.poem-scroll {
  position: relative;
}

.scene {
  position: relative;
  display: grid;
  min-height: 125vh;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
}

.scene::after {
  position: absolute;
  inset: 0;
  z-index: 10;
  content: "";
  pointer-events: none;

  background:
    linear-gradient(
      to bottom,
      rgba(243, 238, 225, 0.84) 0%,
      transparent 18%,
      transparent 82%,
      rgba(243, 238, 225, 0.84) 100%
    );
}

/*
  各シーンが完全なカードに見えないよう、
  境界線や背景色は付けない。
*/

.scene--title {
  min-height: 100vh;
}

.scene--silence {
  min-height: 90vh;
}

.scene--dedication {
  min-height: 130vh;
}

.scene--credit {
  min-height: 105vh;
}

.closing-space {
  height: 45vh;
}

/* =========================
   Title
========================= */

.title-block {
  position: relative;
  z-index: 20;

  opacity: 0;
  transform: translateY(-18px);
  transition:
    opacity 2.2s ease,
    transform 2.2s ease;
}

.scene.is-active .title-block {
  opacity: 1;
  transform: translateY(0);
}

.title-block h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2.4vw, 2.1rem);
  font-weight: 400;
  letter-spacing: 0.22em;
  writing-mode: vertical-rl;
}

.scroll-guide {
  position: absolute;
  bottom: 7vh;
  left: 50%;
  z-index: 20;
  margin: 0;

  color: rgba(36, 33, 29, 0.46);
  font-family: serif;
  font-size: 0.65rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;

  opacity: 0;
  transform: translateX(-50%);
  transition: opacity 2s ease 1.8s;
}

.scene.is-active .scroll-guide {
  opacity: 1;
}

.scroll-guide::after {
  display: block;
  width: 1px;
  height: 46px;
  margin: 12px auto 0;
  content: "";

  background: linear-gradient(
    to bottom,
    rgba(36, 33, 29, 0.48),
    transparent
  );

  animation: guide-breathe 2.8s ease-in-out infinite;
}

@keyframes guide-breathe {
  0%,
  100% {
    opacity: 0.25;
    transform: scaleY(0.5);
    transform-origin: top;
  }

  50% {
    opacity: 0.85;
    transform: scaleY(1);
    transform-origin: top;
  }
}

/* =========================
   Poetry
========================= */

.poem-block {
  position: relative;
  z-index: 30;

  display: flex;
  flex-direction: column;
  gap: clamp(1.2rem, 3.2vw, 3rem);

  max-width: min(78vw, 950px);
  padding: 8vh 5vw;

  writing-mode: vertical-rl;
  text-orientation: upright;
}
.poem-block--left {
  margin-right: min(46vw, 900px);
}
.poem-block p {
  margin: 0;

  font-size: clamp(1rem, 1.6vw, 1.34rem);
  line-height: 2.25;
  letter-spacing: 0.09em;

  opacity: 0;
  filter: blur(4px);
  transform: translateY(-12px);

  transition:
    opacity 2.4s ease,
    filter 2.4s ease,
    transform 2.4s ease;
}

.scene.is-active .poem-block p {
  opacity: 1;
  filter: blur(0);
  transform: translateY(0);
}

.scene.is-active .poem-block p:nth-child(2) {
  transition-delay: 0.65s;
}

.scene.is-active .poem-block p:nth-child(3) {
  transition-delay: 1.3s;
}

.poem-block--center {
  justify-content: center;
}


.poem-block--right {
  margin-left: min(34vw, 470px);
}

.poem-emphasis {
  font-size: clamp(1.18rem, 1.9vw, 1.55rem) !important;
}

.poem-delayed {
  transition-delay: 2.1s !important;
}

.poem-block--address {
  gap: clamp(3rem, 8vw, 8rem);
}

.poem-block--long {
  max-width: min(82vw, 1050px);
  gap: clamp(1.8rem, 4vw, 4rem);
}

.poem-block--city {
  margin-left: 0;
  color: rgba(20, 18, 16, 0.9);
}

/* =========================
   Memory images
========================= */

.memory-image,
.city-memory,
.dedication-image {
  position: absolute;
  z-index: 5;

  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;

  filter:
    grayscale(1)
    contrast(0.86)
    brightness(1.08);

  opacity: 0;
  transform: translate3d(0, 50px, 0) scale(1.08);

  transition:
    opacity 3.2s ease 1.1s,
    filter 3.2s ease,
    transform 0.15s linear;

  /*
    写真の縁を和紙に溶かす。
  */
  -webkit-mask-image: radial-gradient(
    ellipse at center,
    #000 42%,
    rgba(0, 0, 0, 0.92) 64%,
    transparent 84%
  );

  mask-image: radial-gradient(
    ellipse at center,
    #000 42%,
    rgba(0, 0, 0, 0.92) 64%,
    transparent 84%
  );

  mix-blend-mode: multiply;
}

.scene.is-active .memory-image,
.scene.is-active .city-memory {
  opacity: 0.6;
  filter:
    grayscale(1)
    contrast(0.94)
    brightness(1.05);
}

.memory-image--letter {
  inset: 0;
  width: 100%;
  height: 100%;
  background-image: url("./images/letter-table.png");
  background-size: cover;
  background-position: center;

  -webkit-mask-image: none;
  mask-image: none;
}
.smoke {
  position: absolute;
  z-index: 18;
  pointer-events: none;

  width: 140px;
  height: 280px;

  border-radius: 50%;
  background:
    radial-gradient(
      ellipse at center,
      rgba(255, 255, 255, 0.22) 0%,
      rgba(255, 255, 255, 0.1) 35%,
      transparent 72%
    );

  filter: blur(18px);
  opacity: 0;
  mix-blend-mode: screen;
}

.scene.is-active .smoke {
  animation: smoke-rise 10s ease-in-out infinite;
}
.poem-block--ashtray {
  transform: translateX(-10vw);
}
.smoke--one {
  top: 22%;
  right: 20%;
}

.smoke--two {
  top: 18%;
  right: 25%;
  width: 90px;
  height: 220px;
  animation-delay: 3.2s !important;
}

@keyframes smoke-rise {
  0% {
    opacity: 0;
    transform: translate3d(0, 24px, 0) scaleX(0.7) rotate(-4deg);
  }

  20% {
    opacity: 0.28;
  }

  55% {
    opacity: 0.16;
    transform: translate3d(-12px, -55px, 0) scaleX(1.05) rotate(5deg);
  }

  100% {
    opacity: 0;
    transform: translate3d(16px, -125px, 0) scaleX(1.35) rotate(-7deg);
  }
}

.scene.is-active .memory-image--letter {
  opacity: 0.65;
}

.memory-image--okinawa {
  top: 20%;
  left: 3%;
  width:  min(50vw, 660px);
  height: 60%;
  background-image: url("./images/okinawa-memory.png");

}

.scene.is-active .memory-image--okinawa {
  filter:
    grayscale(0.6)
    saturate(0.85)
    contrast(0.94)
    brightness(1.05);
}

.memory-image--tokyo-small {
  left: 10%;
  bottom: 4%;
  width: min(33vw, 450px);
  height: 43%;
  background-image: url("./images/tokyo-small.jpg");
}

.city-memory {
  inset: 7% 0;
  width: 100%;
  height: 86%;

  background-image: url("./images/showa-tokyo.png");
  background-attachment: fixed;

  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    #000 20%,
    #000 78%,
    transparent 100%
  );

  mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    #000 20%,
    #000 78%,
    transparent 100%
  );
}

.scene.is-active .city-memory {
  opacity: 0.68;
}

.city-paper-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;

  background:
    linear-gradient(
      to right,
      rgba(243, 238, 225, 0.9) 0%,
      rgba(243, 238, 225, 0.2) 42%,
      rgba(243, 238, 225, 0.72) 100%
    );

  mix-blend-mode: screen;
  pointer-events: none;
}

/* =========================
   Pressure / ink
========================= */

.scene--pressure {
  min-height: 145vh;
}

.ink-shadow {
  position: absolute;
  z-index: 2;
  border-radius: 50%;
  background: rgba(80, 77, 68, 0.09);
  filter: blur(70px);
  opacity: 0;
  transition: opacity 3s ease;
}

.ink-shadow--one {
  top: 24%;
  left: -8%;
  width: 62vw;
  height: 44vw;
}

.ink-shadow--two {
  right: -12%;
  bottom: 14%;
  width: 58vw;
  height: 40vw;
}

.scene.is-active .ink-shadow {
  opacity: 1;
}

/* =========================
   Final words
========================= */

.scene--final-word {
  min-height: 118vh;
}

.final-message {
  position: relative;
  z-index: 30;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1em;
  writing-mode: vertical-rl;
}

.final-word,
.final-line {
  position: relative;
  writing-mode: inherit;
}

.final-word p,
.final-line p {
  margin: 0;
  letter-spacing: 0.18em;
  opacity: 0;
  filter: blur(6px);
  transform: translateY(-22px);

  transition:
    opacity 2.5s ease,
    filter 2.5s ease,
    transform 2.5s ease;
}

.final-word p {
  font-size: clamp(1rem, 1.7vw, 1.4rem);
}

.final-line p {
  font-size: clamp(1rem, 1.7vw, 1.4rem);
  white-space: nowrap;
  transition-delay: 1s;
}

.scene.is-active .final-word p,
.scene.is-active .final-line p {
  opacity: 1;
  filter: blur(0);
  transform: translateY(0);
}

/* =========================
   Paper light
========================= */

.paper-light {
  position: absolute;
  inset: 0;
  z-index: 1;

  background:
    radial-gradient(
      ellipse at 72% 28%,
      rgba(255, 255, 255, 0.8),
      transparent 43%
    );

  opacity: 0;
  transition: opacity 3s ease;
}

.scene.is-active .paper-light {
  opacity: 1;
}

.paper-light--two {
  background:
    radial-gradient(
      ellipse at center,
      rgba(255, 255, 255, 0.64),
      transparent 62%
    );
}

/* =========================
   Dedication
========================= */

.scene--dedication {
  background: #f3f1ec;
}

.dedication-image {
  inset: 0;
  z-index: 2;
  inset: -15% 0 15%;
  background-image: url("./images/white-flowers.png");
  background-attachment: fixed;
  background-position: center 35%;
  filter:
    grayscale(0.86)
    contrast(0.91)
    brightness(1.05);

  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    #000 12%,
    #000 88%,
    transparent 100%
  );

  mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    #000 12%,
    #000 88%,
    transparent 100%
  );
}

.scene.is-active .dedication-image {
  opacity: 0.86;
  transform: scale(1.02);
}

.dedication-text {
  position: relative;
  z-index: 3;

  width: min(78vw, 760px);
  margin-top: 32vh;
  padding: 3rem;

  text-align: center;

  opacity: 0;
  transform: translateX(3vw);
  transform: translateY(-22px);
  transition:
    opacity 2.8s ease 1.7s,
    transform 2.8s ease 1.7s;
}

.scene.is-active .dedication-text {
  opacity: 1;
  transform: translateY(0);
}

.dedication-text p {
  margin: 0;
  font-size: clamp(0.86rem, 1.3vw, 1.05rem);
  line-height: 2.2;
  letter-spacing: 0.08em;
}

.dedication-heading {
  margin-bottom: 1.7rem !important;
  font-size: clamp(1rem, 1.6vw, 1.3rem) !important;
}

/* =========================
   Credits
========================= */

.credit-block {
  position: relative;
  z-index: 30;

  text-align: center;

  opacity: 0;
  transform: translateY(-22px);
  transition:
    opacity 2.8s ease,
    transform 2.8s ease;
}

.scene.is-active .credit-block {
  opacity: 1;
  transform: translateY(0);
}

.credit-block p {
  margin: 0 0 2.3rem;
  font-size: clamp(0.76rem, 1.15vw, 0.95rem);
  line-height: 2;
  letter-spacing: 0.08em;
}

.credit-title {
  font-size: clamp(1rem, 1.5vw, 1.25rem) !important;
}

.credit-note {
  color: var(--ink-soft);
  font-size: 0.7rem !important;
}

/* =========================
   Responsive
========================= */

@media (max-width: 760px) {
  .scene {
    min-height: 120svh;
  }

  .scene--title {
    min-height: 100svh;
  }

  .scene--pressure {
    min-height: 155svh;
  }

  .poem-block {
    max-width: 92vw;
    padding-inline: 7vw;
    gap: 1.1rem;
  }

  .poem-block p {
    font-size: clamp(0.94rem, 4vw, 1.12rem);
    line-height: 2.05;
  }

  .poem-block--left,
  .poem-block--right,
  .poem-block--city {
    margin-right: 0;
    margin-left: 0;
  }

  .memory-image--letter {
    top: 8%;
    right: -20%;
    width: 95vw;
    height: 75%;
  }

  .memory-image--okinawa {
    top: 5%;
    left: -30%;
    width: 105vw;
  }

  .memory-image--tokyo-small {
    right: -16%;
    bottom: 7%;
    width: 70vw;
    height: 38%;
  }

  .city-memory,
  .dedication-image {
    background-attachment: scroll;
  }

  .poem-block--address {
    gap: 2rem;
  }

  .dedication-text {
    width: 90vw;
    margin-top: 46svh;
    padding: 1.5rem;
  }
}

/* =========================
   Reduced motion
========================= */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .memory-image,
  .city-memory,
  .dedication-image {
    transform: none !important;
  }
}
