/* ==========================================================================
   Hadis Bahçesi — Kraliyet Safir Laciverti & İmparatorluk Kehribarı
   (Hafif & 60 FPS Kart Yapısı + RTL + Gece Modu)
   ========================================================================== */

/* Sülüs Logo Fontu */
@font-face {
    font-family: 'Sulus';
    src: url('../UKIJSlsTom.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}
.font-logo,
.font-sulus {
    font-family: 'Sulus', serif;
    font-weight: normal;
}

.font-uyghur { font-family: 'Lateef', serif; }
.font-arabic { font-family: 'Amiri Quran', 'Amiri', serif; }

html {
    scroll-behavior: smooth;
    overflow-x: clip;
    max-width: 100%;
}

body {
    font-family: 'Lateef', 'Segoe UI', Tahoma, sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: #f4f6fa;
    color: #1e293b;
    overflow-x: clip;
    max-width: 100%;
    /* quranim.site ile aynı 32px çift radyal noktalı zemin — Safir & Kehribar */
    background-image:
        radial-gradient(rgba(15, 52, 96, 0.14) 1.5px, transparent 1.5px),
        radial-gradient(rgba(217, 119, 6, 0.15) 1.5px, transparent 1.5px);
    background-size: 32px 32px, 32px 32px;
    background-position: 0 0, 16px 16px;
}

/* ==================== KARTLAR & ARAMA ALANI (TEMİZ & HIZLI) ==================== */
.card-shadow {
    background-color: #ffffff;
    box-shadow: 0 10px 30px -10px rgba(15, 52, 96, 0.08), 0 4px 10px -4px rgba(15, 52, 96, 0.04);
    border: 1px solid #e2e8f0;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.25s ease;
}

.surface-card {
    background-color: #ffffff;
}

/* Yüzen arama ve filtre çubuğu kabı */
.search-glass {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 15px 35px -10px rgba(7, 26, 52, 0.10), 0 2px 6px rgba(15, 52, 96, 0.04);
    transition: box-shadow 0.25s ease, border-color 0.25s ease;
}
.search-glass:focus-within {
    box-shadow: 0 20px 40px -10px rgba(29, 111, 209, 0.20), 0 0 0 3px rgba(29, 111, 209, 0.15);
    border-color: #1d6fd1;
}

/* RTL uyumlu özel select oku */
.hadis-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' viewBox='0 0 24 24' stroke='%230f3460' stroke-width='2.4'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 10px center;
    background-size: 13px 13px;
}

/* Özel Arama Özellikli Açılır Menü Paneli (Bölüm & Bâb) */
.custom-dropdown-panel {
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    box-shadow: 0 20px 44px -12px rgba(7, 26, 52, 0.22), 0 4px 12px -4px rgba(15, 52, 96, 0.08);
}

/* Tıklanabilir Kitap Butonları */
.book-pill {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 6px 18px -8px rgba(15, 52, 96, 0.08);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s ease, border-color 0.22s ease;
}
.book-pill-active {
    background: linear-gradient(135deg, #071a34 0%, #0f3460 55%, #16467e 100%) !important;
    border-color: rgba(251, 191, 36, 0.78) !important;
    color: #ffffff !important;
    box-shadow: 0 12px 28px -8px rgba(15, 52, 96, 0.45), 0 0 0 2px rgba(251, 191, 36, 0.22) !important;
}
.book-pill-soon {
    opacity: 0.78;
    border-style: dashed;
}

/* Uzun kitap adlarının masaüstü kartlarından taşmasını önler */
#booksShowcaseGrid .book-pill > span:first-child {
    white-space: normal;
    line-height: 1.35;
}

/* Hover animasyonları yalnızca fareli cihazlarda çalışır (mobilde titremeyi önler) */
@media (hover: hover) {
    .card-shadow:hover {
        transform: translateY(-2px);
        box-shadow: 0 16px 40px -12px rgba(217, 119, 6, 0.16), 0 8px 16px -4px rgba(15, 52, 96, 0.10);
        border-color: rgba(217, 119, 6, 0.45);
    }
    .book-pill:hover:not(.book-pill-active) {
        transform: translateY(-2px);
        border-color: rgba(217, 119, 6, 0.55);
        box-shadow: 0 12px 26px -10px rgba(15, 52, 96, 0.14);
    }
    .book-pill-soon:hover {
        opacity: 1;
    }
}

/* Arama sonuç kartlarının çizim izolasyonu */
#results > article {
    contain: layout style;
}

