/* Sad Donkey — palette lifted from the cover: kraft box, packing tape,
   stencil ink, courier-uniform navy, truck hazard stripe. */
:root {
  --kraft: #c49a6c;
  --kraft-dark: #a97e52;
  --kraft-light: #d6b289;
  --ink: #2c2b2a;
  --ink-soft: #4a4038;
  --navy: #3a5689;
  --navy-dark: #2b416b;
  --hazard: #e2b33c;
  --label: #fbf8f1;
  --tape: rgba(226, 200, 152, .5);
  --font-thai: "Anuphan", "Sukhumvit Set", "IBM Plex Sans Thai", system-ui, sans-serif;
  --font-stencil: "Saira Extra Condensed", "Anuphan", sans-serif;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);

  /* textures */
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='260' height='260'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .33  0 0 0 0 .22  0 0 0 0 .1  0 0 0 .3 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  --fibers: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='600' height='600'><filter id='f'><feTurbulence type='fractalNoise' baseFrequency='.012 .09' numOctaves='4' seed='7'/><feColorMatrix values='0 0 0 0 .28  0 0 0 0 .17  0 0 0 0 .07  0 0 0 .55 -.18'/></filter><rect width='100%' height='100%' filter='url(%23f)'/></svg>");
  --blotch: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='900' height='900'><filter id='b'><feTurbulence type='fractalNoise' baseFrequency='.004' numOctaves='3' seed='3'/><feColorMatrix values='0 0 0 0 .36  0 0 0 0 .22  0 0 0 0 .08  0 0 0 1.1 -.45'/></filter><rect width='100%' height='100%' filter='url(%23b)'/></svg>");
  --paper: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .4  0 0 0 0 .35  0 0 0 0 .28  0 0 0 .12 0'/></filter><rect width='100%' height='100%' filter='url(%23p)'/></svg>");
  /* rough, worn-ink mask for printed stamps */
  --worn: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='w'><feTurbulence type='fractalNoise' baseFrequency='.7' numOctaves='2' seed='11'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 -2.4 1.9'/></filter><rect width='100%' height='100%' filter='url(%23w)'/></svg>");
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { overflow-x: clip; }

body {
  min-height: 100vh;
  font-family: var(--font-thai);
  font-size: 18px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--kraft);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* =========================================================
   THE BOX — fixed decor layer behind everything
   ========================================================= */
.box {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background:
    var(--grain),
    var(--fibers),
    var(--blotch),
    /* corrugated flutes showing through the liner */
    repeating-linear-gradient(90deg,
      rgba(255,236,200,.07) 0 3px, rgba(0,0,0,.05) 3px 5px, transparent 5px 15px),
    radial-gradient(ellipse at 50% 10%, var(--kraft-light), transparent 65%),
    var(--kraft);
}
/* edge burn / vignette */
.box::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 120% 90% at 50% 45%, transparent 55%, rgba(80,50,20,.38));
}

/* flap crease: a dented line with a highlight on one side */
.crease {
  position: absolute;
  left: 0; right: 0;
  height: 6px;
  background: linear-gradient(180deg, rgba(255,240,210,.28), rgba(90,60,25,.32) 45%, rgba(90,60,25,.05));
  filter: blur(.4px);
}
.crease--1 { top: 31%; }
.crease--2 { top: 78%; transform: rotate(-.3deg); }

/* coffee ring */
.ring {
  position: absolute;
  width: 210px; height: 200px;
  left: 4%; bottom: 7%;
  border-radius: 50%;
  background: radial-gradient(closest-side, transparent 80%, rgba(110,62,22,.28) 86%, rgba(110,62,22,.12) 91%, transparent 96%);
  transform: rotate(-12deg);
  -webkit-mask: var(--worn); mask: var(--worn);
}

