/* Tokens (colours, grid, fonts) live in tokens.css. */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: var(--frame-line);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: text-decoration-color 0.2s;
}

a:hover {
  text-decoration-color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ── Canvas ─────────────────────────────────────────────── */

.canvas {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overflow: clip; /* never scrollable, not even by focus: app.js pans instead */
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.canvas.is-dragging {
  cursor: grabbing;
}

.canvas.is-dragging a {
  pointer-events: none;
}

/* Graph paper: fine lines every --grid-minor, stronger ones every --grid-major.
   app.js moves it with --gx / --gy so it pans with the content. In the list
   layout the page scrolls over the same paper, drawn on the body instead. */
.grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-position: var(--gx, 0) var(--gy, 0);
}

.grid,
[data-layout="list"] body {
  background-image:
    linear-gradient(to right, var(--line-major) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line-major) 1px, transparent 1px),
    linear-gradient(to right, var(--line-minor) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line-minor) 1px, transparent 1px);
  /* scaled with the canvas zoom (app.js sets --zoom on the grid; 1 elsewhere) */
  background-size:
    calc(var(--grid-major) * var(--zoom, 1)) calc(var(--grid-major) * var(--zoom, 1)),
    calc(var(--grid-major) * var(--zoom, 1)) calc(var(--grid-major) * var(--zoom, 1)),
    calc(var(--grid-minor) * var(--zoom, 1)) calc(var(--grid-minor) * var(--zoom, 1)),
    calc(var(--grid-minor) * var(--zoom, 1)) calc(var(--grid-minor) * var(--zoom, 1));
}

.item {
  position: absolute;
  top: 0;
  left: 0;
  z-index: var(--z-items);
  transform-origin: 0 0; /* the canvas zoom (app.js sets scale) grows from the top left */
  will-change: translate, transform;
}

/* Once zooming stops, app.js drops the layer hint for two frames, so the
   browser draws the scaled items sharp again instead of stretching them. */
.canvas.is-rerastering :is(.item, .sticker-art, .sticker-art img) {
  will-change: auto;
}

/* ── Intro ──────────────────────────────────────────────── */

.intro {
  width: min(calc(100vw - 48px), 600px);
  text-align: center;
}

/* PP Mondwest (Pangram Pangram) for the intro heading. */
@font-face {
  font-family: "PP Mondwest";
  src: url("assets/fonts/PPMondwest-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

.intro h1 {
  font-family: "PP Mondwest", var(--font-sans);
  font-size: clamp(1.75rem, 1.3rem + 1.7vw, 2.5rem);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0;
  text-wrap: balance;
}

.intro-sub {
  max-width: 40ch;
  margin: 20px auto 0;
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--ink-soft);
  text-wrap: balance; /* even lines: "pretty" left "my work." on a line of its own */
}

/* The about view drops the subtext. app.js still centres the intro as if it
   were there, so the heading doesn't move between the views; the about
   items beside the paragraphs were moved up by its height (100) to match. */
[data-view="about"] .intro-sub {
  display: none;
}

.intro-sub a {
  color: var(--ink);
  cursor: pointer;
}

.about-toggle {
  margin-top: 28px;
  padding: 10px 16px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s var(--ease-out);
}

.about-toggle:active {
  transform: scale(0.98);
}

.about-toggle[aria-expanded="true"] {
  background: var(--sheet);
  border-color: var(--frame-line);
  color: var(--ink);
}

.intro-hint {
  margin-top: 28px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-soft);
  transition: opacity 0.6s;
}

.intro-hint.is-done {
  opacity: 0;
}

/* ── Work placeholders ──────────────────────────────────── */

.work {
  width: calc(var(--w) * var(--s) * 1px);
}

.frame {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: var(--ar); /* fallback; app.js sets a height in whole grid cells */
  overflow: hidden;
  isolation: isolate; /* its edge line (::after) stays on top of what's inside */
  border-radius: var(--radius);
  background-color: var(--sheet);
  /* crossed diagonals: the usual "image goes here" mark */
  background-image:
    linear-gradient(to top right, transparent calc(50% - 0.5px), var(--frame-line) 50%, transparent calc(50% + 0.5px)),
    linear-gradient(to bottom right, transparent calc(50% - 0.5px), var(--frame-line) 50%, transparent calc(50% + 0.5px));
  box-shadow: var(--shadow);
  transition: transform 0.5s var(--ease-out);
}

/* The edge: a transparent black line drawn over the image, so it darkens
   the image's own edge. A border sat on the frame's paper-white background
   instead and showed as a light line around dark images. */
.frame::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 10;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--frame-edge);
  pointer-events: none;
}

.folder-tile::after {
  content: none;
}

.frame img,
.frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  -webkit-user-drag: none;
}

/* A film shows only while it plays; at rest its still (the poster, an
   image app.js puts under it) shows instead. */
.frame .film-still + video:not(.is-live) {
  visibility: hidden;
}

.frame-size {
  padding: 6px 10px;
  border-radius: var(--radius);
  background: var(--sheet);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.work figcaption {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 12px;
  font-size: 0.875rem;
  line-height: 1.4;
}

/* a project with a case study: the whole tile leads to it (app.js) */
.work:has(a.frame) {
  cursor: pointer;
}

.work figcaption strong {
  font-weight: 500;
}

.work figcaption span {
  color: var(--ink-soft);
}

/* On the canvas, hovering a tile scales it up, preview and caption as one,
   so the preview grows by half a grid cell on each side, and its shadows
   change as if it lifts off the paper (below). app.js sets
   --grow from the tile's width and --fh, the preview's height. The
   translates make it grow from its centre: the item's own transform-origin
   is its top left, for the canvas zoom. It also parallaxes with the mouse
   (--px and --py, -1 to 1, set by app.js): the whole tile drifts a few
   pixels towards the pointer and leans up to 2 degrees towards it, as one
   object. Only transform and opacity change,
   so the browser can run it without repainting (animating the box-shadow
   itself stuttered). Folders scale, lean and drift the same way, on top of
   their own hover (the cards fanning out); they have no shadows. (.canvas
   in the selector so it beats .item[data-view]'s fade-only transition.) */
.canvas .item.work {
  transition:
    opacity 0.45s ease,
    visibility 0.45s,
    transform 0.45s var(--ease-out);
}

html:not([data-layout="list"]) .item.work::before,
html:not([data-layout="list"]) .item.work:not([data-folder])::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  z-index: -1;
  width: 100%;
  height: var(--fh, 0);
  border-radius: var(--radius);
  pointer-events: none;
}

/* Lifting, as a card off a table: two shadows under the preview. The
   contact shadow (::after, the frame's usual light one) is tight under the
   card at rest and thins as it rises. The cast shadow (::before) is wide and
   soft: at rest it sits tucked under the card, and as the card rises it
   drops down and spreads. (It used to lag the parallax too, but that left
   a strip of bare paper under the card that read as a white rim.) Only
   transform and opacity move, nothing repaints. */
html:not([data-layout="list"]) .item.work:not([data-folder])::after {
  box-shadow: var(--shadow);
  transition: opacity 0.45s var(--ease-out);
}

/* The cast shadow: darkness and colour kept apart, so every tile's shadow
   is equally dark whatever its colour. The darkness is one neutral warm
   shadow, the same on every tile (--shadow-ink). The colour is a wash of
   the tile's hue on top (--shadow-hue on each tile in index.html, worked
   out from its --tint: its hue at one mid lightness, with some saturation),
   light enough to add colour without adding darkness. Tiles without one
   (SLV Club, the folders) get the neutral shadow only. (Matching dark
   tinted shadows to each other by brightness didn't work: the greyer ones
   still read darker than the colourful ones.) */
.item.work {
  --shadow-ink: 70, 58, 40;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .item.work {
    --shadow-ink: 0, 0, 0;
  }
}

