/* =========================================================
   WILA Success Stories — layout
   Mobile-first: the default (no media query) is the safe,
   always-stacked layout. The 2-column "featured + side rail"
   layout only turns on once we know there's enough viewport
   width for it (min-width: 1025px). This means if a breakpoint
   ever gets skipped for any reason, the widget still falls back
   to the safe stacked layout instead of a broken side-by-side
   one that overflows the screen.
   ========================================================= */

.wila-success-grid,
.wila-success-grid *,
.wila-success-grid *::before,
.wila-success-grid *::after {
    box-sizing: border-box;
}

.wila-success-grid {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: stretch;
    width: 100%;
    max-width: 100%;
}

.wila-success-featured-col {
    display: flex !important;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

/* Side rail: on tablet + mobile this renders as a wrapping row of
   small cards underneath the featured card (see reference design).
   flex-basis of 140px means it naturally shows 3-across on wider
   phones/tablets and wraps to fewer per row on very small screens,
   with no extra breakpoints needed. */
.wila-success-side-col {
    display: flex !important;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
    min-width: 0;
    min-height: 1px;
}

/* Base card — same markup is used whether a card is featured or compact,
   so all the sizing differences below are driven purely by the
   --featured / --compact modifier class. */
.wila-success-card {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    background-color: #cfd8d2;
    display: flex !important;
    align-items: flex-end;
    min-width: 0;
    visibility: visible !important;
    opacity: 1 !important;
    transition: min-height 260ms ease;
}

.wila-success-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, rgba(15, 35, 20, 0.75) 0%, rgba(0, 0, 0, 0) 60%);
    pointer-events: none;
    z-index: 1;
}

.wila-success-content {
    position: relative;
    z-index: 2;
    padding: 24px 28px;
    width: 100%;
    min-width: 0;
    transition: opacity 200ms ease;
}

/* Featured card */
.wila-success-card--featured {
    min-height: 360px;
}

.wila-success-card--featured .wila-success-caption {
    display: none;
}

/* Compact side cards: hide the quote + secondary badge + shrink text.
   They reappear automatically once a card is swapped to --featured. */
.wila-success-card--compact {
    display: flex !important;
    flex: 1 1 140px;
    min-width: 0;
    min-height: 130px;
}

.wila-success-card--compact .wila-success-content {
    padding: 12px 14px;
}

.wila-success-card--compact .wila-success-quote,
.wila-success-card--compact .wila-success-badge--outline {
    display: none;
}

.wila-success-card--compact .wila-success-name {
    font-size: 14px;
    margin-bottom: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wila-success-card--compact .wila-success-badges {
    margin-bottom: 8px;
}

.wila-success-card--compact .wila-success-badge {
    font-size: 10px;
    padding: 4px 10px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Play button only ever shows on the featured card. Compact cards with a
   video are clickable as a whole (see --has-video below) but don't show
   the button themselves — clicking swaps them into the featured slot
   first, where the button then appears for actual playback. */
.wila-success-card--compact .wila-success-play {
    display: none;
}

.wila-success-card--compact.wila-success-card--has-video {
    cursor: pointer;
}

.wila-success-card--compact.wila-success-card--has-video:hover .wila-success-overlay {
    background: linear-gradient(0deg, rgba(15, 35, 20, 0.85) 0%, rgba(0, 0, 0, 0.05) 65%);
}

.wila-success-caption {
    margin: 0 0 4px;
    font-size: 12px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.85);
    max-width: 32ch;
    overflow-wrap: break-word;
}

.wila-success-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    min-width: 0;
}

.wila-success-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #FFFFFF;
    padding: 6px 14px;
    border-radius: 999px;
    line-height: 1.2;
    overflow-wrap: break-word;
}

.wila-success-badge--solid {
    background-color: #1F3D22;
}

.wila-success-badge--outline {
    background-color: rgba(255, 255, 255, 0.25);
    font-weight: 400;
}

.wila-success-name {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 600;
    color: #FFFFFF;
    line-height: 1.25;
    overflow-wrap: break-word;
}

.wila-success-quote {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
    color: #F1F5F1;
    max-width: 46ch;
    overflow-wrap: break-word;
}

/* Play button — present on any card with a Video URL set. Smaller by
   default on compact cards; both sizes are also controllable separately
   from the widget's Style tab. */
.wila-success-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: #6EA83B;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    transition: transform 200ms ease, box-shadow 200ms ease, width 200ms ease, height 200ms ease;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
}

.wila-success-play:hover {
    transform: translate(-50%, -50%) scale(1.06);
}

.wila-success-play svg {
    fill: #FFFFFF;
    margin-left: 4px;
}

/* Inline video layer — injected by success-stories.js over a card once
   its play button is clicked, instead of a separate lightbox popup. */
.wila-success-video {
    position: absolute;
    inset: 0;
    z-index: 3;
    background: #000;
}

.wila-success-video iframe,
.wila-success-video video {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    object-fit: cover;
}

.wila-success-video-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 4;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #FFFFFF;
    border: none;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wila-success-video-close:hover {
    background: rgba(0, 0, 0, 0.75);
}

/* While playing, fade out the badges/name/quote and the play button so
   the video is unobstructed; the overlay gradient also steps aside. */
.wila-success-card.is-playing .wila-success-content,
.wila-success-card.is-playing .wila-success-play,
.wila-success-card.is-playing .wila-success-overlay {
    opacity: 0;
    pointer-events: none;
}

/* =========================================================
   Tablet and up: give the featured card more breathing room.
   Still stacked (side rail below), matching the reference
   mobile/tablet design — just bigger, since there's more space.
   ========================================================= */
@media (min-width: 481px) {
    .wila-success-card--featured {
        min-height: 420px;
    }

    .wila-success-card--compact {
        min-height: 150px;
    }

    .wila-success-play {
        width: 72px;
        height: 72px;
    }
}

/* =========================================================
   Desktop: switch to the featured + side-rail 2-column layout.
   1025px keeps this off for landscape tablets (iPad Pro etc.),
   so "tab and mobile" both get the stacked layout requested.
   ========================================================= */
@media (min-width: 1025px) {
    .wila-success-grid {
        /* Reads the widget's "Featured Column Width" control, which now
           only ever writes to this variable (see widget PHP) — falls back
           to 62% if the control hasn't set it. Deliberately only read here,
           inside the desktop breakpoint, so no per-device value stored on
           this control (old or new) can ever affect tablet/mobile again. */
        grid-template-columns: var(--wila-success-ratio, 62%) 1fr;
    }

    .wila-success-side-col {
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 16px;
    }

    .wila-success-card--featured {
        min-height: 600px;
    }

    .wila-success-card--compact {
        flex: 1;
        min-height: 188px;
    }

    .wila-success-card--compact .wila-success-content {
        padding: 18px 20px;
    }

    .wila-success-card--compact .wila-success-name {
        font-size: 17px;
        white-space: normal;
    }

    .wila-success-card--compact .wila-success-badge {
        font-size: 12px;
        padding: 6px 14px;
    }

    .wila-success-play {
        width: 80px;
        height: 80px;
    }
}