:root {
    --bg-color: #e8e6e1;
    --envelope-color: #fdfbf7;
    --envelope-shadow: rgba(0, 0, 0, 0.15);
    --text-color: #2c3e2e;
    --gold-color: #c5a059;
    --font-serif: 'Cormorant Garamond', serif;
    --font-script: 'Pinyon Script', cursive; /* Or Great Vibes */
    --font-sans: 'Montserrat', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    font-family: var(--font-serif);
    color: var(--text-color);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.scroll-container {
    height: 400vh; /* Long scroll area */
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    pointer-events: none; /* Let clicks pass through to viewport if needed, but mostly for scroll */
}

.viewport {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1500px;
    overflow: hidden;
}

.scene {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transform-style: preserve-3d;
}

.envelope-wrapper {
    position: relative;
    width: 600px; /* Horizontal width */
    height: 400px; /* Horizontal height */
    transform-style: preserve-3d;
}

.envelope {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
}

.face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden; /* Hide back when rotated */
    background-color: var(--envelope-color);
    box-shadow: 0 10px 30px var(--envelope-shadow);
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Front Face (Decoration side) */
.front {
    z-index: 2;
    transform: rotateY(0deg) translateZ(1px); /* Push forward */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #fffcf5 0%, #f7f4ec 100%);
}

.front-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 20px;
    text-align: center;
    color: var(--text-color);
}

.front-decoration {
    position: absolute;
    width: 90px;
    opacity: 1;
    mix-blend-mode: multiply; /* Blend with background */
}

.front-decoration.left {
    top: 10px;
    left: 10px;
    transform: rotate(0deg);
}

.front-decoration.right {
    bottom: 10px;
    right: 10px;
    transform: rotate(180deg);
}

.front-title {
    font-size: 12px;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 10px;
    margin-top: 20px;
}

.front-names {
    font-family: var(--font-script);
    font-size: 48px;
    margin: 10px 0;
    line-height: 1.2;
}

.front-names .amp {
    font-family: var(--font-serif);
    font-size: 24px;
    color: var(--gold-color);
}

.front-date {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 2px;
    margin-bottom: 15px;
}

.front-invite {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 5px;
}

.front-line {
    width: 150px;
    height: 1px;
    border-bottom: 1px dotted #999;
    margin-top: 10px;
}

.front-recipient {
    margin-top: 8px;
    font-family: var(--font-script);
    font-size: 24px;
    color: var(--text-color);
}


/* Back Face (Flap side) */
.back {
    transform: rotateY(180deg) translateZ(1px); /* Push forward (in its local space, so back relative to front) */
    z-index: 1;
    background-color: transparent; /* Transparent to see card sliding out */
    display: flex;
    flex-direction: column;
    justify-content: flex-end; /* Pocket at bottom */
    overflow: visible; /* Allow flap to stick out */
}

.flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50%; /* Standard Euro flap height */
    background-color: #fdfbf7;
    /* Euro style V-flap */
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    transform-origin: top;
    z-index: 10;
    transition: transform 0.5s;
    /* Visible border + subtle shadow for clear closed flap edge */
    border: 1px solid rgba(0, 0, 0, 0.25);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.pocket {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%; /* Full height to match front face */
    background-color: #fdfbf7;
    /* Straight top */
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    z-index: 5;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Align content to top */
    box-shadow: 0 -5px 15px rgba(0,0,0,0.05);
    border-top: 1px solid rgba(0,0,0,0.05);
}

.seal {
    margin-top: 180px; /* Position at flap tip (50% of 400px = 200px, minus seal radius) */
    width: 60px;
    height: 60px;
    background-color: #fdfbf7;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 25; /* Above flap (which is z-index 10) */
}

.seal-text {
    font-family: var(--font-serif);
    font-size: 28px;
    color: var(--text-color);
    letter-spacing: 2px;
}

/* Remove old pocket content styles */
.pocket-content, .pocket-decoration, .pocket-title, .pocket-names, .pocket-date, .pocket-invite, .pocket-line {
    display: none;
}

/* Invitation Card */
.card-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: translateZ(0px); /* No rotation needed, already in back face */
    z-index: 4; /* Above pocket */
    pointer-events: none;
    transform-style: preserve-3d;
    display: flex;
    justify-content: center;
    align-items: center;
}

.invitation-card {
    width: 440px; /* Portrait width - larger for more breathing room */
    height: 580px; /* Taller container so text không bị chật */
    background-color: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 15px;
    text-align: center;
    position: relative;
    overflow: hidden;
    /* Initial state: Rotated 90deg to fit in horizontal envelope */
    transform: rotate(-90deg);
    backface-visibility: hidden;
    transform-style: flat;
}


.corner-decoration {
    position: absolute;
    width: 70px;
    opacity: 1;
    mix-blend-mode: multiply; /* Blend with background */
}

.top-left {
    top: 5px;
    left: 5px;
    transform: rotate(0deg);
}

.bottom-right {
    bottom: 5px;
    right: 5px;
    transform: rotate(180deg);
}

.card-content {
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Let content sit naturally */
    align-items: center;
    gap: 6px; /* Tighter spacing giữa các block trên desktop */
}

.recipient-card {
    font-family: var(--font-script);
    font-size: 24px;
    margin-top: 4px;
    margin-bottom: 4px;
    color: var(--text-color);
}

