@import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&family=Cairo:wght@300;400;600;700&display=swap');

/* Theme: sky blue anchored on #87CEEB / rgba(135, 206, 235, 0.6) (#87CEEB99) */
:root {
    --color-primary: #87CEEB;
    --color-primary-alpha: rgba(135, 206, 235, 0.6);
    --color-primary-soft: rgba(135, 206, 235, 0.18);
    --color-primary-dark: #6BB8D4;
    --color-primary-darker: #4a9bb8;
    --color-primary-deep: #3d7a94;
    --color-body-start: #3d6b7a;
    --color-body-end: #2a4a58;
    --color-header-solid: linear-gradient(135deg, #87CEEB 0%, #6BB8D4 50%, #4a9bb8 100%);
    --color-text-on-cream: #2a5f6f;
    --color-text-muted: #3d7a8a;
    --color-accent-gold: #d4a574;
    --color-shadow-primary: rgba(135, 206, 235, 0.45);
    --radius-lg: 20px;
    --radius-md: 15px;
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

body {
    font-family: 'Cairo', sans-serif;
    line-height: 1.6;
    background: linear-gradient(135deg, var(--color-body-start) 0%, var(--color-body-end) 100%);
    background-attachment: fixed;
    color: #333;
    min-height: 100vh;
}

img, video, iframe {
    max-width: 100%;
    height: auto;
}

/* Site top: bar + nav share one band. Nav/backdrop are NOT inside .container so
   position:fixed + z-index are not trapped by .container { z-index: 1 } (root cause
   of mobile drawer painting behind main / not receiving taps on some engines). */
.site-top {
    position: relative;
    z-index: 100000;
    background: var(--color-header-solid);
    box-shadow: 0 4px 24px rgba(61, 122, 148, 0.35);
    color: #fff;
    transition: box-shadow var(--transition-smooth);
}

/* Header */
.header {
    background: transparent;
    color: #fff;
    padding: 0;
    box-shadow: none;
    position: relative;
    z-index: auto;
    transition: box-shadow var(--transition-smooth);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    position: relative;
    z-index: 1;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: relative;
}

.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 1rem;
    padding: 1rem 0;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0;
    flex: 1;
    min-width: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
    text-decoration: none;
}

.logo:hover {
    text-decoration: none;
}

.logo:visited {
    text-decoration: none;
}

.logo-icon {
    width: 50px;
    height: 50px;
    background: var(--color-accent-gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform var(--transition-fast);
}

.logo:hover .logo-icon {
    transform: scale(1.05);
}

.logo h1,
.logo .logo-text {
    font-family: 'Amiri', serif;
    font-size: clamp(1.35rem, 4vw, 2.5rem);
    font-weight: 700;
    color: var(--color-accent-gold);
    margin: 0;
    line-height: 1.2;
    text-align: right;
        text-decoration: none;
        border-bottom: none;
        box-shadow: none;
}

/* Mobile menu toggle */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 48px;
    height: 48px;
    padding: 0;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition-fast), transform var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.nav-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

.nav-toggle:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.nav-toggle-bar {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 1px;
    transition: transform 0.35s ease, opacity 0.25s ease;
}

body.nav-open .nav-toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

body.nav-open .nav-toggle-bar:nth-child(2) {
    opacity: 0;
}

body.nav-open .nav-toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.38s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    -webkit-tap-highlight-color: transparent;
}

