/* --------------------------------------------------------------------------
   Ink / motion layer
   One living object, printed rules, and motion that belongs to the paper.
   Research: Designjoy (idle object), Cuberto (type tracks + stacked sheets),
   Lusion (counting, inset plates), Basement (shell-first, dither, ledger nav).
   No libraries. Transform/opacity only.
-------------------------------------------------------------------------- */
:root {
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-snap: cubic-bezier(0.2, 0.9, 0.2, 1);
  --t-fast: 180ms;
  --t-mid: 420ms;
  --t-slow: 900ms;
}

/* --------------------------------------------------------------------------
   Load choreography
-------------------------------------------------------------------------- */
.masthead::after {
  content: "";
  position: absolute;
  right: var(--pad);
  bottom: 0;
  left: var(--pad);
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 1.1s var(--ease-out) 0.08s;
}

.js.is-ready .masthead::after {
  transform: scaleX(1);
}

.js .masthead .identity,
.js .masthead .nav-links,
.js .masthead .mast-right {
  opacity: 0;
  transform: translateY(-5px);
  transition: opacity 0.5s ease, transform 0.5s var(--ease-out);
}

.js.is-ready .masthead .identity,
.js.is-ready .masthead .nav-links,
.js.is-ready .masthead .mast-right {
  opacity: 1;
  transform: none;
}

.js.is-ready .masthead .identity {
  transition-delay: 0.08s;
}

.js.is-ready .masthead .nav-links {
  transition-delay: 0.14s;
}

.js.is-ready .masthead .mast-right {
  transition-delay: 0.2s;
}

.hero-grid-lines {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 1.2s ease, transform 1.2s var(--ease-out);
}

.js.is-ready .hero-grid-lines {
  opacity: 1;
  transform: none;
}

.js .hero h1 .line > span {
  transform: translateY(115%) rotate(1.2deg);
  transition: transform 1.08s var(--ease-out);
}

.js.is-ready .hero h1 .line > span {
  transform: none;
}

.js.is-ready .hero h1 .line:nth-child(2) > span {
  transition-delay: 0.1s;
}

.hero h1 em {
  position: relative;
}

.hero h1 em::after {
  content: "";
  position: absolute;
  right: 5%;
  bottom: 0.03em;
  left: 3%;
  height: 3px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.9s var(--ease-out) 0.74s;
}

.js.is-ready .hero h1 em::after {
  transform: scaleX(1);
}

.js .ink-stage {
  opacity: 0;
  transform: translateY(18px) rotate(0.5deg);
  transition: opacity 0.7s ease 0.36s, transform 1s var(--ease-out) 0.36s;
}

.js.is-ready .ink-stage {
  opacity: 1;
  transform: none;
}

.js .aside-stamp {
  opacity: 0;
  transform: rotate(-18deg) scale(0.92);
  transition: opacity 0.35s ease 0.9s, transform 0.8s var(--ease-out) 0.9s;
}

.js.is-ready .aside-stamp {
  opacity: 1;
  transform: rotate(calc(-7deg + var(--scroll-rot, 0deg))) scale(1);
}

/* --------------------------------------------------------------------------
   Mascot: Ink
-------------------------------------------------------------------------- */
.hero-aside {
  gap: clamp(22px, 3vw, 34px);
}

.ink-stage {
  position: relative;
  width: 100%;
  padding: 11px 11px 9px;
  border: 1px solid var(--line-strong);
  background: var(--paper-2);
  isolation: isolate;
}