:root[data-theme="dark"] .item.work {
  --shadow-ink: 0, 0, 0;
}

html:not([data-layout="list"]) .item.work::before {
  box-shadow:
    0 2px 4px rgba(var(--shadow-ink), 0.05),
    0 8px 16px -4px rgba(var(--shadow-ink), 0.08),
    0 28px 56px -16px rgba(var(--shadow-ink), 0.22),
    0 28px 56px -16px color-mix(in srgb, var(--shadow-hue, transparent) 32%, transparent);
  opacity: 0;
  transform: translateY(-18px) scale(0.92);
  transform-origin: 50% 0;
  /* the card's own timing (.item.work), so shadow and lift move together */
  transition:
    transform 0.45s var(--ease-out),
    opacity 0.45s var(--ease-out);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-layout="list"]) .item.work::before {
    box-shadow:
      0 2px 4px rgba(0, 0, 0, 0.2),
      0 8px 16px -4px rgba(0, 0, 0, 0.3),
      0 28px 56px -16px rgba(0, 0, 0, 0.55),
      0 28px 56px -16px color-mix(in srgb, var(--shadow-hue, transparent) 18%, transparent);
  }
}

:root[data-theme="dark"]:not([data-layout="list"]) .item.work::before {
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.2),
    0 8px 16px -4px rgba(0, 0, 0, 0.3),
    0 28px 56px -16px rgba(0, 0, 0, 0.55),
    0 28px 56px -16px color-mix(in srgb, var(--shadow-hue, transparent) 18%, transparent);
}

/* Behind the image a frame is paper-white. When a tile scales and tilts,
   the image's edge is antialiased and that white can show through along
   dark tiles, so a tinted tile's frame is filled with its own colour. */
.item.work[style*="--tint"] .frame {
  background: var(--tint);
}

/* On the canvas the contact shadow takes over from the frame's own. */
/* A folder's cast shadow sits under its body (the back panel, 13% to 97%
   of the frame), not under the empty space above it. It has no contact
   shadow: at rest the folder has none of its own. */
html:not([data-layout="list"]) .item.work[data-folder]::before {
  top: calc(var(--fh, 0px) * 0.13);
  height: calc(var(--fh, 0px) * 0.84);
  border-radius: 12px;
}

html:not([data-layout="list"]) .item.work:not([data-folder]) .frame {
  box-shadow: none;
}

/* (In the list, ::before shows a tile's year and ::after its tags instead,
   so the shadow rules are scoped to the canvas.) */

@media (hover: hover) {
  html:not([data-layout="list"]) .canvas:not(.is-dragging) .work:hover {
    z-index: calc(var(--z-items) + 1);
    transform: translate(calc(var(--px, 0) * 5px), calc(var(--py, 0) * 5px)) translate(50%, 50%)
      perspective(1200px) rotateX(calc(var(--py, 0) * -2deg)) rotateY(calc(var(--px, 0) * 2deg))
      scale(var(--grow, 1.04)) translate(-50%, -50%);
  }

  html:not([data-layout="list"]) .canvas:not(.is-dragging) .work:hover::before {
    opacity: 1;
    transform: none;
  }

  html:not([data-layout="list"]) .canvas:not(.is-dragging) .work:not([data-folder]):hover::after {
    opacity: 0.6;
  }
}

/* ── Folder tile: a group of small projects, drawn as a folder ── */

/* No slide of its own: the frame is see-through and the folder sits in it. A back
   panel with a tab, cards sticking out of it, and a frosted-glass flap over
   their lower half, so the marks show through it blurred. Sizes are in container units, so it scales with the tile. On hover the
   cards lift and fan out and the flap tips forward. */
.folder-tile {
  border: 0;
  background: none;
  box-shadow: none;
  overflow: visible;
  container-type: size;
  perspective: 900px;
}

.folder-back,
.folder-front {
  position: absolute;
  left: 0; /* flush with the caption below */
  right: 0;
  bottom: 3%;
  border-radius: 3.5cqw;
}

.folder-back {
  top: 13%;
  border-top-left-radius: 0;
  background: color-mix(in srgb, var(--ink) 13%, var(--sheet));
}

/* the tab */
.folder-back::before {
  content: "";
  position: absolute;
  left: 0;
  bottom: 100%;
  width: 36%;
  height: 8cqh;
  border-radius: 3cqw 5cqw 0 0;
  background: inherit;
}

.frame .folder-card {
  inset: auto;
  left: calc(8% + var(--i) * 6%);
  top: calc(29% - var(--i) * 2%); /* low enough that the back's top edge shows above them */
  width: 66%; /* tall enough to run well down behind the flap */
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: 1.6cqw;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 6px 18px -6px rgba(0, 0, 0, 0.3);
  rotate: calc((var(--i) - 1.5) * 4deg);
  transition: translate 0.6s var(--ease-out), rotate 0.6s var(--ease-out);
}

.folder-front {
  top: 44%;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: color-mix(in srgb, var(--sheet) 45%, transparent);
  -webkit-backdrop-filter: blur(12px) saturate(1.3);
  backdrop-filter: blur(12px) saturate(1.3);
  box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.2) inset, var(--shadow);
  transform-origin: 50% 100%;
  transition: transform 0.6s var(--ease-out);
}

@media (hover: hover) {
  .canvas:not(.is-dragging) .work:hover .folder-tile {
    transform: none;
  }

  .canvas:not(.is-dragging) .work:hover .folder-card {
    /* a fan: spread out, the middle two highest */
    translate: calc((var(--i) - 1.5) * 13cqw) calc(-20cqh + (var(--i) - 1.5) * (var(--i) - 1.5) * 3cqh);
    rotate: calc((var(--i) - 1.5) * 8deg);
  }

  .canvas:not(.is-dragging) .work:hover .folder-front {
    transform: rotateX(-18deg);
  }
}

/* ── VICO tile: the wordmark, retraced on hover (app.js adds .is-playing) ── */

.vico-tile {
  background: #ff4200;
}

