/* davidcrandall.dev: this site's own stylesheet. Not shared with doitmachina.com.
   Direction and token tables: docs/DESIGN.md. Green is for things you can act on. */

/* ============ Tokens ============ */
:root {
  color-scheme: light;
  --bg: #f4f1ea; --surface: #fffdf8; --sunk: #ebe7dd;
  --ink: #15171a; --body: #383b3f; --muted: #5a5d58;
  --line: #d8d2c4; --edge: #827c6c;
  --accent: #06702f; --on-accent: #fff; --accent-soft: #dff0e3;

  /* The terminal is always dark, like a real one */
  --term-bg: #0b0d0c; --term-bar: #171a18; --term-rule: #262a27; --term-dot: #3a3f3b;
  --term-ink: #d6d4cd; --term-dim: #a8abb2; --term-green: #2ee86a;

  /* The signature strip: 75% color bars */
  --bar1: #c0c0c0; --bar2: #c0c000; --bar3: #00c0c0; --bar4: #00c000;
  --bar5: #c000c0; --bar6: #c00000; --bar7: #0000c0;

  --display: "Bricolage Grotesque", "IBM Plex Sans", system-ui, sans-serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;

  --radius: 8px;
  --radius-card: 12px;
  --wrap: 1080px;
  --gutter: 16px;
  --section: clamp(4rem, 2.5rem + 6vw, 8rem);
  --cs-section: clamp(3rem, 2rem + 4vw, 5rem);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1210; --surface: #171b18; --sunk: #121513;
    --ink: #ecebe5; --body: #c5c8c0; --muted: #9ba198;
    --line: #2a302b; --edge: #6b746b;
    --accent: #2ee86a; --on-accent: #07140b; --accent-soft: #12301c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1210; --surface: #171b18; --sunk: #121513;
  --ink: #ecebe5; --body: #c5c8c0; --muted: #9ba198;
  --line: #2a302b; --edge: #6b746b;
  --accent: #2ee86a; --on-accent: #07140b; --accent-soft: #12301c;
}

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0; background: var(--bg); color: var(--body);
  font: 400 1.125rem/1.6 var(--sans); -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-family: var(--display); color: var(--ink); text-wrap: balance; }
h2 { font-size: clamp(2rem, 1.4rem + 2.4vw, 3rem); font-weight: 700; line-height: 1.05; letter-spacing: -.03em; }
h3 { font-size: 1.5rem; font-weight: 600; line-height: 1.15; letter-spacing: -.01em; }
p, li { text-wrap: pretty; }
a { color: var(--ink); text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 4px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
[id] { scroll-margin-top: 24px; }

.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
@media (min-width: 900px) { :root { --gutter: 40px; } }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -80px; z-index: 10; padding: 12px 16px; border-radius: var(--radius);
  background: var(--accent); color: var(--on-accent); font-weight: 600; text-decoration: none; }
.skip:focus { top: 16px; color: var(--on-accent); }

.section { padding-top: var(--section); }
.sub { margin: 16px 0 0; max-width: 40rem; }
.label { margin: 0; font: 500 1rem/1.4 var(--mono); letter-spacing: .02em; color: var(--muted); }

/* ============ Buttons and links ============ */
.cta { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px; }
.btn { display: inline-flex; align-items: center; min-height: 48px; padding: 12px 20px; border-radius: var(--radius);
  border: 1px solid var(--edge); background: transparent; color: var(--ink);
  font: 600 1.0625rem/1.2 var(--sans); text-decoration: none; }
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); color: var(--on-accent); }
.arrow { font-weight: 600; color: var(--accent); text-decoration: none; }
.arrow:hover { text-decoration: underline; }

