/* ─── TOKENS ──────────────────────────────────────────────────── */
:root {
  --bg:        #0c0c0c;
  --bg2:       #141414;
  --bg3:       #1c1c1c;
  --border:    #2a2a2a;
  --muted:     #4a4a4a;
  --subtle:    #666;
  --body:      #c8c8c8;
  --head:      #f0f0f0;
  --accent:    #7fff87;
  --accent2:   #5bc8f5;
  --accent3:   #f5a623;
  --prompt:    #7fff87;
  --cursor-bg: #7fff87;
  --tag-bg:    #1c2e1d;
  --tag-fg:    #7fff87;
  --tag-border:#2d4a2e;

  --font-mono: 'JetBrains Mono', monospace;
  --font-serif: 'Instrument Serif', serif;

  --radius: 3px;
  --transition: 180ms ease;
}

[data-theme="light"] {
  --bg:        #f4f1eb;
  --bg2:       #ece9e2;
  --bg3:       #e2dfd7;
  --border:    #d0ccc3;
  --muted:     #b0aa9e;
  --subtle:    #888;
  --body:      #3a3530;
  --head:      #1a1612;
  --accent:    #2a7a32;
  --accent2:   #1565a8;
  --accent3:   #c47d0a;
  --prompt:    #2a7a32;
  --cursor-bg: #2a7a32;
  --tag-bg:    #dff0e0;
  --tag-fg:    #1e6b26;
  --tag-border:#b8ddb9;
}

/* ─── RESET ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--body);
  line-height: 1.7;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── LAYOUT ──────────────────────────────────────────────────── */
.shell {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

/* ─── TOPBAR ──────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: background var(--transition);
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.prompt-label {
  color: var(--prompt);
  font-weight: 500;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}
.prompt-label:hover { text-decoration: none; }
.prompt-label span { color: var(--accent2); }
.prompt-label .sep { color: var(--muted); }

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
}
.nav a {
  color: var(--subtle);
  font-size: 0.78rem;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
  letter-spacing: 0.04em;
}
.nav a:hover {
  color: var(--head);
  background: var(--bg3);
  text-decoration: none;
}
.nav .sep { color: var(--muted); font-size: 0.7rem; padding: 0 2px; }

/* ─── THEME TOGGLE ────────────────────────────────────────────── */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}
.theme-toggle input { display: none; }
.toggle-track {
  width: 34px; height: 18px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 9px;
  position: relative;
  transition: background var(--transition), border-color var(--transition);
}
.toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 200ms ease, background var(--transition);
}
input:checked ~ .toggle-track .toggle-thumb {
  transform: translateX(16px);
}
.toggle-label {
  font-size: 0.7rem;
  color: var(--subtle);
  letter-spacing: 0.06em;
  width: 22px;
}

/* ─── HERO ────────────────────────────────────────────────────── */
.hero {
  display: flex;
  align-items: flex-start;
  gap: 40px;
  padding: 60px 0 48px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.hero-text {
  flex: 1;
  min-width: 280px;
}
.hero-prompt {
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 10px;
  letter-spacing: 0.04em;
}
.hero-prompt .cmd { color: var(--prompt); }

.ascii-portrait {
  flex-shrink: 0;
  align-self: flex-start;
}
.ascii-portrait-label {
  color: var(--muted);
  font-size: 0.72rem;
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}
.ascii-portrait-label .cmd { color: var(--prompt); }
.ascii-canvas-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 280px;
  max-width: 320px;
  min-height: 200px;
}
.ascii-canvas {
  display: block;
  width: 100%;
  height: auto;
  font-smooth: never;
  -webkit-font-smoothing: none;
  vertical-align: top;
}
.ascii-canvas.loaded { min-height: 140px; }
.ascii-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--font-mono);
  text-align: center;
  line-height: 1.6;
  pointer-events: none;
}
.ascii-canvas-wrap:has(.ascii-canvas.loaded) .ascii-placeholder {
  display: none;
}

.hero-name {
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  color: var(--head);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}
.hero-handle {
  color: var(--accent);
  font-size: 0.8rem;
  margin-bottom: 20px;
  letter-spacing: 0.06em;
}
.hero-bio {
  max-width: 540px;
  color: var(--body);
  font-size: 0.88rem;
  line-height: 1.8;
  margin-bottom: 24px;
}
.hero-bio em {
  font-style: normal;
  color: var(--head);
}
.hero-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.hero-links a {
  font-size: 0.78rem;
  color: var(--subtle);
  letter-spacing: 0.04em;
  transition: color var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}