.vico-mark {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.vico-mark path {
  fill: none;
  stroke-width: var(--line, 8); /* app.js keeps the lines about 1.5 screen px */
}

.vm-raster path { stroke: #ff7030; }
.vm-letters path { stroke: #fff; }

@media (prefers-reduced-motion: no-preference) {
  .vico-tile.is-playing .vm-letters path {
    stroke-dasharray: var(--len);
    animation: vico-trace 1.1s var(--d) cubic-bezier(0.45, 0, 0.55, 1) both;
  }
}

@keyframes vico-trace {
  from { stroke-dashoffset: var(--len); }
  to { stroke-dashoffset: 0; }
}

/* ── Work / about views ─────────────────────────────────── */

.item[data-view] {
  transition: opacity 0.45s ease, visibility 0.45s;
}

.canvas[data-view="work"] .item[data-view="about"],
.canvas[data-view="about"] .item[data-view="work"] {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Filtered-out work, and all of the work for a moment while it is re-dealt. */
.item.is-filtered,
.canvas.is-filtering .item[data-view="work"] {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition-delay: 0s;
}

/* the incoming set arrives one by one */
.canvas[data-view="work"] .item[data-view="work"],
.canvas[data-view="about"] .item[data-view="about"] {
  transition-delay: calc(var(--j, 0) * 35ms + 150ms);
}

/* The stagger is for the fade only: a tile's hover scale (its third
   transition) starts at once. */
.canvas[data-view="work"]:not(.is-filtering) .item.work:not(.is-filtered) {
  transition-delay: calc(var(--j, 0) * 35ms + 150ms), calc(var(--j, 0) * 35ms + 150ms), 0s;
}

/* ── About text ─────────────────────────────────────────── */

/* Titled paragraphs: each title set large, the text under it in body size. */
.about-text {
  margin-top: 72px;
  padding-bottom: 40px;
  text-align: left;
}

.about-text[hidden] {
  display: none;
}

.qa + .qa {
  margin-top: 64px;
}

.qa h2,
.stickers-title {
  font-size: 1.75rem;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.qa p {
  max-width: 52ch;
  margin-top: 12px;
  font-size: 1.125rem;
  line-height: 1.5;
  color: var(--ink-soft);
  text-wrap: pretty;
}

/* The full client list is for screen readers; sighted visitors get the grid. */
.clients {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Six cells, three by two, that sit on the canvas grid: every cell is
   10 x 5 grid squares, so on desktop every hairline lies on a major grid line
   (app.js nudges the block onto the grid with its margins). The block itself
   is see-through: its 1px gaps are the real major grid lines showing between
   the cells. The cells are the paper colour, so they blank out the fine grid
   underneath the logos. */
.logos {
  --cell-w: calc(var(--grid-minor) * 10);
  --cell-h: calc(var(--grid-minor) * 5);
  --columns: 3;
  display: grid;
  grid-template-columns: repeat(var(--columns), calc(var(--cell-w) - 1px));
  grid-auto-rows: calc(var(--cell-h) - 1px);
  gap: 1px;
  width: fit-content;
  margin-top: 16px; /* replaced by app.js */
  padding: 1px; /* the outer hairline */
}

.logo-cell {
  display: grid;
  place-items: center;
  background: var(--paper);
}

.logo {
  display: block;
  width: var(--w);
  height: var(--h);
  max-width: 80%;
  background: var(--ink);
  -webkit-mask: var(--src) center / contain no-repeat;
  mask: var(--src) center / contain no-repeat;
  transition: opacity 0.6s ease;
}

.logo.is-out {
  opacity: 0;
}

.about-mail {
  display: block;
  width: fit-content;
  margin-top: 6px;
  font-size: 1.75rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.03em;
  color: var(--ink);
  cursor: pointer;
}

/* The close: a card, with the email on a button. */
.qa-cta {
  padding: 32px;
  border: 1px solid var(--frame-line);
  border-radius: var(--radius);
  background: var(--sheet);
  box-shadow: var(--shadow);
}

.cta-mail {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
  padding: 12px 18px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s var(--ease-out);
}

.cta-mail svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: translate 0.3s var(--ease-out);
}

.cta-mail:hover svg {
  translate: 3px 0;
}

.cta-mail:active {
  transform: scale(0.98);
}

@media (max-width: 699px) {
  .qa h2,
  .stickers-title,
  .about-mail {
    font-size: 1.375rem;
  }

  .qa-cta {
    padding: 24px 20px;
  }

  /* Two columns, each half the page wide and four squares tall, so the block runs
     from edge to edge and every hairline is a line of the paper (tokens.css fits
     the paper to the page on phones; app.js puts the block's top on a line). The
     cells land on fine lines, so the major line colour is laid over them. */
  .logos {
    --cell-w: calc(var(--grid-minor) * var(--grid-half));
    --cell-h: calc(var(--grid-y) * 4);
    --columns: 2;
    background: var(--line-major);
  }
}



/* ── About widgets ──────────────────────────────────────── */

.widget {
  display: flex;
  flex-direction: column;
  width: calc(var(--w) * 1px);
  padding: 20px;
  border: 1px solid var(--frame-line);
  border-radius: var(--radius);
  background: var(--sheet);
  box-shadow: var(--shadow);
  font-size: 0.9375rem;
  line-height: 1.45;
}

.widget img {
  display: block;
  width: 100%;
  height: auto;
  -webkit-user-drag: none;
}

.widget-photo img {
  border-radius: calc(var(--radius) - 2px);
}

.widget-quote {
  background: color-mix(in srgb, var(--accent) 9%, var(--sheet));
}

.widget-quote blockquote {
  font-size: 1.0625rem;
  line-height: 1.4;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}

.widget-quote figcaption {
  display: flex;
  flex-direction: column;
  margin-top: auto;
  padding-top: 16px;
  font-size: 0.8125rem;
}

.widget-quote figcaption strong {
  font-weight: 500;
}

.widget-quote figcaption span {
  color: var(--ink-soft);
}

.widget-photo,
.widget-map {
  padding: 10px;
}

.widget-map .map {
  position: relative;
  overflow: hidden;
  border-radius: calc(var(--radius) - 2px);
}

/* greyscale and colour map stacked; hovering the card fades the colour in */
.widget-map .map {
  display: grid;
}

.widget-map .map img {
  grid-area: 1 / 1;
}

.map-color {
  opacity: 0;
  transition: opacity 0.35s ease;
}

.canvas:not(.is-dragging) .widget-map:hover .map-color {
  opacity: 1;
}

/* a teardrop whose tip sits on --x / --y of the map */
.map-pin {
  position: absolute;
  left: var(--x, 50%);
  top: var(--y, 50%);
  width: 26px;
  height: 26px;
  margin: -32px 0 0 -13px;
  border-radius: 50% 50% 50% 0;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--sheet);
  rotate: -45deg;
}

.map-pin::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: var(--sheet);
}

.widget-map figcaption {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: auto 0;
  padding: 10px 2px 2px;
  font-size: 0.875rem;
}

.widget-map figcaption strong {
  font-weight: 500;
}

.widget-map figcaption span {
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.widget-map time {
  font-variant-numeric: tabular-nums;
}

/* the colon ticks: on for half a second, off for half a second */
@media (prefers-reduced-motion: no-preference) {
  .widget-map time .colon {
    animation: colon-tick 1s steps(1, end) infinite;
  }

  @keyframes colon-tick {
    50% {
      opacity: 0;
    }
  }
}

.widget-photo figcaption {
  margin: auto 0;
  padding: 10px 2px 2px;
  font-size: 0.8125rem;
  color: var(--ink-soft);
}

.widget-photo figcaption a {
  color: var(--ink);
  cursor: pointer;
}

/* Stickers ignore the grid: loose, slightly tilted cut-outs. Each holds a
   greyscale and a colour image stacked; hover or focus fades the colour in. */
.item.sticker {
  width: calc(var(--w) * 1px);
}

/* What the pointer hovers is the sticker as it rests (turned by --r), not
   its art: on hover the art turns the other way, grows and drifts, and at
   its edge that took it out from under the pointer, which ended the hover,
   which brought it back, over and over. */
.item.sticker::after {
  content: "";
  position: absolute;
  inset: 0;
  rotate: var(--r, 0deg);
}

.item.sticker .sticker-art {
  pointer-events: none;
}

.sticker-art {
  display: grid;
  rotate: var(--r, 0deg);
  filter: drop-shadow(0 6px 10px rgba(70, 58, 40, 0.16));
  transition: rotate 0.5s var(--ease-out), scale 0.5s var(--ease-out), transform 0.45s var(--ease-out);
}

.sticker-art img {
  grid-area: 1 / 1;
  width: 100%;
  height: auto;
  -webkit-user-drag: none;
}

.sticker-color {
  opacity: 0;
  transition: opacity 0.35s ease;
}

/* Kept on layers of their own, not only while they animate: in dark mode the
   art has an outline and the grey a brightness filter, and the browser drew
   those slightly differently each time a hover promoted and dropped the
   layers, so the stickers flickered as the tilt and fade began and ended. */
.sticker-art {
  will-change: rotate, scale, transform;
}

.sticker-art img {
  will-change: opacity;
}

/* The tip has no box of its own. app.js measures the wrapped lines and draws
   one outline around them (.tip-shape), so the dark shape steps in and out
   with the text: outer corners rounded, no corners where two lines meet. */
.sticker-tip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 12px);
  isolation: isolate;
  width: max-content;
  max-width: 232px; /* app.js may pick another width to get a cleaner wrap */
  padding: 3px 12px; /* matches TIP.padX / TIP.padY in app.js */
  font-size: 0.8125rem;
  line-height: 20px;
  color: var(--paper);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  translate: calc(-50% + var(--shift, 0px)) 6px; /* --shift: app.js keeps it on screen */
  transition: opacity 0.25s ease, translate 0.35s var(--ease-out);
}

/* In the list, a sticker with no room above it (right under the bar) gets
   its tip underneath (app.js). */
.sticker-tip.is-below {
  top: calc(100% + 12px);
  bottom: auto;
  translate: calc(-50% + var(--shift, 0px)) -6px;
}

.tip-shape {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: var(--ink);
}

/* The fortune cookie: two pairs of images, closed and open, stacked like the
   others; .is-open (app.js) shows the open pair. Cracking pops it, throws a
   few crumbs and unrolls a paper slip with the fortune underneath. */
.fortune-cookie {
  cursor: pointer;
}

.cookie-open,
.fortune-cookie.is-open .cookie-closed {
  visibility: hidden;
}

.fortune-cookie.is-open .cookie-open {
  visibility: visible;
}

.fortune-cookie.is-cracking .sticker-art {
  animation: cookie-pop 0.45s var(--ease-out);
}

@keyframes cookie-pop {
  30% { scale: 1.16; }
}

.cookie-crumbs {
  position: absolute;
  left: 50%;
  top: 45%;
  pointer-events: none;
}

.cookie-crumbs i {
  position: absolute;
  width: 6px;
  height: 5px;
  border-radius: 40%;
  background: #c8893f;
  opacity: 0;
}

.fortune-cookie.is-cracking .cookie-crumbs i {
  animation: cookie-crumb 0.7s cubic-bezier(0.2, 0.6, 0.4, 1) both;
}

.cookie-crumbs i:nth-child(1) { --dx: -46px; --dy: 18px; }
.cookie-crumbs i:nth-child(2) { --dx: -24px; --dy: 34px; width: 4px; height: 4px; }
.cookie-crumbs i:nth-child(3) { --dx: 4px; --dy: 40px; }
.cookie-crumbs i:nth-child(4) { --dx: 30px; --dy: 30px; width: 4px; height: 3px; }
.cookie-crumbs i:nth-child(5) { --dx: 50px; --dy: 12px; }
.cookie-crumbs i:nth-child(6) { --dx: -12px; --dy: 24px; width: 3px; height: 3px; }
.cookie-crumbs i:nth-child(7) { --dx: 18px; --dy: 46px; width: 3px; height: 3px; }

@keyframes cookie-crumb {
  0% { opacity: 1; translate: 0 0; }
  70% { opacity: 1; }
  100% { opacity: 0; translate: var(--dx) var(--dy); }
}

.cookie-slip {
  position: absolute;
  left: 50%;
  top: calc(100% + 6px);
  width: 210px;
  padding: 8px 12px;
  border-radius: 2px;
  background: #fffdf6;
  box-shadow: 0 1px 2px rgba(70, 58, 40, 0.2), 0 6px 14px -6px rgba(70, 58, 40, 0.25);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.45;
  color: #23221f;
  text-align: center;
  translate: -50% 0;
  rotate: -2deg;
  transform-origin: 50% 50%;
  visibility: hidden;
  pointer-events: none;
}

.fortune-cookie.is-open .cookie-slip {
  visibility: visible;
}

.fortune-cookie.is-cracking .cookie-slip {
  animation: cookie-slip 0.5s 0.15s var(--ease-out) both;
}

@keyframes cookie-slip {
  from { scale: 0.1 1; opacity: 0; }
}

/* In the list the fortune is the sticker's tooltip instead. */
[data-layout="list"] .cookie-slip {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .fortune-cookie.is-cracking :is(.sticker-art, .cookie-crumbs i, .cookie-slip) {
    animation: none;
  }
}

/* On the canvas a sticker answers to :hover and focus. In the list app.js
   picks it instead (.is-picked: pointed at, tapped or tabbed to), since
   :hover sticks after a tap on a touch screen. Either way it lifts, takes
   its colour and shows its tip. */
html:not([data-layout="list"]) .canvas:not(.is-dragging) .sticker:is(:hover, :focus-visible),
[data-layout="list"] .sticker.is-picked {
  z-index: calc(var(--z-items) + 1);
}

html:not([data-layout="list"]) .canvas:not(.is-dragging) .sticker:is(:hover, :focus-visible) .sticker-art,
[data-layout="list"] .sticker.is-picked .sticker-art {
  rotate: calc(var(--r, 0deg) * -1);
  scale: 1.06;
}

/* and drifts and leans towards the mouse (--px and --py, -1 to 1, set by app.js) */
.canvas:not(.is-dragging) .sticker:hover .sticker-art {
  transform: translate(calc(var(--px, 0) * 3px), calc(var(--py, 0) * 3px)) perspective(600px)
    rotateX(calc(var(--py, 0) * -2deg)) rotateY(calc(var(--px, 0) * 2deg));
}

/* A sheen over the colour, cut to the sticker's shape (app.js adds it with
   the colour image as --mask), its highlight under the mouse. */
.sticker-sheen {
  grid-area: 1 / 1;
  background: radial-gradient(
    circle at var(--sheen-x, 50%) var(--sheen-y, 30%),
    rgba(255, 255, 255, 0.27),
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  -webkit-mask: var(--mask) center / 100% 100% no-repeat;
  mask: var(--mask) center / 100% 100% no-repeat;
  mix-blend-mode: overlay;
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

.canvas:not(.is-dragging) .sticker:hover .sticker-sheen {
  opacity: 1;
}

[data-layout="list"] .sticker-sheen {
  display: none;
}

html:not([data-layout="list"]) .canvas:not(.is-dragging) .sticker:is(:hover, :focus-visible) .sticker-color,
[data-layout="list"] .sticker.is-picked .sticker-color {
  opacity: 1;
}

html:not([data-layout="list"]) .canvas:not(.is-dragging) .sticker:is(:hover, :focus-visible) .sticker-tip,
[data-layout="list"] .sticker.is-picked .sticker-tip {
  opacity: 1;
  translate: calc(-50% + var(--shift, 0px)) 0;
}

/* Dark theme: the greyscale cut-outs need lifting off the dark paper. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sticker-art {
    filter: drop-shadow(0 0 1px rgba(236, 232, 223, 0.55)) drop-shadow(0 6px 10px rgba(0, 0, 0, 0.5));
  }

  :root:not([data-theme="light"]) .sticker-grey {
    filter: brightness(1.25);
  }
}

:root[data-theme="dark"] .sticker-art {
  filter: drop-shadow(0 0 1px rgba(236, 232, 223, 0.55)) drop-shadow(0 6px 10px rgba(0, 0, 0, 0.5));
}

:root[data-theme="dark"] .sticker-grey {
  filter: brightness(1.25);
}

/* ── Fixed UI ───────────────────────────────────────────── */

.bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-ui);
  display: grid;
  grid-template-columns: 1fr auto 1fr; /* name, filter, links: the filter stays centred */
  align-items: center;
  gap: 8px;
  padding: 12px;
  font-size: 0.875rem;
  pointer-events: none;
}

/* A fade behind the chips: paper at the top of the screen, gone a little
   below the bar, so what scrolls or pans underneath dissolves into it. The
   stops follow an ease, so there is no visible edge where the fade begins. */
.bar::before {
  content: "";
  position: absolute;
  inset: 0 0 -40px;
  z-index: -1;
  background: linear-gradient(
    var(--paper) 0%,
    color-mix(in srgb, var(--paper) 97%, transparent) 18%,
    color-mix(in srgb, var(--paper) 90%, transparent) 32%,
    color-mix(in srgb, var(--paper) 78%, transparent) 45%,
    color-mix(in srgb, var(--paper) 62%, transparent) 57%,
    color-mix(in srgb, var(--paper) 45%, transparent) 68%,
    color-mix(in srgb, var(--paper) 28%, transparent) 78%,
    color-mix(in srgb, var(--paper) 13%, transparent) 88%,
    color-mix(in srgb, var(--paper) 4%, transparent) 95%,
    color-mix(in srgb, var(--paper) 0%, transparent) 100%
  );
  pointer-events: none;
}

.bar > .bar-name {
  justify-self: start;
}

.bar > .bar-links {
  justify-self: end;
}

/* Plain text, no chips: the fade behind the bar keeps the labels readable
   when a shot passes underneath. Padded like the pill, so they line up. */
.bar-name,
.bar > .bar-links {
  padding: 8px;
}

.bar a,
.bar button {
  pointer-events: auto;
}

/* An icon: a moon to switch to dark, a sun to switch to light (set by the script). */
.theme-toggle {
  display: grid;
  place-items: center;
  align-self: center;
  margin: -4px;
  padding: 4px; /* a bigger target than the icon */
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: color 0.2s;
}

.theme-toggle:hover {
  color: var(--accent);
}

.theme-toggle svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The name as a wordmark: the sans, bold. */
.bar-name {
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.bar-links {
  display: flex;
  gap: 20px;
}

/* One segmented pill: the work filter and "About me", and, after a hairline,
   the canvas / list switch (not on phones: they always get the list). */
.controls {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--frame-line);
  border-radius: var(--radius);
  background: var(--sheet);
}

.filter,
.layout-switch {
  position: relative; /* for the thumb */
  display: flex;
  gap: 2px;
}

/* The active state is one dark thumb per group that slides to the pressed
   button (app.js places it); the buttons sit on top of it. */
.toggle-thumb {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: calc(var(--radius) - 2px);
  background: var(--ink);
  pointer-events: none;
}

.toggle-thumb.is-placed {
  transition:
    translate 0.35s var(--ease-out),
    width 0.35s var(--ease-out);
}

.layout-switch {
  margin-left: 3px;
  padding-left: 6px;
}

/* The hairlines in the pill are 50% of its height, centred. Their box is
   the button height; the pill adds 3px of padding and 1px of border a side. */
.layout-switch::before {
  content: "";
  position: absolute;
  top: 50%;
  height: calc((100% + 8px) * 0.5);
  translate: 0 -50%;
  left: 0;
  width: 1px;
  background: var(--frame-line);
}

/* "About" (last) is a view, not a filter: a hairline sets it apart. It
   stays in the filter's group, so the thumb slides across to it. */
.filter [data-show="about"] {
  margin-left: 8px;
}

.filter [data-show="about"]::before {
  content: "";
  position: absolute;
  top: 50%;
  height: calc((100% + 8px) * 0.5);
  translate: 0 -50%;
  left: -6px;
  width: 1px;
  background: var(--frame-line);
}

.controls .layout-switch button {
  display: grid;
  place-items: center;
  padding-inline: 7px;
}

.layout-switch svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.25;
  stroke-linecap: round;
}

.controls button {
  position: relative; /* above the thumb */
  white-space: nowrap;
  padding: 5px 10px;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: none;
  color: var(--ink-soft);
  font: inherit;
  cursor: pointer;
  transition: color 0.25s;
}

.controls button:hover {
  color: var(--ink);
}

.controls button[aria-pressed="true"] {
  color: var(--paper);
}

/* Phones: name and links share the bar; the filter lives in the page, under
   the intro (app.js moves it there), and sticks once scrolled past. */
@media (max-width: 699px) {
  .bar {
    grid-template-columns: auto 1fr;
  }

  html[data-layout="list"] .bar {
    position: relative;
  }

  html[data-layout="list"] .bar::before {
    display: none; /* the bar scrolls away with the page here */
  }

  .canvas > .controls {
    font-size: 0.875rem; /* as in the bar, not the page's body size */
    position: sticky;
    top: calc(8px + env(safe-area-inset-top));
    z-index: var(--z-ui);
    grid-column: 1 / -1;
    justify-self: center;
    margin-top: -40px; /* close under the about button, not a whole row gap away */
    box-shadow: var(--shadow);
  }

  .layout-switch {
    display: none;
  }

  /* "About" in the pill, which is always in view on phones, does its job. */
  .about-toggle {
    display: none;
  }
}

.recenter {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: var(--z-ui);
  padding: 10px 16px;
  border: 1px solid var(--frame-line);
  border-radius: var(--radius);
  background: var(--sheet);
  box-shadow: var(--shadow);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  white-space: nowrap;
  cursor: pointer;
  transform: translateX(-50%);
  transition: opacity 0.3s, transform 0.3s var(--ease-out), visibility 0.3s;
}

.recenter[hidden] {
  display: block;
  visibility: hidden;
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
}

.recenter:active {
  transform: translateX(-50%) scale(0.98);
}

/* Zoom control, bottom right: − 100% +. The percentage resets. */
.zoom {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: var(--z-ui);
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--frame-line);
  border-radius: var(--radius);
  background: var(--sheet);
  box-shadow: var(--shadow);
  font-size: 0.875rem;
}

