﻿/* قسم "الخبير على السوشال ميديا" بالرئيسية (Shared/KhabeerSocial.razor) */
/* شكلو متل صفحة حساب على السوشال ميديا: الشعار والاسم، عدد المتابعين بكل منصة، وتحت الفيديوهات الأكثر مشاهدة */
/* الكروت جايين من CardsViewer: كل كرت جوّا div، وبوضع لوحة التحكم بيجي بنفس الـ div أزرار الإضافة والحذف (crsl-controls) */

.khsoc {
    --khsoc-ink: var(--sec-color);
    --khsoc-green: var(--pr-color);
    --khsoc-green-text: #3BA811;
    --khsoc-muted: #4E6463;
    --khsoc-line: rgba(0, 34, 33, 0.09);
    direction: rtl;
    position: relative;
    overflow: hidden;
    isolation: isolate;
    width: min(var(--default-spacing), var(--default-max-spacing));
    margin-inline: auto;
    margin-top: 40px;
    padding: 64px 60px 60px;
    border-radius: 20px;
    color: var(--khsoc-ink);
    background:
        radial-gradient(45% 55% at 0% 0%, rgba(91, 225, 30, 0.10), transparent 70%),
        radial-gradient(40% 50% at 100% 100%, rgba(91, 225, 30, 0.08), transparent 70%),
        #fff;
    border: 1px solid var(--khsoc-line);
    box-shadow: 0 40px 80px -56px rgba(0, 34, 33, 0.45);
}

/* لايكات وقلوب صغيرة طايرة بالخلفية */
.khsoc-float {
    position: absolute;
    z-index: -1;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #fff;
    border: 1px solid rgba(91, 225, 30, 0.35);
    box-shadow: 0 12px 24px -14px rgba(0, 34, 33, 0.4);
    pointer-events: none;
}

.khsoc-float svg {
    width: 22px;
    height: 22px;
    fill: var(--khsoc-green);
}

.khsoc-float-1 { top: 70px; left: 7%; }
.khsoc-float-2 { top: 190px; left: 15%; width: 36px; height: 36px; }
.khsoc-float-3 { top: 40px; left: 26%; width: 30px; height: 30px; }
.khsoc-float-4 { top: 150px; right: 4%; width: 38px; height: 38px; }

.khsoc-float-2 svg,
.khsoc-float-4 svg {
    width: 17px;
    height: 17px;
}

.khsoc-float-3 svg {
    width: 14px;
    height: 14px;
}

/* ---------- رأس الحساب ---------- */

.khsoc-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 18px;
}

/* حلقة متدرجة حوالين الشعار متل حلقة الستوري */
.khsoc-avatar {
    position: relative;
    width: 116px;
    height: 116px;
    padding: 4px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, var(--khsoc-green), #B9F59B, var(--khsoc-green-text), #E2FBD4, var(--khsoc-green));
}

.khsoc-avatar-in {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--khsoc-ink);
    border: 4px solid #fff;
}

.khsoc-avatar-in svg {
    width: 62%;
    height: auto;
}

.khsoc-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    font-family: var(--kh-reg);
    font-size: 0.92rem;
    color: var(--khsoc-ink);
    background: rgba(91, 225, 30, 0.12);
    border: 1px solid rgba(91, 225, 30, 0.4);
}

.khsoc-name {
    margin: 12px 0 0;
    font-family: var(--kh-bold);
    font-weight: normal;
    font-size: clamp(2rem, 4vw, 2.9rem);
    line-height: 1.25;
    color: var(--khsoc-ink);
}

.khsoc-name span {
    color: var(--khsoc-green-text);
}

.khsoc-bio {
    margin: 6px 0 0;
    font-family: var(--kh-reg);
    font-size: clamp(1rem, 1.4vw, 1.18rem);
    color: var(--khsoc-muted);
}

/* ---------- عدد المتابعين ---------- */

.khsoc-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 34px;
}

.khsoc-stats > div {
    position: relative;
    flex: 0 1 190px;
    min-width: 0;
}

/* خط فاصل بين المنصات متل صفحة الحساب */
.khsoc-stats > div + div::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    top: 18%;
    bottom: 18%;
    width: 1px;
    background: var(--khsoc-line);
}

.khsoc-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    color: var(--khsoc-ink);
    text-decoration: none;
    border-radius: 16px;
    transition: background-color 0.3s ease;
}

.khsoc-stat:hover {
    background: rgba(91, 225, 30, 0.08);
}

