/* darvein.net — minimal futuristic dark theme */

:root {
  --bg: #0b0e14;
  --bg-raised: #11151f;
  --line: #1c2230;
  --text: #c8d0dc;
  --text-dim: #6b7689;
  --accent: #5ea2ff;
  --accent-2: #9ecbff;
  --code-bg: #11151f;
  --glow-soft: rgba(94, 162, 255, 0.07);
  --glow-sel: rgba(94, 162, 255, 0.28);
  --glow-card: rgba(94, 162, 255, 0.12);
  --glow-strong: rgba(94, 162, 255, 0.35);
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --frame: 62rem;  /* outer container width — same on every page (header/footer/content) */
  --read: 46rem;   /* comfortable reading measure for long-form prose */
}

[data-theme="light"] {
  --bg: #f4f6fa;
  --bg-raised: #ffffff;
  --line: #dbe2ee;
  --text: #26303f;
  --text-dim: #66718a;
  --accent: #2b6cdf;
  --accent-2: #1e56c4;
  --glow-soft: rgba(43, 108, 223, 0.06);
  --glow-sel: rgba(43, 108, 223, 0.22);
  --glow-card: rgba(43, 108, 223, 0.14);
  --glow-strong: rgba(43, 108, 223, 0.3);
}

* { box-sizing: border-box; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 10;
  padding: 0.5rem 1rem;
  background: var(--bg-raised);
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.9rem;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

html {
  background: var(--bg);
  scrollbar-color: var(--line) var(--bg);
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--text);
  background:
    radial-gradient(60rem 24rem at 50% -12rem, var(--glow-soft), transparent 70%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

.frame {
  max-width: var(--frame);
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; min-width: 0; }

/* Long-form prose (individual posts, about, now) sits in one readable,
   centered column — while the outer frame stays the same width as every
   other page, so the header and footer never jump around between pages. */
.post, .page {
  width: 100%;
  max-width: var(--read);
  margin-inline: 0;
}

/* ── sidebar layout ─────────────────────────── */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
  align-items: start;
}
@media (min-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr) 13rem; }
}

.sidebar {
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}
@media (min-width: 900px) {
  .sidebar {
    position: sticky;
    top: 1.5rem;
    border-left: 1px solid var(--line);
    padding-left: 1.5rem;
  }
}

.sidebar h4 {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin: 0 0 0.5rem;
  text-transform: uppercase;
}
.sidebar h4::before { content: "▸ "; }

.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar li {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.14rem 0;
}
.sidebar li a { color: var(--text-dim); }
.sidebar li a:hover { color: var(--accent); text-decoration: none; }
.sidebar .count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  opacity: 0.7;
}
.sidebar .recent li {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

::selection { background: var(--glow-sel); }

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

/* ── header ─────────────────────────────────── */

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  padding: 1.75rem 0 1.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2.5rem;
}

.brand {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
}
.brand:hover { color: var(--text); text-decoration: none; }

.brand-sigil {
  color: var(--accent);
  margin-right: 0.45rem;
}

.cursor {
  color: var(--accent);
  animation: blink 1.2s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.site-header nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  font-family: var(--mono);
  font-size: 0.9rem;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle .ico-moon { display: none; }
[data-theme="light"] .theme-toggle .ico-moon { display: inline; }
[data-theme="light"] .theme-toggle .ico-sun { display: none; }
.site-header nav a { color: var(--text-dim); }
.site-header nav a:hover,
.site-header nav a.active { color: var(--accent); text-decoration: none; }
.site-header nav a.active::before { content: "▸"; margin-right: 0.3rem; }

/* ── home / lists ───────────────────────────── */

.intro { margin-bottom: 2.5rem; }
.intro h1 {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--text);
}
.intro p { margin: 0; color: var(--text-dim); }

.year-group { margin-bottom: 2.25rem; }

