/*
 * Theme: Terminal Nerd Edition
 * Dark. Amber. Monospace. No bullshit.
 */

/* ═══════════════════════════════════════════════════════════════════════════
   THE PALETTE
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
  /* Background layers */
  --bg-base: #121212;
  --bg-surface: #1a1a1a;
  --bg-elevated: #242424;
  --bg-hover: #2a2a2a;

  /* Text hierarchy */
  --text-primary: #e8e8e8;
  --text-secondary: #a0a0a0;
  --text-muted: #8a8a8a;

  /* The accent: warm amber */
  --accent: #f59e0b;
  --accent-dim: #b45309;
  --accent-glow: rgba(245, 158, 11, 0.15);

  /* Borders */
  --border: #333333;
  --border-strong: #444444;

  /* Typography */
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Consolas', monospace;

  /* Spacing */
  --radius: 4px;
  --transition: 150ms ease;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-base);
  min-height: 100vh;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TYPOGRAPHY
   ═══════════════════════════════════════════════════════════════════════════ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-mono);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
  transition: color var(--transition);
}

a:visited {
  color: #d97706;
}

a:hover,
a:visited:hover {
  color: var(--text-primary);
}

p {
  margin-bottom: 1rem;
}

strong {
  font-weight: 600;
  color: var(--text-primary);
}

em {
  font-style: italic;
}

/* Code */
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.15em 0.4em;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

pre {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.5;
  padding: 1rem;
  margin: 1.5rem 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  overflow-x: auto;
}

pre code {
  background: none;
  border: none;
  padding: 0;
}

/* Blockquotes */
blockquote {
  margin: 1.5rem 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-style: italic;
}

blockquote p:last-child {
  margin-bottom: 0;
}

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

li {
  margin-bottom: 0.25rem;
}

li::marker {
  color: var(--accent);
}

/* Horizontal rule */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* Images */
img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

figure,
.post-figure {
  margin: 1.5rem 0;
}

.post-figure img {
  display: block;
}

figcaption {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* Selection */
::selection {
  background: var(--accent);
  color: var(--bg-base);
}

/* ═══════════════════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */
.layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.content {
  flex: 1;
  padding: 2rem 0 4rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════════════════ */
.header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Site title styled like a prompt */
.site-title {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
}

.site-title::before {
  content: '~/ ';
  color: var(--accent);
}

.site-title:visited {
  color: var(--text-primary);
}

.site-title:hover,
.site-title:visited:hover {
  color: var(--accent);
}

/* Navigation */
.nav-menu {
  display: flex;
  gap: 0.25rem;
}

.nav-link {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text-secondary);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  transition: all var(--transition);
  text-decoration: none;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-link.active {
  color: var(--accent);
  background: var(--bg-elevated);
}

/* ═══════════════════════════════════════════════════════════════════════════
   HOME PAGE
   ═══════════════════════════════════════════════════════════════════════════ */
.home-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 3rem;
  align-items: start;
}

.posts-list {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   POST ITEMS
   ═══════════════════════════════════════════════════════════════════════════ */
.post-item {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
}

.post-item:first-child {
  padding-top: 0;
}

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

.posts-list .post-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--accent);
}

.posts-list .post-title a {
  color: inherit;
  text-decoration: none;
}

.posts-list .post-title a:visited {
  color: inherit;
}

.posts-list .post-title a:hover {
  color: var(--text-primary);
}

/* Post meta */
.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.post-meta time {
  color: var(--text-secondary);
}

/* Summary */
.post-summary {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
}

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

.read-more:hover {
  color: var(--text-primary);
}

/* Post item footer */
.post-item-footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
}

.post-item-date {
  color: var(--text-muted);
}

.post-item-date:hover {
  color: var(--accent);
}

.post-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TAGS
   ═══════════════════════════════════════════════════════════════════════════ */
.tag,
.post-item-tag,
.sidebar-tag,
.post-footer-tag,
.tag-cloud-item {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
  padding: 0.25rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
  text-decoration: none;
}

.tag:hover,
.post-item-tag:hover,
.sidebar-tag:hover,
.post-footer-tag:hover,
.tag-cloud-item:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.tag-count {
  font-size: 0.65rem;
  color: var(--text-secondary);
  opacity: 0.7;
  margin-left: 0.25rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════════════════ */
.home-sidebar {
}

.sidebar-sticky {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-section {
  padding: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.sidebar-section h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.sidebar-section h3::before {
  content: '# ';
}

.sidebar-about p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.sidebar-subscribe p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   SINGLE POST
   ═══════════════════════════════════════════════════════════════════════════ */
.post-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 3rem;
  align-items: start;
}

.post-layout .post {
  min-width: 0;
}

/* Post header */
.post-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.post-header .post-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--accent);
}

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

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--accent);
}

.post-content h1::before,
.post-content h2::before {
  content: '## ';
  color: var(--text-muted);
}

.post-content h3::before {
  content: '### ';
  color: var(--text-muted);
}

