/* ===== CSS Variables ===== */
:root {
    --primary-color: #d4af37;
    --primary-light: #f0e6c8;
    --primary-dark: #b8960c;
    --primary-glow: rgba(212, 175, 55, 0.4);
    --secondary-color: #1a1a2e;
    --accent-rose: #e8b4b8;
    --accent-sage: #b8c9b8;
    --text-dark: #1a1a1a;
    --text-light: #6b7280;
    --text-muted: #9ca3af;
    --bg-cream: #fdfbf7;
    --bg-ivory: #fffef9;
    --bg-dark: #0f0f1a;
    --bg-card: rgba(255, 255, 255, 0.95);
    --gradient-gold: linear-gradient(135deg, #d4af37 0%, #f4e4a6 25%, #d4af37 50%, #b8960c 100%);
    --gradient-gold-soft: linear-gradient(135deg, #d4af37 0%, #e8c547 100%);
    --gradient-dark: linear-gradient(180deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%);
    --gradient-radial: radial-gradient(ellipse at center, rgba(212, 175, 55, 0.15) 0%, transparent 70%);
    --shadow-soft: 0 4px 30px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 10px 40px rgba(0, 0, 0, 0.12);
    --shadow-gold: 0 8px 32px rgba(212, 175, 55, 0.25);
    --shadow-glow: 0 0 60px rgba(212, 175, 55, 0.3);
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.5);
    --font-display: 'Great Vibes', cursive;
    --font-heading: 'Cormorant Garamond', serif;
    --font-elegant: 'Cinzel', serif;
    --font-body: 'Montserrat', sans-serif;
    --transition-smooth: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-cream);
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--text-dark);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 24px;
}

.hidden {
    display: none !important;
}

/* ===== FORM SECTION ===== */
.form-section {
    min-height: 100vh;
    padding: 60px 20px;
    background: var(--gradient-dark);
    position: relative;
    overflow: hidden;
}

.form-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient-radial);
    pointer-events: none;
}

/* Animated Background */
.form-section::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(3px 3px at 20% 30%, rgba(212, 175, 55, 0.3), transparent),
        radial-gradient(2px 2px at 40% 70%, rgba(212, 175, 55, 0.2), transparent),
        radial-gradient(2px 2px at 50% 50%, rgba(255, 255, 255, 0.1), transparent),
        radial-gradient(3px 3px at 80% 20%, rgba(212, 175, 55, 0.25), transparent),
        radial-gradient(2px 2px at 70% 80%, rgba(212, 175, 55, 0.2), transparent);
    background-size: 250px 250px;
    animation: twinkle 8s ease-in-out infinite;
    pointer-events: none;
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 0.5;
        transform: rotate(0deg);
    }

    50% {
        opacity: 1;
        transform: rotate(1deg);
    }
}

.form-container {
    max-width: 520px;
    margin: 0 auto;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 32px;
    padding: 48px 36px;
    box-shadow:
        var(--shadow-medium),
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 0 80px rgba(212, 175, 55, 0.1);
    border: 1px solid var(--glass-border);
    position: relative;
    z-index: 10;
    animation: formReveal 1s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes formReveal {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.form-header {
    text-align: center;
    margin-bottom: 40px;
}

.form-title {
    font-family: var(--font-display);
    font-size: 3.5rem;
    background: var(--gradient-gold);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    letter-spacing: 2px;
    text-shadow: 0 2px 10px rgba(212, 175, 55, 0.3);
}

.form-subtitle {
    font-size: 0.95rem;
    color: var(--text-light);
    font-weight: 400;
    letter-spacing: 0.5px;
}

.form-section-title {
    font-family: var(--font-elegant);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--secondary-color);
    padding: 16px 0 12px;
    margin-top: 28px;
    margin-bottom: 16px;
    border-bottom: 2px solid transparent;
    background: linear-gradient(var(--bg-ivory), var(--bg-ivory)) padding-box,
        var(--gradient-gold-soft) border-box;
    border-radius: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.form-section-title i {
    width: 32px;
    height: 32px;
    background: var(--gradient-gold-soft);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    box-shadow: var(--shadow-gold);
}

.wedding-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--secondary-color);
    letter-spacing: 0.5px;
}

.input-group input,
.input-group select,
.input-group textarea {
    padding: 16px 20px;
    border: 2px solid #e5e7eb;
    border-radius: 14px;
    font-size: 0.95rem;
    font-family: var(--font-body);
    transition: var(--transition-smooth);
    background: var(--bg-ivory);
    color: var(--text-dark);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--primary-glow);
    background: white;
}

