/* brenhq.com: software on a shelf.
   One light, the lamp's: up and to the right. Every shadow falls away from it, and is a darker red, never black.
   Layers: shelves 1, dim 3, held box 4, grain 5 (paint sits over everything but the skip link), skip link 6. */

@font-face {
  font-family: "Familjen Grotesk";
  src: url("fonts/familjen-grotesk.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --wall: #BC3723;
  /* The plank: stained cherry. --wood shows under the texture while it loads; --wood-dim darkens it with the lights off. */
  --wood: #6A2110;
  --wood-dim: 0;
  --ink: #FFF6EC;
  --soft: #FFE4D8;
  --sky: #A9CEF2;
  --on-sky: #2A0D08;
  --shadow: 74 10 3;
  --glow: 255 196 168;
  --glow-a: .26;
  --cast-a: .58;
  --dim-a: .5;
  --ease: cubic-bezier(.16, 1, .3, 1);

  /* The light is the lamp's. --lx runs -1 (far left) to 1, --ly 0 (high) to 1 (low). It sits where the lamp hangs,
     up and to the right; JS lets the pointer nudge it a little, never off the lamp's side. */
  --lx: .55;
  --ly: .15;
  --glow-y: 540px;

  color-scheme: light;
}

/* The lamp's state, as a number the shelf's pool can fade with (registered so it transitions; elsewhere it snaps). */
@property --lamp-on { syntax: "<number>"; inherits: true; initial-value: 1; }
:root { --lamp-on: 1; transition: --lamp-on .12s ease-out; }

/* Lights off: the same room with the light down. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --wall: #3A110C;
    --wood: #3A1209;
    --wood-dim: .38;
    --ink: #FBE9DF;
    --soft: #D9A898;
    --shadow: 16 3 1;
    --glow: 255 140 100;
    --glow-a: .1;
    --cast-a: .7;
    --dim-a: .55;
    --lamp-on: 0;
    transition-duration: .32s;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --wall: #3A110C;
  --wood: #3A1209;
  --wood-dim: .38;
  --ink: #FBE9DF;
  --soft: #D9A898;
  --shadow: 16 3 1;
  --glow: 255 140 100;
  --glow-a: .1;
  --cast-a: .7;
  --dim-a: .55;
  --lamp-on: 0;
  transition-duration: .32s;
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Familjen Grotesk", system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.45;
  color: var(--ink);
  background-color: var(--wall);
  /* The light lands on the shelf, not behind the words. */
  background-image: radial-gradient(min(1100px, 120vw) 420px at calc(50% + var(--lx) * 30%) calc(var(--glow-y) + var(--ly) * 40px), rgb(var(--glow) / var(--glow-a)), transparent 72%);
  overflow-x: hidden;
  transition: background-color .5s var(--ease), color .5s var(--ease);
}

/* Paint grain over the whole wall, fixed so it never repaints on scroll. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: .32;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.4 -.35'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; }

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

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 16px; top: -60px; z-index: 6;
  padding: 10px 14px; border-radius: 3px;
  background: var(--sky); color: var(--on-sky); font-weight: 600; text-decoration: none;
}
.skip:focus { top: 12px; }

/* ---------- The room: first screen ---------- */

.room {
  position: relative;
  overflow-x: clip;

  display: flex;
  flex-direction: column;
  padding: 52px 56px 72px;
  max-width: 1520px;
  margin: 0 auto;
  /* One unit for every box size, set by the width alone: a short window scrolls a little rather than shrink the boxes. */
  --u: max(.42px, min(1px, calc((100vw - 112px) / 1470)));
}

.intro { max-width: 1100px; }

h1 {
  margin: 0;
  /* The floor is 48px so that from 761px wide the one-line headline ends well short of the light switch. */
  font-size: clamp(48px, 6.1vw, 88px);
  font-weight: 600;
  line-height: .98;
  letter-spacing: -.035em;
  text-wrap: balance;
}

.lead {
  margin: 20px 0 0;
  max-width: 34ch;
  font-size: 20px;
  line-height: 1.4;
  color: var(--soft);
  text-wrap: pretty;
}

