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

:root {
  --bg:         #f8f7f4;
  --bg-subtle:  #efece6;
  --ink:        #1a1916;
  --ink-mid:    #6b6660;
  --ink-dim:    #b0aba2;
  --rule:       #e3dfd7;
  --accent:     #b35309;
  --accent-alt: #92400e;
}

[data-theme="dark"] {
  --bg:         #131210;
  --bg-subtle:  #1d1b18;
  --ink:        #f0ebe0;
  --ink-mid:    #9e9790;
  --ink-dim:    #524d47;
  --rule:       #2c2820;
  --accent:     #f59e0b;
  --accent-alt: #fbbf24;
}

html { scroll-behavior: smooth; font-optical-sizing: auto; }

/* Transitions enabled after first paint — avoids flash on load */
.transitions-ready * {
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}
/* Keep interaction transitions snappy */
.transitions-ready a,
.transitions-ready .post-list a,
.transitions-ready .back-link,
.transitions-ready .wordmark,
.transitions-ready .site-header nav a,
.transitions-ready .theme-toggle {
  transition: color 0.15s ease, background-color 0.25s ease, border-color 0.25s ease;
}

body {
  font-family: "Manrope", system-ui, sans-serif;
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--ink);
  background: var(--bg);
  margin: 0; padding: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ── Reading progress bar ─────────────────────────── */

.progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 1px;
  width: 0%;
  background: var(--accent);
  z-index: 100;
  pointer-events: none;
}

/* ── Layout ───────────────────────────────────────── */

.layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 0 1.75rem 8rem;
}

/* ── Header ───────────────────────────────────────── */

.site-header {
  width: 100%;
  max-width: 700px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.75rem 0 1.25rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 3rem;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 2.5rem;
}

.wordmark {
  font-family: "Manrope", system-ui, sans-serif;
  font-style: normal;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.logo-emblem {
  color: var(--accent);
  opacity: 0.8;
  flex-shrink: 0;
  position: relative;
  top: -0.08em;
  transition: opacity 0.15s;
}

.wordmark:hover .logo-emblem {
  opacity: 1;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 1.75rem;
}

.site-header nav a {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  text-decoration: none;
  transition: color 0.15s;
}

.site-header nav a.active,
.site-header nav a:hover {
  color: var(--ink-mid);
}

/* ── Theme toggle ─────────────────────────────────── */

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  overflow: visible;
  display: flex;
  align-items: center;
  color: var(--ink-dim);
  transition: color 0.15s;
  margin-left: 0.5rem;
}

.theme-toggle:hover { color: var(--ink-mid); }

.theme-icon {
  display: block;
  width: 16px; height: 16px;
  border-radius: 50%;
  background:
    linear-gradient(135deg,
      rgba(255,255,255,0.28) 0%,
      rgba(255,255,255,0.06) 40%,
      transparent 50%,
      color-mix(in srgb, var(--accent) 35%, transparent) 100%
    ),
    conic-gradient(var(--ink) 0deg 180deg, var(--bg) 180deg 360deg);
  box-shadow: 0 0 0 1.5px currentColor;
  will-change: transform;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transition: transform 0.4s ease, box-shadow 0.3s ease;
}

.theme-toggle:hover .theme-icon {
  transform: rotate(180deg) scale(1.2);
  box-shadow: 0 0 0 1.5px currentColor, 0 0 5px 1px color-mix(in srgb, var(--accent) 40%, transparent);
}

/* ── Main ─────────────────────────────────────────── */

main {
  width: 100%;
  max-width: 700px;
}

/* ── Section label ────────────────────────────────── */

.section-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 0 0 2.5rem;
}

/* ── Post list ────────────────────────────────────── */

.post-list {
  list-style: none;
  padding: 0; margin: 0;
}

.post-list li {
  position: relative;
}

.post-list li::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--rule) 15%, var(--rule) 85%, transparent);
}

.post-list li::before {
  content: '◆';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 50%);
  font-size: 0.42rem;
  line-height: 1;
  color: var(--accent);
  background: var(--bg);
  padding: 0 0.4rem;
  z-index: 2;
}