.zoom button {
  min-width: 30px;
  padding: 5px 8px;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: none;
  color: var(--ink-soft);
  font: inherit;
  cursor: pointer;
  transition: color 0.2s, background-color 0.2s;
}

.zoom button:hover:not(:disabled) {
  color: var(--ink);
  background: color-mix(in srgb, var(--ink) 6%, transparent);
}

.zoom button:disabled {
  opacity: 0.35;
  cursor: default;
}

.zoom .zoom-level {
  min-width: 52px;
  font-variant-numeric: tabular-nums;
}

[data-layout="list"] .zoom {
  display: none;
}

/* ── List layout ────────────────────────────────────────── */

/* The same items, as a normal scrolling page: app.js stops placing them and
   the page scrolls instead of the camera. Phones always get this; elsewhere
   it is the list button. html[data-layout] is set before first paint. */
[data-layout="list"],
[data-layout="list"] body {
  height: auto;
  overflow: visible;
  overflow-x: clip; /* nothing widens the page: not the full-width rows, not a tooltip at the edge */
  overscroll-behavior: auto;
}

html:not([data-layout="list"]) .list-only,
[data-layout="list"] .canvas-only,
[data-layout="list"] .grid,
[data-layout="list"] .recenter,
[data-layout="list"] .intro-hint {
  display: none;
}

