@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=Cinzel:wght@400;500;600;700&display=swap');

:root {
    --primary-color: #5d4a28;
    --accent-color: #c8a76c;
    --bg-color: #fffdf8;
    --page-color: #fdf8ed;
    --blank-page-color: #f5ecd8;
    --text-color: #2c2416;
    --border-color: #d9c9a3;
    --shadow-color: rgba(0, 0, 0, 0.2);
}

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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'EB Garamond', 'Times New Roman', serif;
    background-color: #2c2416;
    color: var(--text-color);
    line-height: 1.5;
}

/* Add new utility class at the beginning of the file */
.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Welcome Screen */
.welcome-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #5d4a28 0%, #9c7a3b 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.8s ease-in-out, transform 0.8s ease-in-out;
}

.welcome-content {
    text-align: center;
    padding: 2rem;
    width: min(90%, 800px);
    background: rgba(253, 248, 237, 0.9);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transform: translateY(0);
    transition: transform 0.5s ease-out;
    position: relative;
    overflow: hidden;
}

.welcome-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 2px solid var(--border-color);
    pointer-events: none;
    border-radius: 8px;
    margin: 10px;
}

.welcome-title {
    font-family: 'Cinzel', serif;
    font-size: clamp(1.5rem, 4vw, 3rem);
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    position: relative;
}

.welcome-title::after {
    content: '';
    position: absolute;
    left: 20%;
    right: 20%;
    bottom: -10px;
    height: 3px;
    background: linear-gradient(to right, transparent, var(--accent-color), transparent);
}

.welcome-author {
    font-family: 'Cinzel', serif;
    font-size: clamp(1rem, 2vw, 1.5rem);
    margin: 1.5rem 0 1rem;
    color: #6a5530;
}

.welcome-description {
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    margin-bottom: 2rem;
    line-height: 1.6;
    color: #4a4030;
    width: min(100%, 500px);
    margin-left: auto;
    margin-right: auto;
}

.welcome-buttons {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 20px;
    margin-bottom: 2rem;
}

@media (max-width: 600px) {
    .welcome-buttons {
        flex-direction: column;
        gap: 15px;
    }
}

.start-btn {
    display: inline-block;
    font-family: 'Cinzel', serif;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    padding: 0.8rem 2.5rem;
    background: linear-gradient(to right, #c8a76c, #9c7a3b);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
}

.book-btn {
    display: inline-block;
    font-family: 'Cinzel', serif;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    padding: 0.8rem 2.5rem;
    background: transparent;
    color: #9c7a3b;
    border: 2px solid #c8a76c;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    text-decoration: none;
}

.book-btn:hover {
    background-color: rgba(200, 167, 108, 0.1);
    transform: translateY(-3px);
    box-shadow: 0 7px 20px rgba(0, 0, 0, 0.15);
}

.start-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.7s;
}

.start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 7px 20px rgba(0, 0, 0, 0.2);
}

.start-btn:hover::before {
    left: 100%;
}

.welcome-ornament {
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--accent-color);
    margin: 1rem 0;
    opacity: 0.7;
}

/* Book Container */
.book-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
    transition: opacity 0.8s ease-in-out, visibility 0.8s ease-in-out;
    padding: 0 10px;
}

.book {
    position: relative;
    width: min(98vw, calc(98vh * 1.5));
    height: min(98vh, calc(98vw / 1.5));
    box-shadow: 0 40px 80px rgba(0,0,0,0.4);
    margin: 0 auto;
}

/* Book Pages */
.page {
    position: relative;
    background-color: var(--page-color);
    box-shadow: 0 0 5px rgba(0,0,0,0.1);
    overflow: hidden;
    /* Add consistent properties for all pages */
    transform-origin: 50% 50%;
    backface-visibility: hidden;
    transform-style: preserve-3d;
}

/* Page Decorations */
.border-design {
    position: absolute;
    top: 5%;
    left: 5%;
    right: 5%;
    bottom: 5%;
    border: 2px solid var(--border-color);
    pointer-events: none;
    z-index: 1;
}

