/* --- Reset i Ogólne --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    height: 100vh;
    overflow: hidden;
    background-color: #121212;
    font-family: 'Lora', serif;
}

/* --- Stół i Scena 3D --- */
.table-surface {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background:
            radial-gradient(circle at center, rgba(255,255,255,0.1) 0%, rgba(0,0,0,0.5) 100%),
            linear-gradient(to bottom, #4a3121, #2c1b12);
    perspective: 1600px;
    overflow: hidden;
}

.scene {
    position: relative;
    width: 320px;
    height: 480px;
    /* Domyślna pozycja */
    transform: rotateX(20deg) translateY(-20px) translateX(0);
    transform-style: preserve-3d;
    /* Dodana tranzycja dla transform (przesuwanie) */
    transition: width 0.3s, height 0.3s, transform 1.2s cubic-bezier(0.645, 0.045, 0.355, 1);
}

/* KLASA PRZESUWAJĄCA KSIĄŻKĘ W PRAWO PO OTWARCIU */
.scene.is-open {
    transform: rotateX(20deg) translateY(-20px) translateX(50%);
}

/* --- Książka --- */
.book {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    box-shadow: 0 20px 30px rgba(0,0,0,0.5);
    border-radius: 5px;
}

/* --- Strony (Wspólne style) --- */
.page {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    transform-origin: left center;
    transform-style: preserve-3d;
    transition: transform 1.2s cubic-bezier(0.645, 0.045, 0.355, 1), box-shadow 0.5s;
    cursor: pointer;
    border-radius: 3px 8px 8px 3px;
    background-color: #e8dcc5;
}

.front, .back {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 25px;
    text-align: center;
    backface-visibility: hidden;
    border: 1px solid rgba(0,0,0,0.1);
    overflow: hidden;
}

.back {
    transform: rotateY(180deg);
    background-image: linear-gradient(to right, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0) 20%);
}

.paper-texture {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    opacity: 0.05;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    pointer-events: none;
}

/* --- Stylizacja Okładek (Czerwone) --- */
.cover-front .front, .back-cover-fixed {
    background-color: #800000;
    color: #d4af37;
    border: 3px solid #d4af37;
}

.back-cover-fixed {
    z-index: 0;
    box-shadow: none;
}

/* --- Widoczność tekstu na okładce --- */
.cover-front .front p {
    color: #ffd700;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.cover-front .front .cover-subtitle {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: #ffd700 !important;
}

.cover-front .front .hint {
    color: #d4af37;
    opacity: 0.8;
    font-weight: normal;
}

/* --- Typografia i Elementy --- */
h1, h2, h3, .handwritten, .important-date, .highlight {
    font-family: 'Dancing Script', cursive;
    font-weight: 700;
}