/* Wrappers that only group items for the list: invisible to the canvas. */
.quotes,
.stickers {
  display: contents;
}

/* The bar scrolls with the page but sticks. Not on phones: there it scrolls
   away, and the filter (moved into the page) is what sticks. */
[data-layout="list"] .bar {
  position: sticky;
  top: 0; /* no backdrop: the chips float over the page, as on the canvas */
}

[data-layout="list"] .canvas {
  position: relative;
  inset: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 40px 16px;
  max-width: 992px;
  margin: 0 auto;
  padding: 40px 16px 120px;
  overflow: visible;
  cursor: auto;
  touch-action: auto;
  user-select: auto;
  -webkit-user-select: auto;
}

[data-layout="list"] .canvas[data-view="about"] {
  max-width: 632px;
  row-gap: 56px;
}

[data-layout="list"] .item {
  position: static;
  grid-column: 1 / -1;
  width: auto;
  min-width: 0;
  will-change: auto; /* would make the fixed hover previews fixed to the row */
}

/* The other view, and filtered-out work, take no room at all. */
[data-layout="list"] .canvas[data-view="work"] :is(.item[data-view="about"], .quotes, .stickers),
[data-layout="list"] .canvas[data-view="about"] .item[data-view="work"],
[data-layout="list"] .canvas .item.is-filtered {
  display: none;
}