.input-group input:hover,
.input-group select:hover {
    border-color: #d1d5db;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.input-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.input-hint::before {
    content: '💡';
    font-size: 0.7rem;
}

/* Enhanced File Upload */
.file-upload-wrapper {
    position: relative;
}

.file-upload-wrapper input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px 24px;
    border: 2px dashed var(--primary-color);
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.03) 0%, rgba(212, 175, 55, 0.08) 100%);
    color: var(--primary-dark);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition-smooth);
    cursor: pointer;
    text-align: center;
}

.file-upload-label i {
    font-size: 2rem;
    color: var(--primary-color);
    transition: var(--transition-bounce);
}

.file-upload-wrapper:hover .file-upload-label {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.08) 0%, rgba(212, 175, 55, 0.15) 100%);
    border-style: solid;
    transform: translateY(-2px);
}

.file-upload-wrapper:hover .file-upload-label i {
    transform: scale(1.1);
}

.file-upload-label.has-file {
    border-style: solid;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.1) 0%, rgba(212, 175, 55, 0.2) 100%);
    border-color: var(--primary-dark);
}

/* Photo Previews */
.photo-preview-small {
    margin-top: 16px;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.photo-preview-small img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 50%;
    border: 4px solid var(--primary-color);
    box-shadow: var(--shadow-gold);
    transition: var(--transition-smooth);
}

.photo-preview-small img:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.photo-preview-large {
    margin-top: 16px;
    text-align: center;
}

.photo-preview-large img {
    width: 100%;
    max-height: 220px;
    object-fit: cover;
    border-radius: 16px;
    border: 4px solid var(--primary-color);
    box-shadow: var(--shadow-gold);
}

.gallery-preview {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
    justify-content: center;
}

.gallery-preview img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 12px;
    border: 3px solid var(--primary-light);
    transition: var(--transition-smooth);
}

.gallery-preview img:hover {
    transform: scale(1.1) rotate(2deg);
    border-color: var(--primary-color);
}

/* Enhanced Submit Button */
.submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px 32px;
    background: var(--gradient-gold);
    border: none;
    border-radius: 16px;
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--font-body);
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-gold);
    margin-top: 32px;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.5px;
}

.submit-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.submit-btn:hover::before {
    left: 100%;
}

.submit-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 45px rgba(212, 175, 55, 0.4);
}

.submit-btn:active {
    transform: translateY(-1px);
}

/* Decorations */
.decoration {
    position: absolute;
    border-radius: 50%;
    background: var(--gradient-gold);
    opacity: 0.08;
    z-index: 1;
    filter: blur(60px);
}

.decoration-1 {
    width: 500px;
    height: 500px;
    top: -200px;
    right: -150px;
}

.decoration-2 {
    width: 400px;
    height: 400px;
    bottom: -150px;
    left: -100px;
}

/* ===== INVITATION ===== */
.invitation {
    position: relative;
    background: var(--bg-cream);
}

/* Back to Form Button */
.back-to-form-btn {
    position: fixed;
    top: 24px;
    left: 24px;
    padding: 12px 24px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: var(--font-body);
    cursor: pointer;
    z-index: 1000;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 10px;
}

.back-to-form-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translateX(-3px);
}

/* ===== CLASSIC 3D BOOK STYLES ===== */
:root {
    --book-width: 520px;
    --book-height: 730px;
    --paper-color: #fdfbf7;
    --paper-shadow: inset 0 0 30px rgba(0, 0, 0, 0.02), 10px 10px 30px rgba(0, 0, 0, 0.1);
    --cover-color: #4a3b32;
    --anim-speed: 1.2s;
}

/* 3D Scene Container */
.scene {
    width: calc(var(--book-width) * 2);
    height: var(--book-height);
    margin: 40px auto;
    position: relative;
    perspective: 2500px;
    transform: scale(1.1);
    transition: transform 0.5s ease;
}

@media (max-width: 1024px) {
    .scene {
        transform: scale(0.85);
    }
}

@media (max-width: 768px) {
    .scene {
        transform: scale(0.65);
    }
}

@media (max-width: 480px) {
    .scene {
        transform: scale(0.45);
    }
}

