/* ============================================================
   TOKENS
   ============================================================ */
:root {
  --font-body: "EB Garamond", Georgia, serif;
  --font-mono: "DM Mono", monospace;

  --color-bg: #f7f5f1;
  --color-text: #18160f;
  --color-muted: #7a7670;
  --color-faint: #b8b4aa;
  --color-rule: #dedad2;
  --color-accent: #8c4a2f;

  --measure-post: 620px;
  --measure-index: 620px;

  --page-margin-x: clamp(1.5rem, 7vw, 5rem);
  --page-margin-y: clamp(2.5rem, 6vh, 4.5rem);

  --body-size: 1.125rem;
  --body-leading: 1.7;
  --para-gap: 1.7rem;
}

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

html {
  font-size: 17px;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--body-size);
  line-height: var(--body-leading);
  min-height: 100dvh;
  padding: var(--page-margin-y) var(--page-margin-x);
  margin: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

/* --- Link Defaults --- */
a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 0.5px;
  transition: opacity 0.2s ease;
}

a:hover {
  opacity: 0.7;
}

/* Force links to stay the same color after visiting */
a:visited {
  color: var(--color-accent);
}

/* Special Case: Meta Title (Intervallum) should stay dark/light text */
.meta__title,
.meta__title:visited {
  color: var(--color-text);
  text-decoration: none;
}

/* ============================================================
   META MODULE (shared between index and single)
   ============================================================ */
.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 1.5rem;
}

.meta__title {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--color-text);
}

.meta__link {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 0.5px;
}

.meta__dark-toggle {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
}

.meta__copy {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 300;
  color: var(--color-faint);
  margin-left: auto;
  align-self: center;
}

/* ============================================================
   DARK MODE
   ============================================================ */
body.dark {
  --color-bg: #1e1c1a;
  --color-text: #e8e4de;
  --color-muted: #8a8680;
  --color-faint: #5a5652;
  --color-rule: #2e2c29;
  --color-accent: #c47a56;
}

body.dark .refs-panel {
  background: #252320;
}

/* ============================================================
   INDEX PAGE
   ============================================================ */
.page {
  max-width: var(--measure-index);
  margin: 0 auto;
  width: 100%;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

.contents-heading {
  font-style: italic;
  font-weight: 400;
  font-size: 1.05rem;
  margin-bottom: 2.75rem;
}

/* ── Primary filter row ───────────────────────────── */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 1.25rem;
  margin-bottom: 0.6rem;
}

.filter-btn {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--color-faint);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
}
.filter-btn.active {
  color: var(--color-text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 0.5px;
}

/* ── References toggle ────────────────────────────── */
.refs-toggle-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1.25rem;
  margin-bottom: 0.4rem;
  margin-top: 0.15rem;
  line-height: 1.2;
}

.refs-toggle-btn {
  font-family: var(--font-mono);
  font-size: 0.63rem;
  font-weight: 300;
  color: var(--color-faint);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}
.refs-toggle-btn.active {
  color: var(--color-accent);
}

.refs-toggle-icon {
  font-style: normal;
  font-size: 0.7rem;
  line-height: 1;
}

.refs-active-label {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.63rem;
  line-height: 1;
  color: var(--color-accent);
  white-space: nowrap;
  display: none;
}

.refs-active-label.visible,
.refs-clear-btn.visible {
  display: inline-block;
}

.refs-clear-btn {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 300;
  color: var(--color-faint);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  letter-spacing: 0.04em;
  display: none;
}

.refs-active-label.visible,
.refs-clear-btn.visible {
  display: inline-block;
}

.refs-toggle-row:empty {
  display: none;
}

/* ── References panel ─────────────────────────────── */
.refs-panel {
  display: none;
  margin-bottom: 0.3rem;
  margin-top: 0;
  padding: 1.25rem 1.5rem;
  background: #f0ede7;
  border-left: 2px solid var(--color-accent);
}
.refs-panel.open {
  display: block;
}

