/* ── CHAPTER ACCENT ── */
:root {
  --chapter-accent: var(--accent-navy);
  --chapter-accent-fill: var(--accent-navy-fill);
}

/* ── PAGE WATERMARKS ── */
header::before {
  content: "Glossary";
}

.reminder-box::before {
  content: "Literature";
}

/* ─────────────────────────────────────────
   PROVENANCE TAGS
   How firmly a term traces to a source —
   read like an evidence grade.
───────────────────────────────────────── */
.prov,
.prov-inline {
  --tag: var(--muted);
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  line-height: 1.2;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--tag);
  border-radius: var(--radius-xs);
  color: var(--tag);
  white-space: nowrap;
}
.prov--origin {
  --tag: var(--accent-forest);
}
.prov--general {
  --tag: var(--accent-navy);
}
.prov--label {
  --tag: var(--accent-terracotta);
}

/* The reminder box is a dark panel in both themes */
.reminder-box a {
  color: var(--text-on-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.reminder-box a:hover {
  color: var(--text-on-dark-soft);
}

/* Inside the dark reminder box the tags need light-on-dark hues */
.reminder-box .prov-inline {
  margin: 0 var(--space-half) var(--space-half) 0;
}
.reminder-box .prov--origin {
  --tag: #8cc4a4;
}
.reminder-box .prov--general {
  --tag: #9dbbd6;
}
.reminder-box .prov--label {
  --tag: #e2b27a;
}

/* ─────────────────────────────────────────
   VIEW SWITCH
───────────────────────────────────────── */
.ref-switch {
  display: inline-flex;
  gap: var(--space-1);
  padding: var(--space-1);
  margin-bottom: var(--space-8);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--paper);
}
.ref-switch [role="tab"] {
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  min-height: 44px;
  padding: 0 var(--space-5);
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}
.ref-switch [role="tab"][aria-selected="true"] {
  background: var(--ink-panel);
  color: var(--text-on-dark);
}
.ref-switch [role="tab"]:focus-visible {
  outline: 2px solid var(--accent-navy);
  outline-offset: 2px;
}

/* ─────────────────────────────────────────
   LETTER JUMP BAR
───────────────────────────────────────── */
.ref-letters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}
.ref-letters a,
.ref-letters .is-empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  text-decoration: none;
  color: var(--primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--paper);
  transition: border-color 150ms ease, color 150ms ease;
}
.ref-letters a:hover {
  border-color: var(--accent-navy);
  color: var(--accent-navy);
}
.ref-letters .is-empty {
  opacity: 0.35;
  cursor: default;
  user-select: none;
}

.ref-letter {
  font-family: var(--font-mono);
  font-size: var(--fs-lg);
  font-weight: 500;
  color: var(--text-secondary);
  margin: var(--space-10) 0 var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 110px;
}

/* ─────────────────────────────────────────
   CONCEPT ENTRY
───────────────────────────────────────── */
.ref-concept {
  background: var(--paper);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--chapter-accent);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  margin-bottom: var(--space-4);
  scroll-margin-top: 110px;
}
.ref-concept-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.ref-concept-head h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-md);
  letter-spacing: var(--ls-tight);
}
.ref-definition {
  margin-top: var(--space-2);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text-primary);
}
.ref-used-in {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-2);
  margin-top: var(--space-3);
  font-size: var(--fs-sm);
}
.ref-used-in > span:first-child {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--ls-widest);
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-right: var(--space-1);
}
.ref-used-in a {
  font-weight: 500;
  /* 44px tall tap target without changing the line's visual rhythm */
  padding: var(--space-2) 0;
  margin: -0.6rem 0;
}
.ref-sep {
  color: var(--text-quaternary);
}
.ref-concept-note {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-light);
  color: var(--text-secondary-strong);
  font-size: var(--fs-sm);
  line-height: 1.65;
}
.ref-group {
  margin-top: var(--space-4);
}
.ref-group h4 {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--ls-widest);
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}
.ref-group ul {
  list-style: none;
}
.ref-group li {
  padding: var(--space-2) 0;
  border-top: 1px solid var(--border-light);
  font-size: var(--fs-sm);
  line-height: 1.6;
}
.ref-group li:first-child {
  border-top: 0;
  padding-top: var(--space-1);
}
.ref-cite {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  margin-bottom: var(--space-half);
}
.ref-apa {
  color: var(--text-primary);
  overflow-wrap: anywhere;
}
.ref-note {
  display: block;
  margin-top: var(--space-1);
  color: var(--text-secondary);
}
.ref-alias {
  display: block;
  scroll-margin-top: 110px;
}

/* ─────────────────────────────────────────
   BIBLIOGRAPHY
───────────────────────────────────────── */
.ref-works {
  list-style: none;
  background: var(--paper);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0 var(--space-6);
}
.ref-works li {
  padding: var(--space-4) 0 var(--space-4) var(--space-8);
  text-indent: -2rem; /* APA hanging indent */
  border-top: 1px solid var(--border-light);
  font-size: var(--fs-sm);
  line-height: 1.65;
  scroll-margin-top: 110px;
}
.ref-works li:first-child {
  border-top: 0;
}
.ref-cited {
  display: block;
  text-indent: 0;
  margin-top: var(--space-1);
  font-size: var(--fs-xs);
  color: var(--text-secondary);
}
.ref-doi {
  overflow-wrap: anywhere;
}

/* Arrival highlight when following a link from a chapter */
.is-target {
  animation: ref-flash 1.6s ease-out;
}
@keyframes ref-flash {
  from {
    background-color: color-mix(in srgb, var(--accent-terracotta) 18%, var(--paper));
  }
  to {
    background-color: var(--paper);
  }
}
.ref-works li.is-target {
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  .is-target {
    animation: none;
    outline: 2px solid var(--accent-terracotta);
    outline-offset: 2px;
  }
  .ref-switch [role="tab"],
  .ref-letters a {
    transition: none;
  }
}

@media (max-width: 480px) {
  .ref-concept {
    padding: var(--space-4);
  }
  .ref-works {
    padding: 0 var(--space-4);
  }
  .ref-works li {
    padding-left: var(--space-5);
    text-indent: -1.25rem;
  }
  .ref-switch {
    display: flex;
  }
  .ref-switch [role="tab"] {
    flex: 1;
    padding: 0 var(--space-3);
  }
}
