/* Xin, v7: a basic, calm, dark-first typographic page (business card / CV feel). One font (JetBrains Mono), thin ASCII rules,
   empty .piece slots with fixed aspect ratios that assets/pieces.js fills. Tokens first. */
@font-face {
  font-family: "JetBrains Mono Variable";
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url("fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2-variations");
}

@property --accent { syntax: "<color>"; inherits: true; initial-value: #F2431A; }
:root {
  /* night is the default; light is opt-in (html[data-theme="light"]) */
  --ground: #0D0D0C;
  --ink: #ECEAE3;
  --muted: #A3A097;
  --rule: #2B2A27;
  --c-vermilion: #F2431A;
  --c-leaf: #4DBE6E;
  --c-sky: #7C8CFF;
  --c-butter: #E5B52A;
  --accent: var(--c-vermilion);
  --ascii: color-mix(in srgb, var(--accent) 62%, var(--fg)); /* ink of the page's ASCII: follows the accent, so it crossfades with it */
  --ascii-soft: color-mix(in srgb, var(--accent) 38%, var(--mut));

  --bg: var(--ground);
  --fg: var(--ink);
  --mut: var(--muted);

  --radius-sm: 2px;
  --pad: clamp(16px, 5vw, 40px);
  --measure: 66ch;
  --mono: "JetBrains Mono Variable", ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --ease-q: cubic-bezier(0.2, 0, 0, 1);
  color-scheme: dark;
  transition: --accent 700ms var(--ease-q);
}
html[data-theme="light"] {
  --ground: #F1F0EB;
  --ink: #14130F;
  --muted: #55534B;
  --rule: #C9C7BE;
  --c-vermilion: #C9330D;
  --c-leaf: #26783F;
  --c-sky: #455BE8;
  --c-butter: #896606;
  color-scheme: light;
}
html[data-accent="leaf"] { --accent: var(--c-leaf); }
html[data-accent="sky"] { --accent: var(--c-sky); }
html[data-accent="butter"] { --accent: var(--c-butter); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; background: var(--ground); }
html[data-motion="on"] { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
h1, h2, h3, p, ul, ol, dl, dd, figure, pre { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: inherit; }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
p { text-wrap: pretty; max-width: var(--measure); }
h1, h2, h3 { text-wrap: balance; font-family: var(--mono); hyphens: none; }
pre { font-family: var(--mono); }

.wrap { width: 100%; max-width: 920px; margin-inline: auto; padding-inline: var(--pad); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.small { font-size: 0.8125rem; font-weight: 400; line-height: 1.5; }
.lead { font-size: clamp(1rem, 1.6vw, 1.1875rem); line-height: 1.6; font-weight: 400; max-width: 46ch; }
h2 { font-size: 1.125rem; font-weight: 700; line-height: 1.3; letter-spacing: 0; margin: 14px 0 20px; }
h2::before { content: "# "; color: var(--accent); }
html:not([data-js]) .js-only { display: none; }
[hidden] { display: none !important; }

main, header, footer { position: relative; }
.sec { padding-block: clamp(20px, 4vw, 40px) clamp(8px, 2vw, 16px); }

/* focus: one ring, always visible */
:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; border-radius: var(--radius-sm); }
.skip { position: absolute; left: 8px; top: -80px; z-index: 50; background: var(--fg); color: var(--bg); padding: 12px 16px; min-height: 44px; text-decoration: none; border-radius: var(--radius-sm); }
.skip:focus { top: 8px; }

/* header: brand + section nav left, tools right */
.site-header { padding-top: 14px; }
.hbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 24px; padding-bottom: 10px; border-bottom: 1px solid var(--rule); }
.hrow { display: flex; flex-wrap: wrap; align-items: center; gap: 0 20px; }
.brand { display: inline-flex; align-items: center; min-height: 44px; font-weight: 800; font-size: 1.0625rem; text-decoration: none; }
.brand-cur { display: inline-block; width: 0.55em; height: 1em; margin-left: 0.2em; background: var(--accent); animation: blink 1.1s steps(1) infinite; }
.nav ul { display: flex; gap: 0 4px; flex-wrap: wrap; }
.nav a { display: inline-flex; align-items: center; min-height: 44px; padding-inline: 8px; color: var(--mut); text-decoration: none; font-size: 0.8125rem; }
.nav a:hover { color: var(--fg); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 0.3em; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.swatches { display: inline-flex; align-items: center; min-height: 44px; border: 1px solid var(--rule); border-radius: var(--radius-sm); padding-inline: 4px 0; }
.swatches > .small { color: var(--mut); padding-inline: 6px 2px; }
.sw { width: 36px; height: 44px; padding: 0; border: 0; background: none; cursor: pointer; display: inline-grid; place-items: center; }
.sw::before { content: ""; width: 14px; height: 14px; background: var(--sw); border-radius: 1px; }
.sw[aria-pressed="true"]::before { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--fg); }
.sw[data-a="vermilion"] { --sw: var(--c-vermilion); }
.sw[data-a="leaf"] { --sw: var(--c-leaf); }
.sw[data-a="sky"] { --sw: var(--c-sky); }
.sw[data-a="butter"] { --sw: var(--c-butter); }
.sw:focus-visible { outline-offset: -3px; }
.btn {
  min-height: 44px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  background: transparent; color: var(--fg); border: 1px solid var(--rule); border-radius: var(--radius-sm);
  font-size: 0.8125rem; font-weight: 500; line-height: 1.4; cursor: pointer; text-decoration: none;
  transition: background-color 120ms var(--ease-q), color 120ms var(--ease-q), border-color 120ms var(--ease-q);
}
.btn:active { transform: translateY(1px); }
.btn[aria-disabled="true"] { border-style: dashed; color: var(--mut); cursor: not-allowed; }
.btn[aria-disabled="true"]:active { transform: none; }
.btn-go { border-color: var(--accent); font-weight: 700; }
.btn-go[aria-disabled="true"] { border-style: solid; color: var(--mut); cursor: progress; }
.kbd { display: none; color: var(--mut); }
@media (hover: hover) and (pointer: fine) { .kbd { display: inline; } }
@media (hover: hover) {
  .btn:not([aria-disabled="true"]):hover { background: var(--fg); color: var(--bg); border-color: var(--fg); }
}

/* links: ink text, a 2px accent underline (the accent's main job) */
.proj-link a, .studies a, .foot-top a, .handle a, .ulink {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.28em;
}
.proj-link a, .foot-top a, .handle a { display: inline-flex; align-items: center; min-height: 44px; }
@media (hover: hover) {
  .proj-link a:hover, .studies a:hover, .foot-top a:hover, .handle a:hover, .ulink:hover { text-decoration-thickness: 4px; }
}

/* thin ASCII rule above each section heading, and box edges around the chart: real characters in the DOM, aria-hidden */
.rule, .ab-edge, .ab-side { font-family: var(--mono); font-size: 12px; line-height: 1.2; color: var(--ascii-soft); user-select: none; }
.rule { overflow: hidden; white-space: nowrap; max-width: 100%; height: 1.2em; }
.abox { display: grid; }
.ab-edge { display: flex; overflow: hidden; white-space: nowrap; color: var(--ascii); }
.ab-fill { flex: 1; min-width: 0; overflow: hidden; }
.ab-mid { display: grid; grid-template-columns: 1ch minmax(0, 1fr) 1ch; }
.ab-side { position: relative; overflow: hidden; color: var(--ascii); }
.ab-side > span { position: absolute; inset: 0 auto auto 0; white-space: pre; }
.ab-body { padding: 8px clamp(8px, 2vw, 18px); min-width: 0; }

/* piece slots: empty until assets/pieces.js mounts a canvas; the aspect ratio is fixed here so nothing ever shifts.
   The renderer sizes its canvas to the slot (position: absolute; inset: 0). */
.piece { position: relative; width: 100%; overflow: hidden; contain: layout paint; user-select: none; }
.piece > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.piece-divider { aspect-ratio: 11 / 1; margin-block: clamp(8px, 2vw, 20px) 0; }
.piece-garden { height: 125vh; height: 125svh; min-height: 520px; max-height: 1500px; margin-top: clamp(28px, 6vw, 56px); }
.piece-garden::after { content: ""; position: absolute; inset: auto 0 0; height: 90px; background: linear-gradient(transparent, var(--bg)); pointer-events: none; }
.piece-footer { aspect-ratio: 22 / 1; }
@media (max-width: 639px) {
  .piece-divider { aspect-ratio: 24 / 7; }
  .piece-garden { height: 80vh; height: 80svh; }
  .piece-footer { aspect-ratio: 8 / 1; }
}

/* Field-journal spread. Only a new seed changes the established reading path. */
.hero { padding-block: clamp(22px, 4vw, 56px) 0; }
.hero > .wrap { max-width: 1280px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px 24px; align-items: center; }
.piece-hero { height: clamp(270px, 70vw, 460px); max-width: 600px; margin-inline: auto; touch-action: pan-y; cursor: crosshair; }
.plot-index, .plot-seed, .plot-hint { color: var(--mut); }
.plot-index { letter-spacing: .12em; text-transform: uppercase; }
.plot-index span { color: var(--accent); }
.plot-seed { font-variant-numeric: tabular-nums; }
.garden-controls { max-width: 100%; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--rule); }
.garden-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.32fr); margin: 3px 0; }
.garden-actions button { min-height: 44px; padding: 0 8px; background: transparent; border: 0; border-bottom: 1px solid var(--rule); text-align: start; cursor: pointer; font-size: .8125rem; }
.garden-actions button:not([data-garden="material"])::before { content: '+ '; color: var(--accent); }
.garden-actions button:hover { color: var(--accent); }
.garden-actions button:focus-visible { outline-color: var(--accent); outline-offset: -2px; }
.plot-hint { max-width: 44ch; margin-top: 7px; }
.hero-copy .bloom-open { min-height: 44px; margin-top: 0; }
.section-vine { width: calc(100% - 2 * var(--pad)); max-width: 840px; margin-inline: auto; pointer-events: none; }
.section-vine .piece-divider { margin: 0; }
@media (min-width: 640px) {
  .hero-grid { grid-template-columns: minmax(0, 47fr) minmax(0, 53fr); }
  .piece-hero { height: clamp(390px, 52vw, 610px); }
  html[data-garden-side="west"] .hero-grid { grid-template-columns: minmax(0, 53fr) minmax(0, 47fr); }
  html[data-garden-side="west"] .hero-copy { grid-area: 1 / 2; }
  html[data-garden-side="west"] .piece-hero { grid-area: 1 / 1; }
}
@media (min-width: 900px) {
  .hero-grid { grid-template-columns: minmax(0, 41fr) minmax(0, 59fr); gap: 32px; }
  html[data-garden-side="west"] .hero-grid { grid-template-columns: minmax(0, 59fr) minmax(0, 41fr); }
  html[data-garden-path="drift"] .hero-copy { transform: translateY(-22px); }
  html[data-garden-path="cross"] .hero-copy { transform: translateY(22px); }
  html[data-garden-side="east"] .sec { --walk: 1; }
  html[data-garden-side="west"] .sec { --walk: -1; }
  .sec > .wrap { position: relative; left: clamp(-76px, (100vw - 920px) * -.16 * var(--walk, 0), 76px); }
  #work > .wrap { left: clamp(-76px, (100vw - 920px) * .16 * var(--walk, 0), 76px); }
  html[data-garden-path="drift"] #work { padding-top: 62px; }
  html[data-garden-path="cross"] #contact { padding-top: 64px; }
  .section-vine { position: absolute; inset: -8px max(3vw, calc(50% - 625px)) auto auto; width: clamp(180px, 26vw, 380px); }
  .section-vine .piece-divider { height: 72px; }
  html[data-garden-side="west"] .section-vine { right: auto; left: max(3vw, calc(50% - 625px)); }
}
.hero-copy { display: grid; gap: 14px; justify-items: start; min-width: 0; }
@media (max-width: 639px) {
  .hero-grid { gap: 8px; }
  .hero-copy { display: contents; }
  .hero-copy .art, html:not([data-js]) .piece-hero { display: none; }
  .piece-hero { order: 1; }
  .hero-copy > :is(.handle, .bloom-open) { justify-self: start; }
  .hero-copy > .garden-controls { order: 2; justify-self: start; }
  .plot-hint { max-width: 32ch; }
}
h1 { font-size: clamp(2rem, 7vw, 3.5rem); font-weight: 800; line-height: 1.05; letter-spacing: -0.04em; }
.hi { font-weight: 300; letter-spacing: -0.03em; white-space: pre-wrap; color: var(--mut); }
.cur { display: inline-block; width: 0.5em; height: 0.82em; margin-left: 0.12em; background: var(--accent); vertical-align: baseline; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.art { display: block; }
.banner { color: var(--ascii); font-size: 26px; line-height: 1; font-weight: 700; letter-spacing: 0; white-space: pre; overflow: hidden; user-select: none; }
.banner-lg { display: none; }
html[data-motion="on"] .banner[data-reveal] { visibility: hidden; animation: reveal-failsafe 0s 1.5s forwards; }
@keyframes reveal-failsafe { to { visibility: visible; } }
@media (min-width: 600px) {
  .banner-lg { display: block; font-size: 22px; }
  .banner-sm { display: none; }
}
.handle { color: var(--mut); margin-top: -6px; }
.handle a { color: var(--fg); }

/* experiment: a real canvas chart (the one deliberate graphic besides the pieces) */
.exp-top { display: grid; gap: 16px 40px; align-items: end; margin-bottom: 18px; }
.exp-top p { max-width: 52ch; }
.ctl { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-top: 16px; }
.ctl .small { color: var(--mut); flex-basis: 100%; }
.readout { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 20px; }
.readout > div { display: grid; align-content: start; border-top: 1px solid var(--rule); padding-block: 6px 4px; min-width: 0; }
.readout dt { color: var(--mut); }
.readout dd { font-family: var(--mono); font-weight: 700; font-size: 1.375rem; line-height: 1.2; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.readout .r-best dd { color: var(--accent); }
.readout .r-small dd { font-weight: 400; font-size: 0.8125rem; letter-spacing: 0; }
.chart-head { display: flex; justify-content: space-between; gap: 4px 24px; flex-wrap: wrap; min-height: 1.5em; color: var(--mut); margin-bottom: 8px; }
.scrub { font-family: var(--mono); font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
.chart { position: relative; width: 100%; aspect-ratio: 2.25 / 1; touch-action: pan-y; cursor: crosshair; }
.chart canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.winners-note { margin-top: 14px; }
@media (min-width: 900px) {
  .exp-top { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
  .readout { grid-template-columns: repeat(5, minmax(0, auto)); justify-content: space-between; }
}
@media (max-width: 639px) {
  .chart { aspect-ratio: 4 / 3; }
  .readout dd { font-size: 1.125rem; }
}

/* work: one project, plain */
.proj article { display: grid; gap: 10px; padding-block: 4px 8px; }
.proj h3 { font-size: clamp(1.25rem, 3.4vw, 1.625rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.15; overflow-wrap: anywhere; }
.tags { display: flex; flex-wrap: wrap; gap: 2px 18px; font-size: 0.8125rem; color: var(--mut); margin-top: 6px; }
.tags li::before { content: "+ "; color: var(--accent); }
.proj-text { display: grid; gap: 10px; align-content: start; }
.note { color: var(--mut); }
.studies { margin-top: 18px; max-width: 60ch; }

/* contact */
.contact-list { display: grid; gap: 0; margin-bottom: 8px; }
.contact-item { display: grid; grid-template-columns: 8ch minmax(0, 1fr); align-items: center; gap: 0 16px; min-height: 44px; }
.contact-item .ulink { display: inline-flex; align-items: center; min-height: 44px; font-weight: 700; font-size: 1.0625rem; }
.handle-txt { color: var(--mut); }
#contact .note { color: var(--mut); }

/* footer */
.site-footer { padding-block: 8px 24px; }
.site-footer .foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0 24px; color: var(--mut); padding-top: 10px; border-top: 1px solid var(--rule); }
.foot-top a { color: var(--fg); }

/* command palette */
dialog { padding: 0; border: 1px solid var(--fg); border-radius: var(--radius-sm); background: var(--ground); color: var(--ink); width: min(640px, calc(100vw - 32px)); max-height: 80vh; margin: 12vh auto auto; overflow: hidden; font-family: var(--mono); }
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.pal { display: flex; flex-direction: column; min-height: 0; max-height: 80vh; }
.pal-top { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--rule); }
#palette-input { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; font: inherit; font-size: 0.9375rem; background: var(--ground); color: var(--ink); border: 1px solid var(--rule); border-radius: var(--radius-sm); }
.pal-list { overflow-y: auto; padding: 8px; min-height: 120px; }
.pal-group { padding-bottom: 8px; }
.pal-group-h { padding: 8px 12px 4px; color: var(--muted); }
.pal-item { min-height: 44px; display: flex; align-items: center; padding: 0 12px; cursor: pointer; border-radius: var(--radius-sm); }
.pal-item[aria-selected="true"] { background: var(--ink); color: var(--ground); }
.pal-empty { padding: 16px 20px; color: var(--muted); }
.pal-foot { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 10px 20px; border-top: 1px solid var(--rule); color: var(--muted); }
dialog :focus-visible { outline-color: var(--ink); }
.pal-top :focus-visible { outline-offset: 2px; }
#palette-input:focus-visible { outline-offset: -3px; }

/* motion: the animations are JS (banner reveal, chart run, pieces); CSS only blinks the cursors. Off under reduced motion and the in-page toggle. */
html[data-motion="off"] *, html[data-motion="off"] *::before, html[data-motion="off"] *::after { animation: none !important; transition-duration: 0s !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0s !important; scroll-behavior: auto !important; }
}

@media (max-width: 639px) {
  .tools { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .btn { padding: 0 8px; }
  .ctl .btn { flex: 1 1 0; }
  .swatches { grid-column: 1 / -1; justify-content: space-between; padding-inline: 8px 0; }
  .sw { width: 52px; }
}
@media (forced-colors: active) { .cur, .brand-cur { forced-color-adjust: none; } }
