/* 暁 Hero. Kasane (重ね) means layering, and the frame is literally a stack, back to front:
   city photo (z -4) → shade gradient (-2) → grid (-1) → red sun (0) → the KASANE word (2) → Aya (3)
   → copy and the seal (5, 6). Putting the character in front of the word is the whole trick. */

.hero {
  position: relative;
  height: 185svh;
}
.hero-frame {
  position: sticky;
  top: 0;
  height: 100svh;
  min-height: 650px;
  overflow: clip;
  isolation: isolate;
  background: var(--surface-hero);
}

/* ---------- Layers ---------- */
.hero-city {
  position: absolute;
  inset: 0;
  z-index: -4;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.65);
  opacity: var(--city-light, 0.26); /* the city brightens as everything else leaves */
  transform: scale(var(--city-scale, 1));
}
.hero-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(90deg, #10150de8 0%, #14190c88 46%, transparent 75%),
    linear-gradient(0deg, #111510 0%, transparent 35%, #11151066 100%);
  opacity: var(--hero-shade, 1);
}
.hero-grid {
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(#ebe5d322 1px, transparent 1px), linear-gradient(90deg, #ebe5d322 1px, transparent 1px);
  background-size: 110px 110px;
  mask-image: linear-gradient(90deg, transparent, #000);
  opacity: var(--grid-light, 0.11);
}
.sun {
  position: absolute;
  right: 9%;
  top: 19%;
  z-index: 0;
  width: 37vw;
  height: 37vw;
  max-width: 610px;
  max-height: 610px;
  background: radial-gradient(circle at 42% 38%, var(--shu-light), var(--shu) 55%, #c53a26);
  border-radius: 50%;
  opacity: 0.93;
  box-shadow: 0 0 120px #d9442f22;
}
.sun::after {
  content: "";
  position: absolute;
  inset: -20px;
  border: 1px solid #d9442f4d;
  border-radius: 50%;
}

/* ---------- The word ---------- */
.hero-title {
  position: absolute;
  top: 21%;
  left: 3.3%;
  right: 3.3%;
  z-index: 2;
  line-height: 1;
  transform-origin: left center;
  perspective: 1200px;
  will-change: transform;
}
.hero-title h1 {
  display: inline-block;
  font: 800 var(--text-hero) / 0.8 var(--font-display);
  letter-spacing: -0.01em;
  color: var(--paper);
}
.hero-title h1[tabindex="-1"]:focus {
  outline: none;
}
.hero-title .title-ink {
  display: block;
  /* The window the entrance wipes open. It reaches past the line box on every side: the word sits in
     a line box 0.8 times its size, and Shippori Mincho's feet hang about 7 px below it, so a clip that
     hugged the box would cut the bottom of every letter. */
  clip-path: polygon(-5% -25%, 105% -25%, 105% 125%, -5% 125%);
  opacity: var(--ink-opacity, 1);
}
/* The game-title lockup: THE LAST DAWN between two brush lines, under the word */
.hero-subtitle {
  display: flex;
  align-items: center;
  gap: 18px;
  width: max-content;
  margin-top: 1.6vw;
  padding-left: 0.6vw;
  font: 400 var(--text-lead) / 1 var(--font-display);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: var(--ink-opacity, 1); /* it leaves with the word */
}
.hero-subtitle::before,
.hero-subtitle::after {
  content: "";
  width: 46px;
  height: 1px;
  background: var(--shu);
}

/* ---------- The character, in front of the word ---------- */
.hero-art {
  position: absolute;
  right: -4%;
  bottom: -1%;
  z-index: 3;
  width: 65%;
  height: 88%;
  object-fit: contain;
  object-position: center bottom;
  pointer-events: none;
  transform-origin: 50% 70%;
  filter: drop-shadow(-18px 25px 30px #0005);
  will-change: transform;
}

/* ---------- The entrance: KASANE inks in from the left, Aya slides in ----------
   js/sections/passage.js adds .hero-entered when the walk reaches the city (or you skip it). */
.hero-entered .title-ink {
  animation: ink-in 1.7s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.hero-entered .hero-subtitle {
  animation: rise-in 1.2s 0.7s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.hero-entered .hero-art {
  animation: art-in 1.9s 0.15s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
@keyframes ink-in {
  0% {
    clip-path: polygon(-5% -25%, -5% -25%, -5% 125%, -5% 125%);
    filter: blur(10px);
  }
  65% {
    filter: blur(0);
  }
  100% {
    clip-path: polygon(-5% -25%, 105% -25%, 105% 125%, -5% 125%);
  }
}
@keyframes art-in {
  from {
    opacity: 0;
    translate: 60px 12px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}
@keyframes rise-in {
  from {
    opacity: 0;
    translate: 0 12px;
  }
}

/* ---------- Copy and the seal ---------- */
.hero-story {
  position: absolute;
  bottom: 96px;
  left: var(--pad);
  z-index: 5;
  width: 440px;
  will-change: transform;
}
.hero-story h2 {
  margin-bottom: 18px;
}
.hero-story p {
  max-width: 320px;
  margin-bottom: 28px;
  color: #c3c8b4;
}
/* 重ね stamped in vermilion, like the artist's seal on an ink painting */
.hero-seal {
  position: absolute;
  right: calc(var(--pad) + 6px);
  bottom: 96px;
  z-index: 6;
  padding: 12px 8px;
  writing-mode: vertical-rl;
  font: 800 var(--text-lead) / 1 var(--font-display);
  letter-spacing: 0.2em;
  color: #ffeedd;
  text-shadow: var(--carved);
  border-radius: 4px;
  /* carved lacquer, like the buttons (css/base.css) */
  background: var(--grain) 0 0 / 200px 200px, var(--lacquer);
  background-blend-mode: overlay, normal;
  box-shadow:
    inset 0 1px 0 #ffc8b080,
    inset 0 -1px 0 #5c130a8c,
    0 3px 0 #6a1a0e,
    0 6px 12px #0000005c;
  opacity: var(--hero-meta, 1);
}

/* The next chapter's title, waiting in the hero until the layers part */
.chapter-incoming {
  position: absolute;
  left: var(--pad);
  top: 34%;
  z-index: 6;
  max-width: 70%;
  color: var(--paper);
  opacity: 0;
  pointer-events: none;
  transform-origin: 30% 50%;
  text-shadow: 0 4px 40px #0008;
}
.chapter-incoming .chapter-mark {
  margin-bottom: 26px;
}

/* ---------- Large, tablet and short screens ---------- */
@media (max-width: 1100px) {
  .hero-story {
    width: 320px;
  }
  .hero-art {
    right: -12%;
    width: 80%;
  }
  .hero-title {
    top: 24%;
  }
}
@media (min-width: 761px) and (max-height: 760px) {
  /* keep the title, subtitle and story apart on shallow desktop windows */
  .hero-frame {
    min-height: 600px;
  }
  .hero-title {
    top: 17%;
  }
  .hero-title h1 {
    font-size: min(var(--text-hero), 30svh);
  }
  .hero-story {
    bottom: 70px;
  }
  .hero-story h2 {
    margin-bottom: 12px;
  }
  .hero-story p {
    margin-bottom: 18px;
  }
  .hero-art {
    height: 84%;
    bottom: 0;
    right: -7%;
  }
}
@media (min-width: 761px) and (max-height: 619px) {
  html.compact-layout .hero-frame {
    min-height: 720px;
  }
}

/* ---------- Phone ---------- */
@media (max-width: 760px) {
  .hero {
    height: 155svh;
  }
  .hero-frame {
    min-height: 720px;
  }
  .hero-frame::after {
    background:
      linear-gradient(0deg, #111510 2%, #111510e0 17%, transparent 52%), linear-gradient(90deg, #11151066, transparent);
  }
  .hero-title {
    left: 20px;
    right: 20px;
    top: 110px;
  }
  .hero-subtitle {
    gap: 12px;
    margin-top: 14px;
    padding-left: 2px;
  }
  .hero-subtitle::before,
  .hero-subtitle::after {
    width: 26px;
  }
  .sun {
    top: 27%;
    right: -9%;
    width: 75vw;
    height: 75vw;
  }
  .hero-art {
    width: 126%;
    height: 68%;
    right: -30%;
    bottom: 16%;
  }
  .hero-story {
    bottom: 40px;
    left: var(--pad);
    width: calc(100% - 44px);
    isolation: isolate;
  }
  .hero-story::before {
    /* a soft dark patch behind the copy, since Aya stands right behind it on phones */
    content: "";
    position: absolute;
    inset: -25px -5px -15px -24px;
    z-index: -1;
    background: linear-gradient(90deg, #111510f2, #111510cc 50%, transparent);
    filter: blur(15px);
  }
  .hero-story h2 {
    max-width: 300px;
    margin-bottom: 12px;
    text-shadow: 0 2px 20px #111510;
  }
  .hero-story p {
    max-width: 260px;
    margin-bottom: 20px;
    color: #cfd4c2;
  }
  .hero-seal {
    top: 40%;
    bottom: auto;
    right: 18px;
    padding: 9px 6px;
  }
  .chapter-incoming {
    top: 32%;
    max-width: 90%;
  }
}
@media (max-width: 760px) and (max-height: 760px) {
  .hero-frame {
    min-height: 670px;
  }
  .hero-art {
    height: 64%;
    bottom: 19%;
  }
}

/* ---------- Reduced motion: a still poster ---------- */
html:is(.reduced, .compact-layout) .hero {
  height: auto;
}
html:is(.reduced, .compact-layout) .hero-frame {
  position: relative;
  height: 100svh;
}
html:is(.reduced, .compact-layout) :is(.hero-art, .hero-title) {
  transform: none !important;
}
html:is(.reduced, .compact-layout) .chapter-incoming {
  display: none;
}
html:is(.reduced, .compact-layout) :is(.title-ink, .hero-subtitle) {
  opacity: 1 !important;
}
html:is(.reduced, .compact-layout) main .hero-city {
  opacity: 0.26;
  transform: none;
}
html:is(.reduced, .compact-layout) main .hero-seal {
  opacity: 1;
}