/* Sahih Müslim çok rivayetli Arapça satır koruması */
#results .font-arabic,
#randArapca {
    white-space: pre-line;
}

/* Uygurca metin içindeki satır içi Arapça alıntı ({{ar}}...{{/ar}}) */
.inline-ar {
    font-family: 'Amiri', 'Amiri Quran', serif;
    font-size: 0.78em;
    color: #0f3460;
    background-color: rgba(29, 111, 209, 0.07);
    border-radius: 0.45rem;
    padding: 0 0.32rem;
    unicode-bidi: isolate;
    display: inline;
    line-height: 2.05;
}

/* KRİTİK: Arapça harflerin bitişikliğini ASLA bozmayan arama vurgusu */
mark.ar-hl {
    background-color: rgba(253, 230, 138, 0.92);
    color: #78350f;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
}

/* Uygurca arama vurgusu */
mark.ug-hl {
    background-color: rgba(254, 243, 199, 0.95);
    color: #78350f;
    padding: 0 4px;
    border-radius: 6px;
    border: 1px solid rgba(217, 119, 6, 0.42);
    font-weight: 700;
}

/* Özel kaydırma çubuğu */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f4f6fa; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Mobil açılır menü karartma katmanı & Sabit köşe butonları */
.dropdown-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(7, 26, 52, 0.58);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 65;
}

.scroll-top-btn {
    position: fixed;
    left: 1rem;
    bottom: calc(1.25rem + env(safe-area-inset-bottom));
    z-index: 55;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 52, 96, 0.92);
    color: #fde68a;
    border: 1px solid rgba(251, 191, 36, 0.55);
    box-shadow: 0 10px 24px -6px rgba(7, 26, 52, 0.45);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.2s ease, bottom 0.2s ease;
}
.scroll-top-btn.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.scroll-top-btn:hover {
    background: #071a34;
}

/* Mobil Sağ Alt Sabit Gece Modu Butonu (masaüstünde gizli) */
.mobile-theme-btn {
    display: none;
    position: fixed;
    right: 1rem;
    bottom: calc(1.25rem + env(safe-area-inset-bottom));
    z-index: 55;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    align-items: center;
    justify-content: center;
    background: rgba(15, 52, 96, 0.92);
    color: #fde68a;
    border: 1px solid rgba(251, 191, 36, 0.55);
    box-shadow: 0 10px 24px -6px rgba(7, 26, 52, 0.45);
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.2s ease, bottom 0.2s ease;
}
.mobile-theme-btn:active { transform: scale(0.94); }
.mobile-theme-btn .sun-ico { display: none; }
html.dark .mobile-theme-btn .moon-ico { display: none; }
html.dark .mobile-theme-btn .sun-ico { display: block; }
html.dark .mobile-theme-btn,
html.dark .scroll-top-btn {
    background: rgba(12, 27, 48, 0.94);
}

#pwaInstallBanner {
    bottom: calc(0.85rem + env(safe-area-inset-bottom));
}
#toastNotice {
    bottom: calc(1.25rem + env(safe-area-inset-bottom));
}
footer {
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
}

