@font-face {
  font-family: "TWK Lausanne";
  src: url("fonts/TWKLausanne-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

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

:root {
  --fg: #ffffff;
  --dim: #666666;
  --label: #323232; /* field labels: project / tags / add */
  --bg: #000000;
  --surface: rgba(26, 26, 26, 0.95);       /* info boxes */
  --pill-bg: rgba(41, 41, 41, 0.8);
  --pill-active: #0b0b0b;    /* magnetic pill + menu hover */
  --panel-bg: rgba(13, 13, 13, 0.95);
  --menu-bg: rgba(26, 26, 26, 0.95);
  --nav-idle: #b5b5b5;
  --muted: #444444;
  --overlay: rgba(0, 0, 0, 0.8);
  --shadow: rgba(0, 0, 0, 0.7);
  --logo-filter: brightness(0) invert(0.72); /* black svgs -> light grey */
  --pad: 24px;
  --bar-h: 67px;   /* top bar height (pad 24 + logo 39 + pad 4) — info page uses it */
  --gap: 24px;     /* horizontal gap between tiles */
  --rowgap: 32px;  /* vertical gap between tiles */
  --ease: cubic-bezier(0.16, 1, 0.3, 1); /* ease-out-expo-ish */
}

html { background: var(--bg); }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: "TWK Lausanne", system-ui, -apple-system, sans-serif;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* ---- intro reel -------------------------------------------------------- */
/* full-viewport video, pinned with position:sticky for the whole document, so
   the black site below simply scrolls up over it (no parallax maths, no JS).
   z-index keeps it behind #site; #site paints solid black on top of it. */
#hero {
  position: sticky; top: 0; z-index: 0;
  height: 100vh; height: 100dvh;
  overflow: hidden;
  background: #000; color: #fff;
}
#hero video, #hero-poster {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
/* the poster sits under the video until its first frame is painted */
#hero-poster { position: absolute; inset: 0; z-index: 0; }
/* "Sound on" / "Sound off": white type, mix-blend-mode difference over the reel.
   desktop: it follows the cursor while it is over the reel (hero.js sets --mx / --my);
   touch: it stays put in the top-right corner. */
#hero-sound {
  position: absolute; z-index: 3; top: 0; left: 0; margin: 0; padding: 14px 18px;
  border: 0; background: none; color: #fff; font: inherit; font-size: 15px; line-height: 1.3; white-space: nowrap;
  mix-blend-mode: difference;
  transform: translate(var(--mx, 50%), var(--my, 50%)) translate(-50%, -50%);
  cursor: pointer; opacity: 0; pointer-events: none;
  transition: opacity 0.25s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
#hero-sound .t-off, #hero-sound[aria-pressed="true"] .t-on { display: none; }
#hero-sound[aria-pressed="true"] .t-off { display: inline; }
/* gone as soon as the page starts scrolling away from the reel */
#hero.scrolled #hero-sound, #hero.scrolled.intro-done #hero-sound { opacity: 0; pointer-events: none; }
#hero.show-ctrl #hero-sound { opacity: 1; pointer-events: auto; }
/* sound feature disabled for now: the label no longer replaces the cursor
@media (hover: hover) { #hero.intro-out, #hero.intro-out #hero-sound { cursor: none; } } /* the normal cursor stays during the logo intro *\/
*/
@media (hover: none) {
  #hero-sound { top: calc(var(--pad) - 14px); left: auto; right: calc(var(--pad) - 18px); transform: none; font-size: 13px; }
  #hero.intro-done #hero-sound { opacity: 1; pointer-events: auto; }
}
/* the reel nudges in a little when the sound goes on */
#hero video { position: relative; z-index: 1; transition: transform 0.3s cubic-bezier(0.76, 0, 0.24, 1); }
#hero.sound-on video { transform: scale(1.03); }
/* intro: the logo draws itself on a black plate, centred; then the plate fades out over the reel */
#hero-intro {
  position: absolute; inset: 0; z-index: 2; background: #000;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.3s ease-out;
}
#hero-intro-logo { width: clamp(85px, 10.1vw, 135px); height: auto; display: block; transition: opacity 0.18s ease-out; }
#hero.logo-out #hero-intro-logo { opacity: 0; }
#hero-intro-logo:not([src]) { visibility: hidden; } /* no alt-text box while the svg is still being fetched */
#hero.intro-out #hero-intro { opacity: 0; pointer-events: none; }
#hero.intro-done #hero-intro { visibility: hidden; transition: opacity 0.3s ease-out, visibility 0s linear 0.3s; }
@media (prefers-reduced-motion: reduce) { #hero-intro { display: none; } }

/* the site proper: starts one screen down (after the hero) and scrolls over
   it. flex column so the footer sticks to the viewport bottom even when the
   content is short — dvh tracks the real visible height on iOS (url bar). */
#site {
  position: relative; z-index: 1;
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; flex-direction: column;
}
#work { flex: 1 0 auto; }

