/* ==========================================================
   Layout: a quiet masonry canvas. Name and theme switch on top,
   one line of text, then the work. Tapping a tile zooms it open.
   Colour: three skins (paper, ink, parchment) built from 3 tokens.
   Type: Martina Plantijn for the name and titles, Söhne for the rest.
   ========================================================== */

@font-face { font-family: "Martina Plantijn"; src: url("fonts/test-martina-plantijn-regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Martina Plantijn"; src: url("fonts/test-martina-plantijn-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Söhne"; src: url("fonts/test-soehne-buch.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Söhne"; src: url("fonts/test-soehne-kraftig.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }

:root {
  /* paper (light) */
  --bg: #f1f1ee;
  --ink: #151514;
  --ink-2: #74746e;
  --ph-l: 0.84;
  --ph-c: 0.06;
  color-scheme: light;

  --line: color-mix(in srgb, var(--ink) 12%, transparent);
  --veil: color-mix(in srgb, var(--bg) 96%, transparent);

  --serif: "Martina Plantijn", "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Söhne", "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;

  --radius: 6px;
  --gap: 12px;
  --gutter: clamp(12px, 2vw, 28px);
  --ease: cubic-bezier(0.22, 0.8, 0.18, 1);
}

/* ink (dark): follows the system unless a skin is chosen */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-skin]) {
    --bg: #0c0c0d; --ink: #ecebe7; --ink-2: #8c8b86;
    --ph-l: 0.36; --ph-c: 0.07;
    color-scheme: dark;
  }
}
:root[data-theme="dark"]:not([data-skin]) {
  --bg: #0c0c0d; --ink: #ecebe7; --ink-2: #8c8b86;
  --ph-l: 0.36; --ph-c: 0.07;
  color-scheme: dark;
}

/* explicit skins win over everything */
:root[data-skin="paper"] {
  --bg: #f1f1ee; --ink: #151514; --ink-2: #74746e;
  --ph-l: 0.84; --ph-c: 0.06;
  color-scheme: light;
}
:root[data-skin="ink"] {
  --bg: #0c0c0d; --ink: #ecebe7; --ink-2: #8c8b86;
  --ph-l: 0.36; --ph-c: 0.07;
  color-scheme: dark;
}
:root[data-skin="parchment"] {
  --bg: #e5d8b9; --ink: #2a2015; --ink-2: #7a694b;
  --ph-l: 0.78; --ph-c: 0.07;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scrollbar-gutter: stable; -webkit-text-size-adjust: 100%; }
html.lb-lock { overflow: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.5s ease, color 0.5s ease;
}

a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 3px; }

/* ---------- Top bar ---------- */
.bar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 14px var(--gutter);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.brand { font: 500 17px/1 var(--sans); letter-spacing: -0.01em; text-decoration: none; }

.skins { display: flex; gap: 10px; align-self: center; }
.skin {
  width: 16px; height: 16px; border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--line);
}
.skin[data-skin="paper"] { background: #f1f1ee; }
.skin[data-skin="ink"] { background: #0c0c0d; }
.skin[data-skin="parchment"] { background: #e5d8b9; }
.skin[aria-pressed="true"] { outline: 1.5px solid var(--ink); outline-offset: 3px; }

/* ---------- Intro ---------- */
.intro { padding: clamp(36px, 8vw, 104px) var(--gutter) clamp(28px, 5vw, 56px); }
.intro h1 {
  margin: 0;
  max-width: 15ch;
  font: 400 clamp(34px, 5.2vw, 68px)/1.02 var(--serif);
  letter-spacing: -0.02em;
  text-wrap: balance;
}

/* ---------- Canvas ---------- */
.grid { display: flex; gap: var(--gap); padding: 0 var(--gutter); align-items: flex-start; }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--gap); }

.tile {
  display: block;
  position: relative;
  border-radius: var(--radius);
  text-decoration: none;
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
}
.tile.is-open { opacity: 0; }

.media {
  position: relative;
  aspect-ratio: var(--r);
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--line);
}
.media > img,
.media > video,
.media > .ph {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  object-fit: cover;
}
.frame { position: absolute; inset: 0; display: grid; place-items: center; }
.frame > video {
  position: relative;
  width: auto; display: block; object-fit: cover;
  border-radius: calc(var(--radius) * 2.5);
  box-shadow: 0 18px 40px -14px rgba(0, 0, 0, 0.35);
}
.frame > .frame-bg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.frame.plain > video { border-radius: 0; box-shadow: none; }
.ph { transition: transform 0.9s var(--ease); }
.ph-hint {
  position: absolute; left: 10px; bottom: 8px; right: 10px;
  font: 400 11px/1.3 ui-monospace, "SFMono-Regular", Menlo, monospace;
  color: color-mix(in srgb, var(--ink) 55%, transparent);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  pointer-events: none;
}

