/* =========================
   أنس أجلاب ♾️ — Static Novels Website
   CSS3 | RTL | Responsive | Dark/Light | Print PDF
   ========================= */

/* Fonts (loaded in HTML) */
:root {
    --font-body: "Cairo", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    --font-title: "Amiri", serif;

    /* Light palette (فلسفي/هادئ) */
    --bg: #f3efe6;
    /* بيج دافئ */
    --surface: #faf7f0;
    /* بطاقة */
    --text: #151515;
    /* أسود ناعم */
    --muted: #4a4a4a;
    /* رمادي داكن */
    --border: rgba(0, 0, 0, .10);
    --shadow: 0 10px 30px rgba(0, 0, 0, .08);
    --accent: #6b4b2a;
    /* بني */
    --accent2: #2b2b2b;
    /* رمادي داكن */
    --link: #6b4b2a;
    --focus: rgba(107, 75, 42, .25);

    --radius: 18px;
    --radius-sm: 12px;
    --container: 1100px;

    --t: 220ms;
    /* transitions */
}

/* Dark palette */
[data-theme="dark"] {
    --bg: #0f0f10;
    --surface: #171718;
    --text: #f0efe9;
    --muted: #b9b7b0;
    --border: rgba(255, 255, 255, .10);
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);
    --accent: #c6a178;
    /* بيج/ذهبي هادئ */
    --accent2: #d9d6cf;
    --link: #c6a178;
    --focus: rgba(198, 161, 120, .22);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font-body);
    background: radial-gradient(1200px 800px at 80% -10%, rgba(107, 75, 42, .08), transparent 60%),
        radial-gradient(900px 600px at 10% 10%, rgba(0, 0, 0, .06), transparent 55%),
        var(--bg);
    color: var(--text);
    line-height: 1.9;
}

/* Accessibility focus */
:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
    border-radius: 10px;
}

/* Layout */
.container {
    width: min(var(--container), calc(100% - 32px));
    margin: 0 auto;
}

a {
    color: var(--link);
    text-decoration: none;
    transition: color var(--t) ease;
}

a:hover {
    color: var(--accent2);
}

/* Header / Navbar */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    border-bottom: 1px solid var(--border);
}

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 210px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 75%, transparent), color-mix(in srgb, var(--accent2) 55%, transparent));
    display: grid;
    place-items: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.brand-mark span {
    font-size: 22px;
    color: var(--text);
    font-weight: 800;
    font-family: var(--font-title);
}

.brand-name {
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.2;
}

.brand-name strong {
    font-family: var(--font-title);
    font-size: 18px;
    letter-spacing: .2px;
}

.brand-name small {
    color: var(--muted);
    font-size: 12px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.nav-links a {
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: background var(--t) ease, border-color var(--t) ease, transform var(--t) ease;
    color: var(--text);
}

.nav-links a:hover {
    background: color-mix(in srgb, var(--surface) 70%, transparent);
    border-color: var(--border);
    transform: translateY(-1px);
}

.nav-links a[aria-current="page"] {
    background: color-mix(in srgb, var(--surface) 80%, transparent);
    border-color: var(--border);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-btn {
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 75%, transparent);
    color: var(--text);
    border-radius: 999px;
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform var(--t) ease, background var(--t) ease, border-color var(--t) ease;
}

.icon-btn:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}

.icon-btn .emoji {
    font-size: 16px;
}

.icon-btn .label {
    font-size: 13px;
    color: var(--muted);
}

@media (max-width: 720px) {
    .icon-btn .label {
        display: none;
    }

    .brand {
        min-width: 0;
    }
}

/* Hero */
.hero {
    padding: 40px 0 26px;
}

.hero-card {
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px;
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
}

.hero-card::after {
    content: "♾️";
    position: absolute;
    top: -14px;
    left: 18px;
    font-family: var(--font-title);
    font-size: 72px;
    opacity: .08;
    transform: rotate(-12deg);
}

.hero h1 {
    margin: 0 0 8px;
    font-family: var(--font-title);
    font-size: clamp(28px, 3.2vw, 40px);
}

.hero .subtitle {
    margin: 0;
    color: var(--muted);
    max-width: 72ch;
}

.hero .hero-actions {
    margin-top: 16px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform var(--t) ease, background var(--t) ease, border-color var(--t) ease;
}

.btn:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--accent) 32%, var(--border));
}

.btn.primary {
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 28%, var(--surface)), color-mix(in srgb, var(--accent2) 14%, var(--surface)));
}

.btn.danger {
    background: linear-gradient(135deg, rgba(150, 40, 40, .14), color-mix(in srgb, var(--surface) 85%, transparent));
}

/* Sections */
.section {
    padding: 22px 0 44px;
}

.section-title {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin: 0 0 14px;
}

.section-title h2 {
    margin: 0;
    font-family: var(--font-title);
    font-size: 22px;
}

.section-title span {
    color: var(--muted);
    font-size: 13px;
}

/* Cards grid */
.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

@media (max-width: 980px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .grid {
        grid-template-columns: 1fr;
    }
}

.card {
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform var(--t) ease, border-color var(--t) ease;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
}

