:root {
    --page-bg: #f4e8d1;
    --text-color: #2c1a0e;
    --accent-color: #8b0000; /* Dark magical red */
    --hover-color: #5c0000;
}

body {
    background: #0d1117;
    margin: 0;
    font-family: 'Crimson Text', serif;
    color: var(--text-color);
    background-image: url('img/cover.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}

.overlay {
    background: rgba(0, 0, 0, 0.85); /* Sötétítő réteg */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

#hud {
    width: 100%;
    max-width: 1000px;
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    font-family: 'MedievalSharp', cursive;
    color: #e5d8b8;
    text-shadow: 1px 1px 3px black;
    font-size: 1.2rem;
}

.voice-btn {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(139, 69, 19, 0.5);
    color: #e5d8b8;
    cursor: pointer;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s ease;
}

.voice-btn:hover {
    background: rgba(139, 69, 19, 0.5);
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(139, 69, 19, 0.8);
}

.back-link {
    color: #e5d8b8;
    text-decoration: none;
    transition: color 0.3s;
}

.back-link:hover {
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

.book-wrapper {
    perspective: 1500px;
    width: 100%;
    max-width: 1000px;
}

.book {
    display: flex;
    flex-direction: row;
    background: var(--page-bg);
    border-radius: 5px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8), inset 0 0 50px rgba(139, 69, 19, 0.2);
    position: relative;
    transform-style: preserve-3d;
    transition: opacity 0.6s ease;
    height: 700px; /* A könyv minden lapon pontosan ekkora marad, sosincs méretváltozás */
}

.page {
    flex: 1;
    padding: 40px;
    box-sizing: border-box;
    position: relative;
}

.left-page {
    border-right: 1px solid rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.center-fold {
    flex: 0 0 40px;
    background: linear-gradient(to right, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.3) 50%, rgba(0,0,0,0.0) 100%);
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    transform: translateX(-50%);
    pointer-events: none;
}

.right-page {
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Ha a tartalom hosszabb, mint a 700px, görgethető legyen pici csuszáddal */
}

#story-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    border: 3px solid #5a3d2b;
    filter: sepia(0.2) contrast(1.1);
    transition: filter 0.3s;
}

.story-title {
    font-family: 'MedievalSharp', cursive;
    color: var(--accent-color);
    font-size: 2.2rem;
    margin-top: 0;
    border-bottom: 2px solid rgba(139, 69, 19, 0.3);
    padding-bottom: 10px;
    line-height: 1.1;
}

.story-text {
    font-size: 1.25rem;
    line-height: 1.35; /* Kisebb sorköz az egybefüggő szövegeknél */
    margin-bottom: 30px;
    white-space: pre-wrap;
    flex-grow: 1;
}

.story-text p {
    margin-top: 0;
    margin-bottom: 15px; /* Kisebb bekezdések közötti távolság */
}

.choices-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: auto;
}

.choice-btn {
    background: transparent;
    border: 2px solid rgba(139, 69, 19, 0.5);
    color: var(--text-color);
    font-family: 'Crimson Text', serif;
    font-size: 1.1rem;
    padding: 12px 20px;
    cursor: pointer;
    text-align: left;
    transition: all 0.3s ease;
    border-radius: 3px;
    position: relative;
    overflow: hidden;
}

.choice-btn:hover {
    background: rgba(139, 69, 19, 0.1);
    border-color: var(--accent-color);
    transform: translateX(5px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.choice-btn::before {
    content: "❯";
    color: var(--accent-color);
    position: absolute;
    left: 10px;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    transform: translateX(-10px);
}

.choice-btn:hover::before {
    opacity: 1;
    transform: translateX(0);
}

.choice-btn:hover {
    padding-left: 30px;
}

/* Reszponzivitás mobilon */
@media (max-width: 768px) {
    .book {
        flex-direction: column;
    }
    .left-page {
        border-right: none;
        border-bottom: 1px solid rgba(0,0,0,0.1);
        padding: 5px;
    }
    .center-fold {
        display: none;
    }
    .page {
        padding: 20px;
    }
    #story-image {
        max-height: 30vh;
    }
    .story-title {
        font-size: 1.8rem;
    }
    .story-text {
        font-size: 1.1rem;
    }
}

.danger-text {
    color: var(--accent-color);
    font-weight: bold;
    font-style: italic;
    font-size: 1.3rem;
    margin-top: 20px;
}

/* 3D Flip Animáció a könyvhöz */
.flip-page {
    position: absolute;
    right: 0;
    top: 0;
    width: 50%; /* Csak a jobb oldalról indul */
    height: 100%;
    transform-origin: left center; /* A gerinc mentén fordul (bal szél) */
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.645, 0.045, 0.355, 1);
    pointer-events: none;
    z-index: 10;
    display: none;
}

.flip-page.animating {
    display: block;
    transform: rotateY(-180deg);
}

.flip-page-front,
.flip-page-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background: var(--page-bg);
    box-sizing: border-box;
    overflow: hidden;
}

.flip-page-front {
    transform: rotateY(0deg);
    border-radius: 0 5px 5px 0;
    padding: 40px;
    box-shadow: inset 10px 0 20px rgba(0,0,0,0.1);
}

.flip-page-back {
    transform: rotateY(180deg);
    border-radius: 5px 0 0 5px;
    box-shadow: inset -10px 0 20px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.flip-page-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    border: 3px solid #5a3d2b;
}

/* Mobilos 3D flip elrejtése (lehetetlen lenne jól megcsinálni függőlegesen) */
@media (max-width: 768px) {
    .flip-page {
        display: none !important;
    }
}

/* Kárra rázkódás */
.shake {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}