/* ============ Signature strip, nav, footer ============ */
.bars { display: flex; height: 4px; }
.bars span { flex: 1; }
.bars span:nth-child(1) { background: var(--bar1); } .bars span:nth-child(2) { background: var(--bar2); }
.bars span:nth-child(3) { background: var(--bar3); } .bars span:nth-child(4) { background: var(--bar4); }
.bars span:nth-child(5) { background: var(--bar5); } .bars span:nth-child(6) { background: var(--bar6); }
.bars span:nth-child(7) { background: var(--bar7); }

.site-nav { border-bottom: 1px solid var(--line); }
.site-nav .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 0 32px; min-height: 64px; }
.brand { margin-right: auto; padding-block: 12px; font: 700 1.25rem/1 var(--display); letter-spacing: -.02em;
  color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.nav-links { display: flex; gap: 0 24px; margin: 0; padding: 0; list-style: none; }
.nav-links a { display: inline-block; padding-block: 12px; color: var(--body); font: 500 1.0625rem/1.2 var(--sans);
  text-decoration: none; }
.nav-links a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 6px; }
@media (max-width: 640px) { .nav-links { order: 3; width: 100%; gap: 0 20px; } }

.theme-btn { width: 44px; height: 44px; padding: 0; display: inline-grid; place-items: center;
  border: 1px solid var(--edge); border-radius: var(--radius); background: transparent; color: var(--ink); cursor: pointer; }
.theme-btn:hover { border-color: var(--ink); }
.theme-btn .i-sun { display: none; }
:root[data-theme="dark"] .theme-btn .i-moon { display: none; }
:root[data-theme="dark"] .theme-btn .i-sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .i-moon { display: none; }
  :root:not([data-theme="light"]) .theme-btn .i-sun { display: block; }
}
html:not(.js) .theme-btn { display: none; }

.site-footer { margin-top: var(--section); border-top: 1px solid var(--line); padding-block: 32px; }
.site-footer .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.site-footer p { margin: 0; font-size: 1rem; color: var(--muted); }

/* ============ Home: hero ============ */
.hero { padding-top: clamp(48px, 8vw, 112px); }
.hero-label { margin-bottom: 16px; }
.hero h1 { width: fit-content; max-width: 100%; font-size: clamp(3.25rem, 1.9rem + 5.6vw, 7rem); font-weight: 700;
  line-height: .95; letter-spacing: -.04em; }
/* The signature: color bars, sized to the name */
.hero h1::after { content: ""; display: block; height: 10px; margin-top: 18px;
  background: linear-gradient(90deg, var(--bar1) 0 14.286%, var(--bar2) 0 28.571%, var(--bar3) 0 42.857%,
    var(--bar4) 0 57.143%, var(--bar5) 0 71.429%, var(--bar6) 0 85.714%, var(--bar7) 0); }
.hero h1 + .lede { margin-top: 32px; }
.lede { margin: 24px 0 0; max-width: 38rem; font-size: 1.375rem; line-height: 1.5; }
@media (max-width: 640px) { .lede { font-size: 1.25rem; } }
.hero .cta { margin-top: 32px; }

/* Platforms shipped on, career-wide */
.shipped { margin: 56px 0 0; padding-top: 16px; border-top: 1px solid var(--line); font: 500 1rem/1.6 var(--mono);
  color: var(--muted); }

/* Facts row (case study) */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 24px; margin: 64px 0 0;
  padding: 24px 0 0; border-top: 1px solid var(--line); list-style: none; }
.facts .n { display: block; font: 700 2.5rem/1 var(--display); letter-spacing: -.03em; color: var(--ink); }
.facts .l { display: block; margin-top: 8px; font-size: 1rem; line-height: 1.5; color: var(--muted); }

/* ============ Home: work ============ */
.feature { display: grid; gap: 32px 40px; margin-top: 48px; padding: 32px; border: 1px solid var(--line);
  border-radius: var(--radius-card); background: var(--surface); color: var(--body); text-decoration: none; }