.nav-backdrop.nav-backdrop--visible {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

.nav-menu {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    justify-content: flex-start;
    padding: 1rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform var(--transition-smooth);
}

.nav-menu a {
    color: #fff;
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 0.8rem;
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    border-radius: 8px;
    min-height: 44px;
}

.nav-menu a i {
    color: #fff;
    font-size: 1rem;
    transition: opacity var(--transition-fast);
}

.nav-menu a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.nav-menu a:hover i {
    color: #fff;
}

.nav-menu a.active {
    background: rgba(255, 255, 255, 0.18);
    font-weight: 600;
}

/* المؤلفات: قائمة فرعية */
.nav-menu .nav-item-dropdown {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* Desktop: invisible strip under the label so the pointer can reach submenu without losing hover */
@media (min-width: 1025px) {
    .nav-menu .nav-item-dropdown::after {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        top: 100%;
        height: 12px;
        display: none;
        z-index: 100009;
    }

    .nav-menu .nav-item-dropdown:hover::after {
        display: block;
    }
}

.nav-menu .nav-dropdown-panel {
    display: none;
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    min-width: 220px;
    background: linear-gradient(180deg, #87CEEB 0%, #6BB8D4 100%);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 100010;
    padding: 0.35rem 0;
    margin-top: 0;
    flex-direction: column;
    align-items: stretch;
}

.nav-menu .nav-dropdown-panel a {
    width: 100%;
    justify-content: flex-start;
    border-radius: 6px;
}

@media (min-width: 1025px) {
    .nav-menu .nav-item-dropdown:hover .nav-dropdown-panel {
        display: flex;
    }
}

@media (max-width: 1024px) {
    .nav-menu .nav-item-dropdown {
        width: 100%;
    }

    .nav-menu .nav-dropdown-panel {
        position: static;
        top: auto;
        display: flex;
        width: 100%;
        margin-top: 0.35rem;
        margin-right: 0.75rem;
        padding: 0.25rem 0;
        box-shadow: none;
        background: rgba(0, 0, 0, 0.08);
        border-radius: 8px;
    }
}

.admin-btn {
    background: var(--color-accent-gold);
    color: #fff;
    border: none;
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-family: 'Cairo', sans-serif;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    border-radius: 8px;
    min-height: 44px;
}

.admin-btn i {
    color: #fff;
}

.admin-btn:hover {
    background: #c49564;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.admin-btn:hover i {
    color: #fff;
}

/* Main Content */
.main-content {
    background: white;
    margin: 2rem auto;
    max-width: 1200px;
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    position: relative;
}

.hero-section {
    background: linear-gradient(135deg, #f8f4e6 0%, #e8dcc0 100%);
    padding: 3rem 2rem;
    text-align: center;
    position: relative;
    overflow: visible;
}

/* Islamic geometric ornament — left, behind content; multiply removes light flat BG from asset */
.hero-ornament {
    position: absolute;
    z-index: 0;
    pointer-events: none;
    left: clamp(-4.5rem, -10vw, -1.5rem);
    top: clamp(-2.5rem, -6vw, -0.75rem);
    width: clamp(150px, 28vw, 250px);
    height: clamp(150px, 28vw, 250px);
    background-image: url('/images/hero-islamic-ornament.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.22;
    mix-blend-mode: multiply;
    -webkit-mask-image: radial-gradient(
        ellipse 72% 72% at 48% 46%,
        #000 0%,
        #000 38%,
        rgba(0, 0, 0, 0.45) 62%,
        transparent 78%
    );
    mask-image: radial-gradient(
        ellipse 72% 72% at 48% 46%,
        #000 0%,
        #000 38%,
        rgba(0, 0, 0, 0.45) 62%,
        transparent 78%
    );
    -webkit-mask-size: 100% 100%;
    mask-size: 100% 100%;
    transform: rotate(-6deg);
}

.hero-inner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 1.75rem;
    position: relative;
    z-index: 1;
}

.hero-top-row {
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 2.5rem;
}

.hero-text {
    flex: 1 1 auto;
    text-align: center;
}

.hero-text .hero-verse {
    max-width: min(100%, 32rem);
    margin-top: 1.1rem;
    margin-inline: auto;
}

.hero-section::before {
    content: '☪';
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 3rem;
    color: rgba(135, 206, 235, 0.12);
    animation: rotate 10s linear infinite;
    z-index: 1;
}

.hero-section::after {
    content: '☪';
    position: absolute;
    bottom: 20px;
    right: 20px;
    font-size: 2rem;
    color: rgba(135, 206, 235, 0.12);
    animation: rotate 15s linear infinite reverse;
    z-index: 1;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.hero-title {
    font-family: 'Amiri', serif;
    font-size: clamp(1.75rem, 5vw, 3rem);
    color: var(--color-text-on-cream);
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.06);
    position: relative;
    z-index: 1;
}

.hero-subtitle {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
    font-weight: 400;
    position: relative;
    z-index: 1;
}

.bismillah {
    font-family: 'Amiri', serif;
    font-size: clamp(1.35rem, 3vw, 1.8rem);
    color: #c9984a;
    margin-bottom: 1.5rem;
    padding: 0.85rem 1.25rem;
    background: rgba(255, 255, 255, 0.55);
    border-radius: 15px;
    border: 2px solid var(--color-accent-gold);
    display: inline-block;
    position: relative;
    z-index: 1;
}

.hero-image-wrapper {
    display: flex;
    justify-content: center;
    flex: 0 0 auto;
    position: relative;
    width: min(31vw, 250px);
    max-width: 100%;
    overflow: hidden;
    border-radius: 22px;
    background: #f4f4f4;
    box-shadow: 0 14px 34px rgba(248, 244, 230, 0.98);
    transform: none;
}

.hero-image-wrapper::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 0%;
    pointer-events: none;
    background: linear-gradient(
        to top,
        #f8f4e6 0%,
        rgba(248, 244, 230, 0.98) 28%,
        rgba(248, 244, 230, 0.82) 52%,
        rgba(248, 244, 230, 0) 100%
    );
    
}

.hero-image {
    width: 115%;
    height: 100%;
    max-height: 500px;
    object-fit: cover;
    object-position: center top; 
    display: block;   
}

@media (max-width: 768px) {
    .hero-top-row {
        flex-direction: column-reverse;
        align-items: center;
        gap: 1rem;
    }

    .hero-inner {
        align-items: center;
    }
    .hero-text {
        text-align: center;
    }
    .hero-image-wrapper {
        width: min(68vw, 260px);
        border-radius: 15px;
        transform: none;
    }
}

/* Hero Quranic verse (replaces CTA buttons) */
.hero-verse {
    margin-top: 1.75rem;
    margin-inline: auto;
    max-width: min(100%, 38rem);
    padding: clamp(1rem, 3vw, 1.35rem) clamp(1rem, 4vw, 1.5rem);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.78) 0%, rgba(248, 244, 230, 0.95) 55%, rgba(232, 220, 192, 0.55) 100%);
    border: 2px solid var(--color-accent-gold);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(42, 95, 111, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.65);
    position: relative;
    z-index: 1;
    text-align: center;
}

.hero-verse--full {
    width: 100%;
    max-width: none;
    margin-top: 0;
}

.hero-verse::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    box-shadow: inset 0 0 0 1px rgba(135, 206, 235, 0.25);
}

