/*
 * enhance.css — שכבת העיצוב של ברכה בצ'יק
 * 1. טוקנים (אור/חושך)  2. מצב כהה מדויק  3. בלוקי נוסח  4. מובייל
 * 5. פרסומות  6. מודאלים (חוסם פרסומות / שבת)
 * נטען אחרי style.css, לפני Tailwind runtime output — לכן משתמשים
 * בסלקטורים ברמת specificity גבוהה יותר (html.dark [class*="..."]).
 */

/* ── 1. טוקנים ─────────────────────────────────────────────────────────── */

:root {
    --bb-bg: #f6f7f9;
    --bb-bg-glow: radial-gradient(1200px 600px at 50% -10%, rgba(0, 104, 95, 0.07), transparent 60%);
    --bb-card: #ffffff;
    --bb-card-2: #f3f6f9;
    --bb-card-3: #e9eef4;
    --bb-line: rgba(15, 23, 42, 0.09);
    --bb-line-strong: rgba(15, 23, 42, 0.16);
    --bb-text: #0f172a;
    --bb-text-2: #475569;
    --bb-brand: #00685f;
    --bb-brand-soft: rgba(0, 104, 95, 0.09);
    --bb-accent: #b45309;
    --bb-accent-soft: rgba(217, 119, 6, 0.12);
    --bb-gold-line: rgba(217, 119, 6, 0.35);
    --bb-radius: 18px;
    --bb-radius-sm: 12px;
    --bb-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 14px 40px -24px rgba(15, 23, 42, 0.35);
    --bb-shadow-hover: 0 2px 4px rgba(15, 23, 42, 0.05), 0 22px 50px -26px rgba(0, 104, 95, 0.45);
}

html.dark {
    --bb-bg: #070c14;
    --bb-bg-glow: radial-gradient(1100px 560px at 50% -8%, rgba(45, 212, 191, 0.12), transparent 62%),
        radial-gradient(900px 500px at 100% 100%, rgba(217, 119, 6, 0.07), transparent 60%);
    --bb-card: #141f31;
    --bb-card-2: #19253a;
    --bb-card-3: #1f2d44;
    --bb-line: rgba(255, 255, 255, 0.10);
    --bb-line-strong: rgba(255, 255, 255, 0.18);
    --bb-text: #e9eff8;
    --bb-text-2: #a6b5c9;
    --bb-brand: #5eead4;
    --bb-brand-soft: rgba(94, 234, 212, 0.12);
    --bb-accent: #fbbf24;
    --bb-accent-soft: rgba(251, 191, 36, 0.12);
    --bb-gold-line: rgba(251, 191, 36, 0.32);
    --bb-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 44px -28px rgba(0, 0, 0, 0.85);
    --bb-shadow-hover: 0 2px 6px rgba(0, 0, 0, 0.45), 0 26px 60px -30px rgba(94, 234, 212, 0.35);
}

/* ── 2. בסיס ומצב כהה ──────────────────────────────────────────────────── */

