@font-face {
  font-family: "Marck Script";
  src: url("./assets/web/MarckScript-Regular.woff") format("woff");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Forum";
  src: url("./assets/web/Forum-Regular.woff") format("woff");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:root {
  color-scheme: light;
  --cloth: url("../../docs/art/stage-2b-1/texture/canvas-1x.webp");
  --cloth-phase: -1237px;
  --paper: #e3dccf;
  --ink: #354239;
  --frame-height: 100vh;
  --first-scale: 1.39;
  --first-x: 4.73;
  --first-y: .567952381;
  --identity-baseline: .942857143;
  --identity-size: 34px;
  --baseline-correction: .7395em;
  --first-palm-x: -130px;
  --first-palm-y: .527380952;
  --first-palm-width: 513px;
  --first-palm-strength: .65;
  --first-rest-right: -69px;
  --first-rest-y: .090476190;
  --first-rest-width: 373px;
  --first-rest-strength: .64;
  --dialogue-height: 1237px;
  --speaker-x: calc(50% - 138px);
  --speaker-baseline: .669047619;
  --speaker-size: 64px;
  --listener-x: calc(50% - 286px);
  --listener-baseline: 1.195238095;
  --listener-size: 62px;
  --open-palm-x: -116px;
  --open-palm-y: .447619048;
  --open-palm-width: 653px;
  --open-palm-strength: .89;
  --open-rest-right: -20px;
  --open-rest-y: .776190476;
  --open-rest-width: 420px;
  --open-rest-strength: .86;
  --travel-ratio: 1.05;
}

@supports (height: 100svh) {
  :root {
    --frame-height: 100svh;
  }
}

@media (min-width: 768px) and (max-height: 699px) {
  :root {
    --first-scale: 1.045;
    --first-palm-x: calc(var(--frame-height) * -.154761905);
    --first-palm-width: calc(var(--frame-height) * .610714286);
    --first-rest-right: calc(var(--frame-height) * -.082142857);
    --first-rest-width: calc(var(--frame-height) * .444047619);
    --open-palm-x: calc(var(--frame-height) * -.138095238);
    --open-palm-width: calc(var(--frame-height) * .777380952);
    --open-rest-right: calc(var(--frame-height) * -.023809524);
    --open-rest-width: calc(var(--frame-height) * .5);
  }
}

@media (min-width: 768px) and (max-height: 539px) {
  :root {
    --first-scale: .765;
  }
}

@media (max-width: 767px) {
  :root {
    --cloth-phase: -1047px;
    --first-scale: .705;
    --first-x: 2.397;
    --first-y: .543174286;
    --identity-baseline: .945714286;
    --identity-size: 23px;
    --first-palm-x: -64px;
    --first-palm-y: .697142857;
    --first-palm-width: 233px;
    --first-palm-strength: .64;
    --first-rest-right: -60px;
    --first-rest-y: -.064285714;
    --first-rest-width: 185px;
    --first-rest-strength: .57;
    --dialogue-height: 1047px;
    --speaker-x: max(18px, calc(50% - 144px));
    --speaker-baseline: .861428571;
    --speaker-size: clamp(29px, 9.23vw, 36px);
    --listener-x: max(18px, calc(50% - 168px));
    --listener-baseline: 1.328571429;
    --listener-size: clamp(27px, 8.21vw, 32px);
    --open-palm-x: -76px;
    --open-palm-y: .4;
    --open-palm-width: 291px;
    --open-palm-strength: .88;
    --open-rest-right: -31px;
    --open-rest-y: .95;
    --open-rest-width: 182px;
    --open-rest-strength: .85;
    --travel-ratio: .95;
  }
}

@media (max-width: 359px) {
  :root {
    --first-scale: .625;
  }
}

@media (max-width: 767px) and (max-height: 559px) {
  :root {
    --first-scale: .525;
  }
}

@media (max-height: 399px) {
  :root {
    --first-scale: .4;
  }
}

html {
  background: var(--paper);
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Marck Script", cursive;
}

.skip-link {
  position: fixed;
  z-index: 2;
  inset: .75rem auto auto .75rem;
  padding: .5rem 1rem;
  border-radius: 2px;
  color: var(--ink);
  background: var(--paper);
  font-family: system-ui, sans-serif;
  transform: translateY(calc(-100% - 1rem));
}

.skip-link:focus {
  transform: none;
}

:focus-visible {
  outline: 2px solid #713241;
  outline-offset: 3px;
}

#opening {
  --run-distance: 0px;
  background: var(--paper) var(--cloth) repeat 0 var(--cloth-phase) / 1536px 1536px;
  /* Preserve the browser's history coordinate while the interactive layout mounts. */
  overflow-anchor: none;
}