.khsoc-stat-top {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* أيقونة المنصة صورة من الداتا */
.khsoc-stat .khsoc-ico {
    flex: none;
    width: 24px;
    height: 24px;
    max-width: none;
    object-fit: contain;
    transition: transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.khsoc-stat:hover .khsoc-ico {
    transform: translateY(-3px) rotate(-8deg);
}

.khsoc-stat-num {
    position: relative;
    display: inline-block;
    font-family: var(--kh-bold);
    font-size: clamp(1.9rem, 3vw, 2.4rem);
    line-height: 1.1;
    direction: ltr;
    font-variant-numeric: tabular-nums;
}

/* الرقم المتحرك (social.js) فوق الرقم الأصلي، والأصلي بيرجع لما يخلص العد */
.khsoc-count.is-counting {
    color: transparent;
}

.khsoc-count-anim {
    position: absolute;
    inset: 0;
    text-align: center;
    color: var(--khsoc-ink);
}

.khsoc-stat-label {
    font-family: var(--kh-reg);
    font-size: 0.95rem;
    color: var(--khsoc-muted);
}

.khsoc-stat-label b {
    font-weight: normal;
    color: var(--khsoc-ink);
}

/* ---------- تبويب الفيديوهات ---------- */

.khsoc-tab {
    display: flex;
    justify-content: center;
    margin-top: 40px;
    border-top: 1px solid var(--khsoc-line);
}

.khsoc-tab-title {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 18px 6px 0;
    font-family: var(--kh-bold);
    font-weight: normal;
    font-size: clamp(1.1rem, 1.6vw, 1.3rem);
    color: var(--khsoc-ink);
}

/* خط التبويب الفعّال فوق متل التطبيقات */
.khsoc-tab-title::before {
    content: "";
    position: absolute;
    top: -1px;
    left: 0;
    right: 0;
    height: 2px;
    border-radius: 2px;
    background: var(--khsoc-ink);
}

.khsoc-tab-title svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: var(--khsoc-green-text);
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---------- الفيديوهات ---------- */

/* 4 فيديوهات بالصف بالكمبيوتر و 2 بالموبايل */
.khsoc-reels {
    --khsoc-gap: 16px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--khsoc-gap);
    margin-top: 24px;
}

.khsoc-reels > div {
    position: relative;
    min-width: 0;
}

/* الفيديوهات الزيادة مخفية لحد ما ينكبس "شاهد المزيد" (social.js) */
.khsoc-reels > div.khsoc-off {
    display: none;
}

/* قبل ما يشتغل الـ JS: أول صف بس (مو بوضع لوحة التحكم، هونيك كل الكروت ظاهرة) */
.khsoc-reels:not(.is-ready):not(:has(.crsl-controls)) > div:nth-child(n+5) {
    display: none;
}

.khsoc-reel {
    position: relative;
    display: block;
    aspect-ratio: 9 / 16;
    overflow: hidden;
    isolation: isolate;
    border-radius: 18px;
    background: #0B2A28;
    color: #fff;
    text-decoration: none;
    box-shadow: 0 20px 40px -28px rgba(0, 34, 33, 0.7);
    transition: transform 0.4s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.4s ease;
}

.khsoc-reel-cover {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    z-index: -2;
    transition: transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.khsoc-reel:hover .khsoc-reel-cover {
    transform: scale(1.06);
}

/* أيقونة المنصة واسمها بالأعلى */
.khsoc-reel-plat {
    position: absolute;
    top: 12px;
    inset-inline-start: 12px;
    max-width: calc(100% - 24px);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px 5px 8px;
    border-radius: 999px;
    font-family: var(--kh-reg);
    font-size: 0.82rem;
    line-height: 1.3;
    background: rgba(0, 22, 21, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.25);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.khsoc-reel-plat img {
    flex: none;
    width: 16px;
    height: 16px;
    max-width: none;
    object-fit: contain;
}

/* نص حقل الرابط: مخفي بالموقع (بيقراه قارئ الشاشة)، وبوضع لوحة التحكم بيبيّن تحت زر التشغيل مشان ينعدّل */
.khsoc-reel-link {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.khsoc-reels:has(.crsl-controls) .khsoc-reel-link {
    top: calc(50% + 40px);
    left: 50%;
    width: auto;
    height: auto;
    max-width: calc(100% - 20px);
    padding: 3px 10px;
    clip-path: none;
    translate: -50% 0;
    border-radius: 999px;
    font-family: var(--kh-reg);
    font-size: 0.8rem;
    background: rgba(0, 22, 21, 0.6);
    border: 1px dashed rgba(255, 255, 255, 0.6);
}

/* تدرّج غامق تحت وفوق مشان ينقرا الكلام فوق أي صورة */
.khsoc-reel::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background:
        linear-gradient(to top, rgba(0, 22, 21, 0.88), rgba(0, 22, 21, 0.15) 48%, transparent 60%),
        linear-gradient(to bottom, rgba(0, 22, 21, 0.45), transparent 22%);
    pointer-events: none;
}

.khsoc-reel:hover {
    transform: translateY(-6px);
    box-shadow: 0 30px 50px -28px rgba(0, 34, 33, 0.8);
}

.khsoc-reel:focus-visible {
    outline: 3px solid var(--khsoc-green-text);
    outline-offset: 3px;
}

.khsoc-reel-play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 56px;
    height: 56px;
    margin: -28px 0 0 -28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.55);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    transition: background-color 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1), border-color 0.3s ease;
}