input, button, label, textarea { font-family: inherit; font-weight: inherit; font-size: 15px; }

/* generic hover for interactive text: dim -> white. one list for every
   dim-grey interactive element; element-specific extras stay at their rules */
#cols button, #modes button, .chip, #detail-close, #f-delete,
#f-public, .suggest div, #auth-links button, #auth-code-ok,
.tag-chip, #f-url-link, .info-add, #legal-footer a {
  color: var(--dim);
  cursor: pointer;
  transition: color 0.2s var(--ease);
}
#cols button:hover, #modes button:hover, .chip:hover,
#detail-close:hover, #f-delete:hover, #f-public:hover, .suggest div:hover,
#auth-links button:hover, #auth-code-ok:hover,
.tag-chip:hover, #f-url-link:hover, .info-add:hover, #legal-footer a:hover {
  color: var(--fg);
}
#legal-footer a { text-decoration: none; }

/* shared recipe for dark floating overlays. two tints:
   .float-panel — near-black, heavy blur (filter panel, suggest dropdowns)
   .float-menu  — lighter, small context menus (link menu) */
.float-panel, .float-menu {
  border-radius: 8px;
  box-shadow: 0 24px 44px var(--shadow);
}
.float-panel {
  background: var(--panel-bg);
  -webkit-backdrop-filter: blur(48px); backdrop-filter: blur(48px);
}
.float-menu {
  background: var(--menu-bg);
  -webkit-backdrop-filter: blur(25px); backdrop-filter: blur(25px);
  box-shadow: 0 12px 30px var(--shadow);
}

/* ---- top bar ---------------------------------------------------------- */
/* not sticky: the bar scrolls away with the page */
#bar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: calc(var(--pad) + 14px) var(--pad) 28px;
  background: var(--bg);
}
#logo { height: 38.4px; flex: 0 0 auto; display: flex; align-items: center; }
#logo img { height: 38.4px; width: auto; display: block; }
/* homepage: the intro already showed the logo, the bar is just spacing */
body:not(.show-page) #bar { padding: calc(var(--pad) + 14px) var(--pad) 0; }
body:not(.show-page) #logo { display: none; }

/* actions pinned to the far right of the bar */
#actions { flex: 0 0 auto; display: flex; gap: 16px; align-items: center; }

/* ---- work nav (Filter) ------------------------------------------------ */
/* first appears where the grid starts, then sticks to the top while you're in
   the work section (and leaves with it). the row itself is click-through so
   it never blocks the tiles it floats over. */
#worknav {
  position: sticky; top: var(--pad); z-index: 10;
  display: flex; justify-content: flex-end;
  padding: 0 var(--pad);
  pointer-events: none;
}
#worknav > * { pointer-events: auto; }

/* nav pill: Info + Filter/Work in a dark rounded container (Figma 623:846) */
#navpill {
  display: flex; align-items: center; justify-content: flex-end;
  height: 38px; padding: 2px;
  border-radius: 8px;
  background: var(--pill-bg);
  -webkit-backdrop-filter: blur(25px); backdrop-filter: blur(25px);
  box-shadow: 0 24px 44px var(--shadow);
}
#navpill button {
  position: relative; z-index: 1; /* above the magnetic pill background */
  height: 100%; padding: 0 14px;
  border-radius: 6px;
  color: var(--nav-idle); cursor: pointer;
  transition: color 0.2s var(--ease);
}
#navpill button:hover { color: var(--fg); }
#navpill button.active { color: var(--fg); }
/* "magnetic pill": one dark background that rests on the active button and
   snaps quickly to whichever button is hovered (JS moves it) */
#navpill-bg {
  position: absolute; top: 2px; bottom: 2px; left: 0; width: 0;
  border-radius: 6px; background: var(--pill-active);
  opacity: 0; pointer-events: none;
  transition: transform 0.15s var(--ease), width 0.15s var(--ease), opacity 0.15s var(--ease);
}

/* filter + view options: an overlay anchored to the bar's bottom edge.
   position:absolute (inside the relatively-positioned #bar) so it floats over
   the grid instead of pushing it down. Collapsed by default; expands on .open
   by animating the height 0 -> content height (easeOutExpo, 0.2s). */