/* big packing-tape runs across the box, like the cover */
.run {
  position: absolute;
  height: 92px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.4), rgba(255,255,255,0) 22%, rgba(255,255,255,.14) 58%, rgba(255,255,255,0) 80%, rgba(255,255,255,.22)),
    repeating-linear-gradient(97deg, rgba(255,255,255,.1) 0 4px, transparent 4px 30px),
    var(--tape);
  box-shadow: 0 1px 0 rgba(255,255,255,.35) inset, 0 -1px 0 rgba(90,60,25,.15) inset, 0 2px 6px rgba(60,35,10,.12);
  overflow: hidden;
  transform-origin: left center;
  animation: unroll 1.1s var(--ease) both;
}
/* light glinting off the plastic */
.run::after {
  content: "";
  position: absolute;
  inset: -40% auto -40% -30%;
  width: 22%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.55), transparent);
  transform: skewX(-20deg);
  animation: glint 7s 1.6s ease-in-out infinite;
}
.run--a { top: 9%; left: -5%; width: 110%; transform: rotate(-2.2deg); }
.run--b { top: 66%; left: -5%; width: 110%; transform: rotate(1.6deg); animation-delay: .25s; }
.run--b::after { animation-delay: 4.2s; }

/* faint printed box markings */
.mark {
  position: absolute;
  font-family: var(--font-stencil);
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1;
  color: rgba(60,38,18,.2);
  white-space: nowrap;
  -webkit-mask: var(--worn); mask: var(--worn);
  mix-blend-mode: multiply;
}
.mark--fragile {
  right: 3%; top: 34%;
  font-size: clamp(54px, 9vw, 130px);
  color: rgba(150,40,30,.2);
  border: .06em solid currentColor;
  padding: .04em .18em 0;
  transform: rotate(-8deg);
}
.mark--up {
  left: 3%; top: 40%;
  font-size: clamp(26px, 3vw, 40px);
  text-align: center;
  transform: rotate(-90deg);
  transform-origin: left top;
}
.mark--up b { display: block; font-size: 1.9em; letter-spacing: .3em; }
.mark--code {
  left: 6%; bottom: 3%;
  font-size: clamp(18px, 2vw, 24px);
  letter-spacing: .25em;
}

/* =========================================================
   CONTENT
   ========================================================= */
.parcel {
  max-width: 560px;
  margin: 0 auto;
  padding: clamp(28px, 6vw, 64px) 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(28px, 5vw, 40px);
}

/* ---------- cover, taped onto the box ---------- */
.cover {
  position: relative;
  margin: 0;
  width: min(100%, 440px);
  perspective: 1200px;
  animation: parcel-drop 1s var(--ease) both;
}
.cover__tilt {
  position: relative;
  transform: rotate(-1.2deg) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transform-style: preserve-3d;
  transition: transform .5s var(--ease);
}
.cover img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1280 / 1789;
  border-radius: 2px;
  box-shadow:
    0 2px 4px rgba(60,35,10,.25),
    0 22px 46px -14px rgba(60,35,10,.6);
}
/* laminate sheen that follows the pointer */
.cover__tilt::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 2px;
  background: radial-gradient(circle at var(--gx, 30%) var(--gy, 20%), rgba(255,255,255,.28), transparent 45%);
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.tape {
  position: absolute;
  z-index: 2;
  width: 46%;
  height: 44px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.4), rgba(255,255,255,0) 40%, rgba(255,255,255,.18) 70%, rgba(255,255,255,0)),
    repeating-linear-gradient(100deg, rgba(255,255,255,.12) 0 6px, transparent 6px 22px),
    var(--tape);
  box-shadow: 0 1px 2px rgba(60,35,10,.2);
  clip-path: polygon(2% 0, 98% 4%, 100% 30%, 97% 55%, 100% 80%, 98% 100%, 1% 96%, 3% 70%, 0 45%, 2% 20%);
  animation: stick .55s var(--ease) both;
}
.tape--tl { top: -10px; right: -9%; --rot: 34deg; transform: rotate(34deg); animation-delay: .75s; }
.tape--br { bottom: -8px; left: -9%; --rot: 30deg; transform: rotate(30deg); animation-delay: .95s; }

