/**
 * BB FAQ Module – Frontend Styles
 * Layout, reset, icon logic, accessibility.
 * Colours/sizes are overridden by inline CSS from module settings.
 */

/* ── Wrapper ─────────────────────────────────────────────────────── */
.bb-faq-wrapper {
    list-style: none;
    padding: 0;
    margin: 0;
}
.bb-faq-empty-notice {
    padding: 16px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    font-size: 14px;
}

/* ── Item ─────────────────────────────────────────────────────────── */
.bb-faq-item {
    margin: 0;
    border: 1px solid #e0e0e0;
}
.bb-faq-item + .bb-faq-item {
    margin-top: 8px; /* overridden by inline CSS */
}

/* ── Question ─────────────────────────────────────────────────────── */
/* Hard reset: neutralise any theme heading styles (h2–h6 margins,
   borders, letter-spacing, text-transform, etc.) */
.bb-faq-question {
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Reset heading defaults */
    margin: 0 !important;
    padding: 14px 16px !important; /* top/bottom left/right – overridden by inline CSS */
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    letter-spacing: normal !important;
    text-transform: none !important;
    cursor: pointer;
    user-select: none;
    gap: 12px;
    line-height: 1.4;
    background-color: #f5f5f5; /* overridden */
    color: #333; /* overridden */
    font-weight: 600;
    width: 100%;
    box-sizing: border-box;
    transition: background-color 0.2s ease, color 0.2s ease;
    outline: none;
}
.bb-faq-question:hover {
    background-color: #eaeaea;
}
.bb-faq-question:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: -2px;
}

/* Icon left layout */
.bb-faq-question.bb-faq-icon-left {
    flex-direction: row;
    justify-content: flex-start;
}
.bb-faq-question.bb-faq-icon-left .bb-faq-icon {
    order: -1;
    margin-right: 8px;
    margin-left: 0;
}

/* Icon right layout (default) */
.bb-faq-question.bb-faq-icon-right {
    justify-content: space-between;
}
.bb-faq-question.bb-faq-icon-right .bb-faq-icon {
    margin-left: auto;
    flex-shrink: 0;
}

/* No icon */
.bb-faq-question.bb-faq-icon-none {
    justify-content: flex-start;
}

/* ── Icon ─────────────────────────────────────────────────────────── */
.bb-faq-icon {
    font-size: 18px; /* overridden */
    line-height: 1;
    color: #0073aa; /* overridden */
    transition: transform 0.3s ease;
    flex-shrink: 0;
}
.bb-faq-icon--open   { display: none; }
.bb-faq-icon--closed { display: inline-block; }

.bb-faq-item.is-active .bb-faq-icon--open   { display: inline-block; }
.bb-faq-item.is-active .bb-faq-icon--closed { display: none; }

/* Rotate chevron/arrow variants as additional visual cue */
.bb-faq-item.is-active .bb-faq-icon {
    transform: rotate(0deg); /* handled by show/hide swap above */
}

/* ── Answer ───────────────────────────────────────────────────────── */
/*
 * Animation uses CSS grid-template-rows: 0fr → 1fr.
 * The .bb-faq-answer is a grid container with one row.
 * The .bb-faq-answer-inner child has min-height:0 so it can collapse.
 * This requires ZERO JS height measurement and always works.
 * The transition duration is overridden by inline CSS from module settings.
 */
.bb-faq-answer {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    transition: grid-template-rows 300ms ease, opacity 300ms ease;
}
.bb-faq-answer.is-open {
    grid-template-rows: 1fr;
    max-height: none !important;
    opacity: 1;
}

.bb-faq-answer-inner {
    /* min-height:0 is REQUIRED for the grid collapse to work */
    min-height: 0;
    overflow: hidden;
    background-color: #fff; /* overridden */
    border-top: 1px solid #ddd; /* overridden by divider_color */
}
.bb-faq-answer.is-open .bb-faq-answer-inner{
    padding: 16px!important; 
}
.bb-faq-answer-inner > *:first-child { margin-top: 0; }
.bb-faq-answer-inner > *:last-child  { margin-bottom: 0; }

/* ── Active item ──────────────────────────────────────────────────── */
.bb-faq-item.is-active > .bb-faq-question {
    background-color: #e8f0fe; /* overridden */
    color: #0073aa; /* overridden */
}

/* ── Always-expanded mode ─────────────────────────────────────────── */
.bb-faq-wrapper[data-mode="always"] .bb-faq-answer {
    grid-template-rows: 1fr;
    opacity: 1;
}
.bb-faq-wrapper[data-mode="always"] .bb-faq-question {
    cursor: default;
    pointer-events: none;
}
.bb-faq-wrapper[data-mode="always"] .bb-faq-icon {
    display: none;
}

/* ── Print ────────────────────────────────────────────────────────── */
@media print {
    .bb-faq-answer {
        grid-template-rows: 1fr !important;
        opacity: 1 !important;
    }
    .bb-faq-answer-inner {
        overflow: visible !important;
    }
    .bb-faq-icon { display: none !important; }
}

/* ── Reduced motion ───────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .bb-faq-answer,
    .bb-faq-question {
        transition: none !important;
    }
}