#filter-panel {
  position: absolute;
  top: calc(100% + 4px); right: var(--pad); left: auto; width: auto; /* hugs content, under the pill */
  z-index: 9; /* under the bar (10), over the grid */
  overflow: hidden;
  height: 0; /* collapsed by default; JS animates the height (easeOutExpo, 0.2s) */
  transition: height 0.2s var(--ease);
  /* panel look comes from .float-panel */
}
/* the actual layout + padding — clipped by #filter-panel when collapsed */
#filter-row {
  display: flex; flex-direction: column; align-items: flex-end;
  gap: 24px; padding: 18px;
}

/* the three sections sit in a right-aligned row on desktop, 24px apart */
#filter-sections { display: flex; align-items: flex-start; gap: 24px; }
#filter-projects, #filter-tags { min-width: 150px; }
#filter-visibility { min-width: 90px; }

/* each section: a left-aligned vertical list, label on top */
.fsec { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.fsec .chip, .fsec button { white-space: nowrap; }
.fsec-label { color: var(--dim); }   /* "view options" — non-interactive */
.fsec-sep { color: var(--dim); }     /* "-" divider between grid + layout opts */

/* column-count buttons: desktop shows 5/4/3, mobile shows 2/1
   (needs #cols prefix to beat the specificity of "#cols button") */
#cols .mobcol { display: none; }

/* grid + layout options stack vertically within the view-options section */
#cols, #modes { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.chip.active, #cols button.active, #modes button.active { color: var(--fg); }

button { background: transparent; border: none; }

#status { color: var(--dim); text-align: right; }

/* ---- grid ------------------------------------------------------------- */
#grid { padding: var(--pad); }

/* masonry: JS distributes the cells row-major (left to right) into equal-width
   flex columns (.mcol), so the reading order goes across, not down. */
#grid[data-mode="masonry"] { display: flex; align-items: flex-start; gap: var(--gap); }
#grid[data-mode="masonry"] .mcol {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; gap: var(--rowgap);
}

/* top aligned: row by row, items align to top (gaps appear) */
#grid[data-mode="grid"] { display: grid; column-gap: var(--gap); row-gap: var(--rowgap); align-items: start; }
#grid[data-mode="grid"][data-cols="5"] { grid-template-columns: repeat(5, 1fr); }
#grid[data-mode="grid"][data-cols="4"] { grid-template-columns: repeat(4, 1fr); }
#grid[data-mode="grid"][data-cols="3"] { grid-template-columns: repeat(3, 1fr); }
#grid[data-mode="grid"][data-cols="2"] { grid-template-columns: repeat(2, 1fr); }
#grid[data-mode="grid"][data-cols="1"] { grid-template-columns: repeat(1, 1fr); }

.cell {
  break-inside: avoid;
  cursor: pointer;
  display: block;
  position: relative;
  /* the cell's own footprint never changes (siblings must not move on hover) */
}
.cell img,
.cell video {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 2px;
}
/* hover shifts the image itself up 12px (not a resize) — .media's own box
   never changes size (transforms don't affect layout, so the cell doesn't
   move). the rounded corners live on the media elements themselves (not a
   clipping parent): .media has no overflow:hidden, so the image is free to
   slide past its box's top edge on hover without getting cropped there.
   the caption slides down 12px at the same time, keeping their distance. */
.cell .media { position: relative; }
.cell .media > * { transition: transform 0.2s var(--ease); }
.cell:hover .media > * { transform: translateY(-12px); }

/* shared 16:9 framing for embedded videos so they sit flush with other items;
   posters are cropped (cover) to hide any letterbox baked into the thumbnail */
.cell .media.yt, .cell .media.vimeo { aspect-ratio: 16 / 9; }
.cell .media.yt, .cell .media.vimeo { background: var(--surface); border-radius: 2px; }
.cell .media.yt img, .cell .media.vimeo img { width: 100%; height: 100%; object-fit: cover; border-radius: 2px; }

/* YouTube: static poster + a small, minimal play button (grid + detail) */
.cell .media.yt .play, .yt-start .play {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  transition: transform 0.2s var(--ease);
  width: 0; height: 0;
  border-style: solid; border-width: 6px 0 6px 11px;
  border-color: transparent transparent transparent rgba(255, 255, 255, 0.92);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
  pointer-events: none;
}
/* keep the play icon centered on the (now shifted-up) poster on hover */
.cell:hover .media.yt .play { transform: translate(-50%, calc(-50% - 12px)); }

/* Vimeo: the background-mode player overlays the poster, fully chrome-free.
   the iframe wrapper clips itself to a rounded rect (its own overflow:hidden,
   not the shared .media box, so the poster above still slides unclipped) */
