/* ==========================================================================
   Niko's Key Patterns — Editorial dark theme
   Aesthetic: Academic dark mode × technical reference × phosphor terminal
   Fonts: Fraunces (display serif) + Source Serif 4 (body) + JetBrains Mono (code)
   ========================================================================== */

/* Google Fonts loaded via <link> in HTML head for non-blocking parallel load */

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

:root {
  --bg:            #0e1117;
  --bg-surface:    #151b28;
  --bg-raised:     #1c2333;
  --text:          #e4dfd4;
  --text-muted:    #6b7585;
  --text-dim:      #9aa3b0;
  --accent:        #3effa8;
  --accent-glow:   rgba(62, 255, 168, 0.15);
  --accent-2:      #fb923c;
  --accent-3:      #60a5fa;
  --border:        #1f2a3c;
  --border-bright: #2e3d55;
  --max-width:     72ch;
  --wide:          1200px;
  --font-display:  'Fraunces', Georgia, serif;
  --font-body:     'Source Serif 4', Georgia, serif;
  --font-mono:     'JetBrains Mono', 'Courier New', monospace;
}

/* ── Base ── */

html {
  font-size: 100%;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(62,255,168,0.05) 0%, transparent 70%),
    linear-gradient(rgba(31,42,60,0.4) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31,42,60,0.4) 1px, transparent 1px);
  background-size: auto, 40px 40px, 40px 40px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Layout ── */

.site-wrapper {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  overflow-x: hidden;
}

header {
  border-bottom: 1px solid var(--border);
  background: rgba(14, 17, 23, 0.9);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  /* Notched phone support */
  padding-top: env(safe-area-inset-top, 0px);
}

