/* ==========================================================================
   A CHILDHOOD AMONG THE RUINS (GAZA) - OFFICIAL MEMOIR LANDING PAGE
   Author: Wisam Ziad Mahdi
   Design System: Editorial Literary + Dark/Light Mode + 3D Book Physics
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. CSS Variables & Theme Tokens
   -------------------------------------------------------------------------- */
:root {
    /* Brand Orange Palettes */
    --color-orange-primary: #D96B27;
    --color-orange-hover: #E87A35;
    --color-orange-dark: #B85317;
    --color-orange-soft: rgba(217, 107, 39, 0.12);
    --color-orange-glow: rgba(217, 107, 39, 0.25);
    --color-orange-border: rgba(217, 107, 39, 0.35);

    /* Transitions */
    --theme-transition: background-color 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                        color 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                        border-color 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                        box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dark Theme (Default) */
html.theme-dark,
body.theme-dark {
    --bg-main: #0E0E10;
    --bg-surface: #151518;
    --bg-card: #1C1C21;
    --bg-card-hover: #23232A;
    --bg-elevated: #282830;
    
    --border-subtle: #26262E;
    --border-regular: #32323D;
    --border-strong: #454554;

    --text-primary: #FFFFFF;
    --text-secondary: #D4D4CE;
    --text-muted: #9E9E94;
    
    --header-bg: rgba(14, 14, 16, 0.92);
    --grain-opacity: 0.05;
    --card-shadow: 0 16px 36px -10px rgba(0, 0, 0, 0.7);
    --book-shadow: -22px 28px 55px -12px rgba(0, 0, 0, 0.9), 0 0 40px rgba(217, 107, 39, 0.15);
}

/* Light Theme (Archival Literary Paper) */
html.theme-light,
body.theme-light {
    --bg-main: #FAF8F5;
    --bg-surface: #FFFFFF;
    --bg-card: #F3EFE9;
    --bg-card-hover: #EBE5DC;
    --bg-elevated: #E5DFD4;
    
    --border-subtle: #E4DDD3;
    --border-regular: #D6CDC0;
    --border-strong: #BDB2A2;

    --text-primary: #09090B;
    --text-secondary: #27272A;
    --text-muted: #52525B;
    
    --header-bg: rgba(250, 248, 245, 0.94);
    --grain-opacity: 0.03;
    --card-shadow: 0 16px 36px -10px rgba(70, 50, 30, 0.08);
    --book-shadow: -18px 24px 45px -10px rgba(60, 45, 30, 0.22), 0 0 35px rgba(217, 107, 39, 0.12);
}

/* --------------------------------------------------------------------------
   2. Base Styles & Global Resets
   -------------------------------------------------------------------------- */
* {
    box-sizing: border-box;
}

/* Zero-flash protection (renders instantly without flash of English or dark mode) */
html:not([data-ready]) body {
    opacity: 0;
}

html, body {
    overflow-x: hidden;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    transition: var(--theme-transition), opacity 0.12s ease-out;
    line-height: 1.68;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Clean Hero Background without dots */
.bg-grain {
    background-image: none;
}

/* Typography Helpers - Apple-Style Modern Editorial */
.font-display {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
    letter-spacing: -0.025em;
}

.font-book {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif;
    letter-spacing: -0.01em;
}

.font-arabic {
    font-family: 'Tajawal', 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ==========================================================================
   ARABIC TYPOGRAPHY SYSTEM (RTL) - Apple-Grade Modern Editorial
   ========================================================================== */
html[dir="rtl"],
body[dir="rtl"] {
    font-family: 'Tajawal', 'Cairo', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
    line-height: 1.78;
}

[dir="rtl"] .font-display,
[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] h4,
[dir="rtl"] .font-arabic-display {
    font-family: 'Alexandria', 'Cairo', 'Tajawal', sans-serif !important;
    letter-spacing: 0 !important;
}

[dir="rtl"] .font-book,
[dir="rtl"] p,
[dir="rtl"] blockquote,
[dir="rtl"] span,
[dir="rtl"] li,
[dir="rtl"] a,
[dir="rtl"] button,
[dir="rtl"] input,
[dir="rtl"] label {
    letter-spacing: 0 !important;
}

[dir="rtl"] p,
[dir="rtl"] li,
[dir="rtl"] blockquote {
    font-family: 'Tajawal', 'Cairo', sans-serif;
}

[dir="rtl"] p {
    line-height: 1.82;
}

[dir="rtl"] blockquote {
    line-height: 1.88;
}

/* Dynamic Themed Backgrounds and Borders */
.theme-bg-main { background-color: var(--bg-main); }
.theme-bg-surface { background-color: var(--bg-surface); }
.theme-bg-card { background-color: var(--bg-card); }
.theme-bg-card-hover:hover { background-color: var(--bg-card-hover); }
.theme-bg-elevated { background-color: var(--bg-elevated); }

.theme-border-subtle { border-color: var(--border-subtle); }
.theme-border-regular { border-color: var(--border-regular); }
.theme-border-strong { border-color: var(--border-strong); }

.theme-text-primary { color: var(--text-primary); }
.theme-text-secondary { color: var(--text-secondary); }
.theme-text-muted { color: var(--text-muted); }

/* --------------------------------------------------------------------------
   3. 3D Book Cover & Realistic Spine Physics
   -------------------------------------------------------------------------- */
.book-perspective {
    perspective: 1400px;
}

.book-card-3d {
    transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), 
                box-shadow 0.45s cubic-bezier(0.16, 1, 0.3, 1),
                background-color 0.4s ease;
    transform: rotateY(-9deg) rotateX(3deg);
    box-shadow: var(--book-shadow);
    transform-style: preserve-3d;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
}

.book-card-3d.book-is-open {
    transform: rotateY(0deg) rotateX(0deg);
}

.book-card-3d.is-dragging {
    transition: none !important;
    cursor: grabbing !important;
}

.book-card-3d:hover:not(.is-dragging) {
    box-shadow: 0 30px 65px -15px rgba(0, 0, 0, 0.7), 0 0 50px rgba(217, 107, 39, 0.25);
}

.book-card-3d:hover:not(.book-is-open):not(.is-dragging) {
    transform: rotateY(-3deg) rotateX(1deg) translateY(-4px);
}

@media (max-width: 640px) {
    .book-card-3d {
        transform: rotateY(-5deg) rotateX(2deg);
    }
    .book-card-3d.book-is-open {
        transform: rotateY(0deg) rotateX(0deg);
    }
}

/* Page flip transition animations */
.page-anim-next {
    animation: pageFlipForward 0.32s cubic-bezier(0.2, 0.8, 0.25, 1) forwards;
}

.page-anim-prev {
    animation: pageFlipBackward 0.32s cubic-bezier(0.2, 0.8, 0.25, 1) forwards;
}

@keyframes pageFlipForward {
    0% {
        opacity: 0.75;
        transform: rotateY(-14deg) scale(0.975);
    }
    100% {
        opacity: 1;
        transform: rotateY(0deg) scale(1);
    }
}

@keyframes pageFlipBackward {
    0% {
        opacity: 0.75;
        transform: rotateY(14deg) scale(0.975);
    }
    100% {
        opacity: 1;
        transform: rotateY(0deg) scale(1);
    }
}

/* Hero pagination dots */
.hero-dot {
    width: 6px;
    height: 6px;
    border-radius: 9999px;
    background-color: rgba(150, 150, 160, 0.35);
    transition: all 0.25s ease;
    cursor: pointer;
}

.hero-dot:hover {
    background-color: var(--color-orange-primary);
}

.hero-dot.active {
    width: 20px;
    background-color: var(--color-orange-primary);
    box-shadow: 0 0 8px rgba(217, 107, 39, 0.5);
}

/* Realistic Book Spine Crease */
.book-spine-effect {
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0.09) 0%, 
        rgba(0, 0, 0, 0.45) 3.5%, 
        rgba(255, 255, 255, 0.05) 7%, 
        transparent 14%);
}

