/* Tokens. Dark is the dealt palette; light inverts it for the theme toggle and light-mode systems. */
:root {
  --bg: #0a0a0a;
  --surface: #161616;
  --ink: #efefef;
  --muted: #8c8c8c;
  --accent: #b11226;
  --accent-strong: #d0172e;
  --accent-ink: #ffffff;
  --frame-bg: #1c1c1c;
  --field: #efefef; --field-ink: #0a0a0a; --field-muted: #5c5c5c;


  --font: "Bricolage Grotesque", system-ui, sans-serif;
  --step-small: clamp(0.8125rem, 0.79rem + 0.1vw, 0.875rem);
  --step-body: clamp(1.0625rem, 1rem + 0.25vw, 1.1875rem);
  --step-lead: clamp(1.25rem, 1.1rem + 0.7vw, 1.625rem);
  --step-head: clamp(1.5rem, 1rem + 1.6vw, 2.25rem);
  --step-display: clamp(3.5rem, 1rem + 9.5vw, 10rem);

  --margin: clamp(1rem, 2.2vw, 2rem);
  --gutter: clamp(0.75rem, 1.6vw, 1.5rem);
  --section: clamp(7.5rem, 12vw, 11rem);
  --frame-h: clamp(5.25rem, 3rem + 6vw, 8.5rem);
  --row-h: clamp(8rem, 4rem + 9vw, 13rem);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.76, 0, 0.24, 1);
  --ease-soft: cubic-bezier(0.33, 1, 0.68, 1);
  --t-press: 140ms;
  --t-hover: 180ms;
  --t-ui: 240ms;
  --t-reveal: 800ms;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #efefef; --surface: #e2e2e2; --ink: #0a0a0a; --muted: #5c5c5c; --frame-bg: #dcdcdc;
    --accent-strong: #8f0e1e;
    --field: #0a0a0a; --field-ink: #efefef; --field-muted: #8c8c8c;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #efefef; --surface: #e2e2e2; --ink: #0a0a0a; --muted: #5c5c5c; --frame-bg: #dcdcdc;
  --accent-strong: #8f0e1e;
  --field: #0a0a0a; --field-ink: #efefef; --field-muted: #8c8c8c;
  color-scheme: light;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: var(--step-body); line-height: 1.5; -webkit-font-smoothing: antialiased; transition: background-color var(--t-ui) ease, color var(--t-ui) ease; }
h1, h2, h3, p, figure, ul, ol, dl, dd { margin: 0; }
ul { padding: 0; list-style: none; }
img { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: var(--margin); top: 0.5rem; z-index: 10; background: var(--accent); color: var(--accent-ink); padding: 0.5rem 1rem; clip-path: inset(50%); }
.skip:focus { clip-path: none; }

/* Type */
.display { font-size: var(--step-display); font-weight: 600; line-height: 0.92; letter-spacing: -0.04em; white-space: nowrap; }
.lead { font-size: var(--step-lead); line-height: 1.35; }
.small { font-size: var(--step-small); }
.muted { color: var(--muted); }
.section-title { font-size: var(--step-lead); font-weight: 500; line-height: 1.2; letter-spacing: -0.01em; }
.nums { font-variant-numeric: tabular-nums; }

/* Layout */
.wrap { padding-inline: var(--margin); }
.grid12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gutter); }

/* Controls */
.button { display: inline-flex; align-items: center; min-height: 3rem; padding: 0 1.5rem; background: var(--accent); color: var(--accent-ink); text-decoration: none; font-weight: 500; transition: transform var(--t-press) var(--ease-out), background-color var(--t-hover) ease; }
.button:active { transform: scale(0.97); }
.link { text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 0.2em; text-decoration-thickness: 0.07em; transition: text-decoration-color var(--t-hover) ease, color var(--t-hover) ease; }
.link-plain { text-decoration: underline; text-underline-offset: 0.18em; text-decoration-thickness: 0.07em; transition: color var(--t-hover) ease; }
@media (hover: hover) and (pointer: fine) {
  .button:hover { background: var(--accent-strong); }
  .link:hover { text-decoration-color: currentColor; }
  .link-plain:hover { color: var(--accent-strong); }
}