body {
    background-color: var(--bb-bg);
    background-image: var(--bb-bg-glow);
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: var(--bb-text);
    -webkit-text-size-adjust: 100%;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

html.dark body,
html.dark body.bg-surface-base {
    background-color: var(--bb-bg) !important;
    background-image: var(--bb-bg-glow) !important;
    color: var(--bb-text) !important;
}

/* כרטיסים */
html.dark [class*="bg-surface-pure"],
html.dark [class*="bg-surface-container-low"],
html.dark [class*="bg-surface-container-high"],
html.dark [class*="bg-surface-variant"] {
    background-color: var(--bb-card) !important;
    border-color: var(--bb-line) !important;
}

html.dark [class*="bg-surface-container"]:not([class*="bg-surface-container-high"]):not([class*="bg-surface-container-low"]) {
    background-color: var(--bb-card-2) !important;
}

/* כרטיס ההדגשה הזהוב (ברכה אחרונה) */
html.dark [class*="bg-gold-subtle"] {
    background-color: var(--bb-accent-soft) !important;
    color: var(--bb-text) !important;
    border-color: var(--bb-gold-line) !important;
}

html.dark [class*="bg-secondary-fixed"] {
    background-color: rgba(217, 119, 6, 0.18) !important;
}

/* טקסטים */
html.dark .text-primary,
html.dark [class*="text-primary"]:not([class*="text-primary-fixed"]) {
    color: var(--bb-brand) !important;
}

html.dark .text-on-surface,
html.dark .text-on-background {
    color: var(--bb-text) !important;
}

html.dark .text-on-surface-variant,
html.dark .text-text-muted {
    color: var(--bb-text-2) !important;
}

html.dark .text-secondary,
html.dark .text-on-secondary-container {
    color: var(--bb-accent) !important;
}

html.dark .text-on-primary,
html.dark .text-on-secondary {
    color: #04211d !important;
}

/* גבולות והצללות */
html.dark [class*="border-border-subtle"],
html.dark [class*="border-outline"] {
    border-color: var(--bb-line) !important;
}

html.dark [class*="border-primary"] {
    border-color: var(--bb-brand) !important;
}

html.dark [class*="border-secondary"] {
    border-color: var(--bb-accent) !important;
}

html.dark [class*="shadow-"] {
    box-shadow: var(--bb-shadow) !important;
}

/* ניווט עליון */
html.dark header {
    background: rgba(9, 14, 24, 0.82) !important;
    border-bottom: 1px solid var(--bb-line);
    backdrop-filter: blur(26px) saturate(160%);
    -webkit-backdrop-filter: blur(26px) saturate(160%);
}

html.dark header nav {
    background: rgba(255, 255, 255, 0.04) !important;
    border-color: var(--bb-line) !important;
}

html.dark nav a[class*="bg-primary-container"] {
    background-color: var(--bb-brand) !important;
    color: #04211d !important;
    font-weight: 700;
}

html.dark nav a:not([class*="bg-primary-container"]):hover {
    background-color: rgba(255, 255, 255, 0.07) !important;
    color: var(--bb-text) !important;
}

html.dark .mobile-nav-panel {
    background: rgba(12, 18, 30, 0.97) !important;
    border-color: var(--bb-line) !important;
}

html.dark footer {
    background: rgba(255, 255, 255, 0.02) !important;
    border-color: var(--bb-line) !important;
}

/* קישורים בגוף הטקסט */
html.dark a:hover {
    color: var(--bb-brand);
}

/* פס גלילה */
html.dark {
    scrollbar-color: #2b3a4d var(--bb-bg);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--bb-line-strong);
    border-radius: 99px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

/* ── 3. בלוקי הנוסח — הלב של הדף ──────────────────────────────────────── */

.nusach-text {
    font-size: clamp(1.05rem, 2.6vw, 1.3rem);
    font-weight: 600;
    line-height: 2.05;
    letter-spacing: 0.2px;
    color: var(--bb-text) !important;
    text-wrap: pretty;
}

/* ברכה ראשונה */
article > div > div[class*="border-primary"] {
    position: relative;
    background: linear-gradient(180deg, var(--bb-brand-soft), transparent 85%);
    border-radius: var(--bb-radius-sm);
    border-inline-start-width: 4px;
    border-inline-start-style: solid;
    border-inline-start-color: var(--bb-brand);
    overflow: hidden;
}

html.dark article > div > div[class*="border-primary"] {
    background: linear-gradient(180deg, rgba(94, 234, 212, 0.10), rgba(94, 234, 212, 0.02) 80%) !important;
    border-inline-start-color: var(--bb-brand) !important;
}

/* ברכה אחרונה */
article > div > div[class*="bg-gold-subtle"] {
    border-radius: var(--bb-radius-sm);
    border-inline-start-width: 4px;
    border-inline-start-style: solid;
    border-inline-start-color: var(--bb-accent);
    background: linear-gradient(180deg, var(--bb-accent-soft), transparent 85%) !important;
}

article > div > div[class*="bg-gold-subtle"] .nusach-text {
    color: var(--bb-text) !important;
}

/* תג הקטגוריה */
article > a[class*="bg-gold-subtle"],
article > a[href*="/category/"] {
    text-decoration: none;
    border: 1px solid var(--bb-gold-line);
}

/* סיכום התשובה */
#answerSummary {
    font-size: clamp(1rem, 2.4vw, 1.12rem);
    line-height: 1.85;
}

#answerSummary strong {
    color: var(--bb-brand);
}