/* Light Mode Spine Effect */
.theme-light .book-spine-effect {
    background: linear-gradient(90deg, 
        rgba(0, 0, 0, 0.12) 0%, 
        rgba(0, 0, 0, 0.35) 3.5%, 
        rgba(0, 0, 0, 0.06) 7%, 
        transparent 14%);
}

/* Realistic Pages Edge (3D Book Thickness Effect) */
.book-pages-edge {
    position: absolute;
    right: -12px;
    top: 5px;
    bottom: 5px;
    width: 12px;
    background: repeating-linear-gradient(
        to bottom,
        #f4f1ea,
        #f4f1ea 1px,
        #ded9cc 1px,
        #ded9cc 2px
    );
    border-radius: 0 4px 4px 0;
    box-shadow: inset 2px 0 4px rgba(0,0,0,0.25), 3px 3px 8px rgba(0,0,0,0.3);
    transform: rotateY(70deg);
    transform-origin: left center;
}

/* --------------------------------------------------------------------------
   4. Interactive Reader Spread Styles
   -------------------------------------------------------------------------- */
.spread-transition {
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.reader-book-container {
    box-shadow: var(--card-shadow);
}

/* --------------------------------------------------------------------------
   5. Custom Scrollbar & Selection
   -------------------------------------------------------------------------- */
::selection {
    background-color: var(--color-orange-primary);
    color: #ffffff;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-orange-primary);
}

/* --------------------------------------------------------------------------
   6. Image Card Glow & Photography Framing
   -------------------------------------------------------------------------- */
.photo-frame {
    position: relative;
    border-radius: 1.25rem;
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--card-shadow);
}

