/**
 * تجاوب واجهة الموقع — جميع الصفحات والأقسام
 */

html {
    -webkit-text-size-adjust: 100%;
}

/* منع تمرير الخلفية عند فتح قائمة الجوال */
body.site-nav-mobile-open {
    overflow: hidden;
    touch-action: none;
}

@media (min-width: 1024px) {
    body.site-nav-mobile-open {
        overflow: auto;
        touch-action: auto;
    }
}

/* قوائم النافبار على شاشات ضيقة جداً */
@media (max-width: 380px) {
    .site-nav-icon-btn {
        padding: 0.45rem;
    }

    .site-nav-account-label {
        display: none !important;
    }
}

/* القوائم المنسدلة لا تخرج عن الشاشة */
.site-nav-dropdown-wrap {
    position: relative;
}

@supports (position: fixed) {
    @media (max-width: 639px) {
        .site-nav-dropdown-account.site-nav-dropdown {
            position: fixed;
            inset-inline: 0.75rem auto;
            top: 3.85rem;
            width: auto;
            max-width: none;
        }

        [dir="rtl"] .site-nav-dropdown-account.site-nav-dropdown {
            inset-inline: auto 0.75rem;
        }
    }
}

.site-shell {
    overflow-x: clip;
}

.site-main {
    overflow-x: clip;
}

.site-main .container {
    width: 100%;
    max-width: var(--site-container-max);
    margin-inline: auto;
    padding-inline: var(--site-container-padding);
}

/* عمود المحتوى — منع انفجار العرض في flex */
.site-content-column {
    min-width: 0;
    width: 100%;
}

/* صور ووسائط */
.site-main img,
.site-main video,
.site-main embed,
.site-main object {
    max-width: 100%;
    height: auto;
}

.site-main iframe {
    max-width: 100%;
    width: 100%;
    border: 0;
}

.site-media-16x9 {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: var(--site-radius-lg);
}

.site-media-16x9 iframe,
.site-media-16x9 video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* نصوص طويلة وروابط */
.site-main,
.font-quran,
.site-quran-text {
    font-size: clamp(1rem, 3.5vw, 1.25rem);
    line-height: 2;
}

.site-main .prose,
.site-main .note-editable,
.site-main [class*="break-"] {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.site-main pre,
.site-main code {
    overflow-x: auto;
    max-width: 100%;
}

/* جداول قابلة للتمرير أفقياً */
.site-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.site-table-wrap table {
    min-width: 100%;
}

/* رأس صفحة مرن */
.site-page-header .flex,
.site-page-header-flex {
    flex-wrap: wrap;
    gap: 0.75rem;
}

.site-page-toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
}

@media (min-width: 640px) {
    .site-page-toolbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.site-page-toolbar .site-btn-primary,
.site-page-toolbar button,
.site-page-toolbar > a {
    width: 100%;
    justify-content: center;
}

@media (min-width: 640px) {
    .site-page-toolbar .site-btn-primary,
    .site-page-toolbar button,
    .site-page-toolbar > a {
        width: auto;
    }
}

/* بطاقات — حشو أصغر على الجوال */
@media (max-width: 639px) {
    .site-page-header,
    .site-filter-bar,
    .site-content-panel,
    .site-auth-card,
    .site-link-card,
    .site-grid-card,
    .site-card {
        padding: 1rem;
        border-radius: 0.75rem;
    }

    .site-page-header h1,
    .site-page-header .page-title {
        font-size: clamp(1.125rem, 4.5vw, 1.5rem);
    }

    .site-auth-card {
        padding: 1.25rem;
    }

    .site-main {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
}

/* الشريط الجانبي — ارتفاع محدود على الجوال */
@media (max-width: 1023px) {
    .site-sidebar-panel {
        position: static;
    }

    .site-sidebar-panel .sidebar-scroll {
        max-height: min(16rem, 40vh);
    }
}

@media (min-width: 1024px) {
    .site-sidebar-panel.sticky-sidebar {
        position: sticky;
        top: 5rem;
    }

    .site-sidebar-panel .sidebar-scroll {
        max-height: calc(100vh - 6rem);
    }
}

/* نوافذ منبثقة */
.site-modal-overlay {
    padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right))
        max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
}

.site-modal-card {
    width: 100%;
    max-width: min(42rem, calc(100vw - 1.5rem));
    max-height: min(calc(100vh - 2rem), calc(100dvh - 2rem));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin-left: auto;
    margin-right: auto;
}

/* محتوى بعرض مقيد — يتمدد على الجوال */
.site-feed-column {
    width: 100%;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* مشغّل الصوت */
.site-audio-bar .audio-player-inner {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    max-width: var(--site-container-max);
    margin: 0 auto;
    padding-inline: var(--site-container-padding);
}

@media (min-width: 640px) {
    .site-audio-bar .audio-player-inner {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.site-audio-bar .audio-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

/* غلاف الملف الشخصي */
.site-profile-cover {
    height: clamp(10rem, 32vw, 16rem);
}

.site-profile-header {
    flex-wrap: wrap;
    gap: 0.75rem;
}

.site-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

@media (min-width: 640px) {
    .site-stats-grid {
        gap: 1rem;
    }
}

/* تبويبات أفقية */
.site-tabs-scroll {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.site-tabs-scroll::-webkit-scrollbar {
    display: none;
}

.site-tabs-scroll > button,
.site-tabs-scroll > a {
    flex-shrink: 0;
    white-space: nowrap;
}

/* أزرار إجراءات البطاقات (منتدى/منشورات) */
.site-action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.site-action-row > * {
    flex: 1 1 auto;
    min-width: min(100%, 5.5rem);
}

/* حقول مشاركة / نسخ */
.site-share-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

@media (min-width: 480px) {
    .site-share-row {
        flex-direction: row;
        align-items: center;
    }
}

/* Summernote */
.note-editor {
    max-width: 100%;
}

.note-editing-area,
.note-editable {
    max-width: 100%;
}

/* مساحة أسفل الصفحة عند وجود مشغّل ثابت */
body.has-audio-player .site-main {
    padding-bottom: 5.5rem;
}

@media (min-width: 640px) {
    body.has-audio-player .site-main {
        padding-bottom: 4.5rem;
    }
}
