/* ==========================================================================
   Hero module (js/hero.js): state hooks, blueprint, readout, touch button and
   the title-sequence pre-states. Everything here hangs on .hero[data-state]
   (set by hero.js) or html.intro-run, so the static hero in main.css is the
   fallback whenever the script does not run.
   ========================================================================== */

/* fitted words: an isolated layout box. Not paint-contained: the italic
   overhang and the tilted ART glyphs reach outside the cap-height box. */
.hero[data-state] .word{contain:layout}

/* ART glyphs settle on their resting tilts while the half is open */
.hero[data-state] .word--art .g{transition:transform var(--d-3) var(--e-spring)}
.hero:is([data-state="art"],[data-state="enter-art"]) .word--art .g:nth-child(1){transform:rotate(-2deg)}
.hero:is([data-state="art"],[data-state="enter-art"]) .word--art .g:nth-child(2){transform:rotate(1deg)}
.hero:is([data-state="art"],[data-state="enter-art"]) .word--art .g:nth-child(3){transform:rotate(-1deg)}

/* blueprint: a 1px box whose bottom-right corner is the right end of the
   word's baseline; hero.js writes the lines in that corner's coordinates */
.hero[data-state] .blueprint{inset:auto var(--pad-seam) 36% auto;width:1px;height:1px}
.hero[data-state] .bp{shape-rendering:crispEdges;stroke-dasharray:1;stroke-dashoffset:1;visibility:hidden}
.hero:is([data-state="eng"],[data-state="enter-eng"]) .bp{stroke-dashoffset:0;visibility:visible;
  transition:stroke-dashoffset var(--d-3) var(--e-mech)}

/* readout: only while the ENG half is open; the connector is drawn, not typed */
.hero[data-state] .readout{visibility:hidden}
.hero:is([data-state="eng"],[data-state="enter-eng"]) .readout{visibility:visible}
.readout__to{display:inline-block;position:relative;width:1.2em;height:.6em;margin:0 .4em}
.readout__to::before{content:"";position:absolute;left:0;right:0;top:50%;border-top:1px solid}
.readout__to::after{content:"";position:absolute;right:1px;top:50%;width:.4em;height:.4em;margin-top:-.2em;
  border-top:1px solid;border-right:1px solid;transform:rotate(45deg)}

/* ENG list: Buz → Kağıt, one line at a time (no fade) */
.hero:is([data-state="eng"],[data-state="enter-eng"]) .half--eng .half__list li{color:var(--kagit);
  transition:color 0s steps(1) calc(var(--li,0)*var(--stagger))}
.half__list li:nth-child(2){--li:1}
.half__list li:nth-child(3){--li:2}
.half__list li:nth-child(4){--li:3}
.half__list li:nth-child(5){--li:4}
.half__list li:nth-child(6){--li:5}

/* touch: the link of an expanded half is its "explore" button */
.touch .hero[data-state="eng"] .half--eng .half__link,
.touch .hero[data-state="art"] .half--art .half__link{display:inline-block;height:auto;min-height:44px;margin-top:var(--s-3);
  padding:0 var(--s-4);border:1px solid;line-height:42px;text-decoration:none;opacity:1;overflow:visible}

@media (max-width:767px){
  .hero[data-state] .blueprint{display:none}
  .hero[data-state] .readout{display:none}
  .hero[data-state="eng"] .readout{display:block;margin-top:var(--s-2)}
  /* a squeezed top half has no room for its kicker under the nav tabs */
  .hero[data-state="art"] .half--eng .half__kicker{visibility:hidden}
  /* a squeezed bottom half keeps only its word: the line would sit in the dot strip at the page edge */
  .hero[data-state="eng"] .half--art .half__line{display:none}
}

/* ---------- title sequence (spec 5.9) ----------
   The dark sheet covers the page; the ink panels (stage mode) or the hero
   halves (flat mode) are lifted above it and print outward from the seam.
   hero.js animates out of these pre-states with WAAPI and then removes
   html.intro-run, so nothing below can outlive the sequence. */
html.intro-run body{background:var(--ustbaski)}            /* the dark sheet, before hero.js adds .intro */
html.intro-run .intro{z-index:var(--z-intro)}
.intro>i{position:absolute;top:0;bottom:0;left:46%;width:1px;background:var(--kagit);transform:scaleY(0);transform-origin:0 0}
html.intro-run .stage{z-index:calc(var(--z-intro) + 1);background:none}
html.intro-run .stage__paper{visibility:hidden}
html.intro-run :is(main,.nav,.inkbar){z-index:calc(var(--z-intro) + 1)}
html.intro-run :is(.nav,.inkbar,.seamstrip,.hero__brush){opacity:0}
html.intro-run:not(.flat) .stage__eng,html.intro-run.flat .half--eng{clip-path:inset(0 0 0 100%)}
html.intro-run:not(.flat) .stage__art,html.intro-run.flat .half--art{clip-path:inset(0 100% 0 0)}
html.intro-run .hero .word .g{opacity:0}
html.intro-run .hero :is(.half__kicker,.half__line,.half__list li){clip-path:inset(0 0 100% 0)}
@media (max-width:767px){
  html.intro-run.flat .half--eng{clip-path:inset(100% 0 0 0)}
  html.intro-run.flat .half--art{clip-path:inset(0 0 100% 0)}
}

/* entering a world: the other half is pushed off the sheet, its lines do not re-wrap on the way */
.hero[data-state="enter-eng"] .half--art :is(.half__kicker,.half__line,.half__list),
.hero[data-state="enter-art"] .half--eng :is(.half__kicker,.half__line,.half__list){white-space:nowrap;max-width:none}
html.intro-run .hero .half__link{opacity:0}

/* The brush canvas is z-index:-1 inside its half. main.css relies on
   container-type to make the half a stacking context; current Chromium no
   longer does that, so in flat mode the canvas fell behind the half's ground. */
.hero .half{isolation:isolate}

/* a narrow squeezed half has no room for its list: only the line stays */
@media (min-width:768px) and (max-width:1299px){
  .hero[data-state="eng"] .half--art .half__list,.hero[data-state="art"] .half--eng .half__list{display:none}
}
/* bottom block vs. the word: hero.js measures each half in each state (data-fit) */
.half[data-fit="1"] .half__list{font-size:var(--t-0)}
.half:is([data-fit="2"],[data-fit="3"]) .half__list{display:none}
.half[data-fit="3"] .half__line{font-size:var(--t-1)}
/* short viewports: the list block reaches the baseline, so the readout sits above the cap line */
@media (min-width:768px) and (max-height:860px){
  .hero[data-state] .half .readout{top:auto;bottom:calc(36% + var(--bp-cap,calc(var(--svh)*30)) + 22px)}
}

/* Reduced motion: the hero words and the axis.fit() measurer are measured right
   after a style write, so they never take a transition. (main.css now uses 0s
   durations under reduced motion; this stays as a guard.) */
.reduced .hero .word,.reduced .hero .word .g,
.reduced body>span[aria-hidden="true"]:is(.eng,.art){transition-property:none!important}

/* short phones: an open ENG half drops its kicker and readout, a squeezed one
   its line, so nothing slides under the nav tabs */
@media (max-width:767px) and (max-height:800px){
  .hero[data-state="eng"] .half--eng :is(.half__kicker,.readout){display:none}
  .hero[data-state="art"] .half--eng .half__line{display:none}
}