.khsoc-reel-play svg {
    width: 24px;
    height: 24px;
    fill: #fff;
    margin-left: 3px;
    transition: fill 0.3s ease;
}

.khsoc-reel:hover .khsoc-reel-play {
    background: var(--khsoc-green);
    border-color: var(--khsoc-green);
    transform: scale(1.1);
}

.khsoc-reel:hover .khsoc-reel-play svg {
    fill: var(--khsoc-ink);
}

.khsoc-reel-info {
    position: absolute;
    inset-inline: 14px;
    bottom: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.khsoc-reel-views {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 1.05rem;
}

.khsoc-reel-views svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: var(--khsoc-green);
    stroke-width: 2;
}

.khsoc-reel-views b {
    font-family: var(--kh-bold);
    font-weight: normal;
    direction: ltr;
}

.khsoc-reel-title {
    font-family: var(--kh-reg);
    font-size: 0.92rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.92);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    direction: rtl;
    text-align: right;
}

/* أول فيديو: شريط "الأكثر مشاهدة" بأعلى الكرت وإطار أخضر حواليه */
/*.khsoc-reels > div:first-child .khsoc-reel {
    box-shadow: 0 0 0 2px var(--khsoc-green), 0 20px 40px -24px rgba(59, 168, 17, 0.8);
}

.khsoc-reels > div:first-child .khsoc-reel::before {
    content: "الأكثر مشاهدة";
    position: absolute;
    top: 0;
    inset-inline: 0;
    height: 28px;
    display: grid;
    place-items: center;
    font-family: var(--kh-bold);
    font-size: 0.8rem;
    color: var(--khsoc-ink);
    background: var(--khsoc-green);
}

.khsoc-reels > div:first-child .khsoc-reel-plat {
    top: 38px;
}*/

/* زر "شاهد المزيد" */
.khsoc-more-wrap {
    display: flex;
    justify-content: center;
    margin-top: 28px;
}

.khsoc-more {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 26px;
    border: 1.5px solid var(--khsoc-ink);
    border-radius: 999px;
    background: #fff;
    color: var(--khsoc-ink);
    font-family: var(--kh-bold);
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
}

.khsoc-more[hidden] {
    display: none;
}

.khsoc-more svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.3s ease;
}

.khsoc-more:hover {
    background: var(--khsoc-green);
    border-color: var(--khsoc-green);
}

.khsoc-more:hover svg {
    transform: translateY(2px);
}

.khsoc-more:focus-visible {
    outline: 3px solid var(--khsoc-green-text);
    outline-offset: 3px;
}

/* ---------- وضع لوحة التحكم ---------- */
/* أزرار الإضافة والحذف تبع لوحة التحكم بتطلع بأعلى كل كرت. ما منغيّر فيها شي، بس منترك فوق الكرت مسافة بقدّها مشان الكرت ما يكون تحتها */
.khsoc-stats > div:has(> .crsl-controls),
.khsoc-reels > div:has(> .crsl-controls) {
    padding-top: 42px;
}

/* ---------- تابلت ---------- */

@media (max-width: 960px) {
    .khsoc {
        padding: 52px 28px 40px;
    }

    .khsoc-reels {
        --khsoc-gap: 12px;
    }

    .khsoc-float-3,
    .khsoc-float-4 {
        display: none;
    }
}

/* ---------- موبايل: الفيديوهات 2 بالصف ---------- */

