/* ══════════════════════════════════════════════════════════════════
   HOMEPAGE — STICKY IDENTITY RAIL (Layout B)
   Loaded after css/tokens.css on / only. Essays keep css/styles.css.
   Reference var(--*) tokens only — do not redeclare palette or type.
   ══════════════════════════════════════════════════════════════════ */

:root {
  --rail-w: 300px;
  --rule: 1.5px solid var(--ink);
  --accent-soft: rgb(var(--vermillion-rgb) / 0.14);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-md);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--bg-washi);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(var(--grid-line-strong) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line-strong) 1px, transparent 1px),
    var(--paper-texture);
  background-size: 8px 8px, 8px 8px, 40px 40px, 40px 40px, auto;
}

a {
  color: inherit;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--vermillion);
}

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

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

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 2rem;
  margin-bottom: var(--space-md);
}

h3 {
  font-size: 1.2rem;
  margin-bottom: 6px;
}

.skip-link {
  position: absolute;
  left: var(--space-sm);
  top: -4rem;
  z-index: 100;
  padding: var(--space-xs) var(--space-sm);
  background: var(--ink);
  color: var(--surface-slate);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.skip-link:focus {
  top: var(--space-sm);
}

.kicker {
  display: block;
  margin-bottom: var(--space-xs);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.btn {
  display: inline-block;
  padding: 12px 18px;
  border: var(--rule);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 150ms var(--ease-kinetic), box-shadow 150ms var(--ease-kinetic);
}

.btn:hover {
  color: var(--ink);
  transform: translate(-2px, -2px);
  box-shadow: 3px 3px 0 var(--vermillion);
}

.btn-primary,
.btn-primary:hover {
  background: var(--ink);
  color: var(--surface-slate);
}

/* ══════════════════════════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════════════════════════ */

.site {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-lg) 26px var(--space-md);
  border-right: var(--rule);
  background: rgb(244 241 234 / 0.72);
}

/* Portrait shrinks on short screens so the rail never needs its own scrollbar */
.rail .portrait {
  flex: none;
  width: clamp(88px, 100vh - 560px, 100%);
  height: auto;
  aspect-ratio: 1;
  border: var(--rule);
  object-fit: cover;
  background: var(--line);
  filter: grayscale(100%) contrast(1.1);
  transition: filter var(--transition-premium);
}

.rail .portrait:hover {
  filter: none;
}

.rail .name {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.rail .tagline {
  list-style: none;
  margin-top: -6px;
  font-family: var(--font-display);
  font-size: 0.98rem;
  line-height: 1.45;
  color: var(--ink-soft);
}

.rail .tagline a {
  text-decoration-color: var(--line);
  text-decoration-thickness: 1px;
}

.rail .tagline a:hover {
  text-decoration-color: currentColor;
}

/* Section nav: a track with a marker that slides to the section in view */
.rail nav {
  position: relative;
}

.rail nav ul {
  list-style: none;
  border-left: 1px solid var(--line);
}

.rail nav a {
  display: block;
  padding: 7px 0 7px 14px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-decoration: none;
}

.rail nav a:hover,
.rail nav a[aria-current="true"] {
  color: var(--vermillion);
}

.rail nav a[aria-current="true"] {
  font-weight: 600;
}

.nav-marker {
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 0;
  background: var(--vermillion);
  opacity: 0;
  transition:
    transform 300ms var(--ease-kinetic),
    height 300ms var(--ease-kinetic),
    opacity 200ms ease;
}

.nav-marker.is-active {
  opacity: 1;
}

/* Action block pinned to the bottom of the rail */
.rail .rail-action {
  display: grid;
  gap: 12px;
  margin-top: auto;
  padding-top: var(--space-xs);
}

.rail .rail-cta {
  text-align: center;
}

.rail .rail-foot {
  display: flex;
  justify-content: center;
  gap: 18px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.rail .rail-foot a {
  text-decoration: none;
}

main {
  width: 100%;
  max-width: 1040px;
  margin-inline: auto;
  padding: 0 clamp(24px, 5vw, 72px);
}

/* Very wide screens: a slightly wider column, centred, so the right side isn't empty */
@media (min-width: 1800px) {
  main {
    max-width: 1200px;
  }
}

main > section {
  padding: 56px 0;
  border-top: 1px solid var(--line);
}

main > section:first-of-type {
  border-top: 0;
}

/* ── Hero ── */
.hero {
  padding: 72px 0 48px;
}

.hero h1 {
  max-width: 16ch;
  margin-bottom: 18px;
  font-size: clamp(2.1rem, 4.6vw, 3.4rem);
}

.hero .lede {
  max-width: 46ch;
  font-size: 1.18rem;
  color: var(--ink-soft);
}

/* Same highlighter as the italic words in the bets */
.hero .lede strong {
  padding: 0 2px;
  font-weight: 600;
  color: var(--vermillion);
  background: linear-gradient(transparent 58%, var(--accent-soft) 58%);
}

/* Keeps a lowercase letter inside an uppercase kicker (CIOs, not CIOS) */
.keep-case {
  text-transform: none;
}

.hero .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

/* Proof row: the headline numbers, right under the pitch */
.proof {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: var(--space-xl);
  border-top: var(--rule);
}

.proof li {
  padding: var(--space-sm) var(--space-sm) 0;
  border-left: 1px solid var(--line);
}

.proof li:first-child {
  padding-left: 0;
  border-left: 0;
}

.proof b {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 2.6vw, 2.4rem);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.proof span {
  display: block;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.45;
  color: var(--ink-muted);
}

/* Narrow hero column (phones, or tablets beside the rail): one stat per row,
   so a word like "Premonition" never overflows */
.hero {
  container: hero / inline-size;
}

@container hero (max-width: 620px) {
  .proof {
    grid-template-columns: minmax(0, 1fr);
  }

  .proof li {
    padding: 14px 0;
    border-left: 0;
  }

  .proof li + li {
    border-top: 1px solid var(--line);
  }
}

/* Browsers without container queries (Safari 15 and earlier): use the
   viewport instead, stacking the stats wherever the hero could be narrow */
@supports not (container-type: inline-size) {
  @media (max-width: 1100px) {
    .proof {
      grid-template-columns: minmax(0, 1fr);
    }

    .proof li {
      padding: 14px 0;
      border-left: 0;
    }

    .proof li + li {
      border-top: 1px solid var(--line);
    }
  }
}

/* ── Three bets ── */
.bets {
  list-style: none;
}

.bet {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: baseline;
  padding: 20px 0;
  border-top: 1px solid var(--line);
}

.bet:last-child {
  border-bottom: 1px solid var(--line);
}

.bet .n {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  color: var(--vermillion);
}

.bet p {
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.bet em {
  font-style: italic;
  background: linear-gradient(transparent 62%, var(--accent-soft) 62%);
}

.bet a {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
  white-space: nowrap;
}

.bet a:hover {
  color: var(--vermillion);
}

/* ── Work with me ── */
.section-note {
  max-width: 60ch;
  margin: calc(var(--space-xs) - var(--space-md)) 0 var(--space-md);
  color: var(--ink-soft);
}

.services {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-sm);
}

.card {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: 22px;
  border: var(--rule);
  background: var(--surface-strong);
}

.card p {
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.card .for {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

/* ── Field notes ──
   Wide cards (feature, doodle) bracket a row of three. Layout follows the
   width of the notes column, not the viewport, because the rail takes 300px. */
#notes {
  container: notes / inline-size;
}

.notes {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-sm);
}

.note {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: 20px;
  border: var(--rule);
  background: var(--surface-strong);
  text-decoration: none;
  transition: transform 150ms var(--ease-kinetic), box-shadow 150ms var(--ease-kinetic);
}

.note:hover {
  color: var(--ink);
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 var(--ink);
}

.note-body {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.note p {
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.note .note-aside {
  margin-top: var(--space-xs);
  font-style: italic;
}

.note-link {
  margin-top: auto;
  padding-top: 12px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.note:hover .note-link {
  color: var(--vermillion);
}

.note-wide h3 {
  font-size: 1.65rem;
}

.note-doodle {
  border-color: var(--vermillion);
  background: rgb(var(--vermillion-rgb) / 0.04);
}

.note-doodle:hover {
  box-shadow: 4px 4px 0 var(--vermillion);
}

/* Medium column: wide cards go side by side; the three become rows */
@container notes (min-width: 560px) {
  .note-wide,
  .note:not(.note-wide) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--space-md);
    align-items: center;
  }

  .note:not(.note-wide) {
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  }

  .note-wide {
    padding: 26px;
  }

  .note-doodle .note-visual {
    order: 2;
  }
}

/* Wide column: the three sit in a row with the diagram on top */
@container notes (min-width: 820px) {
  .notes {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .note-wide {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: 32px;
  }

  .note:not(.note-wide) {
    display: flex;
    align-items: stretch;
  }
}

/* Inline diagrams reused from the previous homepage cards (no image requests) */
.note-visual {
  aspect-ratio: 16 / 9;
  border: 1px solid var(--ink);
  background:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    var(--surface-slate);
  background-size: 12px 12px, 12px 12px, auto;
  overflow: hidden;
}

.note-visual svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.2;
}

.note-visual circle {
  fill: var(--surface-strong);
}

.note-visual .fn-dash {
  stroke: rgb(23 32 30 / 0.42);
  stroke-dasharray: 4 4;
}

.note-visual .fn-faint {
  stroke: rgb(23 32 30 / 0.18);
}

.note-visual .fn-ghost {
  fill: rgb(255 255 255 / 0.42);
  stroke: rgb(23 32 30 / 0.28);
}

.note-visual .fn-blue-soft {
  fill: rgb(43 108 176 / 0.09);
  stroke: rgb(43 108 176 / 0.55);
}

.note-visual .fn-purple-soft {
  fill: rgb(107 70 193 / 0.09);
  stroke: rgb(107 70 193 / 0.55);
}

.note-visual .fn-accent {
  stroke: var(--vermillion);
  stroke-width: 1.7;
}

.note-visual .fn-accent-fill {
  fill: var(--vermillion);
  stroke: var(--vermillion);
}

.note-visual rect {
  fill: rgb(255 255 255 / 0.5);
}

.note-visual .fn-axis,
.note-visual .fn-triangle {
  fill: none;
  stroke: var(--ink);
}

.note-visual .fn-accent-soft {
  fill: rgb(var(--vermillion-rgb) / 0.1);
  stroke: rgb(var(--vermillion-rgb) / 0.58);
}

.note-visual .fn-purpose {
  fill: rgb(var(--vermillion-rgb) / 0.08);
  stroke: rgb(var(--vermillion-rgb) / 0.35);
}

.note-visual .fn-system {
  fill: rgb(43 108 176 / 0.07);
  stroke: rgb(43 108 176 / 0.32);
}

.note-visual .fn-ai {
  fill: rgb(107 70 193 / 0.08);
  stroke: rgb(107 70 193 / 0.34);
}

/* ── Experience ── */
.two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 44px;
}

.timeline {
  list-style: none;
  padding-left: 20px;
  border-left: var(--rule);
}

.timeline li {
  position: relative;
  padding-bottom: 18px;
  font-size: 0.95rem;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: -26px;
  top: 7px;
  width: 10px;
  height: 10px;
  border: var(--rule);
  border-radius: 50%;
  background: var(--bg-washi);
}

.timeline .when {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
}

/* Organization marks: original artwork and colors (see SOURCES.md); CSS sets size only.
   They sit in the rail on tall desktop screens, and under the timeline otherwise. */
.logos {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, auto);
  justify-content: space-between;
  align-items: center;
  gap: 12px 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.logos li {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 26px;
}

.logos img {
  width: auto;
  max-width: 100%;
  height: 18px;
}

.logos .logo-microsoft {
  height: 15px;
}

.logos .logo-atlassian {
  height: 13px;
}

.logos .logo-veriscience {
  height: 18px;
}

.logos .logo-insead {
  height: 26px;
}

.logos .logo-bits {
  height: 22px;
}

.logos-inline {
  display: none;
  max-width: 440px;
  margin-top: var(--space-md);
  gap: 18px 20px;
}

.logos-inline li {
  height: 34px;
}

.logos-inline .logo-microsoft {
  height: 20px;
}

.logos-inline .logo-atlassian {
  height: 17px;
}

.logos-inline .logo-veriscience {
  height: 24px;
}

.logos-inline img {
  height: 24px;
}

.logos-inline .logo-insead {
  height: 34px;
}

.logos-inline .logo-bits {
  height: 28px;
}

.talks {
  list-style: none;
}

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

.talks a {
  display: block;
  padding: 11px 0;
  font-size: 0.95rem;
  text-decoration: none;
}

.talks a:hover {
  text-decoration: underline;
}

.talks small {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
}

/* ── Contact ── */
.contact-reply {
  margin-top: var(--space-sm);
  color: var(--ink-soft);
}

.contact-direct {
  margin-top: var(--space-md);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.contact-form {
  padding: var(--space-md);
  border: var(--rule);
  background: var(--surface-strong);
}

.contact-form fieldset {
  margin-bottom: var(--space-sm);
  border: 0;
}

.contact-form legend {
  margin-bottom: var(--space-xs);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

/* Real radios, visually hidden but still focusable and keyboard operable */
.chips input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.chips label {
  padding: 7px 12px;
  border: var(--rule);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  cursor: pointer;
}

.chips input:checked + label {
  background: var(--ink);
  color: var(--surface-slate);
}

.chips input:focus-visible + label {
  outline: 2px solid var(--vermillion);
  outline-offset: 2px;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field span {
  display: block;
  margin-bottom: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.field input,
.field textarea {
  width: 100%;
  padding: 8px 0;
  border: 0;
  border-bottom: var(--rule);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

.field textarea {
  min-height: 90px;
  resize: vertical;
}

.form-hint {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.form-status {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--vermillion);
}

.form-status:empty {
  display: none;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding: 28px 0 48px;
  border-top: var(--rule);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.site-footer p + p {
  margin-top: 4px;
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════ */

/* Shorter desktop screens: logos move under the timeline and the portrait
   takes the room, so the rail never needs its own scrollbar. */
@media (max-height: 759px) {
  .rail .portrait {
    width: clamp(88px, 100vh - 470px, 100%);
  }
}

@media (max-width: 820px), (max-height: 759px) {
  .rail .logos {
    display: none;
  }

  .logos-inline {
    display: grid;
  }
}

/* Narrow screens, or landscape phones: the rail collapses into a slim sticky bar */
@media (max-width: 820px), (max-height: 560px) {
  html {
    scroll-padding-top: 72px;
  }

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

  .rail {
    z-index: 10;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    height: auto;
    overflow: visible;
    padding: 10px var(--space-sm);
    border-right: 0;
    border-bottom: var(--rule);
    background: rgb(244 241 234 / 0.94);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }

  .rail .portrait {
    width: 34px;
    height: 34px;
    border-width: 1px;
    border-radius: 50%;
    filter: none;
  }

  .rail .name {
    flex: 1;
    min-width: 0;
    font-size: 1rem;
  }

  .rail .tagline,
  .rail nav,
  .rail .rail-foot {
    display: none;
  }

  .rail .rail-action {
    flex: none;
    margin-top: 0;
    padding-top: 0;
  }

  .rail .rail-cta {
    padding: 8px 12px;
    font-size: 0.75rem;
  }
}

/* Narrow screens: single-column content */
@media (max-width: 820px) {
  body {
    font-size: 16px;
  }

  main {
    padding: 0 18px;
  }

  main > section {
    padding: 40px 0;
  }

  .hero {
    padding: 32px 0;
  }

  .proof {
    margin-top: var(--space-lg);
  }

  h2 {
    font-size: 1.5rem;
  }

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

  .bet a {
    grid-column: 2;
  }

  .bet p {
    font-size: 1.12rem;
  }

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }

  .btn:hover,
  .note:hover {
    transform: none;
  }
}