.hero-verse-text {
    font-family: 'Amiri', serif;
    font-size: clamp(0.95rem, 3.8vw, 1.32rem);
    color: var(--color-text-on-cream);
    line-height: 2;
    margin: 0 0 0.85rem;
    font-style: italic;
    overflow-wrap: anywhere;
    word-break: break-word;
    text-align: center;
}

.hero-verse-ref {
    font-family: 'Cairo', sans-serif;
    font-size: clamp(0.8rem, 2.6vw, 0.98rem);
    color: #b8894a;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.02em;
    text-align: center;
}

/* Content Sections */
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: 2rem;
    padding: 2.5rem 1.5rem;
}

.section-title {
    grid-column: 1 / -1;
    text-align: center;
    font-family: 'Amiri', serif;
    color: var(--color-text-on-cream);
    margin-bottom: 1.75rem;
    font-size: clamp(1.35rem, 3vw, 1.85rem);
    font-weight: 700;
}

/* Sections restent visibles sans dépendre du JS (évite page vide si observer / script en échec) */
.section-reveal {
    opacity: 1;
    transform: translateY(0);
}

/* Animation légère seulement quand le JS a ajouté la classe (optionnel) */
.section-reveal.section-reveal--visible {
    animation: sectionRevealIn 0.55s ease forwards;
}

@keyframes sectionRevealIn {
    from {
        opacity: 0.92;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .section-reveal.section-reveal--visible {
        animation: none;
    }
}

.content-card {
    background: white;
    padding: 1.75rem;
    border-radius: var(--radius-md);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
    border-top: 4px solid var(--color-primary);
    transition: transform 0.35s ease, box-shadow 0.35s ease;
    position: relative;
    overflow: hidden;
}

.content-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent-gold), var(--color-primary));
    background-size: 200% 100%;
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { background-position: -200% 0; }
    50% { background-position: 200% 0; }
}

.content-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.12);
}

.card-icon {
    font-size: 2.5rem;
    color: var(--color-accent-gold);
    margin-bottom: 1rem;
    display: block;
    transition: color var(--transition-fast);
}

.card-title {
    font-family: 'Amiri', serif;
    font-size: 1.5rem;
    color: var(--color-text-on-cream);
    margin-bottom: 1rem;
    font-weight: 700;
}