.ink-stage::before {
  content: "";
  position: absolute;
  inset: 30px 8px 92px;
  z-index: -1;
  background-image: radial-gradient(rgba(20, 21, 17, 0.19) 0.65px, transparent 0.8px);
  background-size: 5px 5px;
  mask-image: radial-gradient(ellipse at 60% 62%, #000 0 36%, transparent 72%);
  opacity: 0.42;
  transition: background-position 1s linear;
  animation: ink-dither 9s steps(8) infinite;
  pointer-events: none;
}

.ink-stage::after {
  content: "";
  position: absolute;
  top: 31px;
  right: 8px;
  bottom: 70px;
  width: 1px;
  background: linear-gradient(to bottom, transparent, var(--line-strong) 14%, var(--line) 84%, transparent);
  pointer-events: none;
}

@keyframes ink-dither {
  0%,
  100% {
    background-position: 0 0;
  }
  25% {
    background-position: 5px 0;
  }
  50% {
    background-position: 5px 5px;
  }
  75% {
    background-position: 0 5px;
  }
}

.ink-stage-head,
.ink-stage-foot {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font: 7px var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ink-stage-head {
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}

.ink-stage-head span:last-child {
  color: var(--accent-dark);
}

.ink-stage-foot {
  padding-top: 7px;
  border-top: 1px solid var(--line);
  font-size: 6.5px;
}

.ink-seal {
  position: absolute;
  top: 43px;
  right: 11px;
  z-index: 4;
  display: grid;
  gap: 2px;
  padding: 5px 7px 6px;
  border: 1.5px solid var(--accent-dark);
  box-shadow: inset 0 0 0 2px var(--paper-2), inset 0 0 0 3px rgba(200, 58, 17, 0.35);
  color: var(--accent-dark);
  font: 6px/1.05 var(--mono);
  letter-spacing: 0.11em;
  text-align: center;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transform: rotate(-9deg) scale(1.2);
}

.ink-seal span:last-child {
  font-size: 5px;
  letter-spacing: 0.06em;
  opacity: 0.78;
}

.ink-bubble {
  position: relative;
  z-index: 4;
  width: fit-content;
  max-width: 92%;
  min-height: 29px;
  margin: 8px 0 0 5px;
  padding: 6px 8px 7px;
  border: 1px solid var(--line-strong);
  border-left: 2px solid var(--accent);
  background: var(--paper);
  color: var(--ink-soft);
  font: 8.5px/1.35 var(--mono);
  letter-spacing: -0.01em;
  transform: rotate(-0.4deg);
  transition: opacity 0.18s ease, transform 0.18s var(--ease-out);
}

.ink-bubble::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 18px;
  width: 8px;
  height: 8px;
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
  background: var(--paper);
  transform: rotate(45deg);
}

.ink-bubble.is-swapping {
  opacity: 0;
  transform: translateY(-2px) rotate(-0.4deg);
}

.ink-figure {
  position: relative;
  z-index: 2;
  display: grid;
  width: min(100%, 230px);
  margin: 3px auto 2px;
  padding: 0;
  place-items: center;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  overflow: visible;
  perspective: 900px;
  -webkit-appearance: none;
  appearance: none;
}

.ink-figure:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 5px;
}

.ink-figure::after {
  content: "";
  position: absolute;
  right: 17%;
  bottom: 5.5%;
  left: 17%;
  height: 8px;
  border-radius: 50%;
  background: rgba(20, 21, 17, 0.1);
  filter: blur(4px);
  transform: scaleX(0.72);
  transition: transform 0.4s var(--ease-out), opacity 0.4s;
  pointer-events: none;
}

.ink-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  color: var(--ink);
  filter: drop-shadow(0 8px 0 rgba(20, 21, 17, 0.03));
  transform-origin: 50% 100%;
}

.ink-svg .ink-character,
.ink-svg .ink-head,
.ink-svg .ink-eyes,
.ink-svg .ink-happy-arcs,
.ink-svg .ink-gaze,
.ink-svg .ink-tentacle,
.ink-svg .ink-tail,
.ink-svg .ink-scarf-tail,
.ink-svg .ink-receipt,
.ink-svg .ink-paw-right,
.ink-svg .ink-orbit,
.ink-svg .ink-shadow,
.ink-svg .ink-fx .fx {
  transform-box: view-box;
}

.ink-svg .ink-character {
  transform-origin: 120px 244px;
  animation: ink-bob 4.6s var(--ease-in-out) infinite;
}

.ink-svg .ink-head {
  transform-origin: 120px 142px;
  transform: rotate(var(--ink-head-tilt, 0deg));
  transition: transform 0.32s var(--ease-out);
}

.ink-svg .ink-eyes {
  transform-origin: 120px 109px;
  animation: ink-blink 6.6s infinite;
  transition: opacity 0.12s ease;
}

.ink-svg .ink-happy-arcs {
  opacity: 0;
  transform-origin: 120px 109px;
}

.ink-svg .ink-gaze {
  transform: translate(var(--ink-look-x, 0px), var(--ink-look-y, 0px));
  transition: transform 0.24s ease-out;
}

.ink-svg .ink-tentacle {
  animation: ink-sway 4.8s var(--ease-in-out) infinite;
}

.ink-svg .ink-tentacle.t1 {
  transform-origin: 78px 104px;
  animation-delay: -0.4s;
}

.ink-svg .ink-tentacle.t2 {
  transform-origin: 70px 129px;
  animation-delay: -1.7s;
}

.ink-svg .ink-tentacle.t3 {
  transform-origin: 77px 155px;
  animation-delay: -2.6s;
}

.ink-svg .ink-tentacle.t4 {
  transform-origin: 162px 104px;
  animation-delay: -1.1s;
}

.ink-svg .ink-tentacle.t5 {
  transform-origin: 170px 129px;
  animation-delay: -2.2s;
}

.ink-svg .ink-tentacle.t6 {
  transform-origin: 163px 155px;
  animation-delay: -3s;
}

.ink-svg .ink-tail {
  transform-origin: 72px 207px;
  animation: ink-tail 5.2s var(--ease-in-out) infinite;
}

