/**
 * Immer Stories — card layout classes + carousel styles
 * Also enqueued in the admin for the AJAX preview.
 *
 * CSS custom properties let the theme override colours without touching this file:
 *   --immer-card-radius              corner radius (default 1.25rem / 20px)
 *   --immer-card-border              card border colour
 *   --immer-card-style-white-bg      White style background (default #ffffff)
 *   --immer-card-style-white-color   White style text (default #3B4F5B)
 *   --immer-card-style-grey-bg       Light Grey style background (default #EAECE9)
 *   --immer-card-style-grey-color    Light Grey style text (default #3B4F5B)
 *   --immer-card-style-dark-bg       Dark style background (default #3B4F5B)
 *   --immer-card-style-dark-color    Dark style text (default #ffffff)
 *   --immer-card-btn-primary-bg
 *   --immer-card-btn-primary-color
 *   --immer-card-btn-secondary-bg
 *   --immer-card-btn-secondary-color
 */

/* -------------------------------------------------------------------------
   Card base
   ------------------------------------------------------------------------- */

.immer-story-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow: hidden;
    border-radius: var(--immer-card-radius, 1.25rem); /* 20px */
    width: 16rem;   /* 256px */
    height: 24rem;  /* 384px */
    padding: 1rem;
    box-sizing: border-box;
}

/* -------------------------------------------------------------------------
   Card styles — background, text, and border per style variant
   ------------------------------------------------------------------------- */

.immer-story-card.card--style-white {
    background: var(--immer-card-style-white-bg, #ffffff);
    color: var(--immer-card-style-white-color, #3B4F5B);
    border: 2px solid var(--immer-card-border, #e5e7eb);
}

.immer-story-card.card--style-light-grey {
    background: var(--immer-card-style-grey-bg, #EAECE9);
    color: var(--immer-card-style-grey-color, #3B4F5B);
    border: 2px solid var(--immer-card-border, #e5e7eb);
}

.immer-story-card.card--style-dark {
    background: var(--immer-card-style-dark-bg, #3B4F5B);
    color: var(--immer-card-style-dark-color, #ffffff);
}

/* -------------------------------------------------------------------------
   Layout: image only — image fills the entire card
   ------------------------------------------------------------------------- */

.immer-story-card.card--image-only {
    padding: 0;
}

.immer-story-card.card--image-only .immer-story-card__image {
    flex: 1;
    min-height: 0;
}

.immer-story-card.card--image-only .immer-story-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* -------------------------------------------------------------------------
   Layout: image top — image occupies the top area with padding, content below
   ------------------------------------------------------------------------- */

.immer-story-card.card--image-top .immer-story-card__image {
    flex: 0 0 auto;
    height: 8rem;
    overflow: hidden;
    border-radius: 0.75rem;
}

.immer-story-card.card--image-top .immer-story-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* -------------------------------------------------------------------------
   Layout: content only — no image, content fills the whole card
   (no extra rules needed beyond the base flex column)
   ------------------------------------------------------------------------- */

/* -------------------------------------------------------------------------
   Content area
   ------------------------------------------------------------------------- */

.immer-story-card__content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    padding: 0.5rem;
}

.immer-story-card__text {
    flex: 1;
    color: var(--immer-card-text-color, inherit);
    overflow: hidden;
}

.immer-story-card__text p:first-child { margin-top: 0; }
.immer-story-card__text p:last-child  { margin-bottom: 0; }

/* -------------------------------------------------------------------------
   Buttons — pushed to the bottom of the content area
   ------------------------------------------------------------------------- */

.immer-story-card__buttons {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* -------------------------------------------------------------------------
   Widget layout

   .immer-story-widget-wrap is the container-query anchor.
   Default (< 70.5rem = 1128px): stacked — header on top, carousel below.
   At ≥ 70.5rem: side-by-side with 3 cards.
   ------------------------------------------------------------------------- */

.immer-story-widget-wrap {
    container-type: inline-size;
}

/* Default: stacked */
.immer-story-widget {
    display: grid;
    grid-template-columns: 1fr;
    row-gap: 1.5rem;
    padding-bottom: 5rem;
    align-items: start;
}

.immer-story-widget__header {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.immer-story-widget__carousel-area {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    overflow: hidden;
}

.immer-story-widget__nav {
    justify-content: center;
}

/* Side-by-side: 3 cards + header on left */
@container (min-width: 70.5rem) {
    .immer-story-widget {
        grid-template-columns: 18rem auto;
        column-gap: 2.5rem;
        row-gap: 0;
        align-items: center;
    }

    .immer-story-widget__header {
        grid-column: 1;
        padding-right: 1rem;
    }

    .immer-story-widget__carousel-area {
        grid-column: 2;
        width: calc(3 * 16rem + 2 * 1rem); /* 50rem = 3 cards */
    }

    .immer-story-widget__nav {
        justify-content: flex-end;
    }
}

/* -------------------------------------------------------------------------
   Carousel — native scroll-snap
   ------------------------------------------------------------------------- */

.immer-story-carousel {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 1rem;
    scrollbar-width: none;       /* Firefox */
    -ms-overflow-style: none;    /* IE / Edge */
    cursor: grab;
    box-sizing: border-box;
}

.immer-story-carousel:active {
    cursor: grabbing;
}

.immer-story-carousel::-webkit-scrollbar {
    display: none;
}

.carousel-slide {
    scroll-snap-align: start;
    flex-shrink: 0;
}

/* -------------------------------------------------------------------------
   Navigation arrows (below carousel)
   ------------------------------------------------------------------------- */

.immer-story-widget__nav {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.immer-story-nav {
    flex-shrink: 0;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #333333;
    transition: background 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
}

.immer-story-nav:hover {
    background: #f5f5f5;
}

.immer-story-nav svg {
    width: 27px;
    height: 27px;
    flex-shrink: 0;
}

.immer-story-nav.is-disabled {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

/* -------------------------------------------------------------------------
   Image layout variants

   .card--image-grow: image expands to fill available vertical space
   .card--image-bottom: image moves to bottom (flex-direction: column-reverse)
   .card--image-fit-contain: image uses object-fit: contain instead of cover
   ------------------------------------------------------------------------- */

.immer-story-card.card--image-grow .immer-story-card__image {
    flex: 1;
    min-height: 0;
}

/* Content should not compete for space — let the image take the rest */
.immer-story-card.card--image-grow .immer-story-card__content {
    flex: none;
}

.immer-story-card.card--image-bottom {
    flex-direction: column-reverse;
}

.immer-story-card.card--image-fit-contain .immer-story-card__image img {
    object-fit: contain;
}

.immer-story-card.card--image-only.card--image-fit-contain .immer-story-card__image img {
    object-fit: contain;
}

.immer-story-card.card--image-top.card--image-fit-contain .immer-story-card__image img {
    object-fit: contain;
}
