/*
 * This file is part of the BGB70 TYPO3 extensions.
 *
 * Copyright (c) Bernd Gabel
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/* ─────────────────────────────────────────────────────────────────────────
 * Content element "Social feed" (bgb70_socialfeed)
 * Layouts: cards (image + text), tiles (images only), overlay (tiles, the
 * text appears on a dark layer on hover), strip (horizontal, scroll-snap). Colours from the theme variables of bgb70_themebase.
 * Links need !important: the theme's global link rule is more specific.
 * ───────────────────────────────────────────────────────────────────────── */

.bgb70-socialfeed {
    --bgb70-sf-gap: 1rem;
    --bgb70-sf-radius: var(--bgb70-radius, 0.5rem);
}

.bgb70-socialfeed__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, calc((100% - (var(--bgb70-sf-columns, 4) - 1) * var(--bgb70-sf-gap)) / var(--bgb70-sf-columns, 4))), 1fr));
    gap: var(--bgb70-sf-gap);
    margin: 0;
    padding: 0;
    list-style: none;
}

@media (max-width: 991.98px) {
    .bgb70-socialfeed__list { grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); }
}

.bgb70-socialfeed__item { display: flex; min-width: 0; }

.bgb70-socialfeed__card,
a.bgb70-socialfeed__card {
    display: flex;
    flex-direction: column;
    width: 100%;
    overflow: hidden;
    border: 1px solid var(--bgb70-border, rgba(0, 0, 0, 0.1));
    border-radius: var(--bgb70-sf-radius);
    background: var(--bgb70-surface, #fff);
    box-shadow: var(--bgb70-shadow-card, none);
    color: var(--bgb70-text, inherit) !important;
    text-decoration: none !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

a.bgb70-socialfeed__card::before,
a.bgb70-socialfeed__card::after,
a.bgb70-socialfeed__follow-link::before,
a.bgb70-socialfeed__follow-link::after { display: none !important; }

a.bgb70-socialfeed__card:hover,
a.bgb70-socialfeed__card:focus-visible {
    transform: translateY(-3px);
    box-shadow: 0 0.75rem 1.5rem rgba(0, 0, 0, 0.12);
}

a.bgb70-socialfeed__card:focus-visible {
    outline: 3px solid var(--bgb70-accent, currentColor);
    outline-offset: 2px;
}

.bgb70-socialfeed__media {
    position: relative;
    display: block;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: var(--bgb70-surface-alt, #f1f3f6);
}

.bgb70-socialfeed__image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

a.bgb70-socialfeed__card:hover .bgb70-socialfeed__image { transform: scale(1.04); }

.bgb70-socialfeed__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--bgb70-text-muted, #888);
    font-size: 3rem;
}

/* Platform icons: SVG masks in the text colour */
.bgb70-socialfeed__icon {
    display: inline-block;
    flex: none;
    width: 1em;
    height: 1em;
    background-color: currentColor;
    -webkit-mask: var(--bgb70-sf-icon) center / contain no-repeat;
    mask: var(--bgb70-sf-icon) center / contain no-repeat;
    vertical-align: -0.125em;
}

.bgb70-socialfeed__icon--instagram { --bgb70-sf-icon: url("../Icons/Platforms/instagram.svg"); }
.bgb70-socialfeed__icon--facebook { --bgb70-sf-icon: url("../Icons/Platforms/facebook.svg"); }
.bgb70-socialfeed__icon--youtube { --bgb70-sf-icon: url("../Icons/Platforms/youtube.svg"); }
.bgb70-socialfeed__icon--whatsapp { --bgb70-sf-icon: url("../Icons/Platforms/whatsapp.svg"); }
.bgb70-socialfeed__icon--web,
.bgb70-socialfeed__icon--mixed { --bgb70-sf-icon: url("../Icons/Platforms/web.svg"); }

.bgb70-socialfeed__badge {
    position: absolute;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.55rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    backdrop-filter: blur(4px);
}

.bgb70-socialfeed__badge--platform { top: 0.6rem; right: 0.6rem; padding: 0.4rem; font-size: 1rem; }
.bgb70-socialfeed__badge--video,
.bgb70-socialfeed__badge--carousel { top: 0.6rem; left: 0.6rem; }

.bgb70-socialfeed__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.85rem 1rem 1rem;
}

.bgb70-socialfeed__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.25rem 0.75rem;
    font-size: 0.85rem;
}

