/* =========================================================
   PRIM — personal website
   Fonts: Coolvetica (Adobe Fonts) — Light 300 / Regular 400 / Bold 700
   ========================================================= */

:root {
  --pink: #F092F9;
  --lime: #D6FF2C;
  --ink: #000;
  --bg: #fff;       /* page background (night mode swaps --bg and --ink) */
  --line: #000;     /* every line, frame, dot and folder outline (grey in night mode) */
  --recent: #dcdcdc;   /* fill of the open folder in the category menu */
  --grey: #A6A6A6;
  --ph: #D9D9D9;

  --stroke: .6px;   /* every line on the site (frames, rails, underlines, X in boxes) */
  --dot: 3.5px;     /* every dot at the end of a line */
  --photo-gap: clamp(6px, .2vw, 2px);   /* space between photos on project pages (was 16–30px) */
  --track: .02em;   /* letter spacing for all Coolvetica text (2 = 2%) */
  --track-bold: .015em;   /* bold headings: 5 tighter than --track (20 → 15) */

  --pad: clamp(16px, 2.7vw, 40px);          /* page margin */
  --logo-w: clamp(150px, 16vw, 240px);      /* small logo width */
  --logo-ratio: 0.4323;                     /* logo height / width (incl. frame) */

  --intro-s: 5;  --intro-x: 0px;  --intro-y: 0px;   /* set by JS */

  --ease: cubic-bezier(.7, 0, .2, 1);
  --font: "coolvetica", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-body: "inter-18pt", "Inter 18pt", "Inter", "Helvetica Neue", Arial, sans-serif;   /* body text (descriptions) */
}


* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }   /* lets the script hide things that have a display set */

html, body { min-height: 100%; }

