/* Design notes: dark full-bleed stage, tiny uppercase mono for UI, a floating paper
   nav card, an index of work whose hover swaps the backdrop. Inspired by
   artemiilebedev.com, but the backdrop is the work's own data, not a photo. */

:root {
  --bg: #0c0d0e;
  --bg-2: #141618;
  --ink: #e9e7e2;
  --ink-2: #a3a19c;
  --ink-3: #5f5e5a;
  --rule: #26282a;
  --paper: #f1efe9;
  --paper-ink: #111;
  --accent: #c8f04b;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Inter Tight', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --gutter: 12px;
  --index-left: 46%;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 11px/1.45 var(--mono);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; font-weight: 400; }
ol, ul { list-style: none; margin: 0; padding: 0; }
::selection { background: var(--accent); color: #000; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: var(--gutter); top: var(--gutter); z-index: 100; background: var(--paper); color: var(--paper-ink); padding: 8px; }

.label { font: 400 11px/1.4 var(--mono); text-transform: uppercase; color: var(--ink-2); letter-spacing: 0.04em; }
.label a:hover { color: var(--ink); }
.label--box { background: var(--paper); color: var(--paper-ink); padding: 3px 5px; }
.muted { color: var(--ink-3); }
.pill { font-style: normal; border: 1px solid currentColor; padding: 0 4px; margin-left: 6px; font-size: 10px; opacity: 0.8; }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 7px; vertical-align: 1px; animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- Nav card ---------- */
.card {
  position: fixed; z-index: 20;
  top: var(--gutter); left: var(--gutter);
  width: min(300px, calc(100vw - 2 * var(--gutter)));
  background: var(--paper); color: var(--paper-ink);
  padding: 9px 9px 8px;
  display: grid; grid-template-columns: 1.3fr 1fr; gap: 0 12px;
}
.card__name { display: block; }
.card__role { display: block; color: #6b6a66; }
.card__nav { display: flex; flex-direction: column; }
.card__nav a { width: fit-content; }
.card__nav a:hover, .card__nav a[aria-current] { background: var(--paper-ink); color: var(--paper); }
.card__status { grid-column: 1 / -1; margin-top: 26px; padding-top: 7px; border-top: 1px solid #d8d5cd; color: #3d3c39; }
.card__status .dot { background: #4b8a12; }

/* ---------- Top bar ---------- */
.topbar {
  position: absolute; z-index: 15; top: var(--gutter);
  left: var(--index-left); right: var(--gutter);
  display: flex; justify-content: space-between; gap: 16px;
  pointer-events: none;
  mix-blend-mode: difference;
}

/* ---------- Home stage ---------- */
.stage { position: relative; min-height: 100vh; min-height: 100svh; overflow: hidden; border-bottom: 1px solid var(--rule); }
.stage__bg { position: absolute; inset: 0; }
.stage__visual {
  position: absolute; margin: 0;
  left: var(--gutter); top: 50%; transform: translateY(-46%);
  width: calc(var(--index-left) - 4 * var(--gutter));
  color: var(--ink);
  opacity: 0; transition: opacity 0.35s ease;
}
.stage__visual.is-on { opacity: 1; }
.stage__visual--default { inset: 0; width: auto; transform: none; color: var(--ink-3); }
.stage__visual--default .chart { width: 100%; height: 100%; }
.stage__visual--default .c-line { stroke: var(--accent); stroke-width: 1.5; }
.stage__visual--default.is-on { opacity: 0.75; }
.index .row > span, .index .filters { background: rgb(12 13 14 / 0.72); }
.stage__visual figcaption { margin-top: 10px; color: var(--ink-2); }
.stage__visual figcaption span { color: var(--accent); font: 500 13px var(--mono); margin-right: 6px; }

.stage__intro { position: absolute; left: var(--gutter); bottom: 54px; z-index: 2; pointer-events: none; }
.stage__h1 {
  font: 500 clamp(40px, 6.4vw, 104px)/0.9 var(--sans);
  letter-spacing: -0.035em; text-transform: none; max-width: 9ch;
}
.stage__h1 span { display: block; margin-top: 14px; font: 400 11px var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-2); }
.page-home.has-hover .stage__intro { opacity: 0; transition: opacity 0.25s; }

.index {
  position: absolute; z-index: 3;
  left: var(--index-left); right: var(--gutter); top: 50%;
  transform: translateY(-50%);
}
.index__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 12px; }
.filters { display: flex; gap: 2px; flex-wrap: wrap; }
.filters button {
  font: inherit; text-transform: inherit; letter-spacing: inherit;
  background: none; border: 0; color: var(--ink-3); padding: 2px 5px; cursor: pointer;
}
.filters button:hover { color: var(--ink); }
.filters button[aria-pressed='true'] { color: var(--ink); background: var(--bg-2); }

/* ---------- Index rows (shared) ---------- */
.row {
  display: grid; align-items: baseline;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 0.7fr) 3.5em;
  gap: 12px; padding: 1px 0;
  color: var(--ink-2);
}
.row__year { text-align: right; }
.row:hover, .row:focus-visible, .row.is-on { color: var(--ink); }
.row:hover .row__title, .row:focus-visible .row__title, .row.is-on .row__title { background: var(--paper); color: var(--paper-ink); }
.row__title { width: fit-content; padding: 0 3px; margin-left: -3px; }
.rows li.is-hidden { display: none; }

.rows--plain .row { grid-template-columns: 8em minmax(0, 1.6fr) minmax(0, 1fr) 4em; padding: 7px 0; border-top: 1px solid var(--rule); }
.rows--plain .row--post .row__year, .rows--plain .row--static .row__year { text-align: left; }
.rows--plain .row--post .row__origin { text-align: right; }
.row--static { color: var(--ink); grid-template-columns: 11em minmax(0, 1fr) minmax(0, 1.4fr); }
.row--static:hover .row__title { background: none; color: inherit; }
.row__title small { display: block; color: var(--ink-3); margin-top: 2px; font-size: 11px; }
.row__desc { text-transform: none; font: 400 14px/1.45 var(--sans); letter-spacing: 0; color: var(--ink-2); }

/* ---------- Home sections ---------- */
.statement, .list-section, .page, .case { padding: 120px var(--gutter) 96px; }
.statement { display: grid; grid-template-columns: var(--index-left) 1fr; gap: 24px 0; border-bottom: 1px solid var(--rule); }
.statement > .label { grid-column: 1; }
.statement__text, .facts, .statement .more { grid-column: 2; }
.statement__text {
  font: 400 clamp(22px, 2.6vw, 38px)/1.18 var(--sans);
  text-transform: none; letter-spacing: -0.015em; max-width: 26ch;
}
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 32px; border-top: 1px solid var(--rule); padding-top: 12px; }
.fact { display: block; margin-top: 4px; color: var(--ink); }
.more { display: inline-block; margin-top: 28px; color: var(--ink); border-bottom: 1px solid var(--ink-3); }
.more:hover { border-color: var(--accent); }

