/*
  Hand-authored theme for justinhaygood.com — dark IDE/terminal aesthetic.
  No framework dependency (replaces the Bootstrap 5 / Start Bootstrap "Clean Blog" dist CSS).
*/

:root {
  --bg: #0d1117;
  --bg-elevated: #151a23;
  --bg-inset: #0a0d12;
  --border: #232a38;
  --fg: #d8dee9;
  --fg-muted: #7b8496;
  --fg-dim: #4d5566;
  --accent-cyan: #5fd8e3;
  --accent-cyan-dim: #2c6b73;
  --accent-green: #7ee787;
  --accent-magenta: #ff79c6;
  --accent-amber: #f2c94c;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

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

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  background-image: radial-gradient(circle at 1px 1px, rgba(95, 216, 227, 0.07) 1px, transparent 0);
  background-size: 28px 28px;
  color: var(--fg);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }

a { color: var(--accent-cyan); }
a:hover { color: var(--accent-magenta); }

:focus-visible { outline: 2px solid var(--accent-cyan); outline-offset: 2px; }

::selection { background: var(--accent-cyan); color: var(--bg-inset); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-cyan-dim); }

h1, h2, h3 { text-wrap: balance; }

/* small utility kept for the existing <hr class="my-4"> dividers between posts */
.my-4 { margin-top: 1.5rem; margin-bottom: 1.5rem; border: 0; border-top: 1px dashed var(--border); }

/* ---------- page shell ---------- */
.page {
  max-width: min(1600px, 92vw);
  margin: 0 auto;
  padding: clamp(16px, 5vw, 32px) clamp(14px, 4vw, 24px) 64px;
}

/* ---------- nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px 16px;
  flex-wrap: wrap;
  padding: 14px clamp(14px, 4vw, 20px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-mono);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.nav.is-scrolled {
  box-shadow: 0 12px 28px -12px rgba(0, 0, 0, 0.6);
  border-color: var(--accent-cyan-dim);
}

.brand {
  color: var(--accent-cyan);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.01em;
  text-decoration: none;
}
.brand:hover { color: var(--accent-cyan); }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px;
  height: 28px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
}
.nav-toggle .bar { display: block; height: 2px; width: 16px; margin: 0 auto; background: var(--fg-muted); }
.nav-toggle:hover .bar { background: var(--fg); }

.nav-links {
  display: flex;
  gap: clamp(10px, 4vw, 22px);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: lowercase;
}

.nav-links a {
  color: var(--fg-muted);
  text-decoration: none;
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.nav-links a::before { content: "# "; color: var(--fg-dim); }
.nav-links a:hover { color: var(--fg); border-color: var(--accent-cyan-dim); }
.nav-links a.is-active { color: var(--fg); border-color: var(--accent-cyan); }

@media (max-width: 640px) {
  .nav-toggle { display: flex; }
  .nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 14px;
    margin-top: 4px;
  }
  .nav-links.is-open { display: flex; }
}

/* ---------- content / sidebar split ---------- */
.layout {
  display: grid;
  gap: 40px;
  min-width: 0;
  margin-top: clamp(28px, 6vw, 40px);
}
.content { min-width: 0; }
.sidebar { min-width: 0; display: flex; flex-direction: column; gap: 20px; }

@media (min-width: 1000px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) minmax(240px, 300px);
    align-items: start;
    gap: clamp(40px, 4vw, 64px);
  }
  .sidebar { position: sticky; top: 88px; }
}

.side-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
}
.side-head {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 12px;
}
.side-head .n { color: var(--accent-cyan); }
.side-bio {
  font-size: 13.5px;
  color: var(--fg-muted);
  line-height: 1.6;
  margin: 0;
}
.side-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.side-list a { color: var(--fg); text-decoration: none; }
.side-list a:hover { color: var(--accent-cyan); }
.side-date { display: block; color: var(--fg-dim); font-size: 11px; margin-top: 3px; }

/* ---------- hero terminal ---------- */
.hero {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6);
  margin-bottom: clamp(28px, 6vw, 40px);
}

