/* =====================================================
   64c Blog — Accessible CRT Theme
   Reuses OS color palette, but readable and semantic.
   ===================================================== */

:root {
  --green:        #00ff41;
  --green-dim:    #00cc33;
  --green-dark:   #005c1a;
  --bg:           #060c06;
  --bg-panel:     #0b160b;
  --border:       #183018;
  --border-hi:    #2a5a2a;
  --text:         #c8e8c8;
  --text-dim:     #8aba8a;
  --text-muted:   #5a7a5a;
  --max-width:    720px;
}

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

/* Critical: ensure [hidden] always hides, even when display:flex is set */
[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', Courier, monospace;
  font-size: 16px;
  line-height: 1.8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Hypercube background — same as OS but dimmer for readability */
#hypercube-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.4;
}

/* CRT scanlines overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* Roaming CRT scan beam — same as OS */
body::before {
  content: '';
  position: fixed;
  left: 0;
  right: 0;
  top: -5%;
  height: 12px;
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(0, 255, 65, 0.02) 30%,
    rgba(0, 255, 65, 0.05) 50%,
    rgba(0, 255, 65, 0.02) 70%,
    transparent
  );
  pointer-events: none;
  z-index: 9998;
  opacity: 0;
  animation: crtBeam 18s linear infinite;
}

@keyframes crtBeam {
  0%   { top: -5%;  opacity: 0; }
  3%   { opacity: 1; }
  44%  { top: 105%; opacity: 1; }
  47%  { opacity: 0; }
  100% { top: 105%; opacity: 0; }
}

/* ── Skip Link ──────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--green);
  color: var(--bg);
  padding: 8px 16px;
  font-size: 14px;
  text-decoration: none;
  z-index: 10000;
  transition: top 0.15s;
}
.skip-link:focus {
  top: 0;
}

/* ── Header ─────────────────────────────────────────── */
.site-header {
  position: relative;
  z-index: 1;
  border-bottom: 1px solid var(--border-hi);
  background: var(--bg-panel);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.back-to-os {
  color: var(--green-dim);
  text-decoration: none;
  font-size: 0.8125rem;
  padding: 5px 12px;
  border: 1px solid var(--border-hi);
  transition: border-color 0.12s, color 0.12s;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
}
.back-to-os:hover,
.back-to-os:focus-visible {
  border-color: var(--green);
  color: var(--green);
  outline: none;
}

.blog-badge {
  font-size: 0.8125rem;
  font-weight: bold;
  color: var(--green);
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 5px 12px;
  border: 1px solid var(--green);
  background: rgba(0, 255, 65, 0.08);
  white-space: nowrap;
}

/* ── Navigation ─────────────────────────────────────── */
.blog-nav {
  position: relative;
  z-index: 1;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  padding: 8px 24px;
}

.blog-nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.8125rem;
  padding: 4px 10px;
  border: 1px solid var(--border);
  transition: border-color 0.12s, color 0.12s;
}
.blog-nav a:hover,
.blog-nav a:focus-visible {
  border-color: var(--green-dim);
  color: var(--green);
  outline: none;
}

/* ── Main ───────────────────────────────────────────── */
main {
  flex: 1;
  position: relative;
  z-index: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 48px;
}
main:focus {
  outline: none;
}

/* ── Blog List ──────────────────────────────────────── */
.blog-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.blog-card {
  border: 1px solid var(--border);
  background: var(--bg-panel);
  padding: 20px 24px;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: border-color 0.15s, background 0.15s;
}
.blog-card:hover,
.blog-card:focus-visible {
  border-color: var(--border-hi);
  background: rgba(0, 255, 65, 0.03);
  outline: none;
}

.blog-card-title {
  font-size: 1.25rem;
  color: var(--green);
  margin-bottom: 6px;
}

.blog-card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.blog-card-preview {
  font-size: 0.9375rem;
  color: var(--text-dim);
  line-height: 1.7;
}

/* ── Blog Detail ────────────────────────────────────── */
.blog-detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--green-dim);
  text-decoration: none;
  font-size: 0.875rem;
  margin-bottom: 24px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  transition: border-color 0.12s, color 0.12s;
}
.blog-detail-back:hover,
.blog-detail-back:focus-visible {
  border-color: var(--green);
  color: var(--green);
  outline: none;
}

.blog-detail-title {
  font-size: 1.75rem;
  color: var(--green);
  margin-bottom: 8px;
  line-height: 1.3;
}

.blog-detail-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.blog-detail-body {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text);
}

.blog-detail-body h1,
.blog-detail-body h2,
.blog-detail-body h3,
.blog-detail-body h4 {
  color: var(--green);
  font-size: 1.25rem;
  margin: 24px 0 10px;
  line-height: 1.4;
}

.blog-detail-body h2 { font-size: 1.375rem; }
.blog-detail-body h1 { font-size: 1.5rem; }

.blog-detail-body p {
  margin-bottom: 16px;
}

.blog-detail-body img {
  max-width: 100%;
  border: 1px solid var(--border);
  margin: 12px 0;
  display: block;
  border-radius: 2px;
}

.blog-detail-body a {
  color: var(--green-dim);
}

.blog-detail-body ul,
.blog-detail-body ol {
  padding-left: 24px;
  margin-bottom: 16px;
}

.blog-detail-body li {
  margin-bottom: 6px;
}

.blog-detail-body code {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 5px;
  font-family: inherit;
  color: var(--green-dim);
  font-size: 0.875em;
}

.blog-detail-body pre {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 12px 0;
  font-size: 0.875rem;
  line-height: 1.6;
  border-radius: 2px;
}

.blog-detail-body pre code {
  border: none;
  padding: 0;
  background: none;
}

.blog-detail-body blockquote {
  border-left: 3px solid var(--green-dark);
  padding-left: 16px;
  margin: 16px 0;
  color: var(--text-dim);
  font-style: italic;
}

/* ── Loading / Error ────────────────────────────────── */
.blog-loading {
  text-align: center;
  padding: 60px 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.blog-loading p {
  margin-top: 12px;
}

.spin-loader {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-hi);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.blog-error {
  text-align: center;
  padding: 40px 20px;
  color: #ff6b6b;
  font-size: 0.9375rem;
}
.blog-error p { margin-bottom: 16px; }

.os-btn {
  background: transparent;
  border: 1px solid var(--border-hi);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.875rem;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.12s;
}
.os-btn:hover,
.os-btn:focus-visible {
  border-color: var(--green);
  color: var(--green);
  outline: none;
}

/* ── Footer ─────────────────────────────────────────── */
.site-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border-hi);
  background: var(--bg-panel);
  padding: 16px 24px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.site-footer a {
  color: var(--text-dim);
  text-decoration: none;
}
.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--green);
  outline: none;
}

/* ── Focus Ring (global) ────────────────────────────── */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* ── Reduced Motion ─────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  #hypercube-bg { display: none; }
  body::before { animation: none; display: none; }
  body::after { display: none; }
  .spin-loader { animation: none; border-top-color: var(--green-dim); }
  * { transition: none !important; }
}

/* ── Mobile ─────────────────────────────────────────── */
@media (max-width: 600px) {
  body { font-size: 15px; }
  .site-header { padding: 12px 14px; gap: 8px; }
  .back-to-os, .blog-badge { font-size: 0.75rem; padding: 4px 8px; letter-spacing: 1px; }
  main { padding: 20px 16px 32px; }
  .blog-card { padding: 16px 18px; }
  .blog-card-title { font-size: 1.0625rem; }
  .blog-detail-title { font-size: 1.375rem; }
  .blog-detail-body { font-size: 0.9375rem; }
}
