@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400..900&family=Cormorant:ital,wght@0,300..700;1,300..700&family=Great+Vibes&display=swap');

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

:root {
    --bg-color: #dceeff;
    --card-bg: #f8fbff;
    --text-color: #0b2856;
    --accent-blue: #4f7eb8;
    --dark-blue: #00335a;
    --soft-blue: #dbeaff;

    --blue-gray: rgba(164, 178, 191, 1);
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    background:
        radial-gradient(circle at top left, rgba(255,255,255,0.8), transparent 40%),
        radial-gradient(circle at bottom right, rgba(183, 220, 255, 0.8), transparent 40%),
        linear-gradient(135deg, #ecf6ff, #d4ecff);
}

h1 {
    font-family: "Great Vibes", cursive;
    color: white;
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 400;
}

.postcard-face {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 1rem;
}

.postcard-face svg {
    width: 150px;
    height: 150px;
}

/* =========================
POSTCARD
========================= */

.scene {
    width: min(450px, 90vw);
    aspect-ratio: 2 / 3;
    perspective: 1400px;
    cursor: pointer;
    user-select: none;
    margin: auto;
}

.postcard {
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1.1s cubic-bezier(0.645, 0.045, 0.355, 1);
    box-shadow:
        0 30px 80px rgba(0, 0, 0, 0.122),
        0 8px 24px rgba(0,0,0,0.15);
    width: 100%;
    height: 100%;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    background: rgb(180, 201, 220);
}

.postcard.flipped {
    transform: rotateY(-180deg);
}

.postcard-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    overflow: hidden;
}

/* =========================
FRONT
========================= */

.postcard-front {
    background-color: rgb(180, 201, 220);
    color: #fff;
}

.flip-hint {
    font-size: .7rem;
    letter-spacing: .25em;
    text-transform: uppercase;
    color: rgba(255,255,255,.8);
}

/* =========================
BACK
========================= */

.postcard-back {
    transform: rotateY(180deg);
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 2rem;
}

.postcard-back .bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 1;
}

.postcard-message {
    display: flex;
    flex-direction: column;
    width: 100%;
    align-items: flex-end;
    text-align: right;
    color: #fff;

    height: 100%;
    justify-content: center;
    gap: 0.875rem;
}

.postcard-message h2 {
    font-family: "Cinzel", serif;
    font-size: clamp(3rem, 6vw, 4.5rem);
    font-weight: 400;
    display: block;
    line-height: 1;
}

.postcard-message h2 span {
    font-family: "Great Vibes", cursive;
    margin-right: 0.5rem;
    font-size: clamp(3rem, 6vw, 4.5rem);
    font-weight: 400;
}

.postcard-message .eyebrow {
    font-family: "Cormorant", serif;
    display: block;
    font-size: clamp(1.2rem, 3vw, 1.8rem);
}

.postcard-message time {
    font-size: clamp(1rem, 2.5vw, 1.5rem);
}

.postcard-message span {
    display: block;
}

.overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.overlay img {
    position: absolute;
    width: clamp(250px, 40vw, 400px);
    height: clamp(250px, 40vw, 400px);
}

.overlay img.top {
    top: -60px;
    left: -60px;
    transform: rotate(180deg);
}

.overlay img.bottom {
    bottom: -60px;
    right: -60px;
}

time,
.year,
p.location {
    display: block;
    font-family: "Cinzel", serif;
}

small {
    align-self: flex-end;
    font-family: "Cormorant", serif;
    font-size: 1rem;
}

/* =========================
ADD TO CALENDAR
========================= */

.calendar {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;

    /* Hidden until the postcard is flipped to the date side. */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    /* No delay when hiding — vanishes as soon as you flip back. */
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

/* Reveal only after the flip finishes (flip runs 1.1s). */
#scene:has(.postcard.flipped) ~ .calendar {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.5s ease 1.15s, visibility 0.5s ease 1.15s;
}

.calendar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.6rem 1.4rem;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 999px;
    background: rgba(180, 201, 220, 0.85);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    color: #fff;
    font-family: "Cinzel", serif;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow:
        0 12px 30px rgba(0, 51, 90, 0.18),
        0 4px 12px rgba(0, 0, 0, 0.12);
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.calendar-toggle:hover {
    transform: translateY(-2px);
    background: rgba(0, 51, 90, 0.9);
    box-shadow:
        0 16px 36px rgba(0, 51, 90, 0.25),
        0 6px 14px rgba(0, 0, 0, 0.15);
}

.calendar-icon {
    flex-shrink: 0;
}

.calendar-menu {
    display: flex;
    flex-direction: column;
    min-width: 200px;
    padding: 0.4rem;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 16px;
    background: rgba(248, 251, 255, 0.92);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow:
        0 18px 40px rgba(0, 51, 90, 0.2),
        0 6px 16px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
}

.calendar.open .calendar-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.calendar.open .calendar-toggle {
    background: rgba(0, 51, 90, 0.9);
}

.calendar-option {
    padding: 0.65rem 0.9rem;
    border-radius: 10px;
    font-family: "Cormorant", serif;
    font-size: 1.1rem;
    color: var(--dark-blue);
    text-decoration: none;
    text-align: center;
    transition: background 0.2s ease, color 0.2s ease;
}

.calendar-option:hover {
    background: var(--soft-blue);
    color: var(--text-color);
}