.hero-titlebar {
  display: flex;
  align-items: stretch;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.hero-titlebar .label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
  padding: 10px 10px 10px 14px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hero-titlebar .label .glyph { color: var(--accent-cyan); font-weight: 700; flex: 0 0 auto; }

.win-controls { display: flex; flex: 0 0 auto; }
.win-btn {
  width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  transition: background 0.1s, color 0.1s;
}
.win-btn svg { width: 10px; height: 10px; display: block; }
.win-btn.min svg rect { fill: currentColor; }
.win-btn.max svg rect { fill: none; stroke: currentColor; stroke-width: 1; }
.win-btn.close svg line { stroke: currentColor; stroke-width: 1; }
.win-btn:hover { background: rgba(216, 222, 233, 0.08); color: var(--fg); }
.win-btn.close:hover { background: #e81123; color: #fff; }

.hero-body {
  background: var(--bg-inset);
  padding: clamp(24px, 5vw, 44px) clamp(18px, 5vw, 40px) clamp(26px, 5vw, 48px);
  font-family: var(--font-mono);
}

/* Character-reveal span for short, fixed-length text only (the "whoami" prompt
   command) - relies on white-space:nowrap so it must never be used on content
   whose length varies or that might need to wrap (e.g. real post titles). */
.term-type {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  vertical-align: bottom;
  width: calc(var(--chars, 0) * 1ch);
  animation-name: type-reveal;
  animation-duration: calc(var(--chars, 1) * 0.045s);
  animation-timing-function: steps(var(--chars, 1), end);
  animation-delay: var(--delay, 0s);
  animation-fill-mode: both;
}
@keyframes type-reveal {
  from { width: 0; }
  to { width: calc(var(--chars, 0) * 1ch); }
}

/* Fade-up reveal for variable-length, potentially long terminal output lines
   (title/subtitle/byline) - wraps normally, never clips real content. */
.term-reveal {
  display: inline-block;
  opacity: 0;
  transform: translateY(6px);
  animation: reveal-fade 0.45s ease-out var(--delay, 0s) both;
}
@keyframes reveal-fade {
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .term-type { animation: none; width: calc(var(--chars, 0) * 1ch); }
  .term-reveal { animation: none; opacity: 1; transform: none; }
}

.prompt-line { font-size: clamp(12px, 2vw, 16px); color: var(--fg-muted); }
.prompt-line .who { color: var(--accent-green); }
.prompt-line .sep { color: var(--fg-dim); }
.prompt-line .cmd { color: var(--fg); }

.hero-title {
  font-size: clamp(21px, 5vw, 42px);
  font-weight: 800;
  color: #fff;
  margin: 16px 0 8px;
  letter-spacing: -0.01em;
}

.hero-sub {
  font-size: clamp(12.5px, 2.2vw, 18px);
  font-style: italic;
  color: var(--fg-muted);
  display: block;
  margin-top: 10px;
}

.hero-meta {
  font-size: clamp(10.5px, 1.8vw, 14px);
  color: var(--fg-dim);
  margin-top: 14px;
  display: block;
}
.hero-meta a { color: var(--fg-dim); text-decoration: underline; text-decoration-color: var(--border); }

/* ---------- section heading ---------- */
.section-head {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin: clamp(36px, 9vw, 56px) 0 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.section-head::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.section-head .n { color: var(--accent-cyan); }

/* ---------- post list ---------- */
.post-preview {
  border-left: 3px solid var(--accent-cyan-dim);
  background: var(--bg-elevated);
  border-radius: 0 8px 8px 0;
  padding: clamp(14px, 4vw, 18px) clamp(16px, 4vw, 20px);
  margin-bottom: 14px;
  transition: border-color 0.15s;
}
.post-preview:hover { border-left-color: var(--accent-cyan); }
.post-preview > a { text-decoration: none; color: inherit; }
.post-title {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: clamp(16px, 1.4vw, 20px);
  color: #fff;
  margin: 0 0 4px;
}
.post-preview > a:hover .post-title { color: var(--accent-cyan); }
.post-subtitle {
  font-family: var(--font-sans);
  font-weight: 400;
  font-style: italic;
  color: var(--fg-muted);
  font-size: 15px;
  margin: 0 0 8px;
}
.post-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--fg-muted);
  font-style: italic;
  margin: 0 0 10px;
}
.post-meta a { color: var(--fg-muted); text-decoration: underline; text-decoration-color: var(--border); }
.post-contents { max-width: 68ch; }

/* ---------- pager / buttons ---------- */
.pager { display: flex; justify-content: flex-end; margin-top: 22px; margin-bottom: 1.5rem; gap: 12px; }
.pager--split { justify-content: space-between; }

.btn {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-cyan);
  background: transparent;
  border: 1px solid var(--accent-cyan-dim);
  border-radius: 5px;
  padding: 9px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}
.btn::before { content: "[ "; }
.btn::after { content: " ]"; }
.btn:hover { background: var(--accent-cyan); color: var(--bg-inset); }
.btn.is-disabled { opacity: 0.4; pointer-events: none; }

/* ---------- content typography (post bodies / generic pages are raw HTML) ---------- */
.content h1, .content h2, .content h3 { font-family: var(--font-mono); color: #fff; }
.content p { margin: 0 0 1em; }
.content a { text-decoration-color: var(--border); }
.content blockquote {
  font-family: var(--font-sans);
  font-style: italic;
  color: var(--fg-muted);
  border-left: 3px solid var(--accent-magenta);
  background: var(--bg-elevated);
  margin: 18px 0;
  padding: 14px 18px;
  border-radius: 0 6px 6px 0;
}
.content pre, .content code {
  font-family: var(--font-mono);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  color: var(--fg);
}
.content code { border-radius: 3px; padding: 1px 5px; font-size: 0.9em; color: var(--accent-amber); }
.content pre {
  border-left: 3px solid var(--accent-cyan);
  border-radius: 0 6px 6px 0;
  padding: 14px 18px;
  margin: 14px 0;
  overflow-x: auto;
}
.content pre code { background: none; border: 0; padding: 0; color: inherit; }

.page-content {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: clamp(20px, 5vw, 36px) clamp(18px, 5vw, 32px);
}

/* ---------- footer ---------- */
.footer {
  margin-top: 60px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--fg-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.footer .prompt b { color: var(--accent-green); font-weight: 700; }
.footer .fcur {
  display: inline-block;
  width: 0.5em;
  height: 1em;
  background: var(--accent-green);
  vertical-align: -2px;
  margin-left: 2px;
  animation: fcur-blink 1.1s step-end infinite;
}
@keyframes fcur-blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .footer .fcur { animation: none; }
}

.social-links { display: flex; gap: 10px; }
.social-links a {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}
.social-links a:hover { color: var(--accent-cyan); border-color: var(--accent-cyan-dim); }
