:root {
    --bg-color: #fcf4f4;
    --paper-color: #fffdf5;
    --cover-color: #8B0000;
    --text-color: #3e2723;
    --gold: #d4af37;
    --heart-color: #ff4d4d;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at 50% 50%, #fff, #fdece8);
    font-family: 'Playfair Display', serif;
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
}

h1,
h2,
h3,
.love-text,
.cover-decoration,
.subtitle,
.magic-btn {
    font-family: 'Dancing Script', cursive;
}

/* --- Container Carte --- */
.main-container {
    perspective: 1500px;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 80vh;
    width: 100vw;
}

.book-container {
    position: relative;
    width: 800px;
    height: 500px;
    transition: transform 0.5s ease;
    transform: translateX(-25%);
    /* Centreaza cartea inchisa */
}

@media (max-width: 900px) {
    .main-container {
        height: auto;
        min-height: 100vh;
        padding: 80px 0 40px 0;
        display: block;
    }

    .book-container {
        width: 90vw !important;
        max-width: 500px !important;
        height: auto !important;
        transform: none !important;
        margin: 0 auto !important;
        position: relative !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .book {
        width: 100% !important;
        height: auto !important;
        transform: none !important;
        float: none !important;
        position: relative !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .page {
        position: static !important;
        display: block !important;
        transform: none !important;
        transition: none !important;
        height: auto !important;
        width: 100% !important;
        z-index: auto !important;
    }

    .front,
    .back {
        position: relative !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        transform: none !important;
        width: 100% !important;
        height: auto !important;
        min-height: 50vh !important;
        backface-visibility: visible !important;
        border-radius: 15px !important;
        margin-bottom: 30px !important;
        background-image: none !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
        padding: 40px 20px !important;
    }

    .cover-front,
    .cover-back {
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3) !important;
    }

    /* Ascunde butoanele de navigare (utilizatorul va da scroll) */
    .page-controls,
    .next-btn,
    .prev-btn {
        display: none !important;
    }

    /* Ajustari pentru poze suprapuse pe mobile */
    .double-polaroid-container {
        height: auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    .small-polaroid {
        position: relative;
        top: auto;
        left: auto;
        right: auto;
        bottom: auto;
        transform: none !important;
    }

    .polaroid-tilt-left,
    .polaroid-tilt-right {
        transform: rotate(0) !important;
    }

    .polaroid-tilt-left:hover,
    .polaroid-tilt-right:hover {
        transform: scale(1.05) !important;
    }

    /* Plaseaza plicul de surpriza fixeaza pentru a fi mereu vizibil */
    .magic-btn {
        position: fixed;
        top: 20px;
        right: 20px;
        background-color: rgba(255, 255, 255, 0.85);
        border-radius: 50%;
        width: 60px;
        height: 60px;
        display: flex;
        justify-content: center;
        align-items: center;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    }

    .invitation-card {
        padding: 30px 20px;
        width: 90vw;
    }

    .love-text {
        font-size: 2.5rem;
    }

    .photo-instructions {
        position: relative !important;
        bottom: auto !important;
        margin-top: 20px !important;
        padding-bottom: 20px !important;
    }
}

.book {
    position: relative;
    width: 50%;
    height: 100%;
    float: right;
    transform-style: preserve-3d;
}

/* --- Pagini --- */
.page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: left center;
    transition: transform 1.5s cubic-bezier(0.645, 0.045, 0.355, 1);
    transform-style: preserve-3d;
}

.front,
.back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    padding: 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background-color: var(--paper-color);
    border: 1px solid #f0e6d2;
}

.front {
    z-index: 2;
    transform: rotateY(0deg);
    border-radius: 2px 10px 10px 2px;
    background-image: linear-gradient(to right, rgba(0, 0, 0, 0.05) 0%, rgba(0, 0, 0, 0) 5%);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.05), -2px 0 5px rgba(0, 0, 0, 0.1);
}

.back {
    z-index: 1;
    transform: rotateY(180deg);
    border-radius: 10px 2px 2px 10px;
    background-image: linear-gradient(to left, rgba(0, 0, 0, 0.05) 0%, rgba(0, 0, 0, 0) 5%);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.05), 2px 0 5px rgba(0, 0, 0, 0.1);
}

/* Coperte */
.cover-front,
.cover-back {
    background-color: var(--cover-color) !important;
    color: var(--gold);
    border: 2px solid var(--gold) !important;
    background-image: none !important;
    box-shadow: inset 4px 0 10px rgba(0, 0, 0, 0.2), 5px 5px 15px rgba(0, 0, 0, 0.3) !important;
}

.cover-front::after {
    content: '';
    position: absolute;
    top: 5%;
    left: 5%;
    right: 5%;
    bottom: 5%;
    border: 2px solid var(--gold);
    border-radius: 5px;
    pointer-events: none;
}

