/*
    Fihris Author Page — Theme: Ivory
    Clean, warm, tab-based design. Vanilla CSS (no Tailwind).
    Dynamic color via --author-theme-solid
*/

/* ═══════ 0. Foundation ═══════ */
:root {
    --ivory-bg: #FAF8F5;
    --ivory-ink: #1A1C23;
    --ivory-muted: #7A7265;
    --ivory-surface: #FFFFFF;
    --ivory-border: rgba(0,0,0,0.08);
    --ivory-radius: 24px;

    --author-theme-solid: #92400E;
    --author-theme-glow: rgba(146, 64, 14, 0.4);
    --author-theme-light: rgba(146, 64, 14, 0.1);

    --font-heading: 'Aref Ruqaa', serif;
    --font-body: 'Noto Kufi Arabic', sans-serif;
    --font-latin: 'Space Grotesk', sans-serif;
}

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

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

body {
    background-color: var(--ivory-bg);
    color: var(--ivory-ink);
    font-family: var(--font-body);
    line-height: 1.7;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
}

::selection { background: var(--author-theme-solid); color: var(--author-theme-solid-text); }

a { text-decoration: none; color: inherit; }

/* ═══════ 1. Hero Banner (Dynamic Gradient) ═══════ */
.ivory-hero {
    position: relative;
    height: 45vh;
    min-height: 320px;
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--author-theme-solid) 50%, #1A1C23) 0%,
        color-mix(in srgb, var(--author-theme-solid) 80%, #000) 40%,
        var(--author-theme-solid) 100%
    );
    overflow: hidden;
}

.ivory-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 50%, rgba(255,255,255,0.15) 0%, transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(255,255,255,0.1) 0%, transparent 40%);
    pointer-events: none;
}

.ivory-hero-fade {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(26, 28, 35, 0.15) 0%, var(--ivory-bg) 100%);
}

/* Subtle floating shapes */
.ivory-hero-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.3;
    pointer-events: none;
    animation: ivory-float 12s infinite alternate ease-in-out;
}
.ivory-hero-shape-1 { width: 400px; height: 400px; background: rgba(255,255,255,0.2); top: -100px; right: -100px; }
.ivory-hero-shape-2 { width: 300px; height: 300px; background: rgba(255,255,255,0.15); bottom: -50px; left: -50px; animation-delay: -6s; }

@keyframes ivory-float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(20px, 15px) scale(1.08); }
}

/* ═══════ 2. Author Glass Card ═══════ */
.ivory-container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; position: relative; }

.ivory-author-card {
    position: relative;
    margin-top: -140px;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 20px 50px -15px rgba(0,0,0,0.06);
    border-radius: 32px;
    padding: 4.5rem 2rem 2.5rem;
    text-align: center;
    z-index: 10;
    margin-bottom: 3rem;
}

