:root {
  --bg-color: #1a1a2e;
  --text-color: #ede5ff; /* Improved contrast: 7.1:1 (was 4.8:1) */
  --accent-color: #b388ff;
  --visited-color: #9575cd;
  --highlight-color: #ff79c6;
  --scanline-opacity: 0.05;
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: "Courier New", "Liberation Mono", Monaco, monospace;
  font-size: 16px;
  line-height: 1.6;
  padding: 2rem;
  position: relative;
  overflow-x: hidden;
}

/* CRT screen effect */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.15),
      rgba(0, 0, 0, 0.15) 1px,
      transparent 1px,
      transparent 2px
    );
  pointer-events: none;
  z-index: 1000;
}

/* Screen curvature */
body::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at center, transparent 0%, rgba(0, 0, 0, 0.3) 100%);
  pointer-events: none;
  z-index: 999;
}

/* Main container */
.container {
  max-width: 80ch;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* Text glow effect */
.glow {
  text-shadow:
    0 0 5px var(--accent-color),
    0 0 10px rgba(179, 136, 255, 0.5);
  -webkit-animation: flicker 3s infinite;
  animation: flicker 3s infinite;
}

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

@-webkit-keyframes flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.97; }
}

/* ASCII art header */
.ascii-art {
  color: var(--highlight-color);
  line-height: 1.2;
  margin-bottom: 2rem;
  white-space: pre;
  overflow-x: auto;
  text-shadow:
    0 0 10px var(--highlight-color),
    0 0 20px rgba(255, 121, 198, 0.5);
}

/* Prompt style */
.prompt {
  color: var(--highlight-color);
  margin-right: 0.5rem;
}

/* Navigation */
nav {
  margin: 2rem 0;
  display: flex;
  gap: 1rem;
}

nav a:nth-child(2) {
  margin-left: auto;
}

nav a::before {
  content: "[";
  color: var(--text-color);
}

nav a::after {
  content: "]";
  color: var(--text-color);
}

/* Links */
a {
  color: var(--accent-color);
  text-decoration: none;
  transition: color 0.2s, text-shadow 0.2s;
}

a:hover {
  color: var(--highlight-color);
  text-shadow: 0 0 5px var(--highlight-color);
}

a:visited {
  color: var(--visited-color);
}

