/* Owen Pacetti: monochrome, minimal, live. No hue anywhere in the UI;
   real media (photos, recordings) keep their original color. */

@font-face {
  font-family: "Geist";
  src: url("fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("fonts/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0a0a0a;
  --ink: #f2f2f2;
  --grey-1: #a8a8a8;
  --grey-2: #808080; /* 5.0:1 on --bg, WCAG AA for small text */
  --grey-3: #3a3a3a;
  --line: #222222;
  --sim-ink: #f2f2f2;
  --body-ink: #d4d4d4; /* long-form case-study text */
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --gutter: clamp(16px, 4vw, 48px);
  --max: 1240px;
  --measure: 64ch;
  color-scheme: dark;
}

/* Light theme: the same greys, inverted. Chosen with the header toggle
   (site.js) and applied before first paint by the inline script in <head>. */
:root[data-theme="light"] {
  --bg: #f2f2f2;
  --ink: #0a0a0a;
  --grey-1: #4a4a4a;
  --grey-2: #666666; /* 5.1:1 on --bg, WCAG AA for small text */
  --grey-3: #c4c4c4;
  --line: #dcdcdc;
  --sim-ink: #0a0a0a;
  --body-ink: #2a2a2a;
  color-scheme: light;
}

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

/* Components set their own display; routes rely on [hidden] winning. */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Keep in-page jumps and focused elements clear of the sticky header. */
  scroll-padding-top: 72px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

h1,
h2,
h3,
p,
ol,
ul,
dl,
dd,
figure {
  margin: 0;
}

ol,
ul {
  padding: 0;
  list-style: none;
}

.mono {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: 0;
}

.dim {
  color: var(--grey-1);
}

/* Links: plain until hovered. */
a {
  color: inherit;
  text-decoration: none;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

a:hover {
  text-decoration: underline;
}

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

main:focus,
h1:focus {
  outline: none;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 20;
  padding: 8px 12px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 13px;
}

.skip-link:focus {
  top: 12px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  max-width: var(--max);
  margin: 0 auto;
  padding: 18px var(--gutter);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.wordmark {
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px 20px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--grey-1);
}

.site-nav a:hover {
  color: var(--ink);
}

.theme-toggle {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

main,
.site-footer {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* Nav wipe overlay (site.js) */
/* The page waits under a full band until site.js starts the reveal. */
html[data-wipe="in"] body > :not(.nav-wipe) {
  visibility: hidden;
}

.nav-wipe {
  position: fixed;
  inset: 0;
  z-index: 50;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

/* Hero */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: clamp(24px, 5vw, 72px);
  align-items: end;
  padding: clamp(48px, 10vw, 128px) 0 clamp(56px, 9vw, 112px);
}

.hero h1 {
  font-size: clamp(3.2rem, 10.5vw, 9.5rem);
  font-weight: 600;
  line-height: 0.88;
  letter-spacing: -0.055em;
  margin-left: -0.04em;
}

.hero-line {
  max-width: 30ch;
  margin-top: clamp(20px, 3vw, 32px);
  font-size: clamp(1.15rem, 1.9vw, 1.5rem);
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.hero-meta {
  margin-top: 20px;
  color: var(--grey-2);
}

.hero-sim {
  width: 100%;
  max-width: 560px;
  justify-self: end;
}

.hero-fallback {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(5px, 1.2vw, 8px);
  line-height: 1;
  color: var(--ink);
  white-space: pre;
  overflow: hidden;
}

/* Simulations */
canvas.sim {
  display: block;
  width: 100%;
  height: auto;
  touch-action: pan-y pinch-zoom; /* swipes scroll, pinch still zooms */
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

canvas.sim[data-variant="hero"] {
  aspect-ratio: 1 / 1;
  cursor: crosshair;
}

canvas.sim[data-variant="row"] {
  aspect-ratio: 40 / 14;
}

canvas.sim[data-variant="full"] {
  aspect-ratio: 96 / 30;
}

/* No-JS static frames (inside <noscript>). A mono glyph is about 0.6em wide;
   the letter spacing makes every cell square, like the canvas grid. */
.sim-fallback {
  display: block;
  overflow: hidden;
  font-family: var(--mono);
  line-height: 1;
  letter-spacing: 0.4em;
  white-space: pre;
  color: var(--ink);
}

.row-sim .sim-fallback {
  font-size: min(9px, calc((100vw - 32px) / 40));
}

.case-sim .sim-fallback {
  font-size: min(10.5px, calc((100vw - 2 * var(--gutter)) / 96));
}

.sim-caption {
  display: block;
  margin-top: 10px;
  color: var(--grey-2);
  font-size: 12px;
}

.hint {
  color: var(--ink);
  margin-right: 1ch;
}

.hint::before {
  content: "↳ ";
  color: var(--grey-2);
}

.hint-coarse {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .hint-fine {
    display: none;
  }
  .hint-coarse {
    display: inline;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hint {
    display: none !important;
  }
  canvas.sim[data-variant="hero"] {
    cursor: default;
  }
}

/* Index lists */
.index-section {
  padding-bottom: clamp(40px, 6vw, 72px);
}

.section-label {
  padding-bottom: 14px;
  color: var(--grey-2);
  font-weight: 400;
  text-transform: lowercase;
}

.rows {
  border-top: 1px solid var(--line);
}

.row {
  border-bottom: 1px solid var(--line);
}

.row-link {
  display: grid;
  grid-template-columns: 4ch minmax(0, 1fr) minmax(0, 360px);
  gap: 20px clamp(16px, 3vw, 40px);
  align-items: start;
  padding: clamp(20px, 3vw, 32px) 0;
}

.row-link:hover {
  text-decoration: none;
}

.row-num {
  padding-top: 0.7em;
  color: var(--grey-2);
}

.row-text {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.row-title {
  font-size: clamp(2rem, 5vw, 3.75rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.045em;
  text-underline-offset: 0.12em;
  text-decoration-thickness: 2px;
}

.row-link:hover .row-title,
.row-link:focus-visible .row-title {
  text-decoration: underline;
}

.row-meta {
  color: var(--grey-1);
}

.row-summary {
  max-width: 52ch;
  color: var(--grey-1);
  font-size: 15px;
}

.row-sim {
  display: block;
  min-width: 0;
}

.row-sim .sim-caption {
  margin-top: 6px;
  font-size: 11px;
}

/* Compact blocks */
.block {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2.2fr);
  gap: 16px clamp(16px, 3vw, 40px);
  padding: clamp(32px, 5vw, 56px) 0;
  border-top: 1px solid var(--line);
}

.block-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: var(--measure);
}

.block-title {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.block-title .dim {
  display: block;
  margin-top: 4px;
  font-size: 0.55em;
  font-weight: 400;
  letter-spacing: -0.01em;
}

.block-meta {
  color: var(--grey-2);
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  font-size: 14px;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 24px;
  padding-bottom: 32px;
  border-top: 1px solid var(--line);
  color: var(--grey-2);
}

.site-footer a:hover {
  color: var(--ink);
}

/* Case studies */
.case {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  column-gap: clamp(24px, 5vw, 72px);
  padding: 8px 0 clamp(48px, 8vw, 96px);
}

.case > .back-link,
.case-sim,
.case-head,
.case-nav {
  grid-column: 1 / -1;
}

.case > .back-link {
  justify-self: start;
  margin: 8px 0 16px;
  color: var(--grey-1);
}

.case-sim {
  margin-bottom: clamp(32px, 5vw, 56px);
}

.case-head {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: clamp(32px, 5vw, 56px);
}

.case-kicker,
.case-tags {
  color: var(--grey-2);
}

.case-head h1 {
  font-size: clamp(2.6rem, 8vw, 6.5rem);
  font-weight: 600;
  line-height: 0.92;
  letter-spacing: -0.05em;
  max-width: 14ch;
}

.case-lede {
  max-width: 36ch;
  font-size: clamp(1.15rem, 1.9vw, 1.45rem);
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.case-body {
  display: flex;
  flex-direction: column;
  gap: 28px;
  max-width: var(--measure);
}

.case-body h2 {
  margin-bottom: 6px;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.case-body p {
  color: var(--body-ink);
}

.role {
  padding-left: 16px;
  border-left: 1px solid var(--grey-3);
}

.role-label {
  display: block;
  margin-bottom: 4px;
  color: var(--grey-2);
}

.case-facts {
  display: flex;
  flex-direction: column;
  gap: 32px;
  min-width: 0;
}

.case-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
  margin-top: clamp(48px, 7vw, 80px);
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--grey-1);
}

.case-nav a:hover {
  color: var(--ink);
}

.pipeline {
  border-top: 1px solid var(--line);
}

.pipeline li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--grey-1);
}

.pipeline-num {
  color: var(--grey-2);
}

.pipeline-mine {
  color: var(--ink) !important;
}

.pipeline em {
  margin-left: auto;
  font-style: normal;
  color: var(--grey-2);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 16px;
}

.stats dt {
  font-family: var(--mono);
  font-size: clamp(1.8rem, 3.2vw, 2.6rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1;
}

.stats dd {
  margin-top: 6px;
  color: var(--grey-1);
  font-size: 14px;
  line-height: 1.35;
}

.outcome {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.outcome-label {
  margin-bottom: 6px;
  color: var(--grey-2);
}

.flow {
  color: var(--ink);
}

.flow span {
  color: var(--grey-2);
}

.fact-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  color: var(--grey-1);
}

.fact-list li:first-child {
  border-top: 1px solid var(--line);
}

.terminal {
  padding: 18px;
  border: 1px solid var(--line);
}

.terminal-prompt {
  margin-bottom: 14px;
}

.terminal ol {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--grey-1);
}

.terminal strong {
  display: inline-block;
  min-width: 9ch;
  font-weight: 500;
  color: var(--ink);
}

.media {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.media figcaption {
  color: var(--grey-2);
  font-size: 12px;
}

.media figcaption a {
  color: var(--grey-1);
  text-decoration: underline;
}

.media-button {
  align-self: flex-start;
  padding: 6px 10px;
  border: 1px solid var(--grey-3);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.media-button:hover {
  border-color: var(--ink);
}

/* Row-to-header expansion clone (site.js) */
.sim-flip {
  position: fixed;
  z-index: 30;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  pointer-events: none;
}

.case.is-entering .case-sim canvas {
  opacity: 0;
}

.case.is-entering .case-head,
.case.is-entering .case-body,
.case.is-entering .case-facts,
.case.is-entering .case-nav {
  opacity: 0;
  transform: translateY(12px);
}

.case .case-head,
.case .case-body,
.case .case-facts,
.case .case-nav {
  transition:
    opacity 320ms ease,
    transform 320ms ease;
}

.case .case-sim canvas {
  transition: opacity 120ms linear;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* Blog (blog/, built by scripts/blog.mjs) */
.site-nav a[aria-current="page"] {
  color: var(--ink);
}

.blog-index,
.post {
  max-width: var(--measure);
  padding: clamp(24px, 5vw, 56px) 0 clamp(48px, 8vw, 96px);
}

.blog-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: clamp(32px, 5vw, 56px);
}

.blog-head h1,
.post-head h1 {
  font-size: clamp(2.4rem, 7vw, 4.5rem);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.blog-lede,
.blog-empty {
  color: var(--grey-1);
}

.blog-head .mono a,
.post-body a {
  text-decoration: underline;
  text-decoration-color: var(--grey-3);
}

.blog-head .mono a:hover,
.post-body a:hover {
  text-decoration-color: currentColor;
}

.post-list {
  border-top: 1px solid var(--line);
}

.post-list li {
  border-bottom: 1px solid var(--line);
}

.post-row {
  display: grid;
  grid-template-columns: 13ch minmax(0, 1fr);
  gap: 4px 24px;
  padding: 16px 0;
}

.post-row:hover {
  text-decoration: none;
}

.post-row-date {
  padding-top: 0.2em;
  color: var(--grey-2);
}

.post-row-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.post-row-title {
  font-weight: 600;
  letter-spacing: -0.015em;
}

.post-row:hover .post-row-title {
  text-decoration: underline;
}

.post-row-summary {
  color: var(--grey-1);
}

.post > .back-link {
  display: inline-block;
  margin-bottom: 24px;
  color: var(--grey-1);
}

.post-head {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: clamp(32px, 5vw, 48px);
}

.post-meta {
  color: var(--grey-2);
}

.post-body {
  display: flex;
  flex-direction: column;
  gap: 1.1em;
  color: var(--body-ink);
}

.post-body h2,
.post-body h3,
.post-body h4 {
  margin-top: 0.8em;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.post-body h2 {
  font-size: 1.35rem;
}

.post-body h3 {
  font-size: 1.15rem;
}

.post-body h4 {
  font-size: 1rem;
}

.post-body ul,
.post-body ol {
  display: flex;
  flex-direction: column;
  gap: 0.35em;
  padding-left: 1.4em;
}

.post-body ul {
  list-style: disc;
}

.post-body ol {
  list-style: decimal;
}

.post-body blockquote {
  margin: 0;
  padding-left: 1em;
  border-left: 2px solid var(--grey-3);
  color: var(--grey-1);
}

.post-body code {
  font-family: var(--mono);
  font-size: 0.85em;
}

.post-body pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 14px;
  line-height: 1.5;
}

.post-body pre code {
  font-size: inherit;
}

.post-body img {
  border-radius: 4px;
}

.post-body hr {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
}

.post-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
  margin-top: clamp(48px, 7vw, 80px);
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--grey-1);
}

.post-nav a:hover {
  color: var(--ink);
}

.post-nav-title {
  color: var(--ink);
}

.insightful {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 16px;
  margin-top: clamp(40px, 6vw, 64px);
  color: var(--grey-1);
}

.insightful[hidden] {
  display: none;
}

.insightful-button {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: none;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.insightful-button:hover {
  border-color: var(--grey-2);
}

.insightful-button[aria-pressed="true"] {
  border-color: var(--ink);
}

.insightful + .post-nav {
  margin-top: 24px;
}

.subscribe {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: clamp(40px, 6vw, 64px);
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.subscribe-label {
  font-weight: 600;
}

.subscribe-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.subscribe-input {
  flex: 1 1 16rem;
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: none;
  color: var(--ink);
  font: inherit;
}

.subscribe-input:focus {
  border-color: var(--grey-2);
  outline: none;
}

.subscribe-input:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.subscribe-button {
  padding: 8px 14px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
}

.subscribe-button:hover {
  opacity: 0.85;
}

.subscribe-note {
  color: var(--grey-2);
}

.subscribe-note a {
  text-decoration: underline;
  text-decoration-color: var(--grey-3);
}

.subscribe + .post-nav {
  margin-top: 24px;
}

#writing .post-list {
  margin-top: 4px;
}

#writing .post-row {
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
}

/* Tablet and below */
@media (max-width: 900px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  .hero-sim {
    justify-self: start;
    max-width: 480px;
  }

  .row-link {
    grid-template-columns: 3ch minmax(0, 1fr);
  }

  .row-sim {
    grid-column: 2;
    max-width: 420px;
  }

  .block {
    grid-template-columns: minmax(0, 1fr);
  }

  .case {
    grid-template-columns: minmax(0, 1fr);
  }

  .case-facts {
    margin-top: 40px;
  }
}

/* Phones */
@media (max-width: 560px) {
  html {
    /* The header stacks here: about 74px tall, 96px when the nav wraps. */
    scroll-padding-top: 112px;
  }

  body {
    font-size: 16px;
  }

  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .site-nav {
    justify-content: flex-start;
    gap: 4px 14px;
    font-size: 12px;
  }

  .post-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .row-link {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .row-num {
    padding-top: 0;
  }

  .row-sim {
    grid-column: 1;
    max-width: none;
  }

  .stats {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .case-nav {
    flex-direction: column;
  }
}