html.dark #answerSummary strong {
    color: var(--bb-brand);
}

/* ── 4. טיפוגרפיה כללית ומובייל ───────────────────────────────────────── */

main {
    padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0px));
}

h1, h2, h3 {
    text-wrap: balance;
}

details > summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

details > summary::-webkit-details-marker {
    display: none;
}

details > summary::after {
    content: "expand_more";
    font-family: "Material Symbols Outlined";
    font-size: 20px;
    color: var(--bb-text-2);
    transition: transform 0.2s ease;
    flex: none;
}

details[open] > summary::after {
    transform: rotate(180deg);
}

details > summary {
    min-height: 44px;
}

/* קישורי המאגר והקטגוריות — יעד נגיעה נוח */
[class*="rounded-full"][class*="text-sm"],
[class*="rounded-xl"][class*="py-2"] {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.3;
}

@media (max-width: 640px) {
    main {
        padding-top: 6.5rem !important;
        padding-inline: 0.9rem !important;
    }

    h1 {
        font-size: clamp(1.45rem, 7vw, 1.9rem) !important;
        line-height: 1.24 !important;
    }

    h2 {
        font-size: clamp(1.1rem, 5vw, 1.35rem) !important;
        line-height: 1.3 !important;
    }

    .nusach-text {
        font-size: 1.06rem;
        line-height: 1.95;
    }

    article {
        border-radius: 16px !important;
        padding: 1.1rem !important;
    }

    [class*="grid-cols-2"],
    [class*="grid-cols-3"],
    [class*="grid-cols-4"] {
        gap: 0.45rem !important;
    }

    /* כפתורים וקישורים ברוחב מלא בשורות צ'יפים */
    .bb-chip-grid > a {
        padding-inline: 0.6rem !important;
        font-size: 0.85rem !important;
    }
}

@media (max-width: 380px) {
    [class*="grid-cols-2"] {
        grid-template-columns: 1fr !important;
    }
}

@media (hover: none) {
    [class*="hover:border-primary"]:hover {
        border-color: var(--bb-line) !important;
        color: inherit !important;
    }
}

/* ── 5. פרסומות ───────────────────────────────────────────────────────── */

.ad-slot {
    position: relative;
    display: block;
    width: 100%;
    max-width: 42rem;
    margin-inline: auto;
    min-height: 0;
    border-radius: var(--bb-radius);
    background: transparent;
    contain: layout paint;
}

.ad-slot__label {
    display: block;
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--bb-text-2);
    opacity: 0.65;
    text-align: center;
    margin-bottom: 6px;
}

.ad-slot__inner {
    border: 1px solid var(--bb-line);
    border-radius: var(--bb-radius);
    background: var(--bb-card);
    overflow: hidden;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-slot .adsbygoogle {
    display: block;
    width: 100%;
}

.ad-slot--house .ad-slot__inner {
    min-height: 0;
    padding: 1rem 1.15rem;
    text-align: center;
    background: linear-gradient(135deg, var(--bb-brand-soft), transparent 70%);
    border-style: dashed;
}

.ad-slot--house .ad-slot__title {
    font-weight: 700;
    color: var(--bb-brand);
    font-size: 0.95rem;
}

.ad-slot--house .ad-slot__text {
    color: var(--bb-text-2);
    font-size: 0.82rem;
    line-height: 1.6;
    margin-top: 4px;
}

.ad-slot--house .ad-slot__cta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--bb-brand);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ad-slot--header {
    max-width: 100%;
}

.ad-slot--header .ad-slot__inner {
    min-height: 90px;
}

/* ── 6. מודאלים ───────────────────────────────────────────────────────── */

