/* === Google Fonts === */
@import url('https://fonts.googleapis.com/css2?family=Calistoga:ital@0;1&family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* === CSS Variables === */
:root {
  --c-red: #ff0000;
  --c-pink: #ff006e;
  --c-dark: #1a1a2e;
  --c-darker: #0d0d1a;
  --c-mid: #16213e;
  --c-surface: #1e1e3a;
  --c-border: rgba(255, 0, 110, 0.35);
  --c-text: #e8e8f0;
  --c-muted: #9999bb;
  --c-cyan: #00f5ff;
  --c-yellow: #ffe600;
  --font-head: 'Calistoga', serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --nav-w: 220px;
  --radius: 18px;
  --radius-sm: 8px;
  --glow-red: 0 0 8px #ff0000, 0 0 20px rgba(255,0,0,0.4);
  --glow-pink: 0 0 8px #ff006e, 0 0 20px rgba(255,0,110,0.4);
  --glow-cyan: 0 0 8px #00f5ff, 0 0 20px rgba(0,245,255,0.3);
  --transition: 0.22s ease;
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--c-darker);
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--c-pink); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--c-cyan); }
ul { list-style: none; }

/* === CRT Scanlines Overlay === */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.04) 0px,
    rgba(0,0,0,0.04) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 9999;
  animation: crt-flicker 8s infinite;
}

@keyframes crt-flicker {
  0%, 96%, 100% { opacity: 1; }
  97% { opacity: 0.92; }
  98% { opacity: 1; }
  99% { opacity: 0.95; }
}

/* === Screen Reader Only === */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* === Site Shell: sidebar nav + content === */
.site-shell {
  display: flex;
  flex-direction: row;
  min-height: 100vh;
  position: relative;
}

/* === Header / Left Nav === */
.site-header {
  position: fixed;
  left: 0; top: 0;
  width: var(--nav-w);
  height: 100vh;
  background: var(--c-mid);
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Brand Icon */
.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 72px;
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}
.brand-glyph {
  font-family: var(--font-head);
  font-size: 2rem;
  color: var(--c-red);
  text-shadow: var(--glow-red);
  letter-spacing: -1px;
}
.brand-icon img {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--c-pink);
  box-shadow: var(--glow-pink);
}

