/* lab.sadman.it: a dark room, the logo as a signature, the work on a bench under its own lamps. */

@font-face {
  font-family: "Bricolage";
  src: url("/fonts/bricolage.woff2") format("woff2-variations"), url("/fonts/bricolage.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Mono";
  src: url("/fonts/mono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@property --wipe {
  syntax: "<length>";
  inherits: true;
  initial-value: 0px;
}

:root {
  --bg: #0b0d10;
  --ink: #ede6da;
  --ink-2: #aaa49a;
  --dim: #6f7680;
  --line: rgba(237, 230, 218, 0.08);
  --cold: rgba(185, 210, 235, 0.07);
  --glass-edge: rgba(165, 205, 195, 0.13);

  --display: "Bricolage", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --mono: "Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --gutter: clamp(16px, 4vw, 56px);
  --gap: clamp(16px, 2.4vw, 32px);
  --radius: 12px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");

  color-scheme: dark;
}

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

html { background: var(--bg); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(60% 35% at 50% -8%, var(--cold), transparent 70%), var(--bg);
  font: 400 16px/1.55 var(--display);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

a { color: inherit; }
::selection { background: var(--ink); color: var(--bg); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: 6px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- the mark (logo) ---------- */

/* The SVG is drawn big and scaled down in the corner, so it stays sharp at both sizes. */
.mark {
  position: fixed;
  top: 14px;
  left: 16px;
  z-index: 30;
  width: 64px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--ink);
  cursor: pointer;
}
.mark .logo {
  position: absolute;
  top: 0;
  left: 0;
  width: 512px;
  height: 384px;
  overflow: visible;
  transform-origin: 0 0;
  transform: scale(0.125);
  pointer-events: none;
}
.logo path {
  fill: none;
  stroke: currentColor;
  stroke-width: 13;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke-width 0.8s var(--ease-out);
}
.logo.is-lit path { filter: drop-shadow(0 0 5px rgba(255, 214, 170, 0.35)); }

html.is-intro .mark .logo,
html.is-idle .mark .logo {
  transform: translate(calc(50vw - 16px - 256px * var(--hs, 1)), calc(50vh - 14px - 192px * var(--hs, 1))) scale(var(--hs, 1));
}
html.is-intro .logo path,
html.is-idle .mark .logo path { stroke-width: 8; }
/* hidden until logo.js starts drawing it */
html.is-intro:not(.is-drawing) .mark .logo { opacity: 0; }
html.is-intro body { overflow: hidden; }

/* ---------- back: one pill, top left, on every page but the wall ---------- */

.back {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 14px);
  left: max(16px, env(safe-area-inset-left));
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(11, 13, 16, 0.9);
  color: var(--ink-2);
  font: 400 13px/1 var(--mono);
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.2s, border-color 0.2s, transform 0.3s var(--ease-out), opacity 0.25s;
}
.back span { transition: transform 0.3s var(--ease-out); }
@media (hover: hover) {
  .back:hover { color: var(--ink); border-color: color-mix(in oklab, var(--accent, var(--ink)) 45%, var(--line)); }
  .back:hover span { transform: translateX(-3px); }
}
.back:focus-visible { color: var(--ink); outline-offset: 3px; border-radius: 999px; }
.back:active { transform: scale(0.97); }
/* scrolling down tucks it away, scrolling up brings it back */
.back.is-tucked:not(:focus-visible) { opacity: 0; transform: translateY(-12px); pointer-events: none; }

/* ---------- the gallery ---------- */

.bench {
  width: min(100% - 2 * var(--gutter), 1240px);
  margin: 0 auto;
  padding-top: clamp(96px, 11vw, 150px);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
  transition: opacity 0.6s ease;
}
/* four cases: one column, then 2 × 2, then a single row; never a half-empty row */
@media (min-width: 640px) { .bench { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1180px) { .bench { grid-template-columns: repeat(4, 1fr); } }
html.is-intro .bench,
html.is-intro .foot,
html.is-idle main,
html.is-idle .foot { opacity: 0; pointer-events: none; }
main { transition: opacity 0.6s ease; }

.case { min-width: 0; }

/* ---------- a case ---------- */

/* the card: a frame holding the case and its tag */
.case__link {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  background: linear-gradient(180deg, rgba(237, 230, 218, 0.03), rgba(237, 230, 218, 0.012));
  text-decoration: none;
  transition: transform 0.4s var(--ease-out), border-color 0.4s var(--ease-out), background-color 0.4s;
}
.case__link:hover,
.case__link:focus-visible {
  transform: translateY(-4px);
  border-color: color-mix(in oklab, var(--accent) 30%, var(--line));
}

.case__glass {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(120% 80% at 50% 115%, #050608, transparent 60%),
    linear-gradient(180deg, #0f1318, #0a0c0f);
  box-shadow:
    inset 0 0 0 1px var(--glass-edge),
    inset 0 0 0 5px rgba(165, 205, 195, 0.022),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -40px 60px -20px rgba(0, 0, 0, 0.7),
    0 34px 60px -34px rgba(0, 0, 0, 0.95);
  transition: box-shadow 0.4s var(--ease-out);
}

/* the shelf the specimen stands on */
.case__glass::after {
  content: "";
  position: absolute;
  left: 16%;
  right: 16%;
  bottom: 12%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(237, 230, 218, 0.1), transparent);
  z-index: 1;
}

.case__light {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(45% 62% at 50% -6%, color-mix(in oklab, var(--accent) 28%, transparent), transparent 72%),
    radial-gradient(70% 55% at 50% -10%, rgba(200, 220, 240, 0.08), transparent 70%);
  opacity: 0;
  transition: opacity 0.45s ease-out;
}
.case__light::before {
  content: "";
  position: absolute;
  top: 0;
  left: 40%;
  right: 40%;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 245, 230, 0.8), transparent);
  box-shadow: 0 0 14px 2px color-mix(in oklab, var(--accent) 40%, transparent);
}

.specimen {
  position: absolute;
  inset: 9% 7% 14%;
  z-index: 2;
  display: grid;
  place-items: center;
  color: var(--accent);
  opacity: 0.16;
  filter: saturate(0.2) brightness(0.7);
  transition: opacity 0.45s ease-out, filter 0.45s ease-out;
}
.specimen > svg,
.specimen > canvas { width: 100%; height: 100%; display: block; }

.case__reflect {
  position: absolute;
  inset: -40%;
  z-index: 4;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, 0.05) 48%, rgba(255, 255, 255, 0.012) 53%, transparent 58%);
  transform: translate3d(calc((var(--mx, 0.5) - 0.5) * 26%), calc((var(--my, 0.5) - 0.5) * 14%), 0);
}