.bb-modal {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(8, 13, 22, 0.62);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.bb-modal.is-open {
    display: flex;
    animation: bb-fade 0.18s ease-out;
}

.bb-modal__card {
    position: relative;
    width: 100%;
    max-width: 27rem;
    background: var(--bb-card);
    color: var(--bb-text);
    border: 1px solid var(--bb-line);
    border-radius: 22px;
    padding: 1.5rem 1.35rem 1.25rem;
    box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.6);
    text-align: center;
    animation: bb-pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

.bb-modal__icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 0.75rem;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: var(--bb-brand-soft);
    color: var(--bb-brand);
}

.bb-modal__icon .material-symbols-outlined {
    font-size: 28px;
}

.bb-modal__title {
    font-size: 1.22rem;
    font-weight: 800;
    line-height: 1.35;
    margin-bottom: 0.5rem;
}

.bb-modal__text {
    font-size: 0.92rem;
    line-height: 1.75;
    color: var(--bb-text-2);
}

.bb-modal__actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1.15rem;
}

.bb-btn {
    border: 0;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    padding: 0.8rem 1rem;
    border-radius: 999px;
    min-height: 46px;
    transition: transform 0.15s ease, background 0.2s ease, opacity 0.2s ease;
}

.bb-btn:active {
    transform: scale(0.975);
}

.bb-btn--primary {
    background: var(--bb-brand);
    color: #04211d;
    box-shadow: 0 8px 24px -12px rgba(0, 104, 95, 0.6);
}

.bb-btn--ghost {
    background: transparent;
    color: var(--bb-text-2);
    border: 1px solid var(--bb-line);
}

.bb-btn--ghost:hover {
    color: var(--bb-text);
    border-color: var(--bb-line-strong);
}

.bb-modal__foot {
    margin-top: 0.9rem;
    font-size: 0.72rem;
    color: var(--bb-text-2);
    opacity: 0.8;
}

.bb-modal__foot a,
.bb-modal__foot button {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
    background: none;
    border: 0;
    cursor: pointer;
    font: inherit;
    padding: 0;
}

.bb-modal__status {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--bb-accent);
    min-height: 1.1em;
}

/* חוסם שבת */
.bb-shabbat {
    position: fixed;
    inset: 0;
    z-index: 9100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: radial-gradient(900px 500px at 50% 12%, #14243a, #060a11 70%);
    color: #f4f7fb;
    text-align: center;
}

.bb-shabbat.is-open {
    display: flex;
}

.bb-shabbat__inner {
    max-width: 26rem;
}

.bb-shabbat__candle {
    font-size: 34px;
    color: #fbbf24;
    margin-bottom: 0.8rem;
    display: inline-grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 999px;
    border: 1px solid rgba(251, 191, 36, 0.35);
    background: rgba(251, 191, 36, 0.08);
    animation: bb-glow 3.5s ease-in-out infinite;
}

.bb-shabbat__title {
    font-size: clamp(1.9rem, 8vw, 2.6rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin-bottom: 0.4rem;
}

.bb-shabbat__sub {
    font-size: 0.95rem;
    line-height: 1.8;
    color: #c8d4e4;
}

.bb-shabbat__times {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    margin: 1.4rem 0 0.9rem;
    flex-wrap: wrap;
}

.bb-shabbat__time {
    min-width: 8.5rem;
    padding: 0.7rem 0.9rem;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.05);
}

.bb-shabbat__time span {
    display: block;
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    color: #a9b7cc;
}

.bb-shabbat__time b {
    font-size: 1.15rem;
    font-weight: 800;
    direction: ltr;
}

.bb-shabbat__note {
    font-size: 0.72rem;
    color: #8b9bb1;
    line-height: 1.7;
    margin-top: 0.6rem;
}

.bb-shabbat__note a {
    color: #fbbf24;
    text-decoration: underline;
}

@keyframes bb-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes bb-pop {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to { opacity: 1; transform: none; }
}

@keyframes bb-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
    50% { box-shadow: 0 0 34px 2px rgba(251, 191, 36, 0.22); }
}

@media (prefers-reduced-motion: reduce) {
    .bb-modal.is-open,
    .bb-modal__card,
    .bb-shabbat__candle {
        animation: none !important;
    }
}

