/*
Theme Name: Debilder Theme
Theme URI: https://7ellm.com
Author: Your Name
Description: ثيم مستوحى من Debilder.net - شبكة صور متدرجة وتحميل لا نهائي
Version: 1.0
*/

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=DM+Sans:ital,wght@0,300;0,400;0,500;0,600;1,400&display=swap');

:root {
    --red: #e60023;
    --red-dark: #ad081b;
    --red-light: #fff0f1;
    --black: #111;
    --gray-900: #1a1a1a;
    --gray-700: #444;
    --gray-500: #767676;
    --gray-300: #e2e2e2;
    --gray-100: #f5f5f5;
    --white: #fff;
    --bg: #f0ebe3;
    --surface: #fff;
    --text: #1a1a1a;
    --text-muted: #767676;
    --border: #e2e2e2;
    --nav-h: 68px;
    --radius-pill: 9999px;
    --font-head: 'Nunito', sans-serif;
    --font-body: 'DM Sans', sans-serif;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
    --col-min: 236px;
    --grid-gap: 16px;
    --grid-padding: 20px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    padding-top: var(--nav-h);
    font-size: 15px;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; display: block; }

/* ========== HEADER ========== */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    box-shadow: 0 1px 0 var(--border);
    z-index: 1000;
    padding: 12px 24px 0;
}
.header-content {
    max-width: 1600px;
    margin: 0 auto;
}
.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 12px;
}
.logo a {
    font-family: var(--font-head);
    font-size: 26px;
    font-weight: 900;
    color: var(--red);
    white-space: nowrap;
}
.search-container {
    flex: 1;
    max-width: 500px;
    margin: 0 auto;
}
.search-form {
    display: flex;
    background: var(--gray-100);
    border-radius: var(--radius-pill);
    padding: 8px 16px;
    border: 2px solid transparent;
}
.search-form:focus-within {
    border-color: var(--black);
    background: var(--white);
}
.search-form input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 15px;
}
.search-form button {
    background: none;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
}
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    width: 30px;
    height: 24px;
    position: relative;
    cursor: pointer;
    z-index: 1002;
}
.mobile-menu-btn span {
    display: block;
    position: absolute;
    height: 3px;
    width: 100%;
    background: var(--text);
    border-radius: 3px;
    left: 0;
    transition: 0.25s ease;
}
.mobile-menu-btn span:nth-child(1) { top: 0; }
.mobile-menu-btn span:nth-child(2) { top: 10px; }
.mobile-menu-btn span:nth-child(3) { top: 20px; }
.header-bottom {
    border-top: 1px solid var(--border);
    width: 100%;
    overflow-x: auto;
}
.main-nav {
    display: flex;
    align-items: center;
}
.nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 0;
    margin: 0;
}
.nav-links li a {
    display: inline-block;
    padding: 6px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-pill);
    color: var(--gray-700);
    background: var(--gray-100);
    transition: 0.2s;
    white-space: nowrap;
}
.nav-links li a:hover,
.nav-links li a.active {
    background: var(--black);
    color: var(--white);
}

/* ========== FOOTER ========== */
.site-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 40px var(--grid-padding) 32px;
    margin-top: 60px;
    text-align: center;
}
.footer-links { display: flex; justify-content: center; gap: 20px; margin-bottom: 20px; }
.footer-links a { font-size: 13px; color: var(--gray-500); }
.footer-copy { font-size: 13px; color: var(--gray-500); }

/* ========== MASONRY GRID ========== */
#masonry-grid {
    columns: 5 var(--col-min);
    column-gap: var(--grid-gap);
    padding: var(--grid-padding);
    max-width: 1700px;
    margin: 0 auto;
}
.image-card {
    break-inside: avoid;
    display: inline-block;
    width: 100%;
    margin-bottom: var(--grid-gap);
    border-radius: 24px;
    overflow: hidden;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}
.image-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.15);
}
.image-card .img-container {
    aspect-ratio: 4/3;
    overflow: hidden;
    background: var(--gray-100);
}
.image-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.image-info {
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
}
#load-more-trigger { padding: 40px; text-align: center; }
.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== SINGLE IMAGE ========== */
.single-image-page { max-width: 1200px; margin: 0 auto; padding: 32px var(--grid-padding); }
.image-presentation {
    background: var(--surface);
    border-radius: 24px;
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 40px;
}
.image-wrapper { flex: 1; min-width: 250px; background: var(--gray-100); display: flex; align-items: center; justify-content: center; padding: 20px; }
.image-wrapper img { max-width: 100%; max-height: 70vh; object-fit: contain; }
.info-wrapper { flex: 1; padding: 30px; }
.info-wrapper h1 { font-size: 1.8rem; margin-bottom: 16px; }
.btn-download {
    background: var(--red);
    color: white;
    padding: 10px 20px;
    border-radius: 40px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.share-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 40px; color: white; }
