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

:root {
    --bg:        #0e0c0a;
    --bg2:       #161310;
    --bg3:       #1e1a16;
    --border:    #2e2720;
    --gold:      #c9a84c;
    --gold-dim:  #8a6e2f;
    --text:      #e8ddd0;
    --text-dim:  #9e8e7e;
    --text-faint:#5a4e42;
    --red:       #8b2020;
    --radius:    12px;
    --shadow:    0 8px 40px rgba(0,0,0,0.6);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Cairo', sans-serif;
    direction: rtl;
    min-height: 100vh;
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(201,168,76,0.07) 0%, transparent 60%),
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%232e2720' fill-opacity='0.3'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* ===== HEADER ===== */
header {
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(14,12,10,0.98), rgba(22,19,16,0.95));
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-family: 'Amiri', serif;
    font-size: 1.6rem;
    color: var(--gold);
    text-decoration: none;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo span { font-size: 1.8rem; }

nav a {
    color: var(--text-dim);
    text-decoration: none;
    margin-right: 24px;
    font-size: 0.9rem;
    transition: color 0.2s;
}
nav a:hover { color: var(--gold); }

/* ===== HERO ===== */
.hero {
    padding: 80px 24px 60px;
    text-align: center;
    max-width: 700px;
    margin: 0 auto;
}

.hero-eyebrow {
    color: var(--gold-dim);
    font-size: 0.8rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 16px;
}

.hero h1 {
    font-family: 'Amiri', serif;
    font-size: clamp(2.2rem, 5vw, 3.5rem);
    color: var(--text);
    line-height: 1.3;
    margin-bottom: 16px;
}

.hero p {
    color: var(--text-dim);
    font-size: 1rem;
    line-height: 1.8;
}

/* ===== DIVIDER ===== */
.divider {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 1200px;
    margin: 0 auto 40px;
    padding: 0 24px;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.divider-text {
    color: var(--gold-dim);
    font-size: 0.75rem;
    letter-spacing: 2px;
    white-space: nowrap;
}

/* ===== NOVELS GRID ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

.novels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 28px;
    padding-bottom: 80px;
}

.novel-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.3s, border-color 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
    position: relative;
}

.novel-card:hover {
    transform: translateY(-6px);
    border-color: var(--gold-dim);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(201,168,76,0.1);
}

.novel-cover {
    height: 300px;
    background: var(--bg3);
    position: relative;
    overflow: hidden;
}

.novel-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.85;
    transition: opacity 0.3s, transform 0.4s;
}

.novel-card:hover .novel-cover img { opacity: 1; transform: scale(1.04); }

.novel-cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg3), #1a1410);
    gap: 12px;
}

.novel-cover-placeholder .icon { font-size: 3rem; opacity: 0.4; }
.novel-cover-placeholder .ptitle {
    font-family: 'Amiri', serif;
    color: var(--gold-dim);
    font-size: 1.1rem;
    text-align: center;
    padding: 0 16px;
    opacity: 0.7;
}

.novel-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge-completed { background: rgba(201,168,76,0.2); color: var(--gold); border: 1px solid var(--gold-dim); }
.badge-ongoing   { background: rgba(139,32,32,0.2); color: #e07070; border: 1px solid var(--red); }

.novel-info { padding: 20px; flex: 1; display: flex; flex-direction: column; }

.novel-genre {
    color: var(--gold-dim);
    font-size: 0.72rem;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
}

.novel-title {
    font-family: 'Amiri', serif;
    font-size: 1.25rem;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.4;
}

.novel-desc {
    color: var(--text-dim);
    font-size: 0.85rem;
    line-height: 1.7;
    flex: 1;
    margin-bottom: 16px;
}

.novel-meta {
    display: flex;
    gap: 16px;
    color: var(--text-faint);
    font-size: 0.78rem;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.novel-meta span { display: flex; align-items: center; gap: 5px; }

/* ===== NOVEL PAGE ===== */
.novel-hero {
    max-width: 1000px;
    margin: 40px auto 0;
    padding: 0 24px;
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 40px;
    align-items: start;
}

.novel-hero-cover {
    width: 220px;
    height: 320px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    flex-shrink: 0;
    box-shadow: var(--shadow);
}

.novel-hero-cover img { width: 100%; height: 100%; object-fit: cover; }

.novel-hero-info { padding-top: 8px; }
.novel-hero-genre { color: var(--gold-dim); font-size: 0.8rem; letter-spacing: 2px; margin-bottom: 12px; }
.novel-hero-title { font-family: 'Amiri', serif; font-size: 2.2rem; line-height: 1.3; margin-bottom: 10px; }
.novel-hero-author { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 20px; }
.novel-hero-desc { color: var(--text-dim); line-height: 1.9; font-size: 0.95rem; margin-bottom: 24px; }

.btn-read {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--gold);
    color: #0e0c0a;
    padding: 12px 28px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none;
    transition: background 0.2s, transform 0.2s;
}

