/* --- 3D Book Cover Entry Screen --- */
.cover-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: #050505;
    transition: opacity 1.2s cubic-bezier(0.645, 0.045, 0.355, 1);
    padding: 20px;
}

.cover-screen.opened {
    opacity: 0;
    pointer-events: none;
}

.cover-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    filter: brightness(0.4) blur(4px);
    z-index: -1;
    transform: scale(1.1);
    transition: transform 2s ease, background-position 0.5s ease;
}

.cover-screen.opened .cover-bg {
    transform: scale(1.2);
}

/* Welcome Message */
.cover-welcome {
    text-align: center;
    max-width: 800px;
    margin-bottom: 30px;
    z-index: 100;
    position: relative;
    pointer-events: none;
    animation: fadeInWelcome 1.5s ease-out backwards 0.5s;
}

.welcome-title {
    color: #FFD700;
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-family: 'Playfair Display', serif;
    text-shadow:
        0 0 10px rgba(255, 69, 0, 0.8),
        0 0 20px rgba(255, 0, 0, 0.6);
    animation: fireGlow 3s infinite alternate;
}

.welcome-body {
    color: rgba(255, 255, 255, 0.9);
    font-size: clamp(0.9rem, 3vw, 1.1rem);
    line-height: 1.5;
    max-width: 650px;
    margin: 0 auto;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
    font-weight: 300;
}

@keyframes fireGlow {
    0% {
        text-shadow: 0 0 10px #FF4500, 0 0 20px #FF0000, 0 0 30px #FF0000;
        transform: scale(1);
    }

    100% {
        text-shadow: 0 0 15px #FFD700, 0 0 30px #FF4500, 0 0 50px #FF0000;
        transform: scale(1.02);
    }
}

@keyframes fadeInWelcome {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header & Footer */
.cover-header {
    position: absolute;
    top: 30px;
    right: 40px;
    z-index: 100;
}

.cover-footer {
    position: absolute;
    bottom: 20px;
    /* Moved slightly down */
    z-index: 100;
    width: 100%;
    display: flex;
    justify-content: center;
}

.tg-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #D4AF37;
    text-decoration: none;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    padding: 10px 20px;
    background: rgba(212, 175, 55, 0.1);
    border-radius: 30px;
    border: 1px solid rgba(212, 175, 55, 0.3);
    transition: all 0.3s ease;
}

.tg-link:hover {
    background: rgba(212, 175, 55, 0.2);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.2);
    transform: translateY(-2px);
    color: #fff;
}

.cover-lang-wrapper .lang-select {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: #D4AF37;
    padding: 8px 15px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    outline: none;
    cursor: pointer;
    backdrop-filter: blur(10px);
}

/* Book Container (Increased Volume) */
.book-container {
    perspective: 2000px;
    width: 420px;
    height: 580px;
    position: relative;
    z-index: 10;
    margin-top: -50px;
    /* Bias upward to clear footer */
}

.book {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1.8s cubic-bezier(0.645, 0.045, 0.355, 1);
    transform: rotateY(-25deg) rotateX(10deg);
}

.book.open {
    transform: rotateY(-15deg) translateX(50px) rotateX(0deg);
}

.book-cover {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 4px 16px 16px 4px;
    box-shadow: 30px 30px 80px rgba(0, 0, 0, 0.9);
    transform-origin: left;
    transform-style: preserve-3d;
    transition: transform 1.8s cubic-bezier(0.645, 0.045, 0.355, 1);
}