.refs-panel__heading {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 300;
  color: var(--color-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.refs-book {
  margin-bottom: 1rem;
}
.refs-book:last-child {
  margin-bottom: 0;
}

.refs-book__name {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 300;
  color: var(--color-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.refs-book__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
}

.ref-btn {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--color-text);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
}
.ref-btn.active,
.tag-btn.active {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 0.5px;
}

.tag-btn {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--color-text);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
}

/* Adjacent toggle buttons — pipe separator between them */
.refs-toggle-btn + .refs-toggle-btn::before {
  content: "·";
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--color-rule);
  margin-right: 1.25rem;
  pointer-events: none;
}
.entry-list {
  list-style: none;
  flex: 1;
}

.entry {
  display: flex;
  align-items: last baseline;
  gap: 0.6rem;
  padding: 0.7rem 0;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.entry.hidden {
  display: none;
}

.entry__title {
  flex: 1;
  min-width: 0;
  font-size: 1.1rem;
  font-weight: 400;
  line-height: 1.4;
  color: var(--color-text);
}

.entry__dots {
  flex: 1 1 1rem;
  min-width: 0;
  max-width: 5rem;
  overflow: hidden;
  white-space: nowrap;
  align-self: flex-end;
  padding-bottom: 0.2em;
}
.dots {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--color-rule);
  letter-spacing: 0.25em;
}

.entry__date {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 300;
  color: var(--color-muted);
  white-space: nowrap;
  flex-shrink: 0;
  align-self: flex-end;
  padding-bottom: 0.15em;
}

/* ── Index footer ─────────────────────────────────── */
.toc-footer {
  margin-top: 1.75rem;
}

.toc-footer-count {
  font-family: var(--font-mono);
  font-size: 0.63rem;
  font-weight: 300;
  color: var(--color-faint);
  letter-spacing: 0.05em;
}

.index-meta {
  margin-top: auto;
  padding-top: 3rem;
}

