@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-color-start: #0a0e17;
    --bg-color-end: #1c2438;
    --text-color: #f0e6d2;
    --accent-color: #d4af37; /* Gold */
    --page-bg: rgba(20, 25, 40, 0.85);
    --shadow-color: rgba(0, 0, 0, 0.5);
    --transition-speed: 1.5s;
}

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

body {
    font-family: 'Amiri', serif;
    background: linear-gradient(135deg, var(--bg-color-start), var(--bg-color-end));
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    direction: rtl;
    perspective: 1200px;
}

#particles-js {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.ambient-light {
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, rgba(212, 175, 55, 0.05) 0%, transparent 60%);
    z-index: 2;
    pointer-events: none;
}

.book-container {
    position: relative;
    width: 90%;
    max-width: 800px;
    height: 80vh;
    max-height: 600px;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    transform-style: preserve-3d;
}

.page {
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--page-bg);
    border-radius: 15px;
    box-shadow: 0 15px 35px var(--shadow-color), inset 0 0 20px rgba(212, 175, 55, 0.05);
    border: 1px solid rgba(212, 175, 55, 0.1);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3rem;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95) translateY(20px);
    transition: all var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
}

.page.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
}

.page.exit {
    opacity: 0;
    visibility: hidden;
    transform: scale(1.05) translateY(-20px);
}

/* Cover specific styles */
.cover-page {
    background: #000;
    overflow: hidden;
    border-radius: 15px;
}

.cover-image-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.cover-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.6;
    transition: opacity 2s ease;
}

.cover-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    width: 100%;
    padding: 2rem;
}

.title {
    font-family: 'Cairo', sans-serif;
    font-size: 4rem;
    font-weight: 700;
    color: var(--accent-color);
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.8), 0 0 30px rgba(212, 175, 55, 0.3);
    margin-bottom: 2rem;
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 2s ease forwards 0.5s;
    letter-spacing: 2px;
}

.subtitle {
    font-size: 1.5rem;
    color: #fff;
    opacity: 0;
    animation: fadeInUp 2s ease forwards 1.5s;
    font-family: 'Amiri', serif;
    font-style: italic;
}

.start-btn {
    margin-top: 4rem;
    padding: 1rem 3rem;
    font-size: 1.2rem;
    font-family: 'Cairo', sans-serif;
    color: var(--bg-color-start);
    background: var(--accent-color);
    border: none;
    border-radius: 30px;
    cursor: pointer;
    opacity: 0;
    animation: fadeIn 2s ease forwards 2.5s;
    transition: all 0.3s ease;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.4);
}

.start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.7);
    background: #e6c55e;
}

/* Story Pages */
.story-text {
    font-size: 2.2rem;
    line-height: 1.8;
    margin-bottom: 3rem;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
    max-width: 90%;
}

.controls {
    display: flex;
    gap: 2rem;
    margin-top: auto;
}

.nav-btn {
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 0.8rem 2rem;
    font-family: 'Cairo', sans-serif;
    font-size: 1.1rem;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    background: rgba(212, 175, 55, 0.1);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.2);
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: #666;
    color: #666;
}

.nav-btn.primary {
    background: var(--accent-color);
    color: var(--bg-color-start);
}

.nav-btn.primary:hover {
    background: #e6c55e;
    color: var(--bg-color-start);
}

.progress-container {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 20;
}

.progress-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transition: all 0.5s ease;
}

.progress-dot.active {
    background: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color);
    transform: scale(1.5);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Sound Toggle */
.sound-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    background: transparent;
    border: none;
    color: var(--accent-color);
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.7;
    transition: all 0.3s ease;
}

.sound-toggle:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Dynamic theming based on story progression */
body.theme-dawn {
    background: linear-gradient(135deg, #1c2438, #3a4b66);
}

body.theme-light {
    background: linear-gradient(135deg, #4b5d78, #869fb8);
}
body.theme-light .page {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Text Highlights */
.highlight {
    color: var(--accent-color);
    font-weight: 700;
    transition: all 0.5s ease;
}
.theme-light .highlight {
    color: #f7d45e;
}