.ink-svg .ink-scarf-tail {
  transform-origin: 151px 160px;
  animation: ink-flutter 4.1s var(--ease-in-out) infinite;
}

.ink-svg .ink-receipt {
  transform-origin: 132px 204px;
  animation: ink-receipt-wiggle 5.4s var(--ease-in-out) infinite;
}

.ink-svg .ink-glint {
  animation: ink-glint 5.8s ease-in-out infinite;
  transform-origin: 120px 96px;
}

.ink-svg .ink-fx .fx {
  opacity: 0;
  transform-origin: 120px 145px;
}

.ink-svg .ink-orbit {
  opacity: 0;
  transform-origin: 120px 145px;
}

.ink-svg .ink-stamp-prop {
  transform-origin: 184px 233px;
}

.ink-svg .ink-pointer {
  opacity: 0;
  transform-origin: 73px 192px;
}

.ink-svg .ink-pointer-right {
  transform-origin: 167px 192px;
}

@keyframes ink-bob {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-3px) rotate(-0.45deg);
  }
}

@keyframes ink-blink {
  0%,
  43%,
  47%,
  100% {
    transform: scaleY(1);
  }
  44.5%,
  45.5% {
    transform: scaleY(0.08);
  }
}

@keyframes ink-sway {
  0%,
  100% {
    transform: rotate(0deg) translateY(0);
  }
  50% {
    transform: rotate(1.6deg) translateY(-1.4px);
  }
}

@keyframes ink-tail {
  0%,
  100% {
    transform: rotate(-2deg);
  }
  50% {
    transform: rotate(4deg);
  }
}

@keyframes ink-flutter {
  0%,
  100% {
    transform: rotate(0deg) translateY(0);
  }
  50% {
    transform: rotate(2.2deg) translateY(-1px);
  }
}

@keyframes ink-receipt-wiggle {
  0%,
  100% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(1.2deg);
  }
}

@keyframes ink-glint {
  0%,
  92%,
  100% {
    opacity: 0.72;
  }
  94% {
    opacity: 0.15;
  }
  96% {
    opacity: 1;
  }
}

/* Trick: hop --------------------------------------------------------------- */
.ink-figure.is-hopping .ink-character {
  animation: ink-hop 0.82s var(--ease-snap);
}

.ink-figure.is-hopping .ink-shadow {
  animation: ink-hop-shadow 0.82s var(--ease-snap);
}

.ink-figure.is-hopping .ink-fx .fx1 {
  animation: ink-spark 0.72s 0.04s var(--ease-out);
}

.ink-figure.is-hopping .ink-fx .fx2 {
  animation: ink-spark 0.62s 0.1s var(--ease-out);
}

.ink-figure.is-hopping .ink-fx .fx3 {
  animation: ink-spark 0.7s 0.16s var(--ease-out);
}

.ink-figure.is-hopping .ink-fx .fx4 {
  animation: ink-spark 0.6s 0.2s var(--ease-out);
}

.ink-figure.is-hopping .ink-scarf-tail {
  animation: ink-hop-scarf 0.82s 0.04s var(--ease-snap);
}

.ink-figure.is-hopping .ink-tail {
  animation: ink-hop-tail 0.82s 0.06s var(--ease-snap);
}

.ink-figure.is-hopping .ink-receipt {
  animation: ink-hop-receipt 0.82s 0.08s var(--ease-snap);
}

.ink-figure.is-hopping .ink-tentacle {
  animation: ink-hop-tentacle 0.82s 0.03s var(--ease-snap);
}

@keyframes ink-hop {
  0% {
    transform: translateY(0) scale(1);
  }
  12% {
    transform: translateY(0) scale(1.04, 0.9);
  }
  38% {
    transform: translateY(-36px) scale(0.97, 1.04);
  }
  56% {
    transform: translateY(-38px) scale(1, 1);
  }
  76% {
    transform: translateY(0) scale(1.05, 0.92);
  }
  88% {
    transform: translateY(-3px) scale(0.99, 1.01);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes ink-hop-shadow {
  0%,
  100% {
    transform: scaleX(1);
    opacity: 0.13;
  }
  45% {
    transform: scaleX(0.6);
    opacity: 0.06;
  }
}

@keyframes ink-spark {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.5) rotate(0deg);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--fx-x, 0px), var(--fx-y, -22px)) scale(1) rotate(50deg);
  }
}

@keyframes ink-hop-scarf {
  0%,
  100% {
    transform: rotate(0deg) translateY(0);
  }
  28% {
    transform: rotate(-13deg) translateY(-5px);
  }
  58% {
    transform: rotate(12deg) translateY(2px);
  }
  84% {
    transform: rotate(-3deg) translateY(0);
  }
}

