/**
 * Beekom — JOOOL Accordion
 * Frontend styles
 *
 * Structure:
 *   .bk-jac
 *     └ .bk-jac__item (repeated, .is-open when expanded)
 *         ├ button.bk-jac__header (icon + title + arrow)
 *         └ div.bk-jac__desc (panel, [hidden] when closed, max-height driven by JS)
 */

.bk-jac {
    --bk-jac-duration: 400ms;
    width: 100%;
    box-sizing: border-box;
}

.bk-jac *,
.bk-jac *::before,
.bk-jac *::after {
    box-sizing: border-box;
}

/* =========================================================================
   ITEM
   ========================================================================= */

.bk-jac__item {
    border-top: 1px solid #E5E7EB;
    border-top-style: solid;
}

/* Bottom border only on the last item (all items have top borders) */
.bk-jac__item:last-child {
    border-bottom: 1px solid #E5E7EB;
    border-bottom-style: solid;
}

/* =========================================================================
   HEADER (clickable button)
   ========================================================================= */

.bk-jac__header {
    display: flex;
    align-items: center;
    gap: 20px;
    width: 100%;
    margin: 0;
    padding: 24px 12px;
    background: transparent;
    border: 0;
    border-radius: 0;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    appearance: none;
    -webkit-appearance: none;
    color: inherit;
}

.bk-jac__header:focus {
    outline: none;
}

.bk-jac__header:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* --- Icon slot --- */

.bk-jac__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    color: #B8BCC2;
    line-height: 0;
    transition: color var(--bk-jac-duration) ease;
}

.bk-jac__icon i,
.bk-jac__icon svg {
    width: 100%;
    height: 100%;
    color: inherit;
    display: block;
}

/* Only fill for SVGs that explicitly opt in — outline icons stay outline */
.bk-jac__icon svg [fill="currentColor"],
.bk-jac__icon svg[fill="currentColor"] {
    fill: currentColor;
}

/* Reserve the slot even when no icon, so titles stay aligned */
.bk-jac__icon--empty {
    visibility: hidden;
}

/* --- Title --- */

.bk-jac__title {
    flex: 1 1 auto;
    margin: 0;
    padding: 0;
    font-weight: 600;
    line-height: 1.25;
    color: #0C1E3E;
    min-width: 0;
    word-break: break-word;
    transition: color var(--bk-jac-duration) ease;
}

/* --- Arrow --- */

.bk-jac__arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 0;
    color: #B8BCC2;
    transform-origin: center;
    transition:
        color var(--bk-jac-duration) ease,
        transform var(--bk-jac-duration) ease;
}

.bk-jac__arrow svg {
    display: block;
    width: 28px;
    height: auto;
}

/* Active state: rotate arrow to diagonal ↗ */
.bk-jac__item.is-open .bk-jac__arrow {
    transform: rotate(-45deg);
}

/* =========================================================================
   DESCRIPTION PANEL
   =========================================================================

   The panel uses a two-layer trick for a smooth open/close animation:
   - The outer .bk-jac__desc has max-height transitioned (0 → content height,
     set inline by JS from scrollHeight measurement).
   - The inner .bk-jac__desc-inner holds the actual padding, so closing the
     outer max-height doesn't affect padding interpolation.
   ========================================================================= */

.bk-jac__desc {
    overflow: hidden;
    max-height: 0;
    transition: max-height var(--bk-jac-duration) ease;
}

/* When fully closed, the [hidden] attribute removes it from a11y tree
   and disables its tabbable children. JS removes it on open. */
.bk-jac__desc[hidden] {
    display: none;
}

.bk-jac__desc-inner {
    padding: 0 12px 28px 64px;
    color: #0C1E3E;
    line-height: 1.5;
}

/* Reset margins of WYSIWYG children so padding above controls spacing */
.bk-jac__desc-inner > *:first-child { margin-top: 0; }
.bk-jac__desc-inner > *:last-child  { margin-bottom: 0; }

/* =========================================================================
   REDUCED MOTION
   ========================================================================= */

@media (prefers-reduced-motion: reduce) {
    .bk-jac,
    .bk-jac__desc,
    .bk-jac__arrow,
    .bk-jac__icon,
    .bk-jac__title {
        transition-duration: 0ms !important;
    }
}