/* Avatar */
.ivory-avatar-wrap {
    position: absolute;
    top: -56px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px; height: 120px;
    border-radius: 50%;
    border: 5px solid var(--ivory-surface);
    box-shadow: 0 12px 30px -8px rgba(0,0,0,0.12);
    overflow: hidden;
    background: var(--ivory-bg);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ivory-author-card:hover .ivory-avatar-wrap { transform: translateX(-50%) scale(1.05) rotate(-2deg); }
.ivory-avatar-wrap img { width: 100%; height: 100%; object-fit: cover; }
.ivory-avatar-initial {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    background: var(--author-theme-solid); color: var(--author-theme-solid-text);
    font-family: var(--font-heading); font-size: 3rem;
}

/* Author Info */
.ivory-author-name {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 700;
    color: var(--ivory-ink);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.ivory-author-bio {
    max-width: 600px;
    margin: 0 auto 2rem;
    color: var(--ivory-muted);
    font-size: 1.05rem;
    line-height: 1.9;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Social Stamps */
.ivory-social-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.7rem; margin-top: 1rem; }
.ivory-stamp {
    width: 44px; height: 44px; border-radius: 50%;
    border: 1.5px solid var(--ivory-border);
    background: var(--ivory-surface);
    display: flex; align-items: center; justify-content: center;
    color: var(--ivory-muted);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}
.ivory-stamp:hover {
    border-color: var(--author-theme-solid); color: var(--author-theme-solid);
    transform: translateY(-4px) scale(1.1);
    box-shadow: 0 8px 20px color-mix(in srgb, var(--author-theme-solid) 20%, transparent);
}
.ivory-stamp svg { width: 20px; height: 20px; }

/* Goodreads CTA */
.ivory-cta-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; margin-bottom: 1rem; }
.ivory-btn-primary {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.9rem 2rem; border-radius: 100px;
    background: linear-gradient(135deg, var(--author-theme-solid), color-mix(in srgb, var(--author-theme-solid) 70%, #000));
    color: var(--author-theme-solid-text) !important; font-weight: 700; font-size: 1rem;
    box-shadow: 0 10px 25px color-mix(in srgb, var(--author-theme-solid) 30%, transparent);
    transition: all 0.3s ease; border: none; cursor: pointer;
}
.ivory-btn-primary:hover { transform: translateY(-3px); box-shadow: 0 15px 30px color-mix(in srgb, var(--author-theme-solid) 40%, transparent); }

.ivory-btn-outline {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.85rem 2rem; border-radius: 100px;
    border: 2px solid var(--author-theme-solid); color: var(--author-theme-solid);
    background: rgba(255,255,255,0.5); font-weight: 700; font-size: 1rem;
    transition: all 0.3s ease; cursor: pointer;
}
.ivory-btn-outline:hover { background: var(--author-theme-solid); color: var(--author-theme-solid-text); transform: translateY(-3px); }

/* ═══════ 3. Tabs ═══════ */
.ivory-tabs-bar {
    display: flex; justify-content: center; gap: 2rem;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    margin-bottom: 2.5rem; padding-bottom: 0.25rem;
}
.ivory-tab-btn {
    position: relative; background: none; border: none; cursor: pointer;
    font-family: var(--font-body); font-size: 1.1rem; font-weight: 700;
    color: var(--ivory-muted); padding: 0.5rem 0.5rem;
    transition: color 0.3s ease;
}
.ivory-tab-btn::after {
    content: ''; position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
    width: 0; height: 3px; background: var(--author-theme-solid);
    border-radius: 3px; transition: width 0.3s ease;
}
.ivory-tab-btn.active { color: var(--author-theme-solid); }
.ivory-tab-btn.active::after { width: 100%; }

.ivory-tab-content {
    display: none; opacity: 0; transform: translateY(10px);
    animation: ivory-fadeUp 0.5s ease forwards;
}
.ivory-tab-content.active { display: block; opacity: 1; transform: translateY(0); }

@keyframes ivory-fadeUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ═══════ 4. Novels Grid ═══════ */
.ivory-novels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 3rem 2.5rem;
}

.ivory-book-card {
    display: flex; flex-direction: column; align-items: center;
    perspective: 1000px; transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.ivory-book-cover-wrap {
    width: 200px; height: 300px;
    border-radius: 2px 14px 14px 2px;
    overflow: hidden; position: relative; cursor: pointer;
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.15), 0 5px 15px -5px rgba(0,0,0,0.1);
    transition: all 0.5s ease; transform-origin: left center;
    margin-bottom: 1.2rem;
}
.ivory-book-card:hover .ivory-book-cover-wrap {
    transform: translateY(-10px) rotateY(-12deg);
    box-shadow: 25px 25px 40px -15px rgba(0,0,0,0.2);
}

.ivory-book-cover-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ivory-book-cover-wrap .ivory-book-spine {
    position: absolute; inset: 0; right: auto; width: 4px;
    background: linear-gradient(to left, rgba(0,0,0,0.2), transparent);
    pointer-events: none;
}

.ivory-book-placeholder {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    background: var(--ivory-bg); color: var(--ivory-muted);
    font-size: 3rem;
}

.ivory-book-badge {
    position: absolute; top: 10px; left: 10px;
    background: rgba(255,255,255,0.92); backdrop-filter: blur(4px);
    color: var(--author-theme-solid); font-size: 0.75rem; font-weight: 700;
    padding: 0.3rem 0.7rem; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.ivory-book-title {
    font-family: var(--font-heading); font-size: 1.5rem; font-weight: 700;
    color: var(--ivory-ink); text-align: center; margin-bottom: 0.5rem;
    transition: color 0.3s;
}
.ivory-book-card:hover .ivory-book-title { color: var(--author-theme-solid); }

.ivory-book-genres { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem; margin-bottom: 0.8rem; }
.ivory-book-genre {
    font-size: 0.75rem; font-weight: 600; color: var(--ivory-muted);
    background: var(--ivory-bg); border: 1px solid rgba(0,0,0,0.05);
    padding: 0.2rem 0.7rem; border-radius: 100px;
}

.ivory-book-detail-btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.5rem 1.5rem; border-radius: 100px;
    border: 2px solid var(--author-theme-solid); color: var(--author-theme-solid);
    background: transparent; font-size: 0.85rem; font-weight: 700;
    cursor: pointer; transition: all 0.3s;
}
.ivory-book-detail-btn:hover { background: var(--author-theme-solid); color: var(--author-theme-solid-text); }

/* ═══════ 5. Novel Modal ═══════ */
.ivory-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(26, 28, 35, 0.6); backdrop-filter: blur(8px);
    z-index: 100; display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity 0.4s ease;
    padding: 1rem;
}
.ivory-modal-overlay.active { opacity: 1; pointer-events: auto; }

.ivory-modal-box {
    background: var(--ivory-surface); width: 100%; max-width: 900px;
    border-radius: 24px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.95) translateY(20px); opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden; display: flex; flex-direction: column;
    max-height: 90vh;
}
.ivory-modal-overlay.active .ivory-modal-box { transform: scale(1) translateY(0); opacity: 1; }