.card-media {
    aspect-ratio: 16/10;
    background: radial-gradient(600px 300px at 20% 20%, rgba(107, 75, 42, .18), transparent 55%),
        radial-gradient(500px 250px at 80% 40%, rgba(0, 0, 0, .12), transparent 55%),
        #0000;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    filter: saturate(1.02) contrast(1.02);
}

.card-body {
    padding: 16px 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.card-title {
    margin: 0;
    font-family: var(--font-title);
    font-size: 20px;
}

.card-text {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.card-footer {
    margin-top: auto;
    padding: 0 16px 16px;
}

/* Page header on novel/about/support */
.page-head {
    padding: 28px 0 10px;
}

.page-head h1 {
    margin: 0 0 8px;
    font-family: var(--font-title);
    font-size: clamp(26px, 3vw, 36px);
}

.page-head p {
    margin: 0;
    color: var(--muted);
    max-width: 80ch;
}

/* Novel layout */
.novel-wrap {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 16px;
    align-items: start;
}

@media (max-width: 980px) {
    .novel-wrap {
        grid-template-columns: 1fr;
    }
}

.novel-aside {
    position: sticky;
    top: 86px;
}

@media (max-width: 980px) {
    .novel-aside {
        position: static;
    }
}

.panel {
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
}

.cover {
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.cover img {
    width: 100%;
    height: auto;
    display: block;
}

.meta {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.meta .tag {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    color: var(--muted);
    font-size: 13px;
}

.meta .tag strong {
    color: var(--text);
    font-weight: 700;
}

.novel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

/* Accordion */
.accordion {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chapter {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    box-shadow: var(--shadow);
}

.chapter-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 14px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--surface) 92%, transparent), color-mix(in srgb, var(--accent) 10%, transparent));
    border: none;
    cursor: pointer;
    text-align: right;
}

.chapter-header h3 {
    margin: 0;
    font-family: var(--font-title);
    font-size: 18px;
}

.chapter-header .hint {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.chapter-header .chev {
    transition: transform var(--t) ease;
    font-size: 16px;
    opacity: .85;
}

.chapter[aria-expanded="true"] .chapter-header .chev {
    transform: rotate(180deg);
}

.chapter-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 340ms ease;
}

.chapter-inner {
    padding: 0 16px 16px;
}

.chapter-text {
    margin: 12px 0 0;
    color: color-mix(in srgb, var(--text) 92%, var(--muted));
}

/* Opinion/comments */
.opinion {
    margin-top: 14px;
    border-top: 1px dashed var(--border);
    padding-top: 12px;
}

.opinion h4 {
    margin: 0 0 10px;
    font-family: var(--font-title);
    font-size: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

textarea {
    width: 100%;
    min-height: 92px;
    resize: vertical;
    padding: 12px 12px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    color: var(--text);
    font-family: var(--font-body);
}

.comments {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.comment {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 12px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
}

.comment .meta {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 12px;
}

.comment .text {
    margin: 0;
}

/* Footer */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 18px 0;
    background: color-mix(in srgb, var(--bg) 86%, transparent);
}

.footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.footer-row p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.social {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.social a {
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 80%, transparent);
    padding: 8px 10px;
    border-radius: 999px;
    color: var(--text);
}

.social a:hover {
    border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}

/* Utility */
.hr {
    height: 1px;
    background: var(--border);
    margin: 14px 0;
}

/* =========================
   Print (PDF via window.print)
   ========================= */
@media print {
    :root {
        color-scheme: light;
    }

    body {
        body {
            background: var(--bg);
            color: var(--text);
        }
    }

    .site-header,
    .site-footer,
    .nav-actions,
    .hero-actions,
    .novel-actions,
    .opinion,
    .btn,
    .icon-btn {
        display: none !important;
    }

    .container {
        width: 100% !important;
        margin: 0 !important;
    }

    .panel,
    .chapter,
    .hero-card,
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }

    .novel-wrap {
        grid-template-columns: 1fr !important;
    }

    .novel-aside {
        position: static !important;
    }

    .print-cover {
        display: block !important;
        page-break-after: always;
        border: 1px solid #ddd;
        padding: 22px;
        border-radius: 14px;
        margin-bottom: 18px;
    }

    .print-cover h1 {
        font-family: "Amiri", serif;
        font-size: 30px;
        margin: 0 0 8px;
    }

    .print-cover p {
        margin: 0;
        color: #444;
    }

    .chapter-body {
        max-height: none !important;
        overflow: visible !important;
    }

    .chapter {
        break-inside: avoid;
    }
}

.print-cover {
    display: none;
}

/* =========================
   Support / RIB (Added)
   ========================= */

.support-box {
    max-width: 600px;
    margin: auto;
    padding: 2rem;
    text-align: center;
}

.support-text {
    color: var(--text-muted);
    line-height: 1.8;
    margin-bottom: 1.5rem;
}

.rib-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.label {
    display: block;
    font-size: 0.9rem;
    opacity: 0.7;
}

.rib-value {
    font-family: monospace;
    font-size: 1.05rem;
    margin: 0.7rem 0;
}

.copy-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--accent);
    padding: 0.5rem 1.2rem;
    border-radius: 999px;
    cursor: pointer;
}

.copy-btn:hover {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
}