/* ---------- Theme variables (default palette: nord) ---------- */
:root {
  --bg: #eceff4;
  --bg-alt: #e5e9f0;
  --text: #2e3440;
  --text-muted: #66738e;
  --accent: #5e81ac;
  --accent-soft: #dbe3ee;
  --border: #d8dee9;
  --code-bg: #e5e9f0;

  /* Narrow on phones, opens up on larger screens */
  --max-width: 44rem;
  --content-width: 46rem;
  /* comfortable reading width for post text */
}

@media (min-width: 900px) {
  :root {
    --max-width: 62rem;
  }
}

@media (min-width: 1200px) {
  :root {
    --max-width: 74rem;
  }
}

/* Dark palette — follows system preference automatically */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #2e3440;
    --bg-alt: #3b4252;
    --text: #d8dee9;
    --text-muted: #8a94a8;
    --accent: #88c0d0;
    --accent-soft: #434c5e;
    --border: #434c5e;
    --code-bg: #3b4252;
  }
}

/* Forced dark via site.toml default_theme = "dark" */
:root[data-theme="dark"] {
  --bg: #2e3440;
  --bg-alt: #3b4252;
  --text: #d8dee9;
  --text-muted: #8a94a8;
  --accent: #88c0d0;
  --accent-soft: #434c5e;
  --border: #434c5e;
  --code-bg: #3b4252;
}

/* ---------- Alternate palettes — set palette = "violet"|"amber" in site.toml (default: nord) ---------- */

/* Violet (the original palette) */
:root[data-palette="violet"] {
  --bg: #ffffff;
  --bg-alt: #f4f2fa;
  --text: #1a1626;
  --text-muted: #5d5570;
  --accent: #6d28d9;
  --accent-soft: #e5deff;
  --border: #ddd6ee;
  --code-bg: #f4f2fa;
}

@media (prefers-color-scheme: dark) {
  :root[data-palette="violet"]:not([data-theme="light"]) {
    --bg: #12101a;
    --bg-alt: #1c1828;
    --text: #ece9f5;
    --text-muted: #9d94b3;
    --accent: #b79cff;
    --accent-soft: #2f2650;
    --border: #2d2742;
    --code-bg: #1c1828;
  }
}

:root[data-palette="violet"][data-theme="dark"] {
  --bg: #12101a;
  --bg-alt: #1c1828;
  --text: #ece9f5;
  --text-muted: #9d94b3;
  --accent: #b79cff;
  --accent-soft: #2f2650;
  --border: #2d2742;
  --code-bg: #1c1828;
}

/* Amber CRT */
:root[data-palette="amber"] {
  --bg: #fbf6ea;
  --bg-alt: #f3ead6;
  --text: #2b2114;
  --text-muted: #6f6249;
  --accent: #a16207;
  --accent-soft: #f0e2c0;
  --border: #e2d5ba;
  --code-bg: #f3ead6;
}

@media (prefers-color-scheme: dark) {
  :root[data-palette="amber"]:not([data-theme="light"]) {
    --bg: #100d07;
    --bg-alt: #1a150c;
    --text: #f2e3c2;
    --text-muted: #a08e6a;
    --accent: #ffb000;
    --accent-soft: #33270e;
    --border: #2e2514;
    --code-bg: #1a150c;
  }
}

:root[data-palette="amber"][data-theme="dark"] {
  --bg: #100d07;
  --bg-alt: #1a150c;
  --text: #f2e3c2;
  --text-muted: #a08e6a;
  --accent: #ffb000;
  --accent-soft: #33270e;
  --border: #2e2514;
  --code-bg: #1a150c;
}

/* ---------- Base ---------- */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font: 1rem/1.7 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 1.5rem;
}

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

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  line-height: 1.25;
}

img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

/* ---------- Header ---------- */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1rem;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.site-title {
  display: inline-flex;
  align-items: center;
  color: var(--text);
}

.site-title svg {
  width: 1.25rem;
  height: 1.25rem;
}

.contact-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
}

.contact-links a {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  font-size: .95rem;
}

