@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&display=swap');

:root {
  --bg:        #0d0d0d;
  --bg-alt:    #111111;
  --border:    #1f1f1f;
  --text:      #c0c0c0;
  --accent:    #00ff41;
  --dim:       #555555;
  --font:      'JetBrains Mono', 'Courier New', monospace;
}

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

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.7;
  min-height: 100vh;
}

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

/* ── Background terminal windows ── */

.bg-terminals {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-terminal-win {
  position: absolute;
  width: clamp(220px, 22vw, 340px);
  border: 1px solid rgba(0, 255, 65, 0.04);
  background: rgba(0, 255, 65, 0.006);
  font-family: var(--font);
  font-size: 0.6rem;
  color: rgba(0, 255, 65, 0.055);
  animation: terminal-drift linear infinite;
  will-change: transform;
}

.bg-terminal-bar {
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid rgba(0, 255, 65, 0.04);
  color: rgba(0, 255, 65, 0.07);
  font-size: 0.55rem;
}

.bg-terminal-body {
  padding: 0.5rem 0.6rem;
  line-height: 1.8;
}

@keyframes terminal-drift {
  0%   { transform: translateY(0px)   rotate(-0.5deg); }
  25%  { transform: translateY(-18px) rotate(0.3deg);  }
  50%  { transform: translateY(-8px)  rotate(-0.2deg); }
  75%  { transform: translateY(-22px) rotate(0.5deg);  }
  100% { transform: translateY(0px)   rotate(-0.5deg); }
}

.site-wrapper {
  position: relative;
  z-index: 1;
}

/* ── Layout ── */

.site-wrapper {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1.5rem;
  background: rgba(13, 13, 13, 0.92);
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.8);
  min-height: 100vh;
}

/* ── Header ── */

.site-header {
  padding: 2rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3rem;
}

/* ── ASCII art ── */

.ascii-logo {
  color: var(--accent);
  font-size: 0.6rem;
  line-height: 1.2;
  margin-bottom: 1rem;
  opacity: 0.7;
  overflow-x: auto;
  white-space: pre;
}

@media (max-width: 640px) {
  .ascii-logo { display: none; }
}

.prompt {
  font-size: 1.1rem;
  color: var(--dim);
}

.prompt .user { color: var(--accent); font-weight: 700; }
.prompt .host { color: var(--accent); }
.prompt .path { color: var(--text); }
.prompt .symbol { color: var(--dim); }

.site-title-link {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
  margin: 0.5rem 0 0.25rem;
  text-shadow: 0 0 12px rgba(0, 255, 65, 0.35);
}
.site-title-link:hover { text-decoration: none; opacity: 0.85; }

.site-description {
  color: var(--dim);
  font-size: 0.85rem;
}

nav { margin-top: 1rem; }
.nav-primary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0;
}
nav a {
  color: var(--dim);
  font-size: 0.85rem;
  margin-right: 1.5rem;
  white-space: nowrap;
}
nav a:hover { color: var(--accent); text-decoration: none; }

/* ── Post list ── */

.post-feed { list-style: none; }

.post-card {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
}

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

.post-meta {
  font-size: 0.75rem;
  color: var(--dim);
  margin-bottom: 0.4rem;
}

.post-meta .tag {
  color: var(--accent);
  margin-right: 0.75rem;
}

.post-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.post-card-title a { color: var(--text); }
.post-card-title a:hover { color: var(--accent); text-decoration: none; }

.post-card-excerpt {
  font-size: 0.875rem;
  color: var(--dim);
  line-height: 1.6;
}

.read-more {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--accent);
}

/* ── Post page ── */

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

.post-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.post-byline {
  font-size: 0.8rem;
  color: var(--dim);
}

.post-content {
  font-size: 0.95rem;
  line-height: 1.8;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
  color: var(--accent);
  margin: 2rem 0 0.75rem;
  font-weight: 700;
}

.post-content h2::before { content: '## '; opacity: 0.4; }
.post-content h3::before { content: '### '; opacity: 0.4; }

.post-content p { margin-bottom: 1.25rem; }

.post-content a { color: var(--accent); }

.post-content code {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 0.1em 0.4em;
  border-radius: 2px;
  font-size: 0.9em;
  color: var(--accent);
}