.cell .media.vimeo .vimeo-frame {
  position: absolute; inset: 0; opacity: 0;
  border-radius: 2px; overflow: hidden;
  transition: opacity 0.3s var(--ease), transform 0.2s var(--ease);
  pointer-events: none; /* clicks fall through to the cell (open detail) */
}
.cell .media.vimeo.vimeo-playing .vimeo-frame { opacity: 1; }
.cell .media.vimeo .vimeo-frame iframe {
  position: absolute; inset: 0;
  width: 100%; height: 100%; display: block; border: 0;
}
/* project name below the tile: fixed at its resting spot (12px into the strip
   the lifted image reveals) and only faded in — no motion of its own */
.cell .cap {
  position: absolute;
  bottom: 0; left: 0;
  height: 24px;
  display: flex; align-items: flex-end;
  color: var(--dim); /* same grey as the detail view values */
  white-space: nowrap;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s var(--ease);
  pointer-events: none;
  z-index: 2;
}
.cell:hover .cap { opacity: 1; }

/* hidden-piece marker: bottom-right corner, opposite the project caption.
   only present for logged-in users (hidden items aren't sent otherwise).
   sits still like the caption, only its opacity animates. */
.cell .hid {
  position: absolute; bottom: 4px; right: 0;
  display: flex; color: var(--dim);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s var(--ease);
  pointer-events: none;
}
.cell:hover .hid { opacity: 1; }

/* drop indicator: a fine white vertical line shown between cells while reordering */
.cell.drop-before::before,
.cell.drop-after::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 0.5px;
  background: var(--fg); z-index: 5; pointer-events: none;
}
.cell.drop-before::before { left: calc(var(--gap) / -2); }
.cell.drop-after::after { right: calc(var(--gap) / -2); }

/* ---- detail / edit view ---------------------------------------------- */
#detail {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg);
}
#detail .stage {
  position: absolute;
  top: var(--pad); left: 0; right: 0;
  bottom: 64px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 var(--pad);
}
#detail .stage img, #detail .stage video {
  max-width: 80vw; max-height: 90%; display: block;
  border-radius: 2px; /* same rounding as the grid tiles */
}
/* YouTube / embedded player: 16:9, capped to the stage; sits above the nav
   zones so its own controls stay clickable (use ← → keys to navigate) */
#detail .stage .plyr-host .plyr { border-radius: 2px; overflow: hidden; }
#detail .stage .plyr-host {
  width: min(80vw, calc((100vh - 160px) * 16 / 9));
  max-height: 90%;
  z-index: 52;
  /* white accent (progress bar, hover fill). because the hover fill is white,
     the icon must flip to black on hover so it stays visible (white-on-white). */
  --plyr-color-main: #fff;
  --plyr-video-control-color: #fff;
  --plyr-video-control-color-hover: #000;
}
/* YouTube in the detail view: local poster until the visitor presses play */
.yt-start { position: relative; display: block; aspect-ratio: 16 / 9; cursor: pointer; background: var(--surface); border-radius: 2px; }
.yt-start img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 2px; }
.yt-start .play { transform: translate(-50%, -50%) scale(2); }
/* big center play button: dark arrow on the white circle */
#detail .plyr__control--overlaid { color: #000; background: #fff; }
#detail .plyr__control--overlaid:hover { color: #000; background: #fff; }

#detail .nav { position: fixed; top: 56px; bottom: 64px; width: 30vw; z-index: 51; }
#detail .nav.prev { left: 0; cursor: w-resize; }
#detail .nav.next { right: 0; cursor: e-resize; }
/* while hovering the video's control strip, let clicks through to the player
   instead of the prev/next nav zones that overlap the video's lower corners */
#detail.controls-active .nav { pointer-events: none; }

#detail-close {
  position: fixed; top: var(--pad); right: var(--pad); z-index: 53;
}

/* edit panel: single horizontal row along the bottom */
.panel {
  position: fixed; left: var(--pad); right: var(--pad); bottom: var(--pad); z-index: 52;
  display: flex; gap: 40px; align-items: baseline;
}
.field { display: flex; gap: 12px; align-items: baseline; }
.field.tags { flex: 1; min-width: 0; }
.field .key { color: var(--label); flex: 0 0 auto; }

.combo { position: relative; }
.panel input {
  background: transparent; border: none; outline: none;
  color: var(--dim); padding: 0; line-height: 1.4; width: 120px;
  transition: color 0.2s var(--ease);
}
.panel input:hover, .panel input:focus { color: var(--fg); }
#f-tag { width: 80px; }
.panel input::placeholder { color: var(--label); }

