/* ==========================================================================
   FEF Social Feed — shared styles for the Instagram + Facebook feed widgets
   Feed grid • Tabs • Stories bar & full-screen viewer • Reels • Lightbox
   Fully responsive, reduced-motion aware, no external dependencies.
   ========================================================================== */

.fef-sf-wrap {
    /* Theme tokens — a widget can override these inline via Elementor if needed */
    --fef-sf-accent: #e1306c;
    --fef-sf-accent-2: #f77737;
    --fef-sf-ring: linear-gradient(45deg, #f9ce34, #ee2a7b 45%, #6228d7);
    --fef-sf-fg: #1c1e21;
    --fef-sf-muted: #65676b;
    --fef-sf-line: #e4e6eb;
    --fef-sf-card: #ffffff;
    --fef-sf-radius: 8px;
    box-sizing: border-box;
    width: 100%;
}
.fef-sf-wrap *,
.fef-sf-wrap *::before,
.fef-sf-wrap *::after { box-sizing: border-box; }

.fef-sf-facebook {
    --fef-sf-accent: #1877f2;
    --fef-sf-accent-2: #1877f2;
    --fef-sf-ring: linear-gradient(45deg, #1877f2, #4293ff);
}

/* ── Channel header ─────────────────────────────────────────────────────── */
.fef-sf-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 4px 2px 16px;
    flex-wrap: wrap;
}
.fef-sf-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    overflow: hidden;
    flex: 0 0 auto;
    background: var(--fef-sf-line);
    display: grid;
    place-items: center;
}
.fef-sf-avatar img { width: 100%; height: 100%; object-fit: cover; }
.fef-sf-avatar-fallback {
    font-weight: 700;
    font-size: 22px;
    color: #fff;
    width: 100%; height: 100%;
    display: grid; place-items: center;
    background: var(--fef-sf-accent);
}
.fef-sf-headmeta { flex: 1 1 auto; min-width: 0; }
.fef-sf-name { font-weight: 700; font-size: 1.05rem; line-height: 1.2; color: var(--fef-sf-fg); }
.fef-sf-stats { font-size: .85rem; color: var(--fef-sf-muted); margin-top: 2px; }
.fef-sf-follow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: .9rem;
    text-decoration: none;
    color: #fff;
    background: var(--fef-sf-accent);
    transition: opacity .2s ease, transform .15s ease;
    white-space: nowrap;
}
.fef-sf-follow:hover { opacity: .9; transform: translateY(-1px); }

/* ── Tabs ───────────────────────────────────────────────────────────────── */
.fef-sf-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--fef-sf-line);
    margin-bottom: 16px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.fef-sf-tabs::-webkit-scrollbar { display: none; }
.fef-sf-tab {
    appearance: none;
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    padding: 10px 16px;
    font: inherit;
    font-weight: 600;
    font-size: .95rem;
    color: var(--fef-sf-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
    transition: color .2s ease, border-color .2s ease;
    margin-bottom: -1px;
}
.fef-sf-tab:hover { color: var(--fef-sf-fg); }
.fef-sf-tab[aria-selected="true"] {
    color: var(--fef-sf-accent);
    border-bottom-color: var(--fef-sf-accent);
}
.fef-sf-tab-ico { font-size: 1.05em; line-height: 1; }
.fef-sf-tab-count {
    font-size: .72rem;
    font-weight: 700;
    background: var(--fef-sf-line);
    color: var(--fef-sf-muted);
    border-radius: 999px;
    padding: 1px 7px;
    line-height: 1.5;
}
.fef-sf-tab[aria-selected="true"] .fef-sf-tab-count {
    background: var(--fef-sf-accent);
    color: #fff;
}

/* ── Panels ─────────────────────────────────────────────────────────────── */
.fef-sf-panel { display: none; animation: fef-sf-fade .25s ease; }
.fef-sf-panel.is-active { display: block; }
@keyframes fef-sf-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Feed grid ──────────────────────────────────────────────────────────── */
.fef-sf-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.fef-sf-item {
    position: relative;
    display: block;
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    border-radius: var(--fef-sf-radius);
    cursor: pointer;
    background: var(--fef-sf-card);
}
.fef-sf-media {
    position: relative;
    overflow: hidden;
    border-radius: var(--fef-sf-radius);
    background: #f0f0f0;
}
.fef-sf-ratio-1-1  .fef-sf-media { aspect-ratio: 1 / 1; }
.fef-sf-ratio-4-5  .fef-sf-media { aspect-ratio: 4 / 5; }
.fef-sf-ratio-16-9 .fef-sf-media { aspect-ratio: 16 / 9; }
.fef-sf-ratio-auto .fef-sf-media { aspect-ratio: auto; }
.fef-sf-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .5s cubic-bezier(.2,.7,.2,1), opacity .4s ease;
}
.fef-sf-ratio-auto .fef-sf-img { height: auto; }
.fef-sf-img[data-lazy] { opacity: 0; }
.fef-sf-img.is-loaded { opacity: 1; }
.fef-sf-zoom .fef-sf-item:hover .fef-sf-img { transform: scale(1.06); }