h1 { font-size: 2.8rem; margin-bottom: 15px; line-height: 1.1; }
h2 { font-size: 1.8rem; margin-bottom: 15px; color: #4a3121; }
h3 { font-size: 1.4rem; margin-bottom: 10px; color: #4a3121; }
p { font-size: 0.95rem; line-height: 1.5; margin-bottom: 12px; color: #333; }
.hint { font-size: 0.8rem; opacity: 0.7; margin-top: 30px; }
.ornament { font-size: 2rem; margin: 20px 0; }
.handwritten { font-size: 1.4rem; color: #800000; transform: rotate(-2deg); }
.intro-quote { margin-bottom: 20px; }
.small-text { font-size: 0.85rem; opacity: 0.8; }
.separator { margin: 15px 0; color: #4a3121; opacity: 0.5; }

/* Ikony */
.icon-dark { color: #4a3121; margin-right: 8px; }
.icon-red { color: #800000; margin-right: 8px; }
.insta-icon { color: #C13584; margin-right: 8px; }

/* Statyczny całus */
.static-kiss {
    margin-right: 8px;
    font-size: 1.2em;
    vertical-align: middle;
}

/* Animacja Instagram */
.insta-notification-container {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    width: 100%;
}

.insta-notification {
    background: white;
    border-radius: 12px;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    max-width: 90%;
    opacity: 0;
    transform: scale(0.8);
}

.bounce-in {
    animation: bounceIn 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
    animation-delay: 0.5s;
}

@keyframes bounceIn {
    0% { opacity: 0; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1); }
}

.notif-icon { font-size: 24px; margin-right: 12px; color: #C13584; }
.notif-text { text-align: left; font-size: 0.85rem; color: #262626; }

/* Dymki */
.message-bubble {
    background-color: #fff;
    border-radius: 15px;
    padding: 10px 15px;
    margin: 8px 0;
    position: relative;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    font-style: italic;
    font-size: 0.9rem;
    max-width: 90%;
}

.from-her {
    background-color: #f0f0f0;
    border-bottom-left-radius: 2px;
    align-self: flex-start;
    text-align: left;
    border: 1px solid #e0e0e0;
}

/* Inne */
.important-date {
    font-size: 1.8rem;
    color: #800000;
    margin: 15px 0;
    border-bottom: 2px solid #800000;
    display: inline-block;
}

.big-moment {
    border: 3px dotted #d4af37;
    padding: 20px;
    border-radius: 10px;
}

.highlight {
    font-size: 1.4rem;
    color: #800000;
    margin-top: 15px;
    text-shadow: none;
}

/* Zdjęcia (Generalne) */
img {
    max-width: 100%;
    height: auto;
    border: 3px solid #fff;
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
    transform: rotate(-1deg);
    margin: 10px 0;
}

/* --- Kolaze (2 zdjęcia) --- */
.photo-collage { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.photo-collage img { max-width: 46%; height: auto; object-fit: cover; }
.photo-collage img:first-child { transform: rotate(-3deg); }
.photo-collage img:last-child { transform: rotate(3deg); }

/* --- Pojedyncze zdjęcie (specjalne) --- */
.single-photo {
    transform: rotate(2deg) !important;
    max-height: 160px;
    object-fit: cover;
}

.nice-photos-page .front { justify-content: flex-start; padding-top: 40px; }


/* --- Logika Przewracania --- */
.flipped {
    transform: rotateY(-180deg);
    box-shadow: 5px 0 15px rgba(0,0,0,0.1);
}

/* --- Z-INDEX DLA 7 STRON --- */
.page[data-page="1"] { z-index: 12; }
.page[data-page="2"] { z-index: 11; }
.page[data-page="3"] { z-index: 10; }
.page[data-page="4"] { z-index: 9; }
.page[data-page="5"] { z-index: 8; }
.page[data-page="6"] { z-index: 7; }
.page[data-page="7"] { z-index: 6; }


/* --- Numeracja Stron --- */
.page-number {
    position: absolute;
    bottom: 15px;
    font-family: 'Lora', serif;
    font-size: 0.9rem;
    color: #8b0000;
    opacity: 0.6;
    font-weight: bold;
}

.front .page-number { right: 20px; }
.back .page-number { left: 20px; }
.cover-front .front .page-number, .cover-back .back .page-number { display: none; }


/* ========================================= */
/* RESPONSYWNOŚĆ (TELEFONY/TABLETY)        */
/* ========================================= */

/* 1. TABLETY (i mniejsze laptopy) */
@media (max-width: 1024px) {
    .scene {
        width: 220px;
        height: 380px;
    }

    h1 { font-size: 2rem; margin-bottom: 10px; }
    h2 { font-size: 1.4rem; margin-bottom: 8px; }
    h3 { font-size: 1.1rem; }
    p { font-size: 0.8rem; line-height: 1.4; }

    .front, .back { padding: 15px; }

    .single-photo { max-height: 120px; }

    .insta-notification { padding: 8px; }
    .notif-text { font-size: 0.75rem; }
}

/* 2. TELEFONY (iPhone, Android) */
@media (max-width: 600px) {
    .scene {
        width: 155px; /* Po otwarciu = 310px. Wejdzie na ekran 360px+ */
        height: 260px;
    }

    h1 { font-size: 1.5rem; margin-bottom: 5px; line-height: 1.1; }
    h2 { font-size: 1rem; margin-bottom: 5px; }
    h3 { font-size: 0.9rem; margin-bottom: 5px; }
    p { font-size: 0.6rem; line-height: 1.3; margin-bottom: 5px; }

    .front, .back { padding: 8px; }

    .ornament { font-size: 1rem; margin: 5px 0; }
    .cover-front .front .cover-subtitle { font-size: 0.7rem; margin-bottom: 4px; }
    .handwritten { font-size: 0.9rem; }
    .highlight { font-size: 1rem; margin-top: 10px; }
    .important-date { font-size: 1.1rem; margin: 8px 0; }

    .photo-collage { gap: 4px; margin-top: 5px; }
    .single-photo { max-height: 80px; }

    .insta-notification { padding: 5px 6px; border-radius: 8px; margin-top: 10px; }
    .notif-icon { font-size: 14px; margin-right: 5px; }
    .notif-text { font-size: 0.55rem; line-height: 1.2; }

    .message-bubble { padding: 6px 8px; font-size: 0.65rem; border-radius: 8px; }

    .page-number { bottom: 5px; font-size: 0.6rem; }
    .front .page-number { right: 8px; }
    .back .page-number { left: 8px; }
}

/* 3. BARDZO WĄSKIE TELEFONY */
@media (max-width: 350px) {
    .scene {
        width: 140px;
        height: 240px;
    }
    h1 { font-size: 1.3rem; }
}