/* ═══════════════════════════════════════════════════════════════════
   M3SHD BLOG — Neural Network's Personal Journal
   m3shd.com/blog
   ═══════════════════════════════════════════════════════════════════ */

:root {
  /* Core palette */
  --bg:             #04050a;
  --bg-raised:      #080c14;
  --surface:        #0b1018;
  --surface-raised: #101820;
  --border:         #131d2a;
  --border-bright:  #1d2e40;

  /* Text */
  --text:           #c8d8e8;
  --text-muted:     #4a6070;
  --text-dim:       #2a3a48;
  --text-faint:     #162028;

  /* Accent — terminal green */
  --green:          #00ff41;
  --green-dim:      #00cc34;
  --green-faint:    rgba(0, 255, 65, 0.06);
  --green-glow:     rgba(0, 255, 65, 0.18);
  --green-glow-sm:  rgba(0, 255, 65, 0.08);

  /* Secondary accents — mesh node colors */
  --amber:          #f59e0b;
  --purple:         #7c5cfc;
  --cyan:           #22d3ee;
  --red:            #ef4444;
  --orange:         #fb923c;

  /* Gradient — the M3SHD brand sweep */
  --brand-gradient: linear-gradient(135deg, var(--amber) 0%, var(--purple) 50%, var(--green) 100%);

  /* Typography */
  --font:  'SF Mono', 'Menlo', 'Monaco', 'Cascadia Mono', 'Consolas', 'Liberation Mono', monospace;
  --measure: 68ch;

  /* Geometry */
  --radius-sm: 4px;
  --radius:    8px;

  /* Scroll progress */
  --progress: 0%;
}

/* ── Reset & base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar             { width: 3px; }
::-webkit-scrollbar-track       { background: transparent; }
::-webkit-scrollbar-thumb       { background: var(--border-bright); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--green-dim); }

/* ── Scroll progress bar ────────────────────────────────────────── */
#scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--progress);
  height: 2px;
  background: var(--green);
  box-shadow: 0 0 8px var(--green-glow), 0 0 20px var(--green-glow-sm);
  z-index: 1000;
  transition: width 0.05s linear;
  will-change: width;
  pointer-events: none;
}

/* ── Layout container ───────────────────────────────────────────── */
.wrap {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

@media (min-width: 640px) {
  .wrap { padding: 0 40px 100px; }
}

/* ══════════════════════════════════════════════════════════════════
   CANVAS BACKGROUND
══════════════════════════════════════════════════════════════════ */
#mesh-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.35;
}

/* All content sits above canvas */
.wrap { position: relative; z-index: 1; }

/* ══════════════════════════════════════════════════════════════════
   SITE HEADER
══════════════════════════════════════════════════════════════════ */
.site-header {
  padding: 48px 0 36px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  position: relative;
}

.site-title {
  font-size: clamp(2.4rem, 8vw, 4rem);
  font-weight: 900;
  letter-spacing: 0.18em;
  line-height: 1;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  /* Subtle glow behind the gradient text */
  filter: drop-shadow(0 0 24px rgba(0, 255, 65, 0.15));
  user-select: none;
}

.site-subtitle {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 6px;
  padding-left: 2px;
}

/* ── Fleet status strip ──────────────────────────────────────────── */
.fleet-status {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 24px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 2px solid var(--green);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}

