:root {
  --margin: 2.6vw;                /* outer grid margin (52px on the 2000px mockup) */
  /* Text sizes: four levels, used everywhere
     t1 titles · t2 menu, sub-headings, contact · t3 reading text · t4 small print */
  --t1: max(41.5px, 3.875vw);   /* project titles: 15% smaller than before (was 4.559vw) so there's more room under them; their capitals still start level with the top of the ศ, and nothing under them moves */
  /* before: titles' capitals 1.5 × the ศ logo's height (= 1.5 × logo / Sora's cap height 0.73); Space Grotesk was 4.754vw (cap 0.70), Metallophile 5.501vw (cap 0.605) */
  --t-sub: max(30px, 2.8vw);   /* smaller headings: "Hi! I'm Siranarin" and Contact (project titles stay --t1) */
  --t2: max(14px, 1.2vw);
  --t3: max(14px, 1vw);
  --t4: max(12px, 0.9vw);
  --meta: #9b9b9b;               /* light grey for small print (credits, captions) */
  --nav-size: var(--t2);
  --nav-top: calc(var(--margin) - 0.15 * var(--nav-size));  /* puts the cap height on the grid line */
  --ink: #3a3a3a;
  --blue: #5d82d6;   /* a touch calmer than screen blue */
  --lime: #e0e28a;
  --paper: #f2f2f2;
  --white: #ffffff;
  --side: 25vw;                   /* sidebar width; site.js narrows it to just fit PROJECTS + the longest tag */
  --inner: 2.1vw;                 /* space inside the page: menu → content, text → pictures, inside the tags (30px on a 1440px screen) */
  --heading: "Lexend", "Sora", "Barlow", sans-serif;   /* Sora Light (Google Fonts), with the digits 0–9 from Lexend Light (Sora's are too round; only the digits of Lexend are loaded, so everything else falls through to Sora). Before: Space Grotesk Light, Metallophile Sp8 Light, Space Grotesk Medium, JetBrains Mono */
  --heading-weight: 300;
  --body: "Figtree", system-ui, sans-serif;   /* Figtree (its 6 already has a straight tail, like the headings' Lexend digits); before: Barlow */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--paper);   /* light grey on every page */
  color: var(--ink);
  font-family: var(--body);
  font-weight: 400;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
img { display: block; }
h1, h2, .heading { font-family: var(--heading); font-weight: var(--heading-weight); }

/* ---------- Hero logo: a cover page that slides away ---------- */
.hero {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--paper);
  cursor: pointer;
  transition: transform 1s cubic-bezier(.75,0,.2,1);
}
.logo img, .logo svg {
  display: block;
  width: min(50vw, 1000px);
  transition: transform 0.8s cubic-bezier(.6,0,.2,1), opacity 0.6s ease;
}
body.hero-on { overflow: hidden; }
/* "swipe down" hint on the cover: shows once the name is clicked */
/* phones, homepage: the covers dropping through the screen after the name (fall.js) */
.cover-fall { position: fixed; inset: 0; z-index: 50; overflow: hidden; transition: opacity 0.25s ease; }
.cover-fall img { position: absolute; left: 0; top: 0; height: auto; will-change: transform; transform: translate(-999px, -999px);
                  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.12)); }
.cover-fall.is-done { opacity: 0; pointer-events: none; }
.swipe-hint {
  position: absolute;
  left: 50%;
  bottom: var(--margin);
  translate: -50% 0;
  font-size: var(--t2);
  letter-spacing: 0.02em;
  color: var(--ink);
  opacity: 0;
  transform: translateY(0.6em);
  transition: opacity 0.4s ease, transform 0.6s cubic-bezier(.34,1.56,.5,1);
  pointer-events: none;
}
.swipe-hint.is-on { opacity: 1; transform: none; animation: hint-bob 1.6s ease-in-out 0.6s infinite; }
@keyframes hint-bob { 0%, 100% { transform: none; } 50% { transform: translateY(0.35em); } }
body:not(.hero-on) .hero { transform: translateY(-100%); pointer-events: none; }
body:not(.hero-on) .logo img, body:not(.hero-on) .logo svg { transform: translateY(-12vh) scale(0.9); opacity: 0; }

/* Work page entrance (runs as the cover slides away) */
.layout .sidebar { transition: transform 0.8s cubic-bezier(.2,.8,.2,1) 0.35s; }
body.hero-on .layout .sidebar { transform: translateX(-100%); transition-delay: 0s; }
.selected-title { transition: opacity 0.6s ease 0.6s; }
body.hero-on .selected-title { opacity: 0; transition-delay: 0s; }
body.hero-on .spinnable { opacity: 0; scale: 0.7; transition-delay: 0s; }
/* Arriving from another page (the ศ logo): skip the long entrance — the sidebar is just there
   and the pictures pop in quickly */
body.quick-in .layout .sidebar { transition: none; }
body.quick-in .selected-title { transition: opacity 0.2s ease; }
body.quick-in .spinnable {
  transition:
    transform 0.45s cubic-bezier(.2,.7,.2,1),
    opacity 0.2s ease,
    scale 0.45s cubic-bezier(.3,1.7,.5,1);
}

/* ---------- Bouncy pop on click ---------- */
@keyframes pop {
  0%   { scale: 1; }
  35%  { scale: var(--pop, 1.15); }
  65%  { scale: 0.96; }
  85%  { scale: 1.03; }
  100% { scale: 1; }
}
.pop { animation: pop 0.42s cubic-bezier(.3,.7,.4,1); }
.pic { --pop: 1.1; }
.nav-link, .cv, .contact-info a { display: inline-block; }
.side-nav > .nav-link, .projects-row > .nav-link { align-self: flex-start; }

/* ---------- Sidebar + main layout ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--side) 1fr;
  align-items: start;
}
.layout.on-paper { background: var(--paper); }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--lime);
  z-index: 30;
  overflow: hidden;              /* tags slide in from beyond the right edge */
}
.side-nav {
  padding: var(--nav-top) 0 0 var(--margin);
  display: flex;
  flex-direction: column;
  /* Even spacing chosen so PROJECTS sits level with the work-type line on project pages
     ("Poster Design (2026)"); the category tags line up with PROJECTS, so they move with it */
  gap: 1.975vw;
  font-size: var(--nav-size);
  line-height: 1.2;
  letter-spacing: 0.02em;
}

/* ศ logo at the top of the sidebar (41px wide on the 2000px mockup): dark grey, blue on hover */
.side-logo {
  position: relative; z-index: 1;
  display: block; align-self: flex-start;
  width: 2.05vw; min-width: 22px;
  color: var(--ink);
  transition: color 0.2s ease;
}
.side-logo:hover { color: var(--blue); }
.side-logo svg { display: block; width: 100%; height: auto; }

/* CONTACT at the bottom of the sidebar; hides while the contact section is on screen */
.side-contact {
  position: absolute;
  left: var(--margin);
  bottom: calc(var(--margin) - 0.2 * var(--nav-size));
  font-size: var(--nav-size);
  line-height: 1.2;
  letter-spacing: 0.02em;
  transition: color 0.2s ease, opacity 0.3s ease, translate 0.3s ease;
}
.side-contact.is-hidden { opacity: 0; translate: 0 0.6em; pointer-events: none; }
.contact.is-tucked { display: none; }   /* inner pages: shown when CONTACT is clicked */

/* Project pages: BACK (bottom left, next to the sidebar) and NEXT (bottom right) sit at the very
   end of the page, so they only show once you scroll to the bottom (or straight away on a
   short page). Equal space above and below them, never over a picture. Body-text size, in capitals. */