/* The intro and the about text dissolve into the page grid, so the widgets
   can be ordered in between the questions. */
[data-layout="list"] .intro,
[data-layout="list"] .about-text:not([hidden]) {
  display: contents;
}

[data-layout="list"] .intro-main {
  grid-column: 1 / -1;
  justify-self: center;
  max-width: 600px;
  margin-bottom: 24px;
  text-align: center;
}

[data-layout="list"] .qa {
  grid-column: 1 / -1;
  order: 3;
}

[data-layout="list"] .qa + .qa {
  margin-top: 0;
}

/* About, top to bottom: intro (order 0, like the work), photo and map side
   by side, the questions, the quotes, the sticker sheet, and the last
   question to close. */
[data-layout="list"] :is(.widget-photo, .widget-map) {
  grid-column: span 1;
  align-self: start;
  order: 2;
}

[data-layout="list"] .quotes {
  order: 4;
}

[data-layout="list"] .stickers {
  order: 5;
}

[data-layout="list"] .qa:last-child {
  order: 6;
}

/* Quotes: a swipe row on phones, two columns elsewhere. */
[data-layout="list"] .quotes {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: -24px; /* stays with the question that points at them */
}

[data-layout="list"] .quotes .item {
  grid-column: auto;
}

@media (max-width: 699px) {
  /* The cards are two squares short of the page and a square apart, so each
     starts and ends on a line, and the next one shows at the edge. */
  [data-layout="list"] .quotes {
    display: flex;
    gap: var(--grid-minor);
    margin-inline: calc(var(--page-pad) * -1);
    padding: 4px var(--page-pad) 20px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--page-pad);
    scrollbar-width: none;
  }

  [data-layout="list"] .quotes::-webkit-scrollbar {
    display: none;
  }

  [data-layout="list"] .quotes .widget {
    flex: 0 0 calc(var(--grid-minor) * (var(--grid-cells) - 2));
    scroll-snap-align: start;
  }
}

/* Stickers: all together on one sheet. Tapping one (or pointing at it)
   lifts it and shows its tooltip, as on the canvas, one at a time. */
[data-layout="list"] .stickers {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 16px 12px;
}

[data-layout="list"] .stickers-title {
  flex-basis: 100%;
  margin-bottom: 8px;
  text-align: left;
}