/* The Book Wrapper */
.book {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

/* Individual Pages */
.page {
    position: absolute;
    width: var(--book-width);
    height: var(--book-height);
    top: 0;
    right: 0;
    transform-origin: left center;
    transition: transform var(--anim-speed) cubic-bezier(0.2, 0.1, 0.15, 1);
    transform-style: preserve-3d;
    cursor: pointer;
    z-index: 1;
    will-change: transform;
    display: block !important;
}

/* Front and Back Faces */
.front,
.back {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background-color: var(--paper-color);
    backface-visibility: hidden;
    padding: 40px;
    box-sizing: border-box;
    box-shadow: var(--paper-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.front {
    z-index: 2;
    background:
        linear-gradient(to left, rgba(255, 255, 255, 0.8) 95%, rgba(227, 218, 206, 0.8) 100%),
        url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23noise)' opacity='0.08'/%3E%3C/svg%3E");
    background-color: #fdfbf7;
    border-radius: 0 5px 5px 0;
}

.back {
    transform: rotateY(180deg);
    z-index: 1;
    background:
        linear-gradient(to right, rgba(255, 255, 255, 0.8) 95%, rgba(227, 218, 206, 0.8) 100%),
        url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23noise)' opacity='0.08'/%3E%3C/svg%3E");
    background-color: #fdfbf7;
    border-radius: 5px 0 0 5px;
}

/* Flipped State */
.page.flipped {
    transform: rotateY(-180deg);
    z-index: 5;
}

/* Cover Design */
.cover-front {
    background-color: #3e2723;
    background-image:
        radial-gradient(circle at center, rgba(255, 255, 255, 0.05) 0%, transparent 60%),
        repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.03) 0px, rgba(0, 0, 0, 0.03) 2px, transparent 2px, transparent 4px),
        url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23251612' fill-opacity='0.4' fill-rule='evenodd'%3E%3Cpath d='M0 38.59l2.83-2.83 1.41 1.41L1.41 40H0v-1.41zM0 1.4l2.83 2.83 1.41-1.41L1.41 0H0v1.41zM38.59 40l-2.83-2.83 1.41-1.41L40 38.59V40h-1.41zM40 1.41l-2.83 2.83-1.41-1.41L38.59 0H40v1.41zM20 18.6l2.83-2.83 1.41 1.41L21.41 20l2.83 2.83-1.41 1.41L20 21.41l-2.83 2.83-1.41-1.41L18.59 20l-2.83-2.83 1.41-1.41L18.59 20l-2.83-2.83 1.41-1.41L20 18.59z'/%3E%3C/g%3E%3C/svg%3E");
    color: #e8dcc5;
    text-align: center;
    border: 2px solid #5e4b40;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5);
}

.gold-border {
    border: 2px solid #cfaa6e;
    padding: 20px;
    margin: 10px;
    height: calc(100% - 20px);
    width: calc(100% - 20px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Helpers */
.font-serif {
    font-family: 'Playfair Display', serif;
}

.text-5xl {
    font-size: 3rem;
}

.font-bold {
    font-weight: 700;
}

.mb-4 {
    margin-bottom: 1rem;
}

.tracking-widest {
    letter-spacing: 0.1em;
}

.text-gold {
    color: #cfaa6e;
    background: linear-gradient(to bottom, #d4af37 0%, #f4e4a6 40%, #cfaa6e 60%, #b8860b 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2));
}

.text-cream {
    color: #e8dcc5;
}

.text-brown {
    color: #8b4513;
}

.italic {
    font-style: italic;
}

.drop-cap {
    float: left;
    font-family: 'Playfair Display', serif;
    font-size: 4rem;
    line-height: 3.5rem;
    padding-right: 8px;
    padding-top: 4px;
    color: #8b4513;
}

.page-number {
    position: absolute;
    bottom: 20px;
    font-size: 0.9rem;
    color: #888;
}

.front .page-number {
    right: 20px;
}

.back .page-number {
    left: 20px;
}

/* Mobile Controls */
.controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    z-index: 100;
}

.btn {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 10px 20px;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: sans-serif;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
    backdrop-filter: blur(5px);
}

.btn:hover {
    background-color: white;
    color: #2c241b;
}

.btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Image Helper */
.polaroid {
    background: white;
    padding: 10px 10px 25px 10px;
    box-shadow: 2px 3px 15px rgba(0, 0, 0, 0.1);
    transform: rotate(-2deg);
    margin: 20px auto;
    max-width: 80%;
    text-align: center;
    font-family: 'Crimson Text', cursive;
    color: #444;
    font-size: 0.9rem;
    transition: transform 0.3s ease;
}

.polaroid:hover {
    transform: rotate(0deg) scale(1.02);
}

.polaroid img {
    width: 100%;
    height: auto;
    filter: sepia(30%);
    display: block;
}

body.book-mode {
    background-color: #2c241b;
    background-image: radial-gradient(circle at center, #3e332a 0%, #1a1612 100%);
    font-family: 'Crimson Text', serif;
    overflow: hidden;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}