/* ==========================================================================
   Design tokens
   ========================================================================== */
:root {
  --bg: #0d0d0c;
  --panel: #171614;
  --panel-hover: #1c1b18;
  --border: #2a2823;
  --border-bright: #423f36;
  --text: #e9e6dd;
  --text-dim: #8c887d;
  --text-faint: #5c594f;
  --accent: #ffb020;
  --accent-dim: #b8811c;
  --accent-wash: rgba(255, 176, 32, 0.08);
  --accent2: #5fa8a3;

  --font-display: "Space Grotesk", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;

  --content-width: 760px;
  --wide-width: 1040px;

  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --space-5: 4rem;
  --space-6: 6.5rem;
}

/* ==========================================================================
   Reset
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

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

/* subtle scanline / grain texture, very low opacity so it reads as
   material rather than decoration */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.012) 0px,
    rgba(255, 255, 255, 0.012) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.01em;
}

p { margin: 0 0 1em; }
a { color: inherit; text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; display: block; }

::selection { background: var(--accent); color: #0d0d0c; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ==========================================================================
   Layout shell
   ========================================================================== */
.wrap {
  max-width: var(--wide-width);
  margin: 0 auto;
  padding: 0 var(--space-3);
}

.prose {
  max-width: var(--content-width);
}

/* faint hex-offset gutter — a nod to hex-editor address columns.
   Decorative, low-contrast, hidden on narrow screens. */
.gutter {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.2rem;
  color: var(--text-faint);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
  border-right: 1px solid var(--border);
}
@media (max-width: 900px) {
  .gutter { display: none; }
}

/* ==========================================================================
   Header / nav
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13, 13, 12, 0.88);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text);
}
.logo span { color: var(--accent); }

.site-nav ul {
  display: flex;
  gap: var(--space-4);
}

.site-nav a {
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

@media (max-width: 560px) {
  .site-nav ul { gap: var(--space-2); }
  .site-nav a { font-size: 0.8rem; }
}

/* ==========================================================================
   Hero + boot sequence
   ========================================================================== */
.hero {
  padding: var(--space-6) 0 var(--space-5);
  position: relative;
}

.hero .wrap { position: relative; }

.boot-log {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  font-size: 0.8rem;
  color: var(--accent-dim);
  white-space: pre-wrap;
  margin: 0;
}
.boot-log .cursor {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.hero[data-booted="false"] .hero-content { opacity: 0; }
.hero[data-booted="true"] .hero-content {
  opacity: 1;
  transition: opacity 0.5s ease;
}
.hero[data-booted="false"] .boot-log { display: block; }
.hero[data-booted="true"] .boot-log { display: none; }

.hero-content h1 {
  font-size: clamp(2.4rem, 6vw, 4rem);
  max-width: 14ch;
  margin-bottom: var(--space-2);
}

.hero-tagline {
  font-size: 1.05rem;
  color: var(--text-dim);
  max-width: 56ch;
  margin-bottom: var(--space-2);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: 0.82rem;
  color: var(--text-faint);
  margin-top: var(--space-3);
}
.hero-meta li::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--accent);
  margin-right: 0.5em;
  border-radius: 50%;
  vertical-align: middle;
}

/* ==========================================================================
   Section headings
   ========================================================================== */
.section {
  padding: var(--space-5) 0;
  border-top: 1px solid var(--border);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-2);
  flex-wrap: wrap;
}

.section-head h2 {
  font-size: 1.6rem;
}

.section-head .see-all {
  font-size: 0.85rem;
  color: var(--accent);
  border-bottom: 1px solid var(--accent-dim);
  padding-bottom: 1px;
}
.section-head .see-all:hover { color: var(--text); border-color: var(--text); }

.section-lede {
  color: var(--text-dim);
  max-width: 62ch;
  margin-top: -0.5rem;
  margin-bottom: var(--space-4);
}

/* ==========================================================================
   Project cards
   ========================================================================== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}
@media (max-width: 720px) {
  .card-grid { grid-template-columns: 1fr; }
}

.card {
  background: var(--panel);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  transition: background 0.15s ease;
}
.card:hover { background: var(--panel-hover); }

.card-offset {
  font-size: 0.75rem;
  color: var(--accent);
  margin-bottom: var(--space-2);
}

.card h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.card p {
  color: var(--text-dim);
  font-size: 0.88rem;
  flex-grow: 1;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: var(--space-2) 0;
}
.tag {
  font-size: 0.72rem;
  color: var(--accent2);
  border: 1px solid var(--border-bright);
  padding: 0.15rem 0.5rem;
}

.card-links {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-1);
  font-size: 0.82rem;
}
.card-links a {
  color: var(--accent);
  border-bottom: 1px solid transparent;
}
.card-links a:hover { border-bottom-color: var(--accent); }

/* ==========================================================================
   Blog list
   ========================================================================== */
.post-list li {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: var(--space-3);
}
@media (max-width: 640px) {
  .post-list li { grid-template-columns: 1fr; gap: 0.4rem; }
}

.post-date {
  color: var(--text-faint);
  font-size: 0.8rem;
  padding-top: 0.2rem;
}

.post-list h3 {
  font-size: 1.15rem;
  margin-bottom: 0.35rem;
}

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

.post-excerpt {
  color: var(--text-dim);
  font-size: 0.88rem;
  margin-bottom: 0.5rem;
}

/* ==========================================================================
   Single post
   ========================================================================== */
.post-header { padding: var(--space-5) 0 var(--space-3); }
.post-header .post-date { display: block; margin-bottom: var(--space-2); }
.post-header h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }

.post-body { padding-bottom: var(--space-5); }
.post-body p { color: var(--text); font-size: 0.95rem; }
.post-body h3 {
  font-size: 1.15rem;
  margin: var(--space-4) 0 var(--space-2);
}
.post-body pre {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: var(--space-2);
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.55;
  margin: 0 0 1.2em;
}
.post-body code {
  font-family: var(--font-mono);
  color: var(--accent);
}

.back-link {
  display: inline-block;
  margin-top: var(--space-4);
  font-size: 0.85rem;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-bright);
}
.back-link:hover { color: var(--accent); border-color: var(--accent); }

/* ==========================================================================
   About
   ========================================================================== */
.about-body p {
  color: var(--text-dim);
  font-size: 0.95rem;
}
.about-body p:first-child { color: var(--text); font-size: 1rem; }

/* ==========================================================================
   Contact / footer
   ========================================================================== */
.contact { text-align: left; }
.contact h2 { font-size: 1.8rem; margin-bottom: var(--space-2); }
.contact p { color: var(--text-dim); max-width: 50ch; margin-bottom: var(--space-3); }

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.contact-links a {
  font-size: 0.9rem;
  color: var(--accent);
  border: 1px solid var(--border-bright);
  padding: 0.55rem 1rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.contact-links a:hover { border-color: var(--accent); background: var(--accent-wash); }

.site-footer {
  border-top: 1px solid var(--border);
  padding: var(--space-3) 0;
  color: var(--text-faint);
  font-size: 0.78rem;
}
.site-footer .wrap,
.footer-row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
}
.site-footer a {
  color: var(--text-faint);
  border-bottom: 1px solid var(--border-bright);
}
.site-footer a:hover { color: var(--accent); border-color: var(--accent); }

/* ==========================================================================
   404
   ========================================================================== */
.error-page {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-5) 0;
}
.error-page .code { color: var(--accent); font-size: 0.9rem; margin-bottom: var(--space-2); }
.error-page h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); margin-bottom: var(--space-2); }
.error-page p { color: var(--text-dim); }