.sub-title {
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 5px;
    color: var(--text-color);
    font-weight: 600;
    margin-top: 10px;
}

.divider-line {
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 0;
}

.divider-line img {
    width: 100px;
    opacity: 1;
    mix-blend-mode: multiply;
}

.invite-text {
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 10px;
    color: var(--text-color);
    font-weight: 600;
}

.names {
    font-family: var(--font-script);
    font-size: 48px; /* Slightly smaller to fit */
    color: var(--text-color);
    line-height: 1.1;
    margin: 4px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.names .amp {
    font-size: 24px;
    font-family: var(--font-serif);
    margin: 0;
    color: var(--gold-color);
}

.date-section {
    margin: 6px 0;
}

.time {
    font-size: 11px;
    letter-spacing: 1.5px;
    margin-bottom: 2px;
}

.main-date {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    margin: 2px 0;
}

.separator {
    color: var(--gold-color);
    font-weight: 300;
}

.lunar-date {
    font-size: 12px;
    font-style: italic;
    color: #444;
    font-weight: 500;
    margin-top: 2px;
}

.location-section {
    margin: 6px 0;
}

.at {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 2px;
}

.venue {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 2px;
    color: var(--text-color);
    padding: 0 20px;
}

.address {
    font-size: 12px;
    color: var(--text-color);
    font-weight: 500;
    padding: 0 20px;
}

.footer-msg {
    font-family: var(--font-script);
    font-size: 18px;
    margin: 8px 0;
    color: var(--text-color);
}

.parents {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 10px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
}

.family {
    text-align: center;
    flex: 1;
}

.role {
    font-weight: 600;
    margin-bottom: 2px;
    text-transform: uppercase;
}

.parent-name {
    line-height: 1.3;
    text-transform: uppercase;
    font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
    .envelope-wrapper {
        width: 92vw;
        height: 62vw; /* 1.5:1 aspect ratio gần đúng */
        max-width: 600px;
    }
    
    .invitation-card {
        /* Nằm gọn trong envelope khi còn xoay ngang */
        transform: rotate(-90deg) scale(0.6);
    }
    
    /* Card content: mobile/tablet nhỏ – chữ rất to, ưu tiên đọc dễ */
    .sub-title {
        font-size: 17px;
    }

    .invite-text {
        font-size: 15px;
    }

    .names {
        font-size: 56px;
    }

    .names .amp {
        font-size: 30px;
    }

    /* Giảm cỡ chữ mặt trước trên mobile/tablet nhỏ */
    .front-title {
        font-size: 10px;
    }

    .front-names {
        font-size: 40px;
    }

    .front-names .amp {
        font-size: 20px;
    }

    .front-date {
        font-size: 14px;
    }

    .front-invite {
        font-size: 9px;
    }

    .front-recipient,
    .recipient-card {
        font-size: 22px;
    }
    
    .time {
        font-size: 16px;
    }

    .main-date {
        font-size: 22px;
    }
    
    .venue {
        font-size: 18px;
    }

    .address,
    .lunar-date {
        font-size: 16px;
    }

    .footer-msg {
        font-size: 24px;
    }

    .parents {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .envelope-wrapper {
        width: 100vw;
        height: 70vw;
    }

    .invitation-card {
        /* Màn rất nhỏ: card ngang không tràn wrapper */
        transform: rotate(-90deg) scale(0.48);
    }

    /* Card content: mobile rất nhỏ – vẫn to, không phải nheo mắt */
    .sub-title {
        font-size: 13px;
    }

    .invite-text {
        font-size: 12px;
    }

    .names {
        font-size: 44px;
    }

    .names .amp {
        font-size: 24px;
    }

    /* Màn rất nhỏ: mặt trước nhỏ gọn hơn nữa */
    .front-title {
        font-size: 9px;
    }

    .front-names {
        font-size: 34px;
    }

    .front-names .amp {
        font-size: 18px;
    }

    .front-date {
        font-size: 13px;
    }

    .front-invite {
        font-size: 8px;
    }

    .front-recipient,
    .recipient-card {
        font-size: 20px;
    }

    .time {
        font-size: 13px;
    }

    .main-date {
        font-size: 18px;
    }

    .venue {
        font-size: 15px;
    }

    .address,
    .lunar-date {
        font-size: 13px;
    }

    .footer-msg {
        font-size: 20px;
    }

    .parents {
        font-size: 10px;
    }
}

@media (min-width: 1024px) {
    .envelope-wrapper {
        width: 840px;
        height: 560px;
    }

    .front-decoration {
        width: 110px;
    }

    .corner-decoration {
        width: 80px;
    }

    .front-title {
        font-size: 16px;
    }

    .front-names {
        font-size: 64px;
    }

    .front-names .amp {
        font-size: 30px;
    }

    .front-date {
        font-size: 20px;
    }

    .front-invite {
        font-size: 12px;
    }

    .front-recipient,
    .recipient-card {
        font-size: 26px;
    }

    .names {
        font-size: 52px;
    }

    .main-date {
        font-size: 22px;
    }

    .venue {
        font-size: 16px;
    }

    .address,
    .lunar-date {
        font-size: 13px;
    }

    .footer-msg {
        font-size: 22px;
    }

    .parents {
        font-size: 11px;
    }
}