/* ── 7. שיפורי בית (עמוד החיפוש) ──────────────────────────────────────── */

.glass-search-pill {
    transition: box-shadow 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

.glass-search-pill:focus-within {
    border-color: var(--bb-brand) !important;
    box-shadow: 0 0 0 4px var(--bb-brand-soft), 0 12px 30px -18px rgba(0, 104, 95, 0.6) !important;
}

html.dark .glass-search-pill {
    background: rgba(255, 255, 255, 0.04) !important;
}

html.dark .glass-search-pill:focus-within {
    box-shadow: 0 0 0 4px rgba(94, 234, 212, 0.14), 0 12px 30px -18px rgba(0, 0, 0, 0.7) !important;
}

/* רשימת תוצאות החיפוש */
html.dark #resultsListCard,
html.dark #resultsListCard:hover {
    background: var(--bb-card) !important;
}

.bb-result-item:hover,
.bb-result-item:focus-visible {
    background: var(--bb-brand-soft);
    outline: none;
}

html.dark .bb-result-item:hover,
html.dark .bb-result-item:focus-visible {
    background: rgba(94, 234, 212, 0.10);
}

/* פרסומת תחתונה — בתחתית האתר, ובנייד מתחת לפס הניווט */
.bb-bottom-ad {
    display: block;
    width: 100%;
    max-width: 62rem;
    margin: 0 auto 1.5rem;
    padding: 0 1rem;
    contain: none;
}

@media (max-width: 767px) {
    body.has-bottom-ad .bb-bottom-ad {
        position: fixed;
        inset-inline: 0;
        bottom: 0;
        z-index: 44;
        max-width: none;
        margin: 0;
        padding: 0.25rem 0.4rem calc(0.25rem + env(safe-area-inset-bottom, 0px));
        background: var(--bb-card);
        border-top: 1px solid var(--bb-line);
        box-shadow: 0 -12px 28px -22px rgba(6, 10, 18, 0.85);
    }

    body.has-bottom-ad .bb-bottom-ad .ad-slot__label {
        font-size: 9px;
        margin-bottom: 2px;
    }

    body.has-bottom-ad .bb-bottom-ad .ad-slot__inner {
        min-height: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
    }

    body.has-bottom-ad .bb-mobile-bar {
        bottom: var(--bb-bottom-ad-h, 0px);
        padding-bottom: 0.35rem;
    }

    body.has-bottom-ad.has-mobile-bar {
        padding-bottom: calc(3.6rem + var(--bb-bottom-ad-h, 0px) + env(safe-area-inset-bottom, 0px));
    }
}

/* פס תחתון לנייד — ניווט מהיר */
.bb-mobile-bar {
    display: none;
}

@media (max-width: 767px) {
    .bb-mobile-bar {
        position: fixed;
        inset-inline: 0;
        bottom: 0;
        z-index: 45;
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 0.35rem 0.4rem calc(0.35rem + env(safe-area-inset-bottom, 0px));
        background: var(--bb-card);
        border-top: 1px solid var(--bb-line);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
    }

    .bb-mobile-bar a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        font-size: 0.66rem;
        font-weight: 600;
        color: var(--bb-text-2);
        padding: 0.35rem 0.55rem;
        border-radius: 10px;
        text-decoration: none;
        min-width: 60px;
    }

    .bb-mobile-bar a .material-symbols-outlined {
        font-size: 21px;
    }

    .bb-mobile-bar a.is-active,
    .bb-mobile-bar a:hover {
        color: var(--bb-brand);
        background: var(--bb-brand-soft);
    }

    body.has-mobile-bar {
        padding-bottom: calc(3.6rem + env(safe-area-inset-bottom, 0px));
    }
}

/* ── 8. נגישות ────────────────────────────────────────────────────────── */

:focus-visible {
    outline: 2px solid var(--bb-brand);
    outline-offset: 2px;
    border-radius: 6px;
}

@media print {
    .ad-slot,
    .bb-mobile-bar,
    header,
    footer {
        display: none !important;
    }
}
