/**
 * BotSpot WP Appendix Styles
 *
 * Provides full structural CSS for the appendix widget. The API returns an
 * inline <style> block, but wp_kses strips it — so all layout/structure rules
 * must live here. Theme-inheriting overrides (colors, fonts) use WP
 * theme.json custom properties where available.
 *
 * @package BotDot_WP
 * @version 2.1.0
 */

/* ── Structural: box-sizing & marker reset ── */
.ba-root *,
.ba-root *::before,
.ba-root *::after {
    box-sizing: border-box;
}

.ba-root details > summary {
    list-style: none;
}

.ba-root details > summary::-webkit-details-marker {
    display: none;
}

.ba-root details > summary::marker {
    display: none;
    content: "";
}

/* ── Root: inherit everything from theme ── */
.ba-root {
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.6;
    color: inherit;
    background: transparent;
    max-width: none;
    margin: 2rem auto 0;
    padding: 0;
    border-top: 1px solid var(--wp--preset--color--border, rgba(0, 0, 0, 0.08));
    box-sizing: border-box;
}

/* ── Master accordion (outer wrapper) ── */
.ba-master {
    border: none;
    border-radius: 0;
    overflow: visible;
}

.ba-master > .ba-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    font-size: 0.95em;
    font-weight: 600;
    color: var(--wp--preset--color--foreground, inherit);
    background: transparent;
    border-bottom: 1px solid var(--wp--preset--color--border, rgba(0, 0, 0, 0.08));
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.ba-master > .ba-summary .ba-icon {
    color: inherit;
    opacity: 0.5;
}

/* ── Inner items ── */
.ba-item {
    border: none;
    border-bottom: 1px solid var(--wp--preset--color--border, rgba(0, 0, 0, 0.06));
    border-radius: 0;
    margin-bottom: 0;
    overflow: visible;
}

.ba-item:last-child {
    border-bottom: none;
}

/* ── Summary (shared for master + items) ── */
.ba-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0;
    font-size: 0.9em;
    font-weight: 600;
    color: inherit;
    background: transparent;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.ba-summary:hover {
    background: transparent;
    opacity: 0.7;
}

/* ── Icon (chevron / toggle) ── */
.ba-icon {
    flex-shrink: 0;
    transition: transform 0.2s ease;
    display: inline-flex;
    align-items: center;
    color: inherit;
    opacity: 0.4;
}

details[open] > .ba-summary .ba-icon {
    transform: rotate(180deg);
}

details[open] > .ba-summary .ba-icon-plus {
    transform: none;
}

/* ── Body content ── */
.ba-body {
    padding: 0 0 0.75rem;
    font-size: 0.85em;
    color: inherit;
    opacity: 0.85;
}

.ba-body p {
    margin: 0 0 0.5em;
    line-height: 1.65;
}

.ba-body p:last-child {
    margin-bottom: 0;
}

/* ── FAQ ── */
.ba-faq-item {
    border-bottom: 1px solid var(--wp--preset--color--border, rgba(0, 0, 0, 0.05));
    padding: 0.5rem 0;
}

.ba-faq-item:last-child {
    border-bottom: none;
}

.ba-q {
    font-size: 0.85em;
    font-weight: 600;
    margin: 0 0 0.25em;
}

.ba-a {
    font-size: 0.85em;
    line-height: 1.6;
    padding-left: 0;
}

.ba-a p {
    margin: 0 0 0.5em;
}

.ba-a p:last-child {
    margin-bottom: 0;
}

/* ── Key Facts ── */
.ba-facts .ba-fact-item {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--wp--preset--color--border, rgba(0, 0, 0, 0.04));
}

.ba-facts .ba-fact-item:last-child {
    border-bottom: none;
}

.ba-facts dt {
    font-size: 0.85em;
    font-weight: 500;
}

.ba-facts .ba-source-quote {
    font-size: 0.8em;
    font-style: italic;
    opacity: 0.55;
    margin: 0.15rem 0 0;
    padding-left: 0;
}

/* ── Entities ── */
.ba-entities .ba-entity-item {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--wp--preset--color--border, rgba(0, 0, 0, 0.04));
}

.ba-entities .ba-entity-item:last-child {
    border-bottom: none;
}

.ba-entities dt {
    font-size: 0.85em;
    font-weight: 600;
}

.ba-entity-type {
    display: inline-block;
    font-size: 0.65em;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.45;
    margin-left: 0.4em;
    vertical-align: middle;
}

.ba-entities dd {
    font-size: 0.8em;
    margin: 0.15rem 0 0;
    opacity: 0.75;
}

/* ── Mobile ── */
@media (max-width: 640px) {
    .ba-root {
        font-size: 0.85rem;
    }

    .ba-body {
        font-size: 0.8em;
    }
}

/* ── Print ── */
@media print {
    .ba-root {
        page-break-inside: avoid;
    }

    .ba-master[open] .ba-item {
        page-break-inside: avoid;
    }
}