.list-section { display: grid; grid-template-columns: var(--index-left) 1fr; }
.list-section__head { padding-right: 32px; }
.list-section__head .muted { margin-top: 8px; max-width: 32ch; }
.list-section .rows, .list-section .more, .list-section > .muted { grid-column: 2; }

/* ---------- Generic page ---------- */
.page, .case { max-width: 1400px; padding-left: var(--index-left); padding-right: var(--gutter); }
.page__title, .case__title {
  font: 500 clamp(36px, 5vw, 76px)/0.95 var(--sans);
  letter-spacing: -0.03em; text-transform: none; margin: 14px 0 24px;
}
.page__lede, .case__summary {
  font: 400 clamp(18px, 1.6vw, 24px)/1.3 var(--sans);
  text-transform: none; letter-spacing: -0.01em; color: var(--ink-2); max-width: 36ch; margin-bottom: 48px;
}
.section-label { margin: 72px 0 10px; }

.prose { text-transform: none; font: 400 17px/1.6 var(--sans); letter-spacing: 0; color: var(--ink); max-width: 64ch; }
.prose p, .prose ul, .prose ol, .prose pre, .prose blockquote { margin: 0 0 1.1em; }
.prose ul { list-style: disc; padding-left: 1.2em; }
.prose ol { list-style: decimal; padding-left: 1.4em; }
.prose h2, .prose h3 { font: 500 22px/1.2 var(--sans); margin: 1.8em 0 0.6em; }
.prose a { border-bottom: 1px solid var(--ink-3); }
.prose a:hover { border-color: var(--accent); }
.prose code { font: 13px var(--mono); background: var(--bg-2); padding: 1px 4px; }
.prose pre { background: var(--bg-2); padding: 14px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose blockquote { border-left: 2px solid var(--accent); padding-left: 14px; color: var(--ink-2); }
.prose--lead { font-size: 20px; }

.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px 24px; border-top: 1px solid var(--rule); padding-top: 12px; }
.skills p { margin-top: 6px; text-transform: none; font: 400 15px/1.45 var(--sans); letter-spacing: 0; }

