/* ==========================================================
   Masons Social Feed — Frontend grid + cards
   Uses Kadence CSS custom properties where available,
   with sensible fallbacks for non-Kadence themes.
   ========================================================== */

/* ----------------------------------------------------------
   Container — lets the grid respond to the width it is GIVEN,
   not just the screen. A 4-card grid inside a narrow block-theme
   content column (≈645px) drops to 2 columns automatically.
---------------------------------------------------------- */
.msf-feed {
    container-type: inline-size;
    width: 100%;
}

/* ----------------------------------------------------------
   Grid
---------------------------------------------------------- */
.msf-grid {
    display: grid;
    gap: 1.5rem;
    width: 100%;
    margin: 1.5rem 0;
    /* default: auto-distribute up to 4 columns */
    grid-template-columns: repeat( auto-fill, minmax( 260px, 1fr ) );
}

/* Exact column layouts driven by actual item count */
/* ----------------------------------------------------------
   Padding variants — controls grid gap (space between cards)
   and outer margin of the grid itself. Card internal padding
   is unaffected. Override Kadence section spacing with care.
---------------------------------------------------------- */
.msf-grid.msf-pad-none   { gap: 0;       margin: 0; }
.msf-grid.msf-pad-tight  { gap: 0.5rem;  margin: 0.5rem 0; }
.msf-grid.msf-pad-normal { gap: 1.5rem;  margin: 1.5rem 0; }
.msf-grid.msf-pad-wide   { gap: 2.5rem;  margin: 2.5rem 0; }

/* ----------------------------------------------------------
   Centered variant — cards keep their natural width and sit
   in a horizontally-centred row inside the parent container.
   Wraps to a new row on narrower screens.
---------------------------------------------------------- */
.msf-grid.msf-centered {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: stretch;
    /* Override the grid-template-columns from .msf-cols-N classes */
    grid-template-columns: unset !important;
    max-width: 100%;
}

.msf-grid.msf-centered > .msf-card {
    flex: 0 0 auto;
    width: 260px;
    max-width: 100%;
}

/* Mobile — each card full width, still centred */
@media ( max-width: 782px ) {
    .msf-grid.msf-centered > .msf-card { width: 100%; }
}

/* Desktop column counts. msf-cols-N = N cards per row (set by columns="N",
   or by the card count when columns is not given). */
.msf-cols-1 { grid-template-columns: 1fr; max-width: 420px; }
.msf-cols-2 { grid-template-columns: repeat( 2, 1fr ); }
.msf-cols-3 { grid-template-columns: repeat( 3, 1fr ); }
.msf-cols-4 { grid-template-columns: repeat( 4, 1fr ); }
.msf-cols-5 { grid-template-columns: repeat( 5, 1fr ); }
.msf-cols-6 { grid-template-columns: repeat( 6, 1fr ); }

/* Tablet (viewport) — double stack: everything 2 per row */
@media ( max-width: 1024px ) {
    .msf-cols-3,
    .msf-cols-4,
    .msf-cols-5,
    .msf-cols-6 { grid-template-columns: repeat( 2, 1fr ); }
}

/* Narrow container (a slim content column on a wide screen).
   3 and 4 across are kept as long as cards stay a usable width;
   5–6 fold to 3, then everything folds to 2. */
@container ( max-width: 900px ) {
    .msf-cols-5,
    .msf-cols-6 { grid-template-columns: repeat( 3, 1fr ); }
}
@container ( max-width: 760px ) {
    .msf-cols-3,
    .msf-cols-4 { gap: 1rem; }
    .msf-cols-5,
    .msf-cols-6 { grid-template-columns: repeat( 2, 1fr ); }
}
@container ( max-width: 560px ) {
    .msf-cols-4 { grid-template-columns: repeat( 2, 1fr ); }
}

/* Very narrow container: everything stacks */
@container ( max-width: 480px ) {
    .msf-grid,
    .msf-cols-2,
    .msf-cols-3,
    .msf-cols-4,
    .msf-cols-5,
    .msf-cols-6 { grid-template-columns: 1fr; }
    .msf-grid.msf-centered > .msf-card { width: 100%; }
}