@keyframes ink-hop-tail {
  0%,
  100% {
    transform: rotate(-2deg);
  }
  32% {
    transform: rotate(-8deg) translate(-2px, -2px);
  }
  64% {
    transform: rotate(6deg) translate(1px, 1px);
  }
}

@keyframes ink-hop-receipt {
  0%,
  100% {
    transform: rotate(0deg) translate(0, 0);
  }
  30% {
    transform: rotate(-7deg) translate(-2px, -4px);
  }
  64% {
    transform: rotate(6deg) translate(1px, 1px);
  }
}

@keyframes ink-hop-tentacle {
  0%,
  100% {
    transform: rotate(0deg) translateY(0);
  }
  30% {
    transform: rotate(2.2deg) translateY(-2px);
  }
  68% {
    transform: rotate(-1.4deg) translateY(1px);
  }
}

.ink-figure.is-hopping .fx1 {
  --fx-x: -43px;
  --fx-y: -28px;
}

.ink-figure.is-hopping .fx2 {
  --fx-x: 38px;
  --fx-y: -34px;
}

.ink-figure.is-hopping .fx3 {
  --fx-x: -55px;
  --fx-y: 8px;
}

.ink-figure.is-hopping .fx4 {
  --fx-x: 52px;
  --fx-y: 2px;
}

/* Trick: swirl ------------------------------------------------------------- */
.ink-figure.is-swirling .ink-character {
  transform-origin: 120px 145px;
  animation: ink-swirl 1.05s var(--ease-in-out);
}

.ink-figure.is-swirling .ink-orbit {
  animation: ink-orbit 1.05s var(--ease-out);
}

.ink-figure.is-swirling .ink-scarf-tail {
  animation: ink-scarf-swirl 1.05s var(--ease-in-out);
}

.ink-figure.is-swirling .ink-fx .fx1,
.ink-figure.is-swirling .ink-fx .fx2,
.ink-figure.is-swirling .ink-fx .fx3,
.ink-figure.is-swirling .ink-fx .fx4 {
  animation: ink-spark 1.05s var(--ease-out);
}

.ink-figure.is-swirling .fx1 {
  --fx-x: -58px;
  --fx-y: -30px;
  animation-delay: 0.08s;
}

.ink-figure.is-swirling .fx2 {
  --fx-x: 54px;
  --fx-y: -26px;
  animation-delay: 0.16s;
}

.ink-figure.is-swirling .fx3 {
  --fx-x: -62px;
  --fx-y: 12px;
  animation-delay: 0.22s;
}

.ink-figure.is-swirling .fx4 {
  --fx-x: 60px;
  --fx-y: 16px;
  animation-delay: 0.12s;
}