/* one orchestrated moment: the canvas settles in on load */
.grid:not(.settled) .tile {
  animation: settle 1s var(--ease) both;
  animation-delay: calc(min(var(--i), 14) * 55ms + 120ms);
}
@keyframes settle {
  from { opacity: 0; transform: translateY(18px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

/* title on hover (pointer devices only) */
.cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 36px 12px 11px;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.5), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.cap b { display: block; font-weight: 500; }
.cap span { font-size: 12px; opacity: 0.75; }
.tile:focus-visible .cap { opacity: 1; }
@media (hover: hover) {
  .tile:hover .cap { opacity: 1; }
  .tile:hover .media > img,
  .tile:hover .media > video,
  .tile:hover .ph { transform: scale(1.035); }
  .media > img, .media > video { transition: transform 0.9s var(--ease); }
}
@media (hover: none) { .cap { display: none; } }

/* ---------- Footer ---------- */
.foot {
  display: flex; flex-wrap: wrap; gap: 8px 24px;
  padding: clamp(56px, 9vw, 120px) var(--gutter) calc(32px + env(safe-area-inset-bottom, 0px));
  color: var(--ink-2);
}
.foot a { text-decoration-color: var(--line); text-underline-offset: 4px; }
.foot a:hover { color: var(--ink); text-decoration-color: currentColor; }
.foot .mail { color: var(--ink); user-select: all; }

/* ---------- Lightbox ---------- */
.lb { position: fixed; inset: 0; z-index: 100; }
.lb-veil {
  position: absolute; inset: 0;
  background: var(--veil);
  -webkit-backdrop-filter: blur(26px);
  backdrop-filter: blur(26px);
  opacity: 0;
  transition: opacity 0.55s ease;
}
.lb.is-open .lb-veil { opacity: 1; }

.lb-stage {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; gap: 48px;
  padding: 72px 96px;
}
.lb-media {
  position: relative; flex: none;
  width: var(--mw); height: var(--mh);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--line);
  will-change: transform;
}
.lb-media > img,
.lb-media > video,
.lb-media > .ph {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block; object-fit: cover;
}
.lb-media.swap { transition: opacity 0.16s ease, transform 0.16s ease; }

.lb-info { width: 280px; flex: none; align-self: flex-end; }
.lb-info > * {
  opacity: 0; transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.lb.is-open .lb-info > * {
  opacity: 1; transform: none;
  transition: opacity 0.6s ease, transform 0.7s var(--ease);
  transition-delay: calc(0.28s + var(--k) * 70ms);
}
.lb-meta { margin: 0 0 10px; color: var(--ink-2); --k: 0; }
.lb-title { margin: 0 0 14px; font: 400 clamp(30px, 3vw, 40px)/1.05 var(--serif); letter-spacing: -0.01em; text-wrap: balance; --k: 1; }
.lb-desc { margin: 0 0 22px; max-width: 46ch; --k: 2; }
.lb-links { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; --k: 3; }
.lb-links a { text-decoration-color: var(--line); text-underline-offset: 4px; }
.lb-links a:hover { text-decoration-color: currentColor; }

.lb-close {
  position: absolute; z-index: 2;
  top: calc(14px + env(safe-area-inset-top, 0px)); right: var(--gutter);
  padding: 4px 0;
}
.lb-nav {
  position: absolute; z-index: 2; top: 50%;
  width: 44px; height: 44px; margin-top: -22px;
  display: grid; place-items: center; border-radius: 50%;
  color: var(--ink-2);
  transition: color 0.2s ease;
}
.lb-nav:hover { color: var(--ink); }
.lb-nav.prev { left: 24px; }
.lb-nav.next { right: 24px; }
.lb-nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.lb-close, .lb-nav { opacity: 0; transition: opacity 0.4s ease 0.2s, color 0.2s ease; }
.lb.is-open .lb-close, .lb.is-open .lb-nav { opacity: 1; }

/* ---------- Narrow screens ---------- */
@media (max-width: 859px) {
  .lb-stage {
    flex-direction: column; justify-content: flex-start; align-items: flex-start;
    gap: 20px; padding: 64px var(--gutter) 88px;
    overflow-y: auto;
  }
  .lb-media { align-self: center; }
  .lb-info { width: 100%; align-self: stretch; }
  .lb-nav { top: auto; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); margin: 0; }
  .lb-nav.prev { left: var(--gutter); }
  .lb-nav.next { right: var(--gutter); }
}
@media (max-width: 639px) {
  :root { --gap: 8px; }
}

/* ---------- Cursor ---------- */
.has-cursor, .has-cursor * { cursor: none !important; }
.cur-dot, .cur-blob {
  position: fixed; left: 0; top: 0; z-index: 300;
  pointer-events: none;
  opacity: 0;
  will-change: transform;
}
.cur-dot { transition: opacity 0.25s ease; }
.cur-on .cur-dot { opacity: 1; }
.cur-dot svg { display: block; margin-left: -3px; }
.cur-dot.down svg { transform: translate(1px, 1px); }
.cur-blob {
  padding: 6px 12px 7px;
  border-radius: 4px 15px 15px 15px;
  background: oklch(0.82 0.11 var(--hue, 40));
  color: #1a1a18;
  font: 500 13px/1.2 var(--sans);
  white-space: nowrap;
  transition: opacity 0.2s ease, background-color 0.2s ease;
}
.cur-blob.flip { border-radius: 15px 4px 15px 15px; }
.cur-blob span { display: block; transform: scale(0.92); opacity: 0; transition: transform 0.35s var(--ease), opacity 0.2s ease; }
.cur-on .cur-blob.show { opacity: 1; }
.cur-blob.show span { transform: none; opacity: 1; }
.has-cursor .tile:hover .cap { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .grid:not(.settled) .tile { animation: none; }
  .ph, .media > img, .media > video { transition: none !important; }
  .tile:hover .ph, .tile:hover .media > img, .tile:hover .media > video { transform: none; }
  .lb-veil, .lb-info > *, .lb-close, .lb-nav { transition-duration: 0.01s !important; transition-delay: 0s !important; }
}