/* ---------- download = shipping label ---------- */
.ship {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.label-btn {
  position: relative;
  display: flex;
  align-items: stretch;
  width: min(100%, 420px);
  min-height: 76px;
  text-decoration: none;
  color: var(--label);
  background: var(--paper), var(--navy);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 3px 0 var(--navy-dark), 0 14px 28px -10px rgba(30,40,70,.6);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), background-color .2s;
  animation: slide-in .8s .35s var(--ease) both;
}
.label-btn:hover {
  transform: translateY(-3px) rotate(-.4deg);
  box-shadow: 0 6px 0 var(--navy-dark), 0 22px 36px -12px rgba(30,40,70,.65);
}
.label-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--navy-dark), 0 8px 16px -8px rgba(30,40,70,.6); }
.label-btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }

/* periodic sheen across the label */
.label-btn::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 -40%;
  width: 30%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.22), transparent);
  transform: skewX(-20deg);
  animation: glint 5s 2s ease-in-out infinite;
  pointer-events: none;
}
/* barcode scanner line, fired on click */
.label-btn::before {
  content: "";
  position: absolute;
  z-index: 3;
  top: 0; bottom: 0; left: 0;
  width: 3px;
  background: #ff3b30;
  box-shadow: 0 0 12px 3px rgba(255,59,48,.7);
  opacity: 0;
  pointer-events: none;
}
.label-btn.is-scanning::before { animation: scan .7s ease-in-out; }

.label-btn__stripe {
  flex: 0 0 18px;
  background: repeating-linear-gradient(-45deg, var(--hazard) 0 10px, var(--ink) 10px 20px);
  animation: hazard 1.6s linear infinite;
}
.label-btn:hover .label-btn__stripe { animation-duration: .5s; }
.label-btn__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 18px;
  line-height: 1.35;
}
.label-btn__kicker {
  font-family: var(--font-stencil);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .14em;
  color: var(--hazard);
}
.label-btn__text {
  font-weight: 700;
  font-size: clamp(22px, 5.4vw, 26px);
}
.label-btn__arrow {
  flex: 0 0 72px;
  display: grid;
  place-items: center;
  border-left: 2px dashed rgba(255,255,255,.35);
}
.label-btn__arrow svg { animation: bob 2.2s 1.5s ease-in-out infinite; }
.label-btn:hover .label-btn__arrow svg { animation: bob .6s ease-in-out infinite; }