.post-content a {
  text-decoration: underline;
  text-decoration-color: var(--accent-dim);
  text-underline-offset: 2px;
}

.post-content a:hover {
  text-decoration-color: var(--text-primary);
}

.post-content img {
  display: block;
  max-width: 100%;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
}

/* Post sidebar */
.post-sidebar {
}

.post-sidebar .sidebar-sticky {
}

.sidebar-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.sidebar-meta strong {
  color: var(--text-primary);
  display: block;
  margin-bottom: 0.25rem;
}

.sidebar-meta time {
  color: var(--accent);
}

.sidebar-tags {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.sidebar-nav {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.sidebar-nav-item {
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
}

.sidebar-nav-item:last-child {
  margin-bottom: 0;
}

.sidebar-nav-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.sidebar-nav-item a {
  color: var(--accent);
  line-height: 1.3;
}

/* ═══════════════════════════════════════════════════════════════════════════
   POST FOOTER
   ═══════════════════════════════════════════════════════════════════════════ */
.post-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.post-footer-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.post-footer-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}

.post-footer-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.post-footer-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition);
}

.post-footer-nav-link:hover {
  border-color: var(--accent);
}

.post-footer-nav-link:hover .post-footer-nav-title {
  color: var(--text);
}

.post-footer-nav-prev {
  grid-column: 1;
}

.post-footer-nav-next {
  grid-column: 2;
  text-align: right;
}

.post-footer-nav-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.post-footer-nav-title {
  font-size: 0.85rem;
  color: var(--accent);
  line-height: 1.3;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LIST/TAXONOMY PAGES
   ═══════════════════════════════════════════════════════════════════════════ */
.header-unstyled {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--accent);
}

.header-unstyled::before {
  content: '# ';
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════════
   PAGINATION
   ═══════════════════════════════════════════════════════════════════════════ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.25rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.page-item {
  display: inline-block;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
  text-decoration: none;
}

.page-link:hover {
  color: var(--text-primary);
  border-color: var(--accent);
}

.page-item.active .page-link {
  background: var(--accent);
  color: var(--bg-base);
  border-color: var(--accent);
}

.page-item.disabled .page-link {
  opacity: 0.4;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════════════════════════ */
.footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  margin-top: auto;
}

.footer-inner {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════════════════
   ABOUT PAGE
   ═══════════════════════════════════════════════════════════════════════════ */
.home-content {
  max-width: 80ch;
}

.home-content p {
  margin-bottom: 1rem;
}

.home-content ul,
.home-content ol {
  margin-bottom: 1rem;
}

.social-links {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.social-links ul {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  list-style: none;
  padding: 0;
  max-width: 400px;
}

.social-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text-primary);
  transition: all var(--transition);
}

.social-links a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.social-icon {
  width: 1.25rem;
  height: 1.25rem;
  fill: currentColor;
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .home-layout,
  .post-layout {
    grid-template-columns: 1fr;
  }

  .home-sidebar {
    position: static;
    order: -1;
  }

  .home-sidebar .sidebar-sticky {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
  }

  .post-sidebar {
    display: none;
  }
}

@media (max-width: 600px) {
  html {
    font-size: 15px;
  }

  .container {
    padding: 0 1rem;
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .nav-menu {
    width: 100%;
  }

  h1, .post-header .post-title {
    font-size: 1.4rem;
  }

  .post-footer-nav {
    grid-template-columns: 1fr;
  }

  .post-footer-nav-prev,
  .post-footer-nav-next {
    grid-column: 1;
    text-align: left;
  }

  .home-sidebar {
    display: none;
  }

  .social-links ul {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ACCESSIBILITY
   ═══════════════════════════════════════════════════════════════════════════ */

.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;
}

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  padding: 0.6rem 0.9rem;
  background: var(--accent);
  color: var(--bg-base);
  font-weight: 600;
  border-radius: var(--radius);
  transform: translateY(-200%);
  transition: transform var(--transition);
  z-index: 1000;
  text-decoration: none;
}

.skip-link:focus-visible {
  transform: translateY(0);
}

.skip-link:visited {
  color: var(--bg-base);
}

/* ═══════════════════════════════════════════════════════════════════════════
   FOCUS STATES
   ═══════════════════════════════════════════════════════════════════════════ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.nav-link:focus-visible,
.page-link:focus-visible,
.tag:focus-visible,
.tag-cloud-item:focus-visible,
.post-footer-tag:focus-visible,
.post-item-tag:focus-visible {
  background: var(--bg-hover);
  border-color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   FORCED COLORS (Windows High Contrast Mode)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (forced-colors: active) {
  :focus-visible {
    outline: 2px solid CanvasText;
  }

  .page-link,
  .nav-link,
  .tag,
  .tag-cloud-item {
    forced-color-adjust: auto;
    border: 1px solid CanvasText;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════════════════════ */
@media print {
  body {
    background: white;
    color: black;
  }

  .header,
  .footer,
  .home-sidebar,
  .post-sidebar,
  .post-footer-nav,
  .pagination {
    display: none !important;
  }

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