/* ============================================================
   Marginalia — the design system for "Interpretation"
   Light: ivory vellum, oxblood rubric, ink-blue gloss.
   Dark:  candlelit ink, the same two voices, embered.
   ============================================================ */

:root {
  --c-bg:          #F6F2E8;
  --c-surface:     #EFE9DA;
  --c-text:        #26241F;
  --c-text-muted:  #5C574C;
  --c-text-faint:  #8E8779;
  --c-border:      #DDD5C2;
  --c-border-firm: #C2B89F;
  --c-accent:      #882C33;   /* oxblood — the human hand */
  --c-gloss:       #33546E;   /* ink blue — the machine reader */
}

html.dark {
  --c-bg:          #191713;
  --c-surface:     #221F1A;
  --c-text:        #E8E1D1;
  --c-text-muted:  #ABA28E;
  --c-text-faint:  #76705F;
  --c-border:      #353026;
  --c-border-firm: #4D4636;
  --c-accent:      #C9636B;
  --c-gloss:       #7FA3C0;
}

body {
  background-color: var(--c-bg);
  color: var(--c-text);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Laid-paper grain over everything, very faint */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection {
  background: var(--c-accent);
  color: var(--c-bg);
}

/* ---------- apparatus (labels, sigla) ---------- */

.rubric-label {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--c-text-faint);
}

.siglum {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  color: var(--c-text-faint);
}

/* ---------- the annotated quotation ---------- */

