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

:root {
    --bg: #03100c;
    --bg-2: #071b14;
    --panel: rgba(8, 31, 23, 0.88);
    --panel-soft: rgba(255, 255, 255, 0.035);
    --panel-border: rgba(231, 205, 137, 0.2);
    --gold: #e4cb8b;
    --gold-strong: #f4dda0;
    --text: #f8f4e8;
    --muted: #afc2b9;
    --danger: #ffd0d0;
    --shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
}

* { box-sizing: border-box; }

html {
    direction: rtl;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--text);
    background:
        radial-gradient(circle at 82% 6%, rgba(36, 112, 81, 0.22), transparent 30%),
        radial-gradient(circle at 8% 88%, rgba(201, 169, 81, 0.1), transparent 26%),
        linear-gradient(145deg, #020806, var(--bg) 45%, var(--bg-2));
    font-family: "Cairo", sans-serif;
    text-align: right;
}

button, input { font: inherit; }
button { color: inherit; }

.page-glow {
    position: fixed;
    width: 30rem;
    height: 30rem;
    border-radius: 50%;
    filter: blur(110px);
    opacity: 0.1;
    pointer-events: none;
}
.glow-one { top: -14rem; right: -10rem; background: #2b9b70; }
.glow-two { bottom: -14rem; left: -10rem; background: #c9a951; }

.site-header,
main {
    width: min(1320px, calc(100% - 34px));
    margin-inline: auto;
}

.site-header {
    min-height: 88px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    text-decoration: none;
}

.brand-mark {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border: 1px solid var(--panel-border);
    border-radius: 15px;
    color: var(--gold);
    background: rgba(255,255,255,0.04);
}

.brand strong,
.brand small { display: block; }
.brand strong { font-family: "Amiri", serif; font-size: 1.34rem; }
.brand small { color: var(--muted); font-size: 0.72rem; }

.about-button,
.back-button,
.load-ayahs-button {
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    padding: 10px 18px;
    background: rgba(255,255,255,0.04);
    cursor: pointer;
    transition: 160ms ease;
}

.about-button:hover,
.back-button:hover,
.load-ayahs-button:hover {
    border-color: rgba(228,203,139,0.48);
    background: rgba(228,203,139,0.1);
}

main { padding-bottom: 70px; }

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 28px;
    padding: 46px 0 38px;
}

.eyebrow {
    margin: 0 0 7px;
    color: var(--gold);
    font-size: 0.77rem;
    letter-spacing: 0.06em;
}

.hero h1 {
    margin: 0;
    max-width: 720px;
    font-family: "Amiri", serif;
    font-size: clamp(3rem, 6vw, 5.6rem);
    line-height: 0.98;
}

.hero h1 span { color: var(--gold-strong); }

.hero-text {
    max-width: 680px;
    margin: 18px 0 0;
    color: var(--muted);
    line-height: 1.9;
}

.hero-stat {
    min-width: 270px;
    padding: 18px 20px;
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    background: rgba(255,255,255,0.03);
}

.hero-stat span,
.hero-stat strong { display: block; }
.hero-stat span { color: var(--muted); font-size: 0.72rem; }
.hero-stat strong { margin-top: 6px; color: var(--gold-strong); font-size: 0.86rem; }

.explorer-shell {
    direction: ltr;
    display: grid;
    grid-template-columns: minmax(360px, 0.82fr) minmax(0, 1.18fr);
    grid-template-areas: "panel book";
    gap: 22px;
    align-items: stretch;
}

.book-stage,
.topic-panel {
    direction: rtl;
    min-height: 680px;
    border: 1px solid var(--panel-border);
    border-radius: 28px;
    background:
        linear-gradient(145deg, rgba(255,255,255,0.045), rgba(255,255,255,0.015)),
        var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.book-stage {
    grid-area: book;
    position: relative;
    overflow: hidden;
    padding: 24px;
}

.topic-panel {
    grid-area: panel;
    padding: 26px;
    overflow: auto;
}

.book-heading,
.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.book-heading h2,
.panel-heading h2,
.panel-empty h2 {
    margin: 3px 0 0;
    font-family: "Amiri", serif;
    font-size: 2rem;
}

.selection-hint {
    padding: 7px 11px;
    border: 1px solid rgba(228,203,139,0.18);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(228,203,139,0.055);
    font-size: 0.68rem;
}

.book-visual {
    position: relative;
    min-height: 310px;
    display: grid;
    place-items: center;
}

.book-halo {
    position: absolute;
    width: 360px;
    height: 250px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(240,215,150,0.18), rgba(31,102,75,0.06) 50%, transparent 72%);
    filter: blur(8px);
}

.quran-book {
    position: relative;
    z-index: 2;
    width: min(430px, 82%);
    aspect-ratio: 1.7;
    display: grid;
    grid-template-columns: 1fr 14px 1fr;
    transform: perspective(1200px) rotateX(7deg);
}

.book-cover {
    position: relative;
    border: 2px solid #b89542;
    background:
        radial-gradient(circle at center, rgba(255,255,255,0.06), transparent 42%),
        linear-gradient(145deg, #164a39, #08261d);
    box-shadow:
        inset 0 0 0 8px #0b3327,
        inset 0 0 0 10px rgba(224,190,104,0.65),
        0 24px 44px rgba(0,0,0,0.42);
}

.book-cover-left { border-radius: 18px 5px 5px 18px; transform: skewY(-2deg); }
.book-cover-right {
    border-radius: 5px 18px 18px 5px;
    transform: skewY(2deg);
    display: grid;
    place-items: center;
    text-align: center;
}

.book-spine {
    background: linear-gradient(#c9a451, #6a4d18, #c9a451);
    box-shadow: 0 0 20px rgba(232,198,110,0.35);
}

.cover-frame {
    position: absolute;
    inset: 22px;
    border: 1px solid rgba(229,196,108,0.72);
    border-radius: 42% 12%;
}

.cover-title {
    position: relative;
    z-index: 2;
    font-family: "Amiri", serif;
    font-size: clamp(1.5rem, 3vw, 2.35rem);
    color: #f0d990;
}

.cover-ornament {
    position: absolute;
    bottom: 24%;
    color: #d4b45e;
    font-size: 1.5rem;
}

.root-topics {
    position: relative;
    z-index: 3;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.root-topic {
    --topic-color: #d6b76b;
    min-width: 0;
    min-height: 86px;
    display: grid;
    grid-template-columns: 42px minmax(0,1fr) auto;
    align-items: center;
    gap: 11px;
    padding: 13px;
    text-align: right;
    border: 1px solid color-mix(in srgb, var(--topic-color), transparent 65%);
    border-radius: 17px;
    background: rgba(255,255,255,0.025);
    cursor: pointer;
    transition: 160ms ease;
}

.root-topic:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--topic-color), transparent 28%);
    background: rgba(255,255,255,0.045);
}

.root-topic:focus-visible {
    outline: 2px solid var(--topic-color);
    outline-offset: 2px;
}

.root-topic.is-active {
    border-color: var(--topic-color);
    background: color-mix(in srgb, var(--topic-color), transparent 90%);
    box-shadow: inset -4px 0 0 var(--topic-color);
}

.root-topic-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    color: var(--topic-color);
    background: color-mix(in srgb, var(--topic-color), transparent 90%);
}