.bgb70-socialfeed__author {
    color: var(--bgb70-heading, inherit);
    font-weight: 700;
    overflow-wrap: anywhere;
}

.bgb70-socialfeed__date { color: var(--bgb70-text-muted, #6c757d); white-space: nowrap; }

.bgb70-socialfeed__caption {
    display: -webkit-box;
    overflow: hidden;
    font-size: 0.925rem;
    line-height: 1.5;
    white-space: pre-line;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    line-clamp: 4;
}

.is-pinned .bgb70-socialfeed__card { border-color: var(--bgb70-accent, currentColor); }

/* Tiles: images only, like a profile grid */
.bgb70-socialfeed--tiles { --bgb70-sf-gap: 0.4rem; }
.bgb70-socialfeed--tiles .bgb70-socialfeed__card { border: 0; box-shadow: none; }
.bgb70-socialfeed--tiles a.bgb70-socialfeed__card:hover { transform: none; box-shadow: none; }

/* Overlay: tiles, the text appears in white on a darkened image on hover or
 * keyboard focus; touch screens (no hover) show it permanently on a gradient */
.bgb70-socialfeed--overlay { --bgb70-sf-gap: 0.4rem; }

.bgb70-socialfeed--overlay .bgb70-socialfeed__card {
    position: relative;
    border: 0;
    box-shadow: none;
}

.bgb70-socialfeed--overlay a.bgb70-socialfeed__card:hover { transform: none; box-shadow: none; }

.bgb70-socialfeed--overlay .bgb70-socialfeed__body {
    position: absolute;
    inset: 0;
    z-index: 1;
    justify-content: flex-end;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.68);
    color: #fff;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.bgb70-socialfeed--overlay .bgb70-socialfeed__card:hover .bgb70-socialfeed__body,
.bgb70-socialfeed--overlay .bgb70-socialfeed__card:focus-visible .bgb70-socialfeed__body { opacity: 1; }

.bgb70-socialfeed--overlay .bgb70-socialfeed__author,
.bgb70-socialfeed--overlay .bgb70-socialfeed__date { color: #fff; }

.bgb70-socialfeed--overlay .bgb70-socialfeed__date { opacity: 0.8; }

.bgb70-socialfeed--overlay .bgb70-socialfeed__caption {
    -webkit-line-clamp: 7;
    line-clamp: 7;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.bgb70-socialfeed--overlay .bgb70-socialfeed__badge { z-index: 2; }

@media (hover: none) {
    .bgb70-socialfeed--overlay .bgb70-socialfeed__body {
        background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.35) 55%, transparent);
        opacity: 1;
    }

    .bgb70-socialfeed--overlay .bgb70-socialfeed__caption {
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }
}

/* Strip: one row, swipe/scroll horizontally */
.bgb70-socialfeed--strip .bgb70-socialfeed__list {
    display: flex;
    overflow-x: auto;
    padding-bottom: 0.75rem;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
}

.bgb70-socialfeed--strip .bgb70-socialfeed__item {
    flex: 0 0 calc((100% - (var(--bgb70-sf-columns, 4) - 1) * var(--bgb70-sf-gap)) / var(--bgb70-sf-columns, 4));
    min-width: 14rem;
    scroll-snap-align: start;
}

.bgb70-socialfeed--strip a.bgb70-socialfeed__card:hover { transform: none; }

/* "Follow us" */
.bgb70-socialfeed__follow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.bgb70-socialfeed__follow-label { margin-right: 0.25rem; font-weight: 700; }

a.bgb70-socialfeed__follow-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--bgb70-border, rgba(0, 0, 0, 0.15));
    border-radius: 999px;
    color: var(--bgb70-text, inherit) !important;
    font-size: 0.9rem;
    text-decoration: none !important;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

a.bgb70-socialfeed__follow-link:hover,
a.bgb70-socialfeed__follow-link:focus-visible {
    border-color: var(--bgb70-accent, currentColor);
    background: var(--bgb70-surface-alt, rgba(0, 0, 0, 0.04));
}

.bgb70-socialfeed__empty { color: var(--bgb70-text-muted, #6c757d); }

@media (prefers-reduced-motion: reduce) {
    .bgb70-socialfeed__card,
    .bgb70-socialfeed__image,
    .bgb70-socialfeed__body { transition: none; }
    a.bgb70-socialfeed__card:hover { transform: none; }
    a.bgb70-socialfeed__card:hover .bgb70-socialfeed__image { transform: none; }
}