.year {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.2em;
  margin: 0 0 0.75rem;
}
.year::after {
  content: "";
  display: inline-block;
  vertical-align: middle;
  width: 6rem;
  height: 1px;
  margin-left: 0.9rem;
  background: linear-gradient(90deg, var(--line), transparent);
}

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.post-list li {
  display: flex;
  align-items: baseline;
  gap: 1.1rem;
  padding: 0.32rem 0;
}
.post-list time {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-dim);
  flex-shrink: 0;
}
.post-list a { color: var(--text); }
.post-list a:hover { color: var(--accent); text-decoration: none; }

/* ── post cards ─────────────────────────────── */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px var(--glow-card);
}

.card-link { display: block; color: inherit; }
.card-link:hover { text-decoration: none; color: inherit; }

.card-thumb {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}
.card:hover .card-thumb img { transform: scale(1.04); }

.card-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(12rem 8rem at 50% 120%, var(--glow-card), transparent 70%),
    var(--bg);
}
.card-thumb-empty span {
  font-family: var(--mono);
  font-size: 2.2rem;
  color: var(--accent);
  opacity: 0.55;
}

.card-body { padding: 0.85rem 1rem 1rem; }
.card-body time {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  letter-spacing: 0.06em;
}
.card-body h3 {
  margin: 0.3rem 0 0.4rem;
  font-size: 1.1rem;
  line-height: 1.35;
  color: var(--text);
}
.card:hover .card-body h3 { color: var(--accent); }
.card-body p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text-dim);
}

.more-link {
  margin-top: 1.75rem;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.9rem;
}

/* ── single post ────────────────────────────── */

.post-header { margin-bottom: 2rem; }
.post-header h1 {
  font-size: 2rem;
  line-height: 1.25;
  margin: 0 0 0.6rem;
  letter-spacing: -0.01em;
}

.post-meta {
  font-family: var(--mono);
  font-size: 0.88rem;
  color: var(--text-dim);
}
.post-meta .sep { margin: 0 0.45rem; color: var(--line); }

.tag {
  font-family: var(--mono);
  font-size: 0.88rem;
  color: var(--accent);
}
.tag sup { color: var(--text-dim); margin-left: 0.15rem; }

.prose { overflow-wrap: break-word; }
.prose h2, .prose h3, .prose h4 {
  font-family: var(--mono);
  letter-spacing: -0.01em;
  margin: 2rem 0 0.75rem;
  line-height: 1.3;
}
.prose h2 { font-size: 1.4rem; }
.prose h3 { font-size: 1.15rem; }
.prose h2::before, .prose h3::before {
  content: "▚ ";
  color: var(--accent);
  font-size: 0.8em;
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: block;
  margin: 1.5rem auto;
}

.prose figure {
  margin: 1.5rem 0;
  text-align: center;
}
.prose figure img { margin: 0 auto; }
.prose figcaption {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
}

.prose .ext-img img, .prose img.ext-img {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: block;
  margin: 1.5rem auto;
}

.prose audio { width: 100%; margin: 1rem 0; }
.prose video { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); margin: 1.5rem 0; }

.video-embed {
  position: relative;
  aspect-ratio: 16 / 9;
  margin: 1.5rem 0;
}
.video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.prose blockquote {
  margin: 1.5rem 0;
  padding: 0.25rem 1.25rem;
  border-left: 2px solid var(--accent);
  background: var(--bg-raised);
  border-radius: 0 8px 8px 0;
  color: var(--text-dim);
  font-style: italic;
}

.prose code {
  font-family: var(--mono);
  font-size: 0.95em;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

.prose pre {
  /* chroma colors are tuned for dark — keep code blocks dark in both themes */
  background: var(--code-bg) !important;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-size: 0.92rem;
  line-height: 1.55;
}
.prose pre code {
  background: none;
  border: none;
  padding: 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
  margin: 1.5rem 0;
  display: block;
  overflow-x: auto;
}
.prose th, .prose td {
  text-align: left;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--line);
}
.prose th {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent);
  background: var(--bg-raised);
}

.prose hr {
  border: none;
  height: 1px;
  margin: 2.5rem 0;
  background: linear-gradient(90deg, transparent, var(--line) 20%, var(--line) 80%, transparent);
}

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
}
.post-nav .next { margin-left: auto; text-align: right; }

