/* ==========================================================================
   LOCHLANISM
   Layout: one centred 640px reading column (after the reference), compact
   sticky nav, halftone artwork on tiled canvases behind the content.
   Dark is the default; light is opt-in via the ◐ toggle.
   ========================================================================== */

:root {
  /* colour: dark (default). Every text colour passes WCAG AA on every surface. */
  --bg: #0c0c0b;
  --surface: #141413;
  --surface-2: #1a1a19;
  --surface-3: #2b2b29;          /* button hover */
  --nav-bg: rgba(12, 12, 11, 0.82);
  --line: rgba(236, 236, 230, 0.08);
  --line-strong: rgba(236, 236, 230, 0.16);
  --fg: #ecece6;
  --text-2: #c4c4bf;             /* body copy */
  --muted: #9a9a93;
  --faint: #85857e;              /* small print: years, indexes, footer */
  --dim: #5c5c57;                /* decoration only (dividers, coordinates) */
  --accent-rgb: 0, 160, 230;     /* halftone blue from ref/new.jpg */
  --accent: rgb(var(--accent-rgb));

  /* type */
  --font-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --fs-xs: 0.6875rem;   /* 11px labels */
  --fs-sm: 0.78rem;     /* 12.5px meta */
  --fs-base: 0.875rem;  /* 14px body */
  --fs-h2: 1.0625rem;   /* 17px */
  --fs-h1: clamp(1.9rem, 1.2rem + 2.6vw, 2.85rem);

  /* layout */
  --col: 640px;
  --gutter: clamp(16px, 5vw, 32px);
  --pad-l: max(var(--gutter), env(safe-area-inset-left, 0px));    /* clear the notch in landscape */
  --pad-r: max(var(--gutter), env(safe-area-inset-right, 0px));
  --nav-h: 56px;
  --radius: 6px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f6f6f3;
  --surface: #eeeeea;
  --surface-2: #e7e7e2;
  --surface-3: #d6d6d1;
  --nav-bg: rgba(246, 246, 243, 0.82);
  --line: rgba(18, 18, 16, 0.09);
  --line-strong: rgba(18, 18, 16, 0.18);
  --fg: #121210;
  --text-2: #3b3b39;
  --muted: #52524d;
  --faint: #66665f;
  --dim: #a3a39c;
  --accent-rgb: 0, 150, 220;
  color-scheme: light;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 24px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  position: relative;            /* containing block for the artwork layer */
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--fs-base);
  line-height: 1.8;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color .35s var(--ease), color .35s var(--ease);
}

::selection { background: var(--accent); color: #0c0c0b; }
a { color: inherit; }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  padding: 8px 14px; border-radius: 4px;
  background: var(--fg); color: var(--bg);
  font-size: var(--fs-sm); text-decoration: none;
}
.skip:focus { top: 12px; }

/* ---------- Layers ---------- */
/* Artwork: spans the whole page (inset 0 on body) and scrolls natively.
   overflow: hidden keeps its canvases from ever adding scroll height. */
#art {
  position: absolute; inset: 0;
  z-index: 0; overflow: hidden;
  pointer-events: none;
  opacity: 0; transition: opacity .9s var(--ease);
}
#art.is-ready { opacity: 1; }
#art canvas { position: absolute; display: block; }

.grain {
  position: fixed; inset: 0; z-index: 60;
  display: none;                 /* only exists while the theme switch plays */
  pointer-events: none; opacity: 0;
  background-size: 180px 180px;
  mix-blend-mode: difference;
}
.grain.is-on { display: block; animation: grain .46s steps(6) both; }
@keyframes grain {
  0%   { opacity: 0;   background-position: 0 0; }
  35%  { opacity: .55; background-position: -40px 20px; }
  60%  { opacity: .35; background-position: 30px -50px; }
  100% { opacity: 0;   background-position: -10px 70px; }
}

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: env(safe-area-inset-top, 0px);
  z-index: 50;
  background: var(--nav-bg);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav__inner {
  height: var(--nav-h);
  max-width: 1120px; margin: 0 auto;
  padding-left: var(--pad-l); padding-right: var(--pad-r);
  display: flex; align-items: center; gap: 20px;
}
.wordmark {
  font-weight: 600; font-size: 0.8125rem; letter-spacing: 0.16em;
  text-decoration: none; white-space: nowrap;
  display: inline-block; padding-block: 6px;       /* ≥24px tap target */
  margin-right: auto;
  /* hidden detail: halftone text on hover */
  background-image: radial-gradient(circle at center, var(--accent) 0 42%, transparent 48%);
  background-size: 2.6px 2.6px;
  -webkit-background-clip: text; background-clip: text;
}

