:root {
    --green-900: #0b3d27;
    --green-800: #0d4a2f;
    --green-700: #12633f;
    --green-600: #1a7a4a;
    --green-100: #e3f1e8;
    --green-50: #f1f8f3;
    --red: #c8323a;
    --bg: #f7f6f1;
    --surface: #ffffff;
    --text: #17201b;
    --muted: #5a6660;
    --border: #e3e1d8;
    --shadow: 0 1px 2px rgba(11, 61, 39, .06), 0 6px 20px rgba(11, 61, 39, .08);
    --radius: 16px;
}
@media (prefers-color-scheme: dark) {
    :root {
        --green-100: #173a28;
        --green-50: #12261b;
        --bg: #0e1612;
        --surface: #16211b;
        --text: #e9efe9;
        --muted: #9aaba1;
        --border: #263329;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: "Segoe UI", "Noto Sans Arabic", "Noto Kufi Arabic", Tahoma, system-ui, sans-serif;
    line-height: 1.7;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
p { margin: 0; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* ---------- Top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    background: rgba(13, 74, 47, .96);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    backdrop-filter: saturate(1.4) blur(10px);
    color: #fff;
}
.topbar-in { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.brand img { border-radius: 9px; }
.topbar-cta {
    background: #fff; color: var(--green-800);
    text-decoration: none; font-weight: 700; font-size: .9rem;
    padding: 8px 16px; border-radius: 999px;
    transition: transform .15s;
}
.topbar-cta:active { transform: scale(.96); }

/* ---------- Hero ---------- */
.hero {
    position: relative; overflow: hidden;
    background:
        radial-gradient(1200px 500px at 85% -10%, #1f8a55 0%, transparent 60%),
        linear-gradient(170deg, var(--green-800) 0%, var(--green-900) 100%);
    color: #fff;
    padding: 28px 0 40px;
}
.hero-in { display: grid; gap: 28px; align-items: center; }
.hero h1 { font-size: clamp(1.7rem, 6.4vw, 2.9rem); font-weight: 800; letter-spacing: -.01em; }
.hl {
    display: inline-block; background: var(--red); color: #fff;
    padding: 0 .3em; border-radius: 10px; transform: rotate(-2deg);
}
.sub { margin-top: 14px; font-size: 1.05rem; color: rgba(255, 255, 255, .86); max-width: 34em; }
.sub strong { color: #fff; }

.cta-row { margin-top: 24px; display: flex; flex-direction: column; gap: 16px; align-items: stretch; }

.play-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 12px;
    background: #000; color: #fff; text-decoration: none;
    padding: 12px 26px; border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .25);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
    transition: transform .15s, box-shadow .15s;
    min-height: 64px;
}
.play-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(0, 0, 0, .4); }
.play-btn:active { transform: scale(.98); }
.play-logo { width: 30px; height: 30px; flex: none; }
.play-txt { display: flex; flex-direction: column; line-height: 1.15; text-align: right; }
.play-txt small { font-size: .78rem; opacity: .85; }
.play-txt b { font-size: 1.4rem; font-weight: 700; direction: ltr; text-align: right; font-family: system-ui, "Segoe UI", Roboto, sans-serif; }

.trust { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center; font-size: .9rem; color: rgba(255, 255, 255, .9); }
.trust li { display: flex; align-items: center; gap: 6px; }
.trust svg { width: 18px; height: 18px; fill: none; stroke: #6ee7a0; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

.hero-media { display: none; }
.hero-shot {
    width: 290px; border-radius: 28px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, .45);
    border: 1px solid rgba(255, 255, 255, .15);
}
.qr-card { display: none; }

/* ---------- Sections ---------- */
.block { padding: 44px 0; }
.block.alt { background: var(--surface); border-block: 1px solid var(--border); }
.title { font-size: 1.5rem; font-weight: 800; margin-bottom: 4px; }

/* ---------- Grade picker ---------- */
.stage { margin: 18px 0 8px; font-size: .95rem; color: var(--green-700); }
@media (prefers-color-scheme: dark) { .stage { color: #7fd3a3; } }
.grades { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grade {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 92px; padding: 12px 6px;
    background: var(--surface); color: var(--text); text-decoration: none;
    border: 1px solid var(--border); border-radius: 14px;
    box-shadow: 0 1px 2px rgba(11, 61, 39, .05);
    transition: transform .15s, border-color .15s, background .15s;
}
@media (prefers-color-scheme: dark) { .grade b { color: #5fd08f !important; } }
.grade b { font-size: 1.7rem; font-weight: 800; color: var(--green-600); line-height: 1.1; }
.grade span { font-size: .9rem; font-weight: 600; }
.grade:hover { border-color: var(--green-600); transform: translateY(-2px); }
.grade:active { transform: scale(.97); background: var(--green-100); }

/* ---------- Screenshots ---------- */
.block.alt { padding: 24px 0 8px; }
.shots {
    display: flex; gap: 14px; overflow-x: auto;
    scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
    padding: 4px 16px 18px; scrollbar-width: thin;
    max-width: 1080px; margin: 0 auto;
}
.shots img {
    flex: none; width: 62vw; max-width: 230px; scroll-snap-align: center;
    border-radius: 20px; border: 1px solid var(--border); box-shadow: var(--shadow);
    background: var(--green-100);
}

/* ---------- FAQ ---------- */
.faq { display: grid; gap: 8px; max-width: 760px; }
.faq details { background: var(--bg); border: 1px solid var(--border); border-radius: 14px; }
.faq summary {
    cursor: pointer; list-style: none;
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 14px 16px; font-weight: 700; font-size: .98rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
    content: ""; flex: none; width: 10px; height: 10px;
    border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
    transform: rotate(45deg); transition: transform .2s; margin-top: -4px;
}
.faq details[open] summary::after { transform: rotate(-135deg); margin-top: 4px; }
.faq details p { padding: 0 16px 14px; color: var(--muted); font-size: .94rem; }

/* ---------- Final CTA ---------- */
.final {
    background: linear-gradient(170deg, var(--green-800), var(--green-900));
    color: #fff; text-align: center; padding: 48px 0 56px;
}
.final-in { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.final img { border-radius: 18px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }
.final h2 { font-size: 1.5rem; font-weight: 800; margin-top: 6px; }
.final .play-btn { margin-top: 8px; }

/* ---------- Footer ---------- */
footer { padding: 24px 0 110px; text-align: center; font-size: .85rem; }
footer p + p { margin-top: 4px; }
.muted { color: var(--muted); }

/* ---------- Sticky mobile CTA ---------- */
.sticky-cta {
    position: fixed; z-index: 30; inset-inline: 10px; bottom: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    display: flex; align-items: center; gap: 10px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 18px;
    padding: 8px 8px 8px 8px; padding-inline-start: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
    transform: translateY(0); transition: transform .25s ease, opacity .25s;
}
.sticky-cta.hide { transform: translateY(140%); opacity: 0; pointer-events: none; }
.sticky-cta img { border-radius: 10px; flex: none; }
.sticky-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.sticky-txt b { font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sticky-txt span { font-size: .75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sticky-cta a {
    flex: none; background: var(--green-600); color: #fff; text-decoration: none;
    font-weight: 800; padding: 11px 22px; border-radius: 12px; font-size: 1rem;
}
.sticky-cta a:active { transform: scale(.97); }

/* ---------- Grade page ---------- */
.hero-grade { padding: 18px 0 30px; }
.back { display: inline-block; color: rgba(255, 255, 255, .8); text-decoration: none; font-size: .9rem; margin-bottom: 10px; }
.hint { color: var(--muted); font-size: .88rem; margin-bottom: 14px; }

.books { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 10px; }
.book {
    all: unset; box-sizing: border-box; cursor: pointer;
    display: flex; flex-direction: column; gap: 6px; width: 100%;
    -webkit-tap-highlight-color: transparent;
}
.book img {
    width: 100%; aspect-ratio: 3 / 4.1; object-fit: cover; object-position: top;
    background: #fff; border-radius: 4px 10px 10px 4px;
    border: 1px solid var(--border);
    box-shadow: -3px 0 0 rgba(0, 0, 0, .06) inset, 0 2px 4px rgba(11, 61, 39, .08), 0 8px 18px rgba(11, 61, 39, .1);
    transition: transform .15s;
}
.book:hover img { transform: translateY(-3px); }
.book:active img { transform: scale(.97); }
.book:focus-visible img { outline: 3px solid #f5b400; outline-offset: 2px; }
.book-name { font-size: .86rem; font-weight: 700; line-height: 1.35; }
.book-meta { font-size: .74rem; color: var(--muted); line-height: 1.3; margin-top: -4px; }
.tag { font-style: normal; font-weight: 700; padding: 0 6px; border-radius: 6px; font-size: .7rem; }
.tag-sci { background: #dbeafe; color: #1e40af; }
.tag-lit { background: #fde2e4; color: #9f1239; }

.branch-switch {
    display: inline-grid; grid-template-columns: 1fr 1fr; gap: 4px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    padding: 4px; margin-bottom: 16px; width: 100%; max-width: 320px;
}
.branch-switch input { position: absolute; opacity: 0; pointer-events: none; }
.branch-switch label {
    text-align: center; padding: 9px 0; border-radius: 10px; cursor: pointer;
    font-weight: 800; color: var(--muted);
}
.branch-switch input:checked + label { background: var(--green-600); color: #fff; }
.branch-switch input:focus-visible + label { outline: 3px solid #f5b400; }
.books.branchable .tag { display: none; }
.branch-switch:has(#br-sci:checked) ~ .books .only-lit,
.branch-switch:has(#br-lit:checked) ~ .books .only-sci { display: none; }

.grade-nav { padding-top: 32px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chips a {
    text-decoration: none; font-size: .88rem; font-weight: 600;
    padding: 7px 14px; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border);
}
.chips a[aria-current] { background: var(--green-600); border-color: var(--green-600); color: #fff; }

/* Cover viewer */
.viewer {
    border: 0; padding: 16px; border-radius: 20px; width: min(92vw, 440px);
    background: var(--surface); color: var(--text); text-align: center;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
}
.viewer::backdrop { background: rgba(5, 20, 12, .72); }
.viewer img {
    width: 100%; max-height: 62vh; object-fit: contain; background: #fff;
    border-radius: 6px; border: 1px solid var(--border); min-height: 200px;
}
.viewer-close {
    all: unset; cursor: pointer; position: absolute; top: 8px; inset-inline-start: 8px;
    width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
    background: rgba(0, 0, 0, .55); color: #fff; font-size: 1rem; z-index: 1;
}
.viewer-title { margin: 12px 0; font-size: .95rem; }
.viewer-title span { color: var(--muted); }
.viewer-cta {
    display: block; background: var(--green-600); color: #fff; text-decoration: none;
    font-weight: 800; padding: 14px; border-radius: 14px; font-size: 1.02rem;
}

/* Homepage tile counts */
.grade small { font-size: .72rem; color: var(--muted); }

@media (min-width: 560px) {
    .books { grid-template-columns: repeat(4, 1fr); gap: 20px 14px; }
}
@media (min-width: 900px) {
    .books { grid-template-columns: repeat(6, 1fr); }
    .hero-grade { padding: 32px 0 44px; }
}

/* ---------- Focus ---------- */
a:focus-visible, summary:focus-visible, .shots:focus-visible { outline: 3px solid #f5b400; outline-offset: 3px; }

/* ---------- Tablet / desktop ---------- */
@media (min-width: 560px) {
    .grades { grid-template-columns: repeat(6, 1fr); }
    .cta-row { flex-direction: row; align-items: center; flex-wrap: wrap; }
    .trust { justify-content: flex-start; }
}
@media (min-width: 900px) {
    .hero { padding: 56px 0 72px; }
    .hero-in { grid-template-columns: 1.25fr 1fr; gap: 48px; }
    .hero-media { display: flex; align-items: center; justify-content: center; gap: 22px; position: relative; }
    .qr-card {
        display: flex; flex-direction: column; align-items: center; gap: 8px;
        background: #fff; color: var(--green-900); border-radius: 18px;
        padding: 14px; width: 168px; text-align: center; font-size: .8rem; font-weight: 600;
        box-shadow: 0 20px 40px rgba(0, 0, 0, .3);
        align-self: flex-end; margin-bottom: 30px;
    }
    .block.alt { padding: 24px 0 8px; }
.shots { justify-content: center; }
    .shots img { width: 190px; }
    .block { padding: 64px 0; }
    .title { font-size: 1.85rem; }
    .grade { min-height: 104px; }
    .stages { display: grid; grid-template-columns: 1fr 1fr; column-gap: 10px; }
    .stage-group:first-child { grid-column: 1 / -1; }
    .stage-group:not(:first-child) .grades { grid-template-columns: repeat(3, 1fr); }
    .sticky-cta { display: none; }
    footer { padding-bottom: 32px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; scroll-behavior: auto !important; }
}