@keyframes ink-swirl {
  0% {
    transform: rotate(0deg) scale(1);
  }
  16% {
    transform: rotate(-10deg) scale(0.96);
  }
  52% {
    transform: rotate(360deg) scale(0.72);
  }
  76% {
    transform: rotate(374deg) scale(0.84);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

@keyframes ink-orbit {
  0% {
    opacity: 0;
    transform: rotate(0deg) scale(0.88);
    stroke-dashoffset: 0;
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: rotate(240deg) scale(1.08);
    stroke-dashoffset: -42;
  }
}

@keyframes ink-scarf-swirl {
  0%,
  100% {
    transform: rotate(0deg);
  }
  35% {
    transform: rotate(18deg) translateY(-4px);
  }
  70% {
    transform: rotate(-10deg);
  }
}

/* Trick: point ------------------------------------------------------------- */
.ink-figure.is-pointing .ink-character {
  animation: ink-point-lean 1.05s var(--ease-out);
}

.ink-figure.is-pointing .ink-head {
  transform: rotate(var(--point-head-tilt, -4deg));
}

@keyframes ink-point-lean {
  0%,
  100% {
    transform: translateX(0) rotate(0);
  }
  42%,
  65% {
    transform: translateX(var(--point-lean, -3px)) rotate(var(--point-lean-rotate, -1deg));
  }
}

.ink-figure.is-pointing.point-left .ink-pointer-left {
  animation: ink-pointer-left 1.05s var(--ease-out);
}

.ink-figure.is-pointing.point-right .ink-pointer-right {
  animation: ink-pointer-right 1.05s var(--ease-out);
}

@keyframes ink-pointer-left {
  0% {
    opacity: 0;
    transform: scaleX(0.08) rotate(0deg);
  }
  24% {
    opacity: 1;
    transform: scaleX(1.06) rotate(-2deg);
  }
  64% {
    opacity: 1;
    transform: scaleX(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: scaleX(0.9) rotate(0deg);
  }
}

@keyframes ink-pointer-right {
  0% {
    opacity: 0;
    transform: scaleX(0.08) rotate(0deg);
  }
  24% {
    opacity: 1;
    transform: scaleX(1.06) rotate(2deg);
  }
  64% {
    opacity: 1;
    transform: scaleX(1) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: scaleX(0.9) rotate(0deg);
  }
}

/* Trick: stamp ------------------------------------------------------------- */
.ink-figure.is-stamping .ink-character {
  animation: ink-stamp-hop 0.78s var(--ease-snap);
}

.ink-figure.is-stamping .ink-stamp-prop {
  animation: ink-stamp-prop 0.78s var(--ease-snap);
}

.ink-figure.is-stamping .ink-paw-right {
  transform-origin: 151px 236px;
  animation: ink-paw-stamp 0.78s var(--ease-snap);
}

.ink-figure.is-stamping ~ .ink-seal {
  animation: ink-seal 1.45s var(--ease-out);
}

.ink-figure.is-stamping .ink-fx .fx1,
.ink-figure.is-stamping .ink-fx .fx4 {
  animation: ink-spark 0.8s var(--ease-out);
}

@keyframes ink-stamp-hop {
  0% {
    transform: translateY(0) scale(1);
  }
  20% {
    transform: translateY(-9px) scale(0.99, 1.02);
  }
  42% {
    transform: translateY(4px) scale(1.05, 0.94);
  }
  62% {
    transform: translateY(0) scale(1);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes ink-stamp-prop {
  0%,
  100% {
    transform: rotate(0deg) translate(0, 0);
  }
  32% {
    transform: rotate(-24deg) translate(-18px, -13px);
  }
  48% {
    transform: rotate(3deg) translate(-4px, 2px);
  }
  60% {
    transform: rotate(0deg);
  }
}

@keyframes ink-paw-stamp {
  0%,
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
  28% {
    transform: translate(8px, -4px) rotate(-7deg);
  }
  48% {
    transform: translate(1px, 1px) rotate(2deg);
  }
  64% {
    transform: translate(0, 0);
  }
}

@keyframes ink-seal {
  0%,
  25% {
    opacity: 0;
    transform: rotate(-14deg) scale(1.28);
  }
  37% {
    opacity: 1;
    transform: rotate(-9deg) scale(0.98);
  }
  42% {
    transform: rotate(-9deg) scale(1);
  }
  78% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: rotate(-8deg) scale(1.01);
  }
}

/* Trick: happy / pet ------------------------------------------------------- */
.ink-figure.is-happy .ink-character {
  animation: ink-happy 0.9s var(--ease-out);
}

.ink-figure.is-happy .ink-eyes {
  opacity: 0;
}

.ink-figure.is-happy .ink-happy-arcs {
  animation: ink-happy-arcs 0.9s var(--ease-out);
}

.ink-figure.is-happy .ink-head {
  transform: rotate(4deg);
}

@keyframes ink-happy {
  0%,
  100% {
    transform: translateY(0) rotate(0);
  }
  30% {
    transform: translateY(-4px) rotate(-2deg);
  }
  60% {
    transform: translateY(-2px) rotate(2deg);
  }
}

@keyframes ink-happy-arcs {
  0%,
  16% {
    opacity: 0;
    transform: scaleY(0.4);
  }
  32%,
  100% {
    opacity: 1;
    transform: scaleY(1);
  }
}

.ink-figure.is-startled .ink-character {
  animation: ink-startle 0.6s var(--ease-snap);
}

@keyframes ink-startle {
  0%,
  100% {
    transform: translateY(0);
  }
  24% {
    transform: translateY(-9px) scale(1.01, 1.02);
  }
  50% {
    transform: translateY(0) scale(1.02, 0.98);
  }
}

/* little stage keys */
.ink-tricks {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 2px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.ink-tricks button {
  min-height: 28px;
  padding: 7px 3px 6px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: 6.5px var(--mono);
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast);
}

.ink-tricks button:last-child {
  border-right: 0;
}

.ink-tricks button:hover,
.ink-tricks button:focus-visible {
  background: var(--ink);
  color: var(--paper);
}

.ink-tricks button:active {
  background: var(--accent);
  color: var(--paper);
}

.ink-tricks button:disabled {
  background: transparent;
  color: var(--muted);
  cursor: default;
  opacity: 0.45;
}

.ink-tricks button:disabled span {
  color: var(--muted);
}

.ink-tricks button span {
  display: block;
  color: var(--accent-dark);
  font-size: 5.5px;
  letter-spacing: 0.12em;
}

.ink-tricks button:hover span {
  color: #ff7c55;
}

.aside-stamp {
  width: 70px;
  height: 70px;
  flex: 0 0 auto;
  margin: -15px 0 0 14px;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(242, 239, 229, 0.6);
  font-size: 5.4px;
  pointer-events: none;
}

.aside-stamp::before {
  inset: 4px;
}

.aside-stamp small {
  margin-top: 2px;
  font-size: 4.8px;
}

.ink-stage-foot {
  justify-content: flex-end;
}

/* --------------------------------------------------------------------------
   Section typography + rules
-------------------------------------------------------------------------- */
.section {
  border-top: 0;
}

.section::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 1px;
  background: var(--line);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 1s var(--ease-out);
}

.section.is-section-in::before {
  transform: scaleX(1);
}

.js .is-split .word {
  display: inline-block;
  overflow: hidden;
  padding-bottom: 0.08em;
  margin-bottom: -0.08em;
  vertical-align: top;
}

.js .is-split .word > span {
  display: inline-block;
  transform: translateY(112%) rotate(0.8deg);
  transition: transform 0.95s var(--ease-out);
  transition-delay: calc(var(--word-i, 0) * 38ms);
}

.js .is-split.is-in .word > span {
  transform: none;
}

.js .reveal {
  opacity: 0;
  transform: translateY(18px);
  clip-path: inset(0 0 9% 0);
  transition: opacity 0.7s ease, transform 0.95s var(--ease-out), clip-path 0.95s var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}

.js .reveal.is-in {
  opacity: 1;
  transform: none;
  clip-path: inset(0);
}

.js .section-head.reveal {
  clip-path: inset(0 0 6% 0);
}

.js .case-featured.reveal {
  transition-duration: 0.8s, 1.1s, 1.1s;
}

.js .case-mini.reveal,
.js .ship-row.reveal,
.js .method-step.reveal,
.js .proof-item.reveal {
  --reveal-delay: calc(var(--reveal-i, 0) * 55ms);
}

.js .also-head.reveal {
  --reveal-delay: 40ms;
}

.js .inventory-theme.reveal {
  --reveal-delay: calc(var(--reveal-i, 0) * 90ms);
}

.js .receipt-copy.reveal {
  --reveal-delay: 60ms;
}

.js .console.reveal {
  --reveal-delay: 140ms;
}

/* Hero details */
.js .hero-aside .aside-facts li {
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 0.45s ease, transform 0.6s var(--ease-out);
}

.js.is-ready .hero-aside .aside-facts li {
  opacity: 1;
  transform: none;
}

.js.is-ready .hero-aside .aside-facts li:nth-child(1) {
  transition-delay: 0.72s;
}

.js.is-ready .hero-aside .aside-facts li:nth-child(2) {
  transition-delay: 0.78s;
}

.js.is-ready .hero-aside .aside-facts li:nth-child(3) {
  transition-delay: 0.84s;
}

.js.is-ready .hero-aside .aside-facts li:nth-child(4) {
  transition-delay: 0.9s;
}

.js .proof-num {
  display: inline-block;
  transform: translateY(12px);
  opacity: 0;
  transition: opacity 0.55s ease, transform 0.8s var(--ease-out);
}

.js.is-ready .proof-num {
  opacity: 1;
  transform: none;
}

.js.is-ready .proof-item:nth-child(1) .proof-num {
  transition-delay: 0.62s;
}

.js.is-ready .proof-item:nth-child(2) .proof-num {
  transition-delay: 0.7s;
}

.js.is-ready .proof-item:nth-child(3) .proof-num {
  transition-delay: 0.78s;
}

.js.is-ready .proof-item:nth-child(4) .proof-num {
  transition-delay: 0.86s;
}

/* Section furniture */
.section-head {
  position: relative;
}

.section-head::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1.1rem;
  left: 0;
  height: 1px;
  background: var(--line);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 1.1s var(--ease-out) 0.1s;
}

.section-head.is-in::after {
  transform: scaleX(1);
}

.method-quote,
.about-intro h2 {
  --word-stagger: 22ms;
}

/* --------------------------------------------------------------------------
   Cards, charts, console
-------------------------------------------------------------------------- */
.case-mini,
.proof-item,
.method-step,
.receipt-point,
.inventory-card {
  overflow: clip;
}

.case-mini::before,
.proof-item::before,
.method-step::before,
.receipt-point::before,
.inventory-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(
    260px circle at var(--mx, 50%) var(--my, 50%),
    rgba(233, 73, 27, 0.11),
    rgba(233, 73, 27, 0.035) 30%,
    transparent 66%
  );
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .case-mini:hover::before,
  .proof-item:hover::before,
  .method-step:hover::before,
  .receipt-point:hover::before,
  .inventory-card:hover::before {
    opacity: 1;
  }
}

.case-mini > *,
.proof-item > *,
.method-step > *,
.receipt-point > *,
.inventory-card > * {
  position: relative;
  z-index: 1;
}

.case-mini .case-links a,
.proof-src,
.text-link,
.github-link {
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat;
  background-position: left calc(100% - 0px);
  background-size: 0% 1px;
  transition: color 0.2s, border-color 0.2s, background-size 0.28s var(--ease-out);
}

.case-mini .case-links a:hover,
.proof-src:hover,
.text-link:hover,
.github-link:hover {
  background-size: 100% 1px;
}

.case-featured .media-frame {
  overflow: hidden;
}

.js .case-featured.reveal .media-frame img {
  transform: scale(1.025);
  transition: transform 1.2s var(--ease-out);
}

.js .case-featured.reveal.is-in .media-frame img {
  transform: none;
}

.js .case-featured.reveal .media-frame {
  clip-path: inset(0 0 8% 0);
  transition: clip-path 1s var(--ease-out);
}

.js .case-featured.reveal.is-in .media-frame {
  clip-path: inset(0);
}

.js .mini-viz .pm-paged-bar {
  transform: scaleX(0);
  transform-origin: 20px 0;
  transition: transform 1.15s var(--ease-out) 0.16s;
}

.js .mini-viz.is-in .pm-paged-bar {
  transform: scaleX(1);
}

.js .mini-viz .cp-bar {
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform 0.9s var(--ease-out);
  transition-delay: calc(var(--bar-i, 0) * 90ms + 120ms);
}

.js .mini-viz.is-in .cp-bar {
  transform: scaleY(1);
}

.mini-viz {
  transition: border-color 0.3s;
}

.mini-viz:hover {
  border-color: var(--line-strong);
}

.receipt-strip div {
  transition: background 0.2s;
}

.receipt-strip div:hover {
  background: var(--paper-3);
}

.console {
  position: relative;
}

.console::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  background: linear-gradient(to bottom, transparent 0%, rgba(255, 124, 85, 0.09) 48%, transparent 52%);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-100%);
}