.ivory-modal-cover-area {
    background: var(--ivory-bg); padding: 2rem;
    display: flex; align-items: center; justify-content: center;
    position: relative; min-height: 250px;
}

.ivory-modal-cover-img {
    width: 100%; max-width: 240px; max-height: 360px;
    border-radius: 2px 12px 12px 2px; object-fit: cover;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}
.ivory-modal-cover-area .ivory-book-spine {
    position: absolute; top: 2rem; bottom: 2rem; right: calc(50% + 120px);
    width: 4px; background: linear-gradient(to left, rgba(0,0,0,0.15), transparent);
}

.ivory-modal-close {
    position: absolute; top: 1rem; right: 1rem; z-index: 10;
    background: rgba(0,0,0,0.05); border: none; border-radius: 50%;
    width: 40px; height: 40px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--ivory-ink); transition: all 0.2s;
}
.ivory-modal-close:hover { background: rgba(239, 68, 68, 0.1); color: #EF4444; transform: rotate(90deg); }

.ivory-modal-info { padding: 2rem; display: flex; flex-direction: column; justify-content: center; }

.ivory-modal-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.ivory-modal-meta-tag {
    background: var(--author-theme-light); color: var(--author-theme-solid);
    padding: 0.3rem 0.8rem; border-radius: 6px; font-size: 0.85rem; font-weight: 700;
}

.ivory-modal-title {
    font-family: var(--font-heading); font-size: clamp(1.8rem, 4vw, 2.8rem);
    font-weight: 700; color: var(--ivory-ink); margin-bottom: 1rem; line-height: 1.3;
}

.ivory-modal-desc {
    color: var(--ivory-muted); font-size: 1.05rem; line-height: 1.9;
    margin-bottom: 2rem; word-wrap: break-word;
}

/* Rating display */
.ivory-modal-rating {
    display: inline-flex; align-items: center; gap: 0.5rem;
    background: rgba(217,119,6,0.08); padding: 0.4rem 1rem; border-radius: 100px;
    margin-bottom: 1.5rem;
}
.ivory-modal-rating-star { color: #D97706; font-size: 1.1rem; }
.ivory-modal-rating-num { font-family: var(--font-latin); font-weight: 700; color: #D97706; font-size: 0.95rem; }
.ivory-modal-rating-label { color: var(--ivory-muted); font-size: 0.8rem; }

.ivory-modal-actions {
    display: flex; flex-wrap: wrap; gap: 1rem;
    padding-top: 1.5rem; border-top: 1px solid rgba(0,0,0,0.06); margin-top: auto;
}
.ivory-modal-actions .ivory-btn-primary,
.ivory-modal-actions .ivory-btn-outline { flex: 1; min-width: 180px; justify-content: center; padding: 1rem; }

/* ═══════ 6. Stores Tab ═══════ */
.ivory-stores-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.2rem; max-width: 900px; margin: 0 auto;
}
.ivory-store-card {
    display: flex; align-items: center; gap: 1.2rem;
    background: var(--ivory-surface); padding: 1.5rem;
    border-radius: 20px; border: 1px solid rgba(0,0,0,0.05);
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    transition: all 0.3s ease; cursor: pointer;
}
.ivory-store-card:hover {
    box-shadow: 0 10px 25px rgba(0,0,0,0.06);
    border-color: color-mix(in srgb, var(--author-theme-solid) 30%, transparent);
    transform: translateY(-3px);
}
.ivory-store-icon {
    width: 56px; height: 56px; border-radius: 14px;
    background: var(--ivory-bg); display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: transform 0.3s;
    color: var(--author-theme-solid);
}
.ivory-store-card:hover .ivory-store-icon { transform: scale(1.08); }
.ivory-store-icon svg { width: 24px; height: 24px; }
.ivory-store-name { font-weight: 700; font-size: 1.1rem; color: var(--ivory-ink); transition: color 0.3s; }
.ivory-store-card:hover .ivory-store-name { color: var(--author-theme-solid); }

/* ═══════ 7. Leaks / Teasers Placeholder ═══════ */
.ivory-leaks-placeholder {
    text-align: center; padding: 4rem 2rem;
    background: var(--ivory-surface); border-radius: 24px;
    border: 1px dashed rgba(0,0,0,0.08); max-width: 700px; margin: 0 auto;
}
.ivory-leaks-placeholder-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.6; }
.ivory-leaks-placeholder h3 {
    font-family: var(--font-heading); font-size: 1.5rem;
    color: var(--ivory-ink); margin-bottom: 0.5rem;
}
.ivory-leaks-placeholder p { color: var(--ivory-muted); font-size: 1rem; }

/* ═══════ 8. Reviews Button ═══════ */
.ivory-reviews-btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    background: rgba(0,0,0,0.04); padding: 0.5rem 1.2rem;
    border-radius: 100px; border: none; cursor: pointer;
    font-family: var(--font-body); font-size: 0.85rem; font-weight: 600;
    color: var(--ivory-muted); transition: all 0.3s;
}
.ivory-reviews-btn:hover { background: var(--author-theme-light); color: var(--author-theme-solid); }

