/* =========================================================
   Reset & Variables
   ========================================================= */

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

:root {
  --bg:             #131913;
  --sidebar-bg:     #162016;
  --sidebar-hover:  #1b2a1c;
  --sidebar-active: #223423;
  --text:           #33ff33;
  --text-muted:     #228822;
  --text-light:     #1a5c1a;
  --accent:         #66ff66;
  --border:         #2a5a2a;
  --code-bg:        #101810;
  --sidebar-w:      260px;
  --content-max:    700px;
  --r:              2px;
  --font:           "IBM Plex Mono", "Courier New", "Lucida Console", monospace;
  --mono:           "IBM Plex Mono", "Courier New", "Lucida Console", monospace;
  --ease:           0.12s ease;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: auto;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  text-shadow: 0 0 6px rgba(51, 255, 51, 0.45);
}

a { color: inherit; }

/* =========================================================
   Layout
   ========================================================= */

.layout {
  display: flex;
  min-height: 100vh;
}

/* =========================================================
   Sidebar
   ========================================================= */

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-header {
  padding: 1.375rem 1.25rem 1.125rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.site-title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
  display: block;
  transition: color var(--ease);
}

.site-title:hover { color: var(--accent); text-shadow: 0 0 10px rgba(102, 255, 102, 0.7); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-prompt {
  padding: 0.95rem 1.125rem 1.1rem;
  border-top: 1px solid var(--border);
  color: var(--accent);
  flex-shrink: 0;
  font-size: 1.55rem;
  line-height: 1;
  letter-spacing: 0.04em;
  text-shadow: 0 0 10px rgba(102, 255, 102, 0.75);
}

/* =========================================================
   Nav sections  (details / summary)
   ========================================================= */

details {
  border-bottom: 1px solid var(--border);
}

details > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 1.125rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: background var(--ease), color var(--ease);
}

details > summary::-webkit-details-marker { display: none; }
details > summary::marker               { display: none; }

details > summary::after {
  content: "›";
  font-size: 1.1rem;
  font-weight: 400;
  line-height: 1;
  display: inline-block;
  transition: transform var(--ease);
}

details[open] > summary::after { transform: rotate(90deg); }

details > summary:hover {
  background: var(--sidebar-hover);
  color: var(--text);
}

/* =========================================================
   Nav links
   ========================================================= */

.nav-list {
  list-style: none;
  padding: 0.25rem 0 0.375rem;
}

.nav-link {
  display: block;
  padding: 0.3125rem 1.125rem 0.3125rem 1.375rem;
  font-size: 0.875rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 2px solid transparent;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: var(--accent);
  border-left-color: var(--accent);
  text-shadow: 0 0 8px rgba(102, 255, 102, 0.6);
}

.nav-link.active {
  background: var(--sidebar-active);
  color: var(--accent);
  font-weight: 500;
  border-left-color: var(--accent);
  text-shadow: 0 0 8px rgba(102, 255, 102, 0.6);
}

.nav-empty {
  padding: 0.3125rem 1.375rem;
  font-size: 0.8125rem;
  color: var(--text-light);
  font-style: italic;
}

.archive-link {
  display: block;
  padding: 0.375rem 1.125rem 0.625rem 1.375rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--ease);
}

.archive-link:hover,
.archive-link.active { color: var(--accent); }

/* =========================================================
   Mobile toggle button
   ========================================================= */

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 0.875rem;
  left: 0.875rem;
  z-index: 300;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  width: 36px;
  height: 36px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  transition: background var(--ease);
}

.sidebar-toggle:hover { background: var(--sidebar-hover); }

.sidebar-toggle span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--text);
  border-radius: 2px;
}

/* =========================================================
   Backdrop (mobile)
   ========================================================= */

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ease);
}

.sidebar-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* =========================================================
   Main content
   ========================================================= */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 2.75rem 3.5rem;
}