.case.is-lit .case__light,
html:not(.js) .case__light { opacity: var(--lamp, 1); }

/* lamps come on like neon tubes: a couple of false starts, then steady */
.case.is-lit .case__light { animation: neon 0.9s steps(1, end) both; }
.case.is-lit .specimen { animation: neon-specimen 0.9s steps(1, end) both; }
.case:nth-child(3n + 2).is-lit .case__light,
.case:nth-child(3n + 2).is-lit .specimen { animation-duration: 0.7s; }
.case:nth-child(3n).is-lit .case__light,
.case:nth-child(3n).is-lit .specimen { animation-duration: 1.1s; }
@keyframes neon {
  0% { opacity: 0; }
  8% { opacity: calc(var(--lamp, 1) * 0.75); }
  14% { opacity: 0.05; }
  26% { opacity: calc(var(--lamp, 1) * 0.9); }
  31% { opacity: 0.15; }
  40%, 100% { opacity: var(--lamp, 1); }
}
@keyframes neon-specimen {
  0% { opacity: 0.16; }
  8% { opacity: 0.7; }
  14% { opacity: 0.16; }
  26% { opacity: 0.85; }
  31% { opacity: 0.3; }
  40%, 100% { opacity: 1; }
}
.case.is-lit .specimen,
html:not(.js) .specimen { opacity: 1; filter: none; }