.contact { border-top: 1px solid var(--rule); padding-top: 16px; }
.contact__lede { text-transform: none; font: 400 18px/1.4 var(--sans); max-width: 40ch; color: var(--ink-2); }
.contact__email { display: inline-block; margin: 18px 0 12px; font: 500 clamp(22px, 3.2vw, 44px)/1 var(--sans); text-transform: none; letter-spacing: -0.02em; border-bottom: 2px solid var(--accent); }

/* ---------- Case study ---------- */
.case__context { color: var(--ink-2); margin-bottom: 20px; }
.case__meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px 24px; margin: 0; border-top: 1px solid var(--rule); padding-top: 12px; }
.case__meta dd { margin: 6px 0 0; }
.case__meta a { border-bottom: 1px solid var(--ink-3); margin-right: 10px; }
.case__metric { font: 500 32px/1 var(--sans); text-transform: none; color: var(--accent); }
.case__metric span { display: block; margin-top: 6px; font: 400 11px var(--mono); text-transform: uppercase; color: var(--ink-2); }
.tag { display: inline-block; border: 1px solid var(--rule); padding: 1px 6px; margin: 0 4px 4px 0; }
.case__figure { margin: 56px 0; padding: 28px; background: var(--bg-2); color: var(--ink); }
.case__figure figcaption { margin-top: 12px; }
.case__body section { display: grid; grid-template-columns: 12em 1fr; gap: 16px; padding: 18px 0; border-top: 1px solid var(--rule); }
.case__body p { text-transform: none; font: 400 17px/1.6 var(--sans); letter-spacing: 0; max-width: 62ch; }
.case__pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 64px; border-top: 1px solid var(--rule); padding-top: 16px; }
.case__pager a { display: flex; flex-direction: column; gap: 4px; font: 500 20px var(--sans); text-transform: none; letter-spacing: -0.01em; }
.case__pager a:hover { color: var(--accent); }
.case__pager .right { text-align: right; }

/* ---------- Charts ---------- */
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.c-fill { fill: currentColor; }
.c-dim { opacity: 0.35; }
.c-hollow { fill: none; stroke: currentColor; stroke-width: 1.2; opacity: 0.5; }
.c-line { fill: none; stroke: currentColor; stroke-width: 2; }
.c-axis { stroke: currentColor; stroke-width: 1; opacity: 0.3; }
.c-dash { stroke-dasharray: 4 4; }
.c-label { font: 400 11px var(--mono); fill: currentColor; opacity: 0.7; letter-spacing: 0.04em; }
.c-value { font: 500 13px var(--mono); fill: currentColor; }
.c-big { font: 500 128px var(--sans); fill: currentColor; letter-spacing: -0.04em; }
.c-win { fill: var(--accent); }
.stage__visual:not(.stage__visual--default) .c-line { stroke: var(--accent); }