.site-footer {
  max-width: var(--content-max);
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: #4fb84f;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* =========================================================
   Article header
   ========================================================= */

.article-header {
  max-width: var(--content-max);
  margin-bottom: 2rem;
  padding-bottom: 1.375rem;
  border-bottom: 1px solid var(--border);
}

.article-title {
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 0.375rem;
}

.article-meta {
  font-size: 0.875rem;
  color: #59c959;
}

/* =========================================================
   Article body  (rendered markdown)
   ========================================================= */

.article-body {
  max-width: var(--content-max);
  font-size: 1rem;
  line-height: 1.75;
}

/* vertical rhythm */
.article-body > * + * { margin-top: 1em; }

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4,
.article-body h5,
.article-body h6 {
  margin-top: 1.75em;
  margin-bottom: 0.4em;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.article-body h1 { font-size: 1.6rem; margin-top: 0; }
.article-body h2 { font-size: 1.3rem; border-bottom: 1px solid var(--border); padding-bottom: 0.25rem; }
.article-body h3 { font-size: 1.1rem; }
.article-body h4 { font-size: 1rem; font-weight: 600; }

.article-body a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(91, 106, 191, 0.3);
  transition: border-color var(--ease);
}

.article-body a:hover { border-bottom-color: var(--accent); }

.article-body ul,
.article-body ol { padding-left: 1.5rem; }

.article-body li + li { margin-top: 0.2rem; }

.article-body blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.5em 0;
  padding: 0.5em 1em;
  background: rgba(51, 255, 51, 0.08);
  border-radius: 0 var(--r) var(--r) 0;
  color: #8aff8a;
}

.article-body blockquote > * + * { margin-top: 0.4em; }

/* Inline code */
.article-body code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: #050a05;
  color: #88ff88;
  padding: 0.15em 0.35em;
  border-radius: 2px;
  border: 1px solid var(--border);
}

/* Fenced/indented code blocks */
.article-body pre {
  background: var(--code-bg);
  border-radius: var(--r);
  border: 1px solid var(--border);
  padding: 1.25rem 1.375rem;
  overflow-x: auto;
  margin: 1.25em 0 !important;
  line-height: 1.55;
}

.article-body pre code {
  background: none;
  color: #55dd55;
  padding: 0;
  font-size: 0.875rem;
  border-radius: 0;
  border: none;
  line-height: inherit;
  text-shadow: 0 0 4px rgba(85, 221, 85, 0.5);
}

/* codehilite wrapped blocks */
.codehilite {
  border-radius: var(--r);
  overflow: hidden;
  margin: 1.25em 0;
}

.codehilite pre {
  margin: 0 !important;
  padding: 1.25rem 1.375rem;
  overflow-x: auto;
  line-height: 1.55;
  border-radius: 0;
}

/* Permalink anchors added by toc extension */
.article-body .headerlink {
  font-size: 0.75em;
  opacity: 0;
  margin-left: 0.4em;
  text-decoration: none;
  border: none;
  transition: opacity var(--ease);
}

.article-body h1:hover .headerlink,
.article-body h2:hover .headerlink,
.article-body h3:hover .headerlink,
.article-body h4:hover .headerlink { opacity: 0.5; }

/* Tables */
.article-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  overflow-x: auto;
  display: block;
}

.article-body thead th {
  background: var(--sidebar-bg);
  font-weight: 600;
  text-align: left;
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
}

.article-body tbody td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.75rem;
}

.article-body tbody tr:nth-child(even) td { background: rgba(0, 0, 0, 0.018); }

/* Images */
.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--r);
  display: block;
}

/* HR */
.article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

/* TOC div generated by toc extension */
.article-body .toc {
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 0.75rem 1rem 0.75rem 0.5rem;
  font-size: 0.875rem;
  display: inline-block;
  min-width: 180px;
  max-width: 100%;
}

.article-body .toc ul  { padding-left: 1.25rem; }
.article-body .toc > ul { padding-left: 0; }
.article-body .toc li  { margin-top: 0.2em; }
.article-body .toc a   { color: var(--text); border: none; }
.article-body .toc a:hover { color: var(--accent); }

/* =========================================================
   Archive page
   ========================================================= */

.archive-page { max-width: var(--content-max); }

.archive-header {
  margin-bottom: 1.75rem;
  padding-bottom: 1.375rem;
  border-bottom: 1px solid var(--border);
}