.card-text {
    color: #555;
    line-height: 1.8;
    margin-bottom: 1.5rem;
}

.card-meta {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.read-more-btn {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 44px;
    line-height: 1.4;
}

.read-more-btn:hover {
    background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary-darker));
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--color-shadow-primary);
}

/* Homepage books preview — compact cards (قسم المؤلفات فقط) */
#homeBooksGrid.content-grid {
    gap: 0.65rem;
    padding: 1rem 0.65rem;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 168px), 1fr));
}

#homeBooksGrid .content-card {
    padding: 0.52rem 0.62rem;
    border-radius: 10px;
    border-top-width: 2px;
}

#homeBooksGrid .content-card:hover {
    transform: translateY(-3px);
}

#homeBooksGrid .card-icon {
    font-size: 1.15rem;
    margin-bottom: 0.18rem;
    line-height: 1;
}

#homeBooksGrid .card-title {
    font-size: 0.9rem;
    line-height: 1.24;
    margin-bottom: 0.2rem;
}

#homeBooksGrid .card-text {
    font-size: 0.74rem;
    line-height: 1.34;
    margin-bottom: 0.28rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

#homeBooksGrid .card-meta {
    font-size: 0.68rem;
    line-height: 1.32;
    margin-bottom: 0.32rem;
}

#homeBooksGrid .card-meta:empty {
    display: none;
}

#homeBooksGrid .read-more-btn {
    padding: 0.32rem 0.58rem;
    min-height: 30px;
    font-size: 0.71rem;
    border-radius: 999px;
    margin-top: 0.05rem;
    gap: 0.3rem;
}

/* Homepage + listing: research & videos — same compact grid/cards as books */
#researchGrid.content-grid,
#videosGrid.content-grid,
#researchGridPage.content-grid,
#videosGridPage.content-grid {
    gap: 0.65rem;
    padding: 1rem 0.65rem;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 168px), 1fr));
}

#researchGridPage.content-grid,
#videosGridPage.content-grid {
    padding: 0;
}

#researchGrid .content-card,
#videosGrid .content-card,
#researchGridPage .content-card,
#videosGridPage .content-card {
    padding: 0.52rem 0.62rem;
    border-radius: 10px;
    border-top-width: 2px;
}

#researchGrid .content-card:hover,
#videosGrid .content-card:hover,
#researchGridPage .content-card:hover,
#videosGridPage .content-card:hover {
    transform: translateY(-3px);
}

#researchGrid .card-icon,
#researchGridPage .card-icon {
    font-size: 1.15rem;
    margin-bottom: 0.18rem;
    line-height: 1;
}

#researchGrid .card-title,
#researchGridPage .card-title {
    font-size: 0.9rem;
    line-height: 1.24;
    margin-bottom: 0.2rem;
}

#researchGrid .card-text,
#researchGridPage .card-text {
    font-size: 0.74rem;
    line-height: 1.34;
    margin-bottom: 0.28rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

#researchGrid .card-meta,
#researchGridPage .card-meta {
    font-size: 0.68rem;
    line-height: 1.32;
    margin-bottom: 0.32rem;
}

#researchGrid .card-meta:empty,
#researchGridPage .card-meta:empty {
    display: none;
}

#researchGrid .read-more-btn,
#researchGridPage .read-more-btn {
    padding: 0.32rem 0.58rem;
    min-height: 30px;
    font-size: 0.71rem;
    border-radius: 999px;
    margin-top: 0.05rem;
    gap: 0.3rem;
}

/* Video cards: thumbnail band + compact body (homepage + listing) */
#videosGrid .content-card.content-card--video,
#videosGridPage .content-card.content-card--video {
    padding: 0;
    display: flex;
    flex-direction: column;
}

.content-card--video .card-thumb,
.content-card--video img.card-thumb {
    width: 100%;
    height: 108px;
    object-fit: cover;
    display: block;
}

.content-card--video .card-thumb-placeholder {
    height: 108px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.95);
    font-size: 1.85rem;
}

.content-card--video .card-body {
    padding: 0.52rem 0.62rem 0.62rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 0.35rem;
}

#videosGrid .content-card--video .card-title,
#videosGridPage .content-card--video .card-title {
    font-size: 0.9rem;
    line-height: 1.24;
    margin: 0;
}