.inner-border {
    position: absolute;
    top: 7%;
    left: 7%;
    right: 7%;
    bottom: 7%;
    border: 1px solid var(--border-color);
    pointer-events: none;
    z-index: 1;
}

.decorative-line {
    position: absolute;
    height: 5px;
    left: 10%;
    right: 10%;
    background: linear-gradient(to right, 
        transparent 0%, 
        #e6d0a5 20%, 
        #c8a76c 30%, 
        #dabe89 70%, 
        #e6d0a5 80%, 
        transparent 100%);
    opacity: 0.7;
    z-index: 1;
}

.top-line {
    top: 9%;
}

.bottom-line {
    bottom: 9%;
}

.corner-ornament {
    position: absolute;
    width: 40px;
    height: 40px;
    background-image: url("data:image/svg+xml,%3Csvg width='70' height='70' viewBox='0 0 70 70' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1,1 L69,1 L69,69 C50,50 30,30 15,15 C10,10 5,5 1,1 Z' stroke='%23c8a76c' stroke-width='1.5' fill='none'/%3E%3Cpath d='M15,15 C25,25 40,40 55,55' stroke='%23c8a76c' stroke-width='1' fill='none' opacity='0.6'/%3E%3Cpath d='M20,10 L10,20' stroke='%23c8a76c' stroke-width='1' fill='none' opacity='0.6'/%3E%3Cpath d='M30,10 L10,30' stroke='%23c8a76c' stroke-width='1' fill='none' opacity='0.6'/%3E%3Cpath d='M40,10 L10,40' stroke='%23c8a76c' stroke-width='1' fill='none' opacity='0.6'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.8;
    z-index: 1;
}

.corner-tl {
    top: 5%;
    left: 5%;
    transform: rotate(0deg);
}

.corner-tr {
    top: 5%;
    right: 5%;
    transform: rotate(90deg);
}

.corner-bl {
    bottom: 5%;
    left: 5%;
    transform: rotate(270deg);
}

.corner-br {
    bottom: 5%;
    right: 5%;
    transform: rotate(180deg);
}

.background-texture {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0.15;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.2 0' /%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23noise)' fill='%23c8a76c' fill-opacity='0.15'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 100px 100px;
    z-index: 0;
}

/* Title Page */
.title-page {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
    position: relative;
    padding: 10%;
    text-align: center;
    z-index: 2;
}

.title-ornament {
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    color: var(--accent-color);
    line-height: 1;
    margin: 15px 0;
    opacity: 0.7;
    text-shadow: 0px 0px 2px rgba(0,0,0,0.1);
}

.title-frame {
    position: relative;
    padding: 30px 40px;
    margin: 10px 0 20px;
    width: 100%;
    max-width: 80%;
}

.title-frame::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 2px solid var(--border-color);
    opacity: 0.8;
}

.title {
    font-family: 'Cinzel', serif;
    font-size: clamp(1.2rem, 3vw, 2.2rem);
    font-weight: 700;
    margin: 0;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 3px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
    position: relative;
    display: inline-block;
    line-height: 1.3;
}

.title::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -12px;
    height: 3px;
    background: linear-gradient(to right, transparent, var(--accent-color), transparent);
}

.author {
    font-family: 'Cinzel', serif;
    font-size: clamp(0.9rem, 2vw, 1.3rem);
    margin: 25px 0 15px;
    color: #6a5530;
    letter-spacing: 2px;
}

.year {
    font-size: clamp(0.8rem, 1.5vw, 1.1rem);
    font-style: italic;
    color: #6a5530;
    margin-top: 15px;
    letter-spacing: 1px;
}

/* Phrases */
.phrase-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10%;
    position: relative;
    z-index: 2;
}

.phrase {
    font-size: clamp(1rem, 2vw, 1.6rem);
    line-height: 1.7;
    text-align: center;
    color: var(--text-color);
    max-width: 85%;
    position: relative;
    font-weight: 500;
    padding: 0 30px;
}

