/* ==========================================================================
   Personal site — terminal theme
   Colours are tokens on :root. Dark is the default; light via toggle or OS.
   ========================================================================== */

:root {
  --bg: #0b0f14;
  --bg-soft: #11161d;
  --bg-elev: #161c24;
  --border: #232c37;
  --text: #d5dde6;
  --text-dim: #8a96a3;
  --accent: #4ade80;      /* terminal green */
  --accent-2: #fbbf24;    /* amber */
  --accent-3: #60a5fa;    /* blue */
  --danger: #f87171;
  --selection: rgba(74, 222, 128, 0.25);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --max: 960px;
  --radius: 10px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f7f8fa;
    --bg-soft: #eef1f4;
    --bg-elev: #ffffff;
    --border: #d9dee4;
    --text: #1d2530;
    --text-dim: #5b6773;
    --accent: #15803d;
    --accent-2: #b45309;
    --accent-3: #1d4ed8;
    --danger: #b91c1c;
    --selection: rgba(21, 128, 61, 0.18);
    --shadow: 0 10px 30px rgba(20, 30, 40, 0.08);
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --bg: #f7f8fa;
  --bg-soft: #eef1f4;
  --bg-elev: #ffffff;
  --border: #d9dee4;
  --text: #1d2530;
  --text-dim: #5b6773;
  --accent: #15803d;
  --accent-2: #b45309;
  --accent-3: #1d4ed8;
  --danger: #b91c1c;
  --selection: rgba(21, 128, 61, 0.18);
  --shadow: 0 10px 30px rgba(20, 30, 40, 0.08);
  color-scheme: light;
}

/* ---------- Base ---------- */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--selection); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

img { max-width: 100%; display: block; }

h1, h2, h3 { font-family: var(--mono); line-height: 1.25; margin: 0 0 0.5em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 1em; }

code, kbd, pre { font-family: var(--mono); font-size: 0.9em; }

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

.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 16px; }

.skip-link {
  position: absolute; left: -999px; top: 8px;
  background: var(--accent); color: var(--bg); padding: 6px 12px; border-radius: 6px; z-index: 100;
}
.skip-link:focus { left: 16px; }

/* ---------- Header / nav ---------- */

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

.nav {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 60px; font-family: var(--mono); font-size: 0.9rem;
}

.logo { color: var(--text); font-weight: 700; white-space: nowrap; }
.logo .prompt { color: var(--accent); }
.logo:hover { text-decoration: none; }

.nav-links { display: flex; align-items: center; gap: 4px; list-style: none; margin: 0; padding: 0; }
.nav-links a {
  color: var(--text-dim); padding: 6px 10px; border-radius: 6px; display: inline-block;
}
.nav-links a:hover, .nav-links a[aria-current="page"] {
  color: var(--text); background: var(--bg-soft); text-decoration: none;
}
.nav-links a[aria-current="page"]::before { content: "./"; color: var(--accent); }

.icon-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  width: 36px; height: 36px; border-radius: 8px; cursor: pointer;
  display: inline-grid; place-items: center; font-family: var(--mono); font-size: 0.95rem;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-dim); }

.menu-toggle { display: none; }

@media (max-width: 680px) {
  .menu-toggle { display: inline-grid; }
  .nav-links {
    position: absolute; top: 60px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--bg); border-bottom: 1px solid var(--border);
    padding: 8px 16px 16px; display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 10px 8px; width: 100%; }
}

/* ---------- Hero ---------- */

.hero { padding: 72px 0 48px; }