.hero-links a:hover { color: var(--accent); text-decoration: none; }
.hero-links a::before { content: '→'; color: var(--muted); }

/* ─── CURSOR BLINK ────────────────────────────────────────────── */
.cursor {
  display: inline-block;
  width: 6px;
  height: 1.3em;
  background: var(--cursor-bg);
  vertical-align: text-bottom;
  margin-left: 3px;
  animation: blink 1.1s step-end infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ─── SECTION COMMONS ─────────────────────────────────────────── */
.section {
  padding: 48px 0 0;
}
.section-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 28px;
}
.section-cmd {
  font-size: 0.72rem;
  color: var(--prompt);
  letter-spacing: 0.06em;
  flex-shrink: 0;
}
.section-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  color: var(--head);
  font-weight: 400;
}
.section-divider {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── TAG SYSTEM ──────────────────────────────────────────────── */
.tag {
  display: inline-block;
  font-size: 0.65rem;
  padding: 2px 7px;
  background: var(--tag-bg);
  color: var(--tag-fg);
  border: 1px solid var(--tag-border);
  border-radius: 2px;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: opacity var(--transition), background var(--transition);
  white-space: nowrap;
}
.tag:hover { opacity: 0.75; }
.tag.active { background: var(--accent); color: var(--bg); border-color: var(--accent); }

.tag-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.tag-reset {
  font-size: 0.65rem;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 7px;
  border: 1px solid transparent;
  border-radius: 2px;
  transition: color var(--transition);
}
.tag-reset:hover { color: var(--body); }

/* ─── PROJECT CARDS ───────────────────────────────────────────── */
.project-grid {
  display: grid;
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.project-row {
  background: var(--bg2);
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}
a.project-row {
  color: inherit;
  text-decoration: none;
}
.project-row:last-child { border-bottom: none; }
.project-row:hover { background: var(--bg3); }
.project-row.hidden { display: none; }

.project-name {
  font-size: 0.88rem;
  color: var(--head);
  font-weight: 500;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.project-status {
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  padding: 1px 6px;
  border-radius: 2px;
}
[data-theme="dark"] .status-building {
  color: #5bc8f5;
  background: #0f2535;
  border: 1px solid #1a4a6a;
}
[data-theme="light"] .status-building {
  color: #0e7fa8;
  background: #dceefa;
  border: 1px solid #a8d8f0;
}

[data-theme="dark"] .status-shipped {
  color: #7fff87;
  background: #1a2e1d;
  border: 1px solid #2d4a2e;
}
[data-theme="light"] .status-shipped {
  color: #2a7a32;
  background: #dff0e0;
  border: 1px solid #b8ddb9;
}

[data-theme="dark"] .status-archived {
  color: #e07b54;
  background: #2e1a14;
  border: 1px solid #5a3020;
}
[data-theme="light"] .status-archived {
  color: #b94a2a;
  background: #fae8e2;
  border: 1px solid #e0b0a0;
}

[data-theme="dark"] .status-abandoned {
  color: #666666;
  background: #1c1c1c;
  border: 1px solid #2a2a2a;
}
[data-theme="light"] .status-abandoned {
  color: #888888;
  background: #e2dfd7;
  border: 1px solid #c8c4bc;
}

.project-desc {
  font-size: 0.78rem;
  color: var(--subtle);
  margin-bottom: 8px;
  line-height: 1.6;
}
.project-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.project-meta {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 80px;
}
.project-date { font-size: 0.65rem; color: var(--muted); }

/* ─── BLOG ────────────────────────────────────────────────────── */
.post-list { display: grid; gap: 1px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.post-row {
  background: var(--bg2);
  padding: 14px 18px;
  display: flex;
  color: inherit;
  text-decoration: none;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.post-row:last-child { border-bottom: none; }
.post-row:hover { background: var(--bg3); text-decoration: none; }
.post-row:focus { outline: 1px solid var(--accent); outline-offset: 2px; text-decoration: none; }
.post-row.hidden { display: none; }
.post-left { display: flex; flex-direction: column; gap: 5px; }
.post-title { font-size: 0.88rem; color: var(--head); }
.post-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.post-desc {
  font-size: 0.78rem;
  color: var(--subtle);
  line-height: 1.6;
}
.post-right { text-align: right; flex-shrink: 0; }
.post-date { font-size: 0.65rem; color: var(--muted); white-space: nowrap; }
.post-meta-read { font-size: 0.65rem; color: var(--muted); }

/* ─── INTERESTS ───────────────────────────────────────────────── */
.interest-desc {
  font-size: 0.78rem;
  color: var(--subtle);
  line-height: 1.6;
}

/* ─── INTERESTS (row/list style to match writing/projects) ────── */
.interest-list { display: grid; gap: 1px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.interest-row {
  background: var(--bg2);
  padding: 14px 18px;
  display: flex;
  color: inherit;
  text-decoration: none;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.interest-row:last-child { border-bottom: none; }
.interest-row:hover { background: var(--bg3); text-decoration: none; }
.interest-row:focus { outline: 1px solid var(--accent); outline-offset: 2px; text-decoration: none; }
.interest-left { display: flex; flex-direction: column; gap: 5px; }
.interest-title { font-size: 0.88rem; color: var(--head); }
.interest-right { text-align: right; flex-shrink: 0; }
.interest-date { font-size: 0.65rem; color: var(--muted); white-space: nowrap; }

/* ─── NOW ─────────────────────────────────────────────────────── */
.now-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}
.now-line {
  display: flex;
  gap: 10px;
  font-size: 0.82rem;
  line-height: 1.8;
  color: var(--body);
}
.now-line .prompt-char { color: var(--prompt); flex-shrink: 0; }
.now-line em { font-style: normal; color: var(--head); }

/* ─── CONTACT ─────────────────────────────────────────────────── */
.contact-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
}
.contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
}
.contact-key { color: var(--muted); }
.contact-val { color: var(--accent2); white-space: nowrap; }

/* ─── FOOTER ──────────────────────────────────────────────────── */
.footer {
  margin-top: 64px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.footer-left { font-size: 0.68rem; color: var(--muted); }
.footer-left span { color: var(--subtle); }
.footer-right { font-size: 0.68rem; color: var(--muted); }

/* ─── READER (generated article pages) ────────────────────────── */
.reader {
  margin-top: 32px;
  padding-bottom: 32px;
}
.reader-header {
  margin-bottom: 28px;
}
.reader-back {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--accent2);
  text-decoration: none;
  margin-bottom: 16px;
}
.reader-back:hover { text-decoration: underline; }
.reader-title {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  color: var(--head);
  font-weight: 400;
  margin-bottom: 8px;
  line-height: 1.3;
}
.reader-date {
  font-size: 0.78rem;
  color: var(--muted);
}
.reader-content {
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--body);
}
.reader-content h2 {
  font-size: 1.1rem;
  color: var(--head);
  margin-top: 28px;
  margin-bottom: 10px;
}
.reader-content h3 { font-size: 1rem; color: var(--head); margin-top: 20px; margin-bottom: 8px; }
.reader-content p { margin-bottom: 14px; }
.reader-content ul, .reader-content ol { margin: 14px 0 14px 20px; }
.reader-content li { margin-bottom: 6px; }
.reader-content code { font-size: 0.88em; background: var(--bg3); padding: 2px 6px; border-radius: 2px; }
.reader-content pre { background: var(--bg2); padding: 14px; border-radius: var(--radius); overflow-x: auto; margin: 14px 0; font-size: 0.82rem; }
.reader-content pre code { background: none; padding: 0; }
.reader-content a { color: var(--accent2); }
.reader-content hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.reader-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 0.88rem;
}
.reader-content thead { border-bottom: 2px solid var(--border); }
.reader-content th, .reader-content td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.reader-content th { color: var(--head); font-weight: 500; }
.reader-content tbody tr:last-child td { border-bottom: none; }

/* ─── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 580px) {
  .nav { display: none; }
  .project-row { grid-template-columns: 1fr; }
  .project-meta { flex-direction: row; align-items: center; }
}

/* ─── ANIMATION ───────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.hero, .section { animation: fadeUp 0.4s ease both; }
.section:nth-of-type(1) { animation-delay: 0.05s; }
.section:nth-of-type(2) { animation-delay: 0.10s; }
.section:nth-of-type(3) { animation-delay: 0.15s; }
.section:nth-of-type(4) { animation-delay: 0.20s; }
.section:nth-of-type(5) { animation-delay: 0.25s; }
