/* ---------- Tokens ---------- */
:root {
  --bg: #090e16;
  --ink: #d8e1ee;
  --muted: #8c9bb0;
  --rule: #1f2b3d;
  --accent: #5cc8ff;
  --amber: #f2b544;
  --code-bg: #0f1724;

  /* The terminal stays dark in both themes */
  --term-bg: #0c1422;
  --term-ink: #dbe5f3;
  --term-muted: #8c9bb0;
  --term-accent: #5cc8ff;
  --term-amber: #f2b544;
  --term-rule: #22314a;

  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --label-col: 12rem;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f2f5f9;
  --ink: #0b1220;
  --muted: #4a5870;
  --rule: #cdd6e2;
  --accent: #0a5ca8;
  --amber: #8a5200;
  --code-bg: #e4eaf2;
  color-scheme: light;
}

/* ---------- Base ---------- */
*, *::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-family: var(--sans); font-size: 1.0625rem; line-height: 1.65;
}

.wrap { width: min(100% - 2.5rem, 72rem); margin-inline: auto; }

a { color: var(--accent); text-decoration-thickness: 0.08em; text-underline-offset: 0.2em; }
a:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
img { max-width: 100%; height: auto; }

.skip { position: absolute; left: -999px; top: 0.5rem; background: var(--ink); color: var(--bg); padding: 0.5rem 1rem; font-family: var(--mono); z-index: 10; }
.skip:focus { left: 0.5rem; }

.ps { color: var(--amber); font-family: var(--mono); font-weight: 500; }