.header-inner {
  max-width: var(--wide);
  margin-inline: auto;
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.site-logo {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 300;
  color: var(--text-dim);
  text-decoration: none;
  letter-spacing: -0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.site-logo span {
  color: var(--accent);
  font-weight: 600;
}

nav {
  display: flex;
  gap: 0.15rem;
  flex-wrap: nowrap;
  align-items: center;
}

nav a {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

nav a:hover {
  color: var(--text);
  border-color: var(--border-bright);
  background: var(--bg-surface);
}

nav a[aria-current="page"] {
  color: var(--accent);
  border-color: rgba(62, 255, 168, 0.3);
  background: var(--accent-glow);
}

/* ── Main content area ── */

main {
  max-width: var(--wide);
  margin-inline: auto;
  padding: 3.5rem 1.5rem 4rem;
  width: 100%;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* ── Page hero ── */

.page-hero {
  margin-bottom: 3.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
}

.page-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.page-label::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 1px;
  background: var(--accent);
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 1.25rem;
  font-optical-sizing: auto;
}

h1 em {
  font-style: italic;
  color: var(--accent);
}

.hero-lede {
  font-size: 1.15rem;
  color: var(--text-dim);
  max-width: 60ch;
  line-height: 1.65;
}

.hero-lede strong {
  color: var(--text);
  font-weight: 600;
}

/* ── Hero split — fibonacci golden-ratio layout (φ ≈ 1.618) ── */

.hero-split {
  display: grid;
  grid-template-columns: 1fr 0.618fr;   /* φ ratio: ~61.8% / ~38.2% */
  gap: 3rem;
  align-items: start;
}

.hero-featured {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-featured h1 {
  font-size: clamp(1.6rem, 4vw, 2.6rem);
}

.hero-cta {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  color: var(--accent);
  text-decoration: none;
  padding: 0.6rem 1.2rem;
  border: 1px solid rgba(62, 255, 168, 0.4);
  border-radius: 5px;
  background: var(--accent-glow);
  margin-top: 0.5rem;
  transition: background 0.15s, border-color 0.15s;
  align-self: flex-start;
}

.hero-cta:hover {
  background: rgba(62, 255, 168, 0.18);
  border-color: var(--accent);
  text-decoration: none;
}

/* Right column: blog post list */

.hero-posts {
  border-left: 1px solid var(--border);
  padding-left: 2rem;
}

.hero-posts-heading {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  font-weight: 600;
}

.hero-posts-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.hero-post-item {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.hero-post-item:first-child {
  padding-top: 0;
}

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

.hero-post-item:hover {
  text-decoration: none;
}

.hero-post-item:hover .hero-post-title {
  color: var(--accent);
}

.hero-post-date {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 0.3rem;
}

/* Fibonacci-scaled post titles: each item is ~0.618× the previous */
.hero-post-title {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text);
  display: block;
  line-height: 1.3;
  letter-spacing: -0.01em;
  transition: color 0.15s;
}

.hero-post-item:nth-child(1) .hero-post-title { font-size: 1.15rem; }
.hero-post-item:nth-child(2) .hero-post-title { font-size: 0.95rem; }
.hero-post-item:nth-child(3) .hero-post-title { font-size: 0.82rem; }
.hero-post-item:nth-child(4) .hero-post-title { font-size: 0.72rem; }
.hero-post-item:nth-child(5) .hero-post-title { font-size: 0.68rem; }

.hero-post-desc {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.5;
  display: block;
  margin-top: 0.3rem;
}

/* Only show desc on the first (featured) item */
.hero-post-item:nth-child(n+2) .hero-post-desc {
  display: none;
}

.hero-all-posts {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--accent);
  text-decoration: none;
  margin-top: 1rem;
  transition: text-decoration-color 0.15s;
}

.hero-all-posts:hover {
  text-decoration: underline;
}

@media (max-width: 959px) {
  .hero-split {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  .hero-posts {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
  }
}

/* ── Article body ── */

article {
  animation: fadeUp 0.4s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

h2 {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-top: 3rem;
  margin-bottom: 1rem;
  line-height: 1.2;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

h2 .section-num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 400;
  letter-spacing: 0.05em;
  padding: 0.15em 0.5em;
  border: 1px solid rgba(62, 255, 168, 0.3);
  border-radius: 3px;
  flex-shrink: 0;
  align-self: center;
}

h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
  margin-top: 2rem;
  margin-bottom: 0.6rem;
  line-height: 1.3;
}

p {
  margin-bottom: 1.2em;
  color: var(--text);
}

p + p {
  margin-top: 0;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(62, 255, 168, 0.4);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.15s;
}

a:hover {
  text-decoration-color: var(--accent);
}

/* ── Lists inside article body ── */

article ul,
article ol {
  padding-left: 1.5rem;
  margin-bottom: 1.2em;
}

/* ── h4 — used for labelled sub-entries (e.g. incident logs) ── */

h4 {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  letter-spacing: 0.04em;
  margin-top: 1.2em;
  margin-bottom: 0.4em;
  font-weight: 600;
}

/* ── Callout body paragraph resets margin ── */

.callout p {
  margin: 0;
}

/* ── Page dateline (last-updated line at article end) ── */

.page-dateline {
  color: var(--text-muted);
  margin-top: 3rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

/* ── Card label (date/category line on blog listing cards) ── */

.card-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}

/* ── Back link (bottom of blog posts) ── */

.back-link-wrap {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.back-link {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent);
}

/* ── Sections ── */

section {
  margin-top: 3rem;
}

/* Offset anchor scrolling so sticky header doesn't obscure target */
section[id],
h2[id],
h3[id] {
  scroll-margin-top: 5rem;
}

/* ── Tables ── */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-block: 1.75rem;
  border-radius: 8px;
  border: 1px solid var(--border-bright);
  position: relative;
}

/* Scroll hint: faded right edge on overflowing tables */
.table-wrap::after {
  content: '';
  position: sticky;
  right: 0;
  top: 0;
  bottom: 0;
  width: 2rem;
  pointer-events: none;
  background: linear-gradient(to right, transparent, var(--bg-surface));
  display: block;
  float: right;
  height: 100%;
  margin-top: -100%;
}

@media (min-width: 960px) {
  .table-wrap::after {
    display: none;
  }
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  font-family: var(--font-body);
}

caption {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  padding: 0.75rem 1rem 0.5rem;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg-raised);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-bright);
}

td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text);
}

tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: var(--bg-surface);
}

td:first-child {
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

td code {
  font-size: 0.82em;
}

/* ── Code ── */

code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--bg-raised);
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  padding: 0.15em 0.4em;
  color: var(--accent);
  overflow-wrap: break-word;
  word-break: break-word;
}

pre {
  font-family: var(--font-mono);
  font-size: 0.83rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  line-height: 1.6;
  margin-block: 1.5rem;
  color: var(--text-dim);
  position: relative;
  max-width: 100%;
}

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