body[data-page="project"] .main { min-height: 100vh; display: flex; flex-direction: column; }
body[data-page="project"] .detail { flex: 1; }
.step-row {
  display: flex;
  justify-content: flex-end;
  padding: var(--margin) var(--margin) calc(var(--margin) - 0.2 * var(--t4));
  font-size: var(--t4);   /* small print, in capitals; turns blue on hover like every link */
  text-transform: uppercase;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

/* All links: no underline, turn blue on hover; the current page stays blue */
.nav-link, .top-link { transition: color 0.2s ease; }
.nav-link:hover, .top-link:hover, .nav-link.is-active, .top-link.is-active { color: var(--blue); }

/* PROJECTS row + category tags */
.projects-row { width: calc(var(--side) - var(--margin)); }
.projects-row:hover > .nav-link, .projects-row.is-open > .nav-link { color: var(--blue); }
/* Menu words sit above the tag area so they stay clickable */
.side-nav .nav-link { position: relative; z-index: 1; }

/* Tags are scattered around the sidebar (spots from the mockup, set in site.js).
   The list covers the top of the sidebar so the mouse can travel between tags without it closing. */
.tags {
  list-style: none;
  position: absolute;            /* relative to the sidebar */
  left: 0;
  top: 0;
  width: 100%;
  height: 38vw;
  pointer-events: none;
}
.tags li {
  position: absolute;
  right: 0;                      /* flush against the sidebar's right edge */
  top: calc(var(--top, 9.5vw) + var(--dy, 0px));
  translate: 0 -50%;
  transform: translateX(105%);   /* hidden: tucked away past the right edge */
  transition: transform 0.7s cubic-bezier(.34,1.56,.5,1);   /* overshoot = springy slide */
  transition-delay: calc(var(--i) * 70ms);
}
.projects-row.is-open .tags { pointer-events: auto; }
.projects-row.is-open .tags li { transform: none; }

/* Tags are post-it flags with a tracing-paper feel: matte and a little see-through (the lime
   shows through), a barely-there shadow, and creases from a real crumpled-paper scan, each tag a different patch and depth
   (assets/texture/crease.jpg, Paper003 from ambientCG, CC0). The picked one gets crumpled. */
.tag {
  display: inline-block;
  background-color: rgba(93, 130, 214, 0.95);
  color: var(--white);
  font-size: var(--t2);
  line-height: 1.3;
  /* one solid piece that carries on 3vw past the sidebar edge (hidden), so when it springs
     or slides left there is never a seam or gap on the right */
  padding: 0.2em calc(var(--inner) + 3vw) 0.2em 0.45em;   /* text ends one inner space from the sidebar edge */
  margin-right: -3vw;
  white-space: nowrap;
  isolation: isolate;
  box-shadow: 0 0.03vw 0.08vw rgba(0,0,0,0.1);
  transition: background-color 0.2s ease;
}
.tag::before {                     /* creases — switched off for now (display: none) */
  display: none;
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: url("assets/texture/crease.jpg") var(--cx, 0) var(--cy, 0) / var(--cs, 420px);
  mix-blend-mode: multiply;
  /* scan's grey → white, then pull the creases out: a little here, a lot when crumpled */
  filter: brightness(0.59) contrast(var(--crumple, 8)) brightness(2);
  transition: filter 0.35s ease;
  pointer-events: none;
}
.tag.is-current::before { filter: brightness(0.59) contrast(calc(var(--crumple, 8) + 5)) brightness(2); }
.tags li:nth-child(1) .tag { --cx: -40px;  --cy: -10px;  --cs: 380px; --crumple: 7; }
.tags li:nth-child(2) .tag { --cx: -210px; --cy: -90px;  --cs: 520px; --crumple: 9; }
.tags li:nth-child(3) .tag { --cx: -120px; --cy: -260px; --cs: 300px; --crumple: 6; }
.tags li:nth-child(4) .tag { --cx: -300px; --cy: -170px; --cs: 440px; --crumple: 8; }
.tags li:nth-child(5) .tag { --cx: -60px;  --cy: -330px; --cs: 340px; --crumple: 7.5; }
.tag:hover, .tag.is-current { background-color: rgba(58, 58, 58, 0.96); }
.tag { position: relative; }
/* Clicking a tag: it slides out a little to the left and springs back */
@keyframes tag-nudge {
  0%   { transform: translateX(0); }
  35%  { transform: translateX(-0.9vw); }
  70%  { transform: translateX(0.15vw); }
  100% { transform: translateX(0); }
}
.tag.pop { animation: tag-nudge 0.45s ease-out; }
/* Clicking PROJECTS while the tags are already out: each tucks in a little and springs back out */
@keyframes tag-rebound {
  0%   { transform: translateX(0); }
  35%  { transform: translateX(16%); }
  70%  { transform: translateX(-3.5%); }
  100% { transform: translateX(0); }
}
.tag.rebound { animation: tag-rebound 0.6s cubic-bezier(.3,.7,.4,1) both; }

/* Home link (top right of the inner pages) */
.top-link {
  position: absolute;
  right: var(--margin);
  top: var(--nav-top);
  font-size: var(--nav-size);
  line-height: 1.2;
  letter-spacing: 0.02em;
  z-index: 10;
}
.main { position: relative; min-width: 0; }

/* ---------- Scattered picture stage (home + category) ---------- */
.stage {
  position: relative;
  width: 100%;
  height: 100vh;                 /* exactly one screen, so its centre is the middle of what you see */
}
.pic {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  display: block;
  transition:
    transform 0.45s cubic-bezier(.2,.7,.2,1),
    opacity 0.35s ease 0.45s,
    scale 0.6s cubic-bezier(.3,1.7,.5,1) 0.45s;   /* all pop in together, with a little overshoot */
}
.pic:hover, .spinnable.is-hot { transform: scale(1.08); z-index: 5; }
/* Ring pictures go by .is-hot (set by spin.js from the mouse position), not :hover, which can
   stay stuck on a picture that has turned away from a still mouse */
.spinnable:not(.is-hot):hover { transform: none; z-index: auto; }
.pic .spin { transform: rotate(var(--r, 0deg)); }
.pic img {
  width: 100%;
  aspect-ratio: var(--ar, 1.1);
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transition: filter 0.3s ease;
}
/* Home: hovered picture darkens */
.spinnable.is-hot:not(.is-empty) img { filter: brightness(0.62); }
/* Empty spots in the ring (placeholders for now): not clickable */
.spinnable.is-empty { cursor: default; }

.selected-title {
  position: absolute;
  left: 50%;                     /* dead centre of the light area */
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: var(--t1);
  letter-spacing: -0.01em;
  white-space: nowrap;
  pointer-events: none;
}

.project .caption {
  display: block;
  margin-top: 0.8em;
  width: max-content;
  margin-left: 50%;
  transform: translateX(-50%);
  font-size: var(--t4);
  color: var(--meta);
  white-space: nowrap;
}

/* ---------- Category pages ---------- */
#grid { container-type: inline-size; }      /* lets positions use cqw (= 1% of the picture area's width) */

/* One category: random scatter flowing down the page (positions from site.js) */
.scatter { position: relative; min-height: 100vh; }

/* All projects: a pile you can sweep with the mouse (physics in pile.js) */
.pile { position: relative; height: 100vh; }
.pile .pic { left: 0; top: 0; will-change: translate; }
.pile:not(.is-ready) .pic { visibility: hidden; }
.pile .caption {
  position: absolute;
  left: 50%;
  top: 100%;
  margin: 0.4em 0 0;
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.pile .pic:hover .caption { opacity: 1; }
.pile .pic:hover { transform: scale(1.18); }   /* bigger target once you're on it */
.pile .pic { transition: transform 0.3s ease, opacity 0.35s ease, scale 0.35s ease; }
/* Pieces from other categories fade and shrink away when a category is picked */
.pile .pic.is-out { opacity: 0; scale: 0.4; pointer-events: none; }
/* One category picked: the work pictures show 1.5× bigger */
.pile .pic:not(.dot) { width: calc(var(--w) * var(--fit, 1)); }   /* --fit: shrink so it all fits one screen */
.pile.is-filtered .pic:not(.dot) { width: calc(var(--w) * 1.3 * var(--fit, 1)); }   /* a few at a time: bigger, still not bigger than ARRANGE; dots keep their size */
/* Projects with no work yet: circles cut from the menu's green canvas (the same photo,
   assets/texture/menu-fabric.jpg, clipped to a circle). Each dot shows a different patch of
   the cloth (--fx/--fy, set in site.js) and the weave is turned a little; only a very faint
   contact shadow. Not clickable. */
.pile .dot {
  aspect-ratio: 1;
  cursor: default;
}
.pile .dot .paper {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  filter: drop-shadow(0 0.5px 0.5px rgba(0,0,0,0.14));
}
.pile .dot .paper::before {        /* the cloth, a bit bigger than the circle so turning it never shows a gap */
  content: "";
  position: absolute;
  inset: -25%;
  background: var(--lime) url("assets/texture/menu-fabric.jpg") var(--fx, 50%) var(--fy, 50%) / 900px auto no-repeat;
  transform: rotate(var(--rot, 0deg));
}
.pile .dot:hover { transform: none; }

/* ---------- Project detail ----------
   Measured from the 2000px mockup: title across the top, text column on the left
   (422px, stays in view while scrolling), pictures on the right (948px). */
.detail {
  display: grid;
  /* Content grid: 3 equal columns, inner-space gutters. Text takes 1, pictures take 2.
     (The sidebar beside it is as wide as the menu needs.) Same grid as the About page. */
  grid-template-columns: repeat(3, 1fr);
  column-gap: var(--inner);
  align-content: start;   /* the page stretches to screen height; keep the rows at the top, not spread out */
  padding: var(--title-top) var(--margin) 0 var(--inner);   /* title capitals run from the top to the bottom of the ศ logo */
}
.detail-title {
  grid-column: 1 / -1;
  font-size: var(--t1);
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: calc(2.62 * var(--logo-h) - 0.89 * var(--t1) - 0.655 * var(--t3));   /* 0.89 = 1 - baseline 0.84 + cap 0.73 (Sora Light) */   /* the work-type line sits level with the menu arrow (its middle on the arrow's middle) */
}
.gallery {
  grid-column: 2 / -1;
  grid-row: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5vw;   /* space between pictures */
}
/* Images keep their own shape (no cropping). Pictures in a row share one height;
   each one's width follows its aspect ratio (--ar, set in site.js). */
.gallery img, .gallery video { display: block; width: 100%; height: auto; }
/* Clips: no sliver of black around the picture while one loads or starts (fill the box exactly, page-colored behind) */
.gallery video { object-fit: cover; background: var(--paper); }
/* Tall (portrait) hero pictures stop at screen height instead of growing huge */
.gallery .hero-img { grid-column: 1 / -1; max-height: 90vh; object-fit: contain; object-position: left top; }
/* The live paper puppet */
.gallery canvas.puppet { display: block; width: 100%; aspect-ratio: 4097 / 3280; }
.gallery canvas.puppet { margin-top: -10.3%; }   /* the stage has empty room above him: pulled up so his back is level with the type line (Paper Marionette) */
.gallery canvas.anim { display: block; width: 100%; height: auto; grid-column: 1 / -1; }   /* live animations (site.js { anim }) fill the column */   /* the puppet stage: he fills the column width */
.gallery-row { grid-column: 1 / -1; display: flex; gap: 0.5vw; align-items: flex-start; }
.gallery-row > * { flex: var(--ar, 1) 1 0; min-width: 0; }
/* A picture alone in a row behaves like the top picture: full column width (both edges line up
   with the rows above), and only a tall one stops at screen height, sitting on the left edge */
.gallery-row > img:only-child { flex: 1 1 auto; width: 100%; height: auto; max-height: 90vh; object-fit: contain; object-position: left top; }
/* A picture with a specimen card stuck on it */
.g-item { position: relative; margin: 0; }
.g-item.hero-img { justify-self: start; max-height: none; }
.g-item.hero-img > img:first-child { width: auto; max-width: 100%; max-height: 90vh; }
.gallery-row > .g-item:only-child { flex: 1 1 auto; }
.gallery-row > .g-item:only-child > img:first-child { width: 100%; height: auto; max-height: 90vh; object-fit: contain; object-position: left top; }
.gallery { position: relative; }
/* A clip with sound: starts silent, with a round speaker button in its corner */
.g-item.sound-item.hero-img { justify-self: stretch; }
.sound-item video { width: 100%; }
.sound-btn {
  position: absolute; left: 0.8em; bottom: 0.8em; z-index: 5;   /* above the floating drawings */
  display: grid; place-items: center;
  width: 2.4em; height: 2.4em; padding: 0;   /* a round speaker button */
  border: none; border-radius: 999px;
  background: rgba(30, 30, 30, 0.6); color: var(--white);
  font-size: var(--t3);
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.sound-btn:hover, .sound-btn[aria-pressed="true"] { background: var(--ink); }   /* dark grey (was blue), so the blue cursor shows on it */
/* After the page loads, cards.js lifts each card onto the gallery so it can be pushed around */
.gallery .spec-label.is-loose { left: 0; top: 0; will-change: translate; }
.gallery .spec-label {
  position: absolute;
  left: var(--lx);
  top: var(--ly);
  width: 12vw;
  height: auto;
  transform: rotate(var(--lr, 0deg));
  box-shadow: 0 0.15vw 0.5vw rgba(0, 0, 0, 0.16);
  user-select: none; -webkit-user-drag: none;
  z-index: 2;
  transition: scale 0.45s cubic-bezier(.3,1.6,.5,1);   /* grows out of the middle on arrival (cards.js) */
}
/* Left column: the text at the top and the credit at the bottom. The column is as tall as the
   pictures, or as the text if that's longer, so the credit never runs into the text. */
.detail-side {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
}
.detail-text {
  /* stays in view while the pictures scroll past */
  position: sticky;
  top: var(--margin);
  align-self: start;
  font-size: var(--t3);
  line-height: 1.4;
}
.detail-text p + p { margin-top: 1.25em; }
/* no lonely last word on a line: the browser evens out the last lines of every paragraph */
.detail-text p, .detail-credit, .about-intro p { text-wrap: pretty; }
/* Where the work comes from (university / personal / with whom), set apart at the bottom of the
   text column: level with the bottom of the pictures, and kept at the bottom of the screen
   while a long set of pictures scrolls past */
/* the text's own space, filling the column above the credit: the text stays in view inside it
   while the pictures scroll, and stops before it reaches the credit */
.detail-main { flex: 1; }
.detail-credit {
  padding-top: 1.25em;       /* at least a line's gap under the text; sits at the bottom of the column */
  font-size: var(--t4);   /* small print: a step smaller than the description, in grey */
  line-height: 1.35;
  color: var(--meta);
}
.detail-credit > span { display: block; }
/* When the text and credit both fit on screen (site.js adds .credit-float), the credit waits at the
   bottom of the screen so it's seen straight away, then settles level with the last picture */
.detail-side.credit-float .detail-credit { position: sticky; bottom: var(--margin); }
.credit-group { margin-top: 0.7em; }
.credit-kind + .credit-group, .credit-group + .credit-group { margin-top: 0.7em; }
.detail-credit > .credit-group:first-child { margin-top: 0; }
.credit-label { display: block; }   /* "In collaboration with", "Story and book design": plain, in grey */
.credit-name { display: block; color: var(--ink); }   /* the names in the text colour, so they read as the information */
/* "Poster Design (2026)" */
.detail-text .detail-type {
  font-size: var(--t3);   /* what the work is: as important as the description, so the same size */
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0.02em;
  margin-top: -0.23em;     /* cap height level with the top of the first picture */
}
.detail-text .detail-type + p, .detail-text .detail-size + p { margin-top: max(14px, 1.55vw); }
/* the piece's size, small and grey right under the type line (only where there is one) */
.detail-text .detail-type + .detail-size { margin-top: 0.3em; font-size: var(--t4); color: var(--meta); }

/* ---------- About ---------- */
.about {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  column-gap: var(--inner);
  padding: var(--title-top) var(--margin) 5vw var(--inner);   /* same top as project pages: "Hi!" sits level with a project title */
}
/* The last column holds the photo and Education under it, beside the intro and then Work Experiences and Skills,
   so those two rise up under the intro instead of waiting below the photo */
.about-side { grid-column: 3; grid-row: 1 / span 2; }
.about-work { grid-column: 1; grid-row: 2; }
.about-skills { grid-column: 2; grid-row: 2; }
.about-photo-wrap { position: relative; width: fit-content; }
.about-photo { display: block; width: 100%; height: auto; }   /* whole picture, no crop */
/* the pin: its head (82.4 of the picture's 183 px) is 8% of the photo's width, centred on the top white border */
.about-pin { position: absolute; width: 18%; left: 41%; top: -1.1%; pointer-events: none; }   /* head centre 4.6% down (9% of the width = 5.7% of the height above that) */
.about-intro { grid-column: 1 / 3; grid-row: 1; }   /* name, text and contact on the left */
.about-intro h1 { font-size: var(--t-sub); line-height: 1; margin-bottom: 1.3vw;
  margin-top: calc(0.11 * (var(--t1) - var(--t-sub))); }   /* smaller than a project title, its capitals still start level with the top of the ศ */
.about-intro p, .about-col p { font-size: var(--t3); line-height: 1.6; }
.about-intro p + p:not(.about-cv) { margin-top: 0.9em; }   /* the intro's second paragraph */
@media (max-width: 760px) { br.wide-only { display: none; } }   /* a line break kept to computers only */
/* the intro text runs across both columns next to the photo */
.about-intro p { max-width: none; }
@media (max-width: 760px) { .about-intro p { max-width: none; } }
.about-col p + p { margin-top: 0.9em; }   /* space between education entries */
.about-col { margin-top: 5.6vw; }
.about-col h2 {
  font-family: var(--body);
  font-weight: 400;
  font-size: var(--t2);
  letter-spacing: 0.02em;
  margin-bottom: 0.8vw;
}

/* ---------- Contact footer ---------- */
.contact {
  position: relative;
  z-index: 40;
  background: var(--ink);
  color: var(--paper);
  padding: 2.4vw var(--margin) 3.6vw var(--margin);
  font-size: var(--t2);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;   /* light text on dark: stop macOS drawing it thicker */
  -moz-osx-font-smoothing: grayscale;
}
.contact h2 {
  color: var(--lime);
  font-size: var(--t-sub);
  line-height: 1;
  margin-bottom: 2.6vw;
}
.contact-grid {
  /* On the same lines as the page grid: the details start where the 2nd content column starts
     (WORK EXPERIENCES on About), Download CV where the 3rd does (SKILLS & TOOLS). The form fills
     the space to the left. --c = one content column. */
  --c: calc((100% + var(--margin) - var(--side) - 3 * var(--inner)) / 3);
  display: grid;
  grid-template-columns: calc(var(--side) + var(--inner) - var(--margin) + var(--c)) var(--c) var(--c);
  column-gap: var(--inner);
  align-items: start;
}
.contact-form { display: flex; flex-direction: column; gap: 1.5vw; width: 78%; grid-row: 1 / span 2; }   /* shorter lines, with breathing room before the details */
.contact-form label { display: flex; align-items: baseline; gap: 0.6em; }
.contact-form input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  border-bottom: 0.18em dotted var(--paper);
  color: var(--paper);
  font: inherit;
  padding: 0 0.1em 0.1em;
  outline: none;
}
.contact-form input:focus { border-bottom-color: var(--lime); }
.send {
  align-self: flex-end;
  padding: 0;
  line-height: inherit;
  background: none;
  border: none;
  color: var(--lime);
  font: inherit;
  cursor: pointer;
  transition: color 0.2s ease;
}
.send:hover { color: var(--blue); }
.contact-info { line-height: 1.25; }
.contact-info .name { color: var(--lime); margin-bottom: 0.5em; }
.contact-info a:hover, .cv:hover { color: var(--blue); }
.cv { color: var(--lime); transition: color 0.2s ease; grid-column: 2; justify-self: start; align-self: end; margin-top: 1.5em; }   /* under the contact details, on the same line as send */

/* ---------- Small screens ---------- */
/* Paper: plain light grey (the paper scan, assets/texture/paper.jpg, is kept but not used) */
body, .hero, .layout.on-paper { background: var(--paper); }
/* Menu fabric: the scan of green canvas supplied for the menu (assets/texture/menu-fabric.jpg),
   filling the sidebar top to bottom (the stitched hem at the bottom is cropped off). The light
   in the photo was evened out so the whole strip is the same green as its top. */
.sidebar { background: var(--lime); }   /* fabric texture off for now: url("assets/texture/menu-fabric.jpg") center bottom / cover no-repeat */

@media (max-width: 760px) {
  :root { --side: 100%; --t1: 25px; --t-sub: 22px; --t2: 15px; --t3: 14px; --t4: 12px; }
  .tag { font-size: 13px; }   /* tags stay compact so they fit two rows */
  .logo img, .logo svg { width: 68vw; }   /* centred with room on both sides */
  .layout { grid-template-columns: 1fr; }
  /* Phones: the bar scrolls away with the page and is always tall enough for the tags,
     so opening PROJECTS never moves anything; the menu words stay in one line */
  .sidebar { position: relative; height: 128px; padding-bottom: 0; }
  .side-nav { padding: 16px; flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 20px; font-size: 15px; }
  .side-logo { margin-bottom: 0; }
  .side-nav > .nav-link, .projects-row > .nav-link { align-self: center; }   /* ABOUT and PROJECTS centred on the ศ logo */
  .side-contact { position: absolute; left: auto; right: 16px; top: 19px; bottom: auto; font-size: 15px; line-height: 1.2; }   /* level with ABOUT / PROJECTS */
  .step-row { padding: 32px 16px 16px; font-size: 12px; }
  .projects-row { width: auto; position: static; }
  /* Tags sit on their own line under the menu and drop in from above one after another,
     with a small bounce */
  .tags { position: absolute; left: 16px; right: 16px; top: 56px; width: auto; height: auto; display: flex; flex-wrap: wrap; gap: 10px; padding: 0; }
  .tags li {
    position: static; translate: none;
    transform: translateY(-26px) scale(0.8); opacity: 0;   /* waiting just above, out of sight */
    transition: transform 0.55s cubic-bezier(.34,1.7,.5,1), opacity 0.2s ease;   /* drops in with a small jelly bounce */
    transition-delay: calc(var(--i) * 60ms);
  }
  .projects-row.is-open .tags li { transform: none; opacity: 1; }
  .tag { padding: 0.2em 0.45em; margin-right: 0; }
  .stage { height: auto; min-height: 0; padding: 16px 16px 48px; display: flex; flex-wrap: wrap; gap: 28px; justify-content: center; }
  .pic { position: relative; left: auto; top: auto; width: 42%; }
  .scatter, .pile { height: auto !important; min-height: 0; padding: 32px 16px 48px; display: flex; flex-wrap: wrap; gap: 28px; justify-content: center; }
  .pile .pic { visibility: visible !important; width: 28%; }
  .pile .pic.is-out { display: none; }
  .pile .dot { width: 10%; align-self: center; }   /* don't stretch to the row height: stays a circle */
  .pile.is-filtered .pic:not(.dot) { width: 28%; }
  .pile.is-filtered .dot { width: 10%; }
  /* Projects page: two columns, the right one starting lower so they interleave; pictures sit
     straight so every name is the same distance under its picture (pile.js sorts them in) */
  .pile.in-cols { display: flex; flex-wrap: nowrap; align-items: flex-start; gap: 20px; }
  .pile-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 36px; }
  .pile-col + .pile-col { padding-top: 72px; }
  .pile .pile-col .pic, .pile.is-filtered .pile-col .pic:not(.dot) { width: min(100%, calc(var(--w) * 7.5)); }
  .pile .pic { --r: 0deg !important; }
  .pile .caption { position: static; opacity: 1; transform: none; margin: 0.6em 0 0; width: auto; white-space: normal; text-align: center; }   /* long names wrap under their own picture */
  .selected-title { position: static; transform: none; width: 100%; text-align: left; order: -1; font-size: 30px; line-height: 1; letter-spacing: -0.02em; }   /* same place and size as the project title on project pages */
  .spinnable.is-empty { display: none; }
  .top-link { right: 16px; top: 16px; }
  .detail, .about { grid-template-columns: 1fr; padding: 16px 16px 48px; }   /* top gap = the menu's own 16px margin */
  .detail-text, .about-intro { grid-column: 1; grid-row: auto; margin-top: 24px; }
  .detail-side { grid-column: 1; grid-row: auto; order: -1; margin: 0 0 24px; }
  .detail-text { position: static; margin: 0; }
  .detail-credit { position: static; margin: 0; padding-top: 16px; }   /* phones: right under the text */
  /* homepage on phones: the projects part is always at least a screen tall, so it can scroll right up
     under the logo even when a category has only a few pieces (no logo peeking in above) */
  .hero .logo { touch-action: none; }   /* phones: a finger on the name plays with the letters instead of scrolling */
  body.with-hero .layout { min-height: 100vh; min-height: 100svh; align-content: start; }
  .detail-title { order: -2; margin-bottom: 20px; }
  /* phones: name, type (close under it), the pictures, then the description and credit.
     The text boxes step aside (display: contents) so their lines can sit around the pictures */
  .detail-side, .detail-main, .detail-text { display: contents; }
  .detail-title { order: -4; margin-bottom: 6px; }
  .detail-text .detail-type, .detail-text .detail-size { order: -3; margin: 0; }
  .detail-text .detail-type + .detail-size { margin-top: 0.3em; }
  .gallery { order: -2; margin-top: 20px; }
  .detail-text .detail-type + p, .detail-text .detail-size + p { margin-top: 28px; }   /* the gap under the pictures */
  .gallery { grid-column: 1; grid-row: auto; }
  .gallery .spec-label { width: 30vw; }
  .about-photo-wrap { width: 55%; margin-inline: auto; touch-action: pan-y; }   /* phones: in the middle; a sideways swipe swings it */
  /* phones: one column: photo, intro, education, work, skills */
  .about-side { display: contents; }
  .about-work, .about-skills { grid-column: 1; grid-row: auto; }
  .about-intro { order: 1; } .about-edu { order: 2; } .about-work { order: 3; } .about-skills { order: 4; }   /* phones: Education first, as in the CV */
  .about-col { margin-top: 32px; }
  .contact { padding: 32px 16px; }
  .contact-grid { grid-template-columns: 1fr; gap: 32px; }
  .contact-form { grid-row: auto; width: 100%; }
  .cv { grid-column: auto; margin-top: 0; }
  .contact-form { width: 100%; gap: 18px; }
}

/* Phones (no mouse): nothing grows or darkens on hover, which would stick after a tap;
   tapping gives the same bounce as clicking on a computer (.pop in site.js) */
@media (hover: none) {
  .pic:hover, .pile .pic:hover, .spinnable.is-hot { transform: none; }
  .spinnable.is-hot:not(.is-empty) img { filter: none; }
  .book[data-state="front"] .book-pages:hover .page.right,
  .book[data-state="back"] .book-pages:hover .page.left { filter: none; }
}

/* Phones: the canvas circles float around the projects page behind the pictures and bounce
   softly off the edges (pile.js), squishing a little each time they hit one */
@media (max-width: 760px) {
  .pile.dots-float .dot { position: absolute; left: 0; top: 0; width: 34px; z-index: 0; pointer-events: none; }
  .pile.dots-float .pic:not(.dot) { z-index: 1; }
}
/* A squish when something floating hits an edge (phones and computers) */
.gallery .spec-label.squish-x, .pile .pic.squish-x:not(.dot), .pile .dot.squish-x .paper { animation: dot-squish-x 0.5s ease-out; }
.gallery .spec-label.squish-y, .pile .pic.squish-y:not(.dot), .pile .dot.squish-y .paper { animation: dot-squish-y 0.5s ease-out; }
/* A soft squish, the same on phones and computers */
.gallery .spec-label.squish-x, .pile .pic.squish-x:not(.dot), .pile .dot.squish-x .paper { animation-name: soft-squish-x; }
.gallery .spec-label.squish-y, .pile .pic.squish-y:not(.dot), .pile .dot.squish-y .paper { animation-name: soft-squish-y; }
@keyframes soft-squish-x { 0% { scale: 1; } 30% { scale: 0.93 1.05; } 65% { scale: 1.02 0.99; } 100% { scale: 1; } }
@keyframes soft-squish-y { 0% { scale: 1; } 30% { scale: 1.05 0.93; } 65% { scale: 0.99 1.02; } 100% { scale: 1; } }
@keyframes dot-squish-x { 0% { scale: 1; } 25% { scale: 0.78 1.16; } 55% { scale: 1.08 0.95; } 80% { scale: 0.98 1.02; } 100% { scale: 1; } }
@keyframes dot-squish-y { 0% { scale: 1; } 25% { scale: 1.16 0.78; } 55% { scale: 0.95 1.08; } 80% { scale: 1.02 0.98; } 100% { scale: 1; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .pic, .tags li, .hero, .logo img, .logo svg, .layout .sidebar, .selected-title, .side-contact { transition: none; }
  .pop { animation: none; }
}

/* ---------- Picture book (book.js): flip through the pages ---------- */
/* Tall pages (portrait) get a narrower book, so every book stands the same height as a square one
   (otherwise a small portrait handbook would look much bigger than the square books) */
.book { grid-column: 1 / -1; width: min(100% * min(1, var(--page-ar, 1)), 180vh * var(--page-ar, 1)); }
.book-pages {
  position: relative;
  aspect-ratio: calc(2 * var(--page-ar, 1400 / 1393));   /* two pages side by side; --page-ar (one page's width/height) is set by book.js from the pictures */
  perspective: 3500px;
  cursor: pointer;
  user-select: none;
  /* closed on a cover: slide over so the single page sits on the left edge */
  transition: translate 0.9s cubic-bezier(.45,0,.25,1);
}
.book[data-state="front"] .book-pages { translate: -50% 0; }   /* closed: the single cover sits on the left edge */
.book[data-state="back"]  .book-pages { translate: 0 0; }
.book .page {
  position: absolute; top: 0; width: 50%; height: 100%;
  display: block; object-fit: cover; background: var(--white);
  -webkit-user-drag: none;
}
.book .page.is-blank { visibility: hidden; }
/* "read again": only on the back cover, in the empty right half, near its bottom left corner beside the book */
.book .book-again {
  position: absolute; left: calc(50% + 1.6vw); bottom: calc(1.6vw - 0.22em);   /* letters (not the box) as far up from the bottom as from the spine */
  font: inherit; font-size: var(--t3); line-height: 1; color: var(--blue);
  background: none; border: 0; padding: 0; cursor: pointer;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.book[data-state="back"] .book-again { opacity: 1; pointer-events: auto; transition: opacity 0.4s ease 0.9s; }   /* once the last page has landed */
.book .book-pages { transition: translate 0.9s cubic-bezier(.45,0,.25,1), opacity 0.25s ease; }
.book.is-rewinding .book-pages { opacity: 0; }
.book.no-slide .book-pages { transition: none; }
.book[data-state="back"] .book-pages:has(.book-again:hover) .page.left { filter: none; }   /* pointing at the link doesn't darken the cover */
.book .page.left  { left: 0; }
.book .page.right { left: 50%; }
/* the page that turns */
.book .leaf {
  display: none; position: absolute; top: 0; width: 50%; height: 100%;
  transform-style: preserve-3d; z-index: 2; will-change: transform;
}
.book .leaf.on-right { display: block; left: 50%; transform-origin: left center; }
.book .leaf.on-left  { display: block; left: 0;   transform-origin: right center; }
.book .leaf.is-turning { transition: transform 0.9s cubic-bezier(.45,0,.25,1); }
.book .leaf.on-right.is-turning { transform: rotateY(-180deg); }
.book .leaf.on-left.is-turning  { transform: rotateY(180deg); }
.book .leaf .page { left: 0; width: 100%; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.book .leaf .back { transform: rotateY(180deg); }
/* a soft shadow that sweeps over the turning page, darkest halfway */
.book .leaf .shade {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: linear-gradient(to right, rgba(0,0,0,.18), rgba(0,0,0,0) 60%);
}
.book .leaf.on-left .shade { background: linear-gradient(to left, rgba(0,0,0,.18), rgba(0,0,0,0) 60%); }
.book .leaf.is-turning .shade { animation: book-shade 0.9s ease-in-out; }
@keyframes book-shade { 0%, 100% { opacity: 0; } 50% { opacity: 1; } }

/* ---------- Folded leaflet (fold.js): open it out step by step ----------
   --w (set by fold.js) = the sheet's width. The A3 sheet is --w wide and --w × 420/297 tall; only the part
   that's open takes up room: the middle half (A4) when closed or opened once, more as the strips fold out. */
.fold {
  grid-column: 1 / -1; justify-self: start; position: relative;
  width: var(--w, 100%); height: calc(var(--w, 100vw) * 210 / 297);
  user-select: none;
  transition: height var(--t, 0ms) cubic-bezier(.45,0,.25,1);
}
.fold.moving { perspective: 3500px; }   /* 3D only while something moves (fold.js); still, it would blur the pictures a little */
.fold.tall-75 { height: calc(var(--w) * 315 / 297); }
.fold.tall-100 { height: calc(var(--w) * 420 / 297); }
.fold-stage {
  position: absolute; left: 0; width: 100%; height: calc(var(--w) * 420 / 297); top: calc(var(--w) * -105 / 297);
  transform-style: preserve-3d; cursor: pointer;
  transition: top var(--t, 0ms) cubic-bezier(.45,0,.25,1), translate var(--t, 0ms) cubic-bezier(.45,0,.25,1);
}
.fold.tall-75 .fold-stage, .fold.tall-100 .fold-stage { top: 0; }
.fold.centered .fold-stage { translate: -50% 0; }   /* closed: the A5 sits on the left edge, like the closed book */
.fold-stage > div { position: absolute; transform-style: preserve-3d; }
.fold-face { position: absolute; inset: 0; overflow: hidden; background: #fff; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.fold-face img { position: absolute; display: block; max-width: none; pointer-events: none; -webkit-user-drag: none; transition: filter 0.2s ease; }
/* closed (front or back cover): only the closed leaflet shows, nothing of the inside behind it as it turns over */
.fold.card-on .fold-base, .fold.card-on .fold-flap { visibility: hidden; }
/* the left half only shows once the leaflet is open */
.fold .side-l { visibility: hidden; }
.fold.halves-on .side-l { visibility: visible; }
/* the strips fold up and down */
.fold-flap { transform: translateZ(1px); transition: transform var(--t, 0ms) cubic-bezier(.45,0,.25,1); }
.fold-flap .back { transform: rotateX(180deg); }
.flap-top { transform-origin: 50% 0; }
.flap-bottom { transform-origin: 50% 100%; }
.fold.top-open .flap-top { transform: translateZ(1px) rotateX(180deg); }
.fold.bottom-open .flap-bottom { transform: translateZ(1px) rotateX(-180deg); }
/* the cover opens like a book */
.fold-leaf { display: none; transform-origin: 0 50%; transform: translateZ(2px); transition: transform var(--t, 0ms) cubic-bezier(.45,0,.25,1); }
.fold.leaf-on .fold-leaf { display: block; }
.fold.leaf-open .fold-leaf { transform: translateZ(2px) rotateY(-180deg); }
.fold-leaf .back, .fold-card .back { transform: rotateY(180deg); }
/* the closed leaflet turns over */
.fold-card { display: none; transform: translateZ(3px); transition: transform var(--t, 0ms) cubic-bezier(.45,0,.25,1); }
.fold.card-on .fold-card { display: block; }
.fold.turned .fold-card { transform: translateZ(3px) rotateY(180deg); }
/* Shading only on the paper itself, like the picture book (nothing on the page around it):
   - a shade sweeps over whatever is turning, darkest halfway (book-shade, the book's own keyframes)
   - where a strip is still folded over, a soft shadow falls from its free edge onto the paper under it */
.fold-face::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; z-index: 2; }
.fold-leaf .fold-face::after  { background: linear-gradient(to right,  rgba(0,0,0,.18), rgba(0,0,0,0) 60%); }   /* folds at its left edge */
.fold-leaf .back::after       { background: linear-gradient(to left,   rgba(0,0,0,.18), rgba(0,0,0,0) 60%); }
.flap-top .fold-face::after   { background: linear-gradient(to bottom, rgba(0,0,0,.18), rgba(0,0,0,0) 60%); }   /* folds at its top edge */
.flap-top .back::after        { background: linear-gradient(to top,    rgba(0,0,0,.18), rgba(0,0,0,0) 60%); }
.flap-bottom .fold-face::after{ background: linear-gradient(to top,    rgba(0,0,0,.18), rgba(0,0,0,0) 60%); }   /* folds at its bottom edge */
.flap-bottom .back::after     { background: linear-gradient(to bottom, rgba(0,0,0,.18), rgba(0,0,0,0) 60%); }
.fold-card .fold-face::after  { background: rgba(0,0,0,.14); }   /* turning over: dims a little as it goes edge-on */
.fold.turning-leaf .fold-leaf .fold-face::after,
.fold.turning-top .flap-top .fold-face::after,
.fold.turning-bottom .flap-bottom .fold-face::after,
.fold.turning-card .fold-card .fold-face::after { animation: book-shade var(--t) ease-in-out; }
/* the strips' free edges, while folded: where they meet in the middle, a thin grey line;
   with only the top strip open, the bottom one's edge shades the paper just above it */
.fold-face::before { content: ""; position: absolute; left: 0; right: 0; pointer-events: none; z-index: 1; }
.flap-bottom .fold-face:not(.back)::before { top: 0; height: 1px; background: rgba(0,0,0,.2); }   /* where the two strips meet: one thin grey line */
.base-top .fold-face::before {
  bottom: 0; height: 1.2vw; opacity: 0;
  background: linear-gradient(to top, rgba(0,0,0,.13), rgba(0,0,0,0));
  transition: opacity var(--t, 0ms) ease;
}
.fold.top-open:not(.bottom-open) .base-top .fold-face::before { opacity: 1; }
/* before it's ever opened, the closed leaflet gives the same small springy bounce as the closed book */
.fold:not(.was-opened).card-on:not(.turned) .fold-card .fold-face:not(.back) {
  animation: book-nudge 2.8s cubic-bezier(.3,.7,.4,1) 1s infinite;
}
@media (prefers-reduced-motion: reduce) { .fold .fold-face { animation: none !important; } }
/* closed covers darken on hover, like the book */
.fold.card-on .fold-card:hover img { filter: brightness(0.62); }
@media (hover: none) { .fold.card-on .fold-card:hover img { filter: none; } }

/* Loose kids' drawings (p.floaters): cut-outs, no card edge — pushed around by cards.js */
.gallery .spec-label.kid {
  width: var(--kw); box-shadow: none; background: none;
  filter: drop-shadow(0 0.1vw 0.25vw rgba(0,0,0,.14));
  z-index: 3;
}
/* Mmmm's sketches: only a whisper of a shadow */
.gallery .spec-label.kid[src*="mmmm/sketches"] { filter: drop-shadow(0 0.05vw 0.1vw rgba(0,0,0,.09)); }
/* Phones: cards and drawings float over the project and bounce softly off the edges (cards.js);
   drawings are drawn bigger than their computer size so they read on a small screen */
@media (max-width: 760px) {
  .gallery .spec-label.kid { width: calc(var(--kw) * 2.2); }
  .gallery .spec-label { touch-action: none; cursor: grab; }   /* a finger on one drags it instead of scrolling */
}
.gallery .spec-label.kid:not(.is-loose) { visibility: hidden; }   /* until cards.js places them */
.projects-row.no-slide .tags li { transition: none !important; }   /* tags already out: no slide in */

/* The closed book's cover gives a small springy bounce now and then, so it reads as something to
   click: it dips a little and springs back (never grows past its real size). Stops once opened. */
@keyframes book-nudge {
  0%   { transform: scale(1); }
  7%   { transform: scale(0.955); }
  15%  { transform: scale(1); }
  20%  { transform: scale(0.985); }
  25%  { transform: scale(1); }
  100% { transform: scale(1); }
}
.book[data-state="front"]:not(.was-opened) .page.right {
  animation: book-nudge 2.8s cubic-bezier(.3,.7,.4,1) 1s infinite;
}
/* Closed covers darken on hover, like the pictures in SELECTED WORK */
.book .page { transition: filter 0.2s ease; }
.book[data-state="front"] .book-pages:hover .page.right,
.book[data-state="back"] .book-pages:hover .page.left { filter: brightness(0.62); }
@media (prefers-reduced-motion: reduce) { .book .page.right { animation: none !important; } }

/* ===== Menu, plain version: a white page, the menu split off by one thin line, and the
   categories as a simple list hanging under PROJECTS (no colored block, no boxes).
   Overrides the earlier lime sidebar and post-it tags. ===== */
:root {
  --paper: #ffffff; --line: #e2e2e2;
  /* The page is a 4-column grid: the menu is the first column (with the outer margin),
     project text the second, pictures the last two. Same 30px gutters, 37px margins. */
  --col: calc((100vw - 2 * var(--margin) - 3 * var(--inner)) / 4);
  --side: calc(var(--margin) + var(--col));
}
.sidebar { background: var(--lime); }   /* green menu block; the categories inside are plain text */
.projects-row { width: auto; }
.tags {
  position: static; width: auto; height: auto;
  margin: 0.7em 0 0; padding: 0 0 0 1em;          /* indented under PROJECTS */
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.45em;
}
.tags li {
  position: static; translate: none;
  transform: translateY(-0.4em); opacity: 0; visibility: hidden;   /* waiting just above, hidden */
  transition: transform 0.45s cubic-bezier(.34,1.56,.5,1), opacity 0.25s ease, visibility 0.25s;
  transition-delay: calc(var(--i) * 50ms);
}
.projects-row.is-open .tags li { transform: none; opacity: 1; visibility: visible; }
.tag {
  background: none !important; box-shadow: none;
  color: var(--ink); padding: 0; margin: 0;
  font-size: var(--t2); line-height: 1.2; letter-spacing: 0.02em;
  transition: color 0.2s ease;
}
.tag:hover, .tag.is-current { color: var(--blue); }

@media (max-width: 760px) {
  :root { --side: 100%; }
  /* phones: the categories read as a second, quieter row: smaller and grey, the current one blue */
  .tags { position: absolute; left: 16px; right: 16px; top: 58px; margin: 0; padding: 0; flex-direction: row; flex-wrap: wrap; gap: 6px 16px; }
  .tag { font-size: 13px; color: var(--meta); }
  .tag:hover, .tag.is-current { color: var(--blue); }
}

/* ===== Project pages (computers): the menu can be folded away so the pictures get more room.
   An arrow beside the ศ logo folds it; what's left is a slim green column holding ศ (still the
   way home) and the arrow, turned round, to bring the menu back. The text column keeps its
   width; only the pictures grow. ===== */
.menu-toggle { display: none; }
@media (min-width: 761px) {
  :root { --logo-h: max(24px, 2.22vw); --rail: calc(var(--margin) + var(--logo-h) + var(--inner)); }
  body[data-page="project"] .layout, body[data-page="category"] .layout { transition: grid-template-columns 0.6s cubic-bezier(.6,0,.2,1); }
  body[data-page="project"] .detail { transition: grid-template-columns 0.6s cubic-bezier(.6,0,.2,1); }
  body[data-page="project"] .side-nav > :not(.side-logo), body[data-page="category"] .side-nav > :not(.side-logo),
  body[data-page="project"] .side-contact, body[data-page="category"] .side-contact { transition: opacity 0.3s ease 0.2s, visibility 0.3s 0.2s; }
  body.menu-hidden .layout { grid-template-columns: var(--rail) 1fr; }
  body.menu-hidden .side-nav > :not(.side-logo),
  body.menu-hidden .side-contact { opacity: 0; visibility: hidden; pointer-events: none; transition-delay: 0s; }
  body.menu-hidden .detail { grid-template-columns: var(--col) 1fr 1fr; }
  body.menu-instant .layout, body.menu-instant .detail, body.menu-instant .menu-toggle,
  body.menu-instant .menu-toggle .arrow, body.menu-instant .side-nav > *, body.menu-instant .side-contact { transition: none !important; }

  /* the arrow: level with ศ at the right of the menu; under ศ once the menu is folded */
  .menu-toggle {
    display: grid; place-items: center;
    position: fixed; z-index: 45;
    top: var(--nav-top);
    left: calc(var(--side) - var(--inner) - var(--logo-h));
    width: var(--logo-h); height: var(--logo-h); padding: 0;
    border: none; background: none; color: var(--ink);
    font-size: var(--logo-h); cursor: pointer;
    transition: left 0.6s cubic-bezier(.6,0,.2,1), top 0.6s cubic-bezier(.6,0,.2,1), color 0.2s ease;
  }
  .menu-toggle:hover { color: var(--blue); }
  .menu-toggle .arrow { font-size: 1.15em; transition: rotate 0.6s cubic-bezier(.6,0,.2,1); }
  /* folded: level with the work-type line, the arrow's middle on the middle of its CAPITALS (Figtree: caps 0.70, x-height 0.50, so 0.1 of the text size higher than the middle of the small letters) */
  body.menu-hidden .menu-toggle { left: var(--margin); top: calc(var(--nav-top) + var(--logo-h) + 1em - 0.1 * var(--t3)); }
  body.menu-hidden .menu-toggle .arrow { rotate: 180deg; }
}

/* ===== Projects page (computers): ARRANGE lines the work up in staggered columns with every
   name showing; SCATTER throws it back into the pile. ===== */
.pile-mode { display: none; }
@media (min-width: 761px) {
  body[data-page="category"] .pile-mode {
    display: block; position: fixed; z-index: 45;
    top: var(--nav-top); right: var(--margin);
    padding: 0; border: none; background: none;
    font: inherit; font-size: var(--t4); text-transform: uppercase; letter-spacing: 0.02em;
    color: var(--ink); cursor: pointer; transition: color 0.2s ease;
  }
  body[data-page="category"] .pile-mode:hover { color: var(--blue); }
  .pile.is-tidy { height: auto !important; display: flex; align-items: flex-start; gap: var(--inner); padding: calc(var(--nav-top) + 3em) var(--margin) 4em var(--inner); }
  .pile.is-tidy .pile-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3.5em; }
  .pile.is-tidy .pile-col:nth-child(even) { padding-top: 6em; }     /* every other column starts lower, so they interleave */
  .pile.is-tidy .pic { position: relative; left: auto; top: auto; translate: none !important; visibility: visible !important; --r: 0deg !important; }
  .pile.is-tidy .pic.is-out, .pile.is-tidy .dot { display: none; }
  .pile.is-tidy .caption { position: static; opacity: 1; transform: none; margin: 0.7em 0 0; width: auto; white-space: normal; text-align: center; }
  .pile.is-tidy .pic:hover { transform: scale(1.03); }
  .pile.is-tidy .caption { transition: opacity 0.3s ease; }
  .pile.is-tidy.arriving .caption { opacity: 0; }
}

/* ===== Paper: one muted, grey-leaning cream across the whole page (menu included), with a fine
   grain and a few soft blotches like real paper. The menu has no block of its own any more, only
   a hairline on its edge. Both layers are fixed to the screen, so every surface that shows the
   paper (page, cover, menu) lines up into one sheet. ===== */
:root {
  --paper: #f5f5f3;   /* soft, barely warm off-white (was #f3f2ed cream, which read as vintage) */
  --line: rgba(58, 58, 52, 0.12);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .32 0 0 0 0 .32 0 0 0 0 .32 0.176 0 0 0 -0.055'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");   /* a faint neutral grain; the brown blotches are gone */
}
body, .hero, .layout.on-paper, .sidebar {
  background: var(--grain), var(--paper);
  background-attachment: fixed;
}
/* hairline between menu and page, stopping a margin short of the top and bottom edges */
.sidebar::after {
  content: ""; position: absolute; pointer-events: none;
  right: 0; top: var(--margin); bottom: var(--margin); width: 1px;
  background: var(--line);
}
@media (max-width: 760px) {
  /* phones: the line sits under the menu, inset from both sides */
  .sidebar::after { top: auto; bottom: 0; left: 16px; right: 16px; width: auto; height: 1px; }
}

/* Projects page, SCATTER: tilted corners poking past the bottom edge don't make the page scroll */
@media (min-width: 761px) { .pile:not(.is-tidy) { overflow-y: clip; overflow-x: visible; } }

/* Projects page, ARRANGE with the menu folded: the same 3 columns at the same size, moved to the
   middle; the room the menu gave back is split evenly on both sides */
@media (min-width: 761px) {
  body[data-page="category"] .pile.is-tidy { transition: padding 0.6s cubic-bezier(.6,0,.2,1); }
  body.menu-hidden .pile.is-tidy {
    padding-left: calc(var(--inner) + (var(--side) - var(--rail)) / 2);
    padding-right: calc(var(--margin) + (var(--side) - var(--rail)) / 2);
  }
  body.menu-instant .pile.is-tidy { transition: none; }
}

/* Mmmm is white paper: lift its near-white to real white so it stands off the paper-colored page
   (the filter lives in site.js; colors are left as they are) */
img[src*="mmmm/mmmm-cover"], .gallery canvas.puppet { filter: url(#paper-white); }

/* Thai words: Noto Sans Thai Looped Regular (Google Fonts, linked in each page; before: Thonglor Soi 4 NR from Adobe Fonts).
   Once its Thai letters have arrived (site.js adds .th-ready), it's set one step smaller than the
   English beside it, since it draws a little bigger. Without them Thai stays in the page's own font. */
.th { font-family: "Noto Sans Thai Looped", var(--body); font-weight: 400; }
.th-ready .th { font-size: 0.92em; }

/* ===== About: three steps of text in the lists =====
   heading (bigger) > the place or project name (body size, dark) > year and role (small, grey) */
.about-col h2 { font-size: max(17px, 1.45vw); letter-spacing: 0; margin-bottom: 1.1vw; }
.about-col p.entry > span { display: block; }
.about-col .yr, .about-col .rl { font-size: var(--t4); color: var(--meta); line-height: 1.45; }
.about-col .nm { font-size: var(--t3); color: var(--ink); line-height: 1.4; }
.about-col .yr + .nm { margin-top: 0.15em; }
.about-col .nm + .rl { margin-top: 0.1em; }
.about-col p.entry + p.entry { margin-top: 1.1em; }
@media (max-width: 760px) { .about-col h2 { font-size: 18px; margin-bottom: 10px; } }

/* Click to grow (projects with zoom: true in data.js): two to a row, a clicked one spans the full width */
.gallery.zoom-grid { grid-auto-flow: row dense; }
.gallery.zoom-grid > img.zoomable { cursor: zoom-in; }
.gallery.zoom-grid > img.is-big { grid-column: 1 / -1; cursor: zoom-out; }
::view-transition-group(*) { animation-duration: .45s; animation-timing-function: cubic-bezier(.6,0,.2,1); }

/* Projects, arranged: every column starts at the same top line (no staggering); they end wherever
   their pictures end. Same on phones. */
.pile.is-tidy .pile-col:nth-child(even), .pile.in-cols .pile-col + .pile-col { padding-top: 0; }

/* Project names under the pictures: dark grey, and the same gap below the artwork for every
   picture. --cut (set by site.js) is the empty see-through space under a PNG's artwork, as a share
   of the picture's width, so the name moves up by exactly that much. */
.pile .caption { color: var(--ink); }
.pile.is-tidy .caption { margin-top: calc(0.7em - var(--cut, 0) * 100%); }
@media (max-width: 760px) { .pile.in-cols .caption { margin-top: calc(0.6em - var(--cut, 0) * 100%); } }

/* Contact block: plain dark grey (the grain and blotches are gone) */
.contact { background: var(--ink); }

/* ===== Custom cursor (cursor.js): a blue circle ===== */
html.has-cursor-dot, html.has-cursor-dot * { cursor: none !important; }
.cursor-dot {
  position: fixed; left: 0; top: 0; z-index: 2147483647;
  width: 20px; height: 20px; margin: -10px 0 0 -10px;   /* centred on the mouse point */
  border-radius: 50%;
  background: var(--blue);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, scale 0.15s ease;
}
.cursor-dot.is-on { opacity: 1; }
.cursor-dot.is-link { scale: 1.6; }   /* over something clickable */
.cursor-dot.is-down { scale: 0.75; }
.cursor-dot.is-link.is-down { scale: 1.2; }

/* A link out from a project description (e.g. the article a piece is based on):
   small and grey like the credit lines, blue and underlined on hover */
.detail-text .read-link { font-size: var(--t4); color: inherit; text-decoration: none; transition: color 0.15s ease; }   /* links: the text colour, no line (nothing else on the site is underlined) */
.detail-text .read-link:hover { color: var(--blue); }   /* blue only under the mouse */

/* About: contact details and the CV link sit right under the intro (no contact bar on this page) */
.about-contact { margin-top: 2.2vw; font-size: var(--t3); line-height: 1.6; }
.about-contact { display: grid; grid-template-columns: repeat(2, max-content); column-gap: 3em; row-gap: 0.9em; }
.about-contact p + p { margin-top: 0; }
.about-contact .lbl { display: block; font-size: var(--t4); color: var(--meta); line-height: 1.4; }
.about-contact a { transition: color 0.2s ease; }
.about-contact a:hover { color: var(--blue); }
.about-cv { margin-top: 2.2vw; font-size: var(--t3); }   /* right under the contact details */
/* Download CV: blue, and it gives the closed book's small springy bounce now and then (all the time),
   so it reads as something to click */
.about-cv a { display: inline-block; color: var(--blue);
  animation: book-nudge 2.8s cubic-bezier(.3,.7,.4,1) 1s infinite; }
@media (prefers-reduced-motion: reduce) { .about-cv a { animation: none; } }
@media (max-width: 760px) { .about-cv { margin-top: 20px; } }
.about-col .about-sub { margin-top: 2.6vw; }
@media (max-width: 760px) {
  .about-contact { margin-top: 20px; }
  .about-col .about-sub { margin-top: 28px; }
}

/* ---------- Home: logo and SELECTED WORK on one continuous page ----------
   The logo screen is now part of the page (not a cover on top), so scrolling down simply
   carries on into the work. Overrides the old slide-away cover above. */
body[data-page="home"] .hero {
  position: relative; inset: auto; z-index: auto;
  height: 100vh; height: 100svh;
  transform: none; transition: none;
}
body.hero-on { overflow: visible; }
body:not(.hero-on) .logo img, body:not(.hero-on) .logo svg { transform: none; opacity: 1; }
body.hero-on .layout .sidebar { transform: none; }
.swipe-hint.is-on { pointer-events: auto; cursor: pointer; }

/* Selected Work: the project's year, small and grey just under its name in the middle
   (hung below the name, so the name itself stays dead centre) */
.selected-title .sel-year {
  position: absolute; left: 50%; top: 100%; translate: -50% 0;
  margin-top: 0.55em; white-space: nowrap;
  font-family: var(--body); font-size: var(--t4); letter-spacing: 0.02em; color: var(--meta);
}

/* A small heading inside a project's pictures (e.g. "Other drafts"), like the credit labels */
.gallery-heading { grid-column: 1 / -1; margin-top: 2vw; font-family: var(--body); font-weight: 400; font-size: var(--t3); color: var(--meta); letter-spacing: 0.02em; }

/* The site's one arrow (site.js fillArrows): same line weight and size next to any text */
.arrow { display: inline-block; width: 0.85em; height: 0.85em; vertical-align: -0.08em; line-height: 0; }
.arrow svg { width: 100%; height: 100%; display: block; }
.arrow-left svg { rotate: 180deg; }
.arrow-down svg { rotate: 90deg; }
.arrow-up-right svg { rotate: -45deg; }

/* Project pictures follow three fixed layouts, all measured from the picture area (so folding the
   menu just scales everything together and the layout stays the same):
   1. one landscape or square picture: the full width, never shrunk to fit the screen's height,
      so its left and right edges line up with every other row;
   2. two or more side by side: together the full width, all the same height;
   3. one portrait picture (site.js marks it .is-tall): 75% of the width, left aligned, every one
      exactly the same width whatever its shape (a longer one is simply taller). */
.gallery { --tall-w: 75%; }
.gallery > img.hero-img:not(.is-tall), .gallery-row > img:only-child:not(.is-tall) { width: 100%; height: auto; max-height: none; object-fit: fill; }
.gallery > .g-item.hero-img:not(:has(> img.is-tall)) { justify-self: stretch; }
.g-item.hero-img > img:first-child:not(.is-tall), .gallery-row > .g-item:only-child > img:first-child:not(.is-tall) { width: 100%; height: auto; max-height: none; max-width: none; object-fit: fill; }
.gallery > img.hero-img.is-tall, .gallery-row > img.is-tall:only-child {
  width: var(--tall-w); flex: 0 0 var(--tall-w); justify-self: start; height: auto; max-height: none; object-fit: fill;
}
.gallery > .g-item.hero-img:has(> img.is-tall), .gallery-row > .g-item:only-child:has(> img.is-tall) { width: var(--tall-w); flex: 0 0 var(--tall-w); justify-self: start; }
.g-item > img.is-tall:first-child { width: 100%; height: auto; max-height: none; max-width: none; object-fit: fill; }
@media (max-width: 760px) {
  .gallery { --tall-w: 100%; }
}
.about-intro { align-self: start; }
/* About, top: a bigger photo, and the name, text and CV link sit lower beside it, ending level with the
   photo's bottom (so the name isn't pressed against the top of the page) */
@media (min-width: 761px) {
  /* site.js lines both up with the ABOUT word in the menu: the photo's top, and the top of the name's small letters */
  .about-photo { height: 26vw; width: auto; }
  .about-intro { align-self: start; display: flex; flex-direction: column; justify-content: flex-start; }

  .about-intro h1 { font-size: max(24px, 2.2vw); margin-top: 0; margin-bottom: 1.4vw; }
  .about-cv { margin-top: 2.2vw; }
}
/* the photo swings from its pin when the mouse brushes across it (site.js) */
.about-photo-wrap { transform-origin: 50% 4.6%; will-change: transform; }   /* turns on the pin */

/* ===== Title grid =====
   Titles (project names, "Hi! I'm Siranarin") are sized so their capital letters are exactly as tall
   as the ศ logo, and sit level with it: cap top = logo top, baseline = logo bottom.
   The text under a title starts --text-gap below that baseline, which is exactly where ABOUT sits
   in the menu (ABOUT is nudged down from the logo by the same gap).
   0.11 / 0.15 / 0.305 are font measurements (Sora Light at line-height 1, Barlow at 1.2).
   Changing the heading font means measuring these again (cap height, ascent, descent). */
:root {
  --logo-h: max(23.8px, 2.219vw);                                 /* the ศ logo's height (2.05vw wide) */
  --title-top: calc(var(--nav-top) - 0.11 * var(--t1));   /* 0.11 = space above the capitals (Sora Light; Space Grotesk 0.146, Metallophile 0.245) */
  --text-gap: 2.6vw;
}
.side-nav > .side-logo + .nav-link { margin-top: calc(var(--text-gap) - 0.305 * var(--nav-size) - 1.975vw - 0.236vw); }   /* -0.236vw: measured fine-tune so ABOUT and the text line up exactly */
@media (max-width: 760px) { .side-nav > .side-logo + .nav-link { margin-top: 0; } }

/* Home: the ศ flying from the big name down to the menu (hero.js). While it flies, the real ศ in
   the big name (its second drawn piece, after ิ) and the small ศ in the menu are hidden. */
.so-fly { position: fixed; z-index: 50; display: none; height: auto; pointer-events: none; overflow: visible; }
body.so-flying .so-fly { display: block; }
body.so-flying .hero .logo svg > g.so,   /* the ศ itself (logo.js marks it), not ิ above it */
body.so-flying .side-logo svg { opacity: 0; }
/* Phones: one swipe from the name lands right on Selected Work (and one swipe up from there goes back
   to the name), like the stops on a computer; the long list of work below scrolls freely. */
@media (max-width: 760px) {
  html:has(body[data-page="home"]) { scroll-snap-type: y mandatory; }
  body[data-page="home"] .hero { scroll-snap-align: start; }
  body[data-page="home"] .layout { scroll-snap-align: start; scroll-snap-stop: always; }
  body[data-page="home"] .contact { scroll-snap-align: end; }
}

/* Contact block layout: on the page's 4 equal columns (menu + 3), one column each. The email
   form sits in the first column, under the menu; name, details and Download CV in the second.
   CONTACT stays at the left edge above them. */
@media (min-width: 761px) {
  .contact-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    column-gap: var(--inner);
  }
  .contact-form { grid-column: 1 / 3; grid-row: 1 / span 2; width: 78%; }   /* the form gets two columns, so the lines are long and easy to write on */
  .contact-info { grid-column: 3 / 5; grid-row: 1; }
  .contact .cv { grid-column: auto; grid-row: auto; }
}
/* Contact block, calmer: more room, the same text sizes as About, only light grey, white and blue
   (no green). The details are laid out like About's: small grey label over each one, two across. */
.contact { padding: var(--margin) var(--margin) calc(var(--margin) * 2.2); font-size: var(--t3); }   /* the same space above as at the sides, more below so it doesn't end tight against the edge */
.contact h2 { color: var(--paper); margin-bottom: 2.4vw; }
.contact-info { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--inner); row-gap: 1.2em; line-height: 1.6; }   /* spread over the last two columns */
.contact-info p + p { margin-top: 0; }
.contact-info .lbl { display: block; font-size: var(--t4); color: #a8a7a1; line-height: 1.4; }
.contact-info a { transition: color 0.2s ease; }
.contact-form { gap: 1.8vw; }
.contact-form label { color: var(--paper); }   /* Email / Subject / Letter in white, so the form stands out */
.contact-form input { border-bottom: 1px dotted var(--paper); color: var(--paper); }
.contact-form input:focus { border-bottom-color: var(--blue); }
.send { color: var(--paper); }
.send:hover { color: var(--blue); }
.contact .cv { color: var(--blue); margin-top: 0; align-self: auto; justify-self: auto; }
.contact .cv:hover { color: var(--paper); }
@media (max-width: 760px) {
  .contact { padding: 40px 16px 48px; }
  .contact h2 { margin-bottom: 28px; }
  .contact-form { gap: 20px; }
  .contact-info { grid-template-columns: 1fr 1fr; column-gap: 16px; }
  .cv { margin-top: 0; }
}


/* Projects page, scattered: pictures sit a little smaller, and the one under the mouse grows to
   full size and comes to the front, so it's clear which one you're on. ARRANGE keeps the normal size. */
@media (hover: hover) {
  .pile:not(.is-tidy) .pic:not(.dot) { transform: scale(0.78); }
  .pile:not(.is-tidy) .pic:not(.dot):hover { transform: scale(1.6); z-index: 20; }
  /* one category: the pictures are already 1.3× bigger, so the hover grows less (ends the same size as on all projects) */
  .pile.is-filtered:not(.is-tidy) .pic:not(.dot):hover { transform: scale(1.23); }
  /* the one you're on also turns straight, so it reads clearly */
  .pile:not(.is-tidy) .pic:not(.dot) .spin { transition: transform 0.35s cubic-bezier(.3,1.4,.5,1); }
  .pile:not(.is-tidy) .pic:not(.dot):hover .spin { transform: none; }
}

/* Menu: the categories under PROJECTS only take up room while they're out, so ARCHIVE sits the
   same distance under PROJECTS as PROJECTS is under ABOUT, and slides down when the list opens */
@media (min-width: 761px) {
  .projects-row .tags { max-height: 0; margin-top: 0; overflow: hidden; transition: max-height 0.45s cubic-bezier(.3,1.2,.5,1), margin-top 0.45s cubic-bezier(.3,1.2,.5,1); }
  .projects-row.is-open .tags { max-height: 12em; margin-top: 0.7em; overflow: visible; }
  .projects-row.no-slide .tags { transition: none; }
}

/* The category list under PROJECTS: each one drops in with a soft spring, one after another;
   closing tucks them away quickly, all together */
@media (min-width: 761px) {
  .tags li {
    transform: translateY(-0.8em) scale(0.92); opacity: 0;
    transition: transform 0.6s cubic-bezier(.3,1.7,.45,1), opacity 0.3s ease, visibility 0.3s;
    transition-delay: calc(80ms + var(--i) * 60ms);
  }
  .projects-row.is-open .tags li { transform: none; opacity: 1; }
  .projects-row:not(.is-open) .tags li { transition-duration: 0.2s; transition-delay: 0s; }
  .projects-row .tags { transition: max-height 0.5s cubic-bezier(.3,1.15,.45,1), margin-top 0.5s cubic-bezier(.3,1.15,.45,1); }
  .projects-row:not(.is-open) .tags { transition-duration: 0.25s; }
}

/* Title grid, take 2 (menu folded on project pages, which is how they open):
   the left column is ศ (1 step = the logo's height), a gap (1 step), the arrow (1 step).
   - Title capitals: 1.5 steps tall, starting level with the top of ศ.
   - The work-type line ("Silkscreen Print"): its capitals centred on the arrow (2.5 steps down).
   With the menu open the text no longer lines up with ABOUT; that's accepted. */


/* Projects page, ARRANGE: one grid of rows (pile.js), 3 across. Every row starts on one line and
   each piece sits in the middle of its row, so the gaps stay even all the way down the page. */
@media (min-width: 761px) {
  .pile.is-tidy .pile-grid {
    flex: 1 1 auto; min-width: 0;
    display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
    column-gap: var(--inner); row-gap: 3.5em;
    align-items: center; justify-items: center;
  }
}

/* ===== Test homepage (home-test.html, body.home2) =====
   Selected Work fills the whole screen (no menu bar): the pile, with PROJECTS / ABOUT / CONTACT as boxes
   lying in it; the small ศ top left (back up to the name) and a small "Selected Work" where page titles
   start on other pages (the second column). */
.home2 .home2-layout { grid-template-columns: 1fr; }
.home2-label { font-size: var(--t3); line-height: 1.2; letter-spacing: 0; color: var(--ink); transition: opacity 0.6s ease 0.5s; }
body.home2.hero-on .home2-label { opacity: 0; transition-delay: 0s; }
/* the menu boxes: a thin dark frame round a word, so they read as buttons among the pictures */
.pile .menu-box .spin {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 2.6; border: 1.5px solid var(--ink); background: var(--paper);
  font-size: calc(var(--t2) * 1.25); letter-spacing: 0.04em; color: var(--ink);
  transition: color 0.2s ease, border-color 0.2s ease;
}
.pile .menu-box:hover .spin { color: var(--blue); border-color: var(--blue); }
@media (min-width: 761px) {
  .home2 .home2-stage { height: 100vh; height: 100svh; }
  .home2 .home2-logo { position: absolute; left: var(--margin); top: var(--nav-top); z-index: 6; }
  /* second column of the 4-column page grid, level with the small ศ */
  .home2-label { position: absolute; z-index: 6; top: var(--nav-top);
    left: calc(var(--margin) + (100vw - 2 * var(--margin) - 3 * var(--inner)) / 4 + var(--inner)); }
  .home2 .pile { position: absolute; inset: calc(var(--margin) + 3vw) var(--margin) var(--margin); height: auto; }
}
@media (max-width: 760px) {
  .home2 .home2-stage { display: flex; flex-direction: column; padding: 0 0 48px; gap: 0; }
  .home2 .home2-logo { display: none; }
  .home2-label { order: -1; padding: 20px 16px 0; font-size: 30px; }
  .pile .menu-box .spin { font-size: 16px; }
}

/* ===== Homepage: the logo, then the Projects page (index.html, body.with-hero) =====
   The logo screen is part of the page, like the old homepage; the menu buttons that sit fixed on the
   Projects page (ARRANGE, the fold arrow) stay out of the way until you're down at the work. */
body.with-hero .hero {
  position: relative; inset: auto; z-index: auto;
  height: 100vh; height: 100svh;
  transform: none; transition: none;
}
body.with-hero .pile-mode, body.with-hero .menu-toggle { transition: opacity 0.4s ease 0.3s, color 0.2s ease; }
body.with-hero.hero-on .pile-mode, body.with-hero.hero-on .menu-toggle { opacity: 0; pointer-events: none; transition-delay: 0s; }
/* Phones: one swipe down from the logo glides all the way to the Projects and stops there (mandatory snap,
   and the stop can't be skipped); the long list below then scrolls freely. One swipe up from the top of
   Projects goes back to the logo. */
@media (max-width: 760px) {
  html:has(body.with-hero) { scroll-snap-type: y mandatory; }
  body.with-hero .hero { scroll-snap-align: start; scroll-snap-stop: always; }
  body.with-hero .layout { scroll-snap-align: start; scroll-snap-stop: always; }
  body.with-hero .contact { scroll-snap-align: end; }
}

/* ===== Projects pile, ARRANGE: square windows onto the work =====
   Scattered, each project is its cutout cover (.spin). Arranged, the cover makes way for a square
   window (.inside) showing the work itself, all the same size; with the mouse on it the work's film
   plays or its pictures step on (site.js). Phones keep the covers. */
.pile .pic .inside { display: none; }
@media (min-width: 761px) {
  .pile.is-tidy .pic:not(.dot) { width: 100% !important; }
  .pile.is-tidy .pic:not(.dot) .spin { display: none; }
  .pile.is-tidy .pic:not(.dot) .inside { display: block; position: relative; aspect-ratio: 1; overflow: hidden; background: #e4e3df; }
  .pile.is-tidy .inside img, .pile.is-tidy .inside video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
  /* hoverAnim (Silom): the logo animation, whole, on its own dark ground, over the picture */
  .pile.is-tidy .inside .inside-anim { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #212121; display: block; }
  .pile.is-tidy .caption { margin-top: 0.7em; }   /* squares have no see-through space under them */
  .pile.is-tidy .pile-grid { align-items: start; }
}

/* Ordinals in titles (60th): small letters raised to the top of the figures. Shrunk to half size they
   would look much thinner than the title, so (like a typeset superior) they're set a weight heavier:
   Sora Medium in titles (only these letters are loaded), so their lines match the title's Light. */
.ord { font-size: 0.5em; vertical-align: 0.62em; line-height: 0; margin-left: 0.03em; letter-spacing: 0.02em; }
.detail-title .ord { font-family: "Sora", sans-serif; font-weight: 500; }
/* in the small names under the pictures (Figtree): a weight heavier too, and a little bigger, so it stays readable */
.caption .ord { font-weight: 600; font-size: 0.62em; vertical-align: 0.55em; }
/* in the project text (Figtree): the same as the names, so the small th looks as heavy as the words around it */
.detail-text .ord { font-weight: 600; font-size: 0.62em; vertical-align: 0.55em; }

/* About, Tools: small grey level label (like the years), its tools right under it */
.about-col p.lvl { font-size: var(--t4); color: var(--meta); line-height: 1.45; }
.about-col p.lvl + p.lvl-list { margin-top: 0.15em; }
.about-col p.lvl-list + p.lvl { margin-top: 1.1em; }

/* Contact fields: only the dotted line, never a box (iPhone Safari draws its own rounded field otherwise) */
.contact-form input { -webkit-appearance: none; appearance: none; border-radius: 0; border-top: none; border-left: none; border-right: none; box-shadow: none; background: transparent; }

/* Netlify (free plan) adds a "Powered by Netlify" badge to every page from its side, in an iframe
   with this id. Hidden here; if Netlify ever renames it, the badge comes back and this needs the new id. */
#nl-badge-frame { display: none !important; }