/* Mobile — everything stacks into a single column, cards fill the width */
@media ( max-width: 782px ) {
    .msf-grid,
    .msf-cols-1,
    .msf-cols-2,
    .msf-cols-3,
    .msf-cols-4,
    .msf-cols-5,
    .msf-cols-6 { grid-template-columns: 1fr; max-width: none; gap: 1.25rem; }

    .msf-card-image { aspect-ratio: 16 / 10; }
    .msf-card-title { font-size: 1.05rem !important; }
}

/* ----------------------------------------------------------
   Card
---------------------------------------------------------- */
.msf-card {
    background: var( --global-palette9, #ffffff );
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.08 );
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.msf-card:hover {
    transform: translateY( -4px );
    box-shadow: 0 8px 24px rgba( 0, 0, 0, 0.13 );
}

.msf-card-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none !important;
    color: inherit;
}

/* ----------------------------------------------------------
   Image area
---------------------------------------------------------- */
.msf-card-image {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var( --global-palette7, #f2f2f2 );
    flex-shrink: 0;
}

.msf-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
}

.msf-card:hover .msf-card-image img {
    transform: scale( 1.05 );
}

/* Placeholder when no image is available */
.msf-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.25;
}

.msf-card-placeholder svg {
    width: 48px;
    height: 48px;
}

/* Platform badge */
.msf-badge {
    position: absolute;
    bottom: 10px;
    left: 10px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: #fff;
    line-height: 1;
    white-space: nowrap;
    backdrop-filter: blur( 4px );
    -webkit-backdrop-filter: blur( 4px );
}

/* Play icon — centred over video cards */
.msf-play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 56px;
    height: 56px;
    transform: translate( -50%, -50% );
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba( 0, 0, 0, 0.55 );
    color: #fff;
    box-shadow: 0 2px 10px rgba( 0, 0, 0, 0.35 );
    backdrop-filter: blur( 3px );
    -webkit-backdrop-filter: blur( 3px );
    transition: transform 0.2s ease, background 0.2s ease;
    pointer-events: none;
}
.msf-play svg {
    width: 28px;
    height: 28px;
    margin-left: 3px; /* optical centring of the triangle */
}
.msf-card:hover .msf-play {
    transform: translate( -50%, -50% ) scale( 1.08 );
    background: rgba( 0, 0, 0, 0.7 );
}

/* Per-platform badge colours */
.msf-platform-youtube  .msf-badge { background: rgba( 255,   0,   0, 0.85 ); }
.msf-platform-facebook .msf-badge { background: rgba(  24, 119, 242, 0.85 ); }
.msf-platform-custom1  .msf-badge,
.msf-platform-custom2  .msf-badge,
.msf-platform-custom3  .msf-badge { background: rgba(  40,  40,  40, 0.80 ); }

/* ----------------------------------------------------------
   Card body
---------------------------------------------------------- */
/* Text alignment — set by the align="" attribute (default: center) */
.msf-grid.msf-text-center .msf-card-body { text-align: center; }
.msf-grid.msf-text-left   .msf-card-body { text-align: left; }
.msf-grid.msf-text-right  .msf-card-body { text-align: right; }

.msf-card-body {
    padding: 1rem 1.1rem 1.1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.msf-card-title {
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    margin: 0 !important;
    color: var( --global-palette3, #1a1a1a ) !important;
    /* clamp to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.msf-card-desc {
    font-size: 0.82rem;
    color: var( --global-palette5, #666 );
    line-height: 1.55;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.msf-card-date {
    display: block;
    font-size: 0.74rem;
    color: var( --global-palette6, #999 );
    margin-top: auto;
    padding-top: 0.5rem;
}

/* ----------------------------------------------------------
   Admin-only notice (only shown to logged-in admins)
---------------------------------------------------------- */
.msf-notice-admin {
    padding: 0.75rem 1rem;
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    font-size: 0.9rem;
    margin: 1rem 0;
}