.feature:hover { border-color: var(--edge); color: var(--body); }
.feature:hover .arrow { text-decoration: underline; }
.feature h3 { margin-top: 8px; font-size: 2rem; }
.feature .alt { margin: 4px 0 0; font-size: 1.125rem; font-style: italic; color: var(--muted); }
.feature p { margin: 16px 0 0; }
.feature .arrow { display: inline-block; margin-top: 20px; }
@media (min-width: 900px) { .feature { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: center; } }
@media (max-width: 640px) { .feature { padding: 20px; } }

.term-mini { padding: 20px; border-radius: 10px; background: var(--term-bg); color: var(--term-ink);
  border: 1px solid var(--line); font: 500 1rem/1.5 var(--mono); overflow-wrap: anywhere; }
.term-mini div + div { margin-top: 6px; }
.term-mini .g, .term .g { color: var(--term-green); }
.term-mini .d, .term .d { color: var(--term-dim); }

.problems { margin-top: 64px; }
.problems h3 { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); }
.problems ul { display: grid; gap: 32px; margin: 24px 0 0; padding: 0; list-style: none; }
.problems li { padding-top: 16px; border-top: 1px solid var(--line); }
.problems b { display: block; margin-bottom: 4px; font-weight: 600; color: var(--ink); }
@media (min-width: 900px) { .problems ul { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.timeline { margin: 48px 0 0; padding: 0; list-style: none; }
.timeline li { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 24px; padding-block: 24px;
  border-top: 1px solid var(--line); }
.timeline .when { padding-top: 4px; font: 500 1rem/1.6 var(--mono); color: var(--muted); }
.timeline h3 small { font: 400 1rem/1.4 var(--sans); letter-spacing: 0; color: var(--muted); }
.timeline p { margin: 8px 0 0; }
.timeline .fine, .timeline .dates { font-size: 1rem; }
.timeline .dates { color: var(--muted); }
@media (max-width: 640px) { .timeline li { grid-template-columns: minmax(0, 1fr); gap: 4px; } }

.earlier { border-top: 1px solid var(--line); }
.earlier summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px;
  min-height: 48px; padding-block: 12px; list-style: none; cursor: pointer;
  font: 500 1.0625rem/1.4 var(--sans); color: var(--ink); }
.earlier summary::-webkit-details-marker { display: none; }
.earlier summary > span:first-child::before { content: "▸"; content: "▸" / ""; display: inline-block; margin-right: 8px;
  color: var(--muted); }
.earlier[open] summary > span:first-child::before { transform: rotate(90deg); }
.earlier .count { font-size: 1rem; font-weight: 400; color: var(--muted); }
.earlier .timeline { margin: 0; }

.stack { margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line); }
.stack h3 { font-size: 1.25rem; }
.stack dl { display: grid; gap: 8px; margin: 16px 0 0; }
.stack div { display: grid; grid-template-columns: 6rem minmax(0, 1fr); gap: 16px; }
.stack dt { font: 600 1rem/1.6 var(--sans); color: var(--ink); }
.stack dd { margin: 0; font-size: 1rem; }
@media (max-width: 640px) { .stack div { grid-template-columns: minmax(0, 1fr); gap: 0; } }

/* ============ Home: interlude ============ */
blockquote { max-width: 32ch; margin: 0; font: 500 clamp(1.75rem, 1.2rem + 2vw, 2.5rem)/1.2 var(--display);
  letter-spacing: -.02em; color: var(--ink); }
blockquote cite { display: block; margin-top: 16px; font: 400 1rem/1.5 var(--sans); font-style: normal;
  letter-spacing: 0; color: var(--muted); }