/* ---------- Hero: text band, the name, then the sheet ---------- */
.hero { padding-top: 0.5rem; }
html { scroll-padding-top: var(--bar-h); }
.bar { position: sticky; top: 0; z-index: 5; background: var(--bg); transition: background-color var(--t-ui) ease; }
.bar__inner { padding-inline: calc(var(--margin) + clamp(0.5rem, 2vw, 2rem)); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.25rem var(--gutter); min-height: 3.5rem; font-size: 1rem; }
.bar__sections, .bar__elsewhere { display: flex; align-items: center; gap: 1.5rem; margin: 0; padding: 0; list-style: none; }
:root { --bar-h: 3.5rem; }
.title h1 { margin-left: -0.05em; }
.theme-toggle { display: inline-grid; place-items: center; width: 1.5em; height: 1.5em; margin-block: -0.125em; color: inherit; transition: color var(--t-hover) ease; }
.theme-toggle svg { width: 1.3em; height: 1.3em; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle[data-next="dark"] .theme-toggle__sun, .theme-toggle:not([data-next="dark"]) .theme-toggle__moon { display: none; }
@media (hover: hover) { .theme-toggle:hover { color: var(--accent-strong); } }
.band { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gutter); row-gap: 2rem; margin-top: clamp(2rem, 3.5vw, 3rem); font-size: 1rem; line-height: 1.45; }
.band__intro { grid-column: 1 / span 5; display: flex; flex-direction: column; align-items: flex-start; gap: 1.5rem; }
.band__intro .lead { max-width: 30ch; }
.band__now { grid-column: 7 / span 3; max-width: 28ch; }
.band__worked { grid-column: 10 / span 3; }

.projects { padding-top: var(--section); }


.sheet { display: flex; flex-direction: column; gap: clamp(4rem, 7vw, 6.5rem); margin-top: clamp(3rem, 5vw, 4.5rem); }
.run { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gutter); align-items: start; transition: color var(--t-hover) ease; }
.run__text { grid-column: 1 / span 4; display: flex; flex-direction: column; gap: 0.75rem; }
.run__title { font-size: var(--step-lead); font-weight: 500; line-height: 1.2; letter-spacing: -0.01em; }
.run__title .muted { font-weight: 400; font-variant-numeric: tabular-nums; }
.run__note { max-width: 36ch; }
.run__stack { font-size: var(--step-small); color: var(--muted); }
.run__links { display: flex; gap: 1.25rem; margin-top: 0.25rem; }
.run__frames { grid-column: 5 / span 8; display: flex; gap: 8px; max-width: calc(var(--ratio, 99) * var(--row-h) + (var(--count, 1) - 1) * 8px); }
.frame { flex: 1 1 0%; min-width: 0; width: 100%; height: auto; background: var(--frame-bg); transition: opacity var(--t-ui) ease, transform var(--t-ui) var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .run:hover .frame { transform: translateY(-3px); } }

/* the chess engine's frames, drawn from its real output */
.uci.frame { flex: 0 0 auto; width: auto; height: auto; }
.uci { margin: 0; min-height: var(--frame-h); padding: 0.5rem 0.75rem; background: var(--frame-bg); color: var(--ink); font: 400 13px/1.15 ui-monospace, "SF Mono", Menlo, monospace; white-space: pre; overflow: hidden; } /* taste-skill-ignore: real engine output in a <pre> */
.uci .out { color: var(--muted); }
.uci .best { color: var(--ink); }


/* ---------- Where I've worked: two-ended rows ---------- */
.experience { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gutter); margin-top: var(--section); padding-block: clamp(4.5rem, 8vw, 7rem); background: var(--surface); }
.experience h2 { grid-column: 1 / span 4; }
.rows { grid-column: 5 / span 8; display: flex; flex-direction: column; gap: 2.5rem; }
.group__word { font-size: var(--step-body); color: var(--muted); margin-bottom: 0.5rem; }
.row { display: grid; grid-template-columns: 16px 1fr auto; column-gap: 0.75rem; align-items: baseline; padding-block: 0.55rem; transition: color var(--t-hover) ease; }
.row__dot { width: 16px; height: 16px; border-radius: 50%; background: var(--muted); align-self: center; }
.row--now .row__dot { background: var(--accent); }
.row__name b { font-weight: 500; }
.row__stack { grid-column: 2; font-size: var(--step-small); color: var(--muted); }
.row__value { grid-row: 1; grid-column: 3; font-size: var(--step-small); color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- About: side facts, wide paragraph, portrait ---------- */
.about { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gutter); row-gap: 1.5rem; padding-top: var(--section); }
.about__title { grid-column: 1 / span 4; grid-row: 1; }
.facts { grid-column: 1 / span 3; grid-row: 2; display: flex; flex-direction: column; gap: 1.25rem; font-size: 1rem; }
.facts dt { color: var(--muted); }
.about__text { grid-column: 5 / span 5; grid-row: 1 / span 2; max-width: 52ch; }
.about__portrait { grid-column: 11 / span 2; grid-row: 1 / span 2; overflow: hidden; }
.about__portrait img { width: 100%; aspect-ratio: 1; object-fit: cover; }