.follow {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  margin-top: 26px;
  padding: 0 20px;
  border-radius: 3px;
  background: var(--sky);
  color: var(--on-sky);
  font-weight: 600;
  font-size: 18px;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 1px 0 rgb(255 255 255 / .5) inset, 0 -3px 0 rgb(42 13 8 / .18) inset, -6px 8px 0 -2px rgb(var(--shadow) / .45);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.follow:hover { transform: translateY(-2px); box-shadow: 0 1px 0 rgb(255 255 255 / .5) inset, 0 -3px 0 rgb(42 13 8 / .18) inset, -8px 11px 0 -2px rgb(var(--shadow) / .4); }
.follow:active { transform: translateY(2px); box-shadow: 0 1px 0 rgb(255 255 255 / .5) inset, 0 -2px 0 rgb(42 13 8 / .18) inset, -3px 4px 0 -2px rgb(var(--shadow) / .5); }

/* The light switch: a small plate on the wall. */
.lights {
  position: absolute;
  top: 54px;
  right: 56px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 4px 6px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
}
.lights .switch {
  position: relative;
  width: 24px;
  height: 36px;
  border-radius: 3px;
  background: #FFF6EC;
  box-shadow: 0 1px 0 rgb(255 255 255 / .8) inset, -3px 5px 6px rgb(var(--shadow) / .55);
}
.lights .switch::after {
  content: "";
  position: absolute;
  left: 7px; right: 7px; top: 7px; height: 13px;
  border-radius: 2px;
  background: linear-gradient(#F1E2D6, #D9C3B3);
  box-shadow: 0 2px 0 #B79E8D;
  transition: transform .25s var(--ease);
}
:root[data-theme="dark"] .lights .switch::after { transform: translateY(9px); box-shadow: 0 -2px 0 #B79E8D; background: linear-gradient(#D9C3B3, #F1E2D6); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .lights .switch::after { transform: translateY(9px); box-shadow: 0 -2px 0 #B79E8D; background: linear-gradient(#D9C3B3, #F1E2D6); }
}
.lights:hover .lights-label { text-decoration: underline; text-underline-offset: 4px; }

/* ---------- The lamp ----------
   Poly Haven's CC0 "Desk Lamp Arm 01" rendered in Blender Cycles (img/lamp-source.txt). It is the room's light: its
   shade is aimed down and to the left at the shelf, it is lit from its own side, and the beam is rendered too.
   From 1000px it hangs in through the top edge between the headline and the switch; narrower, the same lamp reaches in
   through the right edge under the switch. The lit render lies over the unlit one and the switch fades it: 120ms on,
   320ms off. Its one pool of light sits at z-index -1, on the wall under everything else. */
.lamp {
  position: absolute;
  top: 0;
  right: calc(76px + 206 * var(--u));
  width: calc(172 * var(--u));
  aspect-ratio: 344 / 834;
  pointer-events: none;
}
.lamp picture, .lamp img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
/* The arm's shadow on the wall: a baked mask filled with the room's shadow red, so it follows both themes and the light. */
.lamp-shadow {
  position: absolute;
  inset: 0;
  background: rgb(var(--shadow) / .55);
  -webkit-mask: url("img/lamp-top-shadow.webp") 0 0 / 100% 100% no-repeat;
  mask: url("img/lamp-top-shadow.webp") 0 0 / 100% 100% no-repeat;
  translate: calc((var(--lx) - .55) * -16 * var(--u)) 0;
}
.lamp-lit { opacity: 1; transition: opacity .12s ease-out; }
/* The beam: what the bulb puts on the wall, rendered (render/render_lamp.py, the "beam" pass) and used as a mask filled
   with warm light. It runs down and to the left to the shelf, sits at z-index -1 under the shelf and the boxes, and
   fades out above the head and at its far edge, so it is never behind a word. */
.lamp::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: -367.5%; top: 39.2%; width: 523.3%; height: 115.1%;
  background: rgb(255 212 164 / var(--beam-a, .36));
  -webkit-mask: url("img/lamp-top-beam.webp") 0 0 / 100% 100% no-repeat;
  mask: url("img/lamp-top-beam.webp") 0 0 / 100% 100% no-repeat;
  transition: opacity .12s ease-out;
}
/* Pressing the lamp's head presses the switch (app.js). No tab stop and no words: the switch is the control. */
.lamp-head { position: absolute; left: 40.5%; top: 60.5%; width: 55.3%; height: 24.2%; border-radius: 45%; }
html.js .lamp-head { pointer-events: auto; cursor: pointer; }
:root[data-theme="dark"] .lamp-lit, :root[data-theme="dark"] .lamp::before { opacity: 0; transition-duration: .32s; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .lamp-lit, :root:not([data-theme="light"]) .lamp::before { opacity: 0; transition-duration: .32s; }
}
/* Narrower: the side view, reaching in through the right edge under the switch; the arm runs on past the edge. */
@media (max-width: 999px) {
  .lamp { top: 95px; right: calc(-99.6 * var(--u)); width: calc(390.9 * var(--u)); aspect-ratio: 482 / 418; }
  .lamp-shadow { -webkit-mask-image: url("img/lamp-side-shadow.webp"); mask-image: url("img/lamp-side-shadow.webp"); }
  .lamp::before { left: -139%; top: 22.5%; width: 228.2%; height: 394.7%;
    -webkit-mask-image: url("img/lamp-side-beam.webp"); mask-image: url("img/lamp-side-beam.webp"); }
  .lamp-head { left: 20.5%; top: 43.4%; width: 30.6%; height: 37.4%; }
}

/* ---------- Shelves ---------- */

.shelves {
  position: relative;
  z-index: 1;
  margin-top: clamp(24px, 5vh, 60px);
  padding-top: 40px;
  display: flex;
  align-items: flex-end;
  /* One camera for every box: above the shelf, a little left of centre. */
  perspective: 1500px;
  perspective-origin: 46% -45%;
  /* Plank sizes. --front: how far the plank's front edge stands out from the box fronts;
     --wall: how far back the wall is. */
  --lip: max(46px, calc(52 * var(--u)));
  --front: calc(18 * var(--u));
  --wall: calc(108 * var(--u));
}

.shelf {
  position: relative;
  transform-style: preserve-3d;
  padding-bottom: var(--lip);
  --pool-w: calc(170 * var(--u));   /* half the width of the lit patch the beam makes on the plank */
}
.shelf-a { flex: none; padding-left: calc(36 * var(--u)); }
.shelf-b { flex: 1; padding-right: calc(110 * var(--u)); }

/* Top of the plank: a real plane lying flat, running from its front edge back to the wall. */
.shelf::before {
  content: "";
  position: absolute;
  left: 0; right: 0;
  top: calc(100% - var(--lip));
  height: calc(var(--front) + var(--wall));
  transform-origin: 50% 0;
  transform: translateZ(var(--front)) rotateX(-90deg);
  /* Its first pixel row is the front corner, its last the wall. Lit from above: lighter than the front edge,
     a worn corner, a satin sheen that follows the light, and shade where it meets the wall. */
  background:
    radial-gradient(var(--pool-w) 130% at var(--pool-x, -9999px) 40%, rgb(255 214 168 / calc(.34 * var(--lamp-on))), rgb(255 214 168 / 0)),
    linear-gradient(to bottom, rgb(255 226 204 / .32) 0, rgb(255 226 204 / .14) 1.5px, transparent 3px),
    linear-gradient(100deg, transparent calc(22% + var(--lx) * 30%), rgb(255 238 224 / .09) calc(42% + var(--lx) * 30%), transparent calc(62% + var(--lx) * 30%)),
    linear-gradient(to bottom, rgb(255 232 214 / .14), rgb(255 232 214 / .05) 50%, rgb(var(--shadow) / .3) 100%),
    linear-gradient(rgb(var(--shadow) / var(--wood-dim)), rgb(var(--shadow) / var(--wood-dim))),
    url("img/wood-top.webp") var(--wood-x, 0px) 0 / 1728px 100% repeat-x,
    var(--wood);
}
/* Front edge of the plank: the lip that carries the names. */
.shelf::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  top: calc(100% - var(--lip));
  height: var(--lip);
  transform: translateZ(var(--front));
  /* In shade below the top: darker than the top, a worn highlight on the upper corner, a dark line on the lower one,
     and a tight shadow on the wall under it. */
  background:
    radial-gradient(var(--pool-w) 160% at var(--pool-x, -9999px) 0, rgb(255 214 168 / calc(.14 * var(--lamp-on))), rgb(255 214 168 / 0)),
    linear-gradient(to bottom, rgb(255 228 206 / .36) 0, rgb(255 228 206 / .16) 1.5px, transparent 3px),
    linear-gradient(to top, rgb(28 5 2 / .6) 0, rgb(28 5 2 / .6) 1px, transparent 2.5px),
    linear-gradient(100deg, transparent calc(24% + var(--lx) * 30%), rgb(255 238 224 / .05) calc(42% + var(--lx) * 30%), transparent calc(60% + var(--lx) * 30%)),
    linear-gradient(to bottom, rgb(var(--shadow) / .24), rgb(var(--shadow) / .36) 70%, rgb(var(--shadow) / .5)),
    linear-gradient(rgb(var(--shadow) / var(--wood-dim)), rgb(var(--shadow) / var(--wood-dim))),
    url("img/wood-edge.webp") var(--wood-x, 0px) 0 / 1728px 100% repeat-x,
    var(--wood);
  box-shadow: 0 5px 5px -3px rgb(var(--shadow) / .65);
}
.shelves::before {
  content: "";
  position: absolute;
  left: calc(16px - 12 * var(--u)); right: calc(-12 * var(--u));
  bottom: -34px;
  height: 40px;
  background: linear-gradient(to bottom, rgb(var(--shadow) / calc(var(--cast-a) * .8)), rgb(var(--shadow) / 0));
  filter: blur(6px);
}
.shelf-a::before, .shelf-a::after { left: calc(-12 * var(--u)); right: -24px; }
.shelf-b::before, .shelf-b::after { right: calc(-12 * var(--u)); }
/* One board across both shelves: the second picks the grain up where the first leaves it (shelf one is 692 units wide). */
.shelf-b { --wood-x: calc(-704 * var(--u)); }