@media (max-width: 600px) {
    .khsoc {
        padding: 40px 14px 24px;
    }

    .khsoc-avatar {
        width: 96px;
        height: 96px;
    }

    .khsoc-stats {
        margin-top: 24px;
        flex-wrap: nowrap;
    }

    .khsoc-stats > div {
        flex: 1 1 0;
    }

    .khsoc-stat {
        padding: 8px 4px;
        gap: 4px;
    }

    .khsoc-stat-top {
        flex-direction: column;
        gap: 4px;
    }

    .khsoc-stat .khsoc-ico {
        width: 20px;
        height: 20px;
    }

    .khsoc-stat-num {
        font-size: 1.45rem;
    }

    .khsoc-stat-label {
        font-size: 0.78rem;
        line-height: 1.4;
        text-align: center;
    }

    .khsoc-tab {
        margin-top: 28px;
    }

    .khsoc-reels {
        --khsoc-gap: 10px;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin-top: 16px;
    }

    .khsoc-reel {
        border-radius: 14px;
    }

    .khsoc-reel-plat {
        top: 8px;
        inset-inline-start: 8px;
        max-width: calc(100% - 16px);
        padding: 4px 8px 4px 6px;
        font-size: 0.74rem;
    }

    .khsoc-reel-plat img {
        width: 14px;
        height: 14px;
    }

    .khsoc-reels > div:first-child .khsoc-reel-plat {
        top: 30px;
    }

    .khsoc-reel-play {
        width: 44px;
        height: 44px;
        margin: -22px 0 0 -22px;
    }

    .khsoc-reel-play svg {
        width: 19px;
        height: 19px;
        margin-left: 2px;
    }

    .khsoc-reel-info {
        inset-inline: 10px;
        bottom: 10px;
    }

    .khsoc-reel-views {
        font-size: 0.92rem;
        gap: 5px;
    }

    .khsoc-reel-views svg {
        width: 15px;
        height: 15px;
    }

    .khsoc-reel-title {
        font-size: 0.8rem;
        line-height: 1.45;
    }

    .khsoc-reels > div:first-child .khsoc-reel::before {
        height: 22px;
        font-size: 0.7rem;
    }

    .khsoc-more-wrap {
        margin-top: 20px;
    }

    .khsoc-float {
        display: none;
    }
}

/* ---------- الحركة ---------- */

@keyframes khsoc-spin {
    to {
        transform: rotate(1turn);
    }
}

@keyframes khsoc-bob {
    from {
        translate: 0 0;
        rotate: -6deg;
    }

    to {
        translate: 0 -14px;
        rotate: 6deg;
    }
}

@keyframes khsoc-rise {
    from {
        opacity: 0;
        translate: 0 32px;
    }

    to {
        opacity: 1;
        translate: none;
    }
}

@keyframes khsoc-show {
    from {
        opacity: 0;
        transform: translateY(18px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: no-preference) {

    /* الفيديوهات يللي بتبيّن بـ "شاهد المزيد" */
    .khsoc-reels > div.khsoc-new {
        animation: khsoc-show 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
    }

    .khsoc-reels > div.khsoc-new:nth-child(4n+2) { animation-delay: 0.07s; }
    .khsoc-reels > div.khsoc-new:nth-child(4n+3) { animation-delay: 0.14s; }
    .khsoc-reels > div.khsoc-new:nth-child(4n) { animation-delay: 0.21s; }

    /* الحلقة بتلف على مهل، والشعار ثابت */
    .khsoc-avatar::before {
        content: "";
        position: absolute;
        inset: 0;
        border-radius: 50%;
        background: inherit;
        animation: khsoc-spin 6s linear infinite;
    }

    .khsoc-avatar-in {
        position: relative;
    }

    .khsoc-float {
        animation: khsoc-bob 4s ease-in-out infinite alternate;
    }

    .khsoc-float-2 { animation-duration: 5s; animation-delay: -2s; }
    .khsoc-float-3 { animation-duration: 3.6s; animation-delay: -1s; }
    .khsoc-float-4 { animation-duration: 4.6s; animation-delay: -3s; }

    @supports (animation-timeline: view()) {
        .khsoc-profile,
        .khsoc-stats > div,
        .khsoc-reels > div {
            animation: khsoc-rise linear both;
            animation-timeline: view();
            animation-range: entry 0% entry 60%;
        }

        .khsoc-reels > div:nth-child(2) { animation-range: entry 6% entry 66%; }
        .khsoc-reels > div:nth-child(3) { animation-range: entry 12% entry 72%; }
        .khsoc-reels > div:nth-child(4) { animation-range: entry 18% entry 78%; }
        .khsoc-reels > div:nth-child(5) { animation-range: entry 24% entry 84%; }
        .khsoc-reels > div:nth-child(6) { animation-range: entry 30% entry 90%; }
    }
}