/* type badge (video / album) */
.fef-sf-type {
    position: absolute;
    top: 8px; right: 8px;
    background: rgba(0,0,0,.55);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    padding: 5px 6px;
    border-radius: 6px;
    backdrop-filter: blur(2px);
    z-index: 2;
}

/* hover overlay */
.fef-sf-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.45);
    opacity: 0;
    transition: opacity .25s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    text-align: center;
    z-index: 1;
}
.fef-sf-item:hover .fef-sf-overlay,
.fef-sf-item:focus-visible .fef-sf-overlay { opacity: 1; }
.fef-sf-glyph { color: #fff; font-size: 1.6rem; line-height: 1; }
.fef-sf-caption { color: #fff; font-size: .85rem; line-height: 1.4; max-height: 5.6em; overflow: hidden; }

/* below-image meta */
.fef-sf-meta { padding: 8px 4px 2px; }
.fef-sf-caption-below { color: var(--fef-sf-fg); font-size: .88rem; line-height: 1.45; }
.fef-sf-facebook .fef-sf-item { box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.fef-sf-facebook .fef-sf-meta { padding: 10px 12px 12px; }
.fef-sf-date { color: var(--fef-sf-muted); font-size: .78rem; margin-top: 4px; }

/* ── Reels ──────────────────────────────────────────────────────────────── */
.fef-sf-reels {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
.fef-sf-reel {
    position: relative;
    aspect-ratio: 9 / 16;
    border-radius: var(--fef-sf-radius);
    overflow: hidden;
    cursor: pointer;
    background: #111;
}
.fef-sf-reel img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s ease; }
.fef-sf-reel:hover img { transform: scale(1.05); }
.fef-sf-reel-play {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 2.4rem;
    text-shadow: 0 2px 12px rgba(0,0,0,.5);
    pointer-events: none;
    background: linear-gradient(180deg, rgba(0,0,0,.05), rgba(0,0,0,.35));
}
.fef-sf-reel-views {
    position: absolute;
    left: 8px; bottom: 8px;
    color: #fff;
    font-size: .78rem;
    font-weight: 600;
    display: flex; align-items: center; gap: 4px;
    text-shadow: 0 1px 4px rgba(0,0,0,.6);
    z-index: 2;
}
.fef-sf-reel-cap {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 26px 10px 8px;
    color: #fff;
    font-size: .78rem;
    line-height: 1.35;
    background: linear-gradient(180deg, transparent, rgba(0,0,0,.75));
    z-index: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Stories bar (circular avatars) ─────────────────────────────────────── */
.fef-sf-stories-bar {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding: 4px 2px 12px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
}
.fef-sf-stories-bar::-webkit-scrollbar { display: none; }
.fef-sf-story {
    appearance: none;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    flex: 0 0 auto;
    width: 74px;
    text-align: center;
    scroll-snap-align: start;
    font: inherit;
}
.fef-sf-story-ring {
    display: block;
    width: 70px; height: 70px;
    border-radius: 50%;
    padding: 3px;
    margin: 0 auto 6px;
    background: var(--fef-sf-ring);
    transition: transform .2s ease;
}
.fef-sf-story.is-seen .fef-sf-story-ring { background: var(--fef-sf-line); }
.fef-sf-story:hover .fef-sf-story-ring { transform: scale(1.05); }
.fef-sf-story-ring img,
.fef-sf-story-thumb {
    width: 100%; height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    border: 2px solid var(--fef-sf-card);
    background: var(--fef-sf-line);
}
.fef-sf-story-name {
    display: block;
    font-size: .74rem;
    color: var(--fef-sf-fg);
    line-height: 1.25;
    max-width: 74px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Setup / error / empty cards ────────────────────────────────────────── */
.fef-sf-setup, .fef-sf-empty {
    text-align: center;
    padding: 40px 24px;
    border: 1px dashed var(--fef-sf-line);
    border-radius: 12px;
    color: var(--fef-sf-muted);
    background: #fafafa;
}
.fef-sf-setup-icon { font-size: 2.4rem; margin-bottom: 8px; }
.fef-sf-setup h4 { margin: 0 0 6px; color: var(--fef-sf-fg); font-size: 1.1rem; }
.fef-sf-setup p { margin: 0; font-size: .9rem; line-height: 1.5; }
.fef-sf-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: .85rem;
    margin: 8px 0;
}

/* ── Skeleton shimmer while media loads ─────────────────────────────────── */
.fef-sf-media::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg, #eee 30%, #f6f6f6 50%, #eee 70%);
    background-size: 200% 100%;
    animation: fef-sf-shim 1.2s ease-in-out infinite;
    z-index: 0;
    opacity: 1;
    transition: opacity .3s ease;
}
.fef-sf-media.is-ready::before { opacity: 0; }
@keyframes fef-sf-shim { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ══════════════════════════════════════════════════════════════════════
   OVERLAYS — Lightbox + Story viewer (appended to <body>, singletons)
   ══════════════════════════════════════════════════════════════════════ */

.fef-sfx {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.92);
    opacity: 0;
    transition: opacity .25s ease;
}
.fef-sfx.is-open { display: flex; opacity: 1; }
body.fef-sfx-lock { overflow: hidden; }

.fef-sfx-close {
    position: absolute;
    top: 16px; right: 18px;
    width: 42px; height: 42px;
    border-radius: 50%;
    border: 0;
    background: rgba(255,255,255,.14);
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    z-index: 5;
    transition: background .2s ease;
}
.fef-sfx-close:hover { background: rgba(255,255,255,.28); }
.fef-sfx-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px; height: 48px;
    border-radius: 50%;
    border: 0;
    background: rgba(255,255,255,.14);
    color: #fff;
    font-size: 1.6rem;
    cursor: pointer;
    z-index: 5;
    display: grid; place-items: center;
    transition: background .2s ease;
}
.fef-sfx-nav:hover { background: rgba(255,255,255,.28); }
.fef-sfx-prev { left: 16px; }
.fef-sfx-next { right: 16px; }
.fef-sfx-nav[hidden] { display: none; }

/* Lightbox stage */
.fef-sfx-stage {
    max-width: min(92vw, 1100px);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.fef-sfx-stage img,
.fef-sfx-stage video {
    max-width: 92vw;
    max-height: 78vh;
    border-radius: 8px;
    background: #000;
    display: block;
}
.fef-sfx-cap {
    color: #eee;
    font-size: .9rem;
    line-height: 1.5;
    max-width: 640px;
    text-align: center;
    max-height: 20vh;
    overflow: auto;
}
.fef-sfx-cap a { color: #fff; text-decoration: underline; }

/* ── Story viewer ───────────────────────────────────────────────────────── */
.fef-sfx-story .fef-sfx-frame {
    position: relative;
    width: min(440px, 96vw);
    height: min(90vh, 780px);
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.fef-sfx-media {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    object-fit: contain;
    background: #000;
}
.fef-sfx-progress {
    position: absolute;
    top: 10px; left: 10px; right: 10px;
    display: flex;
    gap: 4px;
    z-index: 4;
}
.fef-sfx-bar {
    flex: 1;
    height: 3px;
    border-radius: 3px;
    background: rgba(255,255,255,.35);
    overflow: hidden;
}
.fef-sfx-bar > i {
    display: block;
    height: 100%;
    width: 0;
    background: #fff;
    border-radius: 3px;
}
.fef-sfx-bar.is-done > i { width: 100%; }
.fef-sfx-bar.is-active > i { animation: fef-sfx-fill linear forwards; }
@keyframes fef-sfx-fill { from { width: 0; } to { width: 100%; } }

.fef-sfx-shead {
    position: absolute;
    top: 22px; left: 12px; right: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 4;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.fef-sfx-shead img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 1px solid rgba(255,255,255,.5); }
.fef-sfx-sname { font-weight: 600; font-size: .9rem; }
.fef-sfx-stime { font-size: .78rem; opacity: .8; }
.fef-sfx-story .fef-sfx-close { top: 18px; right: 14px; width: 36px; height: 36px; font-size: 1.3rem; }

/* invisible tap zones for prev / next / pause */
.fef-sfx-tap {
    position: absolute;
    top: 0; bottom: 0;
    width: 30%;
    z-index: 3;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.fef-sfx-tap-prev { left: 0; }
.fef-sfx-tap-next { right: 0; }
.fef-sfx-scap {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 40px 16px 18px;
    color: #fff;
    font-size: .9rem;
    line-height: 1.45;
    background: linear-gradient(transparent, rgba(0,0,0,.7));
    z-index: 3;
}
.fef-sfx-scap a { color: #fff; }

/* Story viewer side nav (desktop, to move between story authors/items) */
.fef-sfx-story .fef-sfx-nav { background: rgba(255,255,255,.1); }

/* ══════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .fef-sf-reels { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 767px) {
    .fef-sf-reels { grid-template-columns: repeat(2, 1fr); }
    .fef-sf-tab { padding: 9px 12px; font-size: .9rem; }
    .fef-sf-header { gap: 12px; padding-bottom: 12px; }
    .fef-sf-avatar { width: 48px; height: 48px; }
    .fef-sf-follow { padding: 7px 12px; font-size: .85rem; }
    .fef-sf-story { width: 66px; }
    .fef-sf-story-ring { width: 62px; height: 62px; }
    .fef-sfx-nav { display: none; }          /* stories/lightbox use swipe on mobile */
    .fef-sfx-stage img, .fef-sfx-stage video { max-height: 72vh; }
    .fef-sfx-story .fef-sfx-frame { width: 100vw; height: 100dvh; border-radius: 0; }
    .fef-sfx-story { background: #000; }
}
@media (max-width: 480px) {
    .fef-sf-grid { gap: 6px; }
    .fef-sf-reels { gap: 6px; }
    .fef-sf-follow { flex: 1 1 100%; justify-content: center; margin-top: 4px; }
}

/* Larger tap targets & no hover zoom on touch devices */
@media (hover: none) {
    .fef-sf-zoom .fef-sf-item:hover .fef-sf-img { transform: none; }
    .fef-sf-cap-hover .fef-sf-overlay { opacity: 1; background: linear-gradient(transparent 55%, rgba(0,0,0,.6)); justify-content: flex-end; align-items: flex-start; }
    .fef-sf-cap-hover .fef-sf-glyph { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .fef-sf-img, .fef-sf-reel img, .fef-sf-story-ring, .fef-sf-overlay,
    .fef-sfx, .fef-sf-panel { transition: none !important; animation: none !important; }
    .fef-sfx-bar.is-active > i { animation: none; width: 100%; }
    .fef-sf-media::before { animation: none; }
}