.post-content pre {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.875rem;
  line-height: 1.6;
}

.post-content pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
}

.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1rem;
  margin: 1.5rem 0;
  color: var(--dim);
  font-style: italic;
}

.post-content img {
  max-width: 100%;
  border: 1px solid var(--border);
}

.post-content ul,
.post-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1.25rem;
}

.post-content li { margin-bottom: 0.3rem; }

.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* ── Shared image effect base ── */

.post-card-image,
.post-image {
  position: relative;
  display: block;
  background: black;
  overflow: hidden;
}

.post-card-image-link {
  display: block;
  margin: 0.75rem 0;
}

.post-card-image {
  max-height: 220px;
}

.post-card-image img,
.post-image img {
  display: block;
  width: 100%;
  object-fit: cover;
  filter: grayscale(1) brightness(0.9) contrast(1.4) sepia(1) hue-rotate(80deg);
}

.post-card-image img { max-height: 220px; }
.post-image img      { max-height: 480px; }

/* ── Index card: continuous pixel distortion ── */

@keyframes pixel-distort {
  0%   { filter: grayscale(1) brightness(0.9) contrast(1.4) sepia(1) hue-rotate(80deg)
                 drop-shadow(2px 0 0 rgba(255,0,60,0.3)) drop-shadow(-2px 0 0 rgba(0,255,65,0.3)); }
  15%  { filter: grayscale(1) brightness(0.9) contrast(1.4) sepia(1) hue-rotate(84deg)
                 drop-shadow(0 0 0 transparent); }
  30%  { filter: grayscale(1) brightness(1.0) contrast(1.5) sepia(1) hue-rotate(78deg)
                 drop-shadow(3px 0 0 rgba(255,0,60,0.2)) drop-shadow(-1px 0 0 rgba(0,255,65,0.2)); }
  45%  { filter: grayscale(1) brightness(0.85) contrast(1.4) sepia(1) hue-rotate(82deg)
                 drop-shadow(0 0 0 transparent); }
  60%  { filter: grayscale(1) brightness(0.9) contrast(1.6) sepia(1) hue-rotate(80deg)
                 drop-shadow(-3px 0 0 rgba(255,0,60,0.25)) drop-shadow(2px 0 0 rgba(0,255,65,0.25)); }
  75%  { filter: grayscale(1) brightness(0.95) contrast(1.4) sepia(1) hue-rotate(76deg)
                 drop-shadow(0 0 0 transparent); }
  100% { filter: grayscale(1) brightness(0.9) contrast(1.4) sepia(1) hue-rotate(80deg)
                 drop-shadow(2px 0 0 rgba(255,0,60,0.3)) drop-shadow(-2px 0 0 rgba(0,255,65,0.3)); }
}

.post-card-image img {
  animation: pixel-distort 4s steps(1) infinite;
}

/* ── CRT scan ray ── */

@keyframes scan-ray {
  0%   { top: -6px; opacity: 0; }
  5%   { opacity: 1; }
  95%  { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

.scan-ray {
  position: absolute;
  left: 0;
  width: 100%;
  height: 6px;
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(0, 255, 65, 0.18) 40%,
    rgba(0, 255, 65, 0.32) 50%,
    rgba(0, 255, 65, 0.18) 60%,
    transparent
  );
  pointer-events: none;
  z-index: 4;
  animation: scan-ray 3s linear infinite;
  mix-blend-mode: screen;
}

/* scanlines */
.post-card-image::before,
.post-image::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 255, 0, 0.06),
    rgba(0, 255, 0, 0.06) 1px,
    transparent 3px,
    transparent 5px
  );
  pointer-events: none;
  mix-blend-mode: overlay;
  z-index: 1;
}

/* noise */
.post-card-image::after,
.post-image::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.2'/%3E%3C/svg%3E");
  opacity: 0.08;
  pointer-events: none;
  z-index: 2;
}

/* ── Post page: glitch → flicker → phosphor fade ── */

