/* ===============================================================
   base.css — the LOOK, shared by desktop and phone.
   Paper, pencil/chalk texture, colours, tongue, frames.
   No page layout here: that lives in desktop.css / phone.css.
   =============================================================== */

/* PLACEHOLDER: your own hand-lettered font. Drop a .woff2 at this
   path and it takes over from Reenie Beanie automatically. */
@font-face {
  font-family: "HarryHand";
  src: url("../assets/fonts/harry-hand.woff2") format("woff2");
  font-display: swap;
}

:root {
  /* Palette taken from "Four Animals Singing": warm peach paper, deep brown
     ink, two skin tones — then aged like oxidised hemp paper. */
  /* Four tones + ink, like the comic panels:
       paper (lightest) -> light -> mid -> dark -> ink */
  --paper: #f8d1b5;          /* peach page */
  --paper-fill: #f6d4bb;
  --tone-light: #ecc4a7;     /* light fills: throat sac, notes */
  --tone-mid: #b4856a;       /* mid fills: cards */
  --tone-dark: #74402a;      /* dark fills: panel backgrounds */
  --sepia: #3e1404;          /* red-brown ink: outlines, lettering */
  --sepia-soft: #74402a;
  --sanguine: #8e553a;       /* softer second-pass lines */
  --sanguine-light: #b4856a;
  --chalk: #fbe3d0;          /* highlight */
  --ink-text: #4b2510;      /* brown iron-gall ink for lettering */

  /* Thin pencil hand for titles, lighter hand for text */
  --font-title: "Reenie Beanie", "Caveat", cursive;   /* "My font" in ?edit → Type switches to HarryHand */
  --font-body: "Caveat", "Comic Sans MS", cursive;
  /* Type settings (Colour panel → Type in ?edit) */
  --ink-stroke: .8px;        /* extra line thickness on titles and links */
  --title-scale: 1;
  --body-scale: 1;
  --title-spacing: .02em;

  --boil-speed: .62s;   /* slower = calmer line boil */

  /* Aged paper, layered (top to bottom):
       tooth  — fine grain of the sheet
       grit   — dark specks
       flecks — light chalky specks
       spots  — foxing (oxidation spots)
       linen  — fine crossed weave of linen fibre
       hemp   — longer coarse hemp fibres, crossing
       hatch  — faint cross-hatched ageing marks, in patches
       stain  — big oxidised tide-marks
     To use a scanned paper instead:
     --paper-texture: url("../assets/paper/paper.jpg"); */
  --paper-tooth:  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='1.25' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .34  0 0 0 0 .12  0 0 0 0 .04  0 0 0 1.1 -.45'/></filter><rect width='100%' height='100%' filter='url(%23g)'/></svg>");
  --paper-grit:   url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='420' height='420'><filter id='s'><feTurbulence type='fractalNoise' baseFrequency='.3' numOctaves='2' seed='4' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .25  0 0 0 0 .1  0 0 0 0 .04  0 0 0 12 -9.8'/></filter><rect width='100%' height='100%' filter='url(%23s)'/></svg>");
  --paper-flecks: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='360' height='360'><filter id='w'><feTurbulence type='fractalNoise' baseFrequency='.7' numOctaves='2' seed='8' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 .95  0 0 0 0 .88  0 0 0 11 -8.2'/></filter><rect width='100%' height='100%' filter='url(%23w)'/></svg>");
  --paper-spots:  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='700' height='700'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='.045' numOctaves='3' seed='12' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .55  0 0 0 0 .28  0 0 0 0 .1  0 0 0 14 -10.2'/></filter><rect width='100%' height='100%' filter='url(%23p)' opacity='.18'/></svg>");
  --paper-linen:  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='256' height='256'><filter id='l'><feTurbulence type='fractalNoise' baseFrequency='.75 .015' numOctaves='2' seed='3' stitchTiles='stitch' result='a'/><feColorMatrix in='a' values='0 0 0 0 .4  0 0 0 0 .2  0 0 0 0 .08  0 0 0 3 -1.75' result='h'/><feTurbulence type='fractalNoise' baseFrequency='.015 .75' numOctaves='2' seed='5' stitchTiles='stitch' result='b'/><feColorMatrix in='b' values='0 0 0 0 .4  0 0 0 0 .2  0 0 0 0 .08  0 0 0 3 -1.75' result='v'/><feMerge><feMergeNode in='h'/><feMergeNode in='v'/></feMerge></filter><rect width='100%' height='100%' filter='url(%23l)' opacity='.12'/></svg>");
  --paper-hemp:   url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='640' height='640'><filter id='h'><feTurbulence type='turbulence' baseFrequency='.006 .05' numOctaves='3' seed='21' stitchTiles='stitch' result='a'/><feColorMatrix in='a' values='0 0 0 0 .5  0 0 0 0 .27  0 0 0 0 .1  0 0 0 -9 1.25' result='x'/><feTurbulence type='turbulence' baseFrequency='.05 .006' numOctaves='3' seed='33' stitchTiles='stitch' result='b'/><feColorMatrix in='b' values='0 0 0 0 .5  0 0 0 0 .27  0 0 0 0 .1  0 0 0 -9 1.15' result='y'/><feMerge><feMergeNode in='x'/><feMergeNode in='y'/></feMerge></filter><rect width='100%' height='100%' filter='url(%23h)' opacity='.22'/></svg>");
  --paper-hatch:  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1600 1000' preserveAspectRatio='xMidYMid slice'><defs><pattern id='x' width='6' height='6' patternUnits='userSpaceOnUse' patternTransform='rotate(38)'><line x1='0' y1='0' x2='0' y2='6' stroke='%233f1c0b' stroke-width='.7'/></pattern><pattern id='y' width='7' height='7' patternUnits='userSpaceOnUse' patternTransform='rotate(-48)'><line x1='0' y1='0' x2='0' y2='7' stroke='%233f1c0b' stroke-width='.6'/></pattern><filter id='m'><feTurbulence type='fractalNoise' baseFrequency='.004' numOctaves='3' seed='4'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 4.5 -2.6'/></filter><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.005' numOctaves='3' seed='19'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 4.5 -2.8'/></filter><mask id='k'><rect width='1600' height='1000' filter='url(%23m)'/></mask><mask id='j'><rect width='1600' height='1000' filter='url(%23n)'/></mask></defs><rect width='1600' height='1000' fill='url(%23x)' mask='url(%23k)' opacity='.07'/><rect width='1600' height='1000' fill='url(%23y)' mask='url(%23j)' opacity='.05'/></svg>");
  --paper-stain:  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1600 1000' preserveAspectRatio='none'><filter id='b' x='0' y='0' width='100%' height='100%'><feTurbulence type='fractalNoise' baseFrequency='.005' numOctaves='4' seed='6'/><feColorMatrix values='0 0 0 0 .62  0 0 0 0 .34  0 0 0 0 .14  0 0 0 .6 -.3'/></filter><rect width='100%' height='100%' filter='url(%23b)'/></svg>");
  /* Scrap linen for the title banner: a tighter, stronger weave */
  --linen-weave: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='l'><feTurbulence type='fractalNoise' baseFrequency='1.1 .02' numOctaves='2' seed='2' stitchTiles='stitch' result='a'/><feColorMatrix in='a' values='0 0 0 0 .45  0 0 0 0 .25  0 0 0 0 .12  0 0 0 3.2 -1.85' result='h'/><feTurbulence type='fractalNoise' baseFrequency='.02 1.1' numOctaves='2' seed='9' stitchTiles='stitch' result='b'/><feColorMatrix in='b' values='0 0 0 0 .45  0 0 0 0 .25  0 0 0 0 .12  0 0 0 3.2 -1.85' result='v'/><feMerge><feMergeNode in='h'/><feMergeNode in='v'/></feMerge></filter><rect width='100%' height='100%' filter='url(%23l)' opacity='.4'/></svg>");
  --linen-tooth: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='260' height='260'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='1.05' numOctaves='2' seed='77' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .32  0 0 0 0 .18  0 0 0 0 .08  0 0 0 .9 -.4'/></filter><rect width='100%' height='100%' filter='url(%23g)'/></svg>");
  --linen-slubs: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='520' height='520'><filter id='h'><feTurbulence type='turbulence' baseFrequency='.004 .09' numOctaves='2' seed='58' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .5  0 0 0 0 .3  0 0 0 0 .14  0 0 0 -9 1.2'/></filter><rect width='100%' height='100%' filter='url(%23h)' opacity='.3'/></svg>");
  --linen-texture: var(--linen-weave), var(--linen-tooth), var(--linen-slubs);

  /* Ink from the other side of the sheet showing through (mirrored, blurred) */
  --paper-showthrough: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1600 1000' preserveAspectRatio='xMidYMid slice'><filter id='s'><feGaussianBlur stdDeviation='.9'/></filter><g fill='none' stroke='%234a2410' stroke-linecap='round' opacity='.1' filter='url(%23s)' transform='scale(-1 1) translate(-1600 0)'><path d='M731 550 C638 641 699 726 706 692 C599 704 660 711 543 671 C529 743 638 666 593 629' stroke-width='3.1'/><path d='M171 110 C119 137 131 141 223 221 C98 268 88 38 116 23' stroke-width='3.3'/><path d='M200 293 C219 176 89 43 207 105 C262 19 109 -222 -19 -88' stroke-width='2.3'/><path d='M1101 433 C1032 309 1118 683 1168 544 C1092 424 1170 480 1302 391 C1287 298 1204 304 1135 415 C1111 329 1140 403 1209 262' stroke-width='3.0'/><path d='M518 823 C549 846 218 916 355 1022 C388 1121 291 698 325 825' stroke-width='2.0'/><path d='M997 93 C1134 88 952 184 930 74 C1052 170 690 -157 765 -64 C674 71 1004 143 890 112' stroke-width='2.4'/><path d='M230 113 C157 210 122 132 94 194 C-36 113 -57 388 -75 282 C50 194 -161 125 -16 195' stroke-width='2.4'/><path d='M167 228 C45 120 168 367 183 417 C317 444 431 418 304 426 C164 456 103 221 230 351' stroke-width='2.2'/><path d='M277 141 C397 212 362 324 301 236 C356 356 628 152 516 176 C538 214 632 347 668 322' stroke-width='2.7'/><path d='M195 617 C162 688 417 691 393 708 C468 567 599 536 569 542 C568 576 555 548 429 621' stroke-width='1.6'/><path d='M513 650 C466 779 523 674 523 751 C563 842 550 561 474 651' stroke-width='2.0'/><path d='M407 837 L434 812' stroke-width='2.0'/><path d='M403 841 L426 821' stroke-width='1.3'/><path d='M398 847 L424 824' stroke-width='1.5'/><path d='M393 856 L424 827' stroke-width='1.5'/><path d='M391 855 L420 828' stroke-width='1.0'/><path d='M380 865 L401 846' stroke-width='1.8'/><path d='M383 865 L406 844' stroke-width='1.0'/><path d='M367 871 L385 855' stroke-width='1.0'/><path d='M365 880 L390 857' stroke-width='1.7'/><path d='M356 896 L383 872' stroke-width='1.2'/><path d='M357 885 L373 870' stroke-width='1.5'/><path d='M347 890 L367 872' stroke-width='1.3'/><path d='M1076 516 L1101 479' stroke-width='1.4'/><path d='M1069 520 L1098 477' stroke-width='1.2'/><path d='M1062 523 L1093 476' stroke-width='1.7'/><path d='M1057 530 L1084 490' stroke-width='1.3'/><path d='M1046 530 L1084 474' stroke-width='1.8'/><path d='M1040 534 L1064 496' stroke-width='1.4'/><path d='M1045 539 L1084 480' stroke-width='1.9'/><path d='M1037 548 L1057 517' stroke-width='1.5'/><path d='M1035 547 L1064 505' stroke-width='1.3'/><path d='M1010 549 L1048 493' stroke-width='1.4'/><path d='M1025 558 L1059 507' stroke-width='1.9'/><path d='M1008 571 L1046 514' stroke-width='1.5'/><path d='M996 565 L1033 508' stroke-width='1.6'/><path d='M1065 706 L1096 669' stroke-width='1.3'/><path d='M1059 712 L1097 666' stroke-width='1.2'/><path d='M1052 718 L1082 681' stroke-width='1.6'/><path d='M1049 721 L1080 684' stroke-width='1.6'/><path d='M1046 729 L1076 692' stroke-width='1.4'/><path d='M1032 731 L1062 695' stroke-width='1.7'/><path d='M1036 735 L1064 701' stroke-width='2.0'/><path d='M1017 737 L1047 701' stroke-width='1.1'/><path d='M1020 749 L1058 703' stroke-width='1.5'/><path d='M544 253 L567 218' stroke-width='1.2'/><path d='M539 257 L577 199' stroke-width='1.2'/><path d='M532 261 L567 208' stroke-width='1.9'/><path d='M524 267 L562 209' stroke-width='1.9'/><path d='M524 271 L564 209' stroke-width='1.6'/><path d='M512 277 L546 225' stroke-width='1.2'/><path d='M511 278 L546 225' stroke-width='1.1'/><path d='M493 284 L523 238' stroke-width='1.2'/><path d='M492 291 L518 251' stroke-width='1.8'/><path d='M372 177 L388 142' stroke-width='1.4'/><path d='M365 180 L377 153' stroke-width='1.7'/><path d='M361 183 L376 150' stroke-width='1.9'/><path d='M348 185 L361 156' stroke-width='1.8'/><path d='M345 191 L355 168' stroke-width='1.1'/><path d='M343 190 L357 160' stroke-width='1.5'/><path d='M330 193 L340 170' stroke-width='1.2'/><path d='M318 203 L334 166' stroke-width='1.1'/><path d='M187 861 L218 823' stroke-width='1.2'/><path d='M181 866 L205 837' stroke-width='1.2'/><path d='M175 870 L207 831' stroke-width='1.9'/><path d='M168 873 L209 822' stroke-width='1.3'/><path d='M167 883 L210 829' stroke-width='1.9'/><path d='M152 885 L180 852' stroke-width='1.6'/><path d='M154 892 L183 856' stroke-width='1.1'/><path d='M142 890 L186 835' stroke-width='1.1'/><path d='M143 899 L174 861' stroke-width='1.4'/><path d='M141 899 L168 865' stroke-width='1.8'/><path d='M133 901 L176 847' stroke-width='2.0'/><path d='M112 904 L141 868' stroke-width='2.0'/><path d='M518 273 L542 245' stroke-width='1.7'/><path d='M512 279 L527 261' stroke-width='1.6'/><path d='M506 282 L526 258' stroke-width='1.1'/><path d='M503 287 L520 268' stroke-width='1.3'/><path d='M492 293 L514 267' stroke-width='2.0'/><path d='M489 302 L513 274' stroke-width='1.8'/><path d='M490 303 L516 274' stroke-width='1.0'/><path d='M472 302 L493 278' stroke-width='1.2'/><path d='M794 589 L836 557' stroke-width='1.5'/><path d='M789 594 L852 547' stroke-width='1.7'/><path d='M784 599 L841 555' stroke-width='1.6'/><path d='M779 606 L834 565' stroke-width='1.1'/><path d='M777 612 L828 573' stroke-width='1.7'/><path d='M773 622 L813 592' stroke-width='1.7'/><path d='M769 629 L803 603' stroke-width='1.1'/><path d='M758 638 L795 610' stroke-width='2.0'/><path d='M761 641 L795 615' stroke-width='1.4'/><path d='M759 651 L803 617' stroke-width='1.2'/><path d='M751 640 L797 605' stroke-width='1.6'/><path d='M741 660 L786 626' stroke-width='1.7'/><path d='M733 650 L775 619' stroke-width='1.1'/><path d='M774 502 L810 465' stroke-width='1.7'/><path d='M769 507 L795 480' stroke-width='2.0'/><path d='M763 513 L788 488' stroke-width='1.7'/><path d='M757 515 L783 488' stroke-width='1.0'/><path d='M756 521 L783 493' stroke-width='1.8'/><path d='M742 525 L768 498' stroke-width='2.0'/><path d='M741 532 L770 503' stroke-width='1.5'/><path d='M741 544 L779 505' stroke-width='1.4'/><path d='M725 550 L762 512' stroke-width='1.4'/><path d='M720 547 L745 522' stroke-width='1.2'/><path d='M713 557 L740 529' stroke-width='1.8'/><path d='M707 553 L741 517' stroke-width='1.6'/></g></svg>");
  /* Old water tide-lines */
  --paper-tide: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1600 1000' preserveAspectRatio='xMidYMid slice'><filter id='t' x='0' y='0' width='100%' height='100%'><feTurbulence type='fractalNoise' baseFrequency='.0022' numOctaves='2' seed='31'/><feComponentTransfer><feFuncA type='table' tableValues='0 0 0 0 0 .85 .1 0 0 0 0 .65 0 0 0 0'/></feComponentTransfer><feColorMatrix values='0 0 0 0 .52  0 0 0 0 .27  0 0 0 0 .1  0 0 0 1 0'/></filter><rect width='1600' height='1000' filter='url(%23t)' opacity='.32'/></svg>");
  /* Soft, smudgy mottling of handled old paper */
  --paper-mottle: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='900' height='900'><filter id='m'><feTurbulence type='fractalNoise' baseFrequency='.012' numOctaves='5' seed='44' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .42  0 0 0 0 .3  0 0 0 0 .2  0 0 0 .3 -.12'/></filter><rect width='100%' height='100%' filter='url(%23m)'/></svg>");
  --paper-texture: var(--paper-mottle), var(--paper-tooth), var(--paper-grit), var(--paper-flecks), var(--paper-spots),
                   var(--paper-linen), var(--paper-hemp), var(--paper-hatch),
                   var(--paper-showthrough), var(--paper-tide), var(--paper-stain);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

/* The page paper. Also used by the holes torn in the banner, so a hole
   shows exactly the paper behind it. */
body,
.banner-hole-in {
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse at 50% 45%, transparent 42%, rgba(150, 64, 30, .12) 78%, rgba(96, 32, 10, .3) 100%),
    var(--paper-texture);
  background-size: auto, 900px 900px, 300px 300px, 420px 420px, 360px 360px, 700px 700px, 256px 256px, 640px 640px, cover, cover, cover, 100% 100%;
  background-attachment: fixed;
}
body {
  color: var(--sepia);
  font-family: var(--font-body);
  overflow-x: hidden;
}