.archive-title {
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.archive-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.archive-list { list-style: none; }

.archive-item {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  padding: 0.5625rem 0;
  border-bottom: 1px solid var(--border);
}

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

.archive-item-date {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: #4fb84f;
  min-width: 6.25rem;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.archive-item-link {
  color: var(--text);
  text-decoration: none;
  font-size: 0.9375rem;
  transition: color var(--ease);
}

.archive-item-link:hover { color: var(--accent); }

.archive-empty {
  color: var(--text-muted);
  font-style: italic;
  padding: 1rem 0;
}

/* =========================================================
   Pagination
   ========================================================= */

.pagination {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.page-link,
.page-current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.125rem;
  height: 2.125rem;
  padding: 0 0.5rem;
  border-radius: var(--r);
  font-size: 0.875rem;
  text-decoration: none;
  transition: background var(--ease), color var(--ease);
}

.page-link {
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: var(--bg);
}

.page-link:hover {
  background: var(--sidebar-hover);
  color: var(--text);
}

.page-current {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  border: 1px solid var(--accent);
}

.page-ellipsis {
  color: var(--text-light);
  padding: 0 0.25rem;
  user-select: none;
}

.page-prev,
.page-next { padding: 0 0.75rem; }

/* =========================================================
   Home feed
   ========================================================= */

.home-feed { max-width: var(--content-max); }

.feed-title {
  font-size: 2rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #9bff9b;
  margin: 0.15rem 0 1.45rem;
  text-shadow: 0 0 12px rgba(155, 255, 155, 0.75), 0 0 4px rgba(155, 255, 155, 0.8);
}

.feed-article {
  padding-bottom: 3rem;
  margin-bottom: 3rem;
  border-bottom: 1px solid var(--border);
}

.feed-article:last-of-type {
  border-bottom: none;
  margin-bottom: 1.5rem;
}

.feed-archive-link {
  padding: 1.25rem 0 2rem;
  border-top: 1px solid var(--border);
}

.feed-archive-link a {
  font-size: 0.9375rem;
  color: var(--accent);
  text-decoration: none;
  transition: text-shadow var(--ease);
}

.feed-archive-link a:hover {
  text-shadow: 0 0 8px rgba(102, 255, 102, 0.6);
}

/* =========================================================
   Empty state
   ========================================================= */

.empty-state {
  max-width: var(--content-max);
  padding: 5rem 2rem;
  text-align: center;
  color: var(--text-muted);
}

.empty-state h2 {
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.empty-state code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: #050a05;
  color: var(--accent);
  padding: 0.15em 0.35em;
  border-radius: 2px;
  border: 1px solid var(--border);
}

/* =========================================================
   404
   ========================================================= */

.error-page {
  max-width: var(--content-max);
  padding: 5rem 0;
}

.error-page h1 {
  font-size: 5rem;
  font-weight: 800;
  color: var(--text-light);
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.error-page p {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.error-page a {
  color: var(--accent);
  text-decoration: none;
}

.error-page a:hover { text-decoration: underline; }

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 768px) {
  .sidebar-toggle { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    transform: translateX(-100%);
    transition: transform var(--ease);
    z-index: 200;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.12);
  }

  .sidebar.open { transform: translateX(0); }

  .main-content {
    padding: 4rem 1.5rem 2rem;
  }
}

@media (max-width: 480px) {
  .main-content { padding: 3.75rem 1rem 1.5rem; }
  .article-title { font-size: 1.5rem; }
  .archive-title  { font-size: 1.5rem; }

  .archive-item {
    flex-direction: column;
    gap: 0.1rem;
  }

  .archive-item-date { min-width: auto; }
}

/* =========================================================
   CRT / Scanline effect
   ========================================================= */

body::after {
  content: "";
  display: block;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, 0.05) 2px,
    rgba(0, 0, 0, 0.05) 4px
  );
}

/* Subtle vignette */
body::before {
  content: "";
  display: block;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  background: radial-gradient(
    ellipse at center,
    transparent 72%,
    rgba(0, 0, 0, 0.16) 100%
  );
}

/* Blinking cursor on the site title */
.site-title::after {
  content: "_";
  animation: blink 1.1s step-end infinite;
  margin-left: 1px;
}

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