.case__link:hover .case__glass,
.case__link:focus-visible .case__glass {
  box-shadow:
    inset 0 0 0 1px color-mix(in oklab, var(--accent) 32%, var(--glass-edge)),
    inset 0 0 0 5px rgba(165, 205, 195, 0.022),
    inset 0 1px 0 rgba(255, 255, 255, 0.11),
    inset 0 -40px 60px -20px rgba(0, 0, 0, 0.7),
    0 44px 70px -34px rgba(0, 0, 0, 1);
}
.case__link:focus-visible { outline-offset: 6px; }

/* in progress: a faint blueprint grid behind the unfinished object, warmer lamp */
.case[data-status="wip"] .case__glass::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(rgba(120, 170, 220, 0.05) 1px, transparent 1px) 0 0 / 18px 18px,
    linear-gradient(90deg, rgba(120, 170, 220, 0.05) 1px, transparent 1px) 0 0 / 18px 18px;
}
.case[data-status="wip"] .case__light { filter: sepia(0.4); }

/* archived: dimmer lamp and dust you can wipe with the pointer */
.dust {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: var(--noise), linear-gradient(180deg, rgba(190, 185, 170, 0.1), rgba(190, 185, 170, 0.04));
  background-size: 160px 160px, auto;
  opacity: 0.2;
  mix-blend-mode: screen;
  -webkit-mask: radial-gradient(circle var(--wipe) at calc(var(--mx, 0.5) * 100%) calc(var(--my, 0.5) * 100%), transparent 35%, #000 100%);
  mask: radial-gradient(circle var(--wipe) at calc(var(--mx, 0.5) * 100%) calc(var(--my, 0.5) * 100%), transparent 35%, #000 100%);
  transition: --wipe 0.5s var(--ease-out);
}
.case__link:hover .dust { --wipe: 130px; }
/* its lamp is old: dim, and now and then it stutters */
.case[data-status="archived"] { --lamp: 0.4; }
.case[data-status="archived"].is-lit .case__light { animation: neon 0.9s steps(1, end) both, stutter 9s 2s steps(1, end) infinite; }
@keyframes stutter {
  0%, 91%, 100% { opacity: 0.4; }
  92% { opacity: 0.08; }
  93% { opacity: 0.35; }
  94.5% { opacity: 0.05; }
  96% { opacity: 0.4; }
}
.case[data-status="archived"].is-lit .specimen { filter: saturate(0.5) brightness(0.8); }

/* ---------- the tag under a case ---------- */

.tag { padding: 16px 10px 12px; }

.case__name {
  margin: 0;
  font: 600 clamp(1.2rem, 1.7vw, 1.45rem)/1.15 var(--display);
  letter-spacing: -0.015em;
}
.tag__year {
  margin-left: 0.35em;
  font: 400 0.62em/1 var(--mono);
  letter-spacing: 0.04em;
  color: var(--dim);
  vertical-align: 0.15em;
}
.tag__note {
  margin: 6px 0 0;
  max-width: 36ch;
  color: var(--ink-2);
  line-height: 1.45;
}

/* ---------- footer ---------- */

.foot {
  width: min(100% - 2 * var(--gutter), 1320px);
  margin: clamp(96px, 12vw, 180px) auto 0;
  padding-block: 0 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font: 400 12px/1 var(--mono);
  transition: opacity 0.6s ease;
}
.foot a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink-2); text-decoration: none; }

.sign { display: block; width: 44px; height: 33px; color: var(--ink); opacity: 0; transition: opacity 0.4s; }
.sign.is-on, html:not(.js) .sign { opacity: 0.55; }
.sign .logo { width: 100%; height: 100%; overflow: visible; }

/* on a project page the logo glows in the project's colour */
.page-exp .logo.is-lit path { filter: drop-shadow(0 0 6px color-mix(in oklab, var(--accent) 70%, transparent)); }

/* ---------- 404 ---------- */

