/**
 * KarunaPura Reader Interaction Contract v2
 *
 * Única autoridad visual del sistema SEG: referencias, selección, pasajes
 * guardados y punto de lectura. El host semántico es `.kp-sutta-page`; no
 * depende de body, del shell SPA, de viewport ni de tipo de puntero.
 *
 * Baseline visual: 6.8.802. v2 sustituye la separación artificial entre
 * reader-references-v1.css y reader-segment-states-v1.css para impedir que
 * pueda cargarse la numeración sin sus estados interactivos.
 */

/* ───────────────────── Referencias SEG / Legacy ───────────────────── */
.kp-sutta-page.kp-editorial-links :is(a.kp-segment-ref, .kp-continuous-translation a.kp-continuous-ref, .kp-continuous-translation a.ref) {
  display: none;
}
.kp-sutta-page.kp-editorial-links.kp-refs-active :is(a.kp-segment-ref, .kp-continuous-translation a.kp-continuous-ref, .kp-continuous-translation a.ref) {
  display: inline-block !important;
}
.kp-sutta-page.kp-editorial-links :is(a.kp-segment-ref, .kp-continuous-translation a.kp-continuous-ref, .kp-continuous-translation a.ref) {
  position: static !important;
  margin-left: 0;
  margin-right: .34em;
  border: 0 !important;
  background: none !important;
  background-image: none !important;
  box-shadow: none !important;
  color: var(--extra-color-1, #daa520) !important;
  font-family: "Noto Sans", sans-serif !important;
  font-size: calc(12px + var(--ks-mobile-type-step, 0px)) !important;
  font-style: normal !important;
  font-weight: 700 !important;
  line-height: inherit !important;
  text-decoration: none !important;
  padding: 0 !important;
  vertical-align: baseline !important;
  white-space: nowrap;
  cursor: pointer;
}
.kp-sutta-page.kp-editorial-links :is(a.kp-segment-ref, .kp-continuous-translation a.kp-continuous-ref, .kp-continuous-translation a.ref)::before,
.kp-sutta-page.kp-editorial-links :is(a.kp-segment-ref, .kp-continuous-translation a.kp-continuous-ref, .kp-continuous-translation a.ref)::after {
  content: none !important;
  display: none !important;
}
.kp-sutta-page.kp-editorial-links :is(a.kp-segment-ref, .kp-continuous-translation a.kp-continuous-ref, .kp-continuous-translation a.ref):is(:hover, :focus-visible) {
  color: var(--extra-color-1, #daa520) !important;
  text-decoration: none !important;
  outline: none;
  opacity: .72;
}
.kp-sutta-page.kp-editorial-links.kp-refs-active .kp-line-es + .kp-line-pali > a.kp-segment-ref,
.kp-sutta-page.kp-editorial-links.kp-refs-active .kp-sutta-body.kp-mode-sidebyside .kp-side-pali > a.kp-segment-ref {
  display: none !important;
}

/* Carril canónico 6.8.802. */
.kp-sutta-page.kp-refs-active .kp-ref-track {
  --kp-ref-gutter: 2.25rem;
  --kp-ref-text-inset: 0px;
  position: relative;
  padding-inline-start: calc(var(--kp-ref-gutter) + var(--kp-ref-text-inset)) !important;
}
.kp-sutta-page.kp-refs-active .kp-ref-track > a.kp-segment-ref {
  position: absolute !important;
  inset-inline-start: 0;
  top: 0;
  margin: 0 !important;
}
.kp-sutta-page.kp-refs-active .kp-sutta-body.kp-mode-linebyline .kp-line-pali {
  padding-inline-start: 2.25rem !important;
}

/* ───────────── Selección / guardado / Punto de lectura ───────────── */
/* Una sola frontera: cualquier lector legítimo contiene `.kp-sutta-page`.
 * No se condiciona por body, wrapper SPA, viewport ni dispositivo. */
.kp-sutta-page .kp-hash-active,
.kp-sutta-page .kp-hash-active-child {
  scroll-margin-top: 130px;
  border: 0 !important;
  outline: 0 !important;
  border-radius: .22em !important;
  /* fallback para motores sin color-mix(); la segunda declaración conserva
     exactamente el color canónico cuando color-mix está disponible. */
  background: rgba(218, 165, 32, .14) !important;
  background: color-mix(in srgb, var(--extra-color-1, #daa520) 14%, transparent) !important;
  box-shadow: none !important;
  color: inherit !important;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.kp-sutta-page:not(.kp-refs-active) .kp-hash-active:not(.kp-resume-point),
.kp-sutta-page:not(.kp-refs-active) .kp-hash-active-child:not(.kp-resume-point-child) {
  background: transparent !important;
}
.kp-sutta-page .kp-resume-point,
.kp-sutta-page .kp-resume-point-child {
  border: 0 !important;
  outline: 0 !important;
  border-radius: .22em !important;
  background: rgba(118, 83, 111, .16) !important;
  background: color-mix(in srgb, var(--ks-library-resume, #76536f) 16%, transparent) !important;
  box-shadow: none !important;
  color: inherit !important;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.kp-sutta-page.kp-refs-active .kp-saved-passage,
.kp-sutta-page.kp-refs-active .kp-saved-passage-child {
  border: 0 !important;
  outline: 0 !important;
  border-radius: .22em !important;
  background: rgba(218, 165, 32, .14) !important;
  background: color-mix(in srgb, var(--extra-color-1, #daa520) 14%, transparent) !important;
  box-shadow: none !important;
  color: inherit !important;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.kp-sutta-page.kp-refs-active .kp-resume-point.kp-saved-passage,
.kp-sutta-page.kp-refs-active .kp-resume-point-child.kp-saved-passage-child {
  background: rgba(118, 83, 111, .16) !important;
  background: color-mix(in srgb, var(--ks-library-resume, #76536f) 16%, transparent) !important;
}
.kp-sutta-page .kp-side-pair.kp-hash-active,
.kp-sutta-page .kp-side-pair.kp-resume-point,
.kp-sutta-page .kp-side-pair.kp-saved-passage {
  margin-left: 0 !important;
  padding: 0 !important;
  background: transparent !important;
}
.kp-sutta-page.kp-refs-active .kp-saved-passage > a.kp-segment-ref,
.kp-sutta-page.kp-refs-active .kp-saved-passage-child > a.kp-segment-ref {
  color: var(--extra-color-1, #daa520) !important;
}
.kp-sutta-page.kp-refs-active .kp-resume-point.kp-saved-passage > a.kp-segment-ref,
.kp-sutta-page.kp-refs-active .kp-resume-point-child.kp-saved-passage-child > a.kp-segment-ref {
  color: var(--ks-library-resume, #76536f) !important;
}
.kp-sutta-page .kp-hash-active > a.kp-segment-ref,
.kp-sutta-page .kp-hash-active-child > a.kp-segment-ref {
  color: var(--extra-color-1, #daa520) !important;
  font-size: calc(12px + var(--ks-mobile-type-step, 0px)) !important;
  font-weight: 700 !important;
  opacity: 1 !important;
}

@media print {
  .kp-sutta-page .kp-resume-point,
  .kp-sutta-page .kp-resume-point-child,
  .kp-sutta-page .kp-saved-passage,
  .kp-sutta-page .kp-saved-passage-child {
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
  }
  .kp-sutta-page .kp-resume-point.kp-hash-active,
  .kp-sutta-page .kp-resume-point-child.kp-hash-active-child,
  .kp-sutta-page .kp-saved-passage.kp-hash-active,
  .kp-sutta-page .kp-saved-passage-child.kp-hash-active-child {
    background: rgba(218, 165, 32, .14) !important;
    background: color-mix(in srgb, var(--extra-color-1, #daa520) 14%, transparent) !important;
  }
  .kp-sutta-page .kp-note-marker,
  .kp-sutta-page .kp-note-tooltip,
  .kp-sutta-page .kp-gloss-tooltip {
    display: none !important;
  }
}
