/*
 * Todas las variables tienen un valor por defecto aquí, pero el
 * shortcode las sobreescribe por instancia vía style="--toc-...".
 * Así se pueden personalizar sin tocar este archivo.
 */
:root {
    --toc-bg: #FEFCF9;
    --toc-border: #f8e5d2;
    --toc-line: #FEFCF9;
    --toc-text-size: 15px;
    --toc-accent: #b45f2e;
    --toc-text: #3a2f28;
    --toc-tooltip-bg: #5C226F;
    --toc-tooltip-text: #ffffff;
    --toc-fab-size: 48px;
    --toc-fab-radius: 50%;
}

.toc-sidebar-anchor {
    width: 100%;
    height: 0;
}

/* =========================================================
   TARJETA BASE (modo "inline": widget normal dentro del sidebar)
   ========================================================= */
.toc-sidebar-widget {
    font-size: var(--toc-text-size);
    line-height: 1.5;
    background: var(--toc-bg);
    border: 1.5px solid var(--toc-border);
    border-radius: 10px;
    padding: 20px 22px;
    box-sizing: border-box;
}

.toc-sidebar-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    font: inherit;
    color: inherit;
    text-align: left;
}

/* Anula el hover/focus de botones que algunos temas aplican por defecto
   (fondo oscuro + texto blanco), para que el título no cambie de color. */
.toc-sidebar-toggle,
.toc-sidebar-toggle:hover,
.toc-sidebar-toggle:focus,
.toc-sidebar-toggle:active,
.toc-sidebar-toggle:visited {
    background: none !important;
    background-color: transparent !important;
    color: inherit !important;
    border: none !important;
    box-shadow: none !important;
    text-decoration: none !important;
}

.toc-sidebar-title {
    font-family: 'EB Garamond', serif;
    font-weight: 600;
    font-size: 1.25em;
    letter-spacing: 0.01em;
    padding: 2px 0;
}

.toc-sidebar-chevron {
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--toc-accent);
    border-bottom: 2px solid var(--toc-accent);
    transform: rotate(45deg);
    transition: transform 0.2s ease;
    margin-top: -4px;
}

.toc-sidebar-fab-icon,
.toc-sidebar-close {
    display: none;
}