.scroll-run {
  height: calc(var(--frame-height) + var(--run-distance));
}

.stage {
  position: relative;
  height: var(--frame-height);
  margin: 0;
  overflow: hidden;
}

.sign-hand,
.dialogue-hand {
  position: absolute;
  display: block;
  height: auto;
  pointer-events: none;
}

.sign-hand {
  transform-origin: top left;
}

.sign-palm {
  left: var(--first-palm-x);
  top: calc(var(--frame-height) * var(--first-palm-y));
  width: var(--first-palm-width);
  opacity: var(--first-palm-strength);
}

.sign-rest {
  right: var(--first-rest-right);
  top: calc(var(--frame-height) * var(--first-rest-y));
  width: var(--first-rest-width);
  opacity: var(--first-rest-strength);
}

.emblem {
  position: absolute;
  inset: 0;
  display: block;
}

#opening:not([data-motion="active"]) [data-camera] {
  transform-box: view-box;
  transform:
    translate(calc(50% + var(--first-x) * 1px), calc(100% * var(--first-y)))
    scale(var(--first-scale))
    translate(-283.4px, -348.4px);
}

.pigment,
.releasing-ink {
  display: none;
}

.pigment {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--pigment-width);
  transform-origin: top left;
  opacity: 0;
  pointer-events: none;
}

.pigment img {
  display: block;
  width: 100%;
  height: auto;
}

.identity,
.speaker,
.listener {
  position: absolute;
  margin: 0;
  color: var(--ink);
  line-height: 1;
  white-space: nowrap;
}

.identity {
  top: calc(var(--frame-height) * var(--identity-baseline));
  left: 50%;
  font-size: var(--identity-size);
  transform: translate(-50%, calc(-1 * var(--baseline-correction)));
}

.dialogue {
  position: relative;
  min-height: calc(var(--dialogue-height) + max(0px, var(--frame-height) - 840px) * 1.25);
}

.dialogue:focus-visible {
  outline-offset: -3px;
}

.dialogue-art {
  position: absolute;
  inset: 0;
  overflow: clip;
}

.dialogue-palm {
  left: var(--open-palm-x);
  top: calc(var(--frame-height) * var(--open-palm-y));
  width: var(--open-palm-width);
  opacity: var(--open-palm-strength);
}

.dialogue-rest {
  right: var(--open-rest-right);
  top: calc(var(--frame-height) * var(--open-rest-y));
  width: var(--open-rest-width);
  opacity: var(--open-rest-strength);
}

.speaker {
  top: calc(var(--frame-height) * var(--speaker-baseline) - var(--baseline-correction));
  left: var(--speaker-x);
  font-size: var(--speaker-size);
}

.listener {
  top: calc(var(--frame-height) * var(--listener-baseline) - var(--baseline-correction));
  left: var(--listener-x);
  font-size: var(--listener-size);
}

#opening[data-motion="active"] {
  --run-distance: calc(var(--frame-height) * var(--travel-ratio));
  --run-distance: round(down, calc(var(--frame-height) * var(--travel-ratio)), 1px);
  background-position-y: calc(var(--run-distance) + var(--cloth-phase));
}

#opening[data-motion="active"] .stage {
  position: sticky;
  top: 0;
  background: var(--paper) var(--cloth) repeat 0 var(--cloth-phase) / 1536px 1536px;
}

#opening[data-motion="active"] .dialogue {
  margin-top: calc(-1 * var(--frame-height));
}

#opening[data-motion="active"] .still-heart {
  display: none;
}

#opening[data-motion="active"] :is(.pigment, .releasing-ink) {
  display: block;
}

#opening[data-motion="active"] .dialogue-art {
  opacity: 0;
}

@media (max-width: 767px) {
  .dialogue {
    min-height: calc(var(--dialogue-height) + max(0px, var(--frame-height) - 700px) * 1.4);
  }
}

/* Keep the sticky sheet taller than a mobile browser's changing toolbar. */
@media (max-width: 767px), (max-width: 1100px) and (pointer: coarse) {
  @supports (height: 100lvh) {
    :root { --frame-height: 100lvh; }
    .identity { top: min(calc(var(--frame-height) * var(--identity-baseline)), calc(100svh - max(32px, env(safe-area-inset-bottom)))); }
  }
  #opening[data-motion="active"] .stage { contain: paint; }
}

@media (max-width: 1100px) {
  :root { --cloth: url("./assets/adaptive/canvas.webp"); }
}

.stage .sign-hand { display: none; }