.cover-front h1 {
    font-size: 3rem;
    margin-bottom: 20px;
    line-height: 1.2;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.cover-decoration {
    font-size: 4rem;
    margin: 20px 0;
}

.subtitle {
    font-size: 1.5rem;
    color: #ffd700;
}

/* --- Elemente de design interior --- */
.page h2 {
    font-size: 2rem;
    color: var(--cover-color);
    margin-bottom: 20px;
}

p {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 15px;
}

.decorative-line {
    width: 50%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    margin: 20px auto;
}

.date {
    font-size: 0.9rem;
    font-style: italic;
    color: #777;
}

/* Cadre Poze tip Polaroid */
.polaroid {
    background: white;
    padding: 10px 10px 25px 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transform: rotate(-2deg);
    transition: transform 0.3s;
    margin: 10px auto;
    max-width: 80%;
}

.polaroid:nth-child(even) {
    transform: rotate(3deg);
}

.polaroid:hover {
    transform: scale(1.05) rotate(0deg);
    z-index: 10;
}

.memory-img {
    width: 100%;
    height: 200px;
    object-fit: contain;
    background-color: #eee;
    /* Placeholder bg */
}

.polaroid.small .memory-img {
    height: 120px;
}

.double-polaroid-container {
    position: relative;
    width: 100%;
    height: 380px;
    /* Spatiu pentru pozele asezate pe diagonala */
    margin-top: 10px;
}

.small-polaroid {
    position: absolute;
    /* Pentru a le plasa unde vrem noi in container */
    padding: 8px 8px 15px 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.polaroid-tilt-left {
    top: 0;
    left: 10%;
    transform: rotate(-10deg) scale(0.95);
    z-index: 1;
    transition: transform 0.3s, z-index 0s;
}

.polaroid-tilt-right {
    bottom: 30px;
    right: 10%;
    transform: rotate(10deg) scale(1.05);
    z-index: 2;
    transition: transform 0.3s, z-index 0s;
}

.polaroid-tilt-left:hover,
.polaroid-tilt-right:hover {
    z-index: 10;
    transform: scale(1.2) rotate(0deg);
}

.small-img {
    height: 190px;
    width: auto;
    object-fit: cover;
    margin-bottom: 5px;
}

.caption {
    font-family: 'Dancing Script', cursive;
    font-size: 1.3rem;
    margin-top: 10px;
    color: #555;
}

.text-page {
    justify-content: center;
    padding: 40px;
}

.text-page p {
    font-size: 1.2rem;
    font-style: italic;
}

.hearts-illustration {
    font-size: 3rem;
    margin-top: 30px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

/* --- Butoane --- */
button {
    background-color: var(--cover-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-family: 'Playfair Display', serif;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
    margin-top: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

button:hover {
    background-color: #600000;
    transform: translateY(-2px);
}

.page-controls {
    display: flex;
    justify-content: space-between;
    width: 100%;
    position: absolute;
    bottom: 20px;
    padding: 0 30px;
    left: 0;
}

formidable-btn {
    pointer-events: auto;
}

/* --- Surpriza Interactiva / Scrisoarea --- */
.magic-btn {
    position: absolute;
    top: 20px;
    right: 30px;
    /* Mutat in dreapta */
    left: auto;
    background: transparent;
    border: none;
    font-size: 3rem;
    cursor: pointer;
    z-index: 100;
    box-shadow: none;
    transition: transform 0.3s;
    animation: bounce 2s infinite;
}

.magic-btn:hover {
    transform: scale(1.2) rotate(15deg);
    background: transparent;
}

.surprise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
    opacity: 1;
    transition: opacity 0.5s ease;
}

.surprise-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    z-index: -1;
}

.surprise-content {
    text-align: center;
    background: linear-gradient(135deg, var(--paper-color), #ffe6e6);
    padding: 50px;
    border-radius: 20px;
    box-shadow: 0 0 50px rgba(255, 77, 77, 0.4);
    z-index: 1001;
    transform: scale(0.8);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid var(--heart-color);
}

.invitation-card {
    background: #fff9f0;
    /* Culoare de hartie veche/invitatie */
    border: 3px double #d4af37;
    padding: 60px 40px;
    max-width: 600px;
}

.invitation-details {
    padding: 20px 0;
    border-top: 1px dashed #d4af37;
    border-bottom: 1px dashed #d4af37;
    margin-bottom: 30px;
}

.surprise-overlay:not(.hidden) .surprise-content {
    transform: scale(1);
}

.love-text {
    font-size: 3.5rem;
    color: var(--cover-color);
    margin-bottom: 20px;
    text-shadow: 1px 1px 5px rgba(0, 0, 0, 0.1);
    font-weight: normal;
}

.love-subtext {
    font-size: 1.6rem;
    color: #333;
    margin-bottom: 20px;
    font-family: 'Dancing Script', cursive;
}

.date-highlight {
    font-size: 1.3rem;
    color: var(--cover-color);
    font-weight: bold;
    margin-bottom: 10px;
    font-family: 'Playfair Display', serif;
}

.plan-text {
    font-size: 1.2rem;
    color: #444;
    line-height: 1.6;
    margin-top: 20px;
    font-style: italic;
}

.small-subtext {
    font-size: 1.2rem;
    color: #666;
    font-style: italic;
    margin-bottom: 30px;
}

.btn {
    font-size: 1.2rem;
    padding: 12px 30px;
    background: var(--heart-color);
}

.btn:hover {
    background: #cc0000;
}

@keyframes heartbeat {
    0% {
        transform: scale(1);
    }

    15% {
        transform: scale(1.1);
    }

    30% {
        transform: scale(1);
    }

    45% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

/* Inimioare cazatoare */
.falling-heart {
    position: absolute;
    color: var(--heart-color);
    font-size: 1.5rem;
    top: -50px;
    z-index: 1000;
    user-select: none;
    pointer-events: none;
    animation: fall linear forwards;
}

@keyframes fall {
    to {
        transform: translateY(110vh) rotate(360deg);
    }
}

.photo-instructions {
    position: fixed;
    bottom: 10px;
    text-align: center;
    color: #666;
    font-size: 0.9rem;
    font-style: italic;
}

/* Z-index logic for pages */
#leaf1 {
    z-index: 7;
}

#leaf2 {
    z-index: 6;
}

#leaf3 {
    z-index: 5;
}

#leaf4 {
    z-index: 4;
}

#leaf5 {
    z-index: 3;
}

#leaf6 {
    z-index: 2;
}

#leaf7 {
    z-index: 1;
}

.flipped {
    transform: rotateY(-180deg) !important;
}
