/* ============================================
   Gallery luxury: Carousel (central frame + sides) + lightbox
   ============================================ */

/* ---------- عنوان الجاليري قريب من الصور (كل الشاشات) ---------- */
.gallery-title {
    margin-bottom: 20px !important;
}

.gallery-carousel-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 0 50px;
    position: relative;
}

/* ---------- Carousel: central framed image + layered sides ---------- */

.gallery-carousel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: 100%;
    min-height: 520px;
    position: relative;
}

.gallery-carousel-center {
    flex-shrink: 0;
    position: relative;
    z-index: 3;
    cursor: pointer;
}

/* White frame (polaroid-style) around central image */
.gallery-carousel-frame {
    background: #fff;
    padding: 16px;
    padding-bottom: 44px;
    border-radius: 6px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12),
                0 2px 12px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.35s ease, transform 0.35s ease;
}

.gallery-carousel-frame:hover {
    box-shadow: 0 14px 44px rgba(0, 0, 0, 0.15),
                0 4px 20px rgba(178, 42, 31, 0.15);
    transform: translateY(-2px);
}

.gallery-carousel-center-media {
    display: block;
    width: 100%;
    max-width: 780px;
    height: auto;
    max-height: 500px;
    object-fit: cover;
    border-radius: 4px;
}

.gallery-carousel-center .gallery-carousel-frame video.gallery-carousel-center-media {
    max-height: 480px;
}

/* Side strips: layered, fanned */
.gallery-carousel-side {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    pointer-events: none;
}

.gallery-carousel-side .gallery-carousel-side-frame {
    pointer-events: auto;
    cursor: pointer;
}

.gallery-carousel-left {
    left: 0;
    justify-content: flex-end;
    padding-right: 10px;
}

.gallery-carousel-right {
    right: 0;
    justify-content: flex-start;
    padding-left: 10px;
}

.gallery-carousel-side-frame {
    background: #fff;
    padding: 8px;
    padding-bottom: 24px;
    border-radius: 4px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-carousel-side-frame:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 32px rgba(178, 42, 31, 0.2);
}

.gallery-carousel-side-frame-left {
    transform: translateX(15%) scale(0.72);
}

.gallery-carousel-side-frame-left:hover {
    transform: translateX(10%) scale(0.78);
}

.gallery-carousel-side-frame-right {
    transform: translateX(-15%) scale(0.72);
}

.gallery-carousel-side-frame-right:hover {
    transform: translateX(-10%) scale(0.78);
}

.gallery-carousel-side-media {
    display: block;
    width: 160px;
    height: 114px;
    object-fit: cover;
    border-radius: 4px;
}

/* Arrows */
.gallery-carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--color-accent-red, #B22A1F);
    background: rgba(255, 255, 255, 0.95);
    color: var(--color-accent-red, #B22A1F);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5;
    transition: background 0.25s ease, color 0.25s ease, transform 0.25s ease;
}

