:root { --fg:#000; --bg:#fff; --mute:#777; --line:#e6e6e6; }
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 500 1.1rem/1.4 Rubik, ui-sans-serif, system-ui, sans-serif;
}
a { color: var(--fg); text-decoration: none; }
svg { fill: currentColor; }
img, video { display: block; max-width: 100%; }

/* ---------- Home (layout clone of knurl.ing) ---------- */
body.home { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 24px 64px; line-height: 1.2; }
.home main { width: 100%; max-width: 1100px; text-align: center; }
.slot { position: relative; width: 96px; margin: 0 auto 28px; }
.icon { display: block; width: 96px; height: auto; margin: 0 auto; }
.slot.on .icon { opacity: 0; }
.email { display: block; margin-top: 10px; color: var(--mute); font-size: .95rem; }
.word { margin: 0 auto; font: inherit; font-size: clamp(2rem, 8vw, 2.6rem); line-height: 1.05; font-weight: 500; letter-spacing: -.01em; }
/* Project list fills the width and wraps; on narrow screens it becomes one tall column. */
.home nav { display: flex; flex-wrap: wrap; justify-content: center; }
.home nav.work { margin-top: 48px; gap: 0 40px; }
.home nav.work a { padding: 10px 0; text-transform: lowercase; }
/* Touch screens (see hover.js): the project nearest the pinned logo is a touch bigger, the others a touch fainter. Instant, no animation. */
.home nav.work.has-active a { opacity: .6; }
.home nav.work.has-active a.active { opacity: 1; transform: scale(1.12); }
/* Touch screens: the logo (and the preview that replaces it) stays pinned while the list scrolls under it,
   so the idle auto-cycle can walk the whole list with its icon always in view. */
@media (hover: none) {
  body.home { padding-top: 12px; }
  .home .slot { position: sticky; top: 0; z-index: 4; width: 100%; padding-top: 12px; margin: 0 auto 16px; background: var(--bg); }
}
.home nav.links { margin-top: 56px; gap: 4px 24px; }
.home nav.links a { font-size: .95rem; color: var(--mute); }
@media (max-width: 640px) {
  .home nav.work { flex-direction: column; flex-wrap: nowrap; }
  .home nav.work a { padding: 12px 0; align-self: center; } /* shrink to the text so the active underline matches it */
}
.tagline {
  position: fixed; left: 0; right: 0; bottom: 20px; margin: 0; padding: 0 24px;
  text-align: center; color: #bbb; font-size: .85rem; pointer-events: none;
}
@media (max-width: 640px) { .tagline { position: static; margin-top: 40px; padding: 0; } }
#preview, #preview-img {
  position: absolute; left: 50%; top: 50%; width: 115px; height: 115px; max-width: none; /* the slot is 96px wide, so this is 20% bigger than the old (capped) 96px */
  transform: translate(-50%, -50%); pointer-events: none; opacity: 0;
}
.slot.on #preview { opacity: 1; }
.slot.on.img #preview-img { opacity: 1; }
.slot.on.img #preview { opacity: 0; }
/* Dark artwork (data-invert-dark) is kept for parity with the Knurling site; unused without a dark mode. */
#callout { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; fill: none; }
#callout path { stroke: none; }
#callout text { fill: var(--fg); font: 500 1.7rem Rubik, ui-sans-serif, system-ui, sans-serif; opacity: 0; }
#callout.on text { opacity: 1; }

/* ---------- Case study ---------- */
.case { max-width: 1200px; margin: 0 auto; padding: 24px 24px 96px; }
.top { margin-bottom: 32px; }
.logo { display: block; width: 56px; height: auto; }
/* Project preview shows in the corner; hover/focus swaps it for the logo (the link home). */
.homelink { display: block; position: relative; width: 56px; }
.homelink .mark { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transition: opacity .15s; }
.homelink.has-mark .logo { opacity: 0; transition: opacity .15s; }
.homelink.has-mark:hover .logo, .homelink.has-mark:focus-visible .logo { opacity: 1; }
.homelink.has-mark:hover .mark, .homelink.has-mark:focus-visible .mark { opacity: 0; }

.hero { width: min(100%, calc(85vh * var(--ratio, 1.7778))); margin: 0 auto; aspect-ratio: var(--ar, 16 / 9); background: #000; overflow: hidden; }
.hero video, .hero iframe { width: 100%; height: 100%; border: 0; object-fit: contain; }
.hero.placeholder { display: grid; place-items: center; background: #f3f3f3; color: #bbb; font-size: .95rem; }

.intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 48px; margin: 56px 0 72px; }
.intro.solo { grid-template-columns: 1fr; }
.intro.solo h1 { margin-bottom: 0; }
/* Gallery-type pages have no hero video, so the title tucks up under the logo. */
.case-gallery .intro { margin: 8px 0 40px; }
.intro h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.05; margin: 0 0 20px; font-weight: 500; }
.meta { margin: 0; display: grid; gap: 10px; }
.meta div { display: flex; flex-direction: column; }
.meta dt { color: var(--mute); font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; }
.meta dd { margin: 0; font-size: 1rem; }
.prose { max-width: 640px; font-size: 1.1rem; line-height: 1.55; }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose blockquote { margin: 0 0 1.1em; }
.prose h2, .prose h3 { font-weight: 500; margin: 1.8em 0 .5em; line-height: 1.2; }
.prose h2 { font-size: 1.4rem; } .prose h3 { font-size: 1.15rem; }
/* Lists are credits: plain lines, quieter than the write-up. */
.prose ul { list-style: none; padding: 0; color: #aaa; font-size: .85rem; line-height: 1.6; }
.prose ul a { color: inherit; }
.prose blockquote { padding-left: 1em; border-left: 3px solid var(--line); color: var(--mute); }
.prose a { text-decoration: underline; text-underline-offset: 3px; }
.prose code { background: #f3f3f3; padding: .1em .35em; border-radius: 4px; font-size: .9em; }

/* Gallery: two columns; a file named wide-*.jpg spans both. */
.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.g { margin: 0; background: #f3f3f3; }
.g.wide { grid-column: 1 / -1; }
.g img, .g video { width: 100%; height: auto; cursor: zoom-in; }
.g video { cursor: default; }

.pager { display: flex; justify-content: space-between; gap: 24px; margin-top: 96px; padding-top: 24px; border-top: 1px solid var(--line); }
.pager a { color: var(--mute); }
.pager a:hover { color: var(--fg); }

#lightbox { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; }
#lightbox::backdrop { background: rgba(255,255,255,.96); }
#lightbox img { position: absolute; inset: 24px; width: calc(100% - 48px); height: calc(100% - 48px); object-fit: contain; cursor: zoom-out; }

@media (max-width: 760px) {
  .case { padding: 16px 16px 64px; }
  .intro { grid-template-columns: 1fr; gap: 24px; margin: 32px 0 48px; }
  .gallery { grid-template-columns: 1fr; }
}
