/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  --charcoal:       #1C1C1E;
  --charcoal-mid:   #2C2C2E;
  --charcoal-light: #3A3A3C;
  --signal-red:     #E5323B;
  --signal-red-dark:#C12B33;
  --white:          #FFFFFF;
  --off-white:      #F5F5F7;
  --medium-gray:    #86868B;
  --border-gray:    #D1D1D6;
  --success-green:  #30D158;
  --code-bg:        #1A1A1E;
  --code-text:      #E6EDB8;

  --font-sans: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;

  --max-wide:   1200px;
  --max-narrow: 740px;
  --gutter:     1.5rem;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--off-white);
  color: var(--charcoal);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--signal-red); }
a:hover { color: var(--signal-red-dark); }

/* ── Keyframes ───────────────────────────────────────────────────────────── */
@keyframes blink {
  0%, 49%  { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ── Containers ─────────────────────────────────────────────────────────── */
.wide-container {
  width: 100%;
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.narrow-container {
  width: 100%;
  max-width: var(--max-narrow);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ── Site Header ─────────────────────────────────────────────────────────── */
.site-header {
  background: var(--charcoal);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.site-logo {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1rem;
  color: var(--white);
  text-decoration: none;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 1px;
}

.site-logo:hover { color: var(--white); opacity: 0.85; }

.cursor-blink {
  color: var(--signal-red);
  animation: blink 1s step-end infinite;
  font-weight: 300;
  line-height: 1;
}

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

.site-nav a {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--medium-gray);
  text-decoration: none;
  transition: color 0.15s;
}

.site-nav a:hover { color: var(--white); }

.nav-rss {
  font-family: var(--font-mono) !important;
  font-size: 0.75rem !important;
  background: transparent;
  border: 1px solid var(--charcoal-light);
  color: var(--medium-gray) !important;
  padding: 0.2rem 0.55rem;
  letter-spacing: 0.02em;
  transition: border-color 0.15s, color 0.15s !important;
}

.nav-rss:hover {
  border-color: var(--signal-red) !important;
  color: var(--signal-red) !important;
}

.header-red-rule {
  height: 3px;
  background: var(--signal-red);
}

/* ── Site Main ───────────────────────────────────────────────────────────── */
.site-main { flex: 1; overflow-x: hidden; }

/* ── Site Footer ─────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--charcoal);
}

.footer-red-rule {
  height: 3px;
  background: var(--signal-red);
}

.footer-inner {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 1.25rem var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-tagline {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--medium-gray);
  letter-spacing: 0.01em;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}

.footer-links a {
  font-size: 0.8rem;
  color: var(--medium-gray);
  text-decoration: none;
  transition: color 0.15s;
}

.footer-links a:hover { color: var(--signal-red); }

.footer-copy {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--charcoal-light);
}

/* ── Hero (Homepage) ─────────────────────────────────────────────────────── */
.hero {
  background: var(--charcoal);
  padding: 3rem 0 3.5rem;
}

.hero-inner {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}

/* Error Panel (left side of hero) */
.error-panel {
  background: #0D1117;
  border: 1px solid #30363D;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  overflow: hidden;
}

.ep-header {
  background: #161B22;
  border-bottom: 1px solid #30363D;
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.ep-dots { display: flex; gap: 5px; margin-right: 0.25rem; }

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
}
.dot--red    { background: #FF5F57; }
.dot--yellow { background: #FFBD2E; }
.dot--green  { background: #28C840; }

.ep-title {
  color: #8B949E;
  font-size: 0.72rem;
  flex: 1;
}

.ep-badge {
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
}
.ep-badge--error { background: rgba(229,50,59,0.2); color: #FF7B7F; }
.ep-badge--warn  { background: rgba(255,189,46,0.15); color: #8B949E; }

.ep-body { padding: 0.5rem 0; }

.ep-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #21262D;
  align-items: flex-start;
}

.ep-item:last-child { border-bottom: none; }

.ep-icon {
  color: var(--signal-red);
  font-size: 0.7rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
}

.ep-text { min-width: 0; }

.ep-msg {
  color: #E6EDF3;
  font-size: 0.78rem;
  line-height: 1.3;
  font-weight: 500;
}

.ep-detail {
  color: #8B949E;
  font-size: 0.7rem;
  margin-top: 0.15rem;
  line-height: 1.3;
}

.ep-file {
  color: #4D9375;
  font-size: 0.68rem;
  margin-top: 0.2rem;
}

.ep-footer {
  background: #161B22;
  border-top: 1px solid #30363D;
  padding: 0.4rem 0.75rem;
  display: flex;
  justify-content: space-between;
  color: #484F58;
  font-size: 0.65rem;
}

/* Featured Post (right side of hero) */
.hero-featured {
  background: var(--white);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.featured-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--signal-red);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.featured-category {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--medium-gray);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hero-featured h2 {
  font-family: var(--font-sans);
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.hero-featured h2 a {
  color: var(--charcoal);
  text-decoration: none;
}

.hero-featured h2 a:hover { color: var(--signal-red); }

.hero-featured p {
  font-size: 0.9rem;
  color: var(--medium-gray);
  line-height: 1.6;
}

.featured-meta {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--medium-gray);
}

.featured-cta {
  display: inline-block;
  margin-top: 0.25rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--signal-red);
  text-decoration: none;
  transition: color 0.15s;
}

.featured-cta:hover { color: var(--signal-red-dark); }

/* ── Post Grid (Homepage) ─────────────────────────────────────────────────── */
.grid-section {
  padding: 3rem 0 2rem;
  background: var(--off-white);
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border-gray);
  border: 1px solid var(--border-gray);
}

.post-card {
  background: var(--white);
  padding: 1.5rem;
  border-left: 4px solid transparent;
  transition: border-color 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.post-card:hover { border-left-color: var(--signal-red); }

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-category {
  font-family: var(--font-mono);
  font-size: 0.63rem;
  font-weight: 700;
  color: var(--signal-red);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card-date {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--medium-gray);
  white-space: nowrap;
}

.post-card h3 {
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 0;
}

.post-card h3 a {
  color: var(--charcoal);
  text-decoration: none;
}

.post-card h3 a:hover { color: var(--signal-red); }

.post-card p {
  font-size: 0.83rem;
  color: var(--medium-gray);
  line-height: 1.55;
  flex: 1;
}

/* ── Older Posts Section ────────────────────────────────────────────────── */
.older-section {
  padding: 2rem 0 4rem;
  background: var(--off-white);
}

.section-heading {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--medium-gray);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-gray);
}

.older-list {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.older-item {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 1rem;
  align-items: baseline;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border-gray);
}

.older-item:last-child { border-bottom: none; }

.older-date {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--medium-gray);
  white-space: nowrap;
  flex-shrink: 0;
}

.older-title {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--charcoal);
  text-decoration: none;
  line-height: 1.4;
  transition: color 0.15s;
}

.older-title:hover { color: var(--signal-red); }

/* ── Post Page ───────────────────────────────────────────────────────────── */
.post-container {
  max-width: var(--max-narrow);
  margin: 0 auto;
  padding: 3rem var(--gutter) 4rem;
}

.post-header { margin-bottom: 2.5rem; }

.post-header h1 {
  font-family: var(--font-sans);
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin-bottom: 0.75rem;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--medium-gray);
}

.post-meta time { color: var(--medium-gray); }

.post-categories { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.category {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--signal-red);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(229, 50, 59, 0.08);
  padding: 0.15rem 0.45rem;
}

/* ── Post / Page Content ─────────────────────────────────────────────────── */
.post-content,
.page-content {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.75;
}

.post-content > * + *,
.page-content > * + * { margin-top: 1.35rem; }

.post-content h1, .post-content h2, .post-content h3,
.post-content h4, .post-content h5, .post-content h6,
.page-content h1, .page-content h2, .page-content h3,
.page-content h4, .page-content h5, .page-content h6 {
  font-family: var(--font-sans);
  margin-top: 2.5rem;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.post-content h2, .page-content h2 { font-size: 1.35rem; font-weight: 700; }
.post-content h3, .page-content h3 { font-size: 1.1rem;  font-weight: 700; }

.post-content a, .page-content a { color: var(--signal-red); }
.post-content a:hover, .page-content a:hover { color: var(--signal-red-dark); }

.post-content ul,
.post-content ol,
.page-content ul,
.page-content ol { padding-left: 1.5rem; }

.post-content li + li,
.page-content li + li { margin-top: 0.35rem; }

.post-content blockquote,
.page-content blockquote {
  border-left: 4px solid var(--signal-red);
  padding: 0.25rem 0 0.25rem 1.25rem;
  color: var(--medium-gray);
  font-style: italic;
}

.post-content table,
.page-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.post-content th, .post-content td,
.page-content th, .page-content td {
  text-align: left;
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--border-gray);
}

.post-content th, .page-content th {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--off-white);
}

/* ── Code ───────────────────────────────────────────────────────────────── */
:not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: rgba(229, 50, 59, 0.07);
  border: 1px solid rgba(229, 50, 59, 0.15);
  padding: 0.1em 0.35em;
  color: var(--signal-red);
}

pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.83rem;
  line-height: 1.65;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* ── Prism.js Syntax Highlighting (One Dark) ────────────────────────────── */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata          { color: #5C6370; font-style: italic; }
.token.punctuation    { color: #ABB2BF; }
.token.property,
.token.tag,
.token.constant,
.token.symbol,
.token.deleted        { color: #E06C75; }
.token.boolean,
.token.number         { color: #D19A66; }
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted       { color: #98C379; }
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string  { color: #56B6C2; }
.token.atrule,
.token.attr-value,
.token.keyword        { color: #C678DD; }
.token.function,
.token.class-name     { color: #61AFEF; }
.token.regex,
.token.important,
.token.variable       { color: #E5C07B; }

/* ── Back Link ───────────────────────────────────────────────────────────── */
.back-link {
  display: inline-block;
  margin-top: 3rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--medium-gray);
  text-decoration: none;
  transition: color 0.15s;
}

.back-link:hover { color: var(--signal-red); }

/* ── Page (Writing, etc.) ────────────────────────────────────────────────── */
.page-container {
  max-width: var(--max-narrow);
  margin: 0 auto;
  padding: 3rem var(--gutter) 4rem;
}

.page h1 {
  font-family: var(--font-sans);
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 0.5rem;
  padding-bottom: 1rem;
  border-bottom: 3px solid var(--signal-red);
}

/* ── Anchor links ─────────────────────────────────────────────────────────── */
/* headerLink() mode wraps the full heading text in .header-anchor,
   so opacity tricks hide the heading itself. Just inherit. */
.header-anchor {
  color: inherit;
  text-decoration: none;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .hero-inner { grid-template-columns: 1fr; }
  .error-panel { display: none; }
  .post-grid { grid-template-columns: 1fr; }
  .older-item { grid-template-columns: 90px 1fr; }
  .post-header h1 { font-size: 1.45rem; }
  .page h1 { font-size: 1.45rem; }
  .site-nav { gap: 1.1rem; }
  pre { padding: 1rem; font-size: 0.78rem; }
}

@media (max-width: 480px) {
  :root { --gutter: 1rem; }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .older-item { grid-template-columns: 1fr; gap: 0.15rem; }
  .older-date { display: none; }
}
