:root {
  --bg: #f6f4ee;
  --surface: #ffffff;
  --surface-2: #eeeae0;
  --ink: #1a1e29;
  --muted: #5a5f6e;
  --line: #e1ddd0;
  --accent: #2c56d8;
  --accent-ink: #ffffff;
  --code-bg: #1a1e29;
  --code-ink: #e7e4dc;
  --code-dim: #8a8f9e;
  --code-str: #f2b880;
  --code-key: #8fb4ff;
  --code-num: #9ee0b5;
  --snow: #2f78b8;
  --chat: #c4541f;
  --other: #6d4fc9;
  --art-s: 72%;
  --art-l: 90%;
  --art-ink-l: 30%;
  --shadow: 0 1px 2px rgba(20, 24, 40, 0.05), 0 6px 20px rgba(20, 24, 40, 0.06);
  --shadow-hover: 0 2px 4px rgba(20, 24, 40, 0.08), 0 14px 32px rgba(20, 24, 40, 0.12);
  --radius: 16px;
  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111319;
    --surface: #191c25;
    --surface-2: #222632;
    --ink: #ecebe6;
    --muted: #a2a6b3;
    --line: #2b2f3b;
    --accent: #86a5ff;
    --accent-ink: #0f1320;
    --code-bg: #0b0d12;
    --snow: #7db7ea;
    --chat: #f19364;
    --other: #b39dff;
    --art-s: 32%;
    --art-l: 22%;
    --art-ink-l: 82%;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 10px 30px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

a { color: var(--accent); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- header / footer */

.site-header {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}

.nav { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; }

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink); text-decoration: none;
  font: 700 1.15rem/1 var(--display); letter-spacing: -0.01em;
}

.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--ink); color: var(--bg);
  font: 600 0.78rem/1 var(--mono);
}

.nav-links { display: flex; gap: 4px; }

.nav-links a {
  color: var(--muted); text-decoration: none; font-weight: 500;
  padding: 8px 12px; border-radius: 999px;
}

.nav-links a:hover { color: var(--ink); background: var(--surface-2); }
.nav-links a[aria-current="page"] { color: var(--ink); background: var(--surface-2); }

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 0.9rem;
  padding: 28px 0; margin-top: 72px;
}

.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }

/* ---------- type */

.eyebrow {
  margin: 0 0 12px;
  font: 500 0.8rem/1.2 var(--mono);
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted);
}

h1, h2, h3 { font-family: var(--display); letter-spacing: -0.02em; line-height: 1.1; margin: 0; }

h1 { font-size: clamp(2.4rem, 6vw, 4.2rem); font-weight: 800; }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.2rem); font-weight: 700; }
h3 { font-size: 1.3rem; font-weight: 700; }

.lede { font-size: 1.15rem; color: var(--muted); max-width: 38rem; margin: 18px 0 0; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 600; text-decoration: none;
  padding: 13px 22px; border-radius: 999px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-hover); }

/* ---------- home */

.hero {
  display: grid; gap: 48px; align-items: center;
  padding: 72px 0 40px;
}

@media (min-width: 900px) {
  .hero { grid-template-columns: 1.1fr 1fr; padding: 96px 0 56px; }
}