.root-topic-copy { min-width: 0; }
.root-topic-name,
.root-topic small { display: block; }
.root-topic-name { font-weight: 700; }
.root-topic small { margin-top: 4px; color: var(--muted); font-size: 0.67rem; }
.root-topic-arrow { color: var(--topic-color); }

.loading-card {
    padding: 17px;
    border-radius: 16px;
    color: var(--muted);
    text-align: center;
    background: rgba(0,0,0,0.15);
}

.error-card {
    color: var(--danger);
    border: 1px solid rgba(255,120,120,0.25);
}

.panel-empty {
    min-height: 620px;
    display: grid;
    place-content: center;
    justify-items: center;
    text-align: center;
}

.panel-icon { color: var(--gold); font-size: 2rem; }
.panel-empty p,
.panel-description { color: var(--muted); line-height: 1.85; }

.panel-heading {
    justify-content: flex-start;
    margin-bottom: 18px;
}

.panel-topic-icon {
    width: 50px;
    height: 50px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border: 1px solid var(--panel-border);
    border-radius: 15px;
    color: var(--gold);
    background: rgba(228,203,139,0.09);
}

.topic-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 18px;
}

.topic-breadcrumb button {
    padding: 5px 9px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255,255,255,0.025);
    cursor: pointer;
}