.contact-links a svg {
  width: 1.1rem;
  height: 1.1rem;
}

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

/* ---------- Sub-header (index only) ---------- */
.sub-header {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: .55rem 1.25rem;
  display: flex;
  gap: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.sub-header a {
  color: var(--text-muted);
  font-size: .9rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 2px solid transparent;
  /* reserve space, no layout shift */
}

.sub-header a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-decoration: none;
}

/* ---------- Intro ---------- */
.intro h1 {
  margin-bottom: .25rem;
}

.intro p {
  color: var(--text-muted);
  margin-top: 0;
}

/* ---------- Post list ---------- */
.section-label {
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: .3rem;
}

.post-list {
  list-style: none;
  margin: 0 0 1rem;
}

/* Pinned posts flow straight into the regular list — no extra gap */
.pinned-posts .post-list {
  margin-bottom: 0;
}

.post-item {
  padding: .9rem 0;
  border-bottom: 1px solid var(--border);
}

.post-item.pinned {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .9rem 1rem;
  margin-bottom: 2rem;
}

/* On wide screens, post items become cards with breathing room
   between them; the pinned list gets the same gap so the two
   lists read as one continuous feed */
@media (min-width: 900px) {
  .post-list {
    display: grid;
    gap: 1rem;
  }

  .pinned-posts .post-list {
    margin-bottom: 1rem;
  }

  .post-item,
  .post-item.pinned {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.15rem;
    margin: 0;
    background: var(--bg-alt);
    display: flex;
    flex-direction: column;
  }

  .post-item .tag-row {
    margin-top: auto;
    padding-top: .5rem;
  }
}

.post-item-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .5rem;
}

.post-link {
  font-weight: 600;
  font-size: 1.05rem;
}

.post-item-head time {
  margin-left: auto;
  color: var(--text-muted);
  font-size: .85rem;
}

.post-summary {
  margin: .3rem 0 .2rem;
  color: var(--text-muted);
  font-size: .95rem;
}

.pin {
  font-size: .9rem;
}

/* ---------- Tags ---------- */
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .3rem;
}

.tag {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: .1rem .6rem;
  font-size: .8rem;
}

.tag:hover {
  text-decoration: none;
  filter: brightness(1.05);
}

.tag-big {
  font-size: .95rem;
  padding: .25rem .8rem;
}

.tag-count {
  opacity: .7;
  font-size: .8em;
  margin-left: .25rem;
}

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

/* ---------- Post pages ---------- */
.post {
  margin: 0 auto;
}

@media (min-width: 900px) {
  .post_body {
    font-size: 1.05rem;
    line-height: 1.8;
  }
}

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

.post-body pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .9rem 1rem;
  overflow-x: auto;
  font-size: .9rem;
}

.post-body code {
  background: var(--code-bg);
  border-radius: 4px;
  padding: .1rem .35rem;
  font-size: .9em;
}

.post-body pre code {
  background: none;
  padding: 0;
}

.post-body blockquote {
  margin: 1rem 0;
  padding: .2rem 1rem;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
  background: var(--bg-alt);
  border-radius: 0 6px 6px 0;
}

.post-body table {
  border-collapse: collapse;
  width: 100%;
}

.post-body th,
.post-body td {
  border: 1px solid var(--border);
  padding: .4rem .6rem;
}


/* ---------- Footer ---------- */
.site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
  border-top: 1px solid var(--border);
}

/* "Home page" stays left, contact icons align right like in the header */
.site-footer .contact-links a:first-child {
  margin-right: auto;
  border-bottom: 2px solid transparent;
  /* reserve space, no layout shift — matches .sub-header links */
}

.site-footer .contact-links a:first-child:hover {
  border-bottom-color: var(--accent);
}

/* ---------- Mobile tweaks ---------- */
@media (max-width: 480px) {
  body {
    font-size: .97rem;
  }

  .post-item-head time {
    margin-left: 0;
    width: 100%;
  }

  .site-header {
    padding: .8rem 1rem;
  }
}