.share-whatsapp { background: #25D366; }
.share-facebook { background: #1877F2; }
.share-telegram { background: #0088CC; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.tags a { background: var(--gray-100); padding: 5px 12px; border-radius: 40px; font-size: 13px; }
.breadcrumb { padding: 10px 0; font-size: 13px; color: var(--text-muted); }

/* ========== RESPONSIVE (تصحيح الموبايل بالكامل) ========== */
@media (max-width: 900px) {
    :root {
        --nav-h: 60px;
        --col-min: 160px;
        --grid-gap: 12px;
        --grid-padding: 12px;
    }
    /* اسم الموقع - حجم كبير ومقروء */
    .logo a {
        font-size: 24px !important;
        white-space: nowrap;
    }
    /* إخفاء البحث العادي */
    .search-container {
        display: none;
    }
    /* إظهار زر الهامبرجر */
    .mobile-menu-btn {
        display: block;
    }
    /* إخفاء القائمة الأفقية القديمة */
    .desktop-nav {
        display: none;
    }
    /* شبكة الصور */
    #masonry-grid {
        columns: 3 var(--col-min);
    }
}

/* ========== MOBILE FULLSCREEN MENU ========== */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    z-index: 2000;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0.3s, opacity 0.3s;
}
.mobile-menu-overlay.active {
    visibility: visible;
    opacity: 1;
}
.mobile-menu-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 60px 24px 30px;
    position: relative;
}
.close-menu-btn {
    position: absolute;
    top: 20px;
    right: 24px;
    background: none;
    border: none;
    color: white;
    font-size: 40px;
    cursor: pointer;
}
.mobile-search-box {
    margin-bottom: 40px;
}
.mobile-search-box form {
    display: flex;
    background: #333;
    border-radius: 40px;
    padding: 8px 16px;
}
.mobile-search-box input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-size: 16px;
    outline: none;
}
.mobile-search-box button {
    background: transparent;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
}
.mobile-nav-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.mobile-nav-links li a {
    color: white;
    font-size: 18px;
    font-weight: 600;
    text-decoration: none;
    padding: 10px 0;
    display: block;
    border-bottom: 1px solid #333;
}
.mobile-nav-links li a:hover {
    color: var(--red);
}

/* إظهار البحث على سطح المكتب فقط */
@media (min-width: 901px) {
    .search-container {
        display: block;
    }
}

/* باقي العناصر المساعدة */
#nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    display: none;
}
#nav-overlay.active { display: block; }
.page-header { text-align: center; padding: 40px 20px; background: var(--surface); margin-bottom: 20px; }
.page-header h1 { font-size: 2rem; }
.end-message { text-align: center; padding: 40px; color: var(--text-muted); }
/* إصلاحات الموبايل: تصغير الشعار وإضافة سكرول للقائمة (Mobile Fixes) */
@media (max-width: 900px) {
    .site-header .header-top {
        flex-wrap: nowrap;
    }
    .site-header .logo {
        max-width: 70%; /* منع الشعار من أخذ مساحة أكبر من الشاشة */
    }
    .site-header .logo a {
        display: block;
        white-space: normal;
        word-wrap: break-word;
        font-size: 1.4rem; /* تصغير الخط لتجنب خروج النص */
        line-height: 1.2;
    }
    
    /* إصلاح السكرول في قائمة الموبايل */
    .mobile-menu-container {
        overflow-y: auto !important;
        max-height: 100vh;
        padding-bottom: 100px; /* مساحة بالأسفل لرؤية باقي الأقسام */
        -webkit-overflow-scrolling: touch;
    }
}
/* ========================================================================
   SINGLE IMAGE PAGE & SHARE FIXES (إصلاحات الصفحة الفردية)
======================================================================== */
.single-image-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
}

.single-image-container {
    display: flex;
    flex-wrap: wrap;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    overflow: hidden;
    margin-bottom: 40px;
}

.image-col {
    flex: 1 1 60%;
    background: #f9f9f9;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.image-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
}

/* هنا حل الأبعاد المضروبة */
.image-wrapper img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain; /* هذه الخاصية تمنع تمطيط الصورة */
    border-radius: 12px;
}

.info-col {
    flex: 1 1 40%;
    padding: 40px;
    display: flex;
    flex-direction: column;
}

.image-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 20px;
    line-height: 1.3;
}

/* التاجات */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 30px;
}

.tag-chip {
    padding: 8px 16px;
    background: #f1f1f1;
    color: #333;
    border-radius: 20px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.3s;
}

.tag-chip:hover {
    background: #e2e2e2;
}

/* أزرار المشاركة والتحميل */
.share-actions {
    margin-bottom: 30px;
    border-top: 1px solid #eee;
    padding-top: 20px;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: #e60023;
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 15px;
    transition: background 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.btn-primary:hover {
    background: #cc001f;
}

.social-share-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.share-btn {
    text-align: center;
    padding: 10px;
    border-radius: 12px;
    color: white;
    text-decoration: none;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.share-whatsapp { background: #25D366; }
.share-facebook { background: #1877F2; }
.share-pinterest { background: #E60023; }

.share-btn i { font-size: 20px; }

.btn-download {
    display: inline-block;
    width: 100%;
    text-align: center;
    padding: 14px;
    background: #efefef;
    color: #333;
    border-radius: 30px;
    text-decoration: none;
    font-weight: bold;
    font-size: 16px;
    transition: background 0.3s;
}

.btn-download:hover {
    background: #e2e2e2;
}

.related-title {
    font-size: 1.5rem;
    margin-bottom: 20px;
    font-weight: bold;
}

/* استجابة الموبايل */
@media (max-width: 900px) {
    .image-col, .info-col {
        flex: 1 1 100%;
    }
    .info-col {
        padding: 20px;
    }
    .image-wrapper img {
        max-height: 50vh;
    }
    .social-share-grid {
        display: flex;
        flex-wrap: wrap;
    }
    .share-btn {
        flex: 1;
        flex-direction: row;
        justify-content: center;
    }
    .share-btn span {
        display: none;
    }
    .share-btn i {
        font-size: 18px;
    }
}
/* إخفاء صفحات SEO بصرياً مع السماح لعناكب البحث بقراءتها */
.seo-hidden-pagination {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}