/* Font Face Definitions */
@font-face {
    font-family: 'Cinzel';
    src: url('../fonts/cinzel-regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Cinzel';
    src: url('../fonts/cinzel-bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
}

@font-face {
    font-family: 'Cinzel Decorative';
    src: url('../fonts/cinzel-decorative.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}

/* Overlay */
.page-flipper-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 8, 5, 0.92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.page-flipper-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Panel Container - Ancient Tome */
.page-flipper-panel {
    position: relative;
    width: 90%;
    max-width: 800px;
    height: 75vh;
    max-height: 650px;
    background:
        linear-gradient(135deg, rgba(62, 47, 32, 0.98) 0%, rgba(45, 35, 25, 0.98) 50%, rgba(55, 42, 30, 0.98) 100%);
    border: 4px solid #8b7355;
    border-radius: 4px;
    box-shadow:
        0 0 0 1px rgba(139, 115, 85, 0.3),
        0 0 40px rgba(180, 140, 80, 0.15),
        0 10px 40px rgba(0, 0, 0, 0.5),
        inset 0 0 100px rgba(0, 0, 0, 0.3);
    transform: scale(0.85) translateY(20px);
    opacity: 0;
    transition: transform 0.6s cubic-bezier(0.34, 1.3, 0.64, 1), opacity 0.6s ease;
    font-family: 'Cinzel', Georgia, serif;
    overflow: hidden;
}

.page-flipper-overlay.active .page-flipper-panel {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Parchment Texture Effect */
.page-flipper-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        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)'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
    z-index: 1;
}

/* Decorative Border Frame */
.page-flipper-panel::after {
    content: '';
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    bottom: 12px;
    border: 2px solid rgba(180, 140, 80, 0.25);
    border-radius: 2px;
    pointer-events: none;
    z-index: 2;
}

/* Corner Ornaments */
.panel-corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border-color: #b4a068;
    border-style: solid;
    z-index: 3;
}

.panel-corner.top-left {
    top: 20px;
    left: 20px;
    border-width: 2px 0 0 2px;
}

.panel-corner.top-right {
    top: 20px;
    right: 20px;
    border-width: 2px 2px 0 0;
}

.panel-corner.bottom-left {
    bottom: 20px;
    left: 20px;
    border-width: 0 0 2px 2px;
}

.panel-corner.bottom-right {
    bottom: 20px;
    right: 20px;
    border-width: 0 2px 2px 0;
}

/* Header */
.panel-header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 30px;
    border-bottom: 2px solid rgba(180, 140, 80, 0.3);
    background: linear-gradient(180deg, rgba(50, 38, 28, 0.8) 0%, rgba(40, 30, 22, 0.6) 100%);
    z-index: 5;
}

.panel-title {
    color: #d4b896;
    font-family: 'Cinzel Decorative', 'Cinzel', Georgia, serif;
    font-size: 1.3rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 4px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.panel-close {
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid rgba(160, 120, 80, 0.4);
    border-radius: 50%;
    color: #a08060;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-close:hover {
    background: rgba(160, 120, 80, 0.15);
    border-color: #c0a070;
    color: #d4b896;
}

/* Page Content Area */
.page-content-wrapper {
    position: relative;
    height: calc(100% - 140px);
    overflow: hidden;
    perspective: 1200px;
    z-index: 4;
}

.page-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 35px 40px;
    box-sizing: border-box;
    backface-visibility: hidden;
    transform-style: preserve-3d;
    opacity: 0;
    transform: rotateY(-90deg);
    transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.7s ease;
}

.page.active {
    opacity: 1;
    transform: rotateY(0deg);
    z-index: 5;
}

.page.exit-left {
    opacity: 0;
    transform: rotateY(90deg);
}

.page.exit-right {
    opacity: 0;
    transform: rotateY(-90deg);
}

.page-number {
    position: absolute;
    top: 15px;
    right: 30px;
    color: rgba(180, 160, 120, 0.5);
    font-size: 0.7rem;
    font-style: italic;
    letter-spacing: 1px;
}

.page-title {
    color: #e8d4b8;
    font-family: 'Cinzel Decorative', 'Cinzel', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 400;
    margin-bottom: 25px;
    letter-spacing: 3px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid rgba(180, 140, 80, 0.3);
    padding-bottom: 15px;
}

.page-title::first-letter {
    font-size: 1.8em;
    color: #c9a866;
}

.page-text {
    color: #c8b8a0;
    font-size: 1rem;
    line-height: 1.9;
    font-family: 'Cinzel', Georgia, serif;
    letter-spacing: 0.3px;
}

.page-text .cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background: #c9a866;
    margin-left: 2px;
    animation: quillBlink 1s infinite;
    vertical-align: middle;
}