/* ---------- Ask AI ---------- */
.ask-ai {
  display: grid; grid-template-columns: var(--index-left) 1fr; gap: 16px 0; align-items: end;
  padding: 40px var(--gutter); border-top: 1px solid var(--rule); background: var(--bg-2);
}
.ask-ai__prompt { margin-top: 8px; color: var(--ink-2); text-transform: none; max-width: 52ch; }
.ask-ai__buttons { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.ai-btn {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px; border: 1px solid var(--rule); color: var(--ink);
  transition: background 0.15s, color 0.15s;
}
.ai-btn:hover { background: var(--paper); color: var(--paper-ink); border-color: var(--paper); }
.ask-ai__toast { grid-column: 2; min-height: 1.4em; color: var(--accent); }

/* ---------- Footer ---------- */
.footer { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 14px var(--gutter); }
.footer__links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer__links a:hover { color: var(--accent); }
.footer__meta { color: var(--ink-3); }

/* ---------- Small screens ---------- */
@media (max-width: 860px) {
  :root { --gutter: 16px; --index-left: 0; }
  .card { position: relative; top: auto; left: auto; margin: var(--gutter); width: auto; }
  .topbar { position: static; padding: 0 var(--gutter); mix-blend-mode: normal; color: var(--ink-2); flex-wrap: wrap; }
  .stage { min-height: 0; overflow: visible; padding-bottom: 32px; }
  .stage__bg { position: relative; height: 46vw; min-height: 200px; margin: 16px var(--gutter) 0; }
  .stage__visual { left: 0; width: 100%; top: 0; transform: none; }
  .stage__visual figcaption { display: none; }
  .stage__intro { position: static; padding: 24px var(--gutter) 0; }
  .page-home.has-hover .stage__intro { opacity: 1; }
  .index { position: static; transform: none; padding: 32px var(--gutter) 0; }
  .index__head { flex-direction: column; align-items: flex-start; }
  .row, .rows--plain .row { grid-template-columns: minmax(0, 1fr) auto; padding: 8px 0; border-top: 1px solid var(--rule); }
  .row__cat, .row__origin { display: none; }
  .rows--plain .row--post .row__year { order: 2; text-align: right; }
  .row--static { grid-template-columns: 1fr; gap: 4px; }
  .statement, .list-section, .ask-ai { grid-template-columns: 1fr; }
  .statement > *, .list-section > *, .ask-ai > * { grid-column: 1 !important; }
  .statement, .list-section, .page, .case { padding: 56px var(--gutter); }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ask-ai__buttons { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .case__body section { grid-template-columns: 1fr; gap: 6px; }
  .case__figure { padding: 14px; margin: 32px 0; }
  .c-big { font-size: 96px; }
}

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

/* ---------- Chart motion: plays when a stage visual turns on (.is-on) or a case figure scrolls in (.is-in) ---------- */
.c-bar { transform-box: fill-box; transform-origin: left center; }
.c-pop { transform-box: fill-box; transform-origin: center; }
.c-todo { opacity: 0.6; }
.c-progress { stroke: var(--accent); }
:is(.is-on, .is-in) .c-bar { animation: c-grow 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both; animation-delay: calc(var(--i, 0) * 90ms); }
:is(.is-on, .is-in) .c-value { animation: c-fade 0.5s ease both; animation-delay: calc(0.45s + var(--i, 0) * 90ms); }
:is(.is-on, .is-in) .c-pop { animation: c-pop 0.5s cubic-bezier(0.3, 1.4, 0.5, 1) both; animation-delay: calc(var(--i, 0) * 60ms); }
:is(.is-on, .is-in) .c-draw { stroke-dasharray: 1; animation: c-draw 1.3s cubic-bezier(0.6, 0, 0.2, 1) both; }
:is(.is-on, .is-in) .c-rise { animation: c-rise 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes c-grow { from { transform: scaleX(0); } }
@keyframes c-fade { from { opacity: 0; } }
@keyframes c-pop { from { transform: scale(0); opacity: 0; } }
@keyframes c-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes c-rise { from { opacity: 0; transform: translateY(24px); } }

/* Page entrance */
main > * { animation: page-in 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes page-in { from { opacity: 0; transform: translateY(10px); } }