.book-cover.front {
    z-index: 5;
    background: linear-gradient(135deg, #1a1a1a 0%, #0a0a0a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    overflow: hidden;
    backface-visibility: hidden;
    border: 2px solid;
    border-image: linear-gradient(to bottom, #D4AF37, #FFFFFF, #D4AF37) 1;
}

.book-cover.back {
    transform: translateZ(-80px);
    /* Thicker - 80px */
    background: #0a0a0a;
    border-left: 2px solid #D4AF37;
}

.book-spine {
    position: absolute;
    left: 0;
    width: 80px;
    height: 100%;
    background: linear-gradient(to right, #0a0a0a, #1a1a1a 20%, #0a0a0a 80%, #000);
    transform: rotateY(-90deg);
    transform-origin: left;
    display: flex;
    align-items: center;
    justify-content: center;
    border-left: 1px solid rgba(212, 175, 55, 0.5);
    border-right: 1px solid rgba(212, 175, 55, 0.5);
    z-index: 2;
}

.spine-text {
    color: #D4AF37;
    font-family: 'Playfair Display', serif;
    font-size: 0.8rem;
    white-space: nowrap;
    transform: rotate(90deg);
    letter-spacing: 2px;
    text-transform: uppercase;
    opacity: 0.6;
}

.book-pages {
    position: absolute;
    width: 96%;
    height: 96%;
    top: 2%;
    left: 2%;
    background: #fdfcf0;
    transform: translateZ(-79px);
    /* Just behind the back cover */
    border-radius: 0 4px 4px 0;
    box-shadow:
        inset -5px 0 10px rgba(0, 0, 0, 0.2),
        -5px 0 20px rgba(0, 0, 0, 0.3);
}

.page {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, #fdfcf0 95%, #ddd);
    top: 0;
    left: 0;
    border-right: 1px solid rgba(0, 0, 0, 0.1);
}

/* Page Stack Effect */
.page-1 {
    transform: translateZ(10px);
}

.page-2 {
    transform: translateZ(25px);
}

.page-3 {
    transform: translateZ(40px);
}

.page-4 {
    transform: translateZ(55px);
}

.page-5 {
    transform: translateZ(70px);
}

/* Premium Decorations */
.metallic-border {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    border: 1px solid rgba(212, 175, 55, 0.4);
    pointer-events: none;
}

.metallic-corner {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 2px solid #D4AF37;
    z-index: 10;
}

.metallic-corner.top-left {
    top: 10px;
    left: 10px;
    border-right: none;
    border-bottom: none;
}

.metallic-corner.top-right {
    top: 10px;
    right: 10px;
    border-left: none;
    border-bottom: none;
}

.metallic-corner.bottom-left {
    bottom: 10px;
    left: 10px;
    border-right: none;
    border-top: none;
}

.metallic-corner.bottom-right {
    bottom: 10px;
    right: 10px;
    border-left: none;
    border-top: none;
}

/* Metallic Gradients for Text */
.cover-title {
    font-family: 'Playfair Display', serif;
    font-size: 2.4rem;
    margin-bottom: 5px;
    background: linear-gradient(135deg, #f5e6a3 0%, #D4AF37 40%, #FFFFFF 50%, #D4AF37 60%, #c9a033 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 15px rgba(212, 175, 55, 0.4));
    margin-top: 0;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.cover-year {
    font-family: 'Playfair Display', serif;
    font-size: 1.6rem;
    background: linear-gradient(to bottom, #FFFFFF, #D4AF37);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 6px;
    margin-bottom: 50px;
    font-weight: bold;
}

/* Form Styling */
.login-box {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
    animation: fadeInCover 1.2s ease-out 0.8s both;
}

@keyframes fadeInCover {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-input {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(212, 175, 55, 0.2);
    color: #fff;
    padding: 14px 18px;
    border-radius: 10px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s ease;
}

.login-input:focus {
    border-color: #D4AF37;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.2), inset 0 0 10px rgba(255, 255, 255, 0.05);
}

.warning-text {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    line-height: 1.5;
    font-style: italic;
    margin: 5px 0;
    text-align: center;
}

.login-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

.login-button {
    flex: 1;
    padding: 14px;
    border-radius: 10px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.login-button.primary {
    background: linear-gradient(135deg, #D4AF37 0%, #f5e6a3 50%, #D4AF37 100%);
    color: #000;
    border: none;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}

.login-button.primary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(212, 175, 55, 0.5);
}

.login-button.secondary {
    background: transparent;
    color: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
}

.login-button.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #D4AF37;
    color: #D4AF37;
    transform: translateY(-2px);
}

/* Response for Opening */
.book.open .book-cover.front {
    transform: rotateY(-165deg);
}

/* Hide cover content when open */
.book.open .cover-art,
.book.open .cover-header,
.book.open .cover-footer,
.book.open .login-box {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

/* Exit Button Styles */
.exit-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1500;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: #D4AF37;
    padding: 8px 16px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.exit-btn:hover {
    background: rgba(212, 175, 55, 0.1);
    border-color: #D4AF37;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.2);
    transform: translateY(-2px);
}

.exit-btn svg {
    transition: transform 0.3s ease;
}

.exit-btn:hover svg {
    transform: translateX(-3px);
}

/* --- RTL Support (Arabic) --- */
[dir="rtl"] .book {
    transform: rotateY(25deg) rotateX(10deg);
}

[dir="rtl"] .book.open {
    transform: rotateY(15deg) translateX(-50px) rotateX(0deg);
}

[dir="rtl"] .book-cover {
    transform-origin: right;
    border-radius: 16px 4px 4px 16px;
}

[dir="rtl"] .book-cover.back {
    border-left: none;
    border-right: 2px solid #D4AF37;
}

[dir="rtl"] .book-spine {
    left: auto;
    right: 0;
    transform-origin: right;
    transform: rotateY(90deg);
    background: linear-gradient(to left, #0a0a0a, #1a1a1a 20%, #0a0a0a 80%, #000);
}

[dir="rtl"] .book-pages {
    left: auto;
    right: 2%;
    border-radius: 4px 0 0 4px;
    box-shadow:
        inset 5px 0 10px rgba(0, 0, 0, 0.2),
        5px 0 20px rgba(0, 0, 0, 0.3);
}

[dir="rtl"] .page {
    border-right: none;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    background: linear-gradient(to left, #fdfcf0 95%, #ddd);
}

[dir="rtl"] .book.open .book-cover.front {
    transform: rotateY(165deg);
}

[dir="rtl"] .exit-btn {
    right: auto;
    left: 20px;
}

[dir="rtl"] .exit-btn:hover svg {
    transform: translateX(3px);
}

[dir="rtl"] .metallic-corner.top-left {
    border-left: none;
    border-right: 2px solid #D4AF37;
}

[dir="rtl"] .metallic-corner.top-right {
    border-right: none;
    border-left: 2px solid #D4AF37;
}

[dir="rtl"] .metallic-corner.bottom-left {
    border-left: none;
    border-right: 2px solid #D4AF37;
}

[dir="rtl"] .metallic-corner.bottom-right {
    border-right: none;
    border-left: 2px solid #D4AF37;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 600px) {
    .book-container {
        width: 280px;
        height: 400px;
        perspective: 1200px;
        margin-top: -30px;
        /* Bias upward for mobile */
    }

    .book {
        transform: rotateY(15deg) rotateX(5deg);
    }

    [dir="rtl"] .book {
        transform: rotateY(-15deg) rotateX(5deg);
    }

    .book.open {
        transform: rotateY(-5deg) translateX(20px) scale(0.9);
    }

    [dir="rtl"] .book.open {
        transform: rotateY(5deg) translateX(-20px) scale(0.9);
    }

    .cover-title {
        font-size: 1.5rem;
        letter-spacing: 2px;
    }

    .cover-year {
        font-size: 1.2rem;
    }

    .login-box {
        padding: 15px;
    }

    .login-input {
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    .login-button {
        padding: 12px;
        font-size: 0.8rem;
    }

    .exit-btn {
        top: 10px;
        right: 10px;
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    [dir="rtl"] .exit-btn {
        left: 10px;
    }

    .book-spine {
        width: 60px;
    }

    .spine-text {
        font-size: 0.7rem;
    }
}

@media (max-width: 400px) {
    .book-container {
        width: 240px;
        height: 360px;
        margin-top: -20px;
    }

    .cover-title {
        font-size: 1.3rem;
    }
}
/* Mobile Image Visibility Fix */
@media (max-width: 768px) {
    .cover-bg {
        background-position: 35% center !important;
    }
}