/* ---------- Header and footer ---------- */
.site-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.75rem 1.5rem; padding-block: 1.1rem;
  font-family: var(--mono); font-size: 0.9rem;
  border-bottom: 1px solid var(--rule);
}
.wordmark { font-weight: 600; color: var(--ink); text-decoration: none; }
.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.5rem; }
.site-nav ul { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; list-style: none; margin: 0; padding: 0; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover { color: var(--accent); text-decoration: underline; }

.theme-toggle {
  font: inherit; font-size: 0.8rem; line-height: 1.2;
  background: none; color: var(--ink);
  border: 1px solid var(--rule); border-radius: 3px;
  padding: 0.3rem 0.7rem; cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

.site-footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem;
  padding-block: 2.5rem 3rem; font-family: var(--mono); font-size: 0.85rem; color: var(--muted);
}
.site-footer p { margin: 0; }

/* ---------- Terminal hero ---------- */
.hero { padding-block: clamp(1.5rem, 4vw, 3rem) clamp(1.5rem, 4vw, 3rem); }

.term {
  background: var(--term-bg); color: var(--term-ink);
  border: 1px solid var(--term-rule); border-radius: 8px;
  overflow: hidden; font-family: var(--mono);
}
.term-bar {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.65rem 1rem; border-bottom: 1px solid var(--term-rule);
  font-size: 0.8rem; color: var(--term-muted);
}
.dot { width: 0.75rem; height: 0.75rem; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25); }
.dot:nth-of-type(1) { background: #ff5f57; }
.dot:nth-of-type(2) { background: #febc2e; }
.dot:nth-of-type(3) { background: #28c840; }
.term-title { margin-left: 0.75rem; }
.term-body { padding: clamp(1.25rem, 3vw, 2.25rem); }

.term .cmd, .cmd { font-family: var(--mono); font-size: 0.9rem; margin: 0 0 0.5rem; color: var(--term-muted); }
.term .ps { color: var(--term-amber); }
.term .cmd + .cmd { margin-top: 0; }

.name {
  font-family: var(--mono); font-weight: 700;
  font-size: clamp(3.25rem, 13vw, 9.5rem);
  line-height: 1; letter-spacing: -0.04em;
  margin: 0 0 0.5rem; color: var(--term-ink); overflow-wrap: anywhere;
}
.cursor {
  display: inline-block; width: 0.5em; height: 0.85em; margin-left: 0.08em;
  background: var(--term-accent); vertical-align: -0.05em;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.role { font-weight: 600; font-size: 1.15rem; color: var(--term-accent); margin: 0 0 2rem; }
.tagline { font-family: var(--sans); font-size: clamp(1.1rem, 2vw, 1.4rem); line-height: 1.5; margin: 0 0 2rem; max-width: 44ch; color: var(--term-ink); }

.cert { margin: 0; font-size: 0.875rem; line-height: 1.6; display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: 0.3rem 1rem; max-width: 46rem; }
.cert-head { grid-column: 1 / -1; color: var(--term-amber); }
.cert dt { color: var(--term-muted); padding-left: 1.5rem; }
.cert dd { margin: 0; overflow-wrap: anywhere; }

/* One page-load sequence: lines appear as if typed out */
.step { animation: show 0.2s ease-out both; animation-delay: calc(var(--i, 0) * 0.45s + 0.2s); }
@keyframes show { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Sections ---------- */
.row, .article-grid {
  display: grid; grid-template-columns: var(--label-col) minmax(0, 1fr); gap: 0.75rem 2rem;
}
.row { padding-block: clamp(2rem, 5vw, 3.25rem); border-top: 1px solid var(--rule); }

.row > h2 {
  font-family: var(--mono); font-size: 0.95rem; font-weight: 500;
  text-transform: lowercase; color: var(--accent); line-height: 1.75; margin: 0;
}
.row > h2::before { content: "~/"; color: var(--muted); }

.row-body > :first-child { margin-top: 0; }
.row-body > :last-child { margin-bottom: 0; }

.about p { margin: 0 0 1em; max-width: 42rem; }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 2rem; }
.timeline h3 { font-size: 1.15rem; font-weight: 600; line-height: 1.3; margin: 0; }
.period { font-family: var(--mono); font-size: 0.85rem; color: var(--muted); margin: 0.2rem 0 0.4rem; }
.timeline p:last-child { margin: 0; max-width: 42rem; }

.roles { list-style: none; margin: 0.75rem 0 0; padding: 0 0 0 1rem; border-left: 2px solid var(--rule); }
.roles li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 1.5rem; padding: 0.3rem 0; }
.r-title { flex: 1 1 18rem; }
.r-period { font-family: var(--mono); font-size: 0.82rem; color: var(--muted); }
.roles li p { flex-basis: 100%; margin: 0.2rem 0 0; }

.badge {
  display: inline-block; margin-left: 0.5rem; padding: 0 0.45rem;
  font-family: var(--mono); font-size: 0.72rem; line-height: 1.5;
  color: var(--accent); border: 1px solid var(--accent); border-radius: 3px;
}

.skills { display: grid; grid-template-columns: minmax(8rem, 12rem) 1fr; gap: 1rem 2rem; margin: 0; }
.skills dt { font-weight: 600; }
.skills dd { margin: 0; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chips li {
  font-family: var(--mono); font-size: 0.8rem; line-height: 1.4;
  padding: 0.2rem 0.6rem; border: 1px solid var(--rule); border-radius: 3px;
}

.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; max-width: 42rem; }

.contact-email { font-family: var(--mono); font-size: clamp(1.15rem, 2.6vw, 1.7rem); font-weight: 600; }
.link-list { list-style: none; padding: 0; margin: 1rem 0 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; font-family: var(--mono); font-size: 0.95rem; }

/* ---------- Post lists ---------- */
.posts { list-style: none; margin: 0; padding: 0; }
.post {
  display: grid; grid-template-columns: 10.5rem 1fr; gap: 0.25rem 1.5rem;
  padding: 1.1rem 0; border-top: 1px solid var(--rule); color: inherit; text-decoration: none;
}
.posts li:first-child .post { border-top: 0; padding-top: 0; }
.post time { font-family: var(--mono); font-size: 0.82rem; color: var(--muted); padding-top: 0.4rem; }
.post-title { font-weight: 600; font-size: 1.2rem; line-height: 1.3; }
.post-sum { grid-column: 2; color: var(--muted); }
.post:hover .post-title { color: var(--accent); text-decoration: underline; text-underline-offset: 0.2em; }
.more { font-family: var(--mono); font-size: 0.95rem; margin: 1.5rem 0 0; }
.empty { color: var(--muted); margin: 0; }

/* ---------- Blog index and article ---------- */
.page-head { padding-block: clamp(2rem, 5vw, 3.5rem) clamp(1.5rem, 4vw, 2.5rem); }
.page-head h1, .article-head h1 { font-family: var(--mono); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; margin: 0 0 1rem; }
.page-head h1 { font-size: clamp(2.5rem, 8vw, 5.5rem); }
.page-head p { margin: 0; max-width: 40ch; font-size: 1.15rem; color: var(--muted); }
.page-head .cmd, .article-head .cmd { color: var(--muted); }

.article-head { padding-block: clamp(2rem, 5vw, 3.5rem) clamp(1.5rem, 4vw, 2.5rem); }
.article-head h1 { font-size: clamp(1.9rem, 4.8vw, 3.25rem); max-width: 20em; margin: 0; }

.article-grid { padding-bottom: clamp(2rem, 5vw, 3.5rem); }
.post-meta { font-family: var(--mono); font-size: 0.82rem; color: var(--muted); }
.post-meta p { margin: 0 0 0.25rem; }

.prose { max-width: 42rem; min-width: 0; }
.prose > :first-child { margin-top: 0; }
.prose h2, .prose h3, .prose h4, .prose h5 { line-height: 1.25; letter-spacing: -0.01em; }
.prose h2 { font-size: 1.55rem; margin: 2.2em 0 0.6em; }
.prose h3 { font-size: 1.25rem; margin: 1.8em 0 0.5em; }
.prose h4, .prose h5 { font-size: 1.05rem; margin: 1.6em 0 0.4em; }
.prose p { margin: 0 0 1.2em; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.2em; }
.prose li { margin: 0.3em 0; }
.prose blockquote { margin: 1.6em 0; padding-left: 1.25rem; border-left: 3px solid var(--accent); color: var(--muted); }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }
.prose figure { margin: 1.8em 0; }
figure img { margin: 0 auto; display: block; }
.prose figcaption { font-family: var(--mono); font-size: 0.82rem; color: var(--muted); margin-top: 0.5rem;  display: none; }
.prose pre {
  background: var(--code-bg); border: 1px solid var(--rule); border-left: 3px solid var(--accent);
  padding: 1rem 1.25rem; overflow-x: auto; border-radius: 4px;
  font-size: 0.875rem; line-height: 1.55; margin: 1.5em 0;
}
.prose code { font-family: var(--mono); font-size: 0.88em; }
.prose :not(pre) > code { background: var(--code-bg); border: 1px solid var(--rule); padding: 0.05em 0.35em; border-radius: 3px; }

.post-nav { display: flex; justify-content: space-between; gap: 1.5rem; border-top: 1px solid var(--rule); padding-block: 1.5rem; }
.post-nav a { display: block; max-width: 22rem; color: var(--ink); text-decoration: none; }
.post-nav a:hover strong { color: var(--accent); text-decoration: underline; }
.post-nav small { display: block; font-family: var(--mono); color: var(--muted); font-size: 0.8rem; }
.post-nav .next { margin-left: auto; text-align: right; }

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
  .row, .article-grid { grid-template-columns: 1fr; gap: 0.5rem; }
  .post { grid-template-columns: 1fr; }
  .post-sum { grid-column: 1; }
  .skills { grid-template-columns: 1fr; gap: 0.4rem; }
  .skills dd { margin-bottom: 0.9rem; }
  .cert { grid-template-columns: 1fr; gap: 0; }
  .cert dt { padding-left: 1rem; }
  .cert dd { padding-left: 1rem; margin-bottom: 0.6rem; }
  .roles li { display: block; padding: 0.45rem 0; }
  .r-title, .r-period { display: block; }
  .post-meta { margin-bottom: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .step { animation: none; }
  .cursor { animation: none; }
}

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