.cta-row { margin-top: 32px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.cta-note { color: var(--muted); font-size: 0.95rem; }

.code-card {
  margin: 0; min-width: 0;
  background: var(--code-bg); color: var(--code-ink);
  border-radius: var(--radius); box-shadow: var(--shadow-hover);
  overflow: hidden;
  transform: rotate(1deg);
}

.code-bar {
  display: flex; align-items: center; gap: 7px;
  padding: 12px 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.code-bar span { width: 11px; height: 11px; border-radius: 50%; background: #3a3f4d; }
.code-bar code { margin-left: 8px; font: 0.8rem var(--mono); color: var(--code-dim); }

.code-card pre {
  margin: 0; padding: 20px 22px 24px; overflow-x: auto;
  font: 0.92rem/1.75 var(--mono);
}

.c-com { color: var(--code-dim); font-style: italic; }
.c-str { color: var(--code-str); }
.c-key { color: var(--code-key); }
.c-num { color: var(--code-num); }

.path { padding-top: 40px; }
.path > p { color: var(--muted); max-width: 40rem; }

.steps {
  list-style: none; margin: 28px 0 0; padding: 0;
  display: grid; gap: 16px;
}

@media (min-width: 820px) { .steps { grid-template-columns: repeat(3, 1fr); } }

.step {
  --tone: var(--accent);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px;
  display: flex; flex-direction: column; gap: 10px;
  position: relative; overflow: hidden;
}

.step::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--tone);
}

.step.snow { --tone: var(--snow); }
.step.chat { --tone: var(--chat); }
.step.web { --tone: var(--other); }

.step-top { display: flex; align-items: center; justify-content: space-between; }
.step-emoji { font-size: 1.8rem; line-height: 1; }
.step-unit { font: 500 0.78rem/1 var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--tone); }
.step p { margin: 0; color: var(--muted); }
.step a { margin-top: auto; padding-top: 8px; font-weight: 600; color: var(--tone); text-decoration: none; }
.step a:hover { text-decoration: underline; }

/* ---------- projects page */

.page-head { padding: 64px 0 8px; }

.controls {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  margin: 32px 0 8px; padding: 12px 0;
  position: sticky; top: 64px; z-index: 5;
  background: var(--bg);
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  font: inherit; font-weight: 600; font-size: 0.95rem;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 14px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}

.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip .count { font: 500 0.8rem var(--mono); opacity: 0.7; }

.search input {
  font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 16px 9px 38px; width: min(320px, 100%);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 3.5 3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 14px center;
}

.search { flex: 1 1 220px; display: flex; justify-content: flex-end; }
.search input:focus { outline: 3px solid var(--accent); outline-offset: 1px; }

@media (max-width: 640px) {
  .controls { position: static; }
  .search { justify-content: stretch; }
  .search input { width: 100%; }
}

.category { margin-top: 40px; }

.category-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.category-head .tag {
  font: 500 0.75rem/1 var(--mono); text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--tone); border: 1px solid currentColor; border-radius: 999px; padding: 5px 9px;
}
.category-head .n { color: var(--muted); font: 0.9rem var(--mono); }
.category > p { color: var(--muted); margin: 8px 0 0; max-width: 42rem; }

.category.snowman, .project-page.snowman { --tone: var(--snow); }
.category.chatbot, .project-page.chatbot { --tone: var(--chat); }
.category.other, .project-page.other { --tone: var(--other); }

.grid {
  display: grid; gap: 16px; margin-top: 20px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

.card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); text-decoration: none; overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: transparent; }
.card:focus-visible { outline-offset: 2px; border-radius: var(--radius); }

.card-art {
  position: relative; aspect-ratio: 16 / 10;
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 18% 22%, hsl(var(--h) var(--art-s) calc(var(--art-l) + 4%)) 0 18%, transparent 19%),
    radial-gradient(circle at 86% 88%, hsl(calc(var(--h) + 18) var(--art-s) calc(var(--art-l) - 5%)) 0 24%, transparent 25%),
    hsl(var(--h) var(--art-s) var(--art-l));
  color: hsl(var(--h) 45% var(--art-ink-l));
}

.card-initials { font: 800 2.6rem/1 var(--display); letter-spacing: -0.03em; }
.card-emoji { position: absolute; top: 10px; right: 12px; font-size: 1.3rem; }

.card-body { padding: 14px 16px 4px; flex: 1; }
.card-body h3 { font-size: 1.1rem; }
.card-body p { margin: 4px 0 0; color: var(--muted); font-size: 0.93rem; line-height: 1.4; }

.card-open {
  padding: 10px 16px 14px; font-weight: 600; font-size: 0.9rem; color: var(--tone);
}

.card:hover .card-open { text-decoration: underline; }

.empty {
  margin-top: 40px; padding: 48px 24px; text-align: center;
  border: 1.5px dashed var(--line); border-radius: var(--radius); color: var(--muted);
}

.empty .big { font-size: 2.4rem; line-height: 1; display: block; margin-bottom: 12px; }
.empty strong { display: block; color: var(--ink); font: 700 1.25rem/1.3 var(--display); margin-bottom: 4px; }

