/* TVLR corrected-revision UI: inline citation markers, correction footnotes,
   the Sources & Substantiation list, and the substantiation-log modal.
   Reuses the --framework-* custom properties defined in frameworks-shared.css.
   Selectors that style bare elements (li, p, h3, h4, ul, table...) are prefixed
   with body.framework-theme to match/exceed the specificity of frameworks-shared.css's
   own body.framework-theme element rules — otherwise those base rules win the cascade. */

.tvlr-citation {
  font-size: 0.7em;
  line-height: 1;
  margin-left: 1px;
  white-space: nowrap;
}

.tvlr-citation::before {
  content: "[";
  color: var(--framework-muted);
}

.tvlr-citation::after {
  content: "]";
  color: var(--framework-muted);
}

.tvlr-citation a {
  color: var(--framework-accent);
  text-decoration: none;
}

.tvlr-citation a:hover,
.tvlr-citation a:focus-visible {
  text-decoration: underline;
}

.tvlr-inline-trigger {
  font: inherit;
  color: var(--framework-accent);
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(88, 224, 255, 0.4);
  text-underline-offset: 2px;
}

.tvlr-inline-trigger:hover,
.tvlr-inline-trigger:focus-visible {
  color: var(--framework-heading);
  text-decoration-color: currentColor;
}

.tvlr-inline-trigger:focus-visible {
  outline: 2px solid var(--framework-accent);
  outline-offset: 3px;
  border-radius: 3px;
}

body.framework-theme .tvlr-correction-note {
  font-family: var(--framework-font-sans);
  font-size: 0.9rem;
  color: var(--framework-muted);
  border-left: 2px solid var(--framework-border-strong);
  padding: 0.6rem 0 0.6rem 1rem;
  margin: 0.75rem 0 1.5rem;
}

.tvlr-correction-note em {
  font-style: italic;
}

/* --- Sources & Substantiation list --- */

body.framework-theme .tvlr-sources {
  list-style: none;
  counter-reset: tvlr-source;
  padding: 0;
  margin: 1.5rem 0;
  display: grid;
  gap: 0.75rem;
}

body.framework-theme .tvlr-sources li {
  counter-increment: tvlr-source;
  position: relative;
  margin: 0;
  padding: 0.85rem 1.1rem 0.85rem 3rem;
  border-radius: 14px;
  border: 1px solid var(--framework-border);
  background: rgba(12, 22, 38, 0.55);
  font-family: var(--framework-font-sans);
  font-size: 0.92rem;
  line-height: 1.6;
  scroll-margin-top: 5.5rem;
}

.tvlr-sources li::before {
  content: counter(tvlr-source);
  position: absolute;
  left: 0.85rem;
  top: 0.85rem;
  min-width: 1.6rem;
  height: 1.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--framework-accent-soft);
  color: var(--framework-accent);
  font-size: 0.78rem;
  font-weight: 700;
}

.tvlr-sources li:target {
  border-color: var(--framework-border-strong);
  background: rgba(20, 40, 62, 0.75);
}

body.framework-theme .tvlr-sources li p {
  margin: 0;
  font-size: inherit;
}

.tvlr-sources a {
  font-size: 0.88em;
}

/* --- Closing colophon + corrections CTA --- */

body.framework-theme .tvlr-final-note {
  margin: clamp(2rem, 4vw, 3rem) 0 0;
  padding: clamp(1.4rem, 3vw, 2rem);
  border-top: 1px solid rgba(84, 240, 255, 0.18);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.tvlr-final-note em {
  font-family: var(--framework-font-serif);
  font-style: italic;
  color: var(--framework-muted);
  max-width: 62ch;
  line-height: 1.7;
}

.tvlr-corrections-link {
  font-family: var(--framework-font-sans);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  color: var(--framework-bg);
  background: var(--framework-accent);
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.5rem;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(84, 240, 255, 0.25);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.tvlr-corrections-link:hover,
.tvlr-corrections-link:focus-visible {
  background: var(--framework-heading);
  transform: translateY(-1px);
  box-shadow: 0 16px 36px rgba(84, 240, 255, 0.35);
}

.tvlr-corrections-link:focus-visible {
  outline: 2px solid var(--framework-accent);
  outline-offset: 3px;
}

/* --- Modal overlay + dialog --- */

.tvlr-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(1rem, 4vh, 4rem) 1rem;
  background: rgba(3, 7, 14, 0.78);
  backdrop-filter: blur(6px);
  overflow-y: auto;
}

.tvlr-modal-overlay[hidden] {
  display: none;
}

.tvlr-modal {
  position: relative;
  width: min(100%, 800px);
  max-height: min(88vh, 1000px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, rgba(10, 16, 28, 0.98), rgba(8, 13, 24, 0.98));
  border: 1px solid var(--framework-border-strong);
  border-radius: calc(var(--framework-radius) - 6px);
  box-shadow: var(--framework-shadow-hover);
  color: var(--framework-text);
  outline: none;
}

.tvlr-modal__header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1.4rem 3.6rem 1.1rem 1.6rem;
  border-bottom: 1px solid rgba(84, 240, 255, 0.16);
  background: rgba(9, 15, 27, 0.96);
  border-radius: calc(var(--framework-radius) - 6px) calc(var(--framework-radius) - 6px) 0 0;
}