.console.is-printing::after {
  animation: console-scan 0.55s var(--ease-out);
}

.console.is-printing pre#receiptJson {
  animation: console-print 0.45s var(--ease-out);
}

@keyframes console-scan {
  0% {
    opacity: 0;
    transform: translateY(-100%);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(100%);
  }
}

@keyframes console-print {
  0% {
    clip-path: inset(0 0 100% 0);
  }
  100% {
    clip-path: inset(0);
  }
}

/* --------------------------------------------------------------------------
   Nav, progress, cursor
-------------------------------------------------------------------------- */
.nav-links a.is-active {
  color: var(--ink);
}

.nav-links a.is-active::after {
  transform: scaleX(1);
}

.progress i {
  position: relative;
}

.progress i::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -2px;
  width: 7px;
  height: 7px;
  background: var(--accent);
  transform: rotate(45deg);
}

.reg-cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 130;
  width: 8px;
  height: 8px;
  border: 1px solid var(--accent);
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: width 0.18s var(--ease-out), height 0.18s var(--ease-out), opacity 0.2s, background 0.2s;
  mix-blend-mode: multiply;
}

.reg-cursor.is-on {
  width: 15px;
  height: 15px;
  opacity: 1;
}

.reg-cursor.is-press {
  width: 7px;
  height: 7px;
  background: var(--accent);
}