#videosGrid .content-card--video .read-more-btn,
#videosGridPage .content-card--video .read-more-btn {
    padding: 0.32rem 0.58rem;
    min-height: 30px;
    font-size: 0.71rem;
    border-radius: 999px;
    margin-top: auto;
    gap: 0.3rem;
    align-self: stretch;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 900px) {
    #researchGrid.content-grid,
    #videosGrid.content-grid,
    #researchGridPage.content-grid,
    #videosGridPage.content-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
    }
}

@media (max-width: 560px) {
    #homeBooksGrid.content-grid,
    #researchGrid.content-grid,
    #videosGrid.content-grid,
    #researchGridPage.content-grid,
    #videosGridPage.content-grid {
        grid-template-columns: 1fr;
    }
}

/* Islamic decorative elements */
.decorative-border {
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--color-accent-gold), transparent);
    margin: 2rem 0;
}

.verse-container {
    background: linear-gradient(135deg, #f8f4e6, #e8dcc0);
    padding: 1.75rem;
    border-radius: var(--radius-md);
    margin: 1.5rem 0;
    border: 2px solid var(--color-accent-gold);
    text-align: center;
    position: relative;
}

.verse-text {
    font-family: 'Amiri', serif;
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    color: var(--color-text-on-cream);
    margin-bottom: 1rem;
    line-height: 1.8;
}

.verse-reference {
    color: #c9984a;
    font-weight: 600;
    font-size: 0.9rem;
}

/* About Section — compact, polished */
#about {
    background: linear-gradient(135deg, #f8f4e6 0%, #e8dcc0 100%);
    padding: 2.25rem 1.5rem;
}

#about .section-title {
    margin-bottom: 1.25rem;
    font-size: clamp(1.35rem, 3vw, 1.65rem);
}

.about-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.75rem;
    align-items: center;
}

.about-text p {
    margin-bottom: 1rem;
    line-height: 1.75;
    color: var(--color-text-muted);
    font-size: 1rem;
}

#aboutBio p {
    margin-bottom: 0.85rem;
}

.about-image {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.about-image img {
    width: 100%;
    max-width: 240px;
    max-height: 260px;
    height: auto;
    object-fit: cover;
    object-position: center top;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(42, 95, 111, 0.14);
    margin-inline: auto;
}

.placeholder-image {
    background: linear-gradient(135deg, var(--color-accent-gold), #c9984a);
    color: white;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 600;
}

/* Homepage previews: books / research / videos (navbar links to full pages) */
.home-preview-section {
    padding: 2.25rem 1.5rem;
    background: #fff;
}

.home-preview-section--cream {
    background: linear-gradient(135deg, #f8f4e6 0%, #e8dcc0 100%);
}

.home-preview-section .section-title {
    margin-bottom: 0.5rem;
}

.home-section-cta {
    text-align: center;
    margin-top: 1.5rem;
}

.home-preview-empty {
    color: var(--color-text-muted);
    padding: 1rem;
}

/* Contact Section */
#contact {
    background: white;
    padding: 3rem 1.5rem;
}

.contact-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: 1.5rem;
}

.contact-item {
    text-align: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #f8f4e6, #e8dcc0);
    border-radius: var(--radius-md);
    border: 2px solid var(--color-accent-gold);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.contact-item:hover {
    transform: translateY(-6px);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.15);
}

.contact-item h3 {
    font-family: 'Amiri', serif;
    color: var(--color-text-on-cream);
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.contact-item p {
    color: var(--color-text-muted);
    font-size: 1.05rem;
}

/* Arabic script helper (typography base for admin-controlled content) */
.script-arabic,
.script-Arab {
    font-family: Scheherazade, Lateef, LateefGR, Amiri, 'Noto Naskh Arabic',
    'KFGQPC Uthmanic Script HAFS', 'Droid Arabic Naskh', Harmattan,
    'Arabic Typesetting', 'Traditional Arabic', 'Simplified Arabic',
    'Times New Roman', Arial, 'Sakkal Majalla', 'Microsoft Uighur',
    Calibri, 'Microsoft Sans Serif', 'Segoe UI', serif, sans-serif;
    font-weight: normal;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 2rem;
    border-radius: var(--radius-md);
    width: 90%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    top: 10px;
    right: 15px;
}

.close:hover {
    color: var(--color-text-on-cream);
}

/* Admin Panel */
.admin-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 1001;
    overflow-y: auto;
}

.admin-header {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-darker));
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-header h2 {
    font-family: 'Amiri', serif;
    font-size: 1.8rem;
}