.tvlr-modal__eyebrow {
  margin: 0;
  font-family: var(--framework-font-sans);
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--framework-accent);
}

body.framework-theme .tvlr-modal__header h2 {
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.6rem);
}

.tvlr-modal__close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  width: 2.2rem;
  height: 2.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--framework-border);
  background: rgba(14, 24, 40, 0.85);
  color: var(--framework-heading);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.tvlr-modal__close:hover,
.tvlr-modal__close:focus-visible {
  border-color: var(--framework-accent);
  color: var(--framework-accent);
  transform: rotate(90deg);
}

.tvlr-modal__close:focus-visible {
  outline: 2px solid var(--framework-accent);
  outline-offset: 2px;
}

.tvlr-modal__body {
  overflow-y: auto;
  padding: 1.5rem 1.6rem 2rem;
  font-family: var(--framework-font-sans);
}

body.framework-theme .tvlr-modal__body h3 {
  font-family: var(--framework-font-sans);
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--framework-accent);
  line-height: 1.3;
  margin: 2rem 0 1rem;
}

.tvlr-modal__body h3:first-child {
  margin-top: 0.25rem;
}

body.framework-theme .tvlr-modal__body h4 {
  font-family: var(--framework-font-sans);
  font-size: 1rem;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.3;
  color: var(--framework-heading);
  margin: 0 0 0.5rem;
}

body.framework-theme .tvlr-modal__body p {
  font-size: 0.92rem;
  line-height: 1.7;
  margin: 0 0 0.65rem;
}

body.framework-theme .tvlr-modal__body ul {
  font-size: 0.92rem;
  line-height: 1.65;
  margin: 0.5rem 0;
  padding-left: 1.3rem;
}

body.framework-theme .tvlr-modal__body li {
  margin: 0.2rem 0;
  padding-left: 0;
}

.tvlr-log-intro {
  color: var(--framework-muted);
  font-style: italic;
}

.tvlr-log-entry {
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
  border-radius: 14px;
  border: 1px solid var(--framework-border);
  background: rgba(12, 22, 38, 0.5);
}

.tvlr-log-entry:last-of-type {
  margin-bottom: 0;
}

.tvlr-log-refs {
  display: inline-block;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  color: var(--framework-accent);
  background: var(--framework-accent-soft);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  white-space: nowrap;
}

.tvlr-log-table-wrap {
  overflow-x: auto;
  margin: 1rem 0;
  border-radius: 14px;
  border: 1px solid var(--framework-border);
}

body.framework-theme .tvlr-log-table-wrap table {
  margin: 0;
  border: none;
  border-radius: 0;
  min-width: 620px;
}

body.framework-theme .tvlr-log-table-wrap th,
body.framework-theme .tvlr-log-table-wrap td {
  font-size: 0.85rem;
  vertical-align: top;
}

body.framework-theme .tvlr-log-footnote {
  font-size: 0.85rem;
  color: var(--framework-muted);
  border-top: 1px solid var(--framework-border);
  padding-top: 1rem;
  margin: 1.5rem 0 0;
}

body.framework-theme .tvlr-log-source-note {
  font-size: 0.82rem;
  color: var(--framework-muted);
  text-align: center;
  margin: 1.5rem 0 0;
}

@media (max-width: 640px) {
  .tvlr-modal-overlay {
    padding: 0;
  }

  .tvlr-modal {
    width: 100%;
    max-height: 100vh;
    height: 100%;
    border-radius: 0;
  }

  .tvlr-modal__header {
    border-radius: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tvlr-modal__close {
    transition: none;
  }

  .tvlr-corrections-link {
    transition: none;
  }
}

@media (prefers-contrast: more), (forced-colors: active) {
  .tvlr-modal {
    background: Canvas;
    box-shadow: none;
  }

  .tvlr-modal__header {
    background: Canvas;
  }

  .tvlr-sources li,
  .tvlr-log-entry {
    background: Canvas;
  }
}
