:root {
  color-scheme: light;
  --paper: #fbfbf7;
  --ink: #11130f;
  --quiet: rgba(17, 19, 15, 0.5);
  --green: #16633f;
  --acid: #b7d45b;
  --red: #e22d20;
  --spine-x: 24px;
  --copy-x: 62px;
  --target-x: 50%;
  --target-y: 42%;
  --elbow-y: 59%;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: #e8e8e3; }
body {
  min-width: 320px;
  margin: 0;
  background: #e8e8e3;
  color: var(--ink);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}
img { display: block; max-width: 100%; }

.story-shell {
  width: min(100%, 460px);
  margin: 0 auto;
  overflow: clip;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(17, 19, 15, 0.08);
}

.hero-story { height: 100svh; }
.hero-pin,
.chapter-pin {
  position: sticky;
  top: 0;
  width: 100%;
  height: 100svh;
  min-height: 620px;
  overflow: hidden;
  background: var(--paper);
}
.hero-source,
.hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.hero-source { object-fit: cover; opacity: 1; }
.hero-canvas { display: none; background: transparent; }
.hero-pin.is-fading .hero-source { opacity: 0; }
.hero-pin.is-fading .hero-canvas { display: block; }
.draft-badge {
  position: absolute;
  z-index: 4;
  top: max(78px, env(safe-area-inset-top));
  left: 20px;
  width: min(80%, 356px);
  margin: 0;
  padding: 12px 16px 10px;
  background: var(--acid);
  color: var(--ink);
  font-size: 62px;
  font-weight: 600;
  line-height: 0.78;
  letter-spacing: -0.1em;
  text-transform: uppercase;
  box-shadow: 8px 8px 0 rgba(17, 19, 15, 0.9);
}
.hero-pin.is-fading .draft-badge {
  animation: draft-fade-out 5s linear both;
}
@keyframes draft-fade-out {
  0%, 18% { opacity: 1; }
  100% { opacity: 0; }
}

.story-chapter { height: 172svh; }
.chapter-pin {
  padding: max(24px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(17, 19, 15, 0.1);
}
.chapter-index,
.annotation__label,
footer {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 9px;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.chapter-index {
  position: absolute;
  top: max(24px, env(safe-area-inset-top));
  left: 20px;
  margin: 0;
  color: var(--quiet);
}

.type-field {
  position: absolute;
  left: 20px;
  right: 20px;
  top: 17%;
  min-height: 56%;
  opacity: 0;
  transform: translateY(18vh);
}
.type-chapter.is-approaching .type-field {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 180ms linear, transform 180ms cubic-bezier(.17, .8, .2, 1);
}
.type-chapter h1,
.type-chapter h2 {
  position: relative;
  max-width: 11ch;
  margin: 0;
  font-size: 38px;
  font-weight: 400;
  line-height: 1.14;
  letter-spacing: -0.035em;
}
.audience-chapter h2 {
  max-width: 16ch;
  font-size: 29px;
  line-height: 1.2;
}
.contact-chapter h2 {
  max-width: 100%;
  font-size: 24px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.typed-text { white-space: pre-wrap; }
.typed-token { white-space: nowrap; }
.typed-whitespace { white-space: pre-wrap; }
.typed-char { visibility: hidden; }
.typed-char.is-visible { visibility: visible; }

.cursor {
  position: absolute;
  display: block;
  left: 0;
  top: 0;
  width: 0.62em;
  height: 0.92em;
  background: currentColor;
  opacity: 0;
  pointer-events: none;
}
.story-chapter.is-prepared .cursor {
  opacity: 1;
  animation: cursor-blink 720ms steps(1) infinite;
}
@keyframes cursor-blink { 50% { opacity: 0; } }

.visual-chapter { height: 205svh; }
.story-object {
  position: absolute;
  z-index: 2;
  left: 50%;
  opacity: 0;
  object-fit: contain;
  transform: translate(-50%, 18vh);
}
.visual-chapter.is-active .story-object {
  animation: object-rise 900ms cubic-bezier(.17, .8, .2, 1) 80ms both;
}
@keyframes object-rise {
  from { opacity: 0; transform: translate(-50%, 18vh); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.meal-story { --target-x: 50%; --target-y: 42%; --elbow-y: 59%; }
.meal-outline {
  top: 17%;
  width: min(92%, 420px);
  height: 31%;
}
.ketchup-story { --target-x: 50%; --target-y: 37%; --elbow-y: 57%; }
.ketchup-cup {
  top: 11%;
  width: min(56%, 240px);
  height: 39%;
}
.tube-story { --target-x: 49%; --target-y: 42%; --elbow-y: 59%; }
.tube-image {
  top: 9%;
  width: min(48%, 215px);
  height: 47%;
  mix-blend-mode: multiply;
  -webkit-mask-image:
    linear-gradient(to bottom, transparent, #000 7%, #000 93%, transparent),
    linear-gradient(to right, transparent, #000 9%, #000 91%, transparent);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(to bottom, transparent, #000 7%, #000 93%, transparent),
    linear-gradient(to right, transparent, #000 9%, #000 91%, transparent);
  mask-composite: intersect;
}

.callout {
  position: absolute;
  z-index: 6;
  inset: 0;
  pointer-events: none;
}
.callout img {
  position: absolute;
  max-width: none;
  object-fit: fill;
}
.callout__dot {
  left: calc(var(--target-x) - 6px);
  top: calc(var(--target-y) - 6px);
  width: 12px;
  height: 12px;
  opacity: 0;
}
.callout__stem {
  left: var(--spine-x);
  top: calc(var(--target-y) - 1px);
  width: calc(var(--target-x) - var(--spine-x));
  height: 2px;
  transform: scaleX(0);
  transform-origin: right;
}
.callout__drop {
  left: calc(var(--spine-x) - 1px);
  top: var(--target-y);
  width: 2px;
  height: calc(var(--elbow-y) - var(--target-y));
  transform: scaleY(0);
  transform-origin: top;
}
.callout__terminal {
  left: var(--spine-x);
  top: var(--elbow-y);
  width: calc(var(--copy-x) - var(--spine-x));
  height: 2px;
  transform: scaleX(0);
  transform-origin: left;
}
.visual-chapter.is-active .callout__dot { animation: dot-in 220ms ease-out 720ms both; }
.visual-chapter.is-active .callout__stem { animation: line-stem 360ms ease-out 880ms both; }
.visual-chapter.is-active .callout__drop { animation: line-drop 420ms ease-out 1180ms both; }
.visual-chapter.is-active .callout__terminal { animation: line-terminal 300ms ease-out 1540ms both; }
@keyframes dot-in { from { opacity: 0; transform: scale(.25); } to { opacity: 1; transform: scale(1); } }
@keyframes line-stem { to { transform: scaleX(1); } }
@keyframes line-drop { to { transform: scaleY(1); } }
@keyframes line-terminal { to { transform: scaleX(1); } }

.annotation {
  position: absolute;
  z-index: 7;
  top: calc(var(--elbow-y) + 16px);
  left: var(--copy-x);
  right: 24px;
  opacity: 0;
  transform: translateY(12px);
}
.visual-chapter.is-active .annotation {
  animation: annotation-in 320ms ease-out 1780ms both;
}
@keyframes annotation-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.annotation__label {
  margin: 0;
  color: #708b24;
}
.annotation__copy {
  position: relative;
  max-width: 330px;
  min-height: 5em;
  margin: 10px 0 0;
  font-size: 22px;
  font-weight: 400;
  line-height: 1.18;
  letter-spacing: -0.04em;
}

footer {
  min-height: 42svh;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 28px 20px;
  color: var(--quiet);
  border-top: 1px solid rgba(17, 19, 15, 0.1);
}

@media (max-width: 360px) {
  :root { --copy-x: 54px; --spine-x: 20px; }
  .draft-badge { font-size: 51px; }
  .type-chapter h1,
  .type-chapter h2 { font-size: 31px; }
  .audience-chapter h2 { font-size: 24px; }
  .contact-chapter h2 { font-size: 20px; }
  .annotation__copy { font-size: 18px; }
}

@media (max-height: 740px) {
  .hero-pin,
  .chapter-pin { min-height: 600px; }
  .meal-story { --target-y: 40%; --elbow-y: 55%; }
  .ketchup-story { --target-y: 35%; --elbow-y: 54%; }
  .tube-story { --target-y: 40%; --elbow-y: 56%; }
  .meal-outline { top: 14%; height: 29%; }
  .ketchup-cup { top: 8%; height: 37%; }
  .tube-image { top: 7%; height: 45%; }
  .annotation__copy { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
    transition-duration: .01ms !important;
  }
  .hero-source { opacity: 1; }
  .hero-canvas { display: none !important; }
  .type-field { opacity: 1; transform: none; }
  .story-object { opacity: 1; transform: translate(-50%, 0); }
  .annotation { transform: none; }
  .annotation { opacity: 1; }
  .callout__dot { opacity: 1; }
  .callout__stem,
  .callout__drop,
  .callout__terminal { transform: none; }
  .cursor { opacity: 1 !important; animation: none !important; }
}
