/**
 * STKP Accordion Block — Frontend Styles
 *
 * File: assets/style.css
 */

/* ── FIX #2: Alignment helpers ──────────────────────────────────────────────── */
/*
 * Most block themes handle .alignwide / .alignfull on their own, but we include
 * sensible defaults here for themes that don't. Specificity stays low so a
 * theme's own rules can still override these if needed.
 *
 * Wide: bounded by --wp--style--global--wide-size
 * Full: bleeds edge-to-edge (100vw) via negative margins
 */
.wp-block-stkp-accordion-block.alignwide {
    width: 100%;
    max-width: var( --wp--style--global--wide-size, 1200px );
    margin-left: auto;
    margin-right: auto;
}

.wp-block-stkp-accordion-block.alignfull {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc( 50% - 50vw );
    margin-right: calc( 50% - 50vw );
}

/* ── Block wrapper ──────────────────────────────────────────────────────────── */
.stkp-accordion-block {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;               /* No space between the accordion column and the image column */
    align-items: start;   /* Each column sticks to the top; the image is position:sticky */
}

@media ( max-width: 768px ) {
    .stkp-accordion-block {
        grid-template-columns: 1fr;
        gap: 1.5rem;      /* Restore a small gap on mobile for vertical stacking */
    }

    /* On mobile, show image above the accordion */
    .stkp-accordion-col--right {
        order: -1;
    }
}

/* ── Columns ────────────────────────────────────────────────────────────────── */
.stkp-accordion-col--left {
    /* Defensive: ensure absolute-positioned children stay within this column */
    min-width: 0;
}

.stkp-accordion-col--right {
    position: sticky;
    top: 2rem;
    min-width: 0;        /* Prevents grid blowout if image is very wide */
}

/* ── Feature image ──────────────────────────────────────────────────────────── */
.stkp-accordion-image-wrap {
    overflow: hidden;
    background: #f0f0f0;
    aspect-ratio: 4 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stkp-feature-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.15s ease;
}

/* ── Accordion container ────────────────────────────────────────────────────── */
.stkp-accordion {
    border-top: 2px solid #e0e0e0;
}

/* ── Accordion item ─────────────────────────────────────────────────────────── */
.stkp-accordion__item {
    border-bottom: 1px solid #e0e0e0;
}

/* ── Trigger element (div with role="button") ───────────────────────────────── */
.stkp-accordion__trigger {
    width: 100%;
    padding: 1rem 0rem 1rem 0;
    text-align: left;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    color: inherit;
    cursor: pointer;
    position: relative;
    display: block;
    /* Prevent accidental text-selection on rapid clicks (div behaves differently from button) */
    user-select: none;
    -webkit-user-select: none;
}── */
.stkp-accordion__trigger {
    width: 100%;
    /* Right padding reserves room for the chevron (which is now at right: 0)
       so the title text wraps before reaching it. */
    padding: 1rem 1.75rem 1rem 0;
    text-align: left;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    color: inherit;
    cursor: pointer;
    position: relative;
    display: block;
    /* Prevent accidental text-selection on rapid clicks (div behaves differently from button) */
    user-select: none;
    -webkit-user-select: none;
}

.stkp-accordion__trigger:hover,
.stkp-accordion__trigger:focus-visible {
    color: #0073aa;
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Chevron icon using CSS pseudo-element */
.stkp-accordion__icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%) rotate(0deg);
    width: 0.875rem;
    height: 0.875rem;
    transition: transform 0.25s ease;
    display: block;
    pointer-events: none;   /* Clicks pass through to the trigger */
}

.stkp-accordion__icon::before,
.stkp-accordion__icon::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 0.5rem;
    height: 2px;
    background: currentColor;
    transition: transform 0.25s ease;
}

.stkp-accordion__icon::before {
    left: 0;
    transform: rotate( 45deg);
}

.stkp-accordion__icon::after {
    right: 0;
    transform: rotate(-45deg);
}

/* Rotate chevron when open */
.stkp-accordion__item.is-active .stkp-accordion__icon::before {
    transform: rotate(-45deg);
}

.stkp-accordion__item.is-active .stkp-accordion__icon::after {
    transform: rotate( 45deg);
}

/* ── Panel ──────────────────────────────────────────────────────────────────── */
.stkp-accordion__panel {
    overflow: hidden;
}

.stkp-accordion__panel-inner {
    padding: 0.25rem 0 1.25rem;
    font-size: 0.95rem;
    line-height: 1.7;
    color: #444;
}

/* Active item: highlight trigger */
.stkp-accordion__item.is-active .stkp-accordion__trigger {
    color: #0073aa;
}

/* ── Title + subtitle group inside the trigger ──────────────────────────────── */
.stkp-accordion__title-group {
    display: block;
}

.stkp-accordion__title {
    display: block;
    /* Inherits the trigger's font-size and font-weight (1rem / 600) */
}

.stkp-accordion__subtitle {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.85rem;
    font-weight: 400;
    color: #666;
    line-height: 1.4;
}

/* Subtitle stays muted even on the active item — visual hierarchy */
.stkp-accordion__item.is-active .stkp-accordion__subtitle {
    color: #666;
}