/* ============ Home: side projects ============ */
.projects { margin: 48px 0 0; padding: 0; list-style: none; }
.proj { padding-block: 24px; border-top: 1px solid var(--line); }
.proj:last-child { border-bottom: 1px solid var(--line); }
.proj-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; }
.proj p { max-width: 42rem; margin: 8px 0 0; }
.proj .proj-meta { font: 500 1rem/1.5 var(--mono); color: var(--muted); }
.proj .links { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 12px; }
.chip { padding: 2px 10px; border: 1px solid var(--edge); border-radius: var(--radius); white-space: nowrap;
  font: 500 1rem/1.5 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.chip.play { border-color: var(--accent); color: var(--accent); }
.chip.year { border-color: transparent; padding-inline: 0; }
.more-link { margin: 24px 0 0; }

/* ============ Home: contact ============ */
.email { display: inline-block; margin-top: 32px; font: 700 clamp(1.5rem, 1rem + 2.4vw, 2.5rem)/1.2 var(--display);
  letter-spacing: -.02em; overflow-wrap: anywhere; text-decoration-thickness: 3px; text-underline-offset: 6px; }
.contact-grid { display: grid; gap: 32px 48px; margin-top: 48px; }
.contact-grid h3 { font-size: 1.25rem; }
.contact-grid p, .contact-grid ol { margin: 8px 0 0; font-size: 1rem; }
.contact-grid ol { padding-left: 24px; }
.contact-grid li + li { margin-top: 6px; }
.contact-grid li::marker { color: var(--muted); font-weight: 600; }
@media (min-width: 900px) { .contact-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.contact-grid .elsewhere { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 16px; }

/* ============ Case study ============ */
.progress { position: fixed; inset: 0 0 auto; height: 3px; z-index: 20; background: var(--accent);
  transform-origin: 0 50%; transform: scaleX(0); }
@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    .progress { animation: grow linear both; animation-timeline: scroll(root); }
    @keyframes grow { to { transform: scaleX(1); } }
  }
}
.cs-hero { padding-top: 48px; }
.back { font-size: 1rem; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--ink); text-decoration: underline; }
.cs-hero .label { margin-top: 32px; }
.cs-hero h1 { margin-top: 12px; font-size: clamp(2.75rem, 1.8rem + 4vw, 5rem); font-weight: 700; line-height: 1;
  letter-spacing: -.035em; }
.cs-hero .alt { margin: 12px 0 0; font-size: clamp(1.25rem, 1rem + 1vw, 1.75rem); font-style: italic; color: var(--muted); }
.cs-hero .lede { max-width: 44rem; }
.cs-hero .lede + .lede { margin-top: 16px; font-size: 1.125rem; }
.meta { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 6px 16px; max-width: 44rem; margin: 32px 0 0; }
.meta dt { font: 600 1rem/1.6 var(--sans); color: var(--ink); }
.meta dd { margin: 0; font-size: 1rem; line-height: 1.6; }
.cs-hero .facts { max-width: 44rem; margin-top: 32px; }
.disclaimer { max-width: 44rem; margin: 24px 0 0; font-size: 1rem; color: var(--muted); }

.cs-body section { padding-top: var(--cs-section); }
.cs-body section > .label { margin-bottom: 8px; }
.prose { max-width: 40rem; margin-top: 16px; }
.prose p { margin: 0 0 16px; }
.pull { max-width: 30ch; margin: 8px 0 0; font: 600 clamp(1.5rem, 1.2rem + 1.4vw, 2rem)/1.25 var(--display);
  letter-spacing: -.015em; color: var(--ink); }
.pull em { font-style: normal; color: var(--accent); }

.term { margin-top: 24px; border: 1px solid var(--line); border-radius: var(--radius-card); overflow: hidden;
  background: var(--term-bg); color: var(--term-ink); font: 500 1rem/1.6 var(--mono); }
.term-bar { display: flex; gap: 7px; padding: 10px 14px; background: var(--term-bar); border-bottom: 1px solid var(--term-rule); }
.term-bar i { width: 11px; height: 11px; border-radius: 50%; background: var(--term-dot); }
.term-body { padding: 18px 20px 22px; overflow-x: auto; }
.term-body:focus-visible { outline-color: var(--term-green); outline-offset: -3px; }
.term-body .intro { margin-bottom: 10px; }
.term-body .outro { margin-top: 10px; }
.term-body .row { display: grid; grid-template-columns: 22ch minmax(0, 1fr); gap: 12px; padding: 3px 0; }
.term-body .row span:last-child { overflow-wrap: anywhere; padding-right: 8px; }
@media (max-width: 640px) { .term-body .row { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 6px 0; } }