.toc-sidebar-list {
    list-style: none;
    margin: 20px 0 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

.toc-sidebar-list li {
    margin: 0;
    padding: 8px 0;
    border-top: 1px solid var(--toc-line);
}

.toc-sidebar-list li:first-child {
    border-top: none;
    padding-top: 0;
}

.toc-sidebar-list a {
    font-family: 'Inter', sans-serif;
    font-size: var(--toc-text-size);
    text-decoration: none;
    color: var(--toc-text);
    display: block;
}

.toc-sidebar-list a:hover {
    color: var(--toc-accent);
}

.toc-sidebar-list li.toc-level-3 {
    padding-left: 14px;
    font-size: 0.95em;
    opacity: 0.9;
}

/* Ítem de introducción (título del post, enlaza al inicio del artículo) */
.toc-sidebar-list li.toc-level-0 {
    font-family: 'EB Garamond', serif;
    font-weight: 600;
}

.toc-sidebar-list li.toc-active > a {
    font-weight: 600;
    color: var(--toc-accent);
}

/* Acordeón del modo inline (colapsar/expandir con clic en el título) */
.toc-sidebar-widget[data-toc-state="closed"]:not(.toc-fab-mode) .toc-sidebar-list {
    max-height: 0 !important;
    margin-top: 0 !important;
    overflow: hidden;
}
.toc-sidebar-widget[data-toc-state="closed"]:not(.toc-fab-mode) .toc-sidebar-chevron {
    transform: rotate(-135deg);
    margin-top: 4px;
}

.toc-sidebar-overlay {
    display: none;
}

/* =========================================================
   MODO FAB: botón flotante + panel superpuesto.
   Se activa agregando la clase .toc-fab-mode vía JS:
     - En móvil, siempre (desde que carga la página).
     - En desktop, cuando el usuario baja lo suficiente para que
       el widget salga de la pantalla en su posición normal.
   ========================================================= */
.toc-sidebar-widget.toc-fab-mode {
    position: fixed;
    right: 16px;
    bottom: 16px;
    left: auto;
    top: auto;
    z-index: 9999;
    width: var(--toc-fab-size);
    height: var(--toc-fab-size);
    padding: 0;
    border-radius: var(--toc-fab-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(60, 40, 20, 0.25);
    overflow: hidden;
    transition: width 0.22s ease, height 0.22s ease, border-radius 0.22s ease;
}

.toc-sidebar-widget.toc-fab-mode .toc-sidebar-toggle {
    width: 100%;
    height: 100%;
    justify-content: center;
}

.toc-sidebar-widget.toc-fab-mode .toc-sidebar-title,
.toc-sidebar-widget.toc-fab-mode .toc-sidebar-list,
.toc-sidebar-widget.toc-fab-mode .toc-sidebar-chevron {
    display: none;
}

.toc-sidebar-widget.toc-fab-mode .toc-sidebar-fab-icon {
    display: block;
    position: relative;
    width: 18px;
    height: 2px;
    background: var(--toc-accent);
    border-radius: 2px;
}
.toc-sidebar-widget.toc-fab-mode .toc-sidebar-fab-icon::before,
.toc-sidebar-widget.toc-fab-mode .toc-sidebar-fab-icon::after {
    content: "";
    position: absolute;
    left: 0;
    width: 18px;
    height: 2px;
    background: var(--toc-accent);
    border-radius: 2px;
}
.toc-sidebar-widget.toc-fab-mode .toc-sidebar-fab-icon::before { top: -6px; }
.toc-sidebar-widget.toc-fab-mode .toc-sidebar-fab-icon::after { top: 6px; }

/* --- Panel abierto (mismo comportamiento en móvil y desktop-FAB) --- */
.toc-sidebar-widget.toc-fab-mode[data-toc-state="open"] {
    width: min(calc(100vw - 32px), 420px);
    height: auto;
    max-height: 70vh;
    border-radius: 16px;
    padding: 20px 22px;
}

.toc-sidebar-widget.toc-fab-mode[data-toc-state="open"] .toc-sidebar-toggle {
    width: auto;
    height: auto;
    justify-content: space-between;
}

.toc-sidebar-widget.toc-fab-mode[data-toc-state="open"] .toc-sidebar-fab-icon {
    display: none;
}

.toc-sidebar-widget.toc-fab-mode[data-toc-state="open"] .toc-sidebar-close {
    display: block;
    font-size: 22px;
    line-height: 1;
    color: var(--toc-accent);
}

.toc-sidebar-widget.toc-fab-mode[data-toc-state="open"] .toc-sidebar-title,
.toc-sidebar-widget.toc-fab-mode[data-toc-state="open"] .toc-sidebar-list {
    display: block;
}

.toc-sidebar-widget.toc-fab-mode[data-toc-state="open"] .toc-sidebar-list {
    overflow-y: auto;
    max-height: calc(70vh - 60px);
}

.toc-sidebar-widget.toc-fab-mode[data-toc-state="open"] ~ .toc-sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(30, 20, 10, 0.35);
    z-index: 9998;
}

/* =========================================================
   Globo de aviso ("Haz clic para explorar el contenido")
   ========================================================= */
.toc-sidebar-tooltip {
    position: fixed;
    right: 16px;
    bottom: calc(var(--toc-fab-size, 48px) + 28px);
    max-width: 220px;
    background: var(--toc-tooltip-bg);
    color: var(--toc-tooltip-text);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    line-height: 1.4;
    padding: 10px 14px;
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}
.toc-sidebar-tooltip::after {
    content: "";
    position: absolute;
    bottom: -6px;
    right: 20px;
    width: 12px;
    height: 12px;
    background: var(--toc-tooltip-bg);
    transform: rotate(45deg);
}
.toc-sidebar-tooltip.is-visible {
    opacity: 1;
    transform: translateY(0);
}
