/**
 * hxdevs-toc.css
 * Estilos do Índice Automático de Artigo (TableOfContents)
 * Inspirado no design do TableOfContents.jsx do Busca Melhores clone.
 */

/* ── Container principal ─────────────────────────────────────── */
.hxdevs-toc {
    margin: 2rem 0 2.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--hxdevs-toc-border, rgba(0, 0, 0, 0.12));
    background: var(--hxdevs-toc-bg, #ffffff);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    font-family: inherit;
}

/* ── Cabeçalho clicável ──────────────────────────────────────── */
.hxdevs-toc__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid transparent;
    transition: background 0.2s ease;
}

.hxdevs-toc__header:hover {
    background: rgba(0, 0, 0, 0.02);
}

.hxdevs-toc__header-left {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.hxdevs-toc__icon {
    display: flex;
    align-items: center;
    color: var(--hxdevs-toc-accent, #0087f4);
    flex-shrink: 0;
}

.hxdevs-toc__title {
    margin: 0 !important;
    padding: 0;
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--hxdevs-toc-title, #111827);
    border: none;
    background: none;
    line-height: 1.3;
}

/* ── Chevron animado ─────────────────────────────────────────── */
.hxdevs-toc__chevron {
    display: flex;
    align-items: center;
    color: var(--hxdevs-toc-muted, #6b7280);
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.hxdevs-toc--open .hxdevs-toc__chevron {
    transform: rotate(180deg);
}

.hxdevs-toc--open .hxdevs-toc__header {
    border-bottom-color: var(--hxdevs-toc-border, rgba(0, 0, 0, 0.10));
}

/* ── Corpo do índice (animação max-height) ───────────────────── */
.hxdevs-toc__body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}

.hxdevs-toc--open .hxdevs-toc__body {
    max-height: 2000px;
    /* valor alto suficiente para qualquer lista */
}

/* ── Lista de itens ──────────────────────────────────────────── */
.hxdevs-toc__list {
    margin: 0;
    padding: 0.875rem 1.25rem 1.125rem;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.hxdevs-toc__item {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

/* Linha decorativa vertical para H3 (sub-item) */
.hxdevs-toc__item--sub {
    padding-left: 1.25rem;
}

.hxdevs-toc__item--sub::before {
    content: "";
    display: inline-block;
    width: 2px;
    height: 0.875em;
    background: var(--hxdevs-toc-accent, #0087f4);
    opacity: 0.25;
    flex-shrink: 0;
    align-self: center;
}

/* ── Links ───────────────────────────────────────────────────── */
.hxdevs-toc__link {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--hxdevs-toc-accent, #0087f4);
    text-decoration: none;
    line-height: 1.45;
    transition: color 0.15s ease, opacity 0.15s ease;
}

.hxdevs-toc__link:hover {
    opacity: 0.75;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.hxdevs-toc__item--sub .hxdevs-toc__link {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--hxdevs-toc-link-sub, #0087f4);
}

.hxdevs-toc__item--sub .hxdevs-toc__link:hover {
    color: var(--hxdevs-toc-accent, #0087f4);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 640px) {
    .hxdevs-toc__title {
        font-size: 0.9375rem;
    }

    .hxdevs-toc__link {
        font-size: 0.875rem;
    }
}


/* ==========================================================================
   COPYABLE HEADING
   Botão de copiar link que aparece no hover dos H2 do artigo.
   Equivalente ao CopyableHeading.jsx do Next.js clone.
   ========================================================================== */

/* ── Wrapper em volta do H2 ──────────────────────────────────── */
.hxdevs-heading-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: fit-content;
    max-width: 100%;
    cursor: pointer;
}

/* Cor do heading no hover do wrapper */
.hxdevs-heading-wrapper:hover h2,
.hxdevs-heading-wrapper:hover h3 {
    color: var(--hxdevs-toc-accent, #0087f4);
    transition: color 0.15s ease;
}

/* ── Botão de copiar ─────────────────────────────────────────── */
.hxdevs-copy-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;

    padding: 0.25rem;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 0.375rem;

    color: var(--hxdevs-toc-accent, #0087f4);

    /* Invisível por padrão, aparece no hover do wrapper */
    opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.hxdevs-heading-wrapper:hover .hxdevs-copy-link,
.hxdevs-copy-link:focus-visible {
    opacity: 1;
}

.hxdevs-copy-link:hover {
    background: rgba(225, 29, 41, 0.08);
}

/* ── Estado "copiado" — ícone check verde ────────────────────── */
.hxdevs-copy-link--copied {
    opacity: 1;
    color: #16a34a;
    /* green-600 */
}

/* ── Responsivo: sempre visível no touch ─────────────────────── */
@media (hover: none) {
    .hxdevs-copy-link {
        opacity: 0;
    }
}