.row {
  position: relative;
  display: flex;
  align-items: flex-end;
  transform-style: preserve-3d;
  margin-bottom: 0;
}

/* ---------- One box ---------- */

.slot {
  position: relative;
  flex: none;
  transform-style: preserve-3d;
  --W: var(--w); --H: var(--h); --D: var(--d); --RY: var(--ry); --RZ: var(--rz, 0);
  --bw: calc(var(--W) * var(--u));
  --bh: calc(var(--H) * var(--u));
  --bd: calc(var(--D) * var(--u));
  width: var(--bw);
  height: var(--bh);
  /* Where the light throws this box's shadow on the wall. */
  --sx: calc(var(--lx) * -72px);
  --sy: calc(12px - var(--ly) * 10px);
}
.slot + .slot { margin-left: calc(var(--gap, 40) * var(--u)); }
/* Five boxes, one even gap between each pair, across the join between the two shelves too. */
.shelf-a .slot:nth-child(2) { --gap: 48; }
.shelf-b .slot:nth-child(1) { --gap: 0; margin-left: calc(48 * var(--u)); }
.shelf-b .slot:nth-child(n+2) { --gap: 48; }

.drop, .lean {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}
.lean {
  transform-origin: 0 100%;
  transform: rotateZ(calc(var(--RZ) * 1deg));
  transition: transform .3s var(--ease);
}