/* Nav links */
.main-nav {
  flex: 1;
  padding: 1rem 0;
}
.main-nav p {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.main-nav p a {
  display: block;
  padding: 0.75rem 1.25rem;
  font-size: 0.82rem;
  font-family: var(--font-mono);
  color: var(--c-muted);
  border-left: 3px solid transparent;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  line-height: 1.4;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.main-nav p a:hover,
.main-nav p a[aria-current="page"] {
  color: var(--c-cyan);
  border-left-color: var(--c-pink);
  background: rgba(255,0,110,0.08);
  text-shadow: var(--glow-cyan);
}

/* Search */
.nav-search {
  padding: 1rem;
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
}
.search-input {
  width: 100%;
  background: var(--c-darker);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  color: var(--c-text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.6rem 0.75rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 40px;
}
.search-input:focus {
  border-color: var(--c-pink);
  box-shadow: var(--glow-pink);
}
.search-input::placeholder { color: var(--c-muted); }

/* === Main Content === */
.site-main {
  margin-left: var(--nav-w);
  flex: 1;
  min-width: 0;
}

/* === Hero Section (home only) === */
.hero-section {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  background: var(--c-darker);
}
.hero-media {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.hero-media .hero-img {
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0.35;
  filter: saturate(1.4) hue-rotate(-10deg);
}
.hero-section::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--c-darker) 35%, rgba(26,26,46,0.7) 70%, transparent 100%);
  z-index: 1;
}
.hero-text {
  position: relative;
  z-index: 2;
  text-align: right;
  padding: 3rem 3rem 4rem;
  max-width: 820px;
  margin-left: auto;
}
.hero-badge {
  display: inline-block;
  margin-bottom: 1rem;
}
.hero-h1 {
  font-family: var(--font-head);
  font-size: clamp(2.4rem, 6vw, 5rem);
  color: #fff;
  text-shadow: var(--glow-red), 0 2px 30px rgba(255,0,110,0.5);
  line-height: 1.15;
  margin-bottom: 1rem;
  animation: glitch-hero 6s infinite;
}
@keyframes glitch-hero {
  0%, 90%, 100% { transform: none; }
  91% { transform: skewX(-2deg) translateX(3px); }
  92% { transform: skewX(1deg) translateX(-2px); }
  93% { transform: none; }
}
.hero-lead {
  font-size: 1.1rem;
  color: var(--c-muted);
  margin-bottom: 2rem;
  max-width: 480px;
  margin-left: auto;
}

/* === Pixel Badge === */
.pixel-badge {
  display: inline-flex;
  align-items: center;
  background: var(--c-red);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  padding: 0.3em 0.8em;
  border-radius: 4px;
  text-transform: uppercase;
  box-shadow: var(--glow-red);
  margin-bottom: 0.75rem;
}

/* === Buttons === */
.btn-neon {
  display: inline-flex;
  align-items: center;
  padding: 0.75rem 1.8rem;
  background: transparent;
  border: 2px solid var(--c-red);
  color: var(--c-red);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-shadow: var(--glow-red);
  box-shadow: var(--glow-red);
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
  min-height: 44px;
}
.btn-neon:hover {
  background: var(--c-red);
  color: #fff;
  box-shadow: 0 0 16px #ff0000, 0 0 40px rgba(255,0,0,0.5);
}
.btn-outline {
  display: inline-flex;
  align-items: center;
  padding: 0.6rem 1.4rem;
  border: 1px solid var(--c-border);
  color: var(--c-muted);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), color var(--transition);
  min-height: 40px;
}
.btn-outline:hover {
  border-color: var(--c-pink);
  color: var(--c-pink);
}

/* === Wrap + Content Layout === */
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
}

.content-section {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
}

/* === Sidebar (left) === */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 2rem;
}
.aside-title {
  font-family: var(--font-head);
  font-size: 1rem;
  color: var(--c-pink);
  text-shadow: var(--glow-pink);
  margin-bottom: 0.5rem;
}
.sidebar hr {
  border: none;
  border-top: 1px solid var(--c-border);
  margin-bottom: 0.75rem;
}
.aside-links {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.aside-links li a {
  display: block;
  font-size: 0.84rem;
  font-family: var(--font-mono);
  color: var(--c-muted);
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  min-height: 40px;
  display: flex;
  align-items: center;
}
.aside-links li a:hover {
  color: var(--c-cyan);
  background: rgba(0,245,255,0.06);
}
.tag-links .tag-pill {
  border: 1px solid var(--c-border);
  border-radius: 20px;
  padding: 0.3em 0.8em;
  font-size: 0.78rem;
  margin-bottom: 0.2rem;
}
.tag-links .tag-pill:hover {
  border-color: var(--c-pink);
  background: rgba(255,0,110,0.1);
}
.aside-parent, .aside-back {
  margin-bottom: 1rem;
}
.aside-parent a, .aside-back a {
  font-size: 0.82rem;
  font-family: var(--font-mono);
  color: var(--c-muted);
}
.aside-nav-links {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 1rem;
}
.aside-nav-links a {
  font-size: 0.82rem;
  font-family: var(--font-mono);
  color: var(--c-muted);
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 0.2rem 0;
}

/* === Main Article === */
.main-article {
  flex: 1;
  min-width: 0;
}
.section-eyebrow {
  margin-bottom: 0.75rem;
}
.page-h1 {
  font-family: var(--font-head);
  font-size: clamp(1.8rem, 4vw, 3rem);
  color: #fff;
  text-shadow: var(--glow-red);
  line-height: 1.2;
  margin-bottom: 0.75rem;
}
.page-date, .page-date-mod {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--c-muted);
  margin-bottom: 1.25rem;
  margin-right: 1rem;
}