/* ═══════ 9. Loading Screen ═══════ */
.ivory-loading {
    position: fixed; inset: 0; z-index: 9999;
    background: var(--ivory-bg);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    transition: opacity 0.8s ease, transform 0.8s ease;
}
.ivory-loading.loaded { opacity: 0; transform: scale(1.05); pointer-events: none; }
.ivory-loading-brand {
    font-family: 'Aref Ruqaa', serif; font-size: 4rem; font-weight: 700;
    color: var(--author-theme-solid); margin-bottom: 2rem;
    animation: ivory-pulse 1.5s infinite ease-in-out;
}
.ivory-loading-bar {
    width: 80px; height: 3px; background: rgba(0,0,0,0.06); border-radius: 10px; overflow: hidden;
}
.ivory-loading-fill {
    width: 40%; height: 100%; background: var(--author-theme-solid); border-radius: 10px;
    animation: ivory-loader-slide 1s infinite ease-in-out;
}
@keyframes ivory-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.98); }
}
@keyframes ivory-loader-slide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(300%); }
}

/* ═══════ 10. Scroll Animations ═══════ */
.ivory-anim {
    opacity: 0; transform: translateY(30px);
    transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}
.ivory-anim.animated { opacity: 1; transform: translateY(0); }

/* ═══════ 11. Book Actions Row (Detail + Share) ═══════ */
.ivory-book-actions-row {
    display: flex; gap: 0.5rem; align-items: center; justify-content: center;
    margin-top: 0.3rem;
}
.ivory-share-btn {
    padding: 0.5rem 0.7rem !important; border-radius: 50% !important;
    min-width: unset !important; width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
}
.ivory-share-btn svg { width: 16px; height: 16px; }