a:focus-visible {
  outline: 2px solid var(--highlight-color);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Sections */
section {
  margin: 3rem 0;
}

h1, h2, h3 {
  color: var(--highlight-color);
  margin-bottom: 1rem;
  text-shadow: 0 0 5px var(--highlight-color);
}

h1 {
  font-size: 1.5rem;
}

h2 {
  font-size: 1.3rem;
}

h3 {
  font-size: 1.1rem;
}

/* Lists */
ul, ol {
  margin-left: 2rem;
  margin-bottom: 1rem;
}

li {
  margin: 0.5rem 0;
}

/* Blog entries - tree style */
.tree-root {
  color: var(--accent-color);
  margin-bottom: 0.5rem;
  font-weight: bold;
}

.tree-link {
  display: block;
  text-decoration: none;
  transition: color 0.2s, text-shadow 0.2s;
  margin: 0.2rem 0;
}

.tree-link:hover .tree-entry {
  color: var(--highlight-color);
  text-shadow: 0 0 5px var(--highlight-color);
}

.tree-entry {
  color: var(--text-color);
  transition: color 0.2s, text-shadow 0.2s;
  line-height: 1.6;
}

.tree-char {
  color: var(--accent-color);
}

.tree-file {
  color: var(--text-color);
}

.tree-title {
  color: var(--visited-color);
  font-size: 0.9rem;
  font-style: italic;
}

/* Breadcrumbs */
.breadcrumbs {
  color: var(--visited-color);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

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

.breadcrumbs span {
  color: var(--text-color);
}

/* Blog post metadata */
.blog-date {
  color: var(--visited-color);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

/* Post navigation */
.post-navigation {
  border-top: 1px solid var(--accent-color);
  padding-top: 1rem;
  margin-top: 2rem;
}

.post-navigation p {
  font-size: 0.9rem;
}

/* Project entries */
.project-link {
  display: block;
  text-decoration: none;
  margin: 2rem 0;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s, text-shadow 0.2s;
}

.project-link:hover .project-entry {
  background: rgba(255, 121, 198, 0.1);
  border-color: var(--highlight-color);
  box-shadow: 0 0 10px rgba(255, 121, 198, 0.3);
}

.project-link:hover .project-title {
  text-shadow: 0 0 5px var(--highlight-color);
}

.project-entry {
  padding: 1rem;
  border: 1px solid var(--accent-color);
  border-radius: 3px;
  background: rgba(179, 136, 255, 0.05);
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.project-title {
  color: var(--highlight-color);
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

/* Code blocks */
pre, code {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.2rem 0.4rem;
  border-radius: 2px;
  font-family: inherit;
}

pre {
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
  border-left: 3px solid var(--accent-color);
}

/* Accessibility - reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .glow {
    animation: none;
  }

  body::before {
    display: none;
  }
}

/* Tree summary (excerpts in blog index) */
.tree-summary {
  display: block;
  color: var(--visited-color);
  font-size: 0.8rem;
  font-style: italic;
  padding-left: 3.5rem;
  margin-top: 0.2rem;
}

/* Featured posts */
.tree-link.featured .tree-file {
  color: var(--highlight-color);
}

.tree-link.featured .tree-entry {
  border-left: 2px solid var(--highlight-color);
  padding-left: 0.5rem;
}

/* Table of contents */
.toc {
  border-left: 3px solid var(--accent-color);
  padding: 0.75rem 1rem;
  margin: 1.5rem 0;
  background: rgba(179, 136, 255, 0.05);
}

.toc-title {
  color: var(--highlight-color);
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.toc ul {
  margin-left: 1.5rem;
  margin-bottom: 0;
}

.toc li {
  margin: 0.25rem 0;
  font-size: 0.9rem;
}

/* Series navigation */
.series-nav {
  border: 1px solid var(--accent-color);
  padding: 1rem;
  margin: 2rem 0;
  background: rgba(179, 136, 255, 0.05);
  border-radius: 3px;
}

.series-nav ol {
  margin-left: 2rem;
}

/* Status badges */
.badge {
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--accent-color);
  border-radius: 2px;
  color: var(--accent-color);
  vertical-align: middle;
}

.badge-archived {
  border-color: var(--visited-color);
  color: var(--visited-color);
}

.badge-updated {
  border-color: var(--highlight-color);
  color: var(--highlight-color);
}

/* Tag cloud */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}

.tag-cloud a {
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--accent-color);
  border-radius: 2px;
  font-size: 0.85rem;
}

.tag-cloud a.tag-lg {
  font-size: 1.1rem;
}

.tag-cloud a.tag-md {
  font-size: 0.95rem;
}

/* Site footer - motif */
.site-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--accent-color);
  text-align: center;
  opacity: 0.4;
  transition: opacity 0.3s;
}

.site-footer:hover {
  opacity: 0.7;
}

.site-footer p {
  font-size: 0.75rem;
  color: var(--visited-color);
  margin: 0.1rem 0;
  font-style: italic;
  letter-spacing: 0.05em;
}

.site-footer .footer-attribution {
  margin-top: 0.5rem;
  font-size: 0.65rem;
  font-style: normal;
}

/* Print stylesheet */
@media print {
  body {
    background: white;
    color: black;
    padding: 0;
    font-size: 12pt;
  }

  body::before,
  body::after {
    display: none !important;
  }

  nav,
  .post-navigation,
  .toc {
    display: none;
  }

  a {
    color: black;
    text-decoration: underline;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #555;
  }

  a[href^="#"]::after,
  a[href^="javascript"]::after,
  nav a::after {
    content: "";
  }

  .ascii-art {
    color: black;
    text-shadow: none;
  }

  h1, h2, h3 {
    color: black;
    text-shadow: none;
  }

  pre, code {
    background: #f5f5f5;
    border: 1px solid #ddd;
    page-break-inside: avoid;
  }

  .container {
    max-width: 100%;
  }

  .blog-date, .breadcrumbs {
    color: #555;
  }

  .project-entry {
    border-color: #ddd;
    background: none;
  }
}

/* Responsive */
@media (max-width: 768px) {
  body {
    padding: 1rem;
    font-size: 14px;
  }

  /* Disable CRT effects on mobile for better performance */
  body::before,
  body::after {
    display: none;
  }

  .container {
    max-width: 100%;
  }

  nav {
    flex-wrap: wrap;
  }

  nav a:nth-child(2) {
    margin-left: 0;
  }
}