.box {
  position: absolute;
  inset: 0;
  width: var(--bw);
  height: var(--bh);
  transform-style: preserve-3d;
  transform-origin: 50% 100% calc(var(--bd) * -.5);
  transform: rotateY(calc(var(--RY) * 1deg));
  transition: transform .3s var(--ease);
}

.face {
  position: absolute;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--pack);
}
.face::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}
/* Lights off, the boxes on the shelf dim with the room, as the wood does: a layer of the room's shadow over each face,
   faded by --lamp-on so it follows the bulb. Fronts with a dark printing need less. The box in your hands is outside
   any .slot, so it gets none and its label keeps its contrast. */
.slot { --dim-side: .34; --dim-front: .34; }
.slot:has(source[data-theme-source]) { --dim-front: .12; }
/* Usage's field stays a light grey panel in its own dark theme, so its dark printing barely darkens: it dims nearer the packaging. */
.shelves .slot[data-build="usage"] { --dim-front: .52; --dim-side: .5; }   /* its own dark theme keeps the field light, so the room does the dimming */
.face { --dim-fill: linear-gradient(rgb(var(--shadow) / calc(var(--dim-side, 0) * (1 - var(--lamp-on)))), rgb(var(--shadow) / calc(var(--dim-side, 0) * (1 - var(--lamp-on))))); }
.front { --dim-fill: linear-gradient(rgb(var(--shadow) / calc(var(--dim-front, 0) * (1 - var(--lamp-on)))), rgb(var(--shadow) / calc(var(--dim-front, 0) * (1 - var(--lamp-on))))); }
.front { inset: 0; padding: calc(var(--bw) * .04) calc(var(--bw) * .04) calc(var(--bw) * .085); border-radius: 1px; }
.front img {
  display: block; width: 100%; height: 100%;
  object-fit: cover; object-position: 0 0;
  border-radius: 1px;
  box-shadow: 0 0 0 1px rgb(0 0 0 / .18);
}
/* The printed band under the picture. */
.front::before {
  content: "";
  position: absolute;
  left: calc(var(--bw) * .04);
  bottom: calc(var(--bw) * .03);
  width: 34%;
  height: calc(var(--bw) * .022);
  background: var(--band);
  border-radius: 1px;
}
.front::after {
  background:
    var(--dim-fill),
    linear-gradient(115deg, rgb(255 255 255 / 0) 30%, rgb(255 255 255 / .16) 42%, rgb(255 255 255 / 0) 52%) calc(50% + var(--lx) * 60%) 0 / 220% 100% no-repeat,
    linear-gradient(210deg, rgb(255 250 240 / .22) 0%, rgb(255 250 240 / 0) 38%, rgb(var(--shadow) / 0) 60%, rgb(var(--shadow) / .22) 100%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .45), inset -1px 0 0 rgb(255 255 255 / .2), inset 1px 0 0 rgb(var(--shadow) / .3);
}
.back { inset: 0; transform: translateZ(calc(var(--bd) * -1)) rotateY(180deg); }
.right {
  top: 0; left: 100%;
  width: var(--bd); height: 100%;
  transform-origin: 0 50%;
  transform: rotateY(90deg);
  background: var(--side, var(--pack));
}
.right::after { background: var(--dim-fill), linear-gradient(to bottom, rgb(var(--shadow) / calc(.30 - var(--lx) * .14)), rgb(var(--shadow) / calc(.5 - var(--lx) * .14))); }
.left {
  top: 0; right: 100%;
  width: var(--bd); height: 100%;
  transform-origin: 100% 50%;
  transform: rotateY(-90deg);
  background: var(--side, var(--pack));
}
.left::after { background: var(--dim-fill), linear-gradient(to bottom, rgb(255 245 235 / calc(.16 - var(--lx) * .1)), rgb(var(--shadow) / calc(.12 + var(--lx) * .14))); }
.top {
  left: 0; bottom: 100%;
  width: 100%; height: var(--bd);
  transform-origin: 50% 100%;
  transform: rotateX(90deg);
}
.top::after { background: var(--dim-fill), linear-gradient(to top, rgb(255 248 240 / .34), rgb(255 248 240 / .12)); }
.bottom {
  left: 0; top: 100%;
  width: 100%; height: var(--bd);
  transform-origin: 50% 0;
  transform: rotateX(-90deg);
}

