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

:root {
    --bg: #04120e;
    --bg-soft: #09251d;
    --panel: rgba(9, 37, 29, 0.74);
    --panel-border: rgba(231, 205, 137, 0.22);
    --gold: #e4cb8b;
    --gold-strong: #f3dc9a;
    --text: #f8f4e8;
    --muted: #b7c9c1;
    --shadow: 0 30px 80px rgba(0, 0, 0, 0.42);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--text);
    background:
        radial-gradient(circle at 50% 10%, rgba(33, 104, 76, 0.28), transparent 35%),
        linear-gradient(145deg, #020a07 0%, var(--bg) 42%, #071b14 100%);
    font-family: "Cairo", sans-serif;
}

button,
input {
    font: inherit;
}

button {
    color: inherit;
}

.page-glow {
    position: fixed;
    width: 30rem;
    height: 30rem;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.12;
    pointer-events: none;
}

.glow-one {
    top: -12rem;
    right: -8rem;
    background: #2b9b70;
}

.glow-two {
    bottom: -12rem;
    left: -8rem;
    background: #c9a951;
}

.site-header {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.brand-mark {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    color: var(--gold);
    background: rgba(255,255,255,0.04);
    box-shadow: inset 0 0 20px rgba(228,203,139,0.08);
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-family: "Amiri", serif;
    font-size: 1.28rem;
}

.brand small {
    color: var(--muted);
    font-size: 0.75rem;
}

.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: 180ms ease;
}

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

main {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding-bottom: 60px;
}

.hero {
    text-align: center;
    max-width: 760px;
    margin: 36px auto 52px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--gold);
    font-size: 0.82rem;
    letter-spacing: 0.08em;
}

.hero h1 {
    margin: 0;
    font-family: "Amiri", serif;
    font-size: clamp(2.8rem, 7vw, 5.8rem);
    line-height: 0.98;
    font-weight: 700;
}

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

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

.explorer-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
    gap: 24px;
    align-items: stretch;
}

.book-stage,
.topic-panel {
    min-height: 620px;
    border: 1px solid var(--panel-border);
    border-radius: 32px;
    background: linear-gradient(145deg, rgba(255,255,255,0.045), rgba(255,255,255,0.018));
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.book-stage {
    position: relative;
    overflow: hidden;
    display: grid;
    place-items: center;
    padding: 32px;
}

.book-stage::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
    background-size: 32px 32px;
    mask-image: radial-gradient(circle, black, transparent 75%);
}

.book-halo {
    position: absolute;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(240,215,150,0.24), rgba(31,102,75,0.08) 48%, transparent 70%);
    filter: blur(8px);
    animation: pulse 4s ease-in-out infinite;
}

.quran-book {
    position: relative;
    width: min(420px, 72vw);
    aspect-ratio: 1.65;
    display: grid;
    grid-template-columns: 1fr 14px 1fr;
    transform: perspective(1200px) rotateX(8deg);
    z-index: 2;
}

.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.45);
}

.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, 4vw, 2.4rem);
    color: #f0d990;
    text-shadow: 0 2px 18px rgba(240,217,144,0.2);
}

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

.root-topics {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
}

.root-topic {
    --angle: calc((360deg / 8) * var(--topic-index));
    position: absolute;
    top: 50%;
    left: 50%;
    width: 138px;
    min-height: 84px;
    padding: 12px;
    transform:
        translate(-50%, -50%)
        rotate(var(--angle))
        translateY(-250px)
        rotate(calc(var(--angle) * -1));
    border: 1px solid color-mix(in srgb, var(--topic-color), transparent 45%);
    border-radius: 22px;
    background: rgba(6, 28, 21, 0.84);
    box-shadow: 0 12px 30px rgba(0,0,0,0.25);
    cursor: pointer;
    pointer-events: auto;
    transition: 180ms ease;
}

.root-topic:hover,
.root-topic:focus-visible,
.root-topic.is-active {
    transform:
        translate(-50%, -50%)
        rotate(var(--angle))
        translateY(-258px)
        rotate(calc(var(--angle) * -1))
        scale(1.06);
    border-color: var(--topic-color);
    background: rgba(13, 54, 41, 0.96);
    outline: none;
}

.root-topic-icon,
.root-topic-name,
.root-topic small {
    display: block;
}

.root-topic-icon {
    color: var(--topic-color);
    font-size: 1.15rem;
}

.root-topic-name {
    margin: 4px 0;
    font-weight: 700;
}

.root-topic small {
    color: var(--muted);
    font-size: 0.68rem;
}

.loading-card {
    position: absolute;
    top: 28px;
    right: 28px;
    left: 28px;
    padding: 16px;
    border-radius: 18px;
    color: var(--muted);
    text-align: center;
    background: rgba(0,0,0,0.18);
}

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

.topic-panel {
    padding: 28px;
    overflow: auto;
}

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

.panel-icon {
    color: var(--gold);
    font-size: 2rem;
}

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

.panel-empty p,
.panel-description {
    color: var(--muted);
    line-height: 1.8;
}

.panel-heading {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.panel-topic-icon {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    color: var(--gold);
    background: rgba(228,203,139,0.1);
    border: 1px solid var(--panel-border);
}

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

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

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

.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: 28px 18px;
    text-align: center;
    border: 1px dashed var(--panel-border);
    border-radius: 20px;
    background: rgba(255,255,255,0.025);
}

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

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

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

.ayah-list {
    display: grid;
    gap: 14px;
}

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

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

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

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

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

.modal-card {
    position: relative;
    width: min(560px, 100%);
    padding: 34px;
    border: 1px solid var(--panel-border);
    border-radius: 28px;
    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;
}

@keyframes pulse {
    0%, 100% { transform: scale(0.96); opacity: 0.78; }
    50% { transform: scale(1.05); opacity: 1; }
}

@media (max-width: 980px) {
    .explorer-shell {
        grid-template-columns: 1fr;
    }

    .book-stage {
        min-height: 720px;
    }

    .topic-panel {
        min-height: 420px;
    }
}

@media (max-width: 720px) {
    .site-header {
        padding-top: 16px;
    }

    .brand small {
        display: none;
    }

    .hero {
        margin-top: 18px;
    }

    .book-stage {
        min-height: 740px;
        padding: 16px;
    }

    .quran-book {
        width: 250px;
    }

    .root-topic {
        width: 116px;
        min-height: 76px;
        transform:
            translate(-50%, -50%)
            rotate(var(--angle))
            translateY(-242px)
            rotate(calc(var(--angle) * -1));
    }

    .root-topic:hover,
    .root-topic:focus-visible,
    .root-topic.is-active {
        transform:
            translate(-50%, -50%)
            rotate(var(--angle))
            translateY(-247px)
            rotate(calc(var(--angle) * -1))
            scale(1.03);
    }
}

@media (max-width: 480px) {
    main,
    .site-header {
        width: min(100% - 20px, 1180px);
    }

    .book-stage,
    .topic-panel {
        border-radius: 22px;
    }

    .book-stage {
        min-height: 760px;
    }

    .root-topic {
        width: 104px;
        padding: 9px;
    }

    .root-topic-name {
        font-size: 0.82rem;
    }
}