.nav__links { display: flex; gap: 2px; }
.nav__links a {
  font-size: var(--fs-sm);
  color: var(--muted);
  text-decoration: none;
  padding: 5px 12px;
  border-radius: 5px;
  white-space: nowrap;
  transition: color .2s, background-color .2s;
}
.nav__links a.is-active { color: var(--fg); background: var(--surface-2); }

.nav__tools { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  appearance: none; border: 1px solid transparent; background: none;
  color: var(--muted); cursor: pointer;
  height: 30px; min-width: 30px; padding: 0 8px;
  display: inline-grid; place-items: center;
  border-radius: 5px; font: inherit; font-size: var(--fs-sm);
  transition: color .2s, border-color .2s;
}
.theme-btn svg { transition: transform .6s var(--ease); }
.menu-btn { display: none; }

@media (max-width: 720px) {
  .menu-btn { display: inline-grid; }
  .nav__links {
    position: absolute; left: 0; right: 0; top: var(--nav-h);
    flex-direction: column; gap: 0;
    padding: 8px var(--pad-r) 14px var(--pad-l);
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    display: none;
  }
  .nav__links.is-open { display: flex; }
  .nav__links a { padding: 10px 0; font-size: var(--fs-base); border-radius: 0; background: none !important; }
  .nav__links a.is-active::before { content: "● "; font-size: .6em; vertical-align: middle; }
}
/* medium widths: keep the full nav on one line */
@media (min-width: 721px) and (max-width: 900px) {
  .nav__inner { gap: 12px; }
  .nav__links a { padding: 5px 8px; }
}

/* ---------- Sound toggle ---------- */
.sound {
  appearance: none; font: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 10px 0 9px;
  color: var(--muted); background: none;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: var(--fs-xs); letter-spacing: .12em; text-transform: uppercase;
  transition: color .2s, border-color .2s;
}
.sound__icon { width: 9px; height: 9px; display: grid; }
.sound__icon svg { width: 9px; height: 9px; grid-area: 1 / 1; }
.sound .i-pause { opacity: 0; }
.sound.is-on .i-play { opacity: 0; }
.sound.is-on .i-pause { opacity: 1; }
.sound.is-on { color: var(--fg); }
/* five halftone dots that become a tiny level meter while playing */
.sound__eq { display: inline-flex; align-items: center; gap: 2px; height: 10px; }
.sound__eq i {
  width: 3px; height: 3px; border-radius: 50%;
  background: currentColor; opacity: .45;
  transform: scale(var(--s, 1));
  transition: transform .08s linear, background-color .3s, opacity .3s;
}
.sound.is-on .sound__eq i { background: var(--accent); opacity: 1; }
.sound.is-loading .sound__eq i { animation: eqwait .7s ease-in-out infinite alternate; }
.sound.is-loading .sound__eq i:nth-child(2) { animation-delay: .1s; }
.sound.is-loading .sound__eq i:nth-child(3) { animation-delay: .2s; }
.sound.is-loading .sound__eq i:nth-child(4) { animation-delay: .3s; }
.sound.is-loading .sound__eq i:nth-child(5) { animation-delay: .4s; }
@keyframes eqwait { to { transform: scale(1.8); } }
/* the label stays in the accessibility tree on small screens */
@media (max-width: 900px) {
  .sound { padding: 0 9px; }
  .sound__label {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
  }
}

/* bigger tap targets for touch */
@media (pointer: coarse) {
  .icon-btn, .sound { height: 40px; min-width: 40px; }
}

/* ---------- Page ---------- */
.page {
  position: relative; z-index: 2;
  max-width: calc(var(--col) + var(--gutter) * 2);
  margin: 0 auto;
  padding-left: var(--pad-l); padding-right: var(--pad-r);
  padding-block: 0 48px;
}