.photo-frame:hover {
    transform: translateY(-4px);
    box-shadow: 0 24px 50px -12px rgba(0, 0, 0, 0.5), 0 0 35px var(--color-orange-soft);
}

.photo-frame img {
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.photo-frame:hover img {
    transform: scale(1.03);
}

/* Stamp / Archival Badge: High-contrast dark frosted glass on photos in all modes */
.archival-badge,
.theme-light .archival-badge,
.theme-dark .archival-badge {
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    background: rgba(14, 14, 17, 0.88) !important;
    border: 1px solid rgba(217, 107, 39, 0.5) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45) !important;
}

.archival-badge *,
.theme-light .archival-badge *,
.theme-dark .archival-badge * {
    color: #ffffff !important;
}

.archival-badge .text-gaza-orange,
.theme-light .archival-badge .text-gaza-orange {
    color: #D96B27 !important;
}

.archival-badge .text-stone-300,
.archival-badge .text-stone-400,
.theme-light .archival-badge .text-stone-300,
.theme-light .archival-badge .text-stone-400 {
    color: #D1D5DB !important;
}

/* --------------------------------------------------------------------------
   7. Smooth Theme Switcher Animation
   -------------------------------------------------------------------------- */
.theme-switch-btn {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: var(--bg-card);
    border: 1px solid var(--border-regular);
    color: var(--text-primary);
    transition: var(--theme-transition);
    flex-shrink: 0;
}

.theme-switch-btn:hover {
    border-color: var(--color-orange-primary);
    color: var(--color-orange-primary);
}

.lang-select-btn {
    position: relative;
    height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-regular);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    transition: var(--theme-transition);
    cursor: pointer;
    flex-shrink: 0;
}

.lang-select-btn:hover {
    border-color: var(--color-orange-primary);
}

