/* Ajustes mínimos sobre el tema blanco original de plasTeX. */

body {
  background: #fff;
}

/* Ancho editorial reproducible para todas las compilaciones de plasTeX. */
div.content-wrapper {
  width: 100%;
  max-width: 90ch;
  margin-right: auto;
  margin-left: auto;
}

.plastex-toc {
  flex: 0 0 17rem;
  width: 17rem;
  overflow-y: auto;
  padding: 3.75rem 1rem 2rem;
  border-right: 1px solid #dce3ea;
  background: #f7f9fc;
  scrollbar-width: thin;
}

.plastex-toc-titlebar { margin: 0 0 0.9rem; }

.plastex-toc-title {
  margin: 0;
  color: #24292e;
  font-family: "Lucida Grande", Arial, Helvetica, sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
}

.plastex-toc-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.88rem;
}

.plastex-toc-list li {
  margin: 0;
  border-left: 3px solid transparent;
}

.plastex-toc-list a {
  display: block;
  padding: 0.38rem 0.45rem;
  color: #40505f;
  line-height: 1.25;
  text-decoration: none;
}

.plastex-toc-level-1 {
  margin-top: 0.45rem !important;
  font-weight: 700;
}

.plastex-toc-level-2 a {
  padding-left: 1.15rem;
  font-weight: 400;
}

.plastex-toc-list li:hover,
.plastex-toc-list li.is-active {
  border-left-color: #06c;
  background: #eaf3ff;
}

.plastex-toc-list li.is-active a {
  color: #06c;
}

.plastex-page-controls {
  position: fixed;
  z-index: 45;
  top: 0.7rem;
  left: 0.7rem;
  display: flex;
  gap: 0.3rem;
}

.plastex-toc-toggle,
.plastex-home-link {
  display: inline-grid;
  width: 2rem;
  height: 2rem;
  padding: 0;
  place-items: center;
  border: 1px solid #c8d2dc;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.92);
  color: #536577;
  box-shadow: 0 1px 5px rgba(31, 59, 82, 0.08);
  cursor: pointer;
  text-decoration: none;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.plastex-toc-toggle:hover,
.plastex-home-link:hover {
  border-color: #8eb3d8;
  background: #fff;
  color: #06c;
}

.plastex-home-link span {
  margin-top: -0.08rem;
  font: 1.25rem/1 Arial, Helvetica, sans-serif;
}

.plastex-toc-toggle {
  align-content: center;
  gap: 3px;
}

.plastex-toc-toggle span {
  display: block;
  width: 13px;
  height: 1.5px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 180ms ease, opacity 140ms ease;
}

.plastex-toc-backdrop {
  display: none;
}

@media (min-width: 901px) {
  .plastex-toc {
    transition:
      flex-basis 220ms ease,
      width 220ms ease,
      padding 220ms ease,
      border-width 180ms ease,
      border-color 180ms ease,
      opacity 160ms ease,
      transform 220ms ease,
      visibility 0s linear;
  }

  .plastex-toc-collapsed .plastex-toc {
    visibility: hidden;
    flex-basis: 0;
    width: 0;
    padding-right: 0;
    padding-left: 0;
    overflow: hidden;
    border-right-width: 0;
    border-right-color: transparent;
    opacity: 0;
    transform: translateX(-100%);
    pointer-events: none;
    transition:
      flex-basis 220ms ease,
      width 220ms ease,
      padding 220ms ease,
      border-width 180ms ease,
      border-color 180ms ease,
      opacity 160ms ease,
      transform 220ms ease,
      visibility 0s linear 220ms;
  }

}

.main-text h1[id],
.main-text h2[id] {
  scroll-margin-top: 1rem;
}

a.has-reference-preview {
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-underline-offset: 0.18em;
}

.plastex-reference-preview {
  position: fixed;
  z-index: 60;
  width: min(24rem, calc(100vw - 1.5rem));
  padding: 0.75rem 0.85rem 0.8rem;
  border: 1px solid #cbd8e5;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.98);
  color: #283746;
  box-shadow: 0 8px 24px rgba(31, 59, 82, 0.14);
  font-size: 0.84rem;
  line-height: 1.38;
  visibility: hidden;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 120ms ease, transform 140ms ease, visibility 0s linear 140ms;
}

.plastex-reference-preview::after {
  position: absolute;
  bottom: -5px;
  left: calc(50% - 5px);
  width: 9px;
  height: 9px;
  border-right: 1px solid #cbd8e5;
  border-bottom: 1px solid #cbd8e5;
  background: #fff;
  content: "";
  transform: rotate(45deg);
}

.plastex-reference-preview.is-below::after {
  top: -5px;
  bottom: auto;
  border: 0;
  border-top: 1px solid #cbd8e5;
  border-left: 1px solid #cbd8e5;
}

.plastex-reference-preview.is-visible {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0s;
}

.plastex-reference-preview-label {
  margin-bottom: 0.28rem;
  color: #06c;
  font-family: "Lucida Grande", Arial, Helvetica, sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.plastex-reference-preview-body p {
  margin: 0;
}

/* El único acento visual añadido al tema blanco de plasTeX. */
h1,
h2 {
  color: #06c;
}

.tikzpicture,
.tikzcd {
  width: fit-content;
  max-width: 100%;
  margin: 0.75rem auto;
  text-align: center;
}

.tikzpicture img,
.tikzpicture > .plastex-tikz-svg,
.tikzcd img,
.tikzcd > .plastex-tikz-svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.interactive-figure {
  width: 100%;
  margin: 1.4rem 0;
  container-type: inline-size;
}

.interactive-figure iframe {
  display: block;
  width: 100%;
  height: 760px;
  border: 0;
}

.interactive-figure figcaption {
  margin-top: 0.45rem;
  color: #5c6976;
  font-size: 0.85rem;
}

@media (max-width: 520px) {
  .interactive-figure iframe {
    height: 1280px;
  }
}

/* La visualización responde al ancho del texto, no al de la ventana. */
@container (max-width: 520px) {
  .interactive-figure iframe {
    height: 1280px;
  }
}

@media (max-width: 900px) {
  .plastex-toc {
    position: fixed;
    z-index: 40;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(82vw, 19rem);
    transform: translateX(-102%);
    transition: transform 180ms ease;
    box-shadow: 8px 0 24px rgba(31, 59, 82, 0.16);
  }

  .plastex-toc-backdrop {
    position: fixed;
    z-index: 39;
    inset: 0;
    border: 0;
    background: rgba(31, 46, 61, 0.22);
  }

  .plastex-toc-open .plastex-toc {
    transform: translateX(0);
  }

  .plastex-toc-open .plastex-toc-backdrop {
    display: block;
  }
}

@media (prefers-reduced-motion: reduce) {
  .plastex-toc,
  .plastex-toc-toggle span,
  .plastex-reference-preview {
    transition: none;
  }
}