.lost {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 96px var(--gutter);
}
.lost__case { display: block; width: min(100%, 420px); text-decoration: none; text-align: center; }
.lost__glass {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #0f1318, #0a0c0f);
  box-shadow: inset 0 0 0 1px var(--glass-edge), inset 0 -40px 60px -20px rgba(0, 0, 0, 0.7), 0 34px 60px -34px rgba(0, 0, 0, 0.95);
}
.lost__light {
  position: absolute;
  inset: 0;
  background: radial-gradient(45% 62% at 50% -6%, rgba(255, 214, 170, 0.22), transparent 72%);
  animation: dead-lamp 4s steps(1, end) infinite;
}
.lost__glass .logo {
  position: relative;
  width: 62%;
  overflow: visible;
  color: var(--ink);
  opacity: 0.35;
  transition: opacity 0.3s;
}
.lost__case.is-on .lost__light { animation: none; opacity: 1; }
.lost__case.is-on .logo { opacity: 1; }
.lost__title { margin: 22px 0 6px; font: 600 1.4rem/1.2 var(--display); letter-spacing: -0.015em; }
.lost__back { margin: 0; font: 400 13px/1.4 var(--mono); color: var(--ink-2); }
.lost__case:hover .lost__back, .lost__case:focus-visible .lost__back { color: var(--ink); }
@keyframes dead-lamp {
  0%, 100% { opacity: 0; }
  12% { opacity: 0.6; }
  14% { opacity: 0; }
  16% { opacity: 0.4; }
  18% { opacity: 0; }
  63% { opacity: 0.25; }
  64% { opacity: 0; }
}
.foot a:hover { color: var(--ink); }

/* ---------- project page / dialog ---------- */

.exp {
  width: min(100% - 2 * var(--gutter), 1200px);
  margin: 0 auto;
  display: grid;
  gap: clamp(24px, 4vw, 64px);
  padding-top: clamp(84px, 9vw, 120px);
}
@media (min-width: 900px) {
  .exp { grid-template-columns: 1.1fr 1fr; align-items: start; }
  .exp__case { position: sticky; top: 96px; }
}
.exp__case .case__glass { aspect-ratio: 4 / 3; }

.exp__text { max-width: 58ch; }
.exp__name {
  margin: 0 0 10px;
  font: 700 clamp(2.4rem, 5vw, 3.8rem)/1 var(--display);
  font-variation-settings: "opsz" 96;
  letter-spacing: -0.035em;
}
.exp__name .tag__year { font-size: 0.3em; }
.exp__note { margin: 0 0 26px; font-size: 1.25rem; line-height: 1.4; color: var(--ink); }
.exp__text > p:not([class]) { color: var(--ink-2); margin: 0 0 1em; }

.exp__try {
  display: inline-block;
  margin-top: 22px;
  padding: 12px 22px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--accent) 85%, var(--ink));
  color: var(--bg);
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.3s var(--ease-out), filter 0.3s;
}
.exp__try:hover { transform: translateY(-2px); filter: brightness(1.08); }
.exp__links { list-style: none; display: flex; flex-wrap: wrap; gap: 18px; margin: 18px 0 0; padding: 0; }
.exp__links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: color-mix(in oklab, var(--accent) 75%, var(--ink));
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.exp__nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 40px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  font: 400 13px/1.4 var(--mono);
}
.exp__nav a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink-2); text-decoration: none; }
.exp__nav a:hover { color: var(--ink); }

.exp-dialog {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0 0 48px;
  border: 0;
  background: var(--bg);
  color: var(--ink);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.exp-dialog::backdrop { background: rgba(5, 6, 8, 0.7); }

/* inside the dialog the pill sits in the same corner as on the project page */
.exp-dialog:focus { outline: none; }

html:has(.exp-dialog[open]) { overflow: hidden; }

/* ---------- view transitions ---------- */

::view-transition-group(*) {
  animation-duration: 0.55s;
  animation-timing-function: var(--ease-out);
}
::view-transition-old(exp-glass),
::view-transition-new(exp-glass) {
  height: 100%;
  object-fit: cover;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .case__reflect { transform: none; }
  .lost__light { opacity: 0.3; }
}
