/* ── Solarized palette ──────────────────────────────────────────────────────
   Light uses Solarized Light (base3 background, base00 text)
   Dark  uses Solarized Dark  (base03 background, base0 text)
   Accent (#2AA198 cyan) is identical in both themes.
   ─────────────────────────────────────────────────────────────────────────── */

:root {
  --bg:           #FDF6E3;  /* base3  — warm cream */
  --surface:      #EEE8D5;  /* base2  — panels, code bg */
  --border:       #93A1A1;  /* base1  — dividers */
  --text:         #657B83;  /* base00 — body text */
  --text-muted:   #93A1A1;  /* base1  — dates, meta */
  --heading:      #586E75;  /* base01 — headings */
  --accent:       #2AA198;  /* cyan   — links, active */
  --accent-hover: #1D8A80;
  --accent-light: #d6f0ed;  /* tinted bg for tags */
  --code-bg:      #EEE8D5;
  --code-text:    #586E75;
}

[data-theme="dark"] {
  --bg:           #002B36;  /* base03 */
  --surface:      #073642;  /* base02 */
  --border:       #586E75;  /* base01 */
  --text:         #839496;  /* base0  */
  --text-muted:   #586E75;  /* base01 */
  --heading:      #93A1A1;  /* base1  */
  --accent:       #2AA198;
  --accent-hover: #1D8A80;
  --accent-light: #073642;
  --code-bg:      #073642;
  --code-text:    #93A1A1;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:           #002B36;
    --surface:      #073642;
    --border:       #586E75;
    --text:         #839496;
    --text-muted:   #586E75;
    --heading:      #93A1A1;
    --accent:       #2AA198;
    --accent-hover: #1D8A80;
    --accent-light: #073642;
    --code-bg:      #073642;
    --code-text:    #93A1A1;
  }
}

/* ── Reset ──────────────────────────────────────────────────────────────── */

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

/* ── Base ───────────────────────────────────────────────────────────────── */

body {
  font-family: 'Noto Sans', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  transition: background-color 0.2s, color 0.2s;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
a:visited { color: var(--accent); }

h1, h2, h3, h4 {
  color: var(--heading);
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

p { margin-bottom: 1rem; }

ul, ol { padding-left: 1.5rem; margin-bottom: 1rem; }
li { margin-bottom: 0.25rem; }

blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  color: var(--text-muted);
  background: var(--surface);
}

img { max-width: 100%; height: auto; display: block; }

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

/* ── Code ───────────────────────────────────────────────────────────────── */

code {
  font-family: 'Source Code Pro', 'Menlo', monospace;
  font-size: 0.875em;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

pre {
  background: var(--code-bg);
  color: var(--code-text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  line-height: 1.6;
  white-space: pre;
  tab-size: 4;
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  border-radius: 0;
}

/* ── Page layout ─────────────────────────────────────────────────────────── */

#page {
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
  gap: 1rem;
}

#headerimg a {
  display: flex;
  flex-direction: column;
  text-decoration: none;
}

.site-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--heading);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.site-tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.3rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: 'Source Code Pro', monospace;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

.theme-toggle:hover {
  background: var(--border);
  color: var(--text);
}

/* ── Main columns ────────────────────────────────────────────────────────── */

#main {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

#content {
  flex: 1;
  min-width: 0;
}

#sidebar {
  width: 240px;
  flex-shrink: 0;
}

/* ── Posts ───────────────────────────────────────────────────────────────── */

.post {
  margin-bottom: 2.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
}

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

.post-header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

/* Date stamp widget */
.post-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 52px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.25rem;
  font-family: 'Source Code Pro', monospace;
  text-align: center;
}

.post-month {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  line-height: 1.2;
}

.post-day {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--heading);
  line-height: 1.1;
}