/* optional external project link: visitor sees a dim -> white clickable link */
#f-url-link { text-decoration: none; }
/* visitors have no public/delete actions, so drop that trailing pair and pin
   the project link to the right edge — flush with the Close button above it */
body:not(.authed) .panel-actions { display: none; }
body:not(.authed) #url-field { margin-left: auto; }

.tags-edit { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
#tag-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.tag-chip { white-space: nowrap; }

/* public + delete sit together as a tight pair at the end of the row */
.panel-actions { flex: 0 0 auto; display: flex; gap: 14px; align-items: baseline; }
#f-delete { flex: 0 0 auto; }

/* suggestion dropdowns — .float-panel look, opening upward above the bar */
.suggest {
  position: absolute; left: 0; bottom: 100%; margin-bottom: 8px;
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px;
  max-height: 220px; overflow-y: auto; min-width: 120px; z-index: 60;
}
.suggest div { white-space: nowrap; }
.suggest div.active { color: var(--fg); }

/* ---- login / setup / reset overlay ------------------------------------ */
#auth {
  position: fixed; inset: 0; z-index: 80;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 32px; padding: var(--pad);
}
#auth-form { display: flex; flex-direction: column; align-items: center; gap: 14px; }
/* the only visible field is the word "Passwort"; no box, dim -> white */
.auth-field {
  background: transparent; border: none; outline: none;
  color: var(--dim); text-align: center; width: 240px; padding: 0;
  transition: color 0.2s var(--ease);
}
.auth-field::placeholder { color: var(--dim); }
.auth-field:hover, .auth-field:focus { color: var(--fg); }
#auth-msg { color: var(--dim); min-height: 1.4em; text-align: center; }
#auth-code { display: flex; flex-direction: column; align-items: center; gap: 18px; max-width: 360px; }
.auth-note { color: var(--dim); text-align: center; }
#auth-code-value { color: var(--fg); letter-spacing: 3px; font-size: 14px; }
/* secondary actions: stacked, pinned to the bottom of the viewport (less important) */
#auth-links {
  position: absolute; left: 0; right: 0; bottom: var(--pad);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}

/* without a session the portfolio is view-only: the panel still shows the
   project + tags, but every editing affordance is hidden / inert */
body:not(.authed) #f-delete,
body:not(.authed) #f-public,
body:not(.authed) .field.tags .combo { display: none; }
body:not(.authed) .panel input { pointer-events: none; }
/* nothing to add a tag with → drop the empty trailing gap before the (hidden) input */
body:not(.authed) .tags-edit { gap: 6px; }
/* ---- misc ------------------------------------------------------------- */
.hidden { display: none !important; }

/* drag-to-invert spray: white grains on a full-viewport canvas; blending with
   "difference" turns white into an exact inversion of the page behind it */
#invert-trail {
  position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 100;
  pointer-events: none; mix-blend-mode: difference;
}
body.inverting { cursor: crosshair; }
body.inverting-touch { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

#drop-hint {
  position: fixed; inset: 0; z-index: 60;
  display: none; align-items: center; justify-content: center;
  background: var(--overlay); color: var(--fg);
  pointer-events: none;
}
body.dragging #drop-hint { display: flex; }

/* busy overlay: covers everything (incl. detail view) while compressing/uploading */
#busy {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--fg); text-align: center; padding: var(--pad);
}
#busy-text { font-size: 14px; }

/* ---- studio info (above the grid) + footer pages (/slug) ---------------- */
/* footer pages reuse the info layout and replace info + grid while open */
#info { padding: 0 var(--pad); }
#page { padding: 0 var(--pad) var(--pad); flex: 1 0 auto; }
#info .info-inner, #page .info-inner {
  display: flex; flex-direction: column; align-items: stretch; gap: 124px;
}
/* breathing room before the work grid starts */
#info .info-inner { padding-bottom: 124px; }
/* the copy fills the first screen (bar bottom -> viewport bottom) and bottom-aligns
   its text, so it always sits at the bottom of the viewport; padding-top keeps a
   minimum 300px gap from the nav when the text is tall. clients follow below. */
#info .info-copy, #page .info-copy {
  max-width: 732px;
  min-height: calc(100vh - var(--bar-h) - var(--pad));
  min-height: calc(100dvh - var(--bar-h) - var(--pad));
  padding-top: 180px;
  display: flex; flex-direction: column; justify-content: flex-end;
  gap: 24px; align-items: flex-start;
}
/* on the homepage the copy no longer fills a whole screen: a fixed gap under
   the bar (half of what the full-screen layout used to leave) */
