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

:root {
    --color-bg: #faf8f5;
    --color-surface: #ffffff;
    --color-primary: #3a3a3a;
    --color-primary-hover: #222222;
    --color-text: #3a3a3a;
    --color-text-light: #999590;
    --color-accent-orange: #d4854a;
    --color-accent-pink: #d4a0a0;
    --color-accent-olive: #7a8c5e;
    --color-border: #e8e2da;
    --color-success: #7a8c5e;
    --font-body: 'Cormorant Garamond', serif;
    --font-display: 'Cormorant Garamond', serif;
    --radius: 8px;
    --shadow: 0 2px 16px rgba(100, 80, 60, 0.06);
    --shadow-lg: 0 8px 32px rgba(100, 80, 60, 0.1);
    --spacing: 0.2em;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-weight: 300;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    letter-spacing: 0.05em;
}

/* ===== Header ===== */
header {
    background: var(--color-bg);
    text-align: center;
    padding: 3.5rem 1.5rem 2.5rem;
    border-bottom: 1px solid var(--color-border);
    position: relative;
}

.header-content {
    position: relative;
    z-index: 1;
}

.date-line {
    font-family: var(--font-body);
    font-weight: 200;
    font-size: 0.8rem;
    letter-spacing: var(--spacing);
    text-transform: uppercase;
    color: var(--color-text-light);
    margin-bottom: 1rem;
}

header h1 {
    font-family: var(--font-display);
    font-size: 2.4rem;
    font-weight: 500;
    color: var(--color-text);
    line-height: 1.3;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
}

.subtitle {
    font-weight: 200;
    font-size: 0.9rem;
    letter-spacing: var(--spacing);
    text-transform: uppercase;
    color: var(--color-text-light);
}

/* ===== Sections ===== */
main {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1rem;
}

.section {
    padding: 2.5rem 0;
}

.section h2 {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 1.1rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: var(--spacing);
    margin-bottom: 0.25rem;
}

.section-desc {
    text-align: center;
    color: var(--color-text-light);
    font-size: 0.85rem;
    font-weight: 200;
    letter-spacing: 0.1em;
    margin-bottom: 1.5rem;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.75rem;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 300;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-primary);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    border-color: var(--color-text-light);
    background: var(--color-bg);
}

/* ===== Upload Area ===== */
#upload-area {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.upload-label {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem 2rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 300;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.upload-label:active {
    background: var(--color-bg);
}

.upload-label input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    font-size: 200px;
}


/* ===== Preview Area ===== */
#preview-area {
    margin-top: 1.5rem;
}

#preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
    margin-bottom: 1rem;
}

#preview-grid .preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 4px;
    overflow: hidden;
}

#preview-grid .preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#preview-grid .preview-item .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    border: none;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.upload-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: center;
}

#guest-name {
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    background: var(--color-surface);
    color: var(--color-text);
    outline: none;
    transition: border-color 0.2s;
    width: 220px;
}

#guest-name:focus {
    border-color: var(--color-text-light);
}

#guest-name::placeholder {
    color: var(--color-text-light);
    font-weight: 200;
}

/* ===== Progress Bar ===== */
#progress-area {
    margin-top: 1.5rem;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: var(--color-accent-olive);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

#progress-text {
    font-size: 0.8rem;
    font-weight: 200;
    letter-spacing: 0.1em;
    color: var(--color-text-light);
}

/* ===== Gallery Grid ===== */
#gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 4px;
}

#gallery-grid .gallery-item {
    aspect-ratio: 1;
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s;
}

#gallery-grid .gallery-item:hover {
    transform: scale(1.02);
}

#gallery-grid .gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#gallery-grid .gallery-item .photo-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.5rem 0.5rem 0.4rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.4));
    color: #fff;
    font-size: 0.7rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    opacity: 0;
    transition: opacity 0.2s;
}

#gallery-grid .gallery-item:hover .photo-overlay {
    opacity: 1;
}

.empty-msg {
    text-align: center;
    color: var(--color-text-light);
    font-weight: 200;
    font-style: italic;
    letter-spacing: 0.1em;
    padding: 2rem;
}

/* ===== Lightbox ===== */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s;
}

.lightbox.hidden {
    display: none;
}

.lightbox-content {
    max-width: 90vw;
    max-height: 85vh;
    text-align: center;
}

.lightbox-content img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 2px;
}

#lightbox-caption {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.8rem;
    font-weight: 200;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-top: 0.75rem;
}

.lightbox-btn {
    position: absolute;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 2rem;
    cursor: pointer;
    padding: 1rem;
    z-index: 1001;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.lightbox-btn:hover {
    color: #fff;
}

.lightbox-close {
    top: 0.5rem;
    right: 0.5rem;
    font-size: 2.5rem;
}

.lightbox-prev {
    left: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 3rem;
}

.lightbox-next {
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 3rem;
}

/* ===== Spinner ===== */
.spinner {
    width: 28px;
    height: 28px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-text-light);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 1rem auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Footer ===== */
footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--color-text-light);
    font-size: 0.75rem;
    font-weight: 200;
    letter-spacing: var(--spacing);
    text-transform: uppercase;
    border-top: 1px solid var(--color-border);
    margin-top: 1rem;
}

/* ===== Utilities ===== */
/* ===== Landing Page ===== */
.landing-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 3rem 1rem;
}

.landing-msg {
    font-weight: 200;
    font-size: 1rem;
    letter-spacing: 0.1em;
    color: var(--color-text-light);
    text-align: center;
}

#qr-reader {
    width: 100%;
    max-width: 350px;
    border-radius: var(--radius);
    overflow: hidden;
}

#qr-reader video {
    border-radius: var(--radius);
}

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== Toast Notification ===== */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--color-primary);
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: var(--color-accent-olive);
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    header {
        padding: 2.5rem 1rem 2rem;
    }

    header h1 {
        font-size: 2rem;
    }

    #gallery-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2px;
    }

    #gallery-grid .gallery-item {
        border-radius: 0;
    }

    #gallery-grid .gallery-item .photo-overlay {
        opacity: 1;
        padding: 1rem 0.25rem 0.25rem;
    }

    .lightbox-prev, .lightbox-next {
        font-size: 2rem;
    }

    #preview-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 768px) {
    header h1 {
        font-size: 3rem;
    }

    #gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 4px;
    }

    #preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}
