/*
Block Name: Horizontal Accordion
Description: A row of horizontally expanding panels. One panel is open at a time;
             clicking a collapsed panel expands it while the others collapse.
             On mobile the layout stacks vertically like a standard accordion.
*/


/* ============================================================
   ACCORDION WRAPPER
   Flex container that holds all panels side by side.
   Height is driven by the --panel-height CSS custom property
   set inline by PHP from the ACF panel_height field.
   overflow:hidden clips panels cleanly to the border radius.
============================================================ */

.block-horizontal-accordion .h-accordion {
    display: flex;
    width: 100%;
    height: var(--panel-height, 60rem);
    border-radius: var(--border-radius, 2rem);
    overflow: hidden;
}


/* ============================================================
   INDIVIDUAL PANEL
   Starts collapsed at a fixed narrow width (72px).
   The active panel grows to fill all remaining space via flex.
   background-size/position ensure the image covers the panel
   at any width including the narrow collapsed state.
============================================================ */

.block-horizontal-accordion .h-panel {
    position: relative;
    flex: 0 0 8rem;             /* collapsed width */
    overflow: hidden;
    cursor: pointer;
    transition: flex 0.55s cubic-bezier(0.77, 0, 0.175, 1);
    background-size: cover;
    background-position: center;
    background-color: var(--brand-2); /* fallback if no image or colour set in ACF */
}

.block-horizontal-accordion .h-panel.active {
    flex: 1 1 auto;             /* open panel takes all remaining space */
    cursor: default;
}


/* ============================================================
   DARK OVERLAY
   Sits above the background image on every panel.
   Collapsed panels are darker to suggest they are inactive.
   The active panel lightens so text reads clearly over the image.
============================================================ */

.block-horizontal-accordion .h-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    transition: background 0.4s ease;
    z-index: 1;
    pointer-events: none;
}

.block-horizontal-accordion .h-panel.active::before {
    background: rgba(0, 0, 0, 0.2);
}


/* ============================================================
   DIVIDER LINE
   A subtle vertical line between each collapsed panel.
   Hidden on the last panel and on the currently active panel.
============================================================ */

.block-horizontal-accordion .h-panel::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: .2rem;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    z-index: 3;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.block-horizontal-accordion .h-panel:last-child::after { display: none; }
.block-horizontal-accordion .h-panel.active::after     { opacity: 0; }


/* ============================================================
   COLLAPSED LABEL
   The panel title rotated 90 degrees, shown when collapsed.
   Fades out when the panel becomes active - the open panel
   shows its title inside .panel-content instead.
   Width must match the collapsed flex width (72px) above.
============================================================ */

.block-horizontal-accordion .panel-label {
    position: absolute;
    bottom: 2.5rem;
    left: 0;
    width: 8rem;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.block-horizontal-accordion .panel-label span {
    display: block;
    color: #fff;
    white-space: nowrap;
    writing-mode: vertical-rl;     /* rotates text to run vertically */
    text-orientation: mixed;
    transform: rotate(180deg);     /* flips so it reads bottom-to-top */
	text-transform: uppercase;
}

.block-horizontal-accordion .h-panel.active .panel-label {
    opacity: 0;
    pointer-events: none;
}


/* ============================================================
   OPEN PANEL CONTENT
   Hidden by default (opacity:0, no transition).
   The JS adds 'content-visible' via a transitionend listener
   once the panel has fully expanded. This triggers the fade-in.
   On close the class is removed instantly (via JS) so the
   content disappears immediately before the panel collapses.

   Fixed width prevents text reflow during the panel expansion -
   the panel's overflow:hidden clips it cleanly until it's open.
============================================================ */

.block-horizontal-accordion .panel-content {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50rem;
    padding: 2.5rem;
    z-index: 2;
    opacity: 0;
    transform: translateY(12px);
    transition: none;
    pointer-events: none;
}

.block-horizontal-accordion .h-panel.active .panel-content {
    pointer-events: auto;
}

/* Class added by JS once the panel is fully open */
.block-horizontal-accordion .panel-content.content-visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}


/* ============================================================
   CONTENT ELEMENTS
   All white text with text-shadow so it reads over any image.
============================================================ */

/* Optional Font Awesome icon above the title */
.block-horizontal-accordion .panel-icon {
    display: block;
    font-size: 6rem;
    color: #fff;
    margin-bottom: 1rem;
    line-height: 1;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

/* Panel heading */
.block-horizontal-accordion .panel-title {
    color: #fff;
    margin-bottom: 1rem;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Body copy */
.block-horizontal-accordion .panel-body {
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.6;
    max-width: 50rem;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.block-horizontal-accordion .panel-body p          { margin-bottom: 0.75em; }
.block-horizontal-accordion .panel-body p:last-child { margin-bottom: 0; }


/* ============================================================
   EMPTY STATE
   Shown in the block editor when no slides have been added.
============================================================ */

.block-horizontal-accordion .h-accordion-empty {
    padding: 2rem;
    color: #888;
    font-style: italic;
}


/* ============================================================
   RESPONSIVE - TABLET (max-width: 1024px)
============================================================ */

@media (max-width: 1024px) {
    .block-horizontal-accordion .h-accordion {
        height: calc(var(--panel-height, 520px) * 0.85);
    }
}


/* ============================================================
   RESPONSIVE - MOBILE (max-width: 768px)
   Switches from horizontal to vertical stacking.
   Each panel collapses to a narrow horizontal bar with its
   label displayed horizontally. Active panel expands downward.
============================================================ */

@media (max-width: 768px) {

    .block-horizontal-accordion .h-accordion {
        flex-direction: column;
        height: auto;
    }

    .block-horizontal-accordion .h-panel {
        flex: 0 0 56px;
        transition: flex 0.5s cubic-bezier(0.77, 0, 0.175, 1);
    }

    .block-horizontal-accordion .h-panel.active {
        flex: 0 0 320px;
    }

    /* Label sits horizontally across the top of the collapsed bar */
    .block-horizontal-accordion .panel-label {
        width: auto;
        height: 56px;
        bottom: auto;
        top: 0;
        left: 1.2rem;
        right: 1.2rem;
        justify-content: flex-start;
        align-items: center;
    }

    /* Undo the rotation - text reads left to right on mobile */
    .block-horizontal-accordion .panel-label span {
        writing-mode: horizontal-tb;
        transform: none;
    }

    /* Divider becomes a bottom border between stacked panels */
    .block-horizontal-accordion .h-panel::after {
        width: 100%;
        height: 2px;
        top: auto;
        bottom: 0;
        right: 0;
    }

    .block-horizontal-accordion .panel-content {
        width: 100%;
        padding: 1.5rem;
    }
}


/* ============================================================
   RESPONSIVE - SMALL MOBILE (max-width: 576px)
============================================================ */

@media (max-width: 576px) {

    .block-horizontal-accordion .h-panel.active {
        flex: 0 0 280px;
    }

    .block-horizontal-accordion .panel-title {
        font-size: 1.4rem;
    }
}