#info .info-copy { min-height: 0; padding-top: 0; } /* the copy starts where the logo used to be */
/* big pause between the copy and the clients table (on top of the 124px gap) */
#info .info-table { margin-top: 116px; }
#info .info-text, #page .info-text {
  color: var(--fg);
  font-size: 24px; line-height: 1.3;
  width: 100%;
}
.page-title { font-size: 18px; line-height: 1.3; font-weight: inherit; color: var(--fg); width: 100%; }
.page-title:empty { display: none; }
#page .info-text a { color: var(--dim); text-decoration: none; transition: color 0.2s var(--ease); }
#page .info-text a:hover { color: var(--fg); }
/* copy is white, links the table-header grey, brightening to white on hover */
#info .info-text a { color: var(--dim); text-decoration: none; transition: color 0.2s var(--ease); }
#info .info-text a:hover { color: var(--fg); }
/* the editable copy behaves like the rendered one */
#info-text { outline: none; cursor: text; min-height: 1.3em; white-space: pre-wrap; }
#info-text:empty::before { content: attr(data-placeholder); color: var(--label); }

/* ---- selected clients / acknowledgements boxes (above the table) -------- */
/* extra pause after the copy: 1.5x the regular section gap */
/* desktop: sits 200px below the copy (the section gap is 124px) */
.info-boxes { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: calc(200px - 124px); }
.info-box {
  position: relative; aspect-ratio: 1 / 1; background: var(--surface); border-radius: 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
/* label + logo form one group, vertically centred in the box (logo height = --logo-h) */
.info-box { --logo-h: 14.4%; }
.info-box-label { position: absolute; top: var(--pad); left: var(--pad); text-align: left; color: var(--dim); }
/* logos are centred in the whole box. every svg shares the same 150px-high
   frame (logo vertically centred in it, width varies), so a fixed height keeps
   them all at the same scale */
.info-box-logos { position: relative; width: 100%; height: var(--logo-h); }
.info-box-logos img {
  position: absolute; inset: 0; margin: auto; height: 100%; width: auto; max-width: 82%; opacity: 0; transition: opacity 0.1s linear;
  filter: var(--logo-filter);
}
.info-box-logos img.on { opacity: 1; }

/* ---- recent-clients table (info section) ------------------------------- */
/* hairline rows, dim small-caps-ish header the company name
   big like the info copy — same greys + weight as the rest of the site */
.info-table { display: flex; flex-direction: column; gap: 24px; align-items: flex-start; }
#clients { width: 100%; border-collapse: collapse; table-layout: fixed; }
#clients th, #clients td {
  text-align: left; font-weight: inherit; vertical-align: baseline;
  padding: 14px 24px 14px 0;
  border-bottom: 0.5px solid var(--label);
}
#clients th { padding-top: 0; color: var(--dim); }
#clients th:nth-child(1), #clients td.c-name { width: 40%; }
#clients th { color: var(--muted); } /* a touch darker than the rows */
#clients td { color: var(--dim); } /* category + stage share the header grey */
#clients td.c-name { color: var(--fg); font-size: 15px; line-height: 1.3; }
/* the row at the vertical centre of the viewport lights up in the copy colour
   (js/clients-focus.js sets .mid) */
#clients tbody td { transition: color 1s var(--ease); } /* a row cools down slowly ... */
#clients tbody tr.mid td { color: var(--fg); transition-duration: 0s; } /* ... but lights up at once */
/* while a row is lit, the other company names step back to the grey */
#clients tbody.focusing tr:not(.mid) td.c-name { color: var(--dim); }
/* owner editing: cells are contentEditable */
#clients td[contenteditable] { outline: none; cursor: text; }
#clients td[contenteditable]:empty::before { content: attr(data-placeholder); color: var(--label); }
#clients td.c-x { width: 44px; padding-right: 0; text-align: right; white-space: nowrap; }
body:not(.authed) #clients .c-x { display: none; }

.info-text { color: var(--fg); white-space: pre-wrap; overflow-wrap: break-word; width: 100%; }
.info-text a { color: var(--fg); text-decoration: underline; }

.row-x { color: var(--label); cursor: pointer; flex: 0 0 auto; transition: color 0.2s var(--ease); }
.row-x:hover { color: var(--fg); }

/* ---- floating link menu (select text -> add a link, Figma-style) ------- */
#linkmenu {
  position: fixed; z-index: 95;
  display: flex; align-items: center; gap: 4px;
  padding: 4px;
  /* menu look comes from .float-menu */
}
#linkmenu button {
  padding: 4px 12px; border-radius: 6px;
  color: var(--nav-idle); cursor: pointer;
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
#linkmenu button:hover { color: var(--fg); background: var(--pill-active); }
#linkmenu input {
  background: transparent; border: none; outline: none;
  color: var(--fg); width: 200px; padding: 4px 8px;
}
#linkmenu input::placeholder { color: var(--dim); }

