/* === BASE FONT + STRUCTURE === */
body {
  background: black;
  font-family: "IBM Plex Mono", monospace;
  font-size: 18px;
  margin: 0;
  padding: 2rem;
  text-transform: lowercase;
  line-height: 1.6;
  position: relative;
  overflow-x: hidden;
  cursor: crosshair;
}

body.alt-mode {
  background: #000000;
  color: #aaf0ff;
  text-shadow: 0 0 2px #aaf0ff;
}

body.crt-mode {
  background: #000000;
  color: #00ff8b;
  text-shadow: 0 0 4px #00ff8b;
}

/* === HEADINGS & LOGO === */
.logo,
h1,
h2,
h3 {
  font-family: "VT323", monospace;
  font-size: 2rem;
  margin: 2rem 0 1rem;
  text-transform: lowercase;
  letter-spacing: 0.05em;
}

.logo {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.blinking-cursor::after {
  content: "_";
  animation: blink 1s infinite;
  margin-left: 4px;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* === HEADER === */
header {
  border-bottom: 1px solid currentColor;
  padding-bottom: 1rem;
  margin-bottom: 2rem;
  position: relative;
  z-index: 2;
}

nav {
  margin-top: 0.5rem;
}

nav a {
  margin-right: 1.5rem;
  text-decoration: none;
  transition: transform 0.15s ease;
}

.toggle-mode {
  position: absolute;
  top: 0;
  right: 0;
  font-family: "VT323", monospace;
  background: transparent;
  border: 1px dashed currentColor;
  padding: 0.4rem 1rem;
  cursor: pointer;
  margin-top: 0.5rem;
  text-transform: lowercase;
  transition: transform 0.15s ease;
}

/* === SCANLINE OVERLAY === */
.scanlines {
  pointer-events: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.05),
    rgba(0, 0, 0, 0.05) 1px,
    transparent 2px,
    transparent 3px
  );
  z-index: 1;
  mix-blend-mode: overlay;
}

@keyframes flicker {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.98;
  }
  60% {
    opacity: 0.99;
  }
}

body.crt-mode,
body.alt-mode {
  animation: flicker 0.15s infinite;
}

/* === LINK COLOR + EFFECTS === */
body.alt-mode a,
body.alt-mode .toggle-mode {
  color: #aaf0ff;
}

body.crt-mode a,
body.crt-mode .toggle-mode {
  color: #00ff8b;
}

@keyframes linkFlicker {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.85;
  }
  100% {
    opacity: 1;
  }
}

a:hover,
.toggle-mode:hover {
  animation: linkFlicker 0.15s steps(1) infinite;
  transform: scale(1.03);
  text-decoration: none;
}

/* === CHAPBOOK GRID === */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.5rem;
}

.chapbook {
  border: 1px dashed currentColor;
  padding: 1rem;
  text-align: center;
}

.chapbook-scroll {
  display: flex;
  overflow-x: auto;
  gap: 2rem;
  padding: 1rem 0;
  scroll-snap-type: x mandatory;
}

.chapbook-scroll .chapbook {
  min-width: 300px;
  max-width: 300px;
  scroll-snap-align: start;
  background-color: black;
  transition: transform 0.3s;
}

.chapbook-scroll .chapbook:hover {
  transform: scale(1.02);
}

.chapbook-scroll .chapbook a {
  text-decoration: none;
  color: inherit;
}

.chapbook-scroll .chapbook a:hover {
  text-decoration: none;
}

.ascii-preview {
  font-family: "VT323", monospace;
  font-size: 10px;
  color: inherit;
  white-space: pre;
  text-align: center;
  overflow-x: auto;
  cursor: pointer;
}

.chapbook-title {
  text-align: center;
  margin-top: 0.5rem;
}

.chapbook-author {
  font-size: 0.9rem;
  opacity: 0.7;
}

/* === BLOG LAYOUT === */
.blog-layout {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.categories {
  min-width: 150px;
  flex: 1 1 180px;
}

.categories ul {
  padding-left: 0;
  list-style: none;
}

.posts {
  flex: 3 1 600px;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: flex-start;
}

.post-card {
  background: black;
  border: 2px solid currentColor;
  padding: 1rem;
  font-family: "IBM Plex Mono", monospace;
  width: 280px;
  max-width: 100%;
  box-sizing: border-box;
  cursor: grab;
  transition: transform 0.2s;
}

.post-card:hover {
  transform: scale(1.02);
}

.post-card h3 {
  margin-top: 0;
}

.post-card p {
  font-size: 0.9rem;
  opacity: 0.85;
}

.posts article {
  margin-bottom: 2rem;
}

.posts time {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

/* === LINKS PAGE === */
.links li {
  list-style: none;
  margin-bottom: 0.5rem;
}

.social {
  margin-top: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.social a {
  display: block;
  white-space: nowrap;
}

/* === ABOUT PAGE IMAGE LAYOUT === */
.about-container {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  align-items: flex-start;
}

.about-text {
  flex: 1 1 60%;
}

.about-image {
  flex: 1 1 30%;
  max-width: 300px;
  position: relative;
}

.about-image img.crt-image {
  width: 100%;
  height: auto;
  display: block;
  filter: contrast(1.1) brightness(0.9) grayscale(20%)
    drop-shadow(0 0 5px currentColor);
  image-rendering: pixelated;
  mix-blend-mode: screen;
  position: relative;
  z-index: 2;
}

.about-image::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.05),
    rgba(0, 0, 0, 0.05) 1px,
    transparent 2px,
    transparent 3px
  );
  z-index: 3;
}

