/* ===========================================================
   معرض الصور — أسلوب تحريري + شبكة انستقرام + ستوريات فيديو
   =========================================================== */

.gallery-page {
    background: var(--color-cream);
}

/* ── Hero ── */
.gallery-hero__title {
    font-size: clamp(2rem, 5vw, 3.25rem);
    font-weight: 600;
    color: var(--color-black-light);
    text-align: center;
    margin: 0 0 var(--space-3);
}

.gallery-hero__meta {
    text-align: center;
    color: var(--color-ray);
    font-size: var(--font-size-large);
    margin: 0;
}

.gallery-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 3vw, 2rem) clamp(3rem, 6vw, 5rem);
}

/* ── الستوريات (دوائر) ── */
.stories-section {
    margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
    padding-bottom: clamp(1rem, 3vw, 1.5rem);
    border-bottom: 1px solid var(--color-gray-light);
}

.stories-row {
    display: flex;
    gap: clamp(14px, 3vw, 22px);
    overflow-x: auto;
    padding: 4px 2px 8px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.stories-row::-webkit-scrollbar {
    display: none;
}

.story-circle {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: clamp(70px, 18vw, 88px);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    scroll-snap-align: start;
    -webkit-tap-highlight-color: transparent;
}

.story-circle__ring {
    width: clamp(66px, 17vw, 82px);
    height: clamp(66px, 17vw, 82px);
    border-radius: 50%;
    padding: 3px;
    background: conic-gradient(from 210deg, #f0a93b, #db3c1d, #b3245e, #db3c1d, #f0a93b);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--duration-fast) var(--ease-out);
}

.story-circle:active .story-circle__ring {
    transform: scale(0.95);
}

.story-circle__media {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    background: var(--color-gray-bg);
    border: 2px solid var(--color-cream);
}

.story-circle__media img,
.story-circle__media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.story-circle__label {
    font-size: var(--font-size-small);
    color: var(--color-black-light);
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── شبكة الصور ── */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
}

.gallery-item {
    aspect-ratio: 1 / 1;
    border-radius: 14px;
    overflow: hidden;
    background: var(--color-gray-bg);
    border: none;
    padding: 0;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    -webkit-tap-highlight-color: transparent;
    /* تسريع الطلاء في الشبكات الطويلة (66+ صورة) */
    content-visibility: auto;
    contain-intrinsic-size: 1px 200px;
    transition: transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

@media (hover: hover) and (pointer: fine) {
    .gallery-item:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    }
}

.gallery-item:active {
    transform: scale(0.98);
}

.gallery-empty {
    text-align: center;
    color: var(--color-ray);
    padding: 3rem 1rem;
}

@media (max-width: 1024px) {
    .gallery-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .gallery-item {
        border-radius: 10px;
    }
}

@media (max-width: 420px) {
    .gallery-grid {
        gap: 5px;
    }

    .gallery-item {
        border-radius: 6px;
    }
}

/* ===========================================================
   Lightbox للصور
   =========================================================== */
.fullscreen-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
}

.fullscreen-modal.is-open {
    display: flex !important;
    animation: galleryFadeIn var(--duration-normal) var(--ease-out);
}

.fullscreen-modal.is-closing {
    animation: galleryFadeOut var(--duration-fast) var(--ease-out);
}

.fullscreen-image {
    max-width: 92vw;
    max-height: 88dvh;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
    transition: opacity var(--duration-normal) var(--ease-out);
}

.lightbox-close {
    position: absolute;
    top: max(16px, var(--safe-top));
    inset-inline-end: 16px;
    width: var(--touch-target);
    height: var(--touch-target);
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    z-index: 11;
}

.nav-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: var(--touch-target);
    height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    color: #222;
    z-index: 10;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
    transition: transform var(--duration-fast) var(--ease-out), background-color var(--duration-fast) var(--ease-out);
}

.nav-prev {
    inset-inline-end: 18px;
}

.nav-next {
    inset-inline-start: 18px;
}

@media (hover: hover) and (pointer: fine) {
    .nav-button:hover {
        background: #fff;
        transform: translateY(-50%) scale(1.06);
    }
}

.nav-button:active {
    transform: translateY(-50%) scale(0.95);
}

@media (max-width: 768px) {
    .nav-button {
        display: none;
    }
}

@keyframes galleryFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes galleryFadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ===========================================================
   عارض الستوري (فيديو طولي 9:16)
   =========================================================== */
.story-viewer {
    position: fixed;
    inset: 0;
    background: #0a0a0a;
    z-index: calc(var(--z-modal) + 20);
    align-items: center;
    justify-content: center;
}

.story-viewer.is-open {
    display: flex !important;
    animation: galleryFadeIn var(--duration-fast) var(--ease-out);
}

.story-viewer__video {
    width: auto;
    height: 100dvh;
    max-width: 100vw;
    aspect-ratio: 9 / 16;
    object-fit: contain;
    background: #000;
}

@media (min-aspect-ratio: 1/1) {
    .story-viewer__video {
        height: 92dvh;
        border-radius: 12px;
    }
}

/* أشرطة التقدّم */
.story-viewer__bars {
    position: absolute;
    top: max(10px, var(--safe-top));
    inset-inline: 12px;
    display: flex;
    gap: 4px;
    z-index: 12;
}

.story-bar {
    flex: 1;
    height: 3px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.3);
    overflow: hidden;
}

.story-bar__fill {
    display: block;
    height: 100%;
    width: 0;
    background: #fff;
    border-radius: 3px;
}

.story-viewer__head {
    position: absolute;
    top: calc(max(10px, var(--safe-top)) + 14px);
    inset-inline: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 12;
    pointer-events: none;
}

.story-viewer__title {
    color: #fff;
    font-size: var(--font-size-base);
    font-weight: 500;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.story-viewer__close {
    pointer-events: auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}

/* مناطق التنقّل (يمين = السابق، يسار = التالي في RTL) */
.story-nav {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 32%;
    border: none;
    background: transparent;
    cursor: pointer;
    z-index: 11;
    -webkit-tap-highlight-color: transparent;
}

.story-nav--prev {
    inset-inline-end: 0;
}

.story-nav--next {
    inset-inline-start: 0;
}