#info-msg { color: var(--dim); }

/* legal footer at the end of the grid (sticks to the viewport bottom via the
   body flex column when the grid is short) */
#legal-footer {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  padding: calc(var(--rowgap)) var(--pad) var(--pad);
  margin-top: auto;
}
/* plain text entries (e.g. copyright) — not interactive for visitors */
#legal-footer .foot-text { color: var(--dim); cursor: default; }
#legal-footer:empty { display: none; }
/* studio credit, pushed to the right edge */
.foot-list { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
/* spans and buttons otherwise differ in line height (21px vs 17px) -> uneven gaps */
.foot-list > * { text-align: left; line-height: 1.4; }
.foot-section { color: var(--muted); margin-top: 24px; cursor: default; }

/* a footer page replaces the homepage (info + grid) while open — the legal
   footer stays, shared, and sits right after the page content */
#page { display: none; }
body.show-page #page { display: block; }
body.show-page #info, body.show-page #work, body.show-page #hero { display: none; }

/* edit affordances hidden for visitors */
body:not(.authed) .authed-only { display: none !important; }
/* the owner edits the info copy in place instead of reading it */
body.authed #info-text-ro { display: none; }

::selection { background: var(--fg); color: var(--bg); }
::-webkit-scrollbar { width: 0; height: 0; }

/* ---- mobile ----------------------------------------------------------- */
@media (max-width: 640px) {
  :root { --pad: 14px; --gap: 14px; --rowgap: 24px; --bar-h: 57px; }

  #logo, #logo img { height: 28.8px; }
  #bar { gap: 12px; }

  /* filter button stays pinned to the right */
  #actions { margin-left: auto; }

  /* narrow panel; sections stack vertically instead of sitting side by side,
     growing for long project/tag names, capped at the viewport */
  #filter-panel { min-width: 205px; max-width: calc(100vw - 2 * var(--pad)); }
  #filter-row { gap: 24px; padding: 18px; }
  #filter-sections { flex-direction: column; gap: 24px; width: 100%; }

  /* mobile column options: only 2 / 1 (2 is default) */
  #cols .deskcol { display: none; }
  #cols .mobcol { display: flex; }

  /* items capped at 80% of the (visible) viewport height */
  .cell .media { max-height: 80vh; max-height: 80dvh; overflow: hidden; }

  /* info page + footer pages: slightly smaller copy, tighter spacing */
  #info .info-inner, #page .info-inner { gap: 64px; }
  #info .info-text, #page .info-text { font-size: 18px; }
  .page-title { font-size: 16px; }
  /* the desktop 300px minimum gap below the nav eats half a phone screen */
  #info .info-copy, #page .info-copy { padding-top: 100px; }
  #info .info-inner { padding-bottom: 64px; }
  #info .info-copy { padding-top: 0; }
  #info .info-table { margin-top: 0; }
  #legal-footer { flex-direction: column; align-items: flex-start; gap: 16px; font-size: 13px; }
  #legal-footer > *, .foot-list > * { font-size: inherit; line-height: 1.4; }
  #legal-footer .foot-credit { margin-top: 8px; }
  /* boxes stack, slightly portrait */
  .info-boxes { grid-template-columns: 1fr; margin-top: 56px; } /* 64px gap + 56px = 120px */
  .info-box { aspect-ratio: 4 / 5; --logo-h: 14.4%; }
  .info-box-label { font-size: 13px; }
  /* clients stays a real table on phones, just smaller type, no hover dimming */
  #clients { font-size: 13px; }
  /* rows become a two-column grid: name over category on the left, stage in a
     right-aligned column */
  #clients, #clients tbody { display: block; }
  #clients thead { display: block; }
  #clients tr { position: relative; display: grid; grid-template-columns: 1fr auto; column-gap: 10px; padding: 10px 0; }
  /* hairline as a half-scaled 1px bar: a 0.5px border gets snapped away at some
     scroll offsets / zoom levels on phones, this one only ever blurs */
  #clients tr::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
    background: var(--label); transform: scaleY(0.5); transform-origin: bottom; pointer-events: none;
  }
  body.authed #clients tr { grid-template-columns: 1fr auto 44px; }
  #clients thead tr { padding-top: 0; }
  #clients th, #clients td { padding: 0; border: 0; overflow-wrap: anywhere; }
  /* centre-row highlight on phones too, in three clearly separated tiers:
     lit name > lit category/stage > dimmed name > dimmed category/stage */
  #clients tbody.focusing tr:not(.mid) td.c-name { color: color-mix(in srgb, var(--fg) 52%, var(--bg)); }
  #clients tbody.focusing tr:not(.mid) td.c-category, #clients tbody.focusing tr:not(.mid) td.c-stage { color: color-mix(in srgb, var(--fg) 30%, var(--bg)); }
  #clients tbody.focusing tr.mid td.c-name { color: var(--fg); }
  #clients tbody.focusing tr.mid td.c-category, #clients tbody.focusing tr.mid td.c-stage { color: color-mix(in srgb, var(--fg) 62%, var(--bg)); }
  #clients th:nth-child(2) { display: none; }
  #clients th:nth-child(3), #clients td.c-stage { grid-column: 2; grid-row: 1 / span 2; text-align: right; }
  #clients td.c-name { grid-column: 1; grid-row: 1; width: auto; font-size: 13px; }
  #clients td.c-category { grid-column: 1; grid-row: 2; }
  #clients td.c-x { grid-column: 3; grid-row: 1; }
  #clients th:nth-child(1) { width: auto; }

  /* detail view becomes a vertical scroll: media + fields, delete below the fold */
  #detail { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  #detail .nav { display: none; } /* swipe to navigate instead */
  #detail .stage {
    position: static; bottom: auto;
    min-height: calc(100vh - 38px);
    min-height: calc(100dvh - 38px);
    padding: 52px var(--pad) 0;
  }
  #detail .stage img, #detail .stage video { max-width: 100%; max-height: 80vh; max-height: 80dvh; }

  /* grid: project (left) + tags (right) on row 1, the optional external link
     on its own full-width row, public + delete on a last row below the fold */
  .panel {
    position: static; left: auto; right: auto; bottom: auto;
    display: grid; grid-template-columns: auto minmax(0, 1fr);
    column-gap: 16px; row-gap: 28px; align-items: baseline;
    padding: 8px var(--pad) 0;
  }
  .panel > .field:first-child { grid-column: 1; }          /* project: left */
  .field.tags { grid-column: 2; min-width: 0; justify-content: flex-end; } /* tags: right */
  #url-field { grid-column: 1 / -1; }                      /* link: own row */
  body:not(.authed) #url-field { margin-left: 0; }         /* grid places it; no flex push needed */
  .field { gap: 8px; }
  /* tags on a single right-aligned line; overflow fades out on the left when too many */
  .tags-edit {
    flex-wrap: nowrap; min-width: 0; overflow: hidden; justify-content: flex-end;
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 28px);
    mask-image: linear-gradient(to right, transparent 0, #000 28px);
  }
  #tag-chips { flex-wrap: nowrap; }
  .field.tags .combo { display: none; } /* hide the add-field on mobile for a clean truncated row */
  /* public + delete on their own line below the fold (revealed on scroll), right-aligned */
  .panel-actions { grid-column: 1 / -1; justify-self: end; margin-bottom: var(--pad); }

  /* tapping the tags expands them: hide project, show every tag (wrapping) */
  .panel.tags-expanded > .field:first-child { display: none; }
  .panel.tags-expanded .field.tags { grid-column: 1 / -1; justify-content: flex-start; }
  .panel.tags-expanded .tags-edit {
    flex-wrap: wrap; overflow: visible; justify-content: flex-start;
    -webkit-mask-image: none; mask-image: none;
  }
  .panel.tags-expanded #tag-chips { flex-wrap: wrap; }
}

/* clients table: drag grip + drop indicator (owner only) */
.row-grip { color: var(--label); cursor: grab; margin-right: 12px; user-select: none; transition: color 0.2s var(--ease); }
.row-grip:hover { color: var(--fg); }
#clients tr.dragging-row { opacity: 0.3 !important; }
#clients tbody tr.drop-before td { box-shadow: inset 0 1px 0 var(--fg); }
#clients tbody tr.drop-after td { box-shadow: inset 0 -1px 0 var(--fg); }
@media (max-width: 700px) { .row-grip { display: none; } }

/* sticker: drops in from the top (js/sticker.js, Matter.js) the first time the footer is on screen, lies at the page bottom and can be grabbed and thrown */
#sticker {
  position: absolute; left: 0; top: 0; z-index: 5; width: 120px; height: auto;
  pointer-events: auto; cursor: grab; touch-action: none; user-select: none; -webkit-user-drag: none; will-change: transform;
}
#sticker.grabbing { cursor: grabbing; }
@media (max-width: 700px) { #sticker { width: 96px; } }