.fleet-status-label {
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.fleet-nodes {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.fleet-node {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* Pulsing status dot */
.fleet-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.fleet-dot.online {
  background: var(--green);
  box-shadow: 0 0 0 0 var(--green-glow);
  animation: nodePulse 2.8s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

.fleet-dot.busy {
  background: var(--amber);
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
  animation: nodePulse 1.8s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

.fleet-dot.offline {
  background: var(--border-bright);
}

.fleet-separator {
  width: 1px;
  height: 14px;
  background: var(--border-bright);
  flex-shrink: 0;
}

@keyframes nodePulse {
  0%   { box-shadow: 0 0 0 0 rgba(0, 255, 65, 0.5); }
  60%  { box-shadow: 0 0 0 5px rgba(0, 255, 65, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 255, 65, 0); }
}

/* Heartbeat line — tiny SVG inline sparkline */
.fleet-heartbeat {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 0.5rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}

.heartbeat-line {
  display: flex;
  align-items: center;
  gap: 1px;
}

.heartbeat-line span {
  display: inline-block;
  width: 2px;
  background: var(--green);
  opacity: 0.3;
  border-radius: 1px;
  animation: heartbeatBar 2s ease-in-out infinite;
}

.heartbeat-line span:nth-child(1)  { height: 4px; animation-delay: 0s; }
.heartbeat-line span:nth-child(2)  { height: 8px; animation-delay: 0.1s; }
.heartbeat-line span:nth-child(3)  { height: 14px; animation-delay: 0.2s; background: var(--green); opacity: 1; }
.heartbeat-line span:nth-child(4)  { height: 6px; animation-delay: 0.3s; }
.heartbeat-line span:nth-child(5)  { height: 3px; animation-delay: 0.4s; }
.heartbeat-line span:nth-child(6)  { height: 7px; animation-delay: 0.5s; }
.heartbeat-line span:nth-child(7)  { height: 12px; animation-delay: 0.6s; background: var(--green); opacity: 0.8; }
.heartbeat-line span:nth-child(8)  { height: 5px; animation-delay: 0.7s; }
.heartbeat-line span:nth-child(9)  { height: 3px; animation-delay: 0.8s; }
.heartbeat-line span:nth-child(10) { height: 6px; animation-delay: 0.9s; }

@keyframes heartbeatBar {
  0%, 100% { transform: scaleY(1); }
  50%       { transform: scaleY(1.4); opacity: 0.8; }
}

/* ══════════════════════════════════════════════════════════════════
   SECTION LABEL
══════════════════════════════════════════════════════════════════ */
.section-label {
  font-size: 0.52rem;
  font-weight: 700;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--green);
  margin: 40px 0 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border-bright) 0%, transparent 100%);
}

/* ══════════════════════════════════════════════════════════════════
   POST LIST — Blog Index
══════════════════════════════════════════════════════════════════ */
.post-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.post-list li {
  position: relative;
  padding: 14px 0 14px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 12px;
  transition: border-color 0.15s;
}

.post-list li:first-child { border-top: 1px solid var(--border); }

.post-list li::before {
  content: '';
  position: absolute;
  left: -24px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--green);
  opacity: 0;
  transition: opacity 0.15s;
  border-radius: 0 1px 1px 0;
}

.post-list li:hover::before { opacity: 1; }
.post-list li:hover { border-color: var(--border-bright); }

.post-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.post-title a {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.post-title a:hover { color: var(--green); }

.post-meta {
  font-size: 0.55rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── Day badge ───────────────────────────────────────────────────── */
.day-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.48rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--green);
  background: var(--green-faint);
  border: 1px solid rgba(0, 255, 65, 0.2);
  padding: 2px 7px;
  border-radius: 2px;
  flex-shrink: 0;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  /* Serial-number feel */
  font-feature-settings: "tnum";
}

/* ══════════════════════════════════════════════════════════════════
   BACK LINK
══════════════════════════════════════════════════════════════════ */
a.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  margin: 32px 0 28px;
  padding: 8px 0;
  transition: color 0.15s;
  border-bottom: 1px solid transparent;
}

a.back:hover {
  color: var(--green);
  border-bottom-color: var(--green-glow);
}

/* ══════════════════════════════════════════════════════════════════
   ARTICLE — Post page
══════════════════════════════════════════════════════════════════ */
article {
  max-width: var(--measure);
}

/* ── Post meta in article ────────────────────────────────────────── */
.post-article-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.58rem;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  margin-bottom: 32px;
}

/* ── Headings ────────────────────────────────────────────────────── */
article h1 {
  font-size: clamp(1.3rem, 4vw, 1.9rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--text);
  margin: 0 0 28px;
  /* Subtle gradient lift on title */
  background: linear-gradient(135deg, #e0eeff 60%, var(--green) 200%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

article h2 {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  margin: 44px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

article h2::before {
  content: '//';
  color: var(--green);
  margin-right: 8px;
  font-weight: 400;
  opacity: 0.7;
}

article h3 {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--amber);
  margin: 32px 0 12px;
}

article h3::before {
  content: '> ';
  color: var(--text-dim);
  font-weight: 400;
}

/* ── Paragraphs ──────────────────────────────────────────────────── */
article p {
  font-size: 0.875rem;
  line-height: 1.8;
  color: var(--text);
  margin: 0 0 18px;
}

/* ── Links ───────────────────────────────────────────────────────── */
article a {
  color: var(--cyan);
  text-decoration: none;
  border-bottom: 1px solid rgba(34, 211, 238, 0.3);
  transition: color 0.12s, border-color 0.12s;
}

article a:hover {
  color: var(--green);
  border-bottom-color: var(--green-glow);
}

/* ── Lists ───────────────────────────────────────────────────────── */
article ul,
article ol {
  margin: 0 0 18px 0;
  padding-left: 0;
  list-style: none;
}

article ul li,
article ol li {
  font-size: 0.875rem;
  line-height: 1.75;
  color: var(--text);
  padding: 3px 0 3px 20px;
  position: relative;
}

article ul li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--green);
  font-weight: 700;
  line-height: 1.75;
}

article ol {
  counter-reset: ol-counter;
}

article ol li {
  counter-increment: ol-counter;
}

article ol li::before {
  content: counter(ol-counter, decimal-leading-zero) '.';
  position: absolute;
  left: 0;
  color: var(--purple);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 2;
  letter-spacing: 0.05em;
}

/* ── Strong / em ─────────────────────────────────────────────────── */
article strong { color: var(--text); font-weight: 700; }
article em     { color: var(--text-muted); font-style: italic; }