/* === Page Content (injected HTML) === */
.page-content {
  color: var(--c-text);
  font-size: 1rem;
  line-height: 1.8;
}
.page-content h2 {
  font-family: var(--font-head);
  font-size: 1.5rem;
  color: var(--c-pink);
  margin: 2rem 0 0.5rem;
  text-shadow: var(--glow-pink);
}
.page-content h3 {
  font-family: var(--font-head);
  font-size: 1.2rem;
  color: var(--c-cyan);
  margin: 1.5rem 0 0.5rem;
}
.page-content p { margin-bottom: 1rem; }
.page-content ul, .page-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
  list-style: disc;
}
.page-content ol { list-style: decimal; }
.page-content li { margin-bottom: 0.4rem; }
.page-content strong { color: #fff; }
.page-content a { color: var(--c-pink); border-bottom: 1px solid rgba(255,0,110,0.3); }
.page-content a:hover { color: var(--c-cyan); border-bottom-color: var(--c-cyan); }
.page-content blockquote {
  border-left: 3px solid var(--c-red);
  padding: 0.75rem 1.25rem;
  background: rgba(255,0,0,0.06);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 1.25rem 0;
  color: var(--c-muted);
  font-style: italic;
}
.page-content code {
  font-family: var(--font-mono);
  background: rgba(0,245,255,0.08);
  color: var(--c-cyan);
  padding: 0.15em 0.45em;
  border-radius: 4px;
  font-size: 0.9em;
}
.page-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
}
.page-content th, .page-content td {
  padding: 0.65rem 1rem;
  border: 1px solid var(--c-border);
  font-size: 0.9rem;
}
.page-content th {
  background: rgba(255,0,110,0.1);
  color: var(--c-pink);
  font-family: var(--font-mono);
  text-align: left;
}

/* === Section Heading + HR === */
.section-heading {
  font-family: var(--font-head);
  font-size: 1.4rem;
  color: var(--c-red);
  text-shadow: var(--glow-red);
  margin: 2.5rem 0 0.4rem;
}
.main-article hr,
.sidebar hr {
  border: none;
  border-top: 1px solid var(--c-border);
  margin-bottom: 1.25rem;
}

/* === Card Grid === */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition);
}
.card:hover {
  border-color: var(--c-pink);
  transform: translateY(-3px);
}
.card-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
}
.card-body {
  padding: 1rem 1.25rem;
}
.card-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--c-muted);
  display: block;
  margin-bottom: 0.4rem;
}
.card-title {
  font-family: var(--font-head);
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
  line-height: 1.35;
}
.card-title a { color: #fff; }
.card-title a:hover { color: var(--c-pink); text-shadow: var(--glow-pink); }
.card-desc {
  font-size: 0.85rem;
  color: var(--c-muted);
  margin-bottom: 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-link {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--c-red);
}
.card-link:hover { color: var(--c-cyan); }

/* === Table (article & recent) === */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
}
.recent-table,
.section-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.recent-table th,
.section-table th {
  background: rgba(255,0,110,0.12);
  color: var(--c-pink);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--c-border);
}
.recent-table td,
.section-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid rgba(255,0,110,0.1);
  vertical-align: top;
}
.recent-table tr:last-child td,
.section-table tr:last-child td {
  border-bottom: none;
}
.recent-table tr:hover td,
.section-table tr:hover td {
  background: rgba(255,0,110,0.06);
}
.recent-table a,
.section-table a {
  color: var(--c-text);
  font-weight: 500;
}
.recent-table a:hover,
.section-table a:hover {
  color: var(--c-cyan);
}
.td-num {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--c-red);
  text-shadow: var(--glow-red);
  width: 3rem;
}
.td-date {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--c-muted);
  white-space: nowrap;
}
.td-desc {
  color: var(--c-muted);
  font-size: 0.84rem;
}

