/* ============================================================
   chrisswen.com v2 — design system
   Palette: "warehouse at night" — deep steel slate, safety amber
   accent, semantic green/red reserved for status only.
   Type: Space Grotesk (display) / Inter (body) / JetBrains Mono (data)
   ============================================================ */

:root {
  /* palette tokens */
  --steel-950: #0d1117;
  --steel-900: #12171f;
  --steel-850: #171e28;
  --steel-800: #1d2530;
  --steel-700: #2a3442;
  --steel-500: #55627a;
  --steel-300: #9aa7bd;
  --steel-100: #e8ecf3;
  --amber: #ffb224;
  --amber-deep: #d98f00;
  --ok: #35c26e;
  --warn: #ffb224;
  --bad: #ff5d5d;
  --info: #5aa9ff;

  /* semantic (dark default) */
  --bg: var(--steel-950);
  --bg-2: var(--steel-900);
  --panel: var(--steel-850);
  --panel-2: var(--steel-800);
  --line: #28313f;
  --ink: var(--steel-100);
  --muted: var(--steel-300);
  --faint: var(--steel-500);
  --accent: var(--amber);
  --accent-ink: #171001;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --wrap: 1080px;
}

html[data-theme="light"] {
  --bg: #f4f5f2;
  --bg-2: #eceee9;
  --panel: #ffffff;
  --panel-2: #f6f7f4;
  --line: #dcdfd7;
  --ink: #1a2027;
  --muted: #4c5866;
  --faint: #8a94a3;
  --accent: #c07d00;
  --accent-ink: #ffffff;
  --shadow: 0 8px 24px rgba(25,32,42,.10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; letter-spacing: -0.01em; margin: 0 0 .5em; }
h1 { font-size: clamp(2rem, 5.5vw, 3.4rem); font-weight: 700; }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 600; }
h3 { font-size: 1.15rem; font-weight: 600; }
p  { margin: 0 0 1em; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }
.small { font-size: .85rem; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
section { padding: 56px 0; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav .wrap { display: flex; align-items: center; gap: 18px; height: 60px; }
.brand { font-family: var(--font-mono); font-weight: 700; color: var(--ink); font-size: .95rem; }
.brand b { color: var(--accent); }
.nav-links { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav-links a {
  color: var(--muted); padding: 7px 12px; border-radius: 8px; font-size: .92rem; font-weight: 500;
}
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--ink); background: var(--panel-2); text-decoration: none; }
.theme-btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 1rem; line-height: 1;
}
.theme-btn:hover { border-color: var(--accent); }

/* ---------- signature: conveyor lane ---------- */
.lane { position: relative; height: 14px; overflow: hidden; margin: 26px 0; }
.lane::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px;
  background: repeating-linear-gradient(90deg, var(--line) 0 14px, transparent 14px 24px);
}
.lane .pkg {
  position: absolute; top: 2px; width: 10px; height: 10px; border-radius: 2px;
  background: var(--accent); opacity: .9;
  animation: convey 9s linear infinite;
}
.lane .pkg:nth-child(2) { animation-delay: -3s; background: var(--info); }
.lane .pkg:nth-child(3) { animation-delay: -6s; background: var(--ok); }
@keyframes convey { from { left: -3%; } to { left: 103%; } }
@media (prefers-reduced-motion: reduce) {
  .lane .pkg { animation: none; left: 20%; }
  .lane .pkg:nth-child(2) { left: 50%; }
  .lane .pkg:nth-child(3) { left: 80%; }
}

/* ---------- hero ---------- */
.hero { padding: 72px 0 30px; }
.hero .eyebrow {
  font-family: var(--font-mono); color: var(--accent); font-size: .8rem;
  text-transform: uppercase; letter-spacing: .14em; margin-bottom: 14px;
}
.hero .lede { font-size: 1.15rem; color: var(--muted); max-width: 62ch; }
.hero-grid { display: grid; grid-template-columns: 1fr auto; gap: 36px; align-items: center; }
.hero-photo img {
  width: 168px; height: 168px; object-fit: cover; border-radius: 50%;
  border: 3px solid var(--line); box-shadow: var(--shadow);
}
@media (max-width: 720px) { .hero-grid { grid-template-columns: 1fr; } .hero-photo { order: -1; } }

.btn {
  display: inline-block; background: var(--accent); color: var(--accent-ink);
  font-weight: 600; padding: 10px 18px; border-radius: 10px; border: none; cursor: pointer;
  font-family: var(--font-body); font-size: .95rem;
}
.btn:hover { background: var(--amber-deep); color: #fff; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--accent); background: var(--panel-2); }
.btn.sm { padding: 6px 12px; font-size: .85rem; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- cards ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 22px; display: flex; flex-direction: column; gap: 10px;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.card h3 a { color: var(--ink); }
.card .desc { color: var(--muted); font-size: .93rem; flex: 1; }
.card .impact { font-family: var(--font-mono); font-size: .8rem; color: var(--accent); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-family: var(--font-mono); font-size: .7rem; color: var(--muted);
  border: 1px solid var(--line); background: var(--panel-2);
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: .72rem; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); background: var(--panel-2);
}
.badge.synth { border-color: color-mix(in srgb, var(--info) 50%, var(--line)); color: var(--info); }
.badge.win { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); color: var(--ok); }