/* ── Callout / tip boxes ── */

.callout {
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 1rem 1.25rem;
  margin-block: 1.5rem;
  font-size: 0.95rem;
}

.callout.warn {
  border-left-color: var(--accent-2);
}

.callout-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.callout.warn .callout-label {
  color: var(--accent-2);
}

/* ── Tag badges ── */

.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.2em 0.6em;
  border-radius: 3px;
  border: 1px solid;
  margin-right: 0.3em;
  text-decoration: none;
}

.tag-green  { color: var(--accent);   border-color: rgba(62,255,168,0.4);  background: rgba(62,255,168,0.07);  }
.tag-orange { color: var(--accent-2); border-color: rgba(251,146,60,0.4); background: rgba(251,146,60,0.07); }
.tag-blue   { color: var(--accent-3); border-color: rgba(96,165,250,0.4); background: rgba(96,165,250,0.07); }
.tag-red    { color: #f87171;         border-color: rgba(248,113,113,0.4); background: rgba(248,113,113,0.07); }

/* ── Card grid ── */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-block: 1.75rem;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  padding: 1.25rem 1.25rem 1rem;
  transition: border-color 0.15s, background 0.15s;
  text-decoration: none;
  display: block;
  color: inherit;
}

.card:hover {
  border-color: rgba(62, 255, 168, 0.4);
  background: var(--bg-raised);
  text-decoration: none;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
  letter-spacing: -0.01em;
}

.card-desc {
  font-size: 0.88rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 0;
}

/* ── Inline metric highlights ── */

.metric {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.03em;
  display: block;
  line-height: 1;
  margin-bottom: 0.15rem;
}

.metric-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.metrics-row {
  display: flex;
  gap: 2.5rem;
  margin-block: 2rem;
  flex-wrap: wrap;
}

/* ── Footer ── */

footer {
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}

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

.footer-copy {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

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

.footer-links a {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color 0.15s;
}

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

/* ── Time elements ── */

time {
  font-variant-numeric: tabular-nums;
}

/* ── Hidden checkbox for pure-CSS hamburger toggle ── */

.menu-checkbox {
  display: none;
}

/* ── Hamburger nav toggle label (hidden on desktop) ── */

.nav-toggle {
  display: none; /* hidden by default; shown only in mobile query */
  background: var(--bg-raised);
  border: 1px solid var(--text-muted);
  border-radius: 4px;
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  flex-shrink: 0;
  /* Touch-friendly hit area */
  min-width: 44px;
  min-height: 44px;
  align-items: center;
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.25s ease, opacity 0.2s ease;
}

/* ── Nav overlay (mobile only) ── */

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 90;
  cursor: pointer;
}

header:has(.menu-checkbox:checked) ~ .nav-overlay {
  display: block;
}

/* ── Responsive ── */

/* ─ Desktop: ≥ 1200px — full width content uses --wide naturally ─ */

/* ─ Tablet: 768px – 1199px ─ */
@media (max-width: 1199px) {
  .header-inner {
    padding: 0.75rem 1.5rem;
    gap: 1rem;
  }
  main {
    padding: 2.5rem 1.5rem 3.5rem;
  }
}

/* ─ Tablet narrow: 768px – 959px — nav fits but gets tighter ─ */
@media (max-width: 959px) {
  .header-inner {
    padding: 0.7rem 1.25rem;
  }
  nav a {
    font-size: 0.64rem;
    padding: 0.3rem 0.45rem;
    letter-spacing: 0.03em;
  }
  main {
    padding: 2rem 1.25rem 3rem;
  }
}