.phrase::before, .phrase::after {
    font-family: 'EB Garamond', serif;
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 0;
    color: var(--accent-color);
    opacity: 0.3;
    position: absolute;
}

.phrase::before {
    content: '\201C'; /* Left double quotation mark */
    top: -0.2em;
    left: -0.1em;
}

.phrase::after {
    content: '\201D'; /* Right double quotation mark */
    bottom: -0.7em;
    right: -0.1em;
}

.phrase-number {
    font-family: 'Cinzel', serif;
    font-weight: 600;
    color: var(--accent-color);
    margin-right: 5px;
    font-size: 110%;
}

.page-number {
    position: absolute;
    bottom: 5%;
    font-family: 'Cinzel', serif;
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    color: #9c7a3b;
    z-index: 2;
    text-align: center;
    width: 100%;
}

/* Navigation Controls */
.navigation {
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    z-index: 1000;
    padding: 10px;
    pointer-events: none; /* Make container transparent to clicks */
}

.nav-btn {
    background: rgba(200, 167, 108, 0.2);
    color: #fdf8ed;
    border: 2px solid rgba(200, 167, 108, 0.3);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.2rem;
    backdrop-filter: blur(5px);
    pointer-events: auto; /* Re-enable pointer events */
}

.nav-btn:hover {
    background: rgba(200, 167, 108, 0.4);
    transform: translateY(-3px);
}

.nav-btn:active {
    transform: translateY(-1px);
}

.nav-text {
    background: rgba(43, 36, 22, 0.7);
    color: #fdf8ed;
    padding: 5px 15px;
    border-radius: 20px;
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    backdrop-filter: blur(5px);
    pointer-events: auto; /* Re-enable pointer events */
}

/* Remove all the unnecessary page turning effect styles */
.page-turn-effect { display: none !important; }
.play-turn-effect { display: none !important; }
.blank-page { display: none !important; }
.gold-loader { display: none !important; }
.loader-spinner { display: none !important; }

/* Empty keyframes to override existing ones */
@keyframes pageTurnEffect { 
    0% { opacity: 0; }
    100% { opacity: 0; }
}

@keyframes spin { 
    0% { transform: rotate(0deg); }
    100% { transform: rotate(0deg); }
}

/* Ensure StPageFlip has the right CSS settings */
.stf__parent {
    position: relative;
    display: block;
    z-index: 1; 
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    overflow: hidden;
}

/* Customize StPageFlip shadow if needed */
.stf__block {
    position: absolute;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    perspective: 2000px;
}

/* Remove all the classes that hide previous animation code to prevent conflicts */
.page.current-page {
    display: inherit !important;
}
.page.turning-page {
    display: inherit !important;
}
.page.turning-page::before {
    display: inherit !important;
}
.page.turning-page::after {
    display: inherit !important;
}
.page.next-page {
    display: inherit !important;
}
.page-front {
    display: inherit !important;
}
.page-back {
    display: inherit !important;
}

/* Page content styles */
.page-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 5%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--page-color);
}

/* Page shadow effect */
.page::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, 
        rgba(0,0,0,0.1) 0%, 
        transparent 10%, 
        transparent 90%, 
        rgba(0,0,0,0.05) 100%);
    pointer-events: none;
    z-index: 3;
}

/* Add responsive styles for the book */
@media (max-width: 1080px) {
    .book-container {
        padding: 0;
        will-change: transform; /* Optimize for animations */
        transform: translateY(0); /* Ensure initial position is consistent */
        transform-origin: center center; /* Ensure stable scaling */
    }
    
    .book {
        width: min(95vw, calc(95vh * 1.4));
        height: min(95vh, calc(95vw / 1.4));
        margin: 0 auto;
    }
    
    .stf__parent {
        width: 100% !important;
        height: 100% !important;
    }
    
    .stf__block {
        width: 100% !important;
        height: 100% !important;
    }
    
    .navigation {
        bottom: 15px;
    }
}