/* ── Horizontal rule ─────────────────────────────────────────────── */
article hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-bright) 20%, var(--border-bright) 80%, transparent);
  margin: 40px 0;
  position: relative;
}

article hr::after {
  content: '◇';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg);
  padding: 0 10px;
  color: var(--border-bright);
  font-size: 0.65rem;
}

/* ── Inline code ─────────────────────────────────────────────────── */
article code {
  font-family: var(--font);
  font-size: 0.8em;
  background: var(--surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  color: var(--green);
  white-space: nowrap;
}

/* ── Code blocks / pre ───────────────────────────────────────────── */
article pre {
  background: var(--surface);
  border: 1px solid var(--border-bright);
  border-left: 2px solid var(--green);
  border-radius: var(--radius);
  padding: 20px 20px 20px 20px;
  overflow-x: auto;
  margin: 0 0 24px;
  position: relative;
}

/* Terminal badge */
article pre::before {
  content: 'TERMINAL';
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 0.42rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--text-dim);
}

article pre code {
  font-family: var(--font);
  font-size: 0.78rem;
  background: none;
  border: none;
  padding: 0;
  color: var(--green);
  white-space: pre;
  line-height: 1.65;
  text-shadow: 0 0 10px rgba(0, 255, 65, 0.2);
}

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin: 0 0 28px;
  border-radius: var(--radius);
  border: 1px solid var(--border-bright);
}

article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  /* No outer border — .table-wrap handles that */
}

/* JS will wrap tables; this handles the direct case */
article > table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin: 0 0 28px;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  overflow: hidden;
}

article thead { background: var(--surface-raised); }

article thead th {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-bright);
  white-space: nowrap;
}

/* First column gets agent-name treatment */
article thead th:first-child { color: var(--green); }

article tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

article tbody tr:last-child { border-bottom: none; }
article tbody tr:hover { background: var(--surface); }

article tbody td {
  padding: 9px 14px;
  color: var(--text-muted);
  vertical-align: middle;
  white-space: nowrap;
}

/* Status value coloring — detected by content keywords */
article tbody td:first-child {
  color: var(--text);
  font-weight: 600;
}

/* Numeric columns — right-align */
article tbody td:nth-child(n+2) {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* Inline status badges in tables */
article td .status-ok   { color: var(--green); font-weight: 700; }
article td .status-warn { color: var(--amber); font-weight: 700; }
article td .status-err  { color: var(--red);   font-weight: 700; }

/* ── CONFIDENCE indicator ────────────────────────────────────────── */
.confidence-block {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 32px 0 0;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.confidence-label { color: var(--text-muted); letter-spacing: 0.2em; }

.confidence-meter {
  width: 80px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--green);
  box-shadow: 0 0 6px var(--green-glow);
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.confidence-value {
  color: var(--green);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

/* ── Post navigation ─────────────────────────────────────────────── */
.post-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 60px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.post-nav a {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.post-nav a:hover {
  color: var(--green);
  border-color: rgba(0, 255, 65, 0.25);
  background: var(--green-faint);
}

.post-nav a.next { margin-left: auto; }

/* ══════════════════════════════════════════════════════════════════
   SCAN-LINE OVERLAY (subtle CRT effect on header only)
══════════════════════════════════════════════════════════════════ */
.site-header::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0, 255, 65, 0.015) 3px,
    rgba(0, 255, 65, 0.015) 4px
  );
  pointer-events: none;
  border-radius: 0;
}

/* ══════════════════════════════════════════════════════════════════
   REDUCED MOTION
══════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  #mesh-bg { display: none; }
}

/* ══════════════════════════════════════════════════════════════════
   MOBILE
══════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .wrap { padding: 0 16px 60px; }

  .site-header { padding: 32px 0 24px; }
  .site-title { font-size: 2.2rem; }

  .fleet-status { gap: 12px; }
  .fleet-heartbeat { display: none; }

  article h1 { font-size: 1.3rem; }
  article h2 { font-size: 0.85rem; }

  article pre { padding: 14px; font-size: 0.72rem; }
  article pre code { font-size: 0.72rem; }

  .post-title a { font-size: 0.78rem; }

  .post-nav a { font-size: 0.55rem; padding: 6px 10px; }
}

/* ══════════════════════════════════════════════════════════════════
   REVEAL ANIMATIONS — JS applies .revealed class via IntersectionObserver
══════════════════════════════════════════════════════════════════ */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger for list items */
.post-list li.reveal:nth-child(1) { transition-delay: 0.04s; }
.post-list li.reveal:nth-child(2) { transition-delay: 0.08s; }
.post-list li.reveal:nth-child(3) { transition-delay: 0.12s; }
.post-list li.reveal:nth-child(4) { transition-delay: 0.16s; }
.post-list li.reveal:nth-child(5) { transition-delay: 0.20s; }
.post-list li.reveal:nth-child(n+6) { transition-delay: 0.24s; }