/* The shadow the box throws on the wall behind it. */
.cast {
  position: absolute;
  left: 0; bottom: 0;
  width: calc(var(--bw) + var(--bd) * .3);
  height: calc(var(--bh) * .96);
  background: linear-gradient(to bottom, rgb(var(--shadow) / calc(var(--cast-a) * .55)), rgb(var(--shadow) / var(--cast-a)) 70%);
  border-radius: 4px;
  filter: blur(10px);
  transform: translateZ(calc(var(--wall) * -1 + 2px)) translate(var(--sx), calc(var(--sy) + var(--bh) * .04)) rotateZ(calc(var(--RZ) * 1deg));
  transform-origin: 0 100%;
  transition: opacity .3s var(--ease);
}
/* The shadow on the plank under it, lying flat. */
.footprint {
  position: absolute;
  left: calc(var(--bd) * -.15);
  top: 100%;
  width: calc(var(--bw) + var(--bd) * .5);
  height: calc(var(--bd) + 14px);
  transform-origin: 50% 0;
  transform: translateZ(10px) rotateX(-90deg) translateX(calc(var(--sx) * .35));
  background: radial-gradient(ellipse 58% 62% at 52% 36%, rgb(var(--shadow) / .62), rgb(var(--shadow) / 0) 100%);
  transition: opacity .3s var(--ease);
}

/* The button that turns the box sits over it; the box itself is the picture. */
.turn {
  position: absolute;
  inset: -10px -10px 3px;
  z-index: 1;
  padding: 0; margin: 0; border: 0;
  background: transparent;
  font-size: 0;
  color: transparent;
  cursor: pointer;
  /* In front of the plank too, so its focus ring is never hidden by the 3D sort. */
  transform: translateZ(calc(var(--front) + 6px));
}
/* The ring is drawn inside the button's own box: an outline outside it gets cut by the 3D sort. */
.turn::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 3px solid transparent;
  border-radius: 4px;
}
.turn:focus-visible { outline: none; }
.turn:focus-visible::after { border-color: var(--sky); }

/* The name on the lip: a plain link. */
.lip-label {
  position: absolute;
  left: 50%;
  top: 100%;
  height: var(--lip);
  display: flex;
  align-items: center;
  padding: 0 4px;
  translate: -50% 0;
  transform: translateZ(calc(var(--front) + 3px));
  padding-top: 8px;
  /* A name wider than its box wraps to two lines rather than run into the next name. */
  width: max-content;
  max-width: calc(var(--bw) + 12px);
  text-align: center;
  text-wrap: balance;
  font-size: 17px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.005em;
  text-decoration: none;
  color: var(--ink);
}
.lip-label:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 5px; }
.lip-label:focus-visible { outline: none; }
.lip-label::after {
  content: "";
  position: absolute;
  inset: 13px -5px 3px;
  border: 3px solid transparent;
  border-radius: 3px;
}
.lip-label:focus-visible::after { border-color: var(--sky); }

.back-copy[hidden] { display: none; }

/* Hover or keyboard focus: the box turns to face you. */
@media (hover: hover) {
  .slot:hover .box { transform: translateY(-5px) rotateY(0deg); }
  .slot:hover .lean { transform: rotateZ(0deg); }
}
.slot:has(.turn:focus-visible) .box { transform: translateY(-5px) rotateY(0deg); }
.slot:has(.turn:focus-visible) .lean { transform: rotateZ(0deg); }