.gallery-carousel-btn:hover {
    background: var(--color-accent-red, #B22A1F);
    color: #fff;
    transform: translateY(-50%) scale(1.08);
}

.gallery-carousel-btn svg {
    width: 24px;
    height: 24px;
}

.gallery-carousel-prev {
    left: 0;
}

.gallery-carousel-next {
    right: 0;
}

/* Caption below center */
.gallery-carousel-caption {
    margin-top: 16px;
    font-size: 15px;
    color: var(--color-dark-gray, #2F2F2F);
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* ========== تابلت (شاشات متوسطة) ========== */
@media (max-width: 1024px) {
    .gallery-carousel {
        min-height: 420px;
    }
    .gallery-carousel-center-media {
        max-width: 85vw;
        max-height: 420px;
    }
    .gallery-carousel-side-media {
        width: 140px;
        height: 100px;
    }
}

@media (max-width: 900px) {
    .gallery-title {
        margin-bottom: 16px !important;
        font-size: clamp(1.25rem, 4vw, 1.75rem) !important;
    }
    .gallery-carousel-wrapper {
        padding: 0 0 40px;
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    .gallery-carousel {
        min-height: 380px;
    }
    .gallery-carousel-side-frame {
        display: none;
    }
    .gallery-carousel-center {
        max-width: 80%;
    }
    .gallery-carousel-center-media {
        max-width: 100%;
        width: 100%;
        aspect-ratio: 4 / 3;
        object-fit: cover;
        height: auto;
    }
    .gallery-carousel-frame {
        padding: 12px;
        padding-bottom: 36px;
    }
    .gallery-carousel-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }
    .gallery-carousel-prev {
        left: 8px;
    }
    .gallery-carousel-next {
        right: 8px;
    }
}

/* ========== جوال كبير / تابلت صغير ========== */
@media (max-width: 768px) {
    .projects-gallery-section {
        padding: 40px 0 60px !important;
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    .projects-gallery-section .container {
        padding-left: 16px;
        padding-right: 16px;
    }
    .back-to-categories-btn {
        margin-bottom: 24px !important;
        padding: 12px 20px !important;
        min-height: 44px;
    }
    .gallery-title {
        margin-bottom: 14px !important;
        font-size: clamp(1.15rem, 5vw, 1.5rem) !important;
    }
    .gallery-carousel-wrapper {
        padding: 0 0 36px;
    }
    .gallery-carousel {
        min-height: 320px;
    }
    .gallery-carousel-center {
        max-width: 80%;
    }
    .gallery-carousel-center-media {
        width: 100%;
        aspect-ratio: 4 / 3;
        object-fit: cover;
        height: auto;
    }
    .gallery-carousel-frame {
        padding: 10px;
        padding-bottom: 30px;
    }
    .gallery-carousel-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }
    .gallery-carousel-prev {
        left: 4px;
    }
    .gallery-carousel-next {
        right: 4px;
    }
    .gallery-carousel-caption {
        font-size: 14px;
        margin-top: 14px;
    }
}

/* ========== جوال ========== */
@media (max-width: 600px) {
    .gallery-title {
        margin-bottom: 12px !important;
    }
    .gallery-carousel-wrapper {
        padding: 0 0 32px;
    }
    .gallery-carousel-center {
        max-width: 80%;
    }
    .gallery-carousel-frame {
        padding: 8px;
        padding-bottom: 24px;
    }
    .gallery-carousel-center-media {
        max-width: 100%;
        width: 100%;
        aspect-ratio: 4 / 3;
        object-fit: cover;
        height: auto;
    }
    .gallery-carousel-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }
    .gallery-carousel-prev {
        left: 4px;
    }
    .gallery-carousel-next {
        right: 4px;
    }
    .gallery-carousel-caption {
        font-size: 13px;
        margin-top: 12px;
    }
}

/* ========== جوال صغير ========== */
@media (max-width: 480px) {
    .projects-gallery-section {
        padding: 24px 0 48px !important;
    }
    .projects-gallery-section .container {
        padding-left: 12px;
        padding-right: 12px;
    }
    .back-to-categories-btn {
        margin-bottom: 20px !important;
        padding: 10px 18px !important;
        font-size: 14px !important;
    }
    .gallery-title {
        margin-bottom: 10px !important;
        font-size: 1.15rem !important;
    }
    .gallery-carousel-wrapper {
        padding: 0 0 28px;
    }
    .gallery-carousel {
        min-height: 260px;
    }
    .gallery-carousel-center {
        max-width: 80%;
    }
    .gallery-carousel-frame {
        padding: 6px;
        padding-bottom: 20px;
    }
    .gallery-carousel-center-media {
        width: 100%;
        aspect-ratio: 4 / 3;
        object-fit: cover;
        height: auto;
    }
    .gallery-carousel-btn {
        width: 44px;
        height: 44px;
    }
    .gallery-carousel-caption {
        font-size: 12px;
        margin-top: 10px;
    }
}

/* ========== شاشات صغيرة جداً ========== */
@media (max-width: 380px) {
    .projects-gallery-section .container {
        padding-left: 10px;
        padding-right: 10px;
    }
    .gallery-carousel-center {
        max-width: 80%;
    }
    .gallery-carousel-center-media {
        width: 100%;
        aspect-ratio: 4 / 3;
        object-fit: cover;
        height: auto;
    }
    .gallery-carousel-frame {
        padding: 5px;
        padding-bottom: 18px;
    }
}

/* ---------- Legacy grid (kept for any fallback) ---------- */
.gallery-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    column-gap: unset;
    columns: unset;
    column-fill: unset;
}

@media (min-width: 1400px) {
    .gallery-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 28px;
    }
}

@media (min-width: 1024px) and (max-width: 1399px) {
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 22px;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 18px;
    }
}

@media (max-width: 767px) {
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

.gallery-item {
    display: block !important;
    width: 100% !important;
    aspect-ratio: 4 / 3;
    margin-bottom: 0 !important;
    break-inside: unset;
    page-break-inside: unset;
    -webkit-column-break-inside: unset;
}

.gallery-item img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-item video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    z-index: 1;
}

/* Uniform grid: refined hover (subtle lift + accent overlay) */
.gallery-item {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                box-shadow 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.gallery-item:hover {
    transform: translateY(-6px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12),
                0 4px 20px rgba(178, 42, 31, 0.12);
}

.gallery-item img {
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                filter 0.4s ease;
}

.gallery-item:hover img {
    transform: scale(1.04);
    filter: brightness(1.02) contrast(1.01);
}

/* Overlay: accent tint on hover (no heavy gradient) */
.gallery-item-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(178, 42, 31, 0.25) 0%,
        transparent 50%
    );
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 2;
    pointer-events: none;
}

.gallery-item:hover .gallery-item-overlay {
    opacity: 1;
}