/* === Story Layout === */
.story-hero {
  margin-bottom: 1.5rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--c-border);
}
.story-hero-img {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
}
.story-meta {
  margin-bottom: 0.75rem;
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.story-subhead {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--c-muted);
  font-weight: 400;
  margin-bottom: 1.25rem;
  line-height: 1.6;
}
.story-content {
  margin-bottom: 2rem;
}
.story-footer-nav {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 1.5rem;
  border-top: 1px solid var(--c-border);
}

/* === About / Privacy specific === */
.about-contact-block, .privacy-contact {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.about-contact-block a,
.privacy-contact a {
  align-self: flex-start;
}

/* === Footer === */
.site-footer {
  margin-left: var(--nav-w);
  background: var(--c-mid);
  border-top: 1px solid var(--c-border);
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.footer-brand {
  font-family: var(--font-head);
  font-size: 1.6rem;
  color: var(--c-red);
  text-shadow: var(--glow-red);
  letter-spacing: -0.02em;
  line-height: 1;
}
.footer-copy {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--c-muted);
}
.footer-copy a {
  color: var(--c-muted);
  border-bottom: 1px solid rgba(255,0,110,0.25);
}
.footer-copy a:hover { color: var(--c-pink); }

/* === Stagger Animation === */
.stagger-item {
  opacity: 0;
  transform: translateY(18px);
  animation: stagger-in 0.4s ease forwards;
  animation-delay: calc(var(--i, 0) * 0.07s + 0.1s);
}
@keyframes stagger-in {
  to { opacity: 1; transform: none; }
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  body::before { animation: none; }
}

/* === Responsive: Tablet === */
@media (max-width: 1024px) {
  :root { --nav-w: 180px; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .sidebar { width: 180px; }
}

/* === Responsive: Mobile === */
@media (max-width: 767px) {
  :root { --nav-w: 0px; }

  .site-shell { flex-direction: column; }

  .site-header {
    position: fixed;
    left: 0; top: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--c-border);
    z-index: 200;
    padding: 0;
  }
  .brand-icon {
    height: 52px;
    width: 52px;
    border-bottom: none;
    border-right: 1px solid var(--c-border);
  }
  .main-nav {
    flex: 1;
    padding: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .main-nav p {
    flex-direction: row;
    gap: 0;
    white-space: nowrap;
    padding: 0 0.5rem;
  }
  .main-nav p a {
    padding: 0 0.85rem;
    font-size: 0.75rem;
    height: 52px;
    min-height: 52px;
    border-left: none;
    border-bottom: 3px solid transparent;
  }
  .main-nav p a:hover,
  .main-nav p a[aria-current="page"] {
    border-left-color: transparent;
    border-bottom-color: var(--c-pink);
  }
  .nav-search {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--c-border);
  }

  .site-main {
    margin-left: 0;
    margin-top: 120px;
  }

  .hero-text {
    text-align: left;
    padding: 2rem 1.25rem 3rem;
  }
  .hero-lead { margin-left: 0; }

  .wrap { padding: 1.5rem 1rem; }

  .content-section {
    flex-direction: column;
    gap: 1.5rem;
  }
  .sidebar {
    width: 100%;
    position: static;
  }
  .sidebar hr { margin-bottom: 0.6rem; }
  .aside-links { flex-direction: row; flex-wrap: wrap; gap: 0.4rem; }
  .aside-links li a {
    min-height: 40px;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
  }

  .page-h1 { font-size: 1.7rem; }

  .card-grid { grid-template-columns: 1fr; }

  .site-footer {
    margin-left: 0;
    flex-direction: column;
    align-items: flex-start;
    padding: 1.25rem 1rem;
  }
  .footer-brand { font-size: 1.3rem; }

  .section-table { font-size: 0.82rem; }
  .td-desc { display: none; }
}

@media (max-width: 480px) {
  .hero-h1 { font-size: 2rem; }
  .hero-section { min-height: 100svh; }
}