/* ── Pagination ───────────────────────────────────── */
.pagination {
  display: flex;
  align-items: baseline;
  gap: 0.15rem 1rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.pagination__label {
  font-family: var(--font-mono);
  font-size: 0.63rem;
  font-weight: 300;
  color: var(--color-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pagination__btn {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--color-faint);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
}
.pagination__btn.active,
.pagination__btn[aria-current] {
  color: var(--color-text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 0.5px;
}

/* ============================================================
   SINGLE POST PAGE
   ============================================================ */
.post {
  max-width: var(--measure-post);
  margin: 0 auto;
  width: 100%;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

.post__header {
  margin-bottom: 1rem;
}

/* Category now lives inside .post__meta — inherits mono sizing */
.post__category {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 300;
  color: var(--color-accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 0.5px;
}
.post__category:visited {
  color: #8c4a2f;
}
body.dark .post__category:visited {
  color: #c47a56;
}

.post__meta {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 300;
  color: var(--color-faint);
  letter-spacing: 0.03em;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.15rem 1.5rem;
}

.post__meta--top {
  margin-bottom: 0.75rem;
}
.post__meta--bottom {
  margin-top: 0.6rem;
}

.post__tag {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.65rem;
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 0.5px;
}
.post__tag::before {
  content: "#";
  margin-right: 0.1em;
}

.post__title {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: clamp(1.5rem, 4vw, 2rem);
  line-height: 1.2;
  color: var(--color-text);
  margin-top: 0;
  margin-bottom: 0;
}

/* ── Body typography ──────────────────────────────── */
.post__body p {
  margin-bottom: var(--para-gap);
}
.post__body h2 + p,
.post__body h3 + p {
  text-indent: 0;
}

.post__body h2 {
  font-family: var(--font-body);
  font-weight: 500;
  font-style: italic;
  font-size: 1.125rem;
  line-height: var(--body-leading);
  color: var(--color-text);
  margin-top: 3rem;
  margin-bottom: 0.25rem;
}

.post__body h3 {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 300;
  color: var(--color-text);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

.post__body blockquote {
  margin: 2rem 0 2rem 1.75rem;
  padding: 0 0 0 1.25rem;
  border-left: 1.5px solid var(--color-rule);
}

.post__body blockquote p {
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--color-muted);
  font-style: italic;
  margin-bottom: 0.5rem;
}
.post__body blockquote p:last-child {
  margin-bottom: 0;
}

.post__body blockquote cite {
  display: block;
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 300;
  color: var(--color-faint);
  letter-spacing: 0.04em;
  margin-top: 0.6rem;
}

/* ============================================================
   FIGURES AND CAPTIONS
   ============================================================ */
figure {
  margin: 1.5rem 0 1.5rem 0;
}

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

.about figcaption p,
.post__body figcaption p {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 300;
  color: var(--color-faint);
  letter-spacing: 0.03em;
  text-align: right;
  margin-top: 0;
  margin-bottom: 0;
  line-height: 1.4;
}

/* ── Footnotes ────────────────────────────────────── */
/* Hugo's goldmark renders footnotes automatically.
   These classes target Hugo's output markup. */
.footnotes {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 0.5px solid var(--color-rule);
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--color-muted);
}

.footnotes::before {
  content: "Fotnoter";
  display: block;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 300;
  color: var(--color-faint);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

/* Hugo inserts an <hr> before the footnote list — hide it */
.footnotes > hr {
  display: none;
}

.footnotes ol {
  list-style: none;
  padding: 0;
  counter-reset: fn;
}

.footnotes li {
  display: grid;
  grid-template-columns: 1.5rem 1fr;
  gap: 0 0.5rem;
  margin-bottom: 0.2rem;
  counter-increment: fn;
}

/* Hugo wraps footnote text in <p> — kill its para-gap margin */
.footnotes li p {
  margin-bottom: 0;
}

.footnotes li::before {
  content: counter(fn);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 300;
  color: var(--color-accent);
  padding-top: 0.25em;
  text-align: right;
}

/* footnote back-reference arrow */
.footnotes li a[href^="#fnref"] {
  font-size: 0.6rem;
  color: var(--color-faint);
  margin-left: 0.3em;
}

/* footnote inline marker */
sup[id^="fnref"] a,
a.footnote-ref {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 300;
  color: var(--color-accent);
  text-decoration: none;
  margin-left: 0.1em;
}

/* ── Post footer ──────────────────────────────────── */
.post__footer {
  margin-top: 4rem;
}

/* ============================================================
   ABOUT PAGE
   ============================================================ */
.about {
  max-width: var(--measure-post);
  margin: 0 auto;
  width: 100%;
}

.about__title {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 1.125rem;
  line-height: var(--body-leading);
  color: var(--color-text);
  margin-bottom: 2rem;
}

.about p {
  font-size: var(--body-size);
  line-height: var(--body-leading);
  color: var(--color-text);
  margin-bottom: var(--para-gap);
}

.about img {
  width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem 0;
}

.about__back {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 300;
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 0.5px;
  margin-top: 3rem;
  letter-spacing: 0.06em;
}
.about__back:visited {
  color: #8c4a2f;
}
body.dark .about__back:visited {
  color: #c47a56;
}

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 500px) {
  :root {
    --body-size: 1.05rem;
    --page-margin-x: 1.25rem;
    --page-margin-y: 2rem;
  }
  .post__body blockquote {
    margin-left: 0.75rem;
  }
  .meta__copy {
    margin-left: 0;
  }
  .entry__dots {
    display: none;
  }
  .entry__date {
    color: var(--color-faint);
  }
  .refs-toggle-row {
    flex-direction: column; /* This forces the vertical stack */
    align-items: flex-start; /* Aligns everything to the left */
    gap: 0.7rem; /* Vertical space between each stack item */
  }

  /* This removes the dot separator between items when they are stacked */
  .refs-toggle-btn + .refs-toggle-btn::before {
    display: none;
  }

  /* Optional: Add a tiny bit of left padding to the second line of filters 
     so the hierarchy looks clear */
  .refs-active-label {
    padding-left: 0.5rem;
  }
}