/* === CUSTOM SCROLLBARS === */
::-webkit-scrollbar {
  height: 6px;
  width: 8px;
}
::-webkit-scrollbar-track {
  background: #111;
}
::-webkit-scrollbar-thumb {
  background-color: #aaf0ff;
  border-radius: 10px;
  border: 2px solid #111;
}
::-webkit-scrollbar-thumb:hover {
  background-color: #9aff9a;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #aaf0ff #111;
}

/* === RESPONSIVE === */
@media screen and (max-width: 768px) {
  body {
    padding: 1rem;
  }

  .blog-layout {
    flex-direction: column;
    padding: 1rem;
  }

  .categories {
    width: 100%;
    margin-bottom: 1.5rem;
  }

  .categories ul {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
  }

  .categories li {
    margin-bottom: 0;
  }

  .posts {
    justify-content: center;
  }

  .post-card {
    width: 100% !important;
    max-width: 100% !important;
  }

  .logo {
    font-size: 2rem;
    margin-top: 1rem;
  }

  nav a {
    display: inline-block;
    margin-bottom: 0.5rem;
  }

  header {
    padding-bottom: 1rem;
    margin-bottom: 1rem;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .about-container {
    flex-direction: column;
  }

  .about-text,
  .about-image {
    width: 100%;
    max-width: 100%;
  }

  .ascii-preview {
    font-size: 8px;
  }

  .chapbook-scroll {
    gap: 1rem;
    padding: 0.5rem;
  }

  .chapbook-scroll .chapbook {
    min-width: 260px;
    max-width: 260px;
  }

  .social {
    flex-direction: column;
  }
}

/* added e-paper mode */

/* palette + globals */
body.epaper-mode {
    /* neutral “paper” look */
    background: #f6f6f1 !important;
    color: #1a1a1a !important;
    text-shadow: none !important;
    animation: none !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  
    /* expose tokens so scrollbars & accents can reuse */
    --paper-bg: #f6f6f1;
    --card-bg: #fbfbf8;
    --ink: #1a1a1a;
    --muted-ink: #333;
    --rule: #aaa;
    --rule-strong: #444;
    --link: #222;           /* dark gray instead of blue for e-ink consistency */
    --link-hover: #000;
  
    /* scrollbar tokens (Firefox + WebKit below consume these) */
    --scrollbar-thumb: #999;
    --scrollbar-track: #e0e0e0;
  }
  
  /* kill CRT artifacts */
  body.epaper-mode.scanlines,
  body.epaper-mode .scanlines {
    display: none !important;
  }
  body.epaper-mode.crt-mode,
  body.epaper-mode.alt-mode {
    /* ensure only one mode is active */
    animation: none !important;
  }
  
  /* typography & links */
  body.epaper-mode a,
  body.epaper-mode .toggle-mode {
    color: var(--link) !important;
    text-shadow: none !important;
  }
  body.epaper-mode a:hover,
  body.epaper-mode .toggle-mode:hover {
    animation: none !important;
    transform: none !important;
    text-decoration: underline;
  }
  
  /* header & nav */
  body.epaper-mode header {
    border-bottom: 1px solid var(--rule) !important;
  }
  body.epaper-mode nav a {
    text-decoration: none;
  }
  
  /* cards, posts, lists */
  body.epaper-mode .post-card,
  body.epaper-mode .chapbook,
  body.epaper-mode .chapbook-scroll .chapbook {
    background: var(--card-bg) !important;
    border: 1px solid var(--rule) !important;
    box-shadow: none !important;
  }
  
  /* chapbook strip */
  body.epaper-mode .chapbook-scroll {
    gap: 1.5rem;
  }
  body.epaper-mode .chapbook-title,
  body.epaper-mode .chapbook-author {
    color: var(--muted-ink);
  }
  
  /* general rules that were hard-coded to black */
  body.epaper-mode .post-card,
  body.epaper-mode .chapbook-scroll .chapbook {
    /* override your black backgrounds */
    background: var(--card-bg) !important;
  }
  
  /* ascii previews remain mono but slightly smaller contrast */
  body.epaper-mode .ascii-preview {
    color: var(--ink);
  }
  
  /* about page image: remove CRT filters */
  body.epaper-mode .about-image img.crt-image {
    filter: none !important;
    mix-blend-mode: normal !important;
    image-rendering: auto !important;
    box-shadow: none !important;
  }
  
  /* controls */
  body.epaper-mode .toggle-mode {
    border: 1px solid var(--rule-strong) !important;
    background: transparent !important;
  }
  
  /* firefox scrollbars (inherits tokens) */
  body.epaper-mode {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  }
  
  /* webkit scrollbars (inherits tokens) */
  body.epaper-mode ::-webkit-scrollbar {
    height: 6px;
    width: 8px;
  }
  body.epaper-mode ::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
  }
  body.epaper-mode ::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
    border-radius: 10px;
    border: 2px solid var(--scrollbar-track);
  }
  body.epaper-mode ::-webkit-scrollbar-thumb:hover {
    background-color: #888;
  }
  
  /* motion discipline: if user prefers less motion, also clamp in other modes */
  @media (prefers-reduced-motion: reduce) {
    body,
    body * {
      animation: none !important;
      transition: none !important;
    }
  }
  
  /* printing maps to e-paper automatically */
  @media print {
    body {
      background: #fff !important;
      color: #000 !important;
      text-shadow: none !important;
    }
    .scanlines { display: none !important; }
    a { text-decoration: underline; color: #000 !important; }
    .post-card, .chapbook, .chapbook-scroll .chapbook {
      background: #fff !important;
      border: 1px solid #000 !important;
    }
  }

