/* IslamicWebs v9 — MOBILE-FIRST. Base = mobile. min-width breakpoints ONLY. */
:root {
    --bg: #FAF7F2;
    --surface: #E8DFD3;
    --card: #FFFFFF;
    --ink: #2B1D14;
    --ink-soft: #5A4636;
    --copper: #B87333;
    --copper-dark: #96601F;
    --line: #D8C9B8;
    --ok: #2E6B3A;
    --err: #A63226;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(43, 29, 20, 0.08);
    --max: 72rem;
    --max-narrow: 46rem;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, "Segoe UI", Tahoma, Arial, sans-serif;
    line-height: 1.7;
}
h1, h2, h3 {
    font-family: Georgia, "Traditional Arabic", "Simplified Arabic", "Times New Roman", serif;
    line-height: 1.3;
    color: var(--ink);
}
a { color: var(--copper-dark); }
a:hover, a:focus { color: var(--copper); }
img { max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; }
button, a { min-height: 44px; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
.skip-link { position: absolute; inset-inline-start: 1rem; top: -100px; background: var(--ink); color: #fff; padding: .5rem 1rem; z-index: 100; }
.skip-link:focus { top: .5rem; }

/* ---------- Header ---------- */
.site-header { background: var(--bg); border-bottom: 2px solid var(--copper); }
.utility-bar { background: var(--surface); }
.utility-inner {
    max-width: var(--max);
    margin-inline: auto;
    padding: .5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.search-form { display: flex; gap: .5rem; width: 100%; }
.search-form input[type="search"] {
    flex: 1; min-width: 0; padding: .6rem .75rem;
    border: 1px solid var(--line); border-radius: 8px; background: var(--card);
}
.search-form button, .lang-button {
    padding: .6rem 1rem; border: 1px solid var(--copper); border-radius: 8px;
    background: var(--card); color: var(--ink);
}
.lang-switcher { position: relative; }
.lang-switcher .dropdown-list {
    list-style: none; margin: .25rem 0 0; padding: .25rem 0;
    position: absolute; inset-inline-end: 0; z-index: 50; min-width: 10rem;
    background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
}
.lang-switcher .dropdown-list a { display: block; padding: .6rem 1rem; text-decoration: none; color: var(--ink); }
.lang-switcher .dropdown-list a[aria-current="true"] { font-weight: 700; }

.brand { text-align: center; padding: 1.25rem 1rem .75rem; }
.brand-link { text-decoration: none; display: inline-block; }
.brand-name { display: block; font-family: Georgia, serif; font-size: 2rem; font-weight: 700; color: var(--ink); letter-spacing: .02em; }
.brand-tagline { display: block; color: var(--ink-soft); font-size: 1rem; margin-top: .25rem; }

/* ---------- Navigation: MOBILE base = hamburger + accordion ---------- */
.main-nav { max-width: var(--max); margin-inline: auto; padding: 0 1rem .75rem; }
.hamburger {
    display: block; width: 100%; padding: .7rem 1rem;
    background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
    font-weight: 700; color: var(--ink); text-align: start;
}
.nav-list {
    list-style: none; margin: .5rem 0 0; padding: 0;
    display: none; flex-direction: column; gap: .25rem;
}
.nav-list.open { display: flex; }
.nav-item { position: relative; border-bottom: 1px solid var(--line); }
.nav-link { display: block; padding: .8rem .25rem; text-decoration: none; color: var(--ink); font-weight: 600; }
.submenu-toggle {
    position: absolute; inset-inline-end: .25rem; top: .35rem;
    width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 8px;
    background: var(--card); color: var(--copper-dark); font-size: 1.25rem; line-height: 1;
}
.submenu { list-style: none; margin: 0; padding: 0 0 .5rem 1rem; display: none; }
.submenu.open { display: block; }
.submenu a { display: block; padding: .7rem .25rem; text-decoration: none; color: var(--ink-soft); }
[dir="rtl"] .submenu { padding: 0 1rem .5rem 0; }

/* ---------- Main ---------- */
.page-main { max-width: var(--max); margin-inline: auto; padding: 1rem; }
.content-narrow { max-width: var(--max-narrow); margin-inline: auto; }
.content-wide { max-width: var(--max); margin-inline: auto; }
.breadcrumbs { font-size: .9rem; color: var(--ink-soft); margin-bottom: 1rem; }
.breadcrumbs a { color: var(--copper-dark); }

.hero { text-align: center; padding: 1.5rem 0 2rem; }
.hero h1 { font-size: 2rem; margin: 0 0 .75rem; }
.hero-sub { font-size: 1.1rem; color: var(--ink-soft); max-width: 38rem; margin: 0 auto 1.5rem; }
.hero-actions { display: flex; flex-direction: column; gap: .75rem; align-items: stretch; }
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: .8rem 1.5rem; border-radius: 8px; text-decoration: none;
    font-weight: 700; border: 2px solid var(--copper);
}
.btn-primary { background: var(--copper); color: #fff; }
.btn-primary:hover, .btn-primary:focus { background: var(--copper-dark); color: #fff; }
.btn-secondary { background: transparent; color: var(--copper-dark); }

.tools-section, .categories-section { padding: 1rem 0; }
.section-sub { color: var(--ink-soft); }
.card-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.tool-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1.25rem; display: flex; flex-direction: column; gap: .5rem;
}
.tool-card h2, .tool-card h3 { margin: 0; font-size: 1.25rem; }
.tool-card h2 a, .tool-card h3 a { text-decoration: none; color: var(--ink); }
.tool-card p { margin: 0; color: var(--ink-soft); flex: 1; }
.icon-chip {
    display: inline-flex; align-items: center; justify-content: center;
    width: 2.75rem; height: 2.75rem; border-radius: 50%;
    background: var(--surface); color: var(--copper-dark); font-weight: 700; font-size: 1.25rem;
}
.card-link { color: var(--copper-dark); font-weight: 700; }
.categories-row { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .75rem; }
.categories-row a {
    display: inline-flex; align-items: center; min-height: 44px; padding: .5rem 1.25rem;
    background: var(--surface); border-radius: 999px; text-decoration: none; color: var(--ink); font-weight: 600;
}
.assistant-banner {
    background: var(--surface); border-radius: var(--radius);
    padding: 1.5rem 1rem; text-align: center; margin: 1.5rem 0;
}
.assistant-banner h2 { margin-top: 0; }

/* ---------- Forms / results / chat ---------- */
.calc-form { display: flex; flex-direction: column; gap: 1rem; margin: 1.5rem 0; }
.calc-form label { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; }
.calc-form label.check-label { flex-direction: row; align-items: center; gap: .5rem; }
.calc-form input, .calc-form select, .calc-form textarea, .chat-form input {
    width: 100%; padding: .7rem .75rem; border: 1px solid var(--line);
    border-radius: 8px; background: var(--card); color: var(--ink);
}
.calc-form button[type="submit"] { align-self: flex-start; }
.result-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin: 1.5rem 0; }
.result-table { width: 100%; border-collapse: collapse; }
.result-table th, .result-table td { text-align: start; padding: .7rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.result-table th { font-weight: 600; }
.highlight-row th, .highlight-row td { font-size: 1.15rem; color: var(--copper-dark); }
.result-note { color: var(--ink-soft); font-size: .95rem; }
.alert { border-radius: 8px; padding: 1rem; }
.alert-error { background: #FBECEA; border: 1px solid var(--err); color: var(--err); }
.alert-ok { background: #E9F4EC; border: 1px solid var(--ok); color: var(--ok); }
.inline-form { display: inline-block; }
.inline-form select { padding: .4rem; }

.chat-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.chat-log { min-height: 12rem; display: flex; flex-direction: column; gap: .75rem; margin-bottom: 1rem; }
.chat-msg { padding: .75rem 1rem; border-radius: 10px; max-width: 90%; }
.chat-msg.user { background: var(--surface); align-self: flex-end; }
.chat-msg.assistant { background: var(--bg); border: 1px solid var(--line); align-self: flex-start; }
.chat-form { display: flex; gap: .5rem; }
.chat-form input { flex: 1; min-width: 0; }
.chat-hint, .chat-disclaimer { color: var(--ink-soft); font-size: .9rem; }
.search-page-form { display: flex; gap: .5rem; margin: 1rem 0; }
.search-page-form input { flex: 1; min-width: 0; padding: .7rem .75rem; border: 1px solid var(--line); border-radius: 8px; }

/* ---------- Ads (only rendered when a verified slot exists) ---------- */
.ad-slot { margin: 2rem 0; min-height: 90px; }
.ad-label { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); margin: 0 0 .25rem; text-align: center; }

/* ---------- Footer ---------- */
.site-footer { background: var(--ink); color: #F3EDE4; margin-top: 2rem; }
.footer-grid {
    max-width: var(--max); margin-inline: auto; padding: 2rem 1rem 1rem;
    display: grid; grid-template-columns: 1fr; gap: 1.5rem;
}
.footer-col h2 { color: #F3EDE4; font-size: 1.1rem; margin-top: 0; }
.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li { margin-bottom: .25rem; }
.footer-col a { color: #E8DFD3; text-decoration: none; display: inline-block; padding: .35rem 0; }
.footer-col a:hover { color: #fff; text-decoration: underline; }
.footer-note { color: #CBBFAF; font-size: .9rem; }
.footer-bottom { border-top: 1px solid #4A382A; text-align: center; padding: 1rem; font-size: .9rem; color: #CBBFAF; }

/* ---------- TABLET and up ---------- */
@media (min-width: 640px) {
    .utility-inner { flex-direction: row; justify-content: space-between; align-items: center; }
    .search-form { width: auto; min-width: 18rem; }
    .hero h1 { font-size: 2.6rem; }
    .hero-actions { flex-direction: row; justify-content: center; }
    .card-grid { grid-template-columns: repeat(2, 1fr); }
    .footer-grid { grid-template-columns: repeat(2, 1fr); }
    .chat-msg { max-width: 75%; }
}

/* ---------- DESKTOP and up: horizontal nav with dropdowns ---------- */
@media (min-width: 1024px) {
    .hamburger { display: none; }
    .nav-list { display: flex; flex-direction: row; gap: 1.5rem; margin: 0; }
    .nav-item { border-bottom: none; }
    .nav-link { padding: .8rem 0; }
    .submenu-toggle { display: none; }
    .has-children .submenu {
        display: none; position: absolute; inset-inline-start: 0; top: 100%; z-index: 60;
        min-width: 14rem; background: var(--card); border: 1px solid var(--line);
        border-radius: 8px; box-shadow: var(--shadow); padding: .5rem 0;
    }
    .has-children:hover .submenu,
    .has-children:focus-within .submenu,
    .has-children .submenu.open { display: block; }
    .submenu a { padding: .7rem 1rem; }
    .card-grid { grid-template-columns: repeat(3, 1fr); }
    .footer-grid { grid-template-columns: repeat(4, 1fr); }
    .hero h1 { font-size: 3rem; }
}

/* ---------- v10: articles, categories, ads (reserved space, CLS-safe) ---------- */
.ad-slot {
    margin: 2rem 0; min-height: 100px; background: #F3EDE4;
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: .5rem; text-align: center; overflow: hidden;
}
.ad-slot .adsbygoogle { display: block; min-height: 90px; }
.ad-slot-between_cards { min-height: 140px; }
.ad-slot-between_cards .adsbygoogle { min-height: 120px; }
.ad-slot-after_article { min-height: 280px; }
.ad-slot-after_article .adsbygoogle { min-height: 250px; }
.ad-slot-matched_content_search, .ad-slot-matched_content_advertising { min-height: 280px; }
.ad-slot-matched_content_search .adsbygoogle, .ad-slot-matched_content_advertising .adsbygoogle { min-height: 250px; }

.article-page h1 { font-size: 1.9rem; }
.article-meta { color: var(--ink-soft); font-size: .9rem; }
.article-meta a { color: var(--copper-dark); }
.article-body { font-size: 1.05rem; }
.article-body h2 { font-size: 1.45rem; margin: 2rem 0 .75rem; }
.article-body h3 { font-size: 1.2rem; margin: 1.5rem 0 .5rem; }
.article-body p { margin: 0 0 1rem; }
.article-body ul, .article-body ol { margin: 0 0 1.25rem; padding-inline-start: 1.5rem; }
.article-body li { margin-bottom: .4rem; }
.article-body table { width: 100%; border-collapse: collapse; margin: 1rem 0; display: block; overflow-x: auto; }
.article-body th, .article-body td { border: 1px solid var(--line); padding: .6rem; text-align: start; vertical-align: top; }
.article-body img { max-width: 100%; height: auto; border-radius: 8px; }
.youtube-cta { background: var(--surface); border: 1px solid var(--line); border-inline-start: 4px solid var(--copper); border-radius: var(--radius); padding: 1rem 1.25rem; margin: 2rem 0 0; }
.youtube-cta h2 { font-size: 1.25rem; margin: 0 0 .5rem; }
.youtube-cta p { margin: 0; }
.youtube-cta a { color: var(--copper-dark); font-weight: 700; }
.article-body blockquote { border-inline-start: 3px solid var(--copper); margin: 1rem 0; padding: .5rem 1rem; color: var(--ink-soft); }
.related-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin: 2rem 0; }
.related-block h2 { margin: 0 0 .75rem; font-size: 1.2rem; }
.related-block ul { margin: 0; padding-inline-start: 1.25rem; }
.related-block li { margin-bottom: .5rem; }
.article-cta { margin: 2rem 0; }
.article-card h4 { margin: 0; font-size: 1.1rem; }
.article-card h4 a { text-decoration: none; color: var(--ink); }
.latest-section { padding: 1rem 0; }
.latest-category { font-size: 1.3rem; margin: 1.5rem 0 .75rem; }
.latest-category a { color: var(--ink); text-decoration: none; }
.search-results { display: flex; flex-direction: column; gap: 1rem; margin: 1.5rem 0; }
.search-result { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; }
.search-result h3 { margin: 0 0 .25rem; font-size: 1.1rem; }
.search-result p { margin: 0; color: var(--ink-soft); }
.pagination-wrap { margin: 2rem 0; }
.pagination-wrap nav { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: center; }
.pagination-wrap a, .pagination-wrap span { display: inline-flex; align-items: center; min-height: 44px; padding: .4rem .9rem; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--ink); background: var(--card); }

/* ---------- v11: article cards with thumbnails (horizontal, stacks on mobile) ---------- */
.article-card { display: flex; flex-direction: row; gap: 1rem; align-items: flex-start; }
.article-card-thumb { flex: 0 0 160px; width: 160px; aspect-ratio: 1200 / 630; overflow: hidden; border-radius: 10px; background: var(--surface); }
.article-card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.article-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .5rem; }
.article-card-body h2, .article-card-body h3, .article-card-body h4 { margin: 0; font-size: 1.1rem; }
.article-card-body h2 a, .article-card-body h3 a, .article-card-body h4 a { text-decoration: none; color: var(--ink); }
.article-card-body p { margin: 0; }
.article-featured { margin: 1.5rem 0; aspect-ratio: 1200 / 630; overflow: hidden; border-radius: 12px; background: var(--surface); }
.article-featured img { width: 100%; height: 100%; object-fit: cover; display: block; }
.related-section { margin: 2.5rem 0 0; }
.related-section h2 { font-size: 1.4rem; margin: 0 0 1rem; }
@media (max-width: 640px) {
    .article-card { flex-direction: column; }
    .article-card-thumb { width: 100%; flex: none; aspect-ratio: 1200 / 630; }
}