/* ---------- project page */

.project-page { max-width: 1000px; }

.crumbs { padding-top: 32px; font-size: 0.92rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }

.project-head { padding: 28px 0 8px; }
.project-head h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
.project-head .eyebrow { color: var(--tone); }
.byline { margin: 10px 0 0; font: 600 1.1rem/1.3 var(--display); }
.project-head .btn { background: var(--tone); }
.project-head .lede { max-width: 44rem; }

.stage { margin-top: 56px; }

.stage-label { display: flex; gap: 16px; align-items: flex-start; }
.stage-label h2 { font-size: 1.6rem; }
.stage-label p { margin: 6px 0 0; color: var(--muted); }

.stage-n {
  flex: none; display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--tone); color: var(--bg);
  font: 700 1.1rem/1 var(--display);
}

.stage-arrow {
  margin: 40px 0 0 19px; padding: 6px 0 6px 28px;
  border-left: 2px dashed var(--line);
  font: 500 0.85rem var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
}
.stage-arrow span { color: var(--tone); font-size: 1.1rem; margin-right: 6px; }

.skills { list-style: none; padding: 0; margin: 20px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.skills li {
  font: 500 0.85rem/1 var(--mono);
  padding: 7px 11px; border-radius: 999px;
  color: var(--tone); background: color-mix(in srgb, var(--tone) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--tone) 30%, transparent);
}

.code-view {
  position: relative; margin-top: 20px;
  background: var(--code-bg); color: var(--code-ink);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}

.code-scroll { overflow-x: auto; }
.code-view.collapsed .code-scroll { max-height: 560px; overflow-y: hidden; }
.code-view.collapsed::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 140px; pointer-events: none;
  background: linear-gradient(transparent, var(--code-bg) 75%);
}

.code-block {
  margin: 0; padding: 16px 0 20px; width: max-content; min-width: 100%;
  font: 0.85rem/1.7 var(--mono); counter-reset: ln; tab-size: 4;
}

.code-block .l { display: block; white-space: pre; padding-right: 24px; }
.code-block .l::before {
  counter-increment: ln; content: counter(ln);
  display: inline-block; width: 3em; margin-right: 1.4em; text-align: right;
  color: var(--code-dim); opacity: 0.55; user-select: none;
}

.code-block + .code-block, .md-note + .code-block { border-top: 1px solid rgba(255, 255, 255, 0.08); }

.t-com { color: var(--code-dim); font-style: italic; }
.t-str { color: var(--code-str); }
.t-num, .t-const { color: var(--code-num); }
.t-kw { color: #d4a8ff; }
.t-bi { color: var(--code-key); }
.t-fn { color: #7fdccf; }

.md-note {
  padding: 14px 24px; font-size: 0.95rem; color: var(--code-ink);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.code-bar + .code-scroll > .md-note:first-child { border-top: 0; }
.md-note p, .md-note ul, .md-note h4 { margin: 4px 0; }
.md-note h4 { font: 700 1rem var(--display); }
.md-note code { font: 0.9em var(--mono); color: var(--code-str); }

.code-expand {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 1;
  font: 600 0.92rem var(--body); cursor: pointer;
  color: var(--code-bg); background: var(--code-ink);
  border: 0; border-radius: 999px; padding: 9px 18px;
}
.code-view:not(.collapsed) .code-expand { position: static; transform: none; display: block; margin: 0 auto 18px; }

.site-frame {
  margin-top: 20px; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}

.frame-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line);
  font: 0.8rem var(--mono); color: var(--muted);
}
.frame-url {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: var(--surface); border-radius: 999px; padding: 5px 12px;
}
.frame-bar a { flex: none; color: var(--tone); font-weight: 600; text-decoration: none; }
.frame-bar a:hover { text-decoration: underline; }

.site-frame iframe { display: block; width: 100%; height: min(760px, 80vh); border: 0; background: #fff; }

@media (prefers-reduced-motion: reduce) {
  .btn, .card { transition: none; }
  .btn:hover, .card:hover { transform: none; }
}