.child-topic-list,
.ayah-list { display: grid; gap: 10px; }

.child-topic {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 15px 16px;
    text-align: right;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    background: rgba(255,255,255,0.03);
    cursor: pointer;
    transition: 150ms ease;
}

.child-topic:hover {
    transform: translateX(-3px);
    border-color: var(--panel-border);
    background: rgba(228,203,139,0.07);
}

.child-topic strong,
.child-topic small { display: block; }
.child-topic small { margin-top: 4px; color: var(--muted); font-size: 0.72rem; }
.child-arrow { color: var(--gold); }

.leaf-topic-card {
    padding: 25px 18px;
    text-align: center;
    border: 1px dashed var(--panel-border);
    border-radius: 19px;
    background: rgba(255,255,255,0.02);
}

.leaf-topic-card h3 {
    margin: 7px 0;
    font-family: "Amiri", serif;
    font-size: 1.65rem;
}

.leaf-topic-card p { color: var(--muted); line-height: 1.8; }

.back-button { margin-top: 18px; }

.ayah-card {
    margin: 0;
    padding: 18px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 18px;
    background: rgba(255,255,255,0.03);
}

.ayah-text {
    margin: 0;
    font-family: "Amiri", serif;
    font-size: 1.45rem;
    line-height: 2.05;
}

.ayah-card footer { margin-top: 11px; color: var(--gold); font-size: 0.77rem; }

.ayah-section,
.related-section { margin-top: 22px; }

.related-section {
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.section-title-row {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 13px;
}

.section-title-row h3 {
    margin: 0;
    font-family: "Amiri", serif;
    font-size: 1.42rem;
}

.section-symbol {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid var(--panel-border);
    border-radius: 13px;
    color: var(--gold);
    background: rgba(228,203,139,0.08);
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 9px;
}

.related-entity {
    --entity-color: #d6b76b;
    width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: 36px minmax(0,1fr) auto;
    align-items: center;
    gap: 9px;
    padding: 12px;
    text-align: right;
    border: 1px solid color-mix(in srgb, var(--entity-color), transparent 65%);
    border-radius: 15px;
    background: rgba(255,255,255,0.025);
    cursor: pointer;
}

.related-icon {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    color: var(--entity-color);
    background: color-mix(in srgb, var(--entity-color), transparent 90%);
}

.related-entity strong,
.related-entity small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.related-entity small { color: var(--muted); font-size: 0.65rem; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
}

.modal-backdrop[hidden] { display: none; }

.modal-card {
    position: relative;
    width: min(560px, 100%);
    padding: 32px;
    border: 1px solid var(--panel-border);
    border-radius: 26px;
    background: #09251d;
    box-shadow: var(--shadow);
}

.modal-card h2 { font-family: "Amiri", serif; font-size: 2rem; }
.modal-card p { color: var(--muted); line-height: 1.9; }

.modal-close {
    position: absolute;
    top: 14px;
    left: 14px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    color: var(--text);
    background: rgba(255,255,255,0.08);
    cursor: pointer;
}

.modal-open { overflow: hidden; }

@media (max-width: 980px) {
    .hero { grid-template-columns: 1fr; }
    .hero-stat { min-width: 0; }
    .explorer-shell {
        grid-template-columns: 1fr;
        grid-template-areas:
            "book"
            "panel";
    }
    .book-stage,
    .topic-panel { min-height: auto; }
    .panel-empty { min-height: 300px; }
}

@media (max-width: 660px) {
    .site-header,
    main { width: min(100% - 20px, 1320px); }
    .site-header { min-height: 76px; }
    .brand small { display: none; }
    .hero { padding-top: 25px; }
    .book-stage,
    .topic-panel { padding: 17px; border-radius: 21px; }
    .root-topics,
    .related-grid { grid-template-columns: 1fr; }
    .book-visual { min-height: 245px; }
    .quran-book { width: min(330px, 92%); }
    .selection-hint { display: none; }
}