.terminal {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.terminal-bar {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); background: var(--bg-soft);
  font-family: var(--mono); font-size: 0.78rem; color: var(--text-dim);
}
.dot { width: 11px; height: 11px; border-radius: 50%; background: var(--border); }
.dot.r { background: #ff5f57; } .dot.y { background: #febc2e; } .dot.g { background: #28c840; }
.terminal-title { margin-left: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.terminal-body { padding: 22px 22px 26px; font-family: var(--mono); font-size: 0.95rem; }
.terminal-body .line { margin: 0 0 6px; }
.terminal-body .prompt { color: var(--accent); user-select: none; }
.terminal-body .cmd { color: var(--text); }
.terminal-body .out { color: var(--text-dim); margin: 0 0 16px; }

.hero h1 {
  font-size: clamp(1.9rem, 6vw, 3rem); margin: 4px 0 8px; color: var(--text);
  letter-spacing: -0.02em;
}
.hero .role { color: var(--accent-2); font-size: 1.05rem; margin: 0 0 16px; }
.hero .tagline { font-family: var(--sans); color: var(--text-dim); max-width: 60ch; font-size: 1.05rem; }

.cursor {
  display: inline-block; width: 0.6em; height: 1.1em; background: var(--accent);
  vertical-align: text-bottom; margin-left: 2px; animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 0.88rem; padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--border); color: var(--text); background: var(--bg-soft);
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 700; }
.btn.primary:hover { filter: brightness(1.08); }

/* ---------- Sections ---------- */

section { padding: 40px 0; }

.section-title {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 22px;
  font-size: 1.25rem;
}
.section-title .hash { color: var(--accent); }
.section-title::after {
  content: ""; flex: 1; height: 1px; background: var(--border); transform: translateY(-4px);
}

.about-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 32px; }
@media (max-width: 760px) { .about-grid { grid-template-columns: 1fr; } }

.facts {
  font-family: var(--mono); font-size: 0.85rem; background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
  margin: 0; overflow-x: auto;
}
.facts .k { color: var(--accent-3); }
.facts .s { color: var(--accent-2); }
.facts .c { color: var(--text-dim); }

/* Skills */
.tags { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.tag {
  font-family: var(--mono); font-size: 0.8rem; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-dim); background: var(--bg-soft);
}

.skill-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.skill-group h3 { font-size: 0.9rem; color: var(--text-dim); font-weight: 500; }
.skill-group h3::before { content: "> "; color: var(--accent); }

/* Experience as git log */
.log { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); }
.log > li { position: relative; padding: 0 0 26px 22px; }
.log > li::before {
  content: ""; position: absolute; left: -7px; top: 6px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--bg); border: 2px solid var(--accent);
}
.log .meta { font-family: var(--mono); font-size: 0.8rem; color: var(--text-dim); }
.log .hash { color: var(--accent-2); margin-right: 8px; }
.log h3 { margin: 4px 0 6px; }
.log h3 .at { color: var(--text-dim); font-weight: 400; }
.log p { color: var(--text-dim); margin: 0 0 8px; }
.log ul { margin: 0; padding-left: 18px; color: var(--text-dim); }
.log ul li { margin-bottom: 4px; }
section[id] { scroll-margin-top: 64px; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card .perm { font-family: var(--mono); font-size: 0.75rem; color: var(--text-dim); }
.card h3 { margin: 0; }
.card h3 a { color: var(--text); }
.card p { color: var(--text-dim); margin: 0; font-size: 0.95rem; flex: 1; }
.card .tags { margin-top: 4px; }
.card .tag { font-size: 0.72rem; padding: 2px 8px; }

/* Post list */
.posts { list-style: none; margin: 0; padding: 0; }
.posts li {
  display: grid; grid-template-columns: 110px 1fr; gap: 16px;
  padding: 14px 0; border-bottom: 1px dashed var(--border);
}
.posts li:last-child { border-bottom: none; }
.posts time { font-family: var(--mono); font-size: 0.82rem; color: var(--text-dim); padding-top: 3px; }
.posts a.title { color: var(--text); font-weight: 600; }
.posts a.title:hover { color: var(--accent); }
.posts p { margin: 4px 0 0; color: var(--text-dim); font-size: 0.95rem; }
@media (max-width: 560px) { .posts li { grid-template-columns: 1fr; gap: 2px; } }

.more { font-family: var(--mono); font-size: 0.88rem; margin-top: 16px; display: inline-block; }

/* Contact */
.contact-box {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; font-family: var(--mono);
}
.contact-box p { font-family: var(--sans); color: var(--text-dim); }
.links { display: flex; flex-wrap: wrap; gap: 10px; list-style: none; padding: 0; margin: 16px 0 0; }

/* Hero stats */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  list-style: none; padding: 18px 0 0; margin: 24px 0 0; border-top: 1px dashed var(--border);
}
.stats li { display: flex; flex-direction: column; }
.stats strong { color: var(--accent); font-size: 1.4rem; }
.stats span { color: var(--text-dim); font-size: 0.75rem; }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.nav-right { display: flex; align-items: center; gap: 8px; }
.hint { font-size: 0.8rem; color: var(--text-dim); font-weight: 400; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }
.sub { font-size: 1rem; margin-bottom: 14px; }
.sub .hash { color: var(--accent); }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 10px 0; border-bottom: 1px dashed var(--border); display: flex; flex-direction: column; gap: 2px; }
.plain li:last-child { border-bottom: none; }
.plain strong { font-weight: 600; font-size: 0.98rem; }
.dim { color: var(--text-dim); font-size: 0.88rem; }
.dim:first-of-type { font-family: var(--mono); font-size: 0.8rem; }