a { color: inherit; }

.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- Tongue boil + pencil / ink lettering ---------- */
@keyframes tongue-chalk {
  0%   { filter: url(#tongue-1); }
  33%  { filter: url(#tongue-2); }
  66%  { filter: url(#tongue-3); }
  100% { filter: url(#tongue-1); }
}
.pencil { filter: url(#pencil-1); }   /* static: no boil on lettering */

/* Lettering in brown iron-gall ink, with pools, bleed and stray drops (no boil) */
.ink { color: var(--ink-text); filter: url(#ink-1); }
/* thicker strokes on all hand-lettered titles (the fonts only come in one weight) */
.ink, .tab-label, .page-title, .signature .ink, .card-caption strong, .placeholder-title {
  -webkit-text-stroke: var(--ink-stroke) currentColor;
  paint-order: stroke fill;
  letter-spacing: var(--title-spacing);
}
.page-title { color: var(--ink-text); }
.ink-drop {
  position: absolute;
  border-radius: 50% 46% 54% 48%;
  background: var(--ink-text);
  box-shadow: 0 0 2px 1px rgba(138, 82, 38, .35);
  pointer-events: none;
}

/* ---------- Lettering ---------- */
.signature {
  font-family: var(--font-title);
  line-height: .9;
  text-decoration: none;
  display: inline-flex;
  flex-direction: column;
}
.signature small { font-family: var(--font-body); color: var(--ink-text); opacity: .8; }
.signature .ink { font-family: var(--font-body); }   /* name in the same hand as "2D Animator" */

.tab {
  position: relative;
  display: inline-block;
  font-family: var(--font-title);
  font-weight: 400;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
  padding: 6px 4px 12px;
  transition: transform .15s ease;
}
.tab:nth-child(1) { transform: rotate(-3deg); }
.tab:nth-child(2) { transform: rotate(2deg); }
.tab:nth-child(3) { transform: rotate(-1.5deg); }
.tab:hover { transform: rotate(0deg) scale(1.08); }
.tab:focus-visible { outline: 2px dashed var(--sepia); outline-offset: 6px; }
.tab .tab-label { display: inline-block; }
.tab .tab-art { display: block; height: 1.3em; width: auto; }

/* Red-chalk scribble under the current tab */
.tab::after {
  content: "";
  position: absolute;
  left: -6%;
  right: -6%;
  bottom: -2px;
  height: 14px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 14' preserveAspectRatio='none'><path d='M2 8 C40 2 70 12 110 6 S170 3 198 7' fill='none' stroke='%234b2510' stroke-width='2' stroke-linecap='round'/><path d='M8 10 C50 6 90 12 130 8 S180 7 194 10' fill='none' stroke='%234b2510' stroke-width='.8' stroke-linecap='round' opacity='.7'/></svg>") no-repeat center / 100% 100%;
  opacity: 0;
  transform: scaleX(.3);
  transition: opacity .2s, transform .25s cubic-bezier(.3, 1.6, .5, 1);
  filter: url(#ink-1);   /* same ink spill as the clickable lettering */
}
.tab.is-active::after { opacity: 1; transform: scaleX(1); }

.tab[hidden] { display: none; }
.tab.is-snatched { visibility: hidden; }
@keyframes respawn {
  0%   { transform: scale(0) rotate(-20deg); }
  60%  { transform: scale(1.2) rotate(6deg); }
  100% { transform: scale(1) rotate(0); }
}
.tab.is-respawning .tab-label,
.tab.is-respawning .tab-art {
  animation: respawn .45s cubic-bezier(.3, 1.4, .5, 1) both;
}

/* Copy of the tab that rides the tongue */
.tab-clone {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  margin: 0;
  font-family: var(--font-title);
  color: var(--sepia);
  line-height: 1;
  white-space: nowrap;
  will-change: transform;
}

.page-title {
  font-family: var(--font-title);
  font-weight: normal;
  text-align: center;
  margin: 0 0 24px;
}

/* ---------- Linen banner for the titles ---------- */
.banner-wrap {
  position: relative;
  z-index: 6;
  filter: drop-shadow(0 1.5px 1px rgba(62, 20, 4, .3));   /* lies on the page, barely lifted */
}
.banner {
  position: relative;
  background-color: #f2dcc6;
  background-image:
    radial-gradient(ellipse at 50% 40%, transparent 50%, rgba(150, 80, 40, .22) 100%),
    var(--linen-texture);
  background-size: 100% 100%, 200px 200px, 260px 260px, 520px 520px;
  background-position: 0 0, 37px 11px, 83px 59px, 140px 23px;   /* offset so it never lines up with the page */
  /* torn edges: clip-path is set by js/main.js to fit the banner's size */
}
@keyframes banner-drop {
  0%   { transform: translateY(-140%) rotate(-3deg); }
  55%  { transform: translateY(8%) rotate(1.5deg); animation-timing-function: ease-out; }
  75%  { transform: translateY(-3%) rotate(-.8deg); animation-timing-function: ease-in-out; }
  90%  { transform: translateY(1%) rotate(.3deg); }
  100% { transform: none; }
}
.banner-wrap.is-dropping { animation: banner-drop .9s .05s ease-in backwards; }

/* After it lands the banner keeps swaying a little, like paper in a draught */
@keyframes banner-sway {
  0%, 100% { transform: rotate(-.35deg) translateY(0); }
  50%      { transform: rotate(.35deg) translateY(1.5px); }
}
.banner { transform-origin: 50% -40px; animation: banner-sway 5.5s ease-in-out infinite; }

/* Aged band inside torn edges (drawn by agedEdge() in js/main.js) */
.aged-edge { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.aged-edge .aged-band { fill: none; stroke: #9a5a32; stroke-width: 12; stroke-opacity: .22; filter: url(#edge-blur); }
.aged-edge .aged-line { fill: none; stroke: #5a2a12; stroke-width: 2; stroke-opacity: .55; }
.banner > nav { position: relative; }

/* A hole torn out of the banner: light torn fibres around the edge,
   page paper showing through the middle */
.banner-hole {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  background: #fbeee2;
}
.banner-hole-in { position: absolute; inset: 4px; }
.banner-hole.is-mending { transition: opacity .45s ease-out; opacity: 0; }

/* The torn scrap that rides the tongue */
.tab-clone .scrap-paper {
  position: absolute;
  inset: 0;
  background-color: #f2dcc6;
  background-image: var(--linen-texture);
  background-size: 200px 200px, 260px 260px, 520px 520px;
}
.tab-clone .scrap-fibres { position: absolute; inset: -3px; background: #fbeee2; }
.tab-clone .scrap-label { position: relative; display: grid; place-items: center; width: 100%; height: 100%; }
.tab-clone { filter: drop-shadow(0 4px 3px rgba(62, 20, 4, .3)); }

/* Vignette over the page paper (below all content) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse 75% 70% at 50% 45%, transparent 55%, rgba(110, 44, 14, .16) 85%, rgba(70, 24, 6, .3) 100%);
  opacity: var(--vignette, 1);
}

/* Ink splatter when a page stamps down */
.stamp-splat {
  position: fixed;
  z-index: 55;
  border-radius: 50% 44% 56% 48%;
  background: var(--ink-text);
  box-shadow: 0 0 2px 1px rgba(178, 80, 44, .35);
  pointer-events: none;
}

/* ---------- Pages ---------- */
.page[hidden] { display: none !important; }
main { perspective: 1400px; perspective-origin: 50% 40%; }   /* depth for the stamp-down */
@keyframes page-in {
  from { opacity: 0; transform: translateY(14px) rotate(-.4deg); }
  to   { opacity: 1; transform: none; }
}
.page.is-entering { animation: page-in .45s cubic-bezier(.2, .9, .3, 1) both; }

/* ---------- Sketched frames ----------
   Two passes of line, like a searching contour: a sepia line plus a
   looser red-chalk line. Only the lines boil, never the content. */
.sketch-frame { position: relative; }
.sketch-frame::before,
.sketch-frame::after {
  content: "";
  position: absolute;
  pointer-events: none;
  border-radius: 6px 3px 7px 4px;
}
.sketch-frame::before {
  inset: -6px;
  border: 3px solid var(--ink-text);
  filter: url(#ink-1);   /* the same brown ink + yellow spill as the lettering */
}
.sketch-frame::after {
  display: none;   /* single ink line only */
}

/* Placeholder slots: cross-hatched in red chalk */
.placeholder {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  color: var(--tone-light);
  border-radius: 4px;
  background:
    repeating-linear-gradient(-38deg, transparent 0 5px, rgba(62, 20, 4, .22) 5px 6.2px),
    repeating-linear-gradient(44deg,  transparent 0 9px, rgba(62, 20, 4, .14) 9px 10px),
    var(--tone-dark);
}
.is-empty > .placeholder { display: flex; }
.placeholder-title { font-family: var(--font-title); color: var(--paper); }
.placeholder-hint { font-size: .9rem; opacity: .8; }

/* Showreel */
.reel-frame { aspect-ratio: 16 / 9; border-radius: 4px; background: var(--tone-dark); }
.reel-frame video {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  background: #1d1410;
  object-fit: contain;
}
.reel-frame.is-empty video { visibility: hidden; }

/* Portfolio cards */
.project-card { text-decoration: none; display: block; }
.project-card:nth-child(3n+1) { transform: rotate(-1deg); }
.project-card:nth-child(3n+2) { transform: rotate(.8deg); }
.project-card .card-media {
  aspect-ratio: 16 / 10;
  border-radius: 6px;
  background: var(--tone-mid);
  transition: transform .2s ease;
}
.project-card:hover .card-media { transform: scale(1.03); }
.project-card .card-media::before { inset: -5px; border-width: 4.5px; }
.project-card .card-media::after  { inset: -11px -5px -4px -9px; }
.project-card .card-media .placeholder {
  background:
    repeating-linear-gradient(-38deg, transparent 0 5px, rgba(62, 20, 4, .16) 5px 6.2px),
    var(--tone-mid);
}
.project-card .card-media .placeholder-title { color: var(--sepia); }
.project-card .card-media .placeholder-hint { color: var(--sepia); }
.project-card .card-media img,
.project-card .card-media video { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 6px; }
.card-caption { margin-top: 14px; text-align: center; }
.card-caption strong { font-family: var(--font-title); font-weight: normal; display: block; }
.card-caption span { color: var(--sepia-soft); }

/* Contact note */
.note { text-align: center; background: var(--tone-light); border-radius: 4px; transform: rotate(-1deg); }
.note p { margin: 0 0 14px; }
.contact-email { font-family: var(--font-title); }
.socials { list-style: none; padding: 0; margin: 18px 0 0; display: flex; justify-content: center; gap: 28px; }
.socials a { text-decoration-color: var(--sanguine); text-decoration-thickness: 2px; text-underline-offset: 4px; }

   /* thigh catches a bit more light */
          /* flat shadow tone */   /* the leg lines from the black-line sketch */

/* Jump in from off-screen when the page opens: two hops, easing in,
   squash on landing. Remove the class in js/main.js to turn it off. */

/* Bits that fly out with the page */
.spit-blob {
  position: fixed;
  z-index: 55;
  width: 12px;
  height: 10px;
  border-radius: 50% 45% 55% 50%;
  background: var(--tone-light);
  border: 2px solid var(--sepia);
  pointer-events: none;
}

/* ---------- Tongue ---------- */
.tongue-layer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 61;   /* above the torn scrap, so the sticky end grips it */
  pointer-events: none;
  overflow: visible;
}
.tongue-chalk  { animation: tongue-chalk var(--boil-speed) steps(1, end) infinite; }
.tongue-body   { fill: url(#tongue-grad); stroke: var(--sepia); stroke-linejoin: round; }
.tongue-groove { fill: none; stroke: #8f4630; stroke-linecap: round; opacity: .65; }
.tongue-pad    { fill: none; stroke: #8f4630; stroke-linecap: round; opacity: .7; }
.tongue-shine  { fill: none; stroke: #f6d8c6; stroke-linecap: round; opacity: .85; }

/* ---------- Colour correction (js/colour.js) ----------
   See-through layers over the whole page: a grade (brightness, contrast,
   saturation, hue, warmth) and a tint. Editor panels sit above them. */
.colour-grade,
.colour-tint {
  position: fixed;
  inset: 0;
  z-index: 95;
  pointer-events: none;
}
.colour-tint { z-index: 96; }
.colour-grade[hidden], .colour-tint[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .tongue-chalk, .tab::after,
  .sketch-frame::before, .sketch-frame::after { animation: none !important; }
  .page.is-entering, .banner-wrap.is-dropping, .banner { animation: none; }
}