.btn-read:hover { background: #d4b55c; transform: translateY(-2px); }

/* ===== CHAPTERS LIST ===== */
.chapters-section {
    max-width: 1000px;
    margin: 50px auto 80px;
    padding: 0 24px;
}

.section-title {
    font-family: 'Amiri', serif;
    font-size: 1.4rem;
    color: var(--gold);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.chapters-list { display: flex; flex-direction: column; gap: 8px; }

.chapter-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, background 0.2s;
    gap: 16px;
}

.chapter-item:hover { border-color: var(--gold-dim); background: var(--bg3); }

.chapter-num {
    font-family: 'Amiri', serif;
    color: var(--gold-dim);
    font-size: 1.1rem;
    min-width: 40px;
}

.chapter-title-text { flex: 1; font-size: 0.95rem; }
.chapter-views { color: var(--text-faint); font-size: 0.78rem; }

/* ===== READER ===== */
.reader-header {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.reader-nav { display: flex; gap: 8px; }

.reader-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.82rem;
    text-decoration: none;
    color: var(--text-dim);
    border: 1px solid var(--border);
    background: transparent;
    transition: all 0.2s;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
}

.reader-btn:hover { border-color: var(--gold-dim); color: var(--gold); }
.reader-btn.active { background: var(--gold); color: #0e0c0a; border-color: var(--gold); font-weight: 700; }

.reader-body {
    max-width: 720px;
    margin: 0 auto;
    padding: 60px 24px 120px;
}

.reader-chapter-title {
    font-family: 'Amiri', serif;
    font-size: 1.8rem;
    color: var(--gold);
    margin-bottom: 40px;
    text-align: center;
    line-height: 1.4;
}

.reader-content {
    font-family: 'Amiri', serif;
    font-size: 1.25rem;
    line-height: 2.2;
    color: #d8cdc0;
}

.reader-content p { margin-bottom: 1.6em; text-align: justify; }

.reader-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 60px;
    padding-top: 30px;
    border-top: 1px solid var(--border);
}

/* ===== FONT SIZE CONTROL ===== */
.font-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--text-dim);
}

.font-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s;
}

.font-btn:hover { border-color: var(--gold); }

/* ===== FOOTER ===== */
footer {
    border-top: 1px solid var(--border);
    padding: 30px 24px;
    text-align: center;
    color: var(--text-faint);
    font-size: 0.82rem;
}

footer a { color: var(--gold-dim); text-decoration: none; }

/* ===== RESPONSIVE ===== */
@media (max-width: 700px) {

    /* Header */
    .header-inner { padding: 0 16px; height: 58px; }
    .logo { font-size: 1.3rem; }
    nav a { margin-right: 12px; font-size: .82rem; }

    /* Hero */
    .hero { padding: 40px 16px 30px; }
    .hero h1 { font-size: 1.7rem; }
    .hero p { font-size: .9rem; }

    /* Grid - عمود واحد على الموبايل الصغير */
    .novels-grid { grid-template-columns: 1fr; gap: 16px; }
    .novel-cover { height: 220px; }

    /* Novel page */
    .novel-hero {
        grid-template-columns: 1fr;
        padding: 20px 16px 0;
        gap: 20px;
    }
    .novel-hero-cover { width: 140px; height: 200px; margin: 0 auto; }
    .novel-hero-title { font-size: 1.6rem; }

    .chapters-section { padding: 0 16px; margin-top: 30px; }
    .chapter-item { padding: 12px 14px; }

    /* Reader */
    .reader-header {
        padding: 10px 12px;
        flex-wrap: wrap;
        gap: 8px;
        height: auto;
    }

    /* إخفاء نص "الرواية" واستبداله بسهم بس */
    .reader-header .reader-btn:first-child { padding: 6px 10px; font-size: .78rem; }

    /* عنوان الفصل في الهيدر - صغّره */
    .reader-header > div:nth-child(2) { order: -1; width: 100%; text-align: center; border-bottom: 1px solid var(--border); padding-bottom: 8px; }

    .reader-body { padding: 30px 16px 80px; }

    .reader-chapter-title { font-size: 1.4rem; margin-bottom: 28px; }

    .reader-content { font-size: 1.1rem !important; line-height: 2; }

    /* أزرار التنقل في الأسفل - تحت بعض */
    .reader-footer {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    .reader-footer a, .reader-footer span {
        text-align: center;
        padding: 12px;
        border-radius: 8px;
    }
    .reader-footer .reader-btn { display: block; }

    /* controls حجم الخط */
    .font-controls { font-size: .75rem; }
    .font-btn { width: 28px; height: 28px; }

    /* Container */
    .container { padding: 0 16px; }
    .divider { padding: 0 16px; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

/* ===== EMPTY STATE ===== */
.empty { text-align: center; padding: 80px 24px; color: var(--text-faint); }
.empty .icon { font-size: 3rem; margin-bottom: 16px; }

/* ===== ALERT ===== */
.alert {
    padding: 12px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}
.alert-success { background: rgba(50,100,50,0.2); border: 1px solid #3a6e3a; color: #8bc98b; }
.alert-error   { background: rgba(139,32,32,0.2); border: 1px solid var(--red); color: #e08080; }