.nav-cta-btn {
    height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    background-color: var(--color-orange-primary);
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(217, 107, 39, 0.25);
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-cta-btn:hover {
    background-color: var(--color-orange-hover);
}

/* Icon rotation transition */
.theme-switch-icon {
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

/* ==========================================================================
   8. COMPREHENSIVE ARABIC / RTL LAYOUT SYSTEM
   ========================================================================== */
html[dir="rtl"],
body[dir="rtl"],
[dir="rtl"] {
    direction: rtl !important;
    text-align: right !important;
}

[dir="rtl"] .text-left,
[dir="rtl"] [class*="text-left"] {
    text-align: right !important;
}

[dir="rtl"] p,
[dir="rtl"] h1,
[dir="rtl"] h2,
[dir="rtl"] h3,
[dir="rtl"] h4,
[dir="rtl"] h5,
[dir="rtl"] h6,
[dir="rtl"] blockquote,
[dir="rtl"] ul,
[dir="rtl"] ol,
[dir="rtl"] li,
[dir="rtl"] label {
    text-align: right !important;
}

[dir="rtl"] .text-center {
    text-align: center !important;
}

[dir="rtl"] .border-l,
[dir="rtl"] .border-l-2,
[dir="rtl"] .border-l-4 {
    border-left-width: 0 !important;
}

[dir="rtl"] .border-l { border-right-width: 1px !important; }
[dir="rtl"] .border-l-2 { border-right-width: 2px !important; }
[dir="rtl"] .border-l-4 { border-right-width: 4px !important; }

@media (min-width: 768px) {
    [dir="rtl"] .rtl-photo-left {
        order: 2 !important;
    }
    [dir="rtl"] .rtl-text-right {
        order: 1 !important;
    }
}


[dir="rtl"] #langMenuOptions {
    left: 0 !important;
    right: auto !important;
}

/* Tier Selector Buttons (Flawless in Dark & Light Modes) */
.tier-btn {
    background-color: var(--bg-surface) !important;
    border: 2px solid var(--border-regular) !important;
    color: var(--text-primary) !important;
    transition: all 0.25s ease !important;
    cursor: pointer;
}

.tier-btn:hover {
    border-color: rgba(217, 107, 39, 0.5) !important;
}

.tier-btn.active {
    border-color: var(--color-orange-primary) !important;
    background-color: rgba(217, 107, 39, 0.12) !important;
    box-shadow: 0 4px 18px rgba(217, 107, 39, 0.15) !important;
}

/* In-Book Mini Switcher Adaptation */
.book-edition-switcher {
    display: inline-flex;
    align-items: center;
    padding: 2px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
}

.book-light-mode .book-edition-switcher {
    border-color: rgba(0, 0, 0, 0.15) !important;
    background: rgba(0, 0, 0, 0.08) !important;
}

.book-light-mode .border-stone-800\/80 {
    border-color: rgba(0, 0, 0, 0.12) !important;
}

/* Spread Tabs in Look Inside Reader (Dark & Light Friendly) */
.spread-tab {
    border: 1px solid var(--border-regular) !important;
    background: var(--bg-card) !important;
    color: var(--text-secondary) !important;
    transition: all 0.2s ease;
}

.spread-tab:hover {
    border-color: var(--color-orange-primary) !important;
    color: var(--color-orange-primary) !important;
}

.spread-tab.active {
    border-color: var(--color-orange-primary) !important;
    background: rgba(217, 107, 39, 0.12) !important;
    color: var(--color-orange-primary) !important;
}

/* Ensure Footer and Centered Containers are Strictly Centered in All Languages */
footer,
footer *,
.text-center,
.text-center *,
[dir="rtl"] footer,
[dir="rtl"] footer *,
[dir="rtl"] .text-center,
[dir="rtl"] .text-center * {
    text-align: center !important;
}

/* Family Photo Archival Badge Alignment */
[dir="rtl"] #family .archival-badge {
    left: auto !important;
    right: 0.75rem !important;
}
@media (min-width: 640px) {
    [dir="rtl"] #family .archival-badge {
        right: 1rem !important;
    }
}

/* ==========================================================================
   MODAL NOTICE BOX - ULTRA HIGH CONTRAST IN LIGHT & DARK MODES
   ========================================================================== */
.modal-notice-box {
    border-radius: 1rem;
    padding: 0.875rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    line-height: 1.6;
    transition: var(--theme-transition);
}

.theme-light .modal-notice-box {
    background-color: #FFF7ED !important;
    border: 1.5px solid #FDBA74 !important;
    color: #1C1917 !important;
    box-shadow: 0 2px 8px -2px rgba(217, 107, 39, 0.08);
}

.theme-light .modal-notice-box #modal_step2_notice,
.theme-light .modal-notice-box span,
.theme-light .modal-notice-box p,
.theme-light .modal-notice-box strong {
    color: #1C1917 !important;
    font-weight: 600;
}

.theme-dark .modal-notice-box {
    background-color: rgba(217, 107, 39, 0.12) !important;
    border: 1.5px solid rgba(217, 107, 39, 0.35) !important;
    color: #FFFFFF !important;
}

.theme-dark .modal-notice-box #modal_step2_notice,
.theme-dark .modal-notice-box span,
.theme-dark .modal-notice-box p,
.theme-dark .modal-notice-box strong {
    color: #FFFFFF !important;
    font-weight: 500;
}
