/* ========================================
   MYSTICAL BOOK UI - CSS Component
   For Event Followers Chat Rooms
   ======================================== */

/* Book Container */
.book-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 2000px;
}

/* The Closed Book */
.mystical-book {
    position: relative;
    width: 90%;
    max-width: 450px;
    height: 85%;
    max-height: 650px;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.3s ease;
}

/* Book with Custom Cover Image */
.mystical-book.has-cover-image .book-cover {
    background: none;
    padding: 0;
    overflow: hidden;
}

.mystical-book.has-cover-image .book-cover-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px 15px 15px 5px;
    z-index: 0;
}

.mystical-book.has-cover-image .book-title,
.mystical-book.has-cover-image .book-symbol,
.mystical-book.has-cover-image .book-instruction {
    display: none;
}

.mystical-book.has-cover-image .book-corner {
    display: none;
}

/* Hover glow effect for cover image */
.mystical-book.has-cover-image:hover {
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.4);
}

/* Click instruction overlay for image covers */
.mystical-book.has-cover-image .cover-click-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.7);
    color: #ffd700;
    padding: 8px 20px;
    border-radius: 20px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 10;
}

.mystical-book.has-cover-image:hover .cover-click-hint {
    opacity: 1;
}

.mystical-book:hover {
    transform: scale(1.02) rotateY(-5deg);
}

.mystical-book.open {
    pointer-events: none;
}

/* Book Cover */
.book-cover {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #2a1a0a 0%, #4a2a1a 50%, #2a1a0a 100%);
    border-radius: 5px 15px 15px 5px;
    box-shadow:
        -5px 5px 20px rgba(0,0,0,0.5),
        inset 0 0 50px rgba(0,0,0,0.3),
        inset -3px 0 10px rgba(255,215,0,0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 30px;
    border-left: 8px solid #1a0a00;
}

/* Book Spine Effect */
.book-cover::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 15px;
    height: 100%;
    background: linear-gradient(90deg, #1a0a00 0%, #3a1a0a 50%, #2a1a0a 100%);
    border-radius: 5px 0 0 5px;
}

/* Leather Texture */
.book-cover::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.15'/%3E%3C/svg%3E");
    border-radius: 5px 15px 15px 5px;
    pointer-events: none;
}

/* Book Title */
.book-title {
    font-family: 'Cinzel', 'Times New Roman', serif;
    font-size: 1.4rem;
    color: #ffd700;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    margin-bottom: 20px;
    z-index: 1;
    letter-spacing: 2px;
}

/* Book Symbol */
.book-symbol {
    font-size: 4rem;
    margin-bottom: 20px;
    z-index: 1;
    filter: drop-shadow(0 0 10px rgba(255,215,0,0.5));
}

/* Book Instruction */
.book-instruction {
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.9rem;
    color: #aa8855;
    z-index: 1;
    opacity: 0.8;
}

/* Corner Decorations */
.book-corner {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 2px solid #8b6914;
    z-index: 1;
}

.book-corner.top-left {
    top: 15px;
    left: 25px;
    border-right: none;
    border-bottom: none;
}

.book-corner.top-right {
    top: 15px;
    right: 15px;
    border-left: none;
    border-bottom: none;
}

.book-corner.bottom-left {
    bottom: 15px;
    left: 25px;
    border-right: none;
    border-top: none;
}

.book-corner.bottom-right {
    bottom: 15px;
    right: 15px;
    border-left: none;
    border-top: none;
}

/* ========================================
   OPENED BOOK STATE
   ======================================== */

.book-opened {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.book-opened.visible {
    display: flex;
    opacity: 1;
}

/* Articles Grid (2x2) */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    flex: 1;
    margin-bottom: 15px;
}

/* Article Card */
.article-card {
    background: linear-gradient(145deg, #3a2a1a 0%, #2a1a0a 100%);
    border: 1px solid #5a4a3a;
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.article-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,215,0,0.1) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s;
}

.article-card:hover {
    transform: translateY(-3px);
    border-color: #ffd700;
    box-shadow: 0 5px 20px rgba(255,215,0,0.2);
}

.article-card:hover::before {
    opacity: 1;
}

.article-card .article-number {
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    color: #ffd700;
    opacity: 0.3;
    position: absolute;
    top: 10px;
    right: 15px;
}

.article-card h3 {
    font-family: 'Cinzel', 'Times New Roman', serif;
    font-size: 1.1rem;
    color: #ffd700;
    margin-bottom: 8px;
    z-index: 1;
}

.article-card .subtitle {
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.85rem;
    color: #aa9977;
    z-index: 1;
    flex: 1;
}

.article-card .read-more {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    color: #ffd700;
    margin-top: 10px;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1;
}

.article-card:hover .read-more {
    opacity: 1;
}

/* Close Book Button */
.close-book-btn {
    background: rgba(255,215,0,0.1);
    border: 1px solid #ffd700;
    color: #ffd700;
    padding: 10px 25px;
    border-radius: 25px;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    transition: all 0.3s;
    align-self: center;
}

.close-book-btn:hover {
    background: rgba(255,215,0,0.2);
}

/* ========================================
   ARTICLE VIEW
   ======================================== */

.article-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.article-view.visible {
    display: flex;
    opacity: 1;
}

.article-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255,215,0,0.2);
}

.back-to-book {
    background: none;
    border: 1px solid #ffd700;
    color: #ffd700;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.back-to-book:hover {
    background: rgba(255,215,0,0.1);
}

.article-title-header {
    font-family: 'Cinzel', serif;
    color: #ffd700;
    font-size: 1rem;
}

/* Article Content - Matches existing newspaper style */
.article-content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
}

.article-content-wrapper h1 {
    font-family: 'Cinzel', serif;
    font-size: 1.8rem;
    color: #ffd700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.article-content-wrapper .article-subtitle {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.1rem;
    color: #aa9977;
    margin-bottom: 25px;
    font-style: italic;
}

.article-content-wrapper .article-body {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.1rem;
    color: #d4c4a4;
    line-height: 1.8;
}

.article-content-wrapper .article-body p {
    margin-bottom: 18px;
    text-align: justify;
}

.article-content-wrapper .article-body strong {
    color: #ffd700;
}

.article-content-wrapper .article-body em {
    color: #ffaa44;
}

.article-content-wrapper .article-body .source {
    font-style: italic;
    color: #aa8866;
    border-left: 3px solid #ffd700;
    padding-left: 15px;
    margin-top: 30px;
}

/* ========================================
   BOOK OPEN ANIMATION
   ======================================== */

@keyframes bookOpen {
    0% {
        transform: rotateY(0deg);
    }
    100% {
        transform: rotateY(-180deg);
    }
}

.mystical-book.opening .book-cover {
    animation: bookOpen 0.8s ease-out forwards;
    transform-origin: left center;
}

/* Page flip effect */
@keyframes pageFlip {
    0% {
        transform: rotateY(0deg);
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        transform: rotateY(-90deg);
        opacity: 0;
    }
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 600px) {
    .articles-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .article-card {
        padding: 15px;
    }

    .article-card h3 {
        font-size: 1rem;
    }

    .mystical-book {
        width: 280px;
        height: 370px;
    }

    .book-title {
        font-size: 1.1rem;
    }

    .book-symbol {
        font-size: 3rem;
    }
}