.lemma {
  /* a phrase under commentary: dotted underline in the annotator's ink */
  text-decoration: underline dotted var(--c-accent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.3em;
}

.lemma--gloss {
  text-decoration-color: var(--c-gloss);
}

.note-marker {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.6em;
  vertical-align: super;
  font-style: normal;
  font-weight: 500;
}

.margin-note {
  position: relative;
  padding-left: 1.1rem;
  font-size: 0.95rem;
  line-height: 1.55;
}
.margin-note::before {
  position: absolute;
  left: 0;
  top: 0.1rem;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.7rem;
  font-weight: 500;
}
.margin-note--hand {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-style: italic;
  font-size: 1.08rem;
  color: var(--c-accent);
}
.margin-note--hand::before { content: "a"; color: var(--c-accent); }
.margin-note--machine {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  color: var(--c-gloss);
}
.margin-note--machine::before { content: "b"; color: var(--c-gloss); }

/* connector rule from note to text on large screens */
@media (min-width: 1024px) {
  .margin-note::after {
    content: "";
    position: absolute;
    top: 0.65rem;
    width: 1.6rem;
    border-top: 1px dotted var(--c-border-firm);
  }
  .note-col-left .margin-note::after { right: -2rem; }
  .note-col-right .margin-note::after { left: -2rem; }
}

/* ---------- prose ---------- */

.prose-reading {
  font-family: "Newsreader", Georgia, serif;
  font-size: 1.13rem;
  line-height: 1.75;
  color: var(--c-text);
}
.prose-reading p + p { margin-top: 1.1em; }
.prose-reading em { font-style: italic; }

.prose-reading--dropcap > p:first-child::first-letter {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  font-size: 3.4em;
  line-height: 0.82;
  float: left;
  padding-right: 0.09em;
  color: var(--c-accent);
}

/* ---------- reading body (kramdown output in _texts/) ---------- */

.reading-body h2 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  font-size: 1.9rem;
  line-height: 1.15;
  margin-top: 2.6em;
  margin-bottom: 0.7em;
  color: var(--c-text);
}
.reading-body h2:first-child { margin-top: 0; }
.reading-body h3 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  font-size: 1.4rem;
  margin-top: 2em;
  margin-bottom: 0.6em;
  color: var(--c-text);
}
.reading-body p { margin-top: 1.1em; }
.reading-body a {
  color: var(--c-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
.reading-body blockquote {
  margin: 1.6em 0;
  padding-left: 1.4rem;
  border-left: 2px solid var(--c-accent);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.22em;
  line-height: 1.5;
  color: var(--c-text);
}
.reading-body blockquote cite,
.reading-body blockquote .src {
  display: block;
  margin-top: 0.6em;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-style: normal;
  font-size: 0.62em;
  letter-spacing: 0.06em;
  color: var(--c-text-faint);
}
.reading-body ul, .reading-body ol { margin: 1.1em 0 1.1em 1.4em; }
.reading-body ul { list-style: none; }
.reading-body ul > li { position: relative; padding-left: 1.1em; margin-top: 0.45em; }
.reading-body ul > li::before {
  content: "\00B6";
  position: absolute;
  left: 0;
  color: var(--c-accent);
  font-size: 0.8em;
  top: 0.18em;
}
.reading-body ol { list-style: decimal; }
.reading-body ol > li { margin-top: 0.45em; padding-left: 0.3em; }
.reading-body hr {
  border: 0;
  margin: 2.4em 0;
  text-align: center;
}
.reading-body hr::after {
  content: "\2042";
  color: var(--c-text-faint);
  font-size: 1.1rem;
  letter-spacing: 0.4em;
}
.reading-body strong { font-weight: 600; }

/* table of contents */
.reading-toc ol { font-family: "Newsreader", Georgia, serif; font-size: 0.88rem; }
.reading-toc a {
  display: block;
  color: var(--c-text-muted);
  line-height: 1.4;
  border-left: 1px solid var(--c-border);
  padding-left: 0.8rem;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.reading-toc a:hover { color: var(--c-accent); }
.reading-toc a.is-active { color: var(--c-accent); border-left-color: var(--c-accent); }

/* ---------- the model's note: the AI speaking in its own voice ---------- */

.model-note {
  margin: 2em 0;
  border: 1px solid var(--c-gloss);
  border-left-width: 3px;
  background: color-mix(in srgb, var(--c-gloss) 6%, var(--c-bg));
  padding: 1.2rem 1.4rem 1.1rem;
  border-radius: 0.125rem;
}
.model-note-tag {
  display: block;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-gloss);
  margin-bottom: 0.7rem;
}
.model-note p {
  font-family: "Newsreader", Georgia, serif;
  font-size: 0.98rem;
  line-height: 1.65;
  color: var(--c-text);
  margin-top: 0.6em;
}
.model-note p:first-of-type { margin-top: 0; }
.model-note-meta {
  margin-top: 0.9rem !important;
  font-family: "IBM Plex Mono", ui-monospace, monospace !important;
  font-size: 0.64rem !important;
  color: var(--c-text-faint) !important;
  letter-spacing: 0.04em;
}

/* ---------- dividers ---------- */

.asterism {
  text-align: center;
  font-size: 1.3rem;
  letter-spacing: 0.5em;
  color: var(--c-text-faint);
  user-select: none;
}

.ledger-rule {
  border: 0;
  border-top: 1px solid var(--c-border);
  position: relative;
}
.ledger-rule::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 0;
  right: 0;
  border-top: 1px solid var(--c-border);
}

/* ---------- folio cards (the shelf) ---------- */

.folio-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border-firm);
  position: relative;
  transition: border-color 0.25s ease, transform 0.25s ease;
}
.folio-card:hover {
  border-color: var(--c-accent);
  transform: translateY(-2px);
}
.folio-card::before {
  /* a turned corner */
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 18px 18px 0;
  border-color: transparent var(--c-bg) transparent transparent;
}
.folio-card::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 18px;
  height: 18px;
  border-left: 1px solid var(--c-border-firm);
  border-bottom: 1px solid var(--c-border-firm);
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}

.folio-card--empty {
  background: transparent;
  border: 1px dashed var(--c-border-firm);
}
.folio-card--empty:hover { border-color: var(--c-border-firm); transform: none; }
.folio-card--empty::before, .folio-card--empty::after { content: none; }

/* ---------- reveal on load / scroll ---------- */

.reveal {
  opacity: 0;
  transform: translateY(14px);
  animation: reveal-up 0.7s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

/* hidden-until-scroll only when JS is available to reveal it */
html.js [data-reveal] {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.7s cubic-bezier(0.22, 0.61, 0.36, 1),
              transform 0.7s cubic-bezier(0.22, 0.61, 0.36, 1);
}
html.js [data-reveal].is-revealed {
  opacity: 1;
  transform: none;
}

@keyframes reveal-up {
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal, [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
    transition: none !important;
  }
}