.steps { margin: 32px 0 0; padding: 0 0 0 8px; list-style: none; counter-reset: s; }
.steps li { position: relative; padding: 0 0 28px 40px; border-left: 2px solid var(--line); counter-increment: s; }
.steps li:last-child { padding-bottom: 0; border-left-color: transparent; }
.steps li::before { content: ""; position: absolute; left: -7px; top: 8px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--edge); box-shadow: 0 0 0 4px var(--bg); }
.steps h3 { font-size: 1.25rem; }
.steps h3::before { content: counter(s, decimal-leading-zero) "\00a0\00a0"; font: 500 1rem var(--mono); color: var(--muted); }
.steps p { max-width: 40rem; margin: 4px 0 0; font-size: 1rem; }

.arch { display: grid; gap: 16px; margin-top: 32px; }
.arch .col { padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); }
.arch .col.core { border-color: var(--edge); }
.arch h3 { margin-bottom: 12px; font-size: 1.25rem; }
.arch ul { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.arch li { padding: 6px 10px; border-radius: 6px; background: var(--sunk); font-size: 1rem; color: var(--ink); }
.arch li small { display: block; font-size: 1rem; color: var(--body); }
.loop { margin-top: 16px; padding: 14px 18px; border: 1px dashed var(--edge); border-radius: var(--radius-card); font-size: 1rem; }
.loop b { color: var(--ink); }
@media (min-width: 861px) {
  .arch { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr); }
  .arch .col { position: relative; }
  .arch .col + .col::before { content: "→"; content: "→" / ""; position: absolute; left: -16px; top: 50%;
    transform: translate(-50%, -50%); font: 600 1.25rem var(--mono); color: var(--muted); }
}

.cases { display: grid; gap: 16px; margin-top: 32px; }
.case { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); }
.case .label { letter-spacing: .04em; }
.case h3 { margin: 8px 0; font-size: 1.25rem; }
.case p { margin: 0 0 10px; font-size: 1rem; }
.case p:last-child { margin: 0; }
.case .found { color: var(--ink); }
.case .found::before { content: "Found:\00a0"; font-weight: 700; }
@media (min-width: 761px) { .cases { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.rules { display: grid; gap: 0 40px; margin-top: 24px; }
.rule { padding-block: 18px; border-top: 1px solid var(--line); }
.rule h3 { font-size: 1.25rem; }
.rule p { margin: 4px 0 0; font-size: 1rem; }
@media (min-width: 761px) { .rules { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.next { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: var(--section); padding-top: 48px; border-top: 1px solid var(--line); }
.next h3 { font-size: 1.5rem; }

/* Sticky table of contents on wide screens */
.toc { display: none; }
@media (min-width: 960px) {
  .cs-hero { padding-left: calc(var(--gutter) + 210px); }
  .cs-layout { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 40px; }
  .toc { display: block; position: sticky; top: 24px; align-self: start; margin-top: var(--cs-section); font-size: 1rem; }
  .toc-title { margin-bottom: 10px; font-weight: 600; color: var(--ink); }
  .toc ol { margin: 0; padding: 0; list-style: none; border-left: 1px solid var(--line); }
  .toc a { display: block; margin-left: -1px; padding: 6px 0 6px 14px; border-left: 2px solid transparent;
    color: var(--body); text-decoration: none; }
  .toc a:hover, .toc a.here { color: var(--ink); border-left-color: var(--accent); }
}

/* ============ Motion ============ */
@media (prefers-reduced-motion: no-preference) {
  .earlier summary > span:first-child::before { transition: transform .2s; }
  .btn:active { transform: translateY(1px); }
}