body {
  font-family: var(--font);
  font-weight: 400;
  letter-spacing: var(--track);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ---------- Frame with corner dots (the look from your design) ---------- */
.framed {
  position: relative;
  border: var(--stroke) solid var(--line);
}
.framed::after {
  content: "";
  position: absolute;
  inset: -4px;
  pointer-events: none;
  --dotimg: radial-gradient(circle, var(--line) 0 calc(var(--dot) / 2), transparent calc(var(--dot) / 2 + .5px));
  background:
    var(--dotimg) top left    / 8px 8px no-repeat,
    var(--dotimg) top right   / 8px 8px no-repeat,
    var(--dotimg) bottom left / 8px 8px no-repeat,
    var(--dotimg) bottom right/ 8px 8px no-repeat;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: .28em .45em .2em;
  font-weight: 700;
  font-size: clamp(14px, 1.25vw, 19px);
  letter-spacing: var(--track);
  line-height: 1;
  white-space: nowrap;
  transition: background .2s, color .2s, transform .2s;
}
.btn-lime { background: var(--lime); color: #000; }
.btn-pink { background: var(--pink); color: #000; }
.btn:hover { background: var(--ink); color: var(--bg); }
.btn:active { transform: translateY(1px); }
.btn-big { font-size: clamp(20px, 1.9vw, 28px); padding: .3em .45em .25em; }
.works-btn.btn-big { font-size: clamp(26px, 2.5vw, 36px); }   /* the bouncing WORKs: a bit bigger */

/* =========================================================
   LOGO
   ========================================================= */
.logo {
  position: fixed;
  z-index: 40;
  left: var(--pad);
  top: 28px;
  width: var(--logo-w);
  background: var(--bg);
  color: var(--ink);
  transform-origin: top left;
  transform: translate(0, 0) scale(1);
  transition: transform 1.1s var(--ease), width .7s var(--ease);
}
.logo .logo-mark { display: block; width: 100%; height: auto; }

/* M middle stem: normal logo length = (306 - 189) / 430 of the full stem */
.m-stem {
  transform-box: fill-box;
  transform-origin: 50% 0;
  transform: scaleY(.2721);
}

/* intro state: logo fills the screen */
.is-intro .logo {
  transform: translate(var(--intro-x), var(--intro-y)) scale(var(--intro-s));
}

/* ---- logo frame (thin line + a dot in each corner) ----
   The line is an SVG outline (.logo-frame) and the dots are ::after, instead of a CSS border:
   a border/background line gets rounded by the browser when the logo is scaled up on the intro
   (that caused the stray line). --fs = how much the logo is scaled; dividing by it keeps the
   line and dots as thin as everywhere else on the site even while the logo is huge. */
@property --fs { syntax: "<number>"; inherits: true; initial-value: 1; }
/* --pk scales the space between the letters and the box: 1 = normal (small logo),
   smaller on the intro so the big logo's box hugs the letters (about 10px on screen) */
@property --pk { syntax: "<number>"; inherits: true; initial-value: 1; }
.logo {
  --fs: 1;
  --pk: 1;
  border: 0;
  padding: calc(4px * var(--pk)) calc(6px * var(--pk)) calc(3px * var(--pk));
  transition: transform 1.1s var(--ease), width .7s var(--ease), --fs 1.1s var(--ease), --pk 1.1s var(--ease);
}
.is-intro .logo {
  --fs: var(--intro-s);
  --pk: calc(2.5 / var(--intro-s));
  background: transparent;              /* white background left a grey edge line when scaled up */
  transition: none;                     /* no animating while the page loads; shrinking uses the transitions above */
}

.logo-frame {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  overflow: visible;
  pointer-events: none;
}
.logo-frame rect {
  fill: none;
  stroke: var(--line);
  stroke-width: calc(var(--stroke) / var(--fs));
  stroke-dasharray: 100;
  stroke-dashoffset: 0;
}
.logo::after {
  inset: -4px;
  --d: calc(var(--dot) / var(--fs));
  --dotimg: radial-gradient(circle, var(--line) 0 calc(var(--d) / 2), transparent calc(var(--d) / 2 + .5px / var(--fs)));
}

/* intro timeline (scrolling is locked until it's done – see INTRO_TIME in index.html):
   0.3s  M middle stem starts long (down to the baseline like P, R, I), short hold
   ~1.2s it pulls up into the logo shape (done at 2.4s)
   2.6s  "SCROLL ↓" appears and scrolling is unlocked
   after scrolling: the logo shrinks into the corner, then its frame appears
   (corner dots pop out, then the lines draw between them) */
.is-intro .m-stem { animation: m-stem-up 2.1s var(--ease) .3s both; }
@keyframes m-stem-up {
  0%, 45% { transform: scaleY(1); }
  100%    { transform: scaleY(.2721); }
}
/* no frame on the big intro logo – it only appears once you scroll in and the logo shrinks
   into the corner: dots pop out first, then the line draws between them */
.is-intro .logo::after, .is-intro .logo-frame { opacity: 0; }
.intro-left .logo::after     { animation: frame-dots .5s cubic-bezier(.3,1.6,.5,1) .75s both; }
.intro-left .logo-frame rect { animation: frame-draw .9s var(--ease) 1.1s both; }
@keyframes frame-dots {
  from { opacity: 0; transform: scale(.97); }
  to   { opacity: 1; transform: none; }
}
@keyframes frame-draw {
  from { stroke-dashoffset: 100; }
  to   { stroke-dashoffset: 0; }
}

/* SKIP > on the intro (top right); gone once you're on the home page */
.skip-intro {
  position: fixed;
  z-index: 50;
  top: 28px;
  right: var(--pad);
  padding: .3em .55em .2em;
  font-size: 13px;
  line-height: 1;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s, background .2s, color .2s;
}
.is-intro .skip-intro { opacity: 1; pointer-events: auto; transition-delay: .3s, 0s, 0s; }
.skip-intro:hover { background: var(--ink); color: var(--bg); }

.scroll-hint {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  font-size: 13px;
  letter-spacing: var(--track);
  color: var(--grey);
  opacity: 0;
  transition: opacity .4s;
  pointer-events: none;
  animation: bob 1.6s ease-in-out infinite;
}
.is-intro.intro-ready .scroll-hint { opacity: 1; }   /* only after the box has finished drawing */
@keyframes bob { 50% { transform: translate(-50%, 6px); } }

/* =========================================================
   HOME
   ========================================================= */
.home {
  width: 100%;
  min-height: 100vh;
  padding: 24px var(--pad) var(--pad);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow-x: clip;                 /* the WORKs bloom can spread freely, but never makes the page scroll sideways */
  transition: width .7s var(--ease), opacity .6s .5s;
}
.is-intro .home { opacity: 0; pointer-events: none; transition-delay: 0s; }
.is-intro body { overflow: hidden; }

/* top row: [logo space + update] [hello] [nav] */
.top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 24px;
}

.top-left {
  /* leaves room for the fixed logo above */
  padding-top: calc(var(--logo-w) * var(--logo-ratio) + 50px);
  transition: padding-top .7s var(--ease);
}

/* HELLO WORLD + the LATEST UPDATE line under it (Roboto Mono, grey), spread to the same width */
.hello-wrap { justify-self: center; width: max-content; display: flex; flex-direction: column; }
body[data-panel] .hello-wrap { display: none; }
.update {
  display: flex;
  gap: 1.2em;
  margin-top: .55em;
  color: var(--grey);
  font-family: "Roboto Mono", ui-monospace, Menlo, monospace;
  font-size: clamp(11px, 1vw, 15px);
  letter-spacing: 0;
  line-height: 1.2;
  white-space: nowrap;
}
.update-title { font-weight: 700; letter-spacing: 0 !important; }
.update-time  { font-weight: 300; letter-spacing: 0; }

.hello {
  color: var(--pink);
  font-weight: 700;
  font-size: clamp(40px, 5.3vw, 88px);     /* a touch smaller so it has room on both sides (was 5.8vw / 92px) */
  letter-spacing: var(--track);
  line-height: .9;
  white-space: nowrap;
  margin-top: -2px;
  transition: opacity .4s;
}

.nav {
  justify-self: end;
  display: flex;
  gap: clamp(10px, 1.2vw, 20px);          /* ABOUT ME and CONTACT close together (was 20–70px) */
  padding-top: 6px;
}

/* middle: WORKs button */
.center {
  position: relative;               /* the WORKs button bounces inside this box */
  min-height: 160px;
  margin-block: clamp(16px, 3vh, 32px);
}
.works-btn {
  position: absolute;
  left: 0; top: 0;
  transform: translate(var(--x, 0px), var(--y, 0px));
  transition: background .2s, color .2s;   /* no transform transition, JS moves it */
  will-change: transform;
}
/* keep its bouncing position when pressed (the normal .btn:active nudge would reset it and break the click) */
.works-btn:active { transform: translate(var(--x, 0px), calc(var(--y, 0px) + 1px)); }
.works-btn { cursor: grab; touch-action: none; user-select: none; }   /* WORKs can be dragged around */
.works-btn.is-dragging { cursor: grabbing; transform: translate(var(--x, 0px), var(--y, 0px)) scale(1.06); }

/* bottom: selected works */
.selected { position: relative; display: flex; flex-direction: column; align-items: flex-end; }

.selected-title {
  background: var(--bg);
  font-weight: 700;
  font-size: clamp(14px, 1.2vw, 18px);   /* smaller label (was 22–38px) so it doesn't look like a button */
  letter-spacing: var(--track);
  line-height: 1;
  padding: .3em .45em .22em;
  margin-bottom: 10px;
  cursor: default;
}

/* SELECTED WORKS carousel: 3 visible, slides left (track moved by the script) */
.selected-grid {
  --gap: clamp(10px, 1.3vw, 20px);
  width: calc(100% + 10px);
  margin: -5px;                    /* the padding keeps the corner dots from being cut off */
  padding: 5px;
  overflow: hidden;
}
.selected-grid .track > .sel-item {
  position: relative;
  display: block;
  flex: 0 0 calc((100% - 2 * var(--gap)) / 3);
  aspect-ratio: 1.5 / 1;                /* taller boxes, reaching down to the bottom margin (was 1.6 : 1) */
}
.sel-item > img, .sel-item > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.selected-grid .ph:hover { transform: none; }          /* no grow inside the sliding row */
.ph.sel-item { cursor: default; }

/* hover: project name over the photo */
.sel-name {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .35em;
  padding: 1em;
  background: rgba(0, 0, 0, .85);
  color: #fff;                              /* white text on the dark hover (was pink) */
  font-weight: 700;
  font-size: clamp(13px, 1.2vw, 19px);      /* smaller (was 16–26px) */
  line-height: 1.1;
  text-align: center;
  opacity: 0;
  transition: opacity .3s;
}
.sel-cat { font-weight: 300; font-size: .65em; }   /* subtitle: smaller with the heading */
.sel-item:hover .sel-name, .sel-item:focus-visible .sel-name { opacity: 1; }

/* < > small and light, centred above the middle picture, on the same line as "SELECTED WORKs" */
.sel-nav {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  height: calc(clamp(14px, 1.2vw, 18px) * 1.52);   /* same height as the SELECTED WORKs box */
  display: flex;
  align-items: center;
  gap: 1.2em;
  font-size: clamp(17px, 1.45vw, 23px);    /* bigger so you can see it moves (was 12–15px) */
  font-weight: 400;                         /* thicker stroke than light */
  color: #777;                              /* still softer than black; black on hover */
}
.sel-nav button { padding: 0 .3em; line-height: 1; transition: color .2s; }
.sel-nav button:hover { color: var(--ink); }

/* image placeholder (grey box with an X) — replace with <img> later */
.ph {
  aspect-ratio: 2.1 / 1;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M0 0L100 100M100 0L0 100' stroke='%23000' stroke-width='0.6' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E")
    center / 100% 100% no-repeat,
    var(--ph);
}
/* hover on a grey box / photo: it grows bigger (no colour change, no shadow) */
.ph {
  position: relative;
  cursor: pointer;
  transition: transform .35s var(--ease), background-color .25s;
}
.ph:hover {
  z-index: 5;                         /* sit on top of the boxes next to it */
  transform: scale(1.12);
}

.ph img, .selected-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* =========================================================
   PANEL OPEN (Contact / About) — home squeezes into left half
   ========================================================= */
body[data-panel] { --logo-w: clamp(200px, 24vw, 360px); }
body[data-panel] .home { width: 51%; }
body[data-panel] .top { grid-template-columns: auto 1fr; }
body[data-panel] .hello { display: none; }
body[data-panel] .selected-grid .track > .sel-item { flex-basis: 100%; }   /* panel open: one at a time */

body[data-panel="contact"] .nav [data-open="contact"],
body[data-panel="about"]   .nav [data-open="about"] { display: none; }

.panel {
  position: fixed;
  z-index: 30;
  top: 0; right: 0; bottom: 0;
  width: 49%;
  padding: 28px var(--pad) var(--pad) 28px;
  border-left: var(--stroke) solid var(--line);
  transform: translateX(101%);
  visibility: hidden;
  transition: transform .7s var(--ease), visibility 0s .7s;
}
.panel-contact { background: var(--lime); color: #000; --ink: #000; --line: #000; --bg: #fff; }   /* stays black on lime in night mode too */
/* black About Me page with white text (lines + dots turn white too); scrolls if long */
.panel-about   { background: #000; color: #fff; --ink: #fff; --line: #fff; --bg: #000; overflow-y: auto; }
/* About Me takes 3/4 of the screen; the home page squeezes into the 1/4 on the left */
.panel-about { width: 75%; }
body[data-panel="about"] .home { width: 25%; }
body[data-panel="about"] { --logo-w: clamp(140px, 15vw, 230px); }
body[data-panel="about"] .top { grid-template-columns: 1fr; gap: 14px; }
body[data-panel="about"] .nav { justify-self: start; padding-top: 0; }
body[data-panel="about"] .selected-title { font-size: clamp(15px, 1.5vw, 24px); }   /* fits on one line in the narrow strip */
.panel-about .panel-label { background: #fff; color: #000; }          /* ABOUT ME box: white */
.panel-about .panel-label:hover { background: var(--pink); color: #000; }
/* frame lines + corner dots of the boxes in About Me (ABOUT ME, photo, CV) in lime */
.panel-about .panel-label, .panel-about .about-photo, .panel-about .about-cv { --ink: var(--lime); --line: var(--lime); }
body[data-panel="contact"] .panel-contact,
body[data-panel="about"]   .panel-about { transform: none; visibility: visible; transition: transform .7s var(--ease), visibility 0s; }

/* dots at the two ends of the panel's left line */
.panel::before {
  content: "";
  position: absolute;
  left: calc(var(--stroke) / -2 - 4px); top: 14px; bottom: 14px;
  width: 8px;
  --dotimg: radial-gradient(circle, var(--line) 0 calc(var(--dot) / 2), transparent calc(var(--dot) / 2 + .5px));
  background: var(--dotimg) top / 8px 8px no-repeat, var(--dotimg) bottom / 8px 8px no-repeat;
}

.panel-label {
  font-weight: 700;
  font-size: clamp(16px, 1.45vw, 22px);
  padding: .2em .3em .12em;
  line-height: 1;
  transition: background .2s, color .2s;
}
.panel-label:hover { background: var(--ink); color: var(--bg); }

/* contact form */
.contact-form { margin-top: clamp(36px, 5vh, 56px); display: flex; flex-direction: column; gap: 20px; }

.field {
  display: flex;
  align-items: baseline;
  gap: 14px;
  border-bottom: var(--stroke) solid var(--line);
  padding-bottom: 2px;
  font-size: clamp(14px, 1.15vw, 17px);
}
.field span { font-weight: 400; flex-shrink: 0; }
.field input,
.field textarea {
  flex: 1;
  font: inherit;
  font-weight: 300;
  background: transparent;
  border: 0;
  outline: 0;
  resize: none;
  overflow: hidden;
  color: var(--ink);
}
.field:focus-within { border-bottom-width: calc(var(--stroke) * 2.5); padding-bottom: 1px; }

.send {
  align-self: flex-start;
  margin-top: 14px;
  font-weight: 700;
  font-size: clamp(14px, 1.2vw, 18px);
  padding: .3em .5em .22em;
  background: transparent;
  transition: background .2s, color .2s;
}
.send:hover { background: var(--ink); color: var(--lime); }
.form-note { font-weight: 300; font-size: 14px; }
/* phone / Gmail / Instagram: bottom left corner of the CONTACT page – a small "> label" line, the details big under it */
.contact-info {
  position: absolute; left: 28px; bottom: var(--pad);
  display: flex; flex-direction: column; gap: clamp(12px, 1.8vh, 20px);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; color: #000;
}
.contact-info p { margin: 0; display: flex; flex-direction: column; }
.contact-info .ci-label { font-weight: 300; font-size: clamp(11px, .9vw, 14px); line-height: 1.25; margin-bottom: .15em; }
.contact-info a {
  color: #000 !important; font-weight: 500; font-size: clamp(15px, 1.35vw, 21px); line-height: 1.15; letter-spacing: -.01em;
  text-decoration: none; text-underline-offset: 4px;
}
.contact-info a:hover { text-decoration: underline; }   /* phones never turn them blue (color is forced black) */

/* about */
/* ABOUT ME: name + intro next to the photo, then label | text rows, then the CV button */
.about-body { margin-top: clamp(48px, 9vh, 110px); padding-bottom: 40px; }
.about-intro {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: clamp(20px, 3vw, 50px);
  align-items: start;
}
.about-name {
  font-weight: 400;
  font-size: clamp(26px, 2.6vw, 42px);
  line-height: .95;
  letter-spacing: var(--track);
  margin-bottom: 1em;
}
.about-photo { width: 100%; aspect-ratio: 1.04 / 1; object-fit: cover; display: block; }
.panel-about .ph:hover { transform: none; }

.about-row {
  display: grid;
  grid-template-columns: 1fr 1.25fr;           /* same split as the name / photo above */
  gap: clamp(20px, 3vw, 50px);
  margin-top: clamp(48px, 8vh, 100px);
}
.about-label {
  font-weight: 400;
  font-size: clamp(14px, 1.1vw, 17px);
  letter-spacing: var(--track);
  padding-top: .1em;
}
.about-bio, .about-text {
  font-family: var(--font-body);
  font-weight: 300;
  font-size: clamp(13px, 1.05vw, 16px);
  line-height: 1.35;
  letter-spacing: normal;
}
.about-text p + p { margin-top: .8em; }
.about-text-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5em; }
.about-text-2col p + p { margin-top: 0; }

.about-cv {
  display: block;
  width: fit-content;
  margin: clamp(60px, 12vh, 140px) auto 0;
  padding: .25em .7em .2em;
  background: var(--pink);
  font-weight: 400;
  font-size: clamp(18px, 1.8vw, 30px);   /* CV button size */
  letter-spacing: var(--track);
  color: #000;
  text-decoration: none;
  transition: background .2s, color .2s;
}
.about-cv:hover { background: #fff; color: #000; }

/* =========================================================
   WORKS VIEW
   ========================================================= */
.works {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(30px);
  transition: opacity .45s, transform .6s var(--ease), visibility 0s .6s;
}
body.works-open .works {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .45s, transform .6s var(--ease), visibility 0s;
}

.works-label {
  position: absolute;
  left: var(--pad);
  top: 20px;
  width: calc(25% - var(--pad) - 36px);
  min-width: 120px;
  padding: .28em 0 .2em;
  font-weight: 700;
  font-size: clamp(22px, 2.5vw, 38px);
  letter-spacing: var(--track);
  line-height: 1;
  text-align: center;
  transition: background .2s, color .2s;
}
.works-label:hover { background: var(--ink); color: var(--bg); }

/* HOME at the bottom of the left column (same as on the category pages) */
.works-foot {
  position: absolute;
  left: var(--pad);
  bottom: 20px;
  display: flex; align-items: center; gap: 12px;
}
.works-foot .cat-home { margin-top: 0; }
/* HOME + night-mode button at the bottom of the category menu */
.cat-foot { margin-top: auto; display: flex; align-items: center; gap: 12px; position: relative; z-index: 3; }
.cat-foot .cat-home { margin-top: 0; }
/* phones only (shown in the MOBILE section): MENU button, its close button and the dark shade behind the menu */
.cat-menu-btn, .cat-menu-close, .cat-menu-shade { display: none; }
.cat-menu-btn, .cat-menu-close { font-weight: 700; font-size: 13px; letter-spacing: var(--track); padding: .3em .5em .22em; line-height: 1; }
.cat-menu-btn:hover { background: var(--ink); color: var(--bg); }
.cat-menu-close { padding: 4px; color: var(--ink); background: none; }   /* just an ✕, no word */
.cat-menu-close svg { display: block; width: 26px; height: 26px; }
.cat-menu-btn { background: var(--lime); color: #000; }   /* yellow, like ABOUT ME / CONTACT, so people see it can be tapped */

.works-rail {
  position: absolute;
  left: 25%;
  top: 20px;
  bottom: 0;
  border-left: var(--stroke) solid var(--line);
}
.works-rail::before {               /* dot at the top of the line */
  content: "";
  position: absolute;
  top: calc(var(--dot) / -2); left: calc(var(--stroke) / -2 - var(--dot) / 2);
  width: var(--dot); height: var(--dot);
  border-radius: 50%;
  background: var(--line);
}

.folders {
  position: absolute;
  left: 25%;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

/* each folder = a tab sticking up + a body; the shape itself is drawn by the script (step 3b) */
.folder {
  --head-fs: clamp(22px, 2.5vw, 38px);   /* folder names: same size as the title box inside (GRAPHICS / CRAFTS…) */
  --tab-h: calc(var(--head-fs) * 1.35);   /* the tab is as tall as its name */
  position: relative;
  height: calc(var(--tab-h) + var(--h));
  margin-top: calc(var(--tab-h) * -1);    /* tab overlaps the folder behind it */
  pointer-events: none;                   /* only the drawn shape is clickable, not the empty corners */
  cursor: pointer;
  transition: transform .5s var(--ease);
}
.folder:first-child { margin-top: 0; }
/* WORKS DRAWER on the home page: clicking WORKs moves the home page up and slides these three
   folders up from the bottom of the screen (GRAPHIC · CRAFT. · ARCHIVES, a small staircase) */
:root { --stack-h: calc(2 * clamp(22px, 2.5vw, 38px) * 1.35 + 2vh + 2 * clamp(16px, 3vh, 30px)); }
.home-folders {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  top: auto;
  height: var(--stack-h);
  z-index: 35;                                 /* above the home page, under the logo and the panels */
  transform: translateY(calc(100% + 40px));    /* hidden below the screen */
  transition: transform .75s var(--ease);
}
body.drawer-open .home-folders { transform: none; }
/* the bouncing WORKs (and its dot drawings) fades away while the folders are up */
.center { transition: opacity .45s ease; }
body.drawer-open .center { opacity: 0; pointer-events: none; }
/* top bar that slides down from above while the folders are up */
.drawer-bar {
  position: fixed;
  left: 0; right: 0; top: 0;
  z-index: 36;
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px var(--pad) 16px;
  background: var(--bg);
  transform: translateY(-110%);
  transition: transform .75s var(--ease);
}
body.drawer-open .drawer-bar { transform: none; }
body[data-panel] .drawer-bar { transform: translateY(-110%); }
.drawer-works {
  padding: .28em .5em .2em;
  font-weight: 700;
  font-size: clamp(22px, 2.5vw, 38px);
  letter-spacing: var(--track-bold);
  line-height: 1;
  transition: background .2s, color .2s;
}
.drawer-works:hover { background: var(--ink); color: var(--bg); }
.drawer-nav { display: flex; align-items: center; gap: clamp(14px, 2.2vw, 36px); padding-top: 6px; }
.drawer-nav .cat-home { margin-top: 0; }
/* everything on the home page moves up by the folders' height, so SELECTED WORKs sits in the middle */
.home { transition: width .7s var(--ease), opacity .6s .5s, translate .75s var(--ease); }
.logo { transition: transform 1.1s var(--ease), width .7s var(--ease), --fs 1.1s var(--ease), --pk 1.1s var(--ease), translate .75s var(--ease); }
body.drawer-open .home,
body.drawer-open .logo { translate: 0 calc(-1 * var(--drawer-shift, 200px)); }   /* set by the script: SELECTED WORKs ends up in the middle */
.folders > .folder { flex: none; }
.folder:first-child .folder-head { padding-left: var(--pad); }   /* first name lines up with the page margin */
.folder:not(:first-child) .folder-head { padding-left: .45em; }  /* the others sit inside their stepped tabs */
/* --h = body height: the next folder's tab sits on its lower part, so about 5vh of colour shows under each name */
/* stacked like a drawer of files: each tab sits right on the line of the folder in front of it,
   every step the same height; ARCHIVES at the front runs off the bottom */
/* all three folders stand on the same line: the tabs sit side by side at the same height
   (GRAPHIC · CRAFT. · ARCHIVES), ARCHIVES in front with a short black strip under the tabs */
/* the folders are as tall as the drawer (set by the script), minus the staircase steps */
.folder-graphic  { --h: calc(var(--stack-h) - var(--tab-h) - 2 * var(--step)); --fill: var(--pink); color: #000; }
.folder-craft    { --h: calc(var(--stack-h) - var(--tab-h) - 2 * var(--step)); --fill: var(--lime); color: #000; }
.folder-personal { --h: calc(var(--stack-h) - var(--tab-h) - 2 * var(--step)); --fill: var(--ink); color: var(--bg); }
.folders { --step: clamp(16px, 3vh, 30px); }   /* small staircase: GRAPHIC highest, then CRAFT., ARCHIVES lowest */
.folders > .folder + .folder { margin-top: calc(var(--step) - var(--tab-h) - var(--h)); }

/* hover: the folder pops up a little, like pulling it out of a drawer */
.folder:hover { transform: translateY(-3.5vh); }

.folder-shape {
  position: absolute;
  top: 0; left: 0;
  overflow: visible;
}
.folder-shape path {
  fill: var(--fill);
  stroke: var(--line);
  stroke-width: var(--stroke);
  pointer-events: visiblePainted;
}

.folder-head {
  position: absolute;
  left: 0; top: 0;                        /* the name sits in the tab, at the front */
  height: var(--tab-h);
  display: flex;
  align-items: center;
  padding: .08em .3em 0 clamp(14px, 1.4vw, 24px);
  font-weight: 700;
  font-size: var(--head-fs);
  white-space: nowrap;
  letter-spacing: var(--track);
  text-align: left;
  line-height: 1;
  pointer-events: auto;
}
/* the names sit low in their tabs: the letters' baseline lands on the folder's horizontal line */
.home-folders .folder-head { align-items: flex-end; padding-top: 0; transform: translateY(calc(.17em - 5px)); }   /* 5px up from the line */
.folder:hover .folder-head { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 6px; }

/* =========================================================
   CATEGORY PAGE (Works → Graphic / Craft / Personal project)
   ========================================================= */
.category {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: var(--bg);
  overflow: hidden;                 /* the page itself doesn't scroll, only the right side */
  opacity: 0;
  visibility: hidden;
  transform: translateY(30px);
  transition: opacity .45s, transform .6s var(--ease), visibility 0s .6s;
}
body.cat-open .category {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .45s, transform .6s var(--ease), visibility 0s;
}

.cat-layout {
  display: grid;
  grid-template-columns: 25% 1fr;
  height: 100%;
}

/* left column: title, filters, home (never scrolls) */
.cat-side {
  height: 100%;
  overflow: hidden;
  padding: 20px 36px 20px var(--pad);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.cat-title {
  width: 100%;
  padding: .28em 0 .2em;
  font-weight: 700;
  font-size: clamp(22px, 2.5vw, 38px);
  letter-spacing: var(--track);
  line-height: 1;
  text-align: center;
  transition: background .2s, color .2s;
}
.cat-title:hover { background: var(--ink); color: var(--bg); }
/* hover in the category's own folder colour, like the folders on the Works page */
.cat-title[data-cat="graphic"]:hover { background: var(--pink); color: #000; }
.cat-title[data-cat="craft"]:hover   { background: var(--lime); color: #000; }

.cat-filters {
  list-style: none;
  margin-top: clamp(60px, 13vh, 130px);
  font-size: clamp(18px, 1.75vw, 27px);
  line-height: 1.25;
}
.cat-filters button { font-weight: 300; text-align: left; transform-origin: left center; }
.cat-filters button:hover { text-decoration: underline; text-underline-offset: 4px; }
.cat-filters button[aria-pressed="true"] { font-weight: 700; }
/* on a project page: smaller list of project names under an "ALL WORKS" heading */
.cat-filters.is-projects { font-size: clamp(13px, 1.05vw, 16px); line-height: 1.45; }
.cat-menu-head { font-weight: 300; text-decoration: underline; text-underline-offset: 3px; margin-bottom: .5em; }   /* ALL WORKS: underlined, not bold */
.cat-filters:not(.is-projects) li:last-child { margin-top: .7em; }        /* small gap above "> Recent" */
.cat-filters:not(.is-projects) li:last-child button[aria-pressed="true"] { font-weight: 300; }   /* "Recent" never goes bold */
.cat-filters:not(.is-projects) li:last-child button { text-decoration: underline; text-underline-offset: 4px; }   /* "Recent" is underlined */

.cat-home {
  margin-top: auto;                 /* pushes HOME to the bottom of the screen */
  font-size: clamp(12px, 1vw, 15px);
  padding: .3em .55em .2em;
  line-height: 1;
  transition: background .2s, color .2s;
}
.cat-home:hover { background: var(--ink); color: var(--bg); }

/* right column: the vertical line with a dot at each end stays still… */
.cat-main {
  position: relative;
  margin-block: 20px;
  border-left: var(--stroke) solid var(--line);
  min-height: 0;
}
/* …and only the photos inside it scroll */
.cat-scroll {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(80px, 17vh, 180px) clamp(16px, 2vw, 30px) 0;   /* right margin = left gap (line → photos) */
}
.cat-main::before,
.cat-main::after {
  content: "";
  position: absolute;
  left: calc(var(--stroke) / -2 - var(--dot) / 2);
  width: var(--dot); height: var(--dot);
  border-radius: 50%;
  background: var(--line);
}
.cat-main::before { top: calc(var(--dot) / -2); }
.cat-main::after  { bottom: calc(var(--dot) / -2); }

/* category grid: rows of 2 photos running from margin to margin, same gap as on the project pages */
.cat-grid {
  display: flex;
  flex-direction: column;
  gap: var(--photo-gap);
}
.cat-row {
  display: flex;
  align-items: flex-start;
  gap: var(--photo-gap);
}
.cat-row > * { flex: 1.44 1 0; min-width: 0; }   /* flex-grow is set to each photo's shape by the script */
.cat-grid .ph, .cat-grid .work { aspect-ratio: 1.44 / 1; }
.cat-empty { grid-column: 1 / -1; font-weight: 300; color: var(--grey); }

/* a real work (image) gets the same hover as the grey boxes */
.work { display: block; overflow: visible; transition: transform .35s var(--ease); }
.work img { width: 100%; height: 100%; object-fit: cover; display: block; }
.work video { width: 100%; height: 100%; object-fit: cover; display: block; }   /* a video as the category-page box */
.work:hover { position: relative; z-index: 5; transform: scale(1.12); }

.cat-pager {
  display: flex;
  justify-content: center;
  gap: .6em;
  padding: 40px 0 24px;
  font-size: clamp(14px, 1.15vw, 18px);
  font-weight: 300;
}
.cat-pager button[aria-current="page"] { font-weight: 700; }
.cat-pager button:disabled { opacity: .3; cursor: default; }
.cat-pager button:not(:disabled):hover { text-decoration: underline; text-underline-offset: 3px; }

/* =========================================================
   PROJECT PAGE (after clicking a box on a category page)
   ========================================================= */
.cat-scroll.is-project { padding-top: 16px; }

.project { padding-bottom: 24px; }
/* every picture slot: the image/grey box fills its slot exactly */
.proj-hero, .proj-thumbs button, .proj-process .track > *, .work { position: relative; display: block; width: 100%; }
.proj-hero > *, .proj-thumbs button > *, .proj-process .track > * > *, .work > * {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.project .ph:hover { transform: none; box-shadow: none; }    /* no grow effect on this page */
.project .ph[data-n]::before {          /* number on placeholder boxes (gone once you add photos) */
  content: attr(data-n);
  position: absolute; top: 6px; left: 8px;
  font-size: 13px; font-weight: 300;
}

.proj-meta {
  white-space: pre-line;                  /* credit can have a second line */
  /* under the photo, on the right, its top level with subtitle 1 */
  float: right;
  margin: 6px 0 0 24px;                    /* same space above as subtitle 1 */
  text-align: right;
  font-size: clamp(11px, calc(1.2vw - 5px), 13px);   /* 5 smaller than before (was 14–18px) */
  font-weight: 300;
  line-height: 1.15;                       /* lines a little closer together */
}

.proj-media { margin-top: clamp(60px, 11vh, 120px); }
/* every project: the photos start right at the top margin (level with the top of the CRAFTS / GRAPHIC box) */
@media (min-width: 761px) {
  .proj-media { margin-top: 0; }
  /* category page boxes AND project photos all start right at the top margin (2px = room for the corner dots) */
  .cat-scroll, .cat-scroll.is-project { padding-top: 2px; }
}
.proj-hero {
  display: block;
  width: 100%;
  margin-inline: auto;
  aspect-ratio: 1.9 / 1;
  cursor: zoom-in;
}

/* layout: "side" — big picture on the left in its own shape, small boxes in a column on the right
   that is exactly as tall as the big picture and slides upward */
.layout-side .proj-media {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: var(--photo-gap);
}
.layout-side .proj-hero { aspect-ratio: 3 / 4; }          /* until the photo loads */
.layout-side .proj-thumbs { position: relative; margin-top: 0; --gap: var(--photo-gap); }
.layout-side .proj-thumbs .track { position: absolute; inset: 0; flex-direction: column; }
.layout-side .proj-thumbs .track > button { flex: 0 0 calc((100% - 2 * var(--gap)) / 3); aspect-ratio: auto; width: 100%; }
/* the big picture + side boxes fit the screen height (no scrolling to see the whole photo):
   the big picture takes its own shape at that height, the side boxes get the rest of the width */
@media (min-width: 761px) {
  .layout-side .proj-media {
    grid-template-columns: auto minmax(0, 1fr);
    height: max(380px, calc(100vh - 70px));          /* big picture fills the screen from the top margin to the bottom margin ("Click to view" is just below) */
  }
  .layout-side .proj-hero { height: 100%; width: auto; max-width: 62vw; }
}

/* carousels (3 pictures under the big image, and the process row):
   3 visible at a time, lined up with the edges of the big image; the script slides the track left */
.proj-thumbs, .proj-process {
  --gap: var(--photo-gap);
  overflow: hidden;
  margin-top: var(--gap);
}
.proj-process { margin-top: 12px; }
.track {
  display: flex;
  gap: var(--gap);
  will-change: transform;
}
.track > button, .track > .proc-video {
  flex: 0 0 calc((100% - 2 * var(--gap)) / 3);
  transition: opacity .2s;
}

.proj-thumbs button { aspect-ratio: 1.68 / 1; cursor: zoom-in; }
.proj-thumbs button:hover { opacity: .7; }

/* "< Click to view >" rows */
.proj-viewnav {
  display: flex;
  align-items: center;
  gap: .35em;
  margin-top: 18px;
  font-size: clamp(11px, calc(1.2vw - 5px), 13px);   /* small – same size as the year / Commde's Work / subject text */
  font-weight: 300;
}
.proj-viewnav-right { justify-content: flex-end; margin-top: 10px; }   /* sits right under the 3 pictures */
.proj-viewnav button { padding: 0 .15em; }
.proj-viewnav button:hover { font-weight: 700; }
.view-toggle { padding: 0 .2em; }
.proj-viewnav .view-toggle:hover { font-weight: 300; text-decoration: underline; text-underline-offset: 3px; }   /* never bold */

.proj-title {
  margin-top: clamp(32px, 3.5vw, 56px);   /* more space between the photos and the title */
  font-weight: 700;
  font-size: clamp(30px, 3.2vw, 52px);
  letter-spacing: var(--track);
  line-height: 1.1;
}
/* "Role: …" line under the subtitle */
.proj-role {
  margin-top: .6em;
  font-weight: 300;
  font-size: clamp(14px, 1.15vw, 17px);
  letter-spacing: var(--track);
}

.proj-sub {
  white-space: pre-line;                  /* allows a second line */
  font-weight: 300;                       /* light (no weight between light and regular in this font) */
  font-size: clamp(18px, 1.6vw, 25px);   /* a step bigger than the description (14–17px) */
  line-height: 1.05;                      /* tighter leading between the two subtitle lines */
  margin-top: 6px;
}

/* description (right) + "Collaborate with" (left, lined up with the title) */
.proj-body {
  clear: both;                            /* starts below the year / credit block */
  display: grid;
  grid-template-columns: 34% 1fr;
  margin-top: clamp(56px, 6vw, 100px);    /* more breathing room under the title / year block */
}
.proj-text {
  grid-column: 2; grid-row: 1;
  font-weight: 300;
  font-size: clamp(14px, 1.15vw, 17px);
  line-height: 1.3;                       /* tighter leading */
}
.proj-text p + p { margin-top: 1em; }

.proj-collab {
  grid-column: 1; grid-row: 2;            /* starts where the description ends */
  align-self: start;
  padding-right: 24px;
  font-size: clamp(14px, 1.15vw, 17px);
  font-weight: 300;
  line-height: 1.3;                       /* same as the description so the last lines line up */
  display: flex;
  flex-direction: column;
}
.proj-collab-label { font-weight: 400; }   /* one step heavier than light: regular */
#projCollabNames { white-space: pre-line; }   /* one name per line */
/* body text: Inter 18pt, with the font's own letter spacing */
.proj-text, .proj-collab { font-family: var(--font-body); letter-spacing: normal; }

.proj-body ~ .proj-viewnav { margin-top: clamp(80px, 14vh, 160px); }   /* space between the description (or video) and the process row */

.proj-process .track > * { aspect-ratio: 1.73 / 1; }
.proj-process .track { align-items: flex-start; }        /* photos keep their small size next to the big video */
.proj-process { transition: height .5s var(--ease); }    /* row grows/shrinks to what's in view */
.proj-process button { cursor: zoom-in; }
.proc-video video { background: #000; }   /* video with its own play bar */
/* process row: 2 at a time (bigger boxes); videos are the same size as the photos */
.proj-process .track > button, .proj-process .track > .proc-video { flex-basis: calc((100% - var(--gap)) / 2); }
.proj-process button:hover { opacity: .7; }

/* process GRID (after "Click to view process"): every photo at once, 3 per row */
.proj-process.is-grid { height: auto !important; }
.proj-process.is-grid .track { flex-wrap: wrap; row-gap: var(--gap); transform: none !important; }
.proj-process.is-grid .track > button,
.proj-process.is-grid .track > .proc-video {
  flex-basis: calc((100% - 2 * var(--gap)) / 3);
  animation: proc-in .6s var(--ease) both;
  animation-delay: calc(var(--n, 0) * 60ms);        /* the boxes pop in one after another */
}
@keyframes proc-in { from { opacity: 0; transform: translateY(14px); } }
@media (max-width: 760px) {
  .proj-process.is-grid .track > button,
  .proj-process.is-grid .track > .proc-video { flex-basis: calc((100% - var(--gap)) / 2); }
}

.to-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: clamp(120px, 26vh, 280px) auto 0;
  font-size: clamp(14px, 1.2vw, 18px);
  font-weight: 300;
  line-height: 1.2;
}
/* wide: true – the main picture fills the full width (lined up with the small photos underneath) */
.project.hero-full:not(.layout-side) .proj-hero { width: 100%; }
/* film: a video under the description, full width, with its own play bar */
.proj-film { margin-top: clamp(56px, 6vw, 100px); }
.proj-film video { display: block; width: 100%; height: auto; background: #000; }
.to-top-arrow { font-size: 1.5em; line-height: .8; }
.project.is-short .to-top { display: none; }        /* short projects: nothing to scroll back up from */
.project.is-short .proj-body { margin-top: 0; }
.to-top:hover { font-weight: 700; }

/* =========================================================
   LIGHTBOX (big view of one image)
   ========================================================= */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 60px var(--pad);
}
.lb-stage { height: 100%; display: grid; place-items: center; min-width: 0; min-height: 0; }
/* whole photo in its real shape, always fitting inside the screen */
.lb-stage img, .lb-stage video {
  width: auto; height: auto;
  max-width: 100%;
  max-height: calc(100vh - 120px);
  object-fit: contain;
}
.lb-stage .ph { width: min(100%, 140vh); aspect-ratio: 1.9 / 1; cursor: default; }
.lightbox .ph:hover { transform: none; box-shadow: none; }   /* no grow / shadow inside the pop-up */
.lb-arrow { font-size: clamp(22px, 2.5vw, 36px); font-weight: 300; padding: 0 .3em; }
.lb-arrow:hover { font-weight: 700; }
.lb-close {
  position: absolute;
  top: 20px; right: var(--pad);
  font-weight: 700;
  font-size: 14px;
  padding: .3em .55em .2em;
  border: var(--stroke) solid var(--line);
}
.lb-close:hover { background: var(--ink); color: var(--bg); }
.lb-count {
  position: absolute;
  bottom: 20px; left: 0; right: 0;
  text-align: center;
  font-weight: 300;
  font-size: 14px;
}

/* =========================================================
   MOBILE
   ========================================================= */
@media (max-width: 760px) {
  :root { --logo-w: 130px; }
  .top { grid-template-columns: 1fr auto; }
  .hello-wrap { grid-column: 1 / -1; grid-row: 2; }
  .hello { font-size: 13vw; }
  .nav { flex-direction: row; align-items: center; gap: 8px; }   /* ☾  ABOUT ME  CONTACT in one row, like on a computer */
  .nav .btn { font-size: 13px; }
  .nav .theme-toggle { margin-right: 0; }
  .top-left { padding-top: calc(var(--logo-w) * var(--logo-ratio) + 24px); }
  .selected-grid .track > .sel-item { flex-basis: 100%; }
  .center { min-height: 200px; }

  body[data-panel] { --logo-w: 130px; }
  body[data-panel] .home { width: 100%; }
  .panel { width: 100%; padding-top: calc(var(--logo-w) * var(--logo-ratio) + 44px); }   /* starts under the PRIM logo */
  .about-intro, .about-row { grid-template-columns: 1fr; }
  .about-row { gap: 10px; }

  .works-label { width: auto; padding: .28em .5em .2em; }
  .wsel-grid .track > .sel-item { aspect-ratio: auto; flex-basis: 100%; }   /* phones: one photo at a time */

  .category { overflow-y: auto; }          /* on phones the whole page scrolls */
  .cat-layout { grid-template-columns: 1fr; height: auto; }
  .cat-side { height: auto; padding-right: var(--pad); }
  .cat-scroll { height: auto; overflow: visible; }
  .cat-title { width: auto; padding: .28em .5em .2em; }
  .cat-filters { margin-top: 24px; display: flex; flex-wrap: wrap; gap: 4px 16px; }
  .cat-home { margin-top: 20px; }
  .cat-main { border-left: 0; margin-top: 0; padding: 12px var(--pad) 0; }
  .cat-main::before, .cat-main::after { display: none; }
  /* phones: the same gap-free rows as on a computer, just about 2 works per row (set in the script) */
  .proj-text { grid-column: 1; }
  .proj-body { grid-template-columns: 1fr; }
  .proj-collab { grid-row: 2; margin-top: 2em; }
  .layout-side .proj-media { grid-template-columns: 1fr; }      /* phones: back to big picture + row below */
  .layout-side .proj-thumbs { position: static; margin-top: 10px; }
  .layout-side .proj-thumbs .track { position: static; flex-direction: row; }
  .layout-side .proj-thumbs .track > button { flex: 0 0 calc((100% - 2 * var(--gap)) / 3); aspect-ratio: 1.68 / 1; }
  .proj-thumbs, .proj-process { --gap: 10px; }
  .lightbox { padding: 60px 8px; gap: 4px; }

  /* ---- phone polish ---- */
  /* Works folders: bigger steps so CRAFT. is easy to read and ARCHIVES sits lower (less black) */
  .folders { --step: 44px; }
  .hello { font-size: 10vw; }                        /* fits between the margins on any phone (was 11.6vw – pushed the page wider) */
  .hello-wrap { width: max-content; max-width: 100%; justify-self: center; }   /* HELLO WORLD in the middle */
  .update { font-size: 10px; gap: .9em; }
  /* < > sit on the left of the SELECTED WORKs line (not under the label) */
  .sel-nav { left: 0; transform: none; }
  /* category menu: the drawn folders are for big screens – on phones a simple row of words,
     the open one bold + underlined; the project list lives in the grid underneath */
  /* category menu: a MENU button (next to HOME) slides the same folder menu as on a computer in from the left */
  .cat-menu-btn { display: inline-block !important; }
  body .cat-filters, body .cat-filters.folder-menu {
    box-sizing: border-box;
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 95;
    display: block; width: min(84vw, 340px); margin: 0;
    padding: 84px 22px 24px var(--pad);
    background: var(--bg); border-right: var(--stroke) solid var(--line);
    overflow: hidden;
    font-size: 17px;
    transform: translateX(-102%);
    transition: transform .45s var(--ease);
  }
  body.cat-menu-open .cat-filters.cat-filters { transform: none; }
  .cat-menu-shade {
    display: block; position: fixed; inset: 0; z-index: 94;
    background: rgba(0, 0, 0, .25);
    opacity: 0; pointer-events: none; transition: opacity .35s;
  }
  body.cat-menu-open .cat-menu-shade { opacity: 1; pointer-events: auto; }
  .cat-menu-close { display: block !important; position: fixed; z-index: 96; top: 24px; left: calc(min(84vw, 340px) - 22px); transform: translateX(-100%);
    opacity: 0; pointer-events: none; transition: opacity .3s; }
  body.cat-menu-open .cat-menu-close { opacity: 1; pointer-events: auto; }
  /* HOME + ☾ at the top right, level with the GRAPHICS / CRAFTS box */
  .cat-side { position: relative; }
  .cat-title { width: auto; }
  .cat-foot { position: absolute; top: 20px; right: var(--pad); margin: 0; height: calc(clamp(22px, 2.5vw, 38px) * 1.48 + 2px); }   /* same height as the title box */
  /* project page: year / Commde’s Work / subject on the right, its top level with subtitle 1 (like on a computer) */
  .project .proj-meta { float: right; text-align: right; margin: 6px 0 0 14px; max-width: 46%; }
  /* swipe with a finger instead of the < > arrows (the words stay) */
  .sel-nav, #projPrev, #projNext, #procPrev, #procNext, .lb-arrow, .bk-nav .bk-prev, .bk-nav .bk-next { display: none !important; }
  .selected-grid, .proj-thumbs, .proj-process, .lb-stage, .bk-book { touch-action: pan-y; }
  .cat-scroll, .cat-scroll.is-project { padding: 20px 0 0; }   /* photos line up with the page margin */
  .cat-side { padding-bottom: 6px; }
  /* project page on phones: photos at the top, normal reading width */
  .proj-media { margin-top: 8px; }
  .proj-meta { float: none; text-align: left; margin: 10px 0 0; }
  .proj-title { font-size: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01s !important; animation: none !important; }
}

/* layout A: a tall main video fits the screen height (centred) instead of running off the bottom */
.project:not(.layout-side) .proj-hero { width: min(100%, calc(85vh * var(--ar, 99))); }
/* works with only ONE picture (no small boxes): the picture shrinks a little so the title
   underneath fits on the screen too, its bottom on the bottom margin line */
@media (min-width: 761px) {
  .project:not(.layout-side):has(#projThumbs[hidden]) .proj-hero {
    --fit-h: calc(100vh - 76px - clamp(32px, 3.5vw, 56px) - clamp(33px, 3.52vw, 57.2px));
    width: min(100%, calc(var(--fit-h) * var(--ar, 99)));
  }
}

/* layout C ("poster") — for single-picture works: title, subtitles, role (and description if any)
   on the left against the left margin, the picture on the right against the right margin, tops lined up */
@media (min-width: 761px) {
  .project.layout-poster {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto auto auto 1fr;
    column-gap: clamp(32px, 4vw, 72px);
    align-content: start;
  }
  .project.layout-poster > * { grid-column: 1 / -1; }
  .project.layout-poster .proj-meta { grid-row: 1; }
  .project.layout-poster .proj-media { grid-column: 2; grid-row: 2 / 7; }
  .project.layout-poster .proj-viewnav-right { grid-column: 2; grid-row: 7; }
  .project.layout-poster .proj-title { grid-column: 1; grid-row: 2; margin-top: clamp(60px, 11vh, 120px); }   /* same top as the picture */
  .project.layout-poster .proj-sub   { grid-column: 1; grid-row: 3; }
  .project.layout-poster .proj-role  { grid-column: 1; grid-row: 4; }
  .project.layout-poster .proj-body  { grid-column: 1; grid-row: 5; grid-template-columns: 1fr; max-width: 38em; }
  .project.layout-poster .proj-text  { grid-column: 1; }
  .project.layout-poster .proj-collab { grid-column: 1; margin-top: 2em; }
  .project.layout-poster .proj-hero {
    width: min(45vw, calc(80vh * var(--ar, .5625)));   /* fits the screen height, never wider than ~half the page */
    margin-inline: auto 0;                              /* against the right margin */
  }
}

/* =========================================================
   SIDE MENU AS STACKED FOLDERS (MENU_FOLDERS = true in index.html)
   The menu never changes: one outline folder per type, tabs alternating left / right like a
   file drawer, later folders in front of earlier ones. The open folder pops up, turns black with
   white text and lists the projects inside it.
   ========================================================= */
@media all {   /* computers: the left column · phones: inside the slide-out MENU */
  .cat-filters.folder-menu {
    --tab-h: 2em;            /* tab height */
    --peek: .5em;            /* how much of each closed folder shows under the next tab */
    --r: 7px;                /* corner roundness */
    --sel: var(--recent);    /* open folder: soft grey fill with normal text (lighter grey by day, darker by night) */
    width: 100%;
    margin-top: clamp(40px, 8vh, 90px);
    font-size: clamp(14px, 1.2vw, 19px);
    line-height: 1;
    /* no clipping here: the left column itself cuts the folders off at the screen's left edge and bottom */
  }
  .folder-menu > li {
    position: relative;
    isolation: isolate;
    min-height: calc(var(--tab-h) + var(--peek));
    padding-top: var(--tab-h);
    transition: transform .25s var(--ease);
  }
  .folder-menu > li:first-child { margin-top: .5em; }   /* room for the pop-up */
  /* the folder outline – same shape as the folders on the Works page, drawn by the script:
     body runs off the left edge of the screen and on down behind the next folder */
  .folder-menu .menu-folder {
    position: absolute;
    top: 0;
    overflow: visible;
    pointer-events: none;
    z-index: 0;
  }
  .folder-menu .menu-folder path {
    fill: var(--bg);
    stroke: var(--line);
    stroke-width: var(--stroke);
    transition: fill .25s;
  }
  /* the name sits in the tab */
  .folder-menu > li > button {
    position: absolute;
    top: 0;
    height: var(--tab-h);
    display: flex; align-items: center;
    z-index: 1;
    font-weight: 300;
    white-space: nowrap;
  }
  .folder-menu > li.tab-right > button { justify-content: flex-end; }
  .folder-menu > li > button[aria-pressed="true"] { font-weight: 700; }   /* the open folder's name is bold */
  .folder-menu > li:not(:last-child) > button:hover { text-decoration: none; }
  .folder-menu > li:not(.is-open):hover { transform: translateY(-3px); }
  /* selected / open folder: pops up and fills with the category colour */
  .folder-menu > li:has(> button[aria-pressed="true"]) { transform: translateY(-.35em); }
  .folder-menu > li:has(> button[aria-pressed="true"]) .menu-folder path { fill: var(--sel); }
  .folder-menu > li > button[aria-pressed="true"],
  .cat-filters.folder-menu > li .folder-list li button,
  .folder-menu .folder-empty { color: var(--ink); }   /* normal text colour on the grey folder */
  .cat-filters.folder-menu:not(.is-projects) > li:last-child { margin-top: 0; }   /* Recent: just the next folder */
  .cat-side:has(.folder-menu) .cat-home { position: relative; z-index: 3; background: var(--bg); }   /* HOME sits on top of it */

  /* project names inside the open folder */
  .folder-list {
    position: relative; z-index: 1;
    list-style: none;
    padding: 1.5em 1em 1.1em;        /* more room between the folder edge and the first project name */
    font-size: .8em;
    line-height: 1.5;
    animation: folder-open .35s var(--ease) both;
  }
  .cat-filters.folder-menu .folder-list li { margin-top: 0; }                 /* undo the gap meant for "Recent" */
  .cat-filters.folder-menu .folder-list li button { font-weight: 300; text-align: left; text-decoration: none; }
  /* project names line up with their folder's name: left tabs → left, right tabs → right */
  .folder-menu > li:not(.tab-right) .folder-list { padding-left: .2em; padding-right: 0; }
  .folder-menu > li.tab-right .folder-list { padding-left: 0; padding-right: .875em; text-align: right; }
  .cat-filters.folder-menu > li.tab-right .folder-list li button { text-align: right; }
  .cat-filters.folder-menu .folder-list li button:hover { text-decoration: underline; text-underline-offset: 3px; }
  .cat-filters.folder-menu .folder-list li button[aria-current="true"] { font-weight: 700; }
  .folder-empty { font-weight: 300; opacity: .6; }
  @keyframes folder-open { from { opacity: 0; transform: translateY(-4px); } }
}

/* halftone dot drawing behind the bouncing WORKs button (drawn by the script) */
.works-trail { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cat-side:has(.folder-menu) .cat-home:hover { background: var(--ink); color: var(--bg); }   /* keep HOME's hover */

/* two main photos side by side (mainPair), same height, a small gap between them */
.proj-hero.is-pair { display: flex; gap: var(--photo-gap); }
.proj-hero.is-pair > * { position: relative; inset: auto; height: 100%; width: 0; flex: 1 1 0; object-fit: cover; }


/* bold headings / bold words: a little tighter letter spacing than the rest (--track-bold) */
.btn, .update-title, .hello, .selected-title, .sel-name, .panel-label, .send,
.works-label, .folder-head, .cat-title, .proj-title, .lb-close { letter-spacing: var(--track-bold); }


/* =========================================================
   NIGHT MODE (moon button, bottom right) – dark page, light lines and text;
   pink and lime stay the same, with black text on them
   ========================================================= */
html[data-theme="night"] {
  --bg: #111;
  --ink: #f2f2f2;
  --grey: #8a8a8a;
  --ph: #2a2a2a;
  --line: #555;     /* medium-dark grey lines: softer against the black than white */
  --recent: #333;
  color-scheme: dark;
}
html[data-theme="night"] .sel-nav { color: #9a9a9a; }
html[data-theme="night"] .folder-personal { --fill: #000; color: #f2f2f2; }   /* ARCHIVES: black at night too (grey outline shows its edge) */
html[data-theme="night"] .panel-about { background: #000; }
html { transition: background-color .4s; }
body { transition: background-color .4s, color .4s; }

.theme-toggle {
  flex: none;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border: var(--stroke) solid var(--line);
  border-radius: 50%;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1;
  letter-spacing: 0;
  transition: background .2s, color .2s;
}
.theme-toggle:hover { background: var(--ink); color: var(--bg); }
.nav .theme-toggle { align-self: center; margin-right: clamp(4px, .8vw, 14px); }   /* moon on the left of ABOUT ME */

/* =========================================================
   VIRTUAL FLIP-THROUGH BOOK (book: "…" on a work – THE ANATOMY OF MOLD)
   two A5 landscape pages side by side; flaps fold over from the middle
   ========================================================= */
.mold-book { width: 100%; }
.bk-book {
  position: relative;
  width: min(100%, calc((100vh - 150px) * var(--bk-ar, 2.8398)));      /* fits the screen height, top on the top margin */
  aspect-ratio: var(--bk-ar, 2.8398);                                    /* two pages side by side (set by the script for each book) */
  margin-inline: auto;
  perspective: 3200px;
  cursor: pointer;
  outline: none;
  transition: transform .9s cubic-bezier(.45, .05, .25, 1), opacity .3s ease;
  -webkit-user-select: none; user-select: none;
}
.bk-book[data-state="front"] { transform: translateX(-25%); }   /* closed: the cover sits in the middle */
.bk-book[data-state="back"]  { transform: translateX(25%); }
.bk-slot { position: absolute; top: 0; bottom: 0; width: 50%; }
.bk-slot.is-L { left: 0; width: calc(50% + .5px); }          /* the two pages overlap by 1px: no hairline down the middle */
.bk-slot.is-R { left: calc(50% - .5px); width: calc(50% + .5px); }
.bk-side { position: absolute; inset: 0; overflow: hidden; }
.bk-side > img { position: absolute; top: 0; height: 100%; width: 100%; object-fit: cover; display: block; pointer-events: none; }
.bk-side > .bk-flapimg { object-fit: fill; }
.bk-side.is-R > .bk-flapimg { left: 0; box-shadow: 4px 0 10px rgba(0, 0, 0, .18); }   /* flaps lie at the middle of the book */
.bk-side.is-L > .bk-flapimg { right: 0; box-shadow: -4px 0 10px rgba(0, 0, 0, .18); }
/* soft fold shadow down the middle of the open book */
.bk-side.has-page.is-L::after, .bk-side.has-page.is-R::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 7%; pointer-events: none; z-index: 2;
}
.bk-side.has-page.is-L::after { right: 0; background: linear-gradient(to left, rgba(0, 0, 0, .16), transparent); }
.bk-side.has-page.is-R::after { left: 0;  background: linear-gradient(to right, rgba(0, 0, 0, .16), transparent); }
.bk-book[data-state="front"] .bk-side::after, .bk-book[data-state="back"] .bk-side::after { display: none; }

/* a page or a flap while it turns over around the rings: thin strips joined edge to edge (the script turns them) */
.bk-turn { position: absolute; top: 0; bottom: 0; z-index: 5; transform-style: preserve-3d; pointer-events: none; }
.bk-turn.is-R { left: 50%; }
.bk-turn.is-L { right: 50%; }
.bk-strip { position: absolute; top: 0; bottom: 0; transform-style: preserve-3d; }
.bk-turn > .bk-strip { width: calc(100% / 10); }        /* 10 = STRIPS in the script */
.bk-strip .bk-strip { width: 100%; }
.is-R .bk-strip { transform-origin: left center; }
.is-R > .bk-strip { left: 0; }
.is-R .bk-strip .bk-strip { left: 100%; }
.is-L .bk-strip { transform-origin: right center; }
.is-L > .bk-strip { right: 0; }
.is-L .bk-strip .bk-strip { right: 100%; }
.bk-face { position: absolute; top: 0; bottom: 0; left: 0; right: 0; overflow: hidden;
  backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.bk-turn.is-R .bk-face { right: -2px; }                  /* overlap so no hairline shows between strips */
.bk-turn.is-L .bk-face { left: -2px; }
.bk-face.is-back { transform: rotateY(180deg); }
.bk-cut { position: absolute; top: 0; bottom: 0; height: 100%; }
.bk-face .bk-side { box-shadow: none; }
.bk-face .bk-side::after { display: none; }
.bk-shade { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.bk-turn.is-stencil .bk-face { opacity: .82; }           /* tracing paper: you can see through it while it turns */

/* paper: a fine grain over every page, and the stack of pages showing at the outer edges */
.bk-side.has-page::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5  0 0 0 0 .47  0 0 0 0 .42  0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply; opacity: .32;
}
.bk-slot > .bk-side.has-page.is-L { box-shadow: -1px 1px 0 #f2f2ef, -2px 2px 0 #d9d9d5, -3px 3px 0 #f0f0ec, -4px 4px 0 #d2d2cd, -5px 5px 0 #ececE7, -8px 10px 18px rgba(0, 0, 0, .2); }
.bk-slot > .bk-side.has-page.is-R { box-shadow: 1px 1px 0 #f2f2ef, 2px 2px 0 #d9d9d5, 3px 3px 0 #f0f0ec, 4px 4px 0 #d2d2cd, 5px 5px 0 #ececE7, 8px 10px 18px rgba(0, 0, 0, .2); }
.bk-slot > .bk-side.has-page { overflow: visible; }
.bk-slot > .bk-side.has-page > img { clip-path: inset(0); }
.bk-slot > .bk-side > .bk-flapimg { box-shadow: none; }
.bk-slot > .bk-side.is-R > .bk-flapimg { filter: drop-shadow(3px 0 5px rgba(0, 0, 0, .22)); }
.bk-slot > .bk-side.is-L > .bk-flapimg { filter: drop-shadow(-3px 0 5px rgba(0, 0, 0, .22)); }

/* the 5 shiny metal rings in the middle; every sheet has its own punched holes that turn with it */
.bk-hole {
  position: absolute; aspect-ratio: 1; border-radius: 50%; translate: 0 -50%; z-index: 4;
  background: radial-gradient(circle at 45% 40%, #fff 0 18%, #e9e9e9 40%, #cfcfcf 70%, #a9a9a9);   /* white table showing through */
  box-shadow: inset 1px 1.5px 2px rgba(0, 0, 0, .55), 0 0 0 .5px rgba(0, 0, 0, .25);
}
.bk-rings { position: absolute; inset: 0; pointer-events: none; z-index: 8; }
.bk-cast { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.bk-ring { position: absolute; left: 50%; width: 3.25%;   /* = HOLE_X / 0.8 (% of the book) */ translate: -50% -72%; }
.bk-ring svg { display: block; width: 100%; height: auto; overflow: visible; }

.bk-nav {
  display: flex; justify-content: center; align-items: center; gap: 1.4em;
  margin: 10px 0 0;
  font-size: clamp(11px, calc(1.2vw - 5px), 13px); font-weight: 300;
}
.bk-nav button { font: inherit; color: inherit; background: none; border: 0; padding: 2px 6px; cursor: pointer; }
.bk-nav button:disabled { opacity: .3; cursor: default; }
.bk-count { min-width: 7em; text-align: center; }
/* a work with a book: photo row on top (starts at the top margin), arrows under it, then the book */
.project.has-book .proj-thumbs { margin-top: 0; }
.project.has-book .proj-media > .proj-viewnav-right { margin-bottom: clamp(8px, 1.4vh, 16px); }   /* the book sits close under the row */
/* a book with no photo row (e.g. NIGHTLIFE): it shrinks so the title underneath still fits on the screen (like single-picture works) */
@media (min-width: 761px) {
  .project.has-book:has(#projThumbs[hidden]) .bk-book {
    width: min(100%, calc((100vh - 76px - clamp(32px, 3.5vw, 56px) - clamp(33px, 3.52vw, 57.2px) - clamp(24px, 1.8vw, 30px) - 34px) * var(--bk-ar, 2.8398)));   /* room for the title + 2 subtitle lines */
  }
}
/* a book under the photo row: never taller than what is left of the screen (a tall A5-portrait book like NIGHTLIFE
   shrinks; the wide MOLD book is limited by the width instead, so it doesn't change) */
@media (min-width: 761px) {
  .project.has-book:has(#projThumbs:not([hidden])) .bk-book { width: min(100%, calc((100vh - 330px) * var(--bk-ar, 2.8398))); }
}

/* Manop SemiBold (Adobe Fonts, CSS name "manop"): Thai title font used for พาหุรัด (titleFont: "manop"). Add Manop SemiBold to the Adobe Fonts web project in <head>.
   Put the font file in works/fonts/ as Manop-SemiBold.woff2 / .otf / .ttf – until then a bold Thai system font shows. */
@font-face {
  font-family: "Manop";
  font-weight: 600;
  src: local("Manop SemiBold"), local("Manop-SemiBold"),
       url("works/fonts/Manop-SemiBold.woff2") format("woff2"),
       url("works/fonts/Manop-SemiBold.otf") format("opentype"),
       url("works/fonts/Manop-SemiBold.ttf") format("truetype");
}
.t-manop { font-family: "manop-variable", "manop", "Manop", "Thonburi", "Sukhumvit Set", "Noto Sans Thai", sans-serif !important; font-weight: 600 !important; font-variation-settings: "wght" 572, "wdth" 100; letter-spacing: 0 !important; }

/* sideFit: true (layout B with a wide main photo, e.g. THE USES OF COCONUT):
   main photo a bit smaller so the title + subtitles show on the first screen,
   side column wide enough that the small photos keep their own shape (no crop) */
.proj-title { white-space: pre-line; }
.project.side-fit { container-type: inline-size; }
@media (min-width: 761px) {
  .project.side-fit .proj-media {
    --h: min(calc(100vh - 260px), calc((100cqw - var(--photo-gap)) / 1.79));   /* main 4:3 + column .46 × height = full width */
    height: var(--h);
    grid-template-columns: auto calc(var(--h) * .46);
    justify-content: space-between;
  }
  .project.side-fit .proj-hero { max-width: none; }
  .project.side-fit .proj-thumbs .track > button img,
  .project.side-fit .proj-thumbs .track > button video { object-fit: contain; }
}

/* "Read again" (+ circular arrow): pops up in place of > on the back cover of every flip-through book */
.bk-nav .bk-again {
  border: 1px solid currentColor; border-radius: 999px; padding: 3px 12px; font-weight: 400;
  animation: bk-pop .45s cubic-bezier(.2, 1.6, .4, 1) both;
}
.bk-nav .bk-again:hover { background: var(--ink, #000); color: var(--bg, #fff); }
.bk-nav .bk-again[hidden] { display: none; }
.bk-nav .bk-again { display: inline-flex; align-items: center; gap: .45em; }
.bk-nav .bk-again svg { width: 1.05em; height: 1.05em; }
@keyframes bk-pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
.bk-book.bk-fade { opacity: 0; transition: opacity .3s ease, transform 0s; }   /* faded out: jumps to the cover without sliding */