/* ---------- The ending: contact and footer on the inverted field ---------- */
.ending { margin-top: var(--section); background: var(--field); color: var(--field-ink); --ink: var(--field-ink); --muted: var(--field-muted); --bg: var(--field); }
.contact { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gutter); align-items: start; padding-top: clamp(5rem, 9vw, 8rem); }
.contact__statement { grid-column: 1 / span 6; font-size: var(--step-head); line-height: 1.12; letter-spacing: -0.02em; max-width: 24ch; }
.contact__links { grid-column: 9 / span 4; display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem; font-size: var(--step-body); min-width: 0; overflow-wrap: anywhere; }
.contact__q { font-weight: 500; margin-bottom: 1rem; }
.contact__links .small { margin-top: 0.9rem; }

/* ---------- Footer: one quiet line ---------- */
.foot { display: grid; grid-template-columns: 1fr auto 1fr; align-items: baseline; gap: 1rem; padding-top: clamp(8rem, 22svh, 14rem); padding-bottom: 30px; font-size: 1rem; }
.foot__links { display: flex; gap: 1.5rem; }
.foot__end { justify-self: end; }

/* ---------- Tablet ---------- */
@media (max-width: 64em) {
  .band__intro { grid-column: 1 / -1; }
  .run { display: block; }
  .run__text { margin-bottom: 1.5rem; }
  .run__note { max-width: 52ch; }
  .band__now { grid-column: 1 / span 6; }
  .band__worked { grid-column: 7 / span 6; }
  .about__text { grid-column: 5 / -1; }
  .about__portrait { grid-column: 1 / span 3; grid-row: 3; margin-top: 1rem; }
  .contact__statement { grid-column: 1 / -1; max-width: 30ch; margin-bottom: 3rem; }
  .contact__links { grid-column: 1 / -1; }
}

/* ---------- Phone: its own composition ---------- */
@media (max-width: 40em) {
  :root { --bar-h: 5.5rem; }
  .bar__inner { padding-block: 0.6rem; }
  .bar__sections, .bar__elsewhere { gap: 1.25rem; }
  .band { grid-template-columns: 1fr; margin-top: 1.25rem; }
  .band__intro, .band__now, .band__worked { grid-column: 1; }
  .sheet { gap: 3.5rem; }
  .run { display: block; }
  .run__text { gap: 0.5rem; margin-bottom: 1.25rem; }
  .run__frames { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: none; }
  .run__frames .frame { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; object-position: top; }
  .run__frames .uci { grid-column: 1 / -1; aspect-ratio: auto; height: auto; }
  .run__frames .frame:only-child { grid-column: 1 / -1; aspect-ratio: 16 / 10; }


  .experience, .about { display: block; }
  .rows { margin-top: 2rem; gap: 2rem; }
  .row { padding-block: 0.7rem; }
  .row__value { grid-row: auto; grid-column: 2; }
  .facts { display: grid; grid-template-columns: 1fr 1fr; margin-top: 2rem; }
  .about__text { margin-top: 1.5rem; }
  .about__portrait { width: 9rem; margin-top: 2rem; }
  .contact { display: block; }
  .contact__statement { font-size: 1.5rem; }
  .contact__links { margin-top: 2rem; }
  .contact__q { margin-bottom: 0.4rem; line-height: 1.2; }
  .foot { display: flex; flex-direction: column; gap: 8px; padding-top: 20svh; padding-bottom: 24px; }
  .foot__links { flex-wrap: wrap; gap: 0.5rem 1.25rem; }
  .foot__end { justify-self: start; }
}

/* ---------- Motion (content stays visible without script) ---------- */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  .js [data-rise] { opacity: 0; transform: translateY(18px); animation: rise var(--t-reveal) var(--ease-out) forwards; animation-delay: calc(var(--i, 0) * 90ms + 120ms); }
  .js .sheet:not(.is-in) .run { opacity: 0; }
  .js .sheet.is-in .run { opacity: 0; transform: translateY(20px); animation: rise 700ms var(--ease-out) forwards; animation-delay: calc(var(--i, 0) * 70ms); }
  .js [data-reveal] { opacity: 0; transform: translateY(24px); transition: opacity 700ms var(--ease-out), transform 900ms var(--ease-out); transition-delay: calc(var(--i, 0) * 80ms); }
  .js [data-reveal].is-in { opacity: 1; transform: none; }
  .js .about__portrait img { transform: scale(1.15); transition: transform 2400ms var(--ease-soft); }
  .js .about__portrait.is-in img { transform: none; }
  .js .uci .ln { opacity: 0; }
  .js .sheet.is-in .uci .ln { animation: type 1ms linear forwards; animation-delay: calc(var(--i, 0) * 160ms + 500ms); }
}
@keyframes rise { to { opacity: 1; transform: none; } }
@keyframes type { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; }
}