/* ---------- counter = delivery receipt ---------- */
.stat {
  position: relative;
  margin: 0;
  width: min(100%, 420px);
  padding: 48px 22px 22px;
  background: var(--paper), linear-gradient(180deg, #fffdf8, var(--label) 60%, #f3ede0);
  color: var(--ink-soft);
  font-size: 17px;
  line-height: 1.9;
  text-align: center;
  text-wrap: balance;
  border-radius: 3px;
  box-shadow: 0 2px 4px rgba(60,35,10,.18), 0 10px 24px -14px rgba(60,35,10,.5);
  transform: rotate(.6deg);
  /* perforated top edge */
  -webkit-mask: radial-gradient(circle 5px at 50% 0, transparent 98%, #000) 0 0 / 18px 100% repeat-x;
          mask: radial-gradient(circle 5px at 50% 0, transparent 98%, #000) 0 0 / 18px 100% repeat-x;
  animation: print 1s .55s var(--ease) both;
}
.stat strong { color: var(--ink); font-weight: 600; }
.stat__line { display: block; }
.stat__num {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
}
.stat__count {
  margin: 0;
  font-family: var(--font-stencil);
  font-weight: 800;
  font-size: clamp(56px, 16vw, 76px);
  line-height: 1.1;
  letter-spacing: .02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  display: inline-block;
}
.stat__count.is-bump { animation: bump .45s var(--spring); }
.stat__stamp {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 0 8px;
  font-family: var(--font-stencil);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .12em;
  line-height: 1.6;
  color: rgba(58,86,137,.7);
  border: 2px solid rgba(58,86,137,.6);
  border-radius: 4px;
  transform: rotate(9deg);
  pointer-events: none;
  -webkit-mask: var(--worn); mask: var(--worn);
  opacity: 0;
}
.stat.is-loaded .stat__stamp { animation: thump .45s var(--spring) forwards; }
.stat.is-error .stat__count { font-size: 40px; color: var(--ink-soft); }

.nowrap { white-space: nowrap; }
.credit__isbn { font-size: 13px; letter-spacing: .04em; }
.credit {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 20px 48px;
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
  color: rgba(44,43,42,.72);
}

/* ---------- hook line ---------- */
.hook { width: min(100%, 420px); animation: slide-in .8s .25s var(--ease) both; }
.hook__kicker {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  color: rgba(44,43,42,.72);
}
.hook__q {
  margin: 0;
  font-size: clamp(26px, 6.4vw, 32px);
  font-weight: 700;
  line-height: 1.45;
  color: var(--ink);
  text-wrap: balance;
}

.scroll-cue {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 14px;
  font-weight: 600;
  font-size: 16px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px dashed rgba(44,43,42,.4);
  animation: fade 1s 1.4s both;
}
.scroll-cue span { display: inline-block; animation: bob 1.8s 2s ease-in-out infinite; }
.scroll-cue:hover { border-bottom-color: var(--ink); }

/* ---------- intro = a printed letter taped into the box ---------- */
.intro {
  padding: clamp(24px, 6vw, 56px) 16px clamp(40px, 8vw, 80px);
}
.sheet {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(40px, 7vw, 72px) clamp(22px, 6vw, 64px) 40px;
  background: var(--paper), linear-gradient(180deg, #fffdf7, #f7f1e4);
  color: var(--ink-soft);
  border-radius: 2px;
  box-shadow: 0 2px 4px rgba(60,35,10,.18), 0 30px 60px -24px rgba(60,35,10,.55);
}
.tape--sheet {
  top: -18px; left: 50%;
  width: 180px;
  --rot: -3deg;
  transform: translateX(-50%) rotate(-3deg);
  animation: none;
}
.intro__head { margin-bottom: 28px; }
.intro__kicker {
  margin: 0;
  font-family: var(--font-stencil);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: .1em;
  color: var(--navy);
}
.intro__title {
  margin: 4px 0 6px;
  font-size: clamp(28px, 6vw, 40px);
  line-height: 1.4;
  font-weight: 700;
  color: var(--ink);
  text-wrap: balance;
}
.intro__sub { font-size: .72em; font-weight: 600; color: var(--ink-soft); }
.intro__by { margin: 0; font-size: 16px; color: rgba(74,64,56,.8); }

.intro__body {
  font-size: 18px;
  line-height: 1.95;
  word-break: break-word;
}
.intro__body p { margin: 0 0 1.1em; text-wrap: pretty; }
.intro__beat {
  font-size: 20px;
  font-weight: 500;
  color: var(--ink);
}
.intro__h {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 2em 0 .7em;
  font-size: clamp(22px, 4.6vw, 26px);
  line-height: 1.45;
  color: var(--ink);
}
.intro__no {
  flex: none;
  font-family: var(--font-stencil);
  font-weight: 800;
  font-size: 1.5em;
  line-height: 1;
  color: var(--hazard);
  -webkit-text-stroke: 1px var(--ink);
}

/* collapsed: show the opening, fade the rest */
.sheet.is-collapsed .intro__body {
  max-height: 900px;
  overflow: hidden;
  -webkit-mask: linear-gradient(#000 60%, transparent);
          mask: linear-gradient(#000 60%, transparent);
}
.sheet__fold { display: none; justify-content: center; margin-top: -8px; }
.sheet.is-collapsed .sheet__fold { display: flex; }
.sheet.is-collapsed .sheet__end { display: none; }
.more {
  min-height: 48px;
  padding: 8px 22px;
  font: inherit;
  font-weight: 700;
  font-size: 17px;
  color: var(--label);
  background: var(--ink);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .2s var(--ease), background-color .2s;
}
.more:hover { transform: translateY(-2px); background: #000; }
.more:focus-visible { outline: 3px solid var(--navy); outline-offset: 3px; }

.sheet__end {
  margin-top: 36px;
  padding-top: 28px;
  border-top: 2px dashed rgba(74,64,56,.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
.sheet__end p { margin: 0; font-weight: 600; color: var(--ink); }
.label-btn--small { min-height: 60px; width: min(100%, 360px); animation: none; }
.label-btn--small .label-btn__text { font-size: 20px; }
.label-btn--small .label-btn__arrow { flex-basis: 60px; }

/* paragraphs ink in as they scroll into view */
.js .reveal { opacity: 0; transform: translateY(16px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.js .reveal.is-in { opacity: 1; transform: none; }

/* =========================================================
   MOTION
   ========================================================= */
@keyframes parcel-drop {
  0%   { opacity: 0; transform: translateY(-60px) rotate(-6deg); }
  55%  { opacity: 1; transform: translateY(8px) rotate(1deg); }
  75%  { transform: translateY(-3px) rotate(-.4deg); }
  100% { transform: none; }
}
@keyframes stick {
  from { opacity: 0; transform: rotate(var(--rot)) scaleX(.2) translateY(-8px); }
  to   { opacity: 1; transform: rotate(var(--rot)); }
}
@keyframes unroll {
  from { clip-path: inset(0 100% 0 0); }
  to   { clip-path: inset(0 0 0 0); }
}
@keyframes glint {
  0%, 70% { left: -30%; }
  100%    { left: 130%; }
}
@keyframes slide-in {
  from { opacity: 0; transform: translateX(40px) rotate(2deg); }
}
@keyframes print {
  from { clip-path: inset(0 0 100% 0); transform: rotate(.6deg) translateY(-14px); }
  to   { clip-path: inset(0 0 0 0); transform: rotate(.6deg); }
}
@keyframes thump {
  0%   { opacity: 0; transform: rotate(20deg) scale(2.6); }
  70%  { opacity: 1; transform: rotate(7deg) scale(.92); }
  100% { opacity: 1; transform: rotate(9deg) scale(1); }
}
@keyframes bump { 40% { transform: scale(1.14) translateY(-3px); } }
@keyframes hazard { to { background-position: 0 28.28px; } }
@keyframes bob { 50% { transform: translateY(4px); } }
@keyframes scan {
  0%   { opacity: 1; left: 0; }
  50%  { opacity: 1; left: calc(100% - 3px); }
  100% { opacity: 0; left: 0; }
}
@keyframes fade { from { opacity: 0; } }

/* =========================================================
   DESKTOP
   ========================================================= */
@media (min-width: 900px) {
  .parcel {
    max-width: 1040px;
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
    grid-template-areas: "cover ship";
    align-content: center;
    align-items: center;
    column-gap: 72px;
    padding-top: 56px;
  }
  .cover { grid-area: cover; justify-self: end; }
  .ship { grid-area: ship; align-items: stretch; }
  .stat { text-align: left; }
  .stat__num { justify-content: flex-start; }
  .scroll-cue { align-self: flex-start; padding-left: 0; }
  .parcel { min-height: 92vh; }
}

@media (max-width: 899px) {
  .mark--fragile { top: 52%; right: -4%; }
  .mark--up { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .stat__stamp { opacity: 1; }
  .js .reveal { opacity: 1; transform: none; }
}
