/* ============================================================
   apc/modal-card-grid — frontend styles
   (modal styles come from the Stories snippet: um-story-modal)
   ============================================================ */

.apc-mcg {
    --apc-mcg-cols: 3;
    --apc-mcg-ratio: 4/3;
    --apc-mcg-gap: clamp(16px, 2.2vw, 28px);
    --apc-mcg-row-gap: clamp(28px, 3.5vw, 44px);
    --apc-mcg-row-gap-single: clamp(44px, 6vw, 56px);
    --apc-mcg-accent: #155DFC;
    --apc-mcg-text: #1a1a1a;
    --apc-mcg-muted: rgba(0, 0, 0, 0.55);
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    container-type: inline-size;
}

/* Up to --apc-mcg-cols columns; collapses on its own as the space shrinks,
   never narrower than 240px per card (one column on phones). */
.apc-mcg__grid {
    display: grid;
    grid-template-columns: repeat(
        auto-fill,
        minmax(max(240px, calc((100% - (var(--apc-mcg-cols) - 1) * var(--apc-mcg-gap)) / var(--apc-mcg-cols))), 1fr)
    );
    gap: var(--apc-mcg-row-gap) var(--apc-mcg-gap);
    margin: 0;
    padding: 0;
    list-style: none;
}

/* One column — a larger row gap so each card is clearly separated
   from the previous card's text.
   a) "Columns" set to 1 in the block settings; */
.apc-mcg[style*="--apc-mcg-cols:1;"] .apc-mcg__grid {
    row-gap: var(--apc-mcg-row-gap-single);
}
/* b) the grid collapsed to one column on its own (two 240px cards
   plus the column gap no longer fit in the container). */
@container (max-width: 495.98px) {
    .apc-mcg__grid {
        row-gap: var(--apc-mcg-row-gap-single);
    }
}

/* ── Card ── */
.um-story-card {
    margin: 0;
    min-width: 0;
}
.um-story-card__link {
    display: flex;
    flex-direction: column;
    gap: 14px;
    height: 100%;
    color: var(--apc-mcg-text);
    text-decoration: none;
    border-radius: 12px;
    outline: none;
}
.um-story-card__link:focus-visible {
    outline: 2px solid var(--apc-mcg-accent);
    outline-offset: 4px;
}
.um-story-card__media {
    position: relative;
    display: block;
    aspect-ratio: var(--apc-mcg-ratio);
    overflow: hidden;
    border-radius: 12px;
    background: #e9ebef;
}
.um-story-card__img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.um-story-card__body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.um-story-card__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--apc-mcg-muted);
}
.um-story-card__type {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    background: rgba(21, 93, 252, 0.08);
    color: var(--apc-mcg-accent);
    font-weight: 500;
}
.um-story-card__date {
    font-variant-numeric: tabular-nums;
}
.um-story-card__title {
    margin: 0;
    color: inherit;
    font-size: clamp(1.1rem, 1.35vw, 1.3rem);
    font-weight: 600;
    line-height: 1.3;
    text-wrap: pretty;
    text-decoration: underline;
    text-decoration-color: transparent;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 4px;
    transition: text-decoration-color 0.2s ease;
}
.um-story-card__excerpt {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 15px;
    line-height: 1.5;
    color: var(--apc-mcg-muted);
}

@media (hover: hover) {
    .um-story-card__link:hover .um-story-card__img {
        transform: scale(1.04);
    }
    .um-story-card__link:hover .um-story-card__title {
        text-decoration-color: currentColor;
    }
}

/* ── Load more ── */
.apc-mcg__more {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: clamp(32px, 4vw, 52px);
}
.apc-mcg__more-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 180px;
    min-height: 48px;
    margin: 0;
    padding: 0 28px;
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 999px;
    background: #fff;
    color: var(--apc-mcg-text);
    font: inherit;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.2s ease, background 0.2s ease;
}
.apc-mcg__more-btn:hover {
    border-color: rgba(0, 0, 0, 0.4);
    background: #f7f7f8;
}
.apc-mcg__more-btn:focus-visible {
    outline: 2px solid var(--apc-mcg-accent);
    outline-offset: 3px;
}
.apc-mcg__more-btn:disabled {
    cursor: progress;
}
.apc-mcg__more-btn[hidden] {
    display: none;
}
.apc-mcg__more-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(0, 0, 0, 0.12);
    border-top-color: var(--apc-mcg-accent);
    border-radius: 50%;
    opacity: 0;
}
.apc-mcg__more-btn.is-loading .apc-mcg__more-label {
    visibility: hidden;
}
.apc-mcg__more-btn.is-loading .apc-mcg__more-spinner {
    opacity: 1;
    animation: apc-mcg-spin 0.8s linear infinite;
}
@keyframes apc-mcg-spin {
    to { transform: rotate(360deg); }
}
.apc-mcg__status {
    min-height: 1.4em;
    margin: 0;
    font-size: 14px;
    color: var(--apc-mcg-muted);
    text-align: center;
}
.apc-mcg__status:empty {
    min-height: 0;
}

.apc-mcg__empty {
    margin: 0;
    color: var(--apc-mcg-muted);
}

@media (prefers-reduced-motion: reduce) {
    .um-story-card__img,
    .um-story-card__title {
        transition: none;
    }
    .apc-mcg__more-btn.is-loading .apc-mcg__more-spinner {
        animation-duration: 2.4s;
    }
}