@media (max-width: 768px) {
    .book {
        width: calc(100vw - 20px);
        height: calc(90vh - 100px);
        max-width: 95%;
        margin: 0 auto;
    }
    
    .phrase {
        font-size: clamp(0.9rem, 4vw, 1.4rem);
        padding: 0 15px;
        max-width: 90%;
    }
    
    .page-number {
        bottom: 3%;
    }
    
    .decorative-line {
        left: 6%;
        right: 6%;
    }
    
    .border-design, .inner-border {
        top: 3%;
        left: 3%;
        right: 3%;
        bottom: 3%;
    }
    
    .corner-ornament {
        width: 30px;
        height: 30px;
    }
    
    .navigation {
        bottom: 10px;
    }
    
    .nav-btn {
        width: 40px;
        height: 40px;
    }
    
    .home-button {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
        top: 15px;
        right: 15px;
    }
}

@media (max-width: 480px) {
    .book {
        width: calc(100vw - 16px);
        height: calc(100vh - 80px);
        max-width: 100%;
    }
    
    .phrase {
        font-size: clamp(0.8rem, 3.5vw, 1.2rem);
        padding: 0 10px;
        max-width: 95%;
    }
    
    .page-content {
        padding: 3%;
    }
    
    .nav-btn {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
    
    .nav-text {
        font-size: 0.8rem;
        padding: 3px 10px;
    }
    
    .corner-ornament {
        width: 20px;
        height: 20px;
    }
}

/* Portrait mode adjustments */
@media (orientation: portrait) {
    .book {
        width: min(95vw, calc(85vh * 0.7));
        height: min(85vh, calc(95vw / 0.7));
        aspect-ratio: 0.7; /* Portrait book aspect ratio */
    }
    
    .stf__parent {
        width: 100% !important;
        height: 100% !important;
        aspect-ratio: 0.7;
    }
    
    .stf__block {
        width: 100% !important;
        height: 100% !important;
        aspect-ratio: 0.7;
    }
}

/* Home button styles */
.home-button {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(200, 167, 108, 0.2);
    color: #fdf8ed;
    border: 2px solid rgba(200, 167, 108, 0.3);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.3rem;
    backdrop-filter: blur(5px);
    z-index: 2000;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.home-button:hover {
    background: rgba(200, 167, 108, 0.4);
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.25);
}

.home-button:active {
    transform: translateY(-1px);
}

/* Hide elements initially */
.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Responsive adjustments for home button */
@media (max-width: 768px) {
    .home-button {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
        top: 15px;
        right: 15px;
    }
}

@media (max-width: 480px) {
    .home-button {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
        top: 10px;
        right: 10px;
    }
}

/* Fix for jumpy cover turn on small screens */
@media (max-width: 1003px) {
    .stf__parent {
        transform: translateY(0) !important;
        transform-origin: center center !important;
    }
    
    .stf__block {
        transform: translateY(0) !important;
        transform-origin: center center !important;
    }

    /* Ensure consistent book positioning during page flips */
    .stf__wrapper {
        transform: none !important;
        transform-origin: center center !important;
    }

    /* Stabilize during page turn */
    .stf__wrapper.stf__wrapper--turn {
        transform: none !important;
    }
}

/* Ensure StPageFlip treats all pages the same */
.stf__item {
    backface-visibility: hidden;
    transform-style: preserve-3d;
    position: absolute;
    background-color: var(--page-color);
}

.stf__page {
    background-color: var(--page-color);
}

/* Make sure all pages have the same shadow effect */
.stf__item.--hard {
    background-color: var(--page-color) !important;
    box-shadow: 0 0 5px rgba(0,0,0,0.1) !important;
}

/* Remove any special treatment for different page types */
.stf__page-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Blank page content */
.blank-page-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 5%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--page-color);
}

/* Make sure the hidden blank page still has decorative elements */
.blank-page-content .border-design,
.blank-page-content .inner-border,
.blank-page-content .decorative-line,
.blank-page-content .corner-ornament {
    opacity: 0.6; /* Slightly lighter decorative elements */
} 