.logout-btn {
    background: var(--color-accent-gold);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: #c9984a;
    transform: translateY(-2px);
}

.admin-tabs {
    display: flex;
    background: #f5f5f5;
    border-bottom: 2px solid var(--color-accent-gold);
}

.tab-btn {
    background: none;
    border: none;
    padding: 1rem 2rem;
    cursor: pointer;
    font-weight: 600;
    color: #666;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn.active {
    background: white;
    color: var(--color-text-on-cream);
    border-bottom-color: var(--color-accent-gold);
}

.tab-content {
    display: none;
    padding: 2rem;
}

.tab-content.active {
    display: block;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--color-text-on-cream);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    font-family: 'Cairo', sans-serif;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-accent-gold);
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.1);
}

.btn {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: white;
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-family: 'Cairo', sans-serif;
    font-size: 1rem;
}

.btn:hover {
    background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary-darker));
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--color-shadow-primary);
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-accent-gold), #c9984a);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #c9984a, var(--color-accent-gold));
    box-shadow: 0 5px 15px rgba(212, 165, 116, 0.3);
}

/* Footer */
.footer {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark) 50%, var(--color-primary-darker));
    color: white;
    text-align: center;
    padding: 2.5rem 1.5rem;
    margin-top: 2rem;
    position: relative;
}

.footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--color-accent-gold), #c9984a, var(--color-accent-gold));
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-quote {
    font-family: 'Amiri', serif;
    font-size: clamp(1.05rem, 2.5vw, 1.3rem);
    margin-bottom: 1.5rem;
    font-style: italic;
    color: var(--color-accent-gold);
    line-height: 1.7;
}

/* Desktop: horizontal bar under logo — never off-canvas */
@media (min-width: 1025px) {
    .nav-backdrop {
        display: none !important;
    }

    .nav-toggle {
        display: none !important;
    }

    #siteNav.nav-menu {
        position: static !important;
        top: auto !important;
        right: auto !important;
        left: auto !important;
        bottom: auto !important;
        width: 100% !important;
        max-width: none !important;
        height: auto !important;
        min-height: 0 !important;
        transform: none !important;
        -webkit-transform: none !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 1.5rem !important;
        margin: 0 !important;
        padding: 1rem 0 !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
        overflow: visible !important;
        z-index: auto !important;
        will-change: auto !important;
        max-width: 1200px !important;
        margin-left: auto !important;
        margin-right: auto !important;
        box-sizing: border-box !important;
    }
}