/* ── hub pages (uses / projects / bookshelf) ── */

.hub-updated {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  margin: -1.5rem 0 2rem;
}

.kv {
  display: grid;
  grid-template-columns: minmax(7rem, 13rem) 1fr;
  gap: 0.4rem 1.5rem;
  margin: 0;
}
.kv dt { color: var(--text); font-weight: 500; }
.kv dd { margin: 0; color: var(--text-dim); }

.project-tags {
  margin-top: 0.7rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}
.project-tags .tag { font-size: 0.78rem; }

.book-list li { flex-wrap: wrap; gap: 0.4rem 0.6rem; }
.book-rating {
  color: var(--accent);
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  flex-shrink: 0;
  min-width: 4.6rem;
}
.book-title { color: var(--text); font-weight: 500; }
.book-author { color: var(--text-dim); }
.book-note {
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.9rem;
  width: 100%;
  padding-left: 5.2rem;
}

@media (max-width: 540px) {
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dt { margin-top: 0.65rem; }
  .kv dd { margin-bottom: 0.2rem; }
  .book-note { padding-left: 0; }
}

/* ── term cloud ─────────────────────────────── */

.term-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem 1.4rem;
}

/* ── pagination ─────────────────────────────── */

.pagination {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  list-style: none;
  padding: 1.5rem 0 0;
  font-family: var(--mono);
  font-size: 0.85rem;
}
.pagination .page-link { padding: 0.2rem 0.6rem; }
.pagination .active .page-link {
  color: var(--bg);
  background: var(--accent);
  border-radius: 4px;
}

/* ── footer ─────────────────────────────────── */

.site-footer {
  margin-top: 4rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-dim);
}
.site-footer .social {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-bottom: 0.6rem;
}
.site-footer .social a { color: var(--text-dim); }
.site-footer .social a:hover { color: var(--accent); }
.colophon { margin: 0; }
.colophon a { color: var(--text-dim); }

/* ── search (pagefind) ──────────────────────── */

#search {
  --pagefind-ui-primary: var(--accent);
  --pagefind-ui-text: var(--text);
  --pagefind-ui-background: var(--bg-raised);
  --pagefind-ui-border: var(--line);
  --pagefind-ui-tag: var(--bg-raised);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: 8px;
  --pagefind-ui-font: var(--sans);
}
#search .pagefind-ui__result-link { color: var(--accent); }
#search .pagefind-ui__result-excerpt mark {
  background: var(--glow-sel);
  color: var(--text);
  border-radius: 2px;
}

/* ── 404 ────────────────────────────────────── */

.notfound h1 {
  font-size: 4rem;
  color: var(--accent);
  text-shadow: 0 0 24px var(--glow-strong);
}

/* ── large / wide screens ───────────────────────
   Fixed-width columns leave big empty gutters on
   desktop. Bump the root size (everything is in rem,
   so the whole UI scales up on hi-dpi displays while
   the reading measure stays constant) and let the
   list/sidebar container use the extra width for more
   card columns. Long-form prose stays a readable width. */

@media (min-width: 1200px) {
  .frame { max-width: 72rem; }
  /* a bit more room for the sidebar so it doesn't crowd the content */
  .layout { grid-template-columns: minmax(0, 1fr) 15rem; }
}
@media (min-width: 1600px) {
  .frame { max-width: 80rem; }
}
@media (min-width: 2000px) {
  html { font-size: 17px; }
  .frame { max-width: 88rem; }
  :root { --read: 48rem; }
}
@media (min-width: 2560px) {
  html { font-size: 18px; }
  .frame { max-width: 96rem; }
}

/* ── small screens ──────────────────────────── */

@media (max-width: 540px) {
  body { font-size: 1.0625rem; }
  .post-list li { flex-direction: column; gap: 0; padding: 0.55rem 0; }
  .post-nav { flex-direction: column; }
  .post-nav .next { margin-left: 0; text-align: left; }
}