.post-year {
  font-size: 0.6rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.post-title {
  flex: 1;
  min-width: 0;
}

.post-title h2 {
  font-size: 1.3rem;
  margin-bottom: 0.25rem;
}

.post-title h2 a {
  color: var(--heading);
}

.post-title h2 a:hover {
  color: var(--accent);
  text-decoration: none;
}

.post-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.post-cats a {
  color: var(--text-muted);
  background: var(--accent-light);
  padding: 0.1em 0.45em;
  border-radius: 3px;
  font-size: 0.75rem;
  margin-right: 0.2rem;
}

.post-cats a:hover {
  color: var(--accent-hover);
  text-decoration: none;
}

.entry {
  padding-left: calc(52px + 1rem); /* align with post title */
  margin-top: 0.5rem;
}

.entry p:first-child { margin-top: 0; }

/* Single post page — no left padding offset */
article.post .entry {
  padding-left: 0;
  margin-top: 1rem;
}

/* ── Page ─────────────────────────────────────────────────────────────────── */

article.page h2 {
  font-size: 1.6rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.page-content h2 {
  font-size: 1.2rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  border-bottom: none;
  padding-bottom: 0;
}

/* ── Archive pages ───────────────────────────────────────────────────────── */

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

.archive-header h1 {
  font-size: 1.4rem;
}

.archive-header .post-count {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */

#sidebar {
  font-size: 0.875rem;
}

.pixel-dan {
  display: block;
  margin: 0 auto 1.25rem;
  image-rendering: pixelated;
}

.sidebar-nav ul {
  list-style: none;
  padding: 0;
  margin-bottom: 1.25rem;
}

.sidebar-nav li { margin-bottom: 0.2rem; }

.sidebar-nav a {
  display: block;
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  color: var(--text);
  font-weight: 500;
}

.sidebar-nav a:hover {
  background: var(--surface);
  color: var(--accent);
  text-decoration: none;
}

.sidebar-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-section:last-child {
  border-bottom: none;
}

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

.list-cat, .list-archives {
  list-style: none;
  padding: 0;
}

.list-cat li { margin-bottom: 0.2rem; }

.list-cat a, .list-archives a {
  color: var(--text);
  font-size: 0.85rem;
}

.list-cat a:hover, .list-archives a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* Archive year/month tree */
#ulArchives > li {
  margin-bottom: 0.2rem;
}

#ulArchives > li > ul {
  padding-left: 1rem;
  margin-top: 0.2rem;
}

#ulArchives > li > ul li {
  margin-bottom: 0.15rem;
}

.archive-year-toggle {
  display: inline-block;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid var(--text-muted);
  margin-right: 5px;
  vertical-align: middle;
  transition: transform 0.15s;
  cursor: pointer;
}

.archive-year-toggle.expanded {
  transform: rotate(90deg);
}

.rss-link { font-size: 0.8rem; }

/* Pagefind UI overrides */
:root {
  --pagefind-ui-scale: 0.75;
  --pagefind-ui-primary: var(--accent);
  --pagefind-ui-text: var(--text);
  --pagefind-ui-background: var(--bg);
  --pagefind-ui-border: var(--border);
  --pagefind-ui-tag: var(--surface);
}

/* ── Footer ──────────────────────────────────────────────────────────────── */

#footer {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.footer-recent-posts {
  flex: 1;
  min-width: 200px;
}

.footer-recent-posts h4 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.footer-recent-posts ul {
  list-style: none;
  padding: 0;
}

.footer-recent-posts li {
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.footer-recent-posts a { color: var(--text); font-size: 0.82rem; }
.footer-recent-posts a:hover { color: var(--accent); }
.footer-recent-posts small { color: var(--text-muted); font-size: 0.75rem; }

.footer-credits {
  width: 100%;
  padding-top: 1rem;
  font-size: 0.75rem;
  text-align: center;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 720px) {
  #main {
    flex-direction: column-reverse;
  }

  #sidebar {
    width: 100%;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1.5rem;
    margin-bottom: 1rem;
  }

  .entry {
    padding-left: 0;
  }

  .post-header {
    flex-wrap: wrap;
  }
}