@keyframes quillBlink {
    0%, 40% { opacity: 1; }
    50%, 90% { opacity: 0; }
    100% { opacity: 1; }
}

/* Navigation Footer */
.panel-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 30px;
    border-top: 2px solid rgba(180, 140, 80, 0.3);
    background: linear-gradient(0deg, rgba(50, 38, 28, 0.8) 0%, rgba(40, 30, 22, 0.6) 100%);
    z-index: 5;
}

.nav-button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 22px;
    background: linear-gradient(180deg, rgba(80, 60, 40, 0.4) 0%, rgba(60, 45, 30, 0.4) 100%);
    border: 1px solid rgba(180, 140, 80, 0.4);
    border-radius: 3px;
    color: #c9a866;
    font-family: 'Cinzel', Georgia, serif;
    font-size: 0.85rem;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nav-button:hover:not(:disabled) {
    background: linear-gradient(180deg, rgba(100, 75, 50, 0.5) 0%, rgba(80, 60, 40, 0.5) 100%);
    border-color: #c9a866;
    box-shadow: 0 0 15px rgba(180, 140, 80, 0.2);
    transform: translateY(-2px);
}

.nav-button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.nav-button .arrow {
    font-size: 1.1rem;
}

.page-indicator {
    display: flex;
    gap: 12px;
    align-items: center;
}

.indicator-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(180, 140, 80, 0.25);
    border: 1px solid rgba(180, 140, 80, 0.5);
    cursor: pointer;
    transition: all 0.3s ease;
}

.indicator-dot:hover {
    background: rgba(180, 140, 80, 0.45);
    transform: scale(1.15);
}

.indicator-dot.active {
    background: #c9a866;
    box-shadow: 0 0 8px rgba(200, 160, 100, 0.5);
    transform: scale(1.15);
}

/* Glowing Border Animation */
@keyframes tomeGlow {
    0%, 100% {
        box-shadow:
            0 0 0 1px rgba(139, 115, 85, 0.3),
            0 0 40px rgba(180, 140, 80, 0.1),
            0 10px 40px rgba(0, 0, 0, 0.5),
            inset 0 0 100px rgba(0, 0, 0, 0.3);
    }
    50% {
        box-shadow:
            0 0 0 1px rgba(139, 115, 85, 0.4),
            0 0 60px rgba(180, 140, 80, 0.2),
            0 10px 40px rgba(0, 0, 0, 0.5),
            inset 0 0 100px rgba(0, 0, 0, 0.3);
    }
}

.page-flipper-overlay.active .page-flipper-panel {
    animation: tomeGlow 4s ease-in-out infinite;
}

/* Trigger Button */
.open-panel-btn {
    padding: 16px 35px;
    background: linear-gradient(180deg, rgba(80, 60, 40, 0.5) 0%, rgba(55, 42, 30, 0.6) 100%);
    border: 2px solid rgba(180, 140, 80, 0.5);
    border-radius: 3px;
    color: #d4b896;
    font-family: 'Cinzel', Georgia, serif;
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 3px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 30px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.open-panel-btn:hover {
    background: linear-gradient(180deg, rgba(100, 75, 50, 0.6) 0%, rgba(70, 52, 38, 0.7) 100%);
    border-color: #c9a866;
    box-shadow: 0 0 25px rgba(180, 140, 80, 0.25);
    transform: translateY(-3px);
}

/* Text Emphasis Classes */
.text-magic {
    color: #a0c4e8;
    text-shadow: 0 0 8px rgba(160, 196, 232, 0.4);
    font-style: italic;
}

.text-important {
    color: #e8c878;
    text-shadow: 0 0 6px rgba(232, 200, 120, 0.3);
}

.text-danger {
    color: #d4a0a0;
    text-shadow: 0 0 6px rgba(212, 160, 160, 0.3);
}

.text-elvish {
    color: #a8d4b8;
    font-style: italic;
    text-shadow: 0 0 8px rgba(168, 212, 184, 0.3);
}

/* Decorative Divider */
.divider {
    display: block;
    text-align: center;
    color: rgba(180, 140, 80, 0.5);
    margin: 15px 0;
    font-size: 1.2rem;
    letter-spacing: 8px;
}

/* Responsive */
@media (max-width: 768px) {
    .page-flipper-panel {
        width: 95%;
        height: 85vh;
        border-width: 3px;
    }

    .panel-title {
        font-size: 1rem;
        letter-spacing: 2px;
    }

    .page {
        padding: 25px 20px;
    }

    .page-title {
        font-size: 1.2rem;
    }

    .page-text {
        font-size: 0.9rem;
        line-height: 1.7;
    }

    .nav-button {
        padding: 8px 16px;
        font-size: 0.75rem;
    }
}