/* ---------- Blog / article ---------- */

.page-head { padding: 56px 0 16px; }
.page-head h1 { font-size: clamp(1.7rem, 5vw, 2.4rem); }
.page-head .prompt { color: var(--accent); }
.page-head p { color: var(--text-dim); }

.filter {
  width: 100%; max-width: 420px; padding: 10px 14px; margin: 8px 0 24px;
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; font-family: var(--mono); font-size: 0.9rem;
}
.filter:focus { outline: none; border-color: var(--accent); }

.article { max-width: 70ch; padding: 48px 16px 24px; margin: 0 auto; }
.article .meta { font-family: var(--mono); font-size: 0.82rem; color: var(--text-dim); margin-bottom: 28px; }
.article h1 { font-size: clamp(1.7rem, 5vw, 2.3rem); margin-bottom: 10px; }
.article h2 { margin-top: 2em; }
.article h2::before { content: "## "; color: var(--accent); }
.article h3::before { content: "### "; color: var(--accent); }
.article p, .article li { color: var(--text); }
.article blockquote {
  margin: 1.4em 0; padding: 4px 18px; border-left: 3px solid var(--accent-2);
  color: var(--text-dim); background: var(--bg-soft); border-radius: 0 8px 8px 0;
}
.article :not(pre) > code {
  background: var(--bg-soft); border: 1px solid var(--border); padding: 1px 6px; border-radius: 5px;
}
.article pre {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; overflow-x: auto; line-height: 1.5;
}
.back { font-family: var(--mono); font-size: 0.88rem; }

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border); margin-top: 48px; padding: 24px 0 40px;
  font-family: var(--mono); font-size: 0.8rem; color: var(--text-dim);
}
.site-footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }

/* ---------- Motion ---------- */

.reveal { opacity: 0; transform: translateY(12px); transition: opacity .5s ease, transform .5s ease; }
.reveal.visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .cursor { animation: none; }
  .card, .card:hover { transition: none; transform: none; }
}

/* ---------- Long-form guide ---------- */

.article-wide { max-width: 78ch; }
.article h2[id], .article h3[id] { scroll-margin-top: 72px; }
.article h4 { font-family: var(--mono); font-size: 0.95rem; margin: 0 0 8px; }

.toc {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; margin: 24px 0 8px; font-size: 0.95rem;
}
.toc-title { font-family: var(--mono); color: var(--text-dim); margin: 0 0 6px; font-size: 0.8rem; }
.toc-title::before { content: "$ cat "; color: var(--accent); }
.toc ol { margin: 0; padding-left: 22px; }
.toc li { margin: 2px 0; }

.callout {
  border: 1px solid var(--border); border-left: 3px solid var(--accent-3);
  background: var(--bg-soft); border-radius: 0 8px 8px 0; padding: 10px 14px; margin: 16px 0;
}
.callout p { margin: 0; }
.callout-warn { border-left-color: var(--accent-2); }

/* tables */
.table-wrap { overflow-x: auto; margin: 16px 0; border: 1px solid var(--border); border-radius: var(--radius); }
.article table { border-collapse: collapse; width: 100%; font-size: 0.9rem; min-width: 560px; }
.article th, .article td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.article th { font-family: var(--mono); font-size: 0.78rem; color: var(--text-dim); background: var(--bg-soft); }
.article tr:last-child td { border-bottom: none; }