/* Phones & tablets: logo + hamburger only; links live in sliding panel */
@media screen and (max-width: 1024px) {
    .header-bar {
        position: relative;
        z-index: 20002;
    }

    .nav-toggle {
        display: flex !important;
        position: relative;
        z-index: 50000 !important;
        pointer-events: auto !important;
    }

    .nav-backdrop {
        display: none;
    }

    .nav-backdrop.nav-backdrop--visible {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }

    /* Fixed panel: sibling of .container — not inside stacking context z-index:1 */
    #siteNav.nav-menu {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        left: auto !important;
        width: min(320px, calc(100vw - 16px)) !important;
        max-width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: none !important;
        z-index: 20001 !important;
        /* Hidden by default on mobile; JS will set display:flex when open */
        display: none !important;
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        gap: 0.25rem !important;

        margin: 0 !important;
        padding: max(5rem, calc(1.25rem + env(safe-area-inset-top, 0px))) 1.25rem calc(2rem + env(safe-area-inset-bottom, 0px)) !important;

        border-top: none !important;
        border-radius: 0 0 0 16px;
        box-shadow: -4px 0 32px rgba(0, 0, 0, 0.25);
        background: linear-gradient(180deg, #87CEEB 0%, #6BB8D4 100%) !important;

        transform: translate3d(100%, 0, 0) !important;
        -webkit-transform: translate3d(100%, 0, 0) !important;

        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;

        pointer-events: none !important;
        will-change: transform;
        transition: transform 0.36s cubic-bezier(0.4, 0, 0.2, 1);
    }

    body.nav-open #siteNav.nav-menu {
        display: flex !important;
        transform: translate3d(0, 0, 0) !important;
        -webkit-transform: translate3d(0, 0, 0) !important;
        pointer-events: auto !important;
    }

    /* Robust mobile open state: rely on menu class, not only on body.nav-open */
    #siteNav.nav-menu.open {
        display: flex !important;
        transform: translate3d(0, 0, 0) !important;
        -webkit-transform: translate3d(0, 0, 0) !important;
        pointer-events: auto !important;
    }

    #siteNav.nav-menu a {
        white-space: normal;
        padding: 0.85rem 1rem;
        border-radius: 10px;
        font-size: 1.05rem;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.15);
        touch-action: manipulation;
        text-align: right;
    }

    #siteNav.nav-menu .admin-btn {
        margin-top: 0.5rem;
        justify-content: center;
        width: 100%;
        touch-action: manipulation;
    }

    .header-content {
        text-align: right;
    }

    .logo-section {
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .hero-title {
        font-size: 2rem;
    }

    .bismillah {
        font-size: 1.3rem;
    }

    .content-grid {
        grid-template-columns: 1fr;
        padding: 2rem 1rem;
        gap: 1rem;
    }

    .container {
        padding: 0 1rem;
    }

    .about-content {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .about-image img {
        max-width: 200px;
        max-height: 220px;
    }

    .hero-verse {
        margin-inline: 0.25rem;
        padding: 1rem 0.9rem;
    }

    .read-more-btn, .btn {
        width: 100%;
        text-align: center;
    }

    .admin-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .admin-tabs {
        flex-wrap: wrap;
    }

    .tab-btn {
        flex: 1;
        min-width: 120px;
    }

    .main-content {
        margin: 1rem;
        border-radius: 14px;
    }

    .content-card {
        padding: 1.1rem;
    }

    .footer {
        padding: 2rem 1rem;
    }

    .footer-quote {
        font-size: 1.05rem;
    }

    .books-container,
    .book-detail-container,
    .checkout-container,
    .container-wide {
        padding: 0 1rem !important;
    }

    .books-grid,
    .page-wrap .grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .book-cover {
        height: 320px !important;
    }

    .book-title-large {
        font-size: 2rem !important;
    }

    .pdf-viewer-container {
        min-height: 420px !important;
    }

    .pdf-viewer {
        height: 520px !important;
    }
}

@media (max-width: 640px) {
    .hero-ornament {
        width: clamp(110px, 34vw, 180px);
        height: clamp(110px, 34vw, 180px);
        opacity: 0.16;
        left: clamp(-2.5rem, -6vw, -0.75rem);
        top: -1.25rem;
    }
}

@media (max-width: 480px) {
    .hero-ornament {
        display: none;
    }

    .logo h1,
    .logo .logo-text {
        font-size: 1.8rem;
    }

    .hero-title {
        font-size: 1.5rem;
    }

    .bismillah {
        font-size: 1.1rem;
    }

    .verse-text {
        font-size: 1.1rem;
    }

    .modal-content {
        margin: 10% auto;
        width: 95%;
    }

    .hero-section {
        padding: 2.2rem 1rem;
    }

    .card-title, .book-title {
        font-size: 1.15rem;
    }

    .book-cover {
        height: 260px !important;
    }

    .book-title-large {
        font-size: 1.6rem !important;
    }

    .pdf-section, .checkout-card, .book-detail-header, .book-introduction {
        padding: 1rem !important;
        border-radius: 12px !important;
    }

    .pdf-viewer {
        height: 420px !important;
    }

    .page-header h1, .books-header h1 {
        font-size: 2rem !important;
    }

    .page-header p, .books-header p {
        font-size: 0.95rem;
    }
}

/* --- GA4 page view badge (compteur de vues) --- */
.page-view-badge-wrap {
    display: flex;
    justify-content: center;
    margin: 0.75rem 0 0;
}

.page-view-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.28);
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.page-view-badge__value {
    min-width: 1.25em;
    text-align: center;
}

.page-view-badge__icon {
    font-size: 1rem;
    line-height: 1;
    opacity: 0.92;
}

.page-view-badge--loading {
    opacity: 0.75;
}

.page-view-badge--unavailable,
.page-view-badge--error {
    opacity: 0.65;
}

/* Variante sur fond clair (ex. pied de page crème, cartes) */
.page-view-badge--on-light {
    background: rgba(42, 95, 111, 0.08);
    border-color: rgba(42, 95, 111, 0.18);
    color: #2a5f6f;
}