@media (hover: none), (pointer: coarse) {
  .reg-cursor {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Ink-on-the-margin companion
-------------------------------------------------------------------------- */
.ink-tab {
  position: fixed;
  right: 0;
  bottom: 18px;
  z-index: 170;
  display: grid;
  width: 52px;
  padding: 6px 2px 5px 6px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-right: 0;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) rotate(2deg);
  transition: opacity 0.35s ease, transform 0.55s var(--ease-out), border-color 0.2s;
}

.ink-tab.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.ink-tab.is-visible:hover,
.ink-tab.is-visible:focus-visible {
  transform: translateX(-6px);
}

.ink-tab:hover,
.ink-tab:focus-visible {
  border-color: var(--accent);
}

.ink-tab::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: var(--accent);
}

.ink-tab-label {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font: 6px var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ink-tab-label b {
  color: var(--accent-dark);
  font-weight: 500;
}

.ink-tab svg {
  display: block;
  width: 40px;
  height: 40px;
  overflow: visible;
  animation: ink-tab-bob 4.2s var(--ease-in-out) infinite;
}

.ink-tab.is-hopping svg {
  animation: ink-tab-hop 0.72s var(--ease-snap);
}

.ink-tab.is-swirling svg {
  animation: ink-tab-swirl 0.92s var(--ease-in-out);
}

.ink-tab.is-pointing svg {
  animation: ink-tab-point 0.8s var(--ease-out);
}

@keyframes ink-tab-bob {
  0%,
  100% {
    transform: translateY(0) rotate(0);
  }
  50% {
    transform: translateY(-2px) rotate(-1deg);
  }
}

@keyframes ink-tab-hop {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  40% {
    transform: translateY(-15px) scale(0.97, 1.03);
  }
  72% {
    transform: translateY(0) scale(1.04, 0.95);
  }
}

@keyframes ink-tab-swirl {
  0% {
    transform: rotate(0);
  }
  60% {
    transform: rotate(368deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes ink-tab-point {
  0%,
  100% {
    transform: rotate(0) translateX(0);
  }
  40%,
  62% {
    transform: rotate(-7deg) translateX(-5px);
  }
}

.ink-tab-bubble {
  position: absolute;
  right: 58px;
  bottom: 10px;
  width: max-content;
  max-width: 170px;
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  border-right: 2px solid var(--accent);
  background: var(--paper);
  color: var(--ink-soft);
  font: 8px/1.35 var(--mono);
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transform: translateX(6px);
  transition: opacity 0.2s ease, transform 0.3s var(--ease-out);
}

.ink-tab.is-visible .ink-tab-bubble.is-on {
  opacity: 1;
  transform: none;
}

.ink-tab-bubble::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -6px;
  width: 8px;
  height: 8px;
  border-top: 1px solid var(--line-strong);
  border-right: 1px solid var(--line-strong);
  background: var(--paper);
  transform: translateY(-50%) rotate(45deg);
}

@media (max-width: 1320px) {
  .ink-tab {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Responsive
-------------------------------------------------------------------------- */
@media (max-width: 1439px) {
  .ink-stage {
    width: 300px;
    flex: 0 0 300px;
  }

  .ink-figure {
    width: 220px;
  }

  .ink-stamp-badge {
    display: none;
  }
}

@media (max-width: 980px) {
  .ink-stage {
    width: min(340px, 100%);
    flex: 0 0 auto;
  }

  .ink-figure {
    width: 235px;
  }
}

@media (max-width: 820px) {
  .ink-stage {
    width: 100%;
    padding: 10px;
  }

  .ink-figure {
    width: clamp(216px, 46vw, 300px);
  }

  .ink-bubble {
    max-width: 100%;
    margin-left: 0;
  }

  .ink-stage::after {
    display: none;
  }

  .ink-tricks button {
    min-height: 31px;
    font-size: 7px;
  }
}

@media (max-width: 520px) {
  .ink-stage {
    padding: 9px;
  }

  .ink-figure {
    width: clamp(224px, 60vw, 240px);
  }

  .ink-seal {
    top: 41px;
    right: 8px;
    font-size: 5.5px;
  }

  .ink-bubble {
    min-height: 27px;
    padding: 5px 7px;
    font-size: 7.5px;
  }

  .ink-stage-head,
  .ink-stage-foot {
    font-size: 6px;
  }

  .ink-tricks button {
    padding: 7px 2px 6px;
    font-size: 6.3px;
  }
}

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

  .ink-svg *,
  .ink-tab svg,
  .ink-stage::before {
    animation: none !important;
  }

  .ink-svg .ink-character,
  .ink-svg .ink-head,
  .ink-svg .ink-gaze,
  .ink-svg .ink-tentacle,
  .ink-svg .ink-tail,
  .ink-svg .ink-scarf-tail,
  .ink-svg .ink-receipt {
    transform: none !important;
  }

  .js .is-split .word > span,
  .js .reveal,
  .js .proof-num {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
    transition: none !important;
  }

  .js .mini-viz .pm-paged-bar,
  .js .mini-viz .cp-bar {
    transform: none !important;
  }
}

.static .ink-svg *,
.static .ink-tab svg,
.static .ink-stage::before {
  animation: none !important;
}

.static .ink-svg .ink-character,
.static .ink-svg .ink-head,
.static .ink-svg .ink-gaze,
.static .ink-svg .ink-tentacle,
.static .ink-svg .ink-tail,
.static .ink-svg .ink-scarf-tail,
.static .ink-svg .ink-receipt {
  transform: none !important;
}

.static .masthead .identity,
.static .masthead .nav-links,
.static .masthead .mast-right,
.static .hero-grid-lines,
.static .hero h1 .line > span,
.static .is-split .word > span,
.static .reveal,
.static .proof-num,
.static .ink-stage {
  opacity: 1 !important;
  transform: none !important;
  clip-path: none !important;
  transition: none !important;
}

.static .aside-stamp {
  opacity: 1 !important;
  transform: rotate(-7deg) !important;
  transition: none !important;
}

.static .mini-viz .pm-paged-bar,
.static .mini-viz .cp-bar {
  transform: none !important;
}

.static .section::before,
.static .section-head::after,
.static .masthead::after,
.static .hero h1 em::after {
  transform: scaleX(1) !important;
  transition: none !important;
}

.static .ink-tab {
  display: none !important;
}

.static .reg-cursor {
  display: none !important;
}