/* ---------- metric strip (case studies) ---------- */
.metric-strip { display: flex; flex-wrap: wrap; gap: 12px; margin: 18px 0 6px; }
.metric {
  border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius);
  padding: 10px 16px;
}
.metric .n { font-family: var(--font-mono); font-weight: 700; color: var(--accent); font-size: 1.15rem; }
.metric .l { color: var(--muted); font-size: .75rem; }

/* ---------- demo frame ---------- */
.demo-frame {
  border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden;
  background: var(--panel); box-shadow: var(--shadow); margin: 26px 0;
}
.demo-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel-2);
}
.demo-bar .dots { display: flex; gap: 5px; }
.demo-bar .dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); display: block; }
.demo-bar .title { font-family: var(--font-mono); font-size: .78rem; color: var(--muted); }
.demo-bar .spacer { margin-left: auto; }
.demo-body { padding: 18px; min-height: 320px; }
.demo-skeleton { color: var(--faint); font-family: var(--font-mono); font-size: .85rem; padding: 40px; text-align: center; }
.demo-body.shot { padding: 0; min-height: 0; }
.demo-body.shot img { display: block; width: 100%; height: auto; }

/* ---------- demo widgets ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar label { font-size: .8rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
select, input[type="text"], input[type="search"], input[type="email"] {
  background: var(--bg-2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; padding: 7px 10px; font-family: var(--font-body); font-size: .88rem;
}
input[type="checkbox"] { accent-color: var(--accent); }

.dtable { width: 100%; border-collapse: collapse; font-size: .86rem; }
.dtable th {
  text-align: left; font-family: var(--font-mono); font-size: .68rem; text-transform: uppercase;
  letter-spacing: .08em; color: var(--faint); padding: 8px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap; cursor: pointer; user-select: none;
}
.dtable td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.dtable tr:hover td { background: color-mix(in srgb, var(--panel-2) 60%, transparent); }
.table-scroll { overflow-x: auto; }

.pill { font-family: var(--font-mono); font-size: .7rem; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.pill.ok   { background: color-mix(in srgb, var(--ok) 16%, transparent);   color: var(--ok); }
.pill.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.pill.bad  { background: color-mix(in srgb, var(--bad) 16%, transparent);  color: var(--bad); }
.pill.info { background: color-mix(in srgb, var(--info) 16%, transparent); color: var(--info); }
.pill.dim  { background: var(--panel-2); color: var(--faint); }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; font-family: var(--font-mono); font-size: .68rem; font-weight: 700;
  color: #fff; flex: none;
}

.statsband { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.statsband .metric { padding: 8px 14px; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button {
  background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted);
  font-family: var(--font-body); font-weight: 600; font-size: .88rem; padding: 8px 14px; cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

.progress-log { font-family: var(--font-mono); font-size: .8rem; color: var(--muted); }
.progress-log div::before { content: "› "; color: var(--accent); }

.gauge-wrap { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }

.notice {
  border: 1px dashed color-mix(in srgb, var(--info) 45%, var(--line));
  background: color-mix(in srgb, var(--info) 6%, transparent);
  color: var(--muted); border-radius: var(--radius); padding: 10px 14px; font-size: .82rem;
}

/* ---------- case-study prose ---------- */
.prose { max-width: 760px; }
.prose h2 { margin-top: 2em; }
.prose ul { padding-left: 1.2em; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 16px; font-size: .9rem; }
.kv dt { color: var(--faint); font-family: var(--font-mono); font-size: .78rem; }
.kv dd { margin: 0; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline li { position: relative; padding: 0 0 26px 34px; }
.timeline li::before {
  content: ""; position: absolute; left: 2px; top: 6px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--bg); border: 3px solid var(--accent);
}
.timeline .when { font-family: var(--font-mono); font-size: .75rem; color: var(--faint); }
.timeline h3 { margin: 2px 0 4px; }
.timeline details summary { cursor: pointer; color: var(--accent); font-size: .85rem; }
.timeline details { margin-top: 6px; }

/* ---------- footer ---------- */
footer { border-top: 1px solid var(--line); padding: 36px 0 48px; margin-top: 40px; color: var(--muted); font-size: .9rem; }
footer .links { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- misc ---------- */
.pagenav { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; }
hr.rule { border: none; border-top: 1px solid var(--line); margin: 32px 0; }

/* comparison slider (HDSprites) */
.cmp { position: relative; user-select: none; touch-action: none; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.cmp canvas { display: block; width: 100%; image-rendering: pixelated; }
.cmp .top { position: absolute; inset: 0; overflow: hidden; }
.cmp .divider {
  position: absolute; top: 0; bottom: 0; width: 3px; background: var(--accent); cursor: ew-resize;
}
.cmp .divider::after {
  content: "◂ ▸"; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: var(--accent); color: var(--accent-ink); font-size: .7rem; font-family: var(--font-mono);
  padding: 4px 7px; border-radius: 999px; white-space: nowrap;
}
.cmp .lbl {
  position: absolute; top: 10px; font-family: var(--font-mono); font-size: .68rem;
  background: rgba(0,0,0,.55); color: #fff; padding: 3px 8px; border-radius: 999px;
}

@media (max-width: 640px) {
  .nav .wrap { gap: 8px; padding: 0 12px; }
  .brand { font-size: .85rem; }
  .nav-links { gap: 0; }
  .nav-links a { padding: 6px 7px; font-size: .82rem; }
  .theme-btn { flex-shrink: 0; width: 30px; height: 30px; }
  section { padding: 40px 0; }
  .demo-body { padding: 12px; }
}