/* tabs (all panels show without JS) */
.tabs { border: 1px solid var(--border); border-radius: var(--radius); margin: 18px 0; background: var(--bg-elev); overflow: hidden; }
.tab-list { display: none; }
.tabs.js-tabs .tab-list {
  display: flex; gap: 2px; overflow-x: auto; background: var(--bg-soft);
  border-bottom: 1px solid var(--border); padding: 6px 6px 0;
}
.tab-list button {
  font-family: var(--mono); font-size: 0.82rem; color: var(--text-dim); background: transparent;
  border: 1px solid transparent; border-bottom: none; border-radius: 8px 8px 0 0;
  padding: 8px 12px; cursor: pointer; white-space: nowrap;
}
.tab-list button:hover { color: var(--text); }
.tab-list button[aria-selected="true"] {
  color: var(--text); background: var(--bg-elev); border-color: var(--border);
  margin-bottom: -1px; box-shadow: inset 0 2px 0 var(--accent);
}
.tab-panel { padding: 4px 18px 8px; }
.tabs:not(.js-tabs) .tab-panel + .tab-panel { border-top: 1px dashed var(--border); }
.tabs.js-tabs .tab-fallback { display: none; }
.tab-panel pre { background: var(--bg); }

/* code copy button */
.code-wrap { position: relative; }
.copy-btn {
  position: absolute; top: 8px; right: 8px; font-family: var(--mono); font-size: 0.72rem;
  background: var(--bg-soft); color: var(--text-dim); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 8px; cursor: pointer; opacity: 0.85;
}
.copy-btn:hover { color: var(--text); opacity: 1; }

/* architecture diagram */
.arch { margin: 20px 0; }
.arch svg { width: 100%; height: auto; display: block; }
.arch figcaption { color: var(--text-dim); font-size: 0.9rem; margin-top: 8px; }
.arch-boundary { fill: none; stroke: var(--border); stroke-width: 1.5; stroke-dasharray: 6 5; }
.arch-boundary-warn { stroke: var(--accent-2); }
.arch-box { fill: var(--bg-elev); stroke: var(--border); stroke-width: 1.5; }
.arch-box-accent { stroke: var(--accent); }
.arch-label { fill: var(--text-dim); font-family: var(--mono); font-size: 13px; }
.arch-title { fill: var(--text); font-family: var(--mono); font-size: 15px; font-weight: 700; }
.arch-text { fill: var(--text-dim); font-family: var(--sans); font-size: 13.5px; }
.arch-small { fill: var(--text-dim); font-family: var(--mono); font-size: 11.5px; }
.arch-warn-text { fill: var(--accent-2); }
.arch-line { stroke: var(--text-dim); stroke-width: 1.5; }
.arch-line-warn { stroke: var(--accent-2); }
.arch-arrowhead { fill: var(--text-dim); }

/* chat examples */
.chat { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.chat p { margin: 0; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); font-size: 0.95rem; }
.chat span { display: block; font-family: var(--mono); font-size: 0.72rem; color: var(--text-dim); margin-bottom: 4px; }
.chat-you { background: var(--bg-soft); }
.chat-you span::before { content: "> "; color: var(--accent); }
.chat-agent { background: var(--bg-elev); border-left: 3px solid var(--accent-3) !important; }

/* faq + checklist */
.faq dt { font-weight: 600; margin-top: 14px; }
.faq dd { margin: 4px 0 0; color: var(--text-dim); }
.checklist { list-style: none; padding-left: 0; }
.checklist li { padding-left: 28px; position: relative; margin: 6px 0; }
.checklist li::before { content: "[ ]"; position: absolute; left: 0; font-family: var(--mono); color: var(--accent); font-size: 0.85rem; top: 2px; }
@media (max-width: 640px) {
  .arch .arch-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
  .arch svg { min-width: 640px; }
  .arch figcaption::before { content: "← swipe to see the whole diagram → "; display: block; font-family: var(--mono); font-size: 0.75rem; margin-bottom: 4px; }
}