.gallery-item-zoom-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: var(--color-accent-red, #B22A1F);
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.gallery-item:hover .gallery-item-zoom-icon {
    transform: scale(1);
}

.gallery-item-zoom-icon svg {
    width: 22px;
    height: 22px;
}

/* Lightbox: صورة على كامل الشاشة تقريباً + زر إغلاق واضح */
.lightbox-modal {
    background: rgba(0, 0, 0, 0.97);
    padding: 16px;
    transition: opacity 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.lightbox-content {
    max-width: 96vw;
    max-height: 96vh;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.lightbox-content img {
    max-width: 96vw;
    max-height: 96vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0.45s ease;
}

/* زر الإغلاق فوق الصورة دائماً */
.lightbox-close {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10002;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

.lightbox-close:hover {
    background: var(--color-accent-red, #B22A1F);
    border-color: var(--color-accent-red, #B22A1F);
    transform: scale(1.08);
}

.lightbox-close svg {
    width: 26px;
    height: 26px;
}

/* أزرار السابق/التالي */
.lightbox-prev,
.lightbox-next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10002;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: background 0.3s ease,
                border-color 0.3s ease,
                transform 0.3s ease;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: var(--color-accent-red, #B22A1F);
    transform: translateY(-50%) scale(1.08);
}

.lightbox-counter {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10002;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 15px;
    transition: opacity 0.3s ease;
}

@media (max-width: 768px) {
    .lightbox-modal {
        padding: 12px;
        padding-top: max(12px, env(safe-area-inset-top));
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
    .lightbox-content,
    .lightbox-content img {
        max-width: 98vw;
        max-height: 92vh;
    }
    .lightbox-close {
        top: max(12px, env(safe-area-inset-top));
        right: max(12px, env(safe-area-inset-right));
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
    }
    .lightbox-close svg {
        width: 22px;
        height: 22px;
    }
    .lightbox-counter {
        bottom: max(24px, env(safe-area-inset-bottom));
    }
}

@media (max-width: 480px) {
    .lightbox-close {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }
}

/* Touch: keep hover effects subtle on mobile */
@media (max-width: 768px) {
    .gallery-item:hover {
        transform: translateY(-4px);
        box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
    }
    .gallery-item:hover img {
        transform: scale(1.03);
    }
    .gallery-item-overlay {
        opacity: 0.6;
    }
    .gallery-item .gallery-item-overlay {
        opacity: 0.5;
    }
    .gallery-item:active .gallery-item-overlay {
        opacity: 1;
    }
}

/* ============================================
   بطاقات التصنيفات (Projects Grid) - متوافقة مع كل الشاشات
   ============================================ */

.projects-categories-section .container {
    padding-left: 20px;
    padding-right: 20px;
}

@media (max-width: 1024px) {
    .projects-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 24px !important;
        margin-top: 40px !important;
    }
    .project-category-card {
        aspect-ratio: 4/3 !important;
        border-radius: 16px !important;
    }
    .project-category-content {
        padding: 28px 20px !important;
    }
    .project-category-title {
        font-size: 22px !important;
        margin-bottom: 8px !important;
    }
    .project-category-subtitle {
        font-size: 13px !important;
    }
    .project-category-arrow {
        font-size: 14px !important;
    }
}

@media (max-width: 768px) {
    .projects-categories-section .container {
        padding-left: 16px;
        padding-right: 16px;
    }
    .projects-categories-section .section-title {
        font-size: 28px !important;
    }
    .projects-categories-section .section-subtitle {
        font-size: 15px !important;
    }
    .projects-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px !important;
        margin-top: 32px !important;
    }
    .project-category-card {
        aspect-ratio: 4/3 !important;
        border-radius: 12px !important;
    }
    .project-category-content {
        padding: 20px 16px !important;
    }
    .project-category-title {
        font-size: 18px !important;
        margin-bottom: 6px !important;
    }
    .project-category-subtitle {
        font-size: 12px !important;
        margin-bottom: 10px !important;
    }
    .project-category-arrow {
        font-size: 13px !important;
    }
}

@media (max-width: 480px) {
    .projects-categories-section .container {
        padding-left: 12px;
        padding-right: 12px;
    }
    .projects-categories-section .section-title {
        font-size: 22px !important;
        margin-bottom: 8px !important;
    }
    .projects-categories-section .section-subtitle {
        font-size: 14px !important;
    }
    .projects-grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
        margin-top: 24px !important;
    }
    .project-category-card {
        aspect-ratio: 16/10 !important;
        border-radius: 10px !important;
        min-height: 180px;
    }
    .project-category-content {
        padding: 16px 14px !important;
    }
    .project-category-title {
        font-size: 16px !important;
        margin-bottom: 4px !important;
    }
    .project-category-subtitle {
        font-size: 11px !important;
        margin-bottom: 8px !important;
    }
    .project-category-arrow {
        font-size: 12px !important;
    }
}

@media (max-width: 380px) {
    .projects-categories-section .container {
        padding-left: 10px;
        padding-right: 10px;
    }
    .projects-grid {
        gap: 12px !important;
    }
    .project-category-card {
        min-height: 160px;
    }
    .project-category-title {
        font-size: 15px !important;
    }
}