/* ═══════ Mobile (max-width: 768px) ═══════ */
@media (max-width: 768px) {
    .ivory-hero { height: 35vh; min-height: 250px; }
    .ivory-author-card { margin-top: -100px; padding: 3.5rem 1.2rem 2rem; border-radius: 24px; }
    .ivory-avatar-wrap { width: 100px; height: 100px; top: -48px; }
    .ivory-author-name { font-size: 1.8rem; }
    .ivory-author-bio { font-size: 0.95rem; }

    .ivory-tabs-bar { gap: 1rem; overflow-x: auto; justify-content: center; padding: 0 0.5rem 0.25rem; }
    .ivory-tab-btn { font-size: 0.95rem; white-space: nowrap; }

    .ivory-novels-grid { grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
    .ivory-book-cover-wrap { width: 100%; height: auto; aspect-ratio: 2/3; }
    .ivory-book-title { font-size: 1.1rem; }
    .ivory-book-card:hover .ivory-book-cover-wrap { transform: none; box-shadow: 0 20px 40px -10px rgba(0,0,0,0.15); }

    .ivory-modal-box { flex-direction: column; border-radius: 20px; margin: 0.5rem; overflow-y: auto; }
    .ivory-modal-cover-area { padding: 1rem; min-height: auto; flex-shrink: 0; }
    .ivory-modal-cover-img { max-width: 120px; max-height: 180px; }
    .ivory-modal-info { padding: 1.2rem; overflow-y: visible; }
    .ivory-modal-title { font-size: 1.4rem; }
    .ivory-modal-desc { font-size: 0.95rem; margin-bottom: 1rem; }
    .ivory-modal-actions { flex-direction: column; }
    .ivory-modal-actions .ivory-btn-primary,
    .ivory-modal-actions .ivory-btn-outline { min-width: auto; }

    .ivory-stores-grid { grid-template-columns: 1fr; }
    .ivory-store-card { padding: 1.2rem; }

    .ivory-cta-row { flex-direction: column; align-items: center; }
    .ivory-btn-primary, .ivory-btn-outline { width: 100%; justify-content: center; }

    .ivory-book-detail-btn { font-size: 0.78rem; padding: 0.4rem 1rem; }
    .ivory-share-btn { width: 32px; height: 32px; }
    .ivory-book-actions-row { gap: 0.4rem; }

    .ivory-loading-brand { font-size: 3rem; }
}

/* ═══════ Desktop Modal (side-by-side) ═══════ */
@media (min-width: 769px) {
    .ivory-modal-box { flex-direction: row; }
    .ivory-modal-cover-area { width: 40%; }
    .ivory-modal-info { width: 60%; padding: 2.5rem; }
}

/* ═══════ Small phones ═══════ */
@media (max-width: 400px) {
    .ivory-novels-grid { grid-template-columns: 1fr; }
    .ivory-book-cover-wrap { max-width: 200px; margin-left: auto; margin-right: auto; }
}