/* ==================== GECE MODU (DARK MODE) ==================== */
html.dark { color-scheme: dark; }
html.dark body {
    background-color: #06101f;
    color: #f1f5f9;
    background-image:
        radial-gradient(rgba(96, 165, 250, 0.12) 1.5px, transparent 1.5px),
        radial-gradient(rgba(217, 119, 6, 0.12) 1.5px, transparent 1.5px);
}
html.dark .card-shadow,
html.dark .search-glass,
html.dark .book-pill:not(.book-pill-active),
html.dark .surface-card {
    background-color: #0c1b30 !important;
    border-color: #1e3a5f !important;
    color: #f1f5f9;
}
html.dark .custom-dropdown-panel {
    background-color: #0a172a !important;
    border-color: rgba(56, 130, 214, 0.38) !important;
    box-shadow: 0 24px 50px -12px rgba(0, 0, 0, 0.78);
}
html.dark .card-shadow {
    box-shadow: 0 12px 32px -10px rgba(0, 0, 0, 0.60);
}
@media (hover: hover) {
    html.dark .card-shadow:hover,
    html.dark .book-pill:not(.book-pill-active):hover {
        border-color: rgba(251, 191, 36, 0.55) !important;
        box-shadow: 0 16px 38px -12px rgba(217, 119, 6, 0.18), 0 8px 18px -4px rgba(0, 0, 0, 0.55);
    }
}
html.dark .search-glass:focus-within {
    border-color: #60a5fa !important;
    box-shadow: 0 20px 44px -10px rgba(29, 111, 209, 0.32), 0 0 0 3px rgba(96, 165, 250, 0.22);
}
html.dark .surface-elevated {
    background-color: #11243f !important;
    border-color: #1e3a5f !important;
}
html.dark .inline-ar {
    color: #93c5fd !important;
    background-color: rgba(59, 130, 246, 0.16);
}
html.dark mark.ar-hl {
    background-color: rgba(217, 119, 6, 0.45);
    color: #fef3c7;
}
html.dark mark.ug-hl {
    background-color: rgba(217, 119, 6, 0.36);
    color: #fef3c7;
    border-color: rgba(251, 191, 36, 0.55);
}
html.dark .hadis-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' viewBox='0 0 24 24' stroke='%2360a5fa' stroke-width='2.4'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
}
html.dark select option {
    background-color: #0c1b30;
    color: #f1f5f9;
}
html.dark ::-webkit-scrollbar-track { background: #06101f; }
html.dark ::-webkit-scrollbar-thumb { background: #1e3a5f; }
html.dark ::-webkit-scrollbar-thumb:hover { background: #2d5180; }

/* ==================== YALNIZCA MOBİL EKRANLAR (<= 639px) ==================== */
@media (max-width: 639px) {
    /* 1) Üst menü: kesin 2 satır (1. satır: 3 ana buton | 2. satır: قۇرئانىم تورى + Hicri takvim) */
    body > nav {
        padding-top: max(0.45rem, env(safe-area-inset-top)) !important;
        padding-bottom: 0.45rem !important;
        background-color: rgba(7, 26, 52, 0.90) !important;
    }
    body > nav > div {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 0.38rem !important;
    }
    body > nav > div > div {
        display: contents !important;
    }
    body > nav button,
    #navQuranBtn {
        height: 36px !important;
        padding-left: 0.65rem !important;
        padding-right: 0.65rem !important;
        font-size: 1.14rem !important;
    }
    #hijriDate {
        height: 36px !important;
        padding-left: 0.65rem !important;
        padding-right: 0.65rem !important;
        font-size: 1.1rem !important;
        gap: 0.35rem !important;
    }
    #themeToggleBtn {
        display: none !important;
    }
    .mobile-theme-btn {
        display: flex;
    }

    /* 2) Mobil hero & makale üst boşluğu */
    #heroHeader {
        padding-top: calc(6.75rem + env(safe-area-inset-top)) !important;
        padding-bottom: 4.5rem !important;
    }
    #mainContainer.pt-44 {
        padding-top: calc(6.75rem + env(safe-area-inset-top)) !important;
    }
    #heroHeader .inline-flex.rounded-full {
        padding: 0.3rem 0.9rem !important;
        font-size: 1.18rem !important;
    }

    /* 3) Kitap butonları mobilde 2x2 ortalı ızgara */
    #booksShowcaseGrid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.5rem !important;
    }
    #booksShowcaseGrid .book-pill {
        flex-direction: column;
        align-items: center !important;
        justify-content: center;
        text-align: center !important;
        gap: 0.3rem;
        padding: 0.58rem 0.5rem !important;
    }
    #booksShowcaseGrid .book-pill > span:first-child {
        font-size: 1.24rem !important;
        white-space: normal;
    }
    #booksShowcaseGrid .book-pill > span:last-child {
        font-size: 1.04rem !important;
    }

    /* 4) Yaklaşan Mübarek Günler: quranim.site ile uyumlu tek satır sağ-sol hizalama */
    #islamicEventsContainer > div {
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 0.6rem !important;
        padding: 0.85rem 0.95rem !important;
    }
    #islamicEventsContainer > div > span:first-child {
        font-size: 1.2rem !important;
        line-height: 1.45 !important;
        min-width: 0;
    }
    #islamicEventsContainer > div > span:last-child {
        font-size: 1.08rem !important;
        padding: 0.25rem 0.65rem !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }

    /* 5) Bölüm / Bâb menüsü mobilde ekran içi sabit pencere */
    .custom-dropdown-panel {
        position: fixed !important;
        left: 12px !important;
        right: 12px !important;
        top: calc(5.8rem + env(safe-area-inset-top)) !important;
        width: auto !important;
        max-height: 70dvh !important;
        display: flex;
        flex-direction: column;
        z-index: 80 !important;
    }
    .custom-dropdown-panel.hidden {
        display: none !important;
    }
    .custom-dropdown-panel > div:last-child {
        max-height: calc(70dvh - 58px) !important;
        -webkit-overflow-scrolling: touch;
    }

    /* 6) Hadis kartı mobil aksiyon butonları */
    #results > article > div:nth-child(2) > div:last-child {
        width: 100%;
    }
    #results > article > div:nth-child(2) > div:last-child > button {
        flex: 1 1 auto;
        justify-content: center;
        min-height: 36px;
    }

    /* 7) PWA bandı açıkken her iki köşe butonu da üstte kalsın */
    body.pwa-banner-open .scroll-top-btn,
    body.pwa-banner-open .mobile-theme-btn {
        bottom: calc(5.8rem + env(safe-area-inset-bottom));
    }
}