[data-layout="list"] .item.sticker {
  position: relative; /* the tooltip hangs off it */
  width: calc(var(--w) * 0.75px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

[data-layout="list"] .sticker:focus-visible {
  outline: none;
}

/* Unseen, a tooltip beside the edge of the screen would still widen the page
   on a phone. So until its sticker is picked it is scaled to nothing, and
   again once it has faded out. */
[data-layout="list"] .sticker-tip {
  scale: 0;
  transition: opacity 0.25s ease, translate 0.35s var(--ease-out), scale 0s 0.35s;
}

[data-layout="list"] .sticker.is-picked .sticker-tip {
  scale: 1;
  transition-delay: 0s;
}

@media (prefers-reduced-motion: reduce) {
  [data-layout="list"] .sticker-tip {
    transition: none;
  }
}

/* Under the sheet, how to use it: "Tap a sticker." */
.sticker-note {
  flex-basis: 100%;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.6875rem;
  color: var(--ink-soft);
  text-align: center;
}

/* Phones: three to a row, all about the same size. On the canvas each has a
   size of its own (--w); here every picture is fitted into the same box, a
   little taller than wide, so a tall one and a wide one weigh about the same. */
@media (max-width: 699px) {
  [data-layout="list"] .stickers {
    --sticker: calc(var(--grid-minor) * 4.5);
    gap: calc(var(--grid-y) * 1.5) 0;
  }

  [data-layout="list"] .item.sticker {
    display: grid;
    place-items: center;
    flex: 0 0 calc(100% / 3);
    width: auto;
  }

  [data-layout="list"] .sticker-art img {
    width: auto;
    height: auto;
    max-width: calc(var(--sticker) * var(--fit, 1));
    max-height: calc(var(--sticker) * var(--fit, 1) * 1.15);
  }

  /* its picture has room around the cookie, for the halves to fall open into */
  [data-layout="list"] .fortune-cookie {
    --fit: 1.2;
  }
}

/* Work as cards: the default, and all there is on phones and touch screens. */
[data-layout="list"] .work .frame {
  height: auto;
  max-height: min(440px, 70vh);
}

[data-layout="list"] .work .frame :is(img, video) {
  object-position: top;
}

[data-layout="list"] .work::after {
  display: none;
  content: attr(data-tags);
}

[data-layout="list"] .item.work {
  scroll-margin-top: 72px;
}

/* The folders, last in the list as a row of folders like on the canvas
   (app.js gathers them). On the canvas the row has no box of its own. */
.folder-row {
  display: contents;
}

[data-layout="list"] .canvas[data-view="work"] .folder-row {
  grid-column: 1 / -1;
  display: grid;
  /* three grid squares each, so every folder starts on a major line */
  grid-template-columns: repeat(3, calc(3 * var(--grid-major) - 24px));
  gap: 32px 24px;
  margin-top: 64px;
}

[data-layout="list"] .canvas[data-view="about"] .folder-row {
  display: none;
}

/* Not on phones: the folders are not filtered. All three stay in their row
   whatever the filter is set to (app.js still marks them .is-filtered). */
@media (min-width: 700px) {
  [data-layout="list"] .canvas .folder-row .item.work.is-filtered {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
}

/* each folder as on the canvas: its drawing, and its name and line below */
[data-layout="list"] .canvas .folder-row .item.work {
  display: block;
  align-content: start; /* the index centres a row's content: here they line up at the top */
  grid-column: auto;
  height: auto;
  margin: 0;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
  background: none;
}

[data-layout="list"] .canvas .folder-row .item.work .frame {
  position: relative;
  width: 75%; /* of its three squares, from the line it starts on */
  height: auto;
  max-height: none;
  aspect-ratio: 4 / 3;
  translate: none;
  visibility: visible;
  opacity: 1;
  scale: 1;
}

[data-layout="list"] .canvas .folder-row .work figcaption {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 12px;
}

[data-layout="list"] .canvas .folder-row .work :is(figcaption strong, figcaption span) {
  grid-area: auto;
}

[data-layout="list"] .canvas .folder-row .work::after {
  display: none;
}

/* no row dividers, including the closing line the index draws under its last row */
[data-layout="list"] .canvas .folder-row .item.work.work:nth-child(n) {
  box-shadow: none;
}

/* Phones: one under the other, each as wide as the project cards above them. */
@media (max-width: 699px) {
  [data-layout="list"] .canvas[data-view="work"] .folder-row {
    grid-template-columns: minmax(0, 1fr);
    gap: calc(var(--grid-y) * 2);
    margin-top: 0;
  }

  [data-layout="list"] .canvas .folder-row .item.work .frame {
    width: 100%;
  }

  /* a folder the filter leaves out takes no room (in a row of three it left a hole) */
  [data-layout="list"] .canvas .folder-row .item.work.is-filtered {
    display: none;
  }
}

/* The year (app.js puts data-year-label on the first project of each year):
   list only. On cards it sits above the card. */
[data-layout="list"] .item.work[data-year-label]::before {
  content: attr(data-year-label);
  display: block;
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

/* Phones: no years, the cards follow one another. (The order is still newest first.) */
@media (max-width: 699px) {
  [data-layout="list"] .item.work[data-year-label]::before {
    content: none;
  }
}

/* Phones: everything on the graph paper. tokens.css fits the paper to the
   page here (an even number of squares between the 16 px margins), so what is
   as wide as the page already starts and ends on a line. The gaps are whole
   squares, and app.js (snapList) rounds the heights to whole squares and puts
   the tops on lines. */
@media (max-width: 699px) {
  [data-layout="list"] body {
    background-image: var(--paper-image);
    background-size: var(--paper-size);
    background-position: var(--paper-position);
  }

  [data-layout="list"] .canvas,
  [data-layout="list"] .canvas[data-view="about"] {
    gap: calc(var(--grid-y) * 2) calc(var(--grid-minor) * 2);
    max-width: none;
    padding-inline: var(--page-pad);
  }

  [data-layout="list"] .canvas[data-view="about"] {
    row-gap: calc(var(--grid-y) * 3);
  }

  [data-layout="list"] .canvas > .controls {
    margin-top: calc(var(--grid-y) * -2); /* close under the intro, not a whole row gap away */
  }
}

@media (min-width: 700px) and (hover: none) {
  [data-layout="list"] .item.work {
    grid-column: span 1;
  }
}

/* With a mouse: an index. One row per project, and the shot floats beside
   the pointer (app.js sets --mx / --my) while you hover the row. */
@media (min-width: 700px) and (hover: hover) {
  [data-layout="list"] .canvas[data-view="work"] {
    row-gap: 0;
  }

  [data-layout="list"] .intro-main {
    margin-bottom: 64px;
  }

  /* Each row is one major grid square tall, and app.js shifts the page's
     graph paper so its major lines fall on the row dividers. Rows run the
     full width of the window (their line, hover and click area), with their
     contents padded back into the column (the body clips the overflow). The
     paper draws a line on the first pixel of each square, so each row draws
     its divider on its top edge, and the last shown row one just below. */
  [data-layout="list"] .item.work {
    position: relative;
    display: grid;
    /* Year, name, description and tags each start on a major grid line (1,
       3 and 7 squares in), their text 12px past it like the row's own
       padding. The year shows on a year's first row only. */
    grid-template-columns:
      calc(1 * var(--grid-major) - 24px)
      calc(2 * var(--grid-major) - 24px)
      calc(4 * var(--grid-major) - 24px)
      minmax(0, 1fr);
    align-content: center;
    align-items: baseline;
    column-gap: 24px;
    height: var(--grid-major);
    /* % here is the column's width: out to the window's edges, and back in */
    margin-inline: calc((100% - 100vw) / 2);
    padding: 0 calc((100vw - 100%) / 2 + 12px);
    border-radius: 0;
    box-shadow: inset 0 1px var(--frame-line);
    z-index: auto; /* no stacking context, or the next rows cover the preview */
    transition: background-color 0.2s;
  }

  /* Not quite room for that: the description gets a square less. */
  @media (max-width: 1031px) {
    [data-layout="list"] .item.work {
      grid-template-columns:
        calc(1 * var(--grid-major) - 24px)
        calc(2 * var(--grid-major) - 24px)
        calc(3 * var(--grid-major) - 24px)
        minmax(0, 1fr);
    }
  }

  [data-layout="list"] .item.work:nth-last-child(1 of .work:not(.is-filtered)) {
    box-shadow:
      inset 0 1px var(--frame-line),
      0 1px var(--frame-line);
  }

  [data-layout="list"] .item.work:hover {
    background: color-mix(in srgb, var(--sheet) 70%, transparent);
  }

  /* The caption's parts become the columns: name, description, tags. */
  [data-layout="list"] .work figcaption {
    display: contents;
  }

  /* the description: its own column, even on rows without a year before it */
  [data-layout="list"] .work figcaption span {
    grid-area: 1 / 3;
  }

  [data-layout="list"] .work figcaption {
    font-size: 0.9375rem;
  }

  [data-layout="list"] .work figcaption strong {
    grid-area: 1 / 2;
    font-size: 1.0625rem;
  }

  [data-layout="list"] .item.work[data-year-label]::before {
    grid-area: 1 / 1;
    margin: 0;
  }

  [data-layout="list"] .work::after {
    display: block;
    grid-area: 1 / 4;
    padding-left: var(--grid-major); /* one square clear of the description */
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    word-spacing: 0.6em;
    color: var(--ink-soft);
  }

  [data-layout="list"] .work .frame {
    position: fixed;
    top: 0;
    left: 0;
    z-index: var(--z-items);
    width: auto;
    height: 240px;
    max-height: none;
    aspect-ratio: var(--ar);
    translate: calc(var(--mx, 0px) + 28px) clamp(80px, calc(var(--my, 0px) - 120px), calc(100vh - 256px));
    visibility: hidden; /* also keeps the frame's own link out of the tab order */
    opacity: 0;
    scale: 0.96;
    pointer-events: none;
    transition: opacity 0.2s, scale 0.3s var(--ease-out), visibility 0.2s;
  }

  [data-layout="list"] .canvas.preview-left .work .frame {
    translate: calc(var(--mx, 0px) - 100% - 28px) clamp(80px, calc(var(--my, 0px) - 120px), calc(100vh - 256px));
  }

  [data-layout="list"] .work .frame :is(img, video) {
    object-position: center;
  }

  [data-layout="list"] .canvas .work:hover .frame {
    visibility: visible;
    opacity: 1;
    scale: 1;
    transform: none;
  }
}

/* ── Case study overlay ─────────────────────────────────── */

/* The dialog is a clear full-screen layer. In it, the sheet holds the case
   study page (a frame). It rests 100px down and a little narrower than the
   screen (app.js sets --rest-scale from --rest-side), and grows to fill the screen as the case study scrolls
   (app.js sets --grow from 0 to 1). Scaled rather than resized, so the page
   inside never reflows. Close sits bottom centre and stays put. Behind the
   sheet sits the pull hint.

   The side margin scales with the screen: 20px on phones up to 64px on wide
   screens (--rest-side). It is registered as a length, so app.js can read
   it in px to work out --rest-scale (CSS cannot divide one length by another).

   Pulled down to close, app.js sets --pull (px), --shrink (0 to 1, the sheet
   narrows by up to a fifth from its top centre) and --progress (0 to 1, the
   hint's circle). The sheet follows directly; only letting go eases
   (.is-settling). */
@property --rest-side {
  syntax: "<length>";
  inherits: true;
  initial-value: 20px;
}

.case-overlay {
  --rest-side: clamp(20px, 5vw, 64px);
  --rest-top: 100px;
  --rest-scale: 0.9; /* app.js sets the exact scale for the side margins */
  --sheet-top: var(--rest-top);
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: none;
  color: inherit;
}

.case-overlay::backdrop {
  background: rgba(20, 19, 17, 0.5);
}

.case-sheet {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 1px solid var(--frame-line);
  /* Rounded at rest, square once it fills the screen, and rounded again as
     soon as it is pulled (either way): at the end of a case study it lifts
     from full screen. --shrink is the pull, 0 to 1. */
  border-radius: calc(var(--radius) * 2 * max(1 - var(--grow, 0), min(var(--shrink, 0) * 6, 1)));
  background: var(--paper);
  box-shadow: 0 24px 80px -16px rgba(0, 0, 0, 0.45);
  transform-origin: 50% 0;
  translate: 0 calc(var(--rest-top) * (1 - var(--grow, 0)) + var(--pull, 0px));
  scale: calc((var(--rest-scale) + (1 - var(--rest-scale)) * var(--grow, 0)) * (1 - var(--shrink, 0) * 0.2));
}

.case-overlay iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.case-close {
  position: absolute;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 1;
  min-width: 128px;
  padding: 14px 28px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  box-shadow: var(--shadow);
  color: var(--paper);
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  translate: -50% 0;
  transition: scale 0.2s var(--ease-out);
}

.case-close:active {
  scale: 0.97;
}

/* A momentum bump (touch): out quickly, then is-settling eases it back. */
.case-overlay.is-bumping .case-sheet {
  transition:
    translate 0.24s cubic-bezier(0.2, 0.8, 0.3, 1),
    scale 0.24s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.case-overlay.is-settling .case-sheet {
  transition:
    translate 0.45s var(--ease-out),
    scale 0.45s var(--ease-out);
}

/* The pull hint: tucked just under the sheet's top edge, so pulling the sheet
   down uncovers it. The ring fills with --progress; once full (.is-ready) the
   circle fills in and letting go closes. */
.pull-hint {
  position: absolute;
  top: calc(var(--sheet-top) + 20px);
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px; /* room for the circle to charge up */
  color: #f4f1ea; /* on the dimmed backdrop in either theme */
  font-size: 0.875rem;
  font-weight: 500;
  pointer-events: none;
  opacity: calc(var(--progress, 0) * 4);
}

.pull-ring {
  display: block;
  overflow: visible;
  rotate: -90deg; /* the ring fills from twelve o'clock */
  scale: calc(1 + var(--tension, 0) * 0.25); /* charging up past full */
}

.pull-ring circle {
  fill: transparent;
  stroke-width: 2;
}

.pull-ring-track {
  stroke: rgba(244, 241, 234, 0.3);
}

/* Past full, a halo swells out of the circle as the tension builds. */
.pull-ring-charge {
  stroke: currentColor;
  transform-origin: 12px 12px;
  scale: calc(1 + var(--tension, 0) * 0.45);
  opacity: calc(var(--tension, 0) * 0.5);
}

.pull-ring-fill {
  stroke: currentColor;
  /* The ring's length (2 x pi x r, r = 11) in px: Firefox will not take a
     unitless calc() here, and pathLength is not needed then. */
  --ring: 69.12px;
  stroke-dasharray: var(--ring);
  stroke-dashoffset: calc((1 - var(--progress, 0)) * var(--ring));
  transition: fill 0.2s ease;
}

.pull-icon {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  rotate: 90deg; /* undo the ring's turn: the arrow points down */
  transform-origin: 12px 12px;
  transition: stroke 0.2s ease;
}

.pull-icon > * {
  transform-origin: 12px 12px;
  transition:
    rotate 0.35s var(--ease-out),
    scale 0.35s var(--ease-out),
    opacity 0.2s ease;
}

.pull-icon-b {
  opacity: 0;
}

.is-ready .pull-ring-fill {
  fill: currentColor;
}

/* Full: the arrow becomes a close icon, dark on the filled circle. */
.is-ready .pull-icon {
  stroke: #23221f;
}

.is-ready .pull-icon-a {
  rotate: 45deg;
  scale: 0.85;
}

.is-ready .pull-icon-b {
  rotate: -45deg;
  scale: 0.85;
  opacity: 1;
}

.is-ready .pull-icon-head {
  scale: 0.4;
  opacity: 0;
}

/* At the end of a case study the sheet lifts instead (.is-pull-end): it
   shrinks from its bottom edge, the hint below it (arrow up) shows instead of
   the one above, and Close, which sits right there, fades out of its way. */
.case-overlay:not(.is-pull-end) .pull-hint-end,
.is-pull-end .pull-hint:not(.pull-hint-end) {
  display: none;
}

.pull-hint-end {
  top: auto;
  bottom: calc(40px + env(safe-area-inset-bottom));
}

@media (min-width: 700px) {
  .pull-hint-end {
    bottom: 64px; /* more room on big screens; still inside the gap the lifted sheet opens */
  }
}

.pull-hint-end .pull-icon {
  rotate: -90deg; /* undo the ring's turn the other way: the arrow points up */
}

.is-pull-end .case-sheet {
  transform-origin: 50% 100%;
}

.is-pull-end .case-close {
  opacity: calc(1 - var(--progress, 0) * 4);
}

/* The two labels share a spot and cross-fade. */
.pull-hint-text {
  display: grid;
}

.pull-hint-text > span {
  grid-area: 1 / 1;
  transition: opacity 0.2s ease;
}

.pull-release,
.is-ready .pull-keep {
  opacity: 0;
}

.is-ready .pull-release {
  opacity: 1;
}

/* A trackpad or wheel closes as soon as the ring is full (there is no
   release to wait for), so it keeps the first label. */
/* Dragging on touch, scrolling with a trackpad or wheel. */
.case-overlay:not([data-input="touch"]) .pull-by-touch,
[data-input="touch"] .pull-by-wheel {
  display: none;
}

[data-input="wheel"].is-ready .pull-keep {
  opacity: 1;
}

[data-input="wheel"].is-ready .pull-release {
  opacity: 0;
}

/* Phones: the page behind is blurred, so the list's cards (16px from the
   edge, close to the sheet's 20px) do not show as a second set of corners
   around it. Blurred itself rather than with backdrop-filter on the backdrop:
   that fades and rounds the backdrop's own edges against the screen edges. */
@media (max-width: 699px) {
  .case-overlay::backdrop {
    background: rgba(20, 19, 17, 0.6);
  }

  .bar,
  .canvas {
    transition: filter 0.3s ease;
  }

  .case-open :is(.bar, .canvas) {
    filter: blur(10px);
  }
}

/* Rises in and fades out. display and overlay are held until the fade is done. */
@media (prefers-reduced-motion: no-preference) {
  .case-overlay,
  .case-overlay::backdrop {
    opacity: 0;
    transition: opacity 0.3s ease, translate 0.5s var(--ease-out), overlay 0.3s allow-discrete, display 0.3s allow-discrete;
  }

  .case-overlay {
    translate: 0 16px;
  }

  .case-overlay[open],
  .case-overlay[open]::backdrop {
    opacity: 1;
    translate: 0 0;
  }

  @starting-style {
    .case-overlay[open],
    .case-overlay[open]::backdrop {
      opacity: 0;
    }

    .case-overlay[open] {
      translate: 0 16px;
    }
  }
}

/* ── Load-in ────────────────────────────────────────────── */

@media (prefers-reduced-motion: no-preference) {
  .item {
    animation: item-in 0.9s var(--ease-out) backwards;
    animation-delay: calc(var(--i, 0) * 50ms + 100ms);
  }

  /* The list reads top to bottom: a quicker cascade, capped after a screenful. */
  [data-layout="list"] .item {
    animation-duration: 0.6s;
    animation-delay: calc(min(var(--j, 0), 10) * 40ms + 60ms);
  }

  /* The entry (app.js, with a mouse): the canvas opens zoomed out, far enough to
     take in the work as a whole, and closes in on the intro. Meanwhile the tiles
     fade in from the outside inwards (app.js orders --i that way): slowly and
     evenly, where the usual load-in is quick off the mark and would read as a
     pop at this size. They hold until their pictures have loaded (.is-waiting;
     the camera doesn't wait), and nothing reacts to the pointer until the entry
     is done. */
  .canvas.is-entering .item {
    animation-duration: 1s;
    animation-timing-function: cubic-bezier(0.4, 0, 0.6, 1);
    animation-delay: calc(var(--i, 0) * 30ms);
    pointer-events: none;
  }

  .canvas.is-waiting .item {
    animation-play-state: paused;
    opacity: 0 !important; /* over the animation, which may be a few frames in by now */
  }

  @keyframes item-in {
    from {
      opacity: 0;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .frame,
  .recenter,
  .intro-hint,
  .about-toggle,
  .controls button,
  .toggle-thumb.is-placed,
  .item[data-view],
  .canvas .item.work,
  html:not([data-layout="list"]) .item.work::before,
  html:not([data-layout="list"]) .item.work:not([data-folder])::after,
  .logo,
  .sticker-art,
  .sticker-color,
  .sticker-sheen,
  .map-color,
  .sticker-tip,
  .case-sheet,
  .case-close,
  .pull-ring-fill,
  .pull-icon,
  .pull-icon > *,
  .pull-hint-text > span {
    transition: none;
  }
}