@keyframes glitch-shift {
  0%   { clip-path: inset(40% 0 50% 0); transform: translate(-6px, 0); opacity: 1; }
  10%  { clip-path: inset(10% 0 80% 0); transform: translate(6px,  0); opacity: 1; }
  20%  { clip-path: inset(70% 0 10% 0); transform: translate(-4px, 0); opacity: 1; }
  30%  { clip-path: inset(30% 0 60% 0); transform: translate(4px,  0); opacity: 1; }
  40%  { clip-path: inset(60% 0 20% 0); transform: translate(-2px, 0); opacity: 1; }
  50%  { clip-path: inset(20% 0 70% 0); transform: translate(2px,  0); opacity: 1; }
  60%  { clip-path: inset(80% 0 5%  0); transform: translate(-6px, 0); opacity: 1; }
  70%  { clip-path: inset(5%  0 85% 0); transform: translate(6px,  0); opacity: 1; }
  90%  { clip-path: inset(0 0 0 0);     transform: translate(0,    0); opacity: 1; }
  100% { clip-path: inset(0 0 0 0);     transform: translate(0,    0); opacity: 0; }
}

@keyframes scan-flicker {
  0%,  100% { opacity: 1;    filter: grayscale(1) brightness(0.9) contrast(1.4) sepia(1) hue-rotate(80deg); }
  10%        { opacity: 0.4;  filter: grayscale(1) brightness(1.8) contrast(2.0) sepia(1) hue-rotate(80deg); }
  20%        { opacity: 1;    filter: grayscale(1) brightness(0.3) contrast(1.4) sepia(1) hue-rotate(80deg); }
  35%        { opacity: 0.6;  filter: grayscale(1) brightness(1.4) contrast(1.8) sepia(1) hue-rotate(80deg); }
  50%        { opacity: 1;    filter: grayscale(1) brightness(0.9) contrast(1.4) sepia(1) hue-rotate(80deg); }
  65%        { opacity: 0.7;  filter: grayscale(1) brightness(1.2) contrast(1.6) sepia(1) hue-rotate(80deg); }
  80%        { opacity: 1;    filter: grayscale(1) brightness(0.9) contrast(1.4) sepia(1) hue-rotate(80deg); }
}

@keyframes phosphor-fade {
  from { filter: grayscale(1) brightness(0.9) contrast(1.4) sepia(1) hue-rotate(80deg); }
  to   { filter: grayscale(0) brightness(1)   contrast(1)   sepia(0) hue-rotate(0deg); }
}

@keyframes overlay-fade {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.post-image {
  isolation: isolate;
}

.post-image img {
  animation:
    scan-flicker  0.8s steps(1) 0s    1        forwards,
    phosphor-fade 2.5s ease-out 1.2s  1        forwards;
}

/* glitch layer — ::before does double duty during glitch phase */
.post-image::before {
  animation:
    overlay-fade  2.5s ease-out 1.2s forwards;
}

.post-image::after {
  animation: overlay-fade 2.5s ease-out 1.2s forwards;
}

/* glitch overlay — cloned img injected via JS */
.post-image .glitch-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  animation: glitch-shift 0.8s steps(1) 0s 1 forwards;
  mix-blend-mode: screen;
  filter: grayscale(1) brightness(0.9) contrast(1.4) sepia(1) hue-rotate(80deg);
}

/* ── Post Image margin ── */
.post-image { margin: 2rem 0; }

/* ── Tags ── */

.post-tags { margin-top: 2rem; font-size: 0.8rem; }
.post-tags a {
  color: var(--dim);
  margin-right: 0.75rem;
}
.post-tags a::before { content: '#'; color: var(--accent); }

/* ── Footer ── */

.site-footer {
  margin-top: 4rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--dim);
}

.footer-links {
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0;
}

.footer-links a {
  color: var(--dim);
  margin-right: 1.5rem;
}

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

.footer-bottom { color: var(--dim); }

.cursor {
  display: inline-block;
  width: 0.6em;
  height: 1em;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ── Pagination ── */

.pagination {
  display: flex;
  justify-content: space-between;
  padding: 2rem 0;
  font-size: 0.85rem;
}

.pagination a { color: var(--accent); }

/* ── 404 ── */

.error-page { padding: 4rem 0; }
.error-code { font-size: 4rem; font-weight: 700; color: var(--accent); }
.error-message { color: var(--dim); margin-top: 0.5rem; }