/* Full-row link */
.post-list a.post-link {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 2rem;
  padding: 1.5rem 0;
  text-decoration: none;
}

.post-list a.post-link::before {
  content: '';
  position: absolute;
  inset: 0;
}

.post-title {
  font-family: "Manrope", system-ui, sans-serif;
  font-style: normal;
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  transition: color 0.15s;
}

.post-list a.post-link:hover .post-title { color: var(--accent); }

.post-list time {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s;
}

.post-list a.post-link:hover time { color: var(--ink-mid); }

/* ── Back link ────────────────────────────────────── */

.back-link {
  display: inline-block;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  text-decoration: none;
  margin-bottom: 3rem;
  transition: color 0.15s;
}
.back-link:hover { color: var(--ink-mid); }

/* ── Article ──────────────────────────────────────── */

article h1 {
  font-family: "Manrope", system-ui, sans-serif;
  font-style: normal;
  font-weight: 600;
  font-size: clamp(1.5rem, 4vw, 1.9rem);
  line-height: 1.2;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin: 0 0 0.5rem;
}

article h2 {
  font-family: "Manrope", system-ui, sans-serif;
  font-style: normal;
  font-weight: 600;
  font-size: 1.2rem;
  line-height: 1.3;
  letter-spacing: -0.015em;
  margin: 2.75rem 0 0.75rem;
  color: var(--ink);
}

article h3 {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mid);
  margin: 2.25rem 0 0.75rem;
}

article .meta {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 3rem;
  display: block;
}

article p, article ul, article ol {
  font-size: 1.05rem;
  line-height: 1.8;
  margin: 0 0 1.4rem;
}

article a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: color 0.15s, text-decoration-thickness 0.15s;
}

article a:hover {
  color: var(--accent);
  text-decoration-thickness: 2px;
}

article code {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.82em;
  color: var(--ink-mid);
  background: var(--bg-subtle);
  padding: 0.12em 0.4em;
  border-radius: 2px;
}

article pre {
  background: var(--bg-subtle);
  border: 1px solid var(--rule);
  padding: 1.25rem 1.5rem;
  border-radius: 3px;
  overflow-x: auto;
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0 0 1.4rem;
}

article pre code { background: none; padding: 0; color: var(--ink); }

article blockquote {
  margin: 1.75rem 0;
  padding: 0 0 0 1.25rem;
  border-left: 1px solid var(--accent);
  color: var(--ink-mid);
  font-style: italic;
}

article hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2.5rem 0;
}

article img {
  max-width: 100%;
  height: auto;
  border-radius: 3px;
  display: block;
  margin: 1.75rem auto;
}

article figure {
  margin: 2rem 0;
}

article figure img {
  margin: 0 0 0.75rem;
  width: 100%;
}

article figcaption {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
  text-align: center;
}

/* ── Work list (projects / contributions) ─────────── */

.work-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
}

.work-list li {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--rule);
}

.work-list li:last-child { border-bottom: none; }

.work-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
  text-decoration: none;
}

.work-name {
  font-family: "Manrope", system-ui, sans-serif;
  font-style: normal;
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  transition: color 0.15s;
}

.work-head:hover .work-name { color: var(--accent); }

.work-meta {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

.work-desc {
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--ink-mid);
  margin: 0.5rem 0 0;
}

@media (max-width: 560px) {
  .work-head { flex-direction: column; gap: 0.25rem; }
}

/* ── Footer ───────────────────────────────────────── */

footer.site {
  width: 100%;
  max-width: 700px;
  margin-top: 6rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

footer.site a {
  color: var(--ink-dim);
  text-decoration: none;
  transition: color 0.15s;
}
footer.site a:hover { color: var(--ink-mid); }
footer.site .links { display: flex; gap: 1.5rem; }

/* ── Mobile ───────────────────────────────────────── */

@media (max-width: 560px) {
  .site-header { flex-wrap: wrap; gap: 0.75rem 0; }
  .header-left { gap: 1.5rem; }
  .post-list a.post-link { flex-direction: column; gap: 0.35rem; padding: 1.25rem 0; }
}