/* ─ Mobile: < 768px — hamburger drawer ─ */
@media (max-width: 767px) {
  .header-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    padding-left: max(1rem, env(safe-area-inset-left, 1rem));
    padding-right: max(1rem, env(safe-area-inset-right, 1rem));
    gap: 0;
    position: relative;
  }
  .site-logo {
    font-size: 1.15rem;
  }
  .nav-toggle {
    display: flex;
  }
  /* Animated slide-down mobile nav */
  nav {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(14, 17, 23, 0.98);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-bright);
    padding: 0 1rem;
    gap: 0;
    z-index: 200;
    /* Hidden state */
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
      max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1),
      opacity 0.22s ease,
      visibility 0s linear 0.22s;
  }
  .menu-checkbox:checked ~ nav {
    max-height: 480px; /* fits all 7 nav items with room */
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    padding: 0.4rem 1rem 0.75rem;
    transition:
      max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1),
      opacity 0.22s ease,
      visibility 0s linear 0s;
  }
  nav a {
    font-size: 0.78rem;
    /* 44px minimum touch target height */
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0 0.5rem;
    letter-spacing: 0.04em;
    flex-shrink: unset;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    white-space: nowrap;
  }
  nav a:last-child {
    border-bottom: none;
  }
  .menu-checkbox:checked + .nav-toggle span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }
  .menu-checkbox:checked + .nav-toggle span:nth-child(2) {
    opacity: 0;
  }
  .menu-checkbox:checked + .nav-toggle span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }
  h1 { font-size: 1.75rem; }
  .metrics-row { gap: 1.5rem; }
  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom, 1.5rem));
  }
  main {
    padding: 2rem 1rem 3rem;
    padding-left: max(1rem, env(safe-area-inset-left, 1rem));
    padding-right: max(1rem, env(safe-area-inset-right, 1rem));
  }
}

/* ─ Small mobile: < 480px ─ */
@media (max-width: 479px) {
  h1 { font-size: 1.55rem; }
  .hero-lede { font-size: 1rem; }
  main { padding: 1.5rem 1rem 2.5rem; }

  /* Allow h2 badge + text to wrap on narrow screens */
  h2 {
    flex-wrap: wrap;
    gap: 0.4rem 0.6rem;
  }

  /* Allow first-column table cells to wrap */
  td:first-child {
    white-space: normal;
  }

  /* Metrics: spread evenly in a row */
  .metrics-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    text-align: center;
  }
  .metric {
    font-size: 1.8rem;
  }

  /* Cards: full-width single column on very small screens */
  .card-grid {
    grid-template-columns: 1fr;
  }

  /* Slightly smaller pre text to reduce horizontal overflow */
  pre {
    font-size: 0.76rem;
    padding: 1rem 0.875rem;
  }
}

/* ── Selection ── */

::selection {
  background: rgba(62, 255, 168, 0.2);
  color: var(--text);
}

/* ── Scrollbar ── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }


/* ── Prose max-width — readable line length at large viewports ── */

article p,
article li,
article h3 {
  max-width: min(var(--max-width), 100%);
}

.hero-lede {
  max-width: min(60ch, 100%);
}

/* ── Reduced motion ── */

@media (min-width: 768px) {
  .nav-toggle,
  .menu-checkbox { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  article { animation: none; }
  .nav-toggle span { transition: none; }
  nav { transition: none !important; }
}


/* ── Related posts ── */

.related-posts {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.related-posts-heading {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.related-post {
  display: block;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s;
}

.related-post:hover {
  border-color: var(--accent);
  background: var(--bg-raised);
}

.related-post-category {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.related-post-title {
  display: block;
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--text);
  line-height: 1.35;
  margin-bottom: 0.3rem;
}

.related-post-desc {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.45;
}


/* ── Post prev/next navigation ── */

.post-nav {
  display: flex;
  gap: 1.5rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.post-nav-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s;
}

.post-nav-link:hover {
  border-color: var(--accent);
  background: var(--bg-raised);
}

.post-nav-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.post-nav-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.35;
}

.post-nav-older {
  text-align: right;
}

.post-nav-placeholder {
  border: none;
  background: none;
}

@media (max-width: 600px) {
  .post-nav {
    flex-direction: column;
    gap: 1rem;
  }
  .post-nav-older {
    text-align: left;
  }
}


/* ── Back to top button ── */

.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-raised);
  border: 1px solid var(--border-bright);
  border-radius: 50%;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 1.25rem;
  line-height: 1;
  transition: background 0.2s, color 0.2s, border-color 0.2s, opacity 0.3s;
  z-index: 90;
  opacity: 0;
  pointer-events: none;
}

.back-to-top.visible {
  opacity: 0.7;
  pointer-events: auto;
}

.back-to-top:hover {
  background: var(--bg-surface);
  color: var(--accent);
  border-color: var(--accent);
  opacity: 1;
}

@media (max-width: 600px) {
  .back-to-top {
    bottom: 1.25rem;
    right: 1.25rem;
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.1rem;
  }
}
