/* ─────────────────────────────────────────────
   SIDENOTES
   Tufte-style margin notes for blog posts
   ───────────────────────────────────────────── */

/* ── Layout: widen post when sidenotes are active ── */
@media (min-width: 900px) {
  .post-page.has-sidenotes {
    max-width: 1080px;
  }

  .post-page.has-sidenotes .post-body {
    max-width: none;
  }
}

/* ── Inline wrapper ── */
.sidenote {
  display: inline;
}

/* ── Toggle: superscript marker ── */
.sidenote-toggle {
  cursor: pointer;
  user-select: none;
  font-size: 0.68em;
  vertical-align: super;
  color: var(--accent);
  margin-left: 0.05em;
  line-height: 0;
}

/* ── Checkbox hidden — controls open/close on mobile ── */
.sidenote-checkbox {
  display: none;
}

/* ── Automatic numbering ── */
.sidenotes-container {
  counter-reset: sidenote-counter;
}

.sidenote-numbered {
  counter-increment: sidenote-counter;
}

.sidenote-numbered .sidenote-toggle::before {
  content: counter(sidenote-counter);
}

.sidenote-numbered .sidenote-content::before {
  content: counter(sidenote-counter) ". ";
  font-weight: 500;
  color: var(--accent);
}

/* ── Sidenote & marginnote content: shared type styles ── */
.sidenote-content,
.marginnote {
  font-size: 0.8rem;
  line-height: 1.65;
  color: var(--ink-light);
  font-family: var(--font-body);
  font-weight: 300;
}

/* ── Desktop: float into right margin ── */
@media (min-width: 900px) {
  .sidenote-content,
  .marginnote {
    display: block;
    float: right;
    clear: right;
    width: 26%;
    margin-left: 2rem;
    margin-top: 0.25rem;
    margin-bottom: 1rem;
    padding-left: 0.875rem;
    border-left: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
  }
}

/* ── Mobile: collapsed inline, expand on toggle ── */
@media (max-width: 899px) {
  .sidenote-content {
    display: none;
    float: none;
    width: auto;
    margin: 0.6rem 0 0.6rem 1.25rem;
    padding: 0.65rem 0.875rem;
    border-left: 2px solid color-mix(in srgb, var(--ink) 15%, transparent);
    background: color-mix(in srgb, var(--ink) 3%, transparent);
  }

  .sidenote-checkbox:checked ~ .sidenote-content {
    display: block;
  }

  .sidenote-toggle {
    display: inline-block;
    padding: 1px 4px;
    border: 1px solid color-mix(in srgb, var(--ink) 20%, transparent);
    border-radius: 2px;
    font-size: 0.65em;
    vertical-align: super;
    line-height: 1.4;
  }

  .marginnote {
    display: block;
    float: none;
    margin: 0.75rem 0 0.75rem 1.25rem;
    padding: 0.65rem 0.875rem;
    border-left: 2px solid color-mix(in srgb, var(--ink) 15%, transparent);
  }
}

/* ── Links inside sidenotes ── */
.sidenote-content a,
.marginnote a {
  color: var(--ink-mid);
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 25%, transparent);
  text-decoration: none;
}

.sidenote-content a:hover,
.marginnote a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Tufte extras ── */

/* Small caps for opening words of a section */
.newthought {
  font-variant: small-caps;
  letter-spacing: 0.04em;
}

/* Epigraph: opening quote */
.epigraph {
  margin: 2.5em 0;
  padding-left: clamp(1.5rem, 3vw, 2.5rem);
  border-left: 2px solid var(--accent);
}

.epigraph p {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2vw, 1.3rem);
  font-style: italic;
  line-height: 1.55;
  color: var(--ink);
  margin: 0;
}

.epigraph footer {
  margin-top: 0.75em;
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-light);
}

/* ── Print: show all sidenotes ── */
@media print {
  .sidenote-content {
    display: block !important;
    float: right;
    width: 35%;
    font-size: 9pt;
  }
  .sidenote-toggle { display: none; }
}