/* While its box is in your hands, the slot keeps only a clean patch of plank. */
.slot.is-out .drop { visibility: hidden; }
.slot.is-out .cast { opacity: 0; }
.slot.is-out .footprint { background: radial-gradient(ellipse 50% 50% at 50% 40%, rgb(255 236 220 / .14), rgb(255 236 220 / 0)); }

/* ---------- Packaging: each build's own box colours ---------- */
.pack-wb { --pack: #1B2A4A; --band: linear-gradient(90deg, #D9774F 0 50%, #149E86 50% 100%); --side: linear-gradient(to bottom, #1B2A4A 0 80%, #D9774F 80% 84%, #1B2A4A 84% 86%, #149E86 86% 90%, #1B2A4A 90%); }
.pack-usage { --pack: #2E8A3D; --band: repeating-linear-gradient(90deg, #F4F1E8 0 3px, transparent 3px 14px); --side: linear-gradient(to bottom, #2E8A3D 0 84%, #F4F1E8 84% 86%, #2E8A3D 86%); }
.pack-draft { --pack: #1E1F22; --band: linear-gradient(90deg, #2DA44E 0 33%, #2F7FC1 33% 66%, #E8833A 66%); --side: linear-gradient(to bottom, #1E1F22 0 78%, #2DA44E 78% 82%, #2F7FC1 82% 86%, #E8833A 86% 90%, #1E1F22 90%); }
.pack-domain { --pack: #111827; --band: linear-gradient(90deg, #047857 0 62%, #059669 62% 78%, #F8FAFC 78%); --side: linear-gradient(to bottom, #111827 0 80%, #047857 80% 85%, #111827 85% 87%, #059669 87% 90%, #111827 90%); }
.pack-bison { --pack: #E9B624; --band: linear-gradient(90deg, #C8401E 0 70%, #1E1A14 70%); --side: linear-gradient(to bottom, #E9B624 0 66%, #C8401E 66% 80%, #1E1A14 80%); }

/* ---------- Notes on the lip ---------- */
.lip-hint, .shelf-note {
  position: absolute;
  bottom: 0;
  height: var(--lip);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 18px;
  transform: translateZ(calc(var(--front) + 1px));
  font-size: 15px;
  color: var(--ink);
  white-space: nowrap;
}
.lip-hint { left: 0; }
.shelf-note { right: calc(4 * var(--u)); z-index: 1; }
.shelf-note .hint { display: none; }
.count { font-variant-numeric: tabular-nums; }

/* When the boxes shrink, the first name reaches the hint: the hint and the count go under the plank, as on a phone. */
@media (min-width: 761px) and (max-width: 1199px) {
  /* The shelf sits higher here, so the light falls on the wall words under it ("Open source", the hint, the count):
     a softer light keeps them at 4.5:1 or better wherever the pointer carries it. Lights off keeps its own value. */
  :root { --glow-a: .18; }
  .lip-hint { display: none; }
  .shelf-note { top: calc(100% + 16px); bottom: auto; left: 0; right: 0; height: auto; justify-content: space-between; transform: none; }
  .shelf-note .hint { display: inline; }
}

/* Without scripts a box is a plain link: no hint to press it and no light switch. */
html:not(.js) .lights, html:not(.js) .lip-hint, html:not(.js) .shelf-note .hint { display: none; }
/* A box turned toward you stands in front of its link in the 3D sort: let a press go through the box to the link,
   and reach the link a little further up and down, where the box top and the near corner show past it. */
html:not(.js) .drop { pointer-events: none; }
html:not(.js) .turn::before { content: ""; position: absolute; inset: -12px 0 -12px; }

/* ---------- The box in your hands ---------- */

.dim {
  position: fixed;
  inset: 0;
  z-index: 3;
  background: rgb(var(--shadow) / var(--dim-a));
  opacity: 0;
  pointer-events: none;
  transition: opacity .45s var(--ease);
}
.room.is-holding .dim { opacity: 1; pointer-events: auto; cursor: pointer; }

.held {
  position: absolute;
  z-index: 4;
  perspective: 1500px;
}
.held[hidden] { display: none; }
.held .tilt {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: rotateX(calc(var(--tx, 0) * 1deg)) rotateY(calc(var(--ty, 0) * 1deg));
  transition: transform .5s var(--ease);
}
.held .box { transform: rotateY(180deg); transition: none; }
.held .back { padding: calc(var(--bw) * .045); display: flex; }
.held .label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 22px 20px;
  border-radius: 3px;
  background: #FFF6EC;
  color: #2A0D08;
  box-shadow: 0 1px 2px rgb(0 0 0 / .18);
  overflow: hidden;
}
.held .head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.held h3 { margin: 0; font-size: 28px; line-height: 1.05; font-weight: 600; letter-spacing: -.02em; }
.held p { margin: 0; font-size: 18px; line-height: 1.4; max-width: 34ch; text-wrap: pretty; }
.held .actions { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 18px; }
.held .addr { font-size: 15px; color: #6E3426; letter-spacing: .005em; }
.held .actions a {
  display: inline-flex; align-items: center;
  min-height: 44px; padding: 0 16px;
  border-radius: 3px;
  background: var(--sky); color: var(--on-sky);
  font-weight: 600; text-decoration: none; white-space: nowrap;
  box-shadow: 0 -2px 0 rgb(42 13 8 / .2) inset;
}
.held .actions a:hover { background: #BCD9F5; }
.held .put {
  flex: none;
  min-height: 44px; margin: -12px -4px -12px 0; padding: 0 4px;
  border: 0; background: none;
  font: inherit; font-size: 16px; font-weight: 500; color: #2A0D08;
  text-decoration: underline; text-underline-offset: 4px;
  cursor: pointer;
}
.held .label :focus-visible { outline-color: #2A0D08; }
.held.tight h3 { font-size: 22px; }
.held.tight p { font-size: 16px; line-height: 1.35; }
.held.tight .label { padding: 14px 16px; gap: 8px; }

/* ---------- Load: each box drops onto the plank ---------- */
@media (prefers-reduced-motion: no-preference) {
  .drop { animation: drop .5s var(--ease) backwards; animation-delay: calc(120ms + var(--i) * 70ms); }
  .cast, .footprint { animation: land .5s var(--ease) backwards; animation-delay: calc(120ms + var(--i) * 70ms); }
}
@keyframes drop {
  0% { translate: 0 -70px; visibility: hidden; }
  1% { visibility: visible; }
  62% { translate: 0 0; }
  78% { translate: 0 -5px; }
  100% { translate: 0 0; }
}
@keyframes land { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Below: open source ---------- */

.low {
  position: relative;
  overflow-x: clip;
  max-width: 1520px;
  margin: 0 auto;
  padding: 72px 56px 120px;
}
.low h2 { margin: 0 0 30px; font-size: 26px; font-weight: 600; letter-spacing: -.015em; }
.stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: min(620px, 100%);
  transition: transform .7s var(--ease);
}
.low.pending .stack { transform: translateY(56px); }
.low.pending.risen .stack { transform: none; }

/* Two books lying flat, one on the other: the spine faces you, the cover shows on top. */
.book {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
  min-height: 54px;
  padding: 14px 22px 12px;
  border-radius: 2px;
  text-decoration: none;
  box-shadow: -18px 14px 18px -6px rgb(var(--shadow) / .45);
}
.book::before {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 100%;
  height: 9px;
  transform-origin: 50% 100%;
  transform: perspective(300px) rotateX(58deg);
  border-radius: 2px 2px 0 0;
}
/* The longest name: a thicker book, its note under the name. */
.book-top { flex-direction: column; gap: 2px; width: 80%; margin-left: 48px; background: var(--sky); color: var(--on-sky); z-index: 2; }
/* Lying square, so its pale top edge stays clean on a 1x screen; the top overlaps the spine by a pixel so no wall shows between. */
.book-top::before { bottom: calc(100% - 1px); background: #CCE1F6; }
/* On a phone the name breaks after the slash, never inside the repo name. */
.book-top .book-name span { white-space: nowrap; }
.book-1 { width: 88%; margin-left: 26px; rotate: -1.2deg; background: #2A0D08; color: #FFF6EC; z-index: 1; }
.book-1::before { background: #5A2A20; }
.book-2 { background: #FFF6EC; color: #2A0D08; }
.book-2::before { background: #E9D2C0; }
.book-name { font-weight: 600; font-size: 19px; }
.book-note { font-size: 16px; opacity: .92; white-space: nowrap; }
.book:hover .book-name { text-decoration: underline; text-underline-offset: 4px; }

.plank-low {
  position: relative;
  width: min(720px, 100%);
  height: 40px;
  margin-left: -20px;
  background:
    linear-gradient(to bottom, rgb(255 228 206 / .36) 0, rgb(255 228 206 / .16) 1.5px, transparent 3px),
    linear-gradient(to top, rgb(28 5 2 / .6) 0, rgb(28 5 2 / .6) 1px, transparent 2.5px),
    linear-gradient(to bottom, rgb(var(--shadow) / .24), rgb(var(--shadow) / .36) 70%, rgb(var(--shadow) / .5)),
    linear-gradient(rgb(var(--shadow) / var(--wood-dim)), rgb(var(--shadow) / var(--wood-dim))),
    url("img/wood-edge.webp") -310px 0 / 1728px 100% repeat-x,
    var(--wood);
  box-shadow: 0 5px 5px -3px rgb(var(--shadow) / .65), 0 22px 28px -8px rgb(var(--shadow) / var(--cast-a));
  margin-top: 14px;
}
/* Its top, seen from above at a slant: the same board, the grain pressed flat. */
.plank-low::before {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 100%;
  height: 14px;
  background:
    linear-gradient(to top, rgb(255 226 204 / .3) 0, rgb(255 226 204 / .12) 1.5px, transparent 3px),
    linear-gradient(to top, rgb(255 232 214 / .1), rgb(var(--shadow) / .3)),
    linear-gradient(rgb(var(--shadow) / var(--wood-dim)), rgb(var(--shadow) / var(--wood-dim))),
    url("img/wood-top.webp") -310px -20px / 1728px 64px repeat-x,
    var(--wood);
}
.follow-end { margin-top: 48px; }

/* ---------- Phone ---------- */
@media (max-width: 760px) {
  :root { --glow-y: 640px; }
  body { --glow-a: .14; }
  .room {
    padding: 22px 16px 40px;
    --u: calc((100vw - 32px) / 358);
  }
  h1 { font-size: min(44px, 11.25vw); line-height: 1; letter-spacing: -.03em; }
  .lead { margin-top: 14px; font-size: 18px; max-width: 30ch; }
  .follow { margin-top: 20px; min-height: 46px; font-size: 17px; }
  .lights { top: 22px; right: 12px; gap: 9px; font-size: 15px; }
  .lights .switch { width: 20px; height: 30px; }
  /* On a phone the lamp grows with the boxes up to 390px wide, then holds its size: wider, it would reach the boxes. */
  .lamp { --s: min(var(--u), 1px); top: calc(164px - 52 * var(--s)); right: calc(-72 * var(--s)); width: calc(229 * var(--s)); }
  .lights .switch::after { left: 6px; right: 6px; top: 6px; height: 10px; }
  :root[data-theme="dark"] .lights .switch::after { transform: translateY(8px); }

  .shelves {
    flex-direction: column;
    align-items: stretch;
    gap: 26px;
    margin-top: 30px;
    padding-top: 22px;
    perspective: 900px;
    perspective-origin: 50% -25%;
    --lip: 44px;
    --front: 10px;
    --wall: 62px;
  }
  .shelf-a, .shelf-b { padding-left: 0; padding-right: 0; }
  .shelf-a::before, .shelf-a::after, .shelf-b::before, .shelf-b::after { left: -6px; right: -6px; }
  .shelves::before { display: none; }
  .shelf::after { box-shadow: 0 5px 5px -3px rgb(var(--shadow) / .65), 0 20px 24px -8px rgb(var(--shadow) / var(--cast-a)); }
  .shelf-b { --wood-x: -860px; }
  .row { justify-content: center; }
  .slot { --W: var(--pw); --H: var(--ph); --D: var(--pd); --RY: var(--pry); --sx: calc(var(--lx) * -24px); }
  .slot + .slot { margin-left: calc(var(--pgap, 22) * var(--u)); }
  .shelf-b .slot:nth-child(1) { margin-left: 0; }
  .shelf-b .slot:nth-child(n+2) { --pgap: 26; }
  .lip-label { font-size: 15px; }
  .cast { filter: blur(6px); }
  .front::before { display: none; }
  .front { padding: calc(var(--bw) * .045); }
  .lip-hint { display: none; }
  .shelf-note {
    position: static;
    transform: none;
    height: auto;
    justify-content: space-between;
    margin-top: -12px;
  }
  .shelf-note .hint { display: inline; }
  .held .label { padding: 16px 16px; }
  .held h3 { font-size: 24px; }
  .held p { font-size: 16px; line-height: 1.38; }

  .low { padding: 56px 16px 90px; }
  .book { flex-direction: column; gap: 2px; padding: 12px 16px; }
  .book-top { width: 88%; margin-left: 22px; }
  .book-1 { width: 94%; margin-left: 12px; }
  .book-note { white-space: normal; }
  .plank-low { margin-left: -6px; width: calc(100% + 12px); }
}

/* Up to 640px the headline breaks after "Bren builds" in every browser, with or without text-wrap: balance,
   so its first line never runs under the light switch. From 641px it fits on one line beside the switch. */
@media (max-width: 640px) {
  h1 { max-width: 6.8em; }
}
/* From 641px the headline is one line and the boxes ride 44px higher: the lamp rises with them. */
@media (min-width: 641px) and (max-width: 760px) {
  .lamp { top: 68px; }
}

/* Reduced motion: nothing moves; a pressed box swaps faces at once. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .slot:hover .box, .slot:has(.turn:focus-visible) .box { transform: rotateY(calc(var(--RY) * 1deg)); }
  .slot:hover .lean, .slot:has(.turn:focus-visible) .lean { transform: rotateZ(calc(var(--RZ) * 1deg)); }
  .low.pending .stack { transform: none; }
}