@media (max-width: 375px) {
    body > nav button,
    #navQuranBtn,
    #hijriDate {
        font-size: 1.02rem !important;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    #islamicEventsContainer > div {
        padding: 0.75rem 0.75rem !important;
    }
    #islamicEventsContainer > div > span:first-child {
        font-size: 1.12rem !important;
    }
    #islamicEventsContainer > div > span:last-child {
        font-size: 1rem !important;
        padding: 0.2rem 0.5rem !important;
    }
}

/* ==================== SEÇİLİ KİTAP ÖZET KUTUSU ==================== */
.book-summary-box {
    margin-top: 0.75rem;
}

.book-summary-card {
    position: relative;
    overflow: hidden;
    border-radius: 1.15rem;
    background: linear-gradient(135deg, #fffdf4 0%, #fef6df 100%);
    border: 1px solid #efd59a;
    border-right: 4px solid #d97706;
    box-shadow: 0 8px 22px -12px rgba(180, 83, 9, 0.16), 0 2px 6px rgba(15, 52, 96, 0.04);
    text-align: right;
}

.book-summary-card.is-entering {
    animation: bookSummaryReveal 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes bookSummaryReveal {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.book-summary-inner {
    padding: 0.85rem 1.15rem 0.9rem;
}

.book-summary-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem 0.75rem;
    flex-wrap: wrap;
    padding-bottom: 0.55rem;
    margin-bottom: 0.55rem;
    border-bottom: 1px dashed rgba(217, 119, 6, 0.32);
}

.book-summary-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
}

.book-summary-icon {
    width: 34px;
    height: 34px;
    border-radius: 0.7rem;
    background: linear-gradient(135deg, #071a34, #0f3460);
    border: 1px solid rgba(251, 191, 36, 0.45);
    color: #fbbf24;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.book-summary-title {
    font-family: 'Lateef', serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f3460;
    line-height: 1.2;
    margin: 0;
}

.book-summary-subtitle {
    display: inline-flex;
    align-items: center;
    padding: 0.12rem 0.68rem;
    border-radius: 0.65rem;
    background-color: rgba(217, 119, 6, 0.11);
    border: 1px solid rgba(217, 119, 6, 0.26);
    font-family: 'Lateef', serif;
    font-size: 1.16rem;
    font-weight: 700;
    color: #92400e;
    line-height: 1.3;
}

.book-summary-text {
    font-family: 'Lateef', serif;
    font-size: 1.34rem;
    line-height: 1.55;
    color: #334155;
    text-align: justify;
    text-justify: inter-word;
    margin: 0;
}

/* Gece Modu */
html.dark .book-summary-card {
    background: linear-gradient(135deg, #101f35 0%, #17273e 100%);
    border-color: rgba(217, 119, 6, 0.35);
    border-right-color: #fbbf24;
    box-shadow: 0 10px 28px -10px rgba(0, 0, 0, 0.58);
}
html.dark .book-summary-head {
    border-bottom-color: rgba(251, 191, 36, 0.22);
}
html.dark .book-summary-title {
    color: #fde68a;
}
html.dark .book-summary-subtitle {
    background-color: rgba(217, 119, 6, 0.18);
    border-color: rgba(251, 191, 36, 0.32);
    color: #fde68a;
}
html.dark .book-summary-text {
    color: #e2e8f0;
}

/* Mobil Uyarlama */
@media (max-width: 639px) {
    .book-summary-box {
        margin-top: 0.6rem;
    }
    .book-summary-inner {
        padding: 0.75rem 0.9rem 0.8rem;
    }
    .book-summary-head {
        padding-bottom: 0.45rem;
        margin-bottom: 0.45rem;
    }
    .book-summary-icon {
        width: 30px;
        height: 30px;
        font-size: 0.95rem;
        border-radius: 0.6rem;
    }
    .book-summary-title {
        font-size: 1.34rem;
    }
    .book-summary-subtitle {
        font-size: 1.06rem;
        padding: 0.08rem 0.55rem;
    }
    .book-summary-text {
        font-size: 1.22rem;
        line-height: 1.48;
    }
}

/* ==================== SABİT ÜST MENÜ KAYDIRMA BOŞLUĞU ==================== */
#resultCountWrapper,
#results > article {
    scroll-margin-top: 92px;
}

@media (max-width: 639px) {
    #resultCountWrapper,
    #results > article {
        scroll-margin-top: calc(6.5rem + env(safe-area-inset-top));
    }
}

/* ==================== İNCE & ZARİF DİPNOT NUMARALARI (①..⑯) ==================== */
.fn-ref {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    margin: 0 2px;
    border-radius: 9999px;
    background-color: #fef3c7;
    border: 1px solid #f59e0b;
    color: #92400e;
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1;
    vertical-align: super;
    transform: translateY(-2px);
    user-select: none;
}

.fn-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 19px;
    height: 19px;
    padding: 0 4px;
    margin-left: 6px;
    border-radius: 9999px;
    background-color: #0f3460;
    color: #fbbf24;
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    vertical-align: middle;
}

html.dark .fn-ref {
    background-color: rgba(180, 83, 9, 0.28);
    border-color: rgba(251, 191, 36, 0.55);
    color: #fde68a;
}

html.dark .fn-num {
    background-color: #1e3a5f;
    color: #fde68a;
}