.eyebrow, .section__index, .contact__label, dt {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

/* ---------- Hero ---------- */
.hero { padding-block: clamp(72px, 13vh, 128px) 56px; }
.hero .eyebrow { margin: 0 0 22px; }
.hero__title {
  margin: 0 0 40px;
  font-size: var(--fs-h1);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.prose { max-width: 62ch; }
.prose p { margin: 0 0 1.25em; color: var(--text-2); }
.prose p:last-child { margin-bottom: 0; }

/* animated dotted underline */
.link {
  text-decoration: none;
  background:
    linear-gradient(currentColor, currentColor) left bottom / 0% 1px no-repeat,
    radial-gradient(circle, var(--muted) 0.6px, transparent 0.8px) left bottom / 3px 1px repeat-x;
  padding-bottom: 2px;
  transition: background-size .45s var(--ease);
}

.hero__actions {
  margin-top: 40px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
}
/* 34px tap targets */
.socials { list-style: none; margin: 0 0 0 4px; padding: 0; display: flex; gap: 2px; }
.socials a {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 6px;
  color: var(--muted);
  transition: color .2s, transform .3s var(--ease);
}
.socials svg { width: 16px; height: 16px; fill: currentColor; }

.btn {
  appearance: none; font: inherit; font-size: var(--fs-sm); font-weight: 500;
  color: var(--fg); text-decoration: none; cursor: pointer;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  transition: border-color .2s, background-color .2s;
}
.btn--ghost { background: transparent; }
.btn--solid { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.row--static { grid-template-columns: 44px 1fr; }
.contact__card + .contact__card { margin-top: 12px; }

/* halftone divider: dots fading from both ends */
.divider {
  height: 6px;
  background: radial-gradient(circle, var(--dim) 0.9px, transparent 1.2px) 0 50% / 6px 6px repeat-x;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
  margin-block: 8px 24px;
}

/* ---------- Sections ---------- */
.section { padding-block: 40px 56px; }
.contact { padding-bottom: 40px; }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.section h2 { margin: 0; font-size: var(--fs-h2); font-weight: 600; letter-spacing: -0.005em; }
.section__index { color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.section__sub { margin: 4px 0 28px; font-size: var(--fs-sm); color: var(--muted); }

.facts { margin: 36px 0 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.facts > div {
  display: grid; grid-template-columns: 120px 1fr; gap: 16px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.facts dt { padding-top: 3px; }
.facts dd { margin: 0; min-width: 0; font-size: var(--fs-sm); }
@media (max-width: 520px) { .facts > div { grid-template-columns: 1fr; gap: 2px; } }
@media (max-width: 520px) { .socials { flex-basis: 100%; margin-left: -9px; } }

/* ---------- Rows (project cards) ---------- */
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.row {
  position: relative;
  display: grid; grid-template-columns: 44px 1fr auto; gap: 20px; align-items: start;
  padding: 20px;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: background-color .25s var(--ease), border-color .25s var(--ease);
}
.row__icon {
  width: 44px; height: 44px;
  border-radius: 9px;
  background: var(--bg);
  border: 1px solid var(--line);
  overflow: hidden;
  transition: transform .45s var(--ease);
}
.row__icon canvas { display: block; width: 100%; height: 100%; }
.row__body { display: grid; gap: 4px; min-width: 0; }
.row__title { font-size: var(--fs-sm); font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row__desc { font-size: var(--fs-sm); color: var(--muted); line-height: 1.75; }
.row__meta { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.arrow { display: inline-block; color: var(--muted); font-size: 0.9rem; transition: transform .35s var(--ease), color .2s; }

.tag {
  font-size: 0.625rem; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 1px 7px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--fg);
}
.tag:not(.tag--dim)::before { content: ""; display: inline-block; width: 5px; height: 5px; margin-right: 6px; border-radius: 50%; background: var(--accent); vertical-align: 1px; }
.tag--dim { color: var(--muted); border-color: var(--line); }

@media (max-width: 520px) {
  .row { grid-template-columns: 40px 1fr; gap: 16px; padding: 16px; }
  .row__icon { width: 40px; height: 40px; }
  .row__meta { position: absolute; top: 16px; right: 16px; }
  .row__year { display: none; }
  .row__title { padding-right: 20px; }
}

/* Redacted ventures: remove .is-redacted from a row to reveal it */
.is-redacted .redact { filter: blur(5px); user-select: none; -webkit-user-select: none; pointer-events: none; }
.is-redacted .row__icon canvas { filter: blur(2.5px); opacity: .8; }

/* ---------- Contact ---------- */
.contact__card {
  margin-top: 28px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.contact__email {
  font-size: 1rem; font-weight: 500; text-decoration: none;
  margin-right: auto; min-width: 0; overflow-wrap: anywhere;
}

/* ---------- Footer ---------- */
.footer { position: relative; z-index: 2; border-top: 1px solid var(--line); }
.footer__inner {
  max-width: calc(var(--col) + var(--gutter) * 2); margin: 0 auto;
  padding: 22px var(--pad-r) calc(22px + env(safe-area-inset-bottom, 0px)) var(--pad-l);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px;
  font-size: var(--fs-xs); letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.footer__mark { display: inline-flex; align-items: center; gap: 8px; }
.star { width: 14px; height: 14px; fill: currentColor; transition: transform 1.2s var(--ease); }

/* ---------- Hidden detail: cursor coordinates ---------- */
.coords {
  position: fixed; left: 16px; bottom: 14px; z-index: 40;
  font-size: 10px; letter-spacing: .12em; color: var(--dim);
  font-variant-numeric: tabular-nums; pointer-events: none;
  opacity: 0; transition: opacity .6s;
}
.coords.is-on { opacity: .8; }
@media (max-width: 1100px), (hover: none) { .coords { display: none; } }

/* ---------- Hover effects: mouse and trackpad only (no sticky hover after a tap) ---------- */
@media (hover: hover) {
  .wordmark:hover { color: transparent; }
  .nav__links a:hover { color: var(--fg); }
  .icon-btn:hover { color: var(--fg); border-color: var(--line); }
  .theme-btn:hover svg { transform: rotate(180deg); }
  .sound:hover { color: var(--fg); border-color: var(--line-strong); }
  .link:hover { background-size: 100% 1px, 3px 1px; }
  .socials a:hover { color: var(--fg); transform: translateY(-2px); }
  .btn:hover { border-color: var(--line-strong); background: var(--surface-3); }
  .btn--solid:hover { background: var(--text-2); border-color: var(--text-2); }
  a.row:hover { background: var(--surface-2); border-color: var(--line-strong); }
  a.row:hover .row__icon { transform: translate(2px, -2px); }
  a.row:hover .arrow { transform: translate(3px, -3px); color: var(--fg); }
  .contact__email:hover { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
  .footer__mark:hover .star { transform: rotate(72deg); }
}

/* ---------- Opening sequence (html.intro is set in <head>) ----------
   Everything animates *from* hidden and ends in its normal state, so the page
   is complete even if scripts fail. */
.hero__title .ln { display: block; overflow: hidden; padding-bottom: .12em; margin-bottom: -.12em; }
.hero__title .ln > span { display: block; }
.intro .nav { animation: intro-fade .7s var(--ease) both; }
.intro .hero .eyebrow { animation: intro-up .8s var(--ease) .05s both; }
.intro .hero__title .ln > span { animation: intro-line .95s cubic-bezier(.16, .84, .24, 1) both; }
.intro .hero__title .ln:nth-child(1) > span { animation-delay: .12s; }
.intro .hero__title .ln:nth-child(2) > span { animation-delay: .22s; }
.intro .hero__title .ln:nth-child(3) > span { animation-delay: .32s; }
.intro .hero .prose > p:nth-child(1) { animation: intro-up .9s var(--ease) .5s both; }
.intro .hero .prose > p:nth-child(2) { animation: intro-up .9s var(--ease) .6s both; }
.intro .hero__actions { animation: intro-up .9s var(--ease) .72s both; }
.intro .divider:first-of-type { animation: intro-fade 1.2s var(--ease) .8s both; }
@keyframes intro-line { from { transform: translateY(108%); } }
@keyframes intro-up { from { opacity: 0; transform: translateY(14px); } }
@keyframes intro-fade { from { opacity: 0; } }

/* ---------- Preferences & special modes ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
/* Windows high-contrast mode: drop the decorative layer */
@media (forced-colors: active) {
  #art, .grain, .coords { display: none; }
}
@media print {
  :root, :root[data-theme] {
    --bg: #fff; --surface: #fff; --surface-2: #fff; --fg: #000; --text-2: #222;
    --muted: #444; --faint: #555; --line: #ccc; --line-strong: #999; color-scheme: light;
  }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  #art, .grain, .coords, .nav__tools, .skip, .divider { display: none !important; }
  .nav { position: static; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .row, .contact__card { break-inside: avoid; }
}
