:root {
    --bg: #0a0906;
    --text: #f0e8de;
    --accent: #9e8a78;
    --gold: #c4a882;
    --border: rgba(240, 232, 222, 0.15);
}

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

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    font-family: 'Cormorant Garamond', Georgia, serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    margin: 0;
}

p {
    margin: 0;
}

h1 {
    font-size: clamp(3.5rem, 10vw, 12rem);
    font-weight: 300;
    letter-spacing: 0.04em;
    margin: 0;
    line-height: 0.95;
}

h2 {
    font-size: clamp(2.5rem, 5vw, 8rem);
    font-weight: 300;
    letter-spacing: 0.02em;
    margin: 0;
    line-height: 1.1;
}

:is(section, article) {
    position: relative;
}

/* ── Hero ──────────────────────────────────────────── */

.s-hero {
    height: 100vh;
    background: var(--bg);
}

.s-hero .fixed {
    z-index: 5;
}

.hero-content {
    position: absolute;
    inset: 0;
    display: grid;
    align-content: end;
    justify-content: start;
    padding: 6rem 4rem;
    z-index: 2;
}

.eyebrow {
    font-size: clamp(0.65rem, 1vw, 0.85rem);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 1.25rem;
    font-family: system-ui, sans-serif;
}

.hero-date {
    font-size: clamp(1rem, 1.5vw, 1.5rem);
    color: var(--accent);
    margin-top: 1.5rem;
    letter-spacing: 0.1em;
}

.hero-scroll {
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(240, 232, 222, 0.35);
    margin-top: 3rem;
    font-family: system-ui, sans-serif;
}

/* ── Fixed image pattern ───────────────────────────── */

.fixed {
    position: relative;
}

.fixed img {
    height: 100%;
    width: 150%;
    object-fit: cover;
    position: absolute;
    inset: 0;
    left: 50%;
    translate: -50% 0;
    filter: brightness(0.55);
    z-index: -1;
    will-change: transform;
}

/* ── Story section ─────────────────────────────────── */

.s-story article {
    min-height: 100vh;
}

.s-story .content {
    position: absolute;
    inset: 0;
    padding: 4rem;
    display: grid;
    align-content: center;
    z-index: 2;
    width: min(940px, 100%);
    margin: 0 auto;
}

/* ── Article 1: a-story ────────────────────────────── */

.a-story .fixed {
    z-index: 2;
}

.a-story .content {
    align-content: end;
    padding-bottom: 6rem;
}

/* ── Article 2: a-details ──────────────────────────── */

.a-details .fixed {
    z-index: 2;
}

.a-details img {
    filter: brightness(0.4) !important;
}

.a-details .content {
    align-content: center;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 2.5rem;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.detail-label {
    display: block;
    font-size: 0.7rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--accent);
    font-family: system-ui, sans-serif;
}

.detail-value {
    display: block;
    font-size: clamp(1.1rem, 2vw, 1.75rem);
    margin-top: 0.5rem;
    line-height: 1.2;
}

.detail-sub {
    display: block;
    font-size: clamp(0.8rem, 1.2vw, 1rem);
    color: var(--accent);
    margin-top: 0.375rem;
}

/* ── Article 3: a-vows ─────────────────────────────── */

.a-vows .fixed {
    z-index: 2;
}

.a-vows img {
    filter: saturate(0.4) brightness(0.4) !important;
}

.a-vows .content {
    align-content: start;
}

.chat-container {
    height: 100vh;
    width: 100%;
    position: sticky;
    top: 0;
    display: grid;
    place-items: center;
}

.text-blocks {
    max-width: 100%;
    width: 40ch;
    justify-self: end;
    display: grid;
    gap: 2rem 0;
}

.text-blocks p {
    display: inline-block;
    margin: 0;
    font-size: clamp(1.25rem, 2.5vw, 3rem);
    font-style: italic;
    font-weight: 300;
    line-height: 1.3;
}

.text-blocks p:nth-of-type(odd) {
    justify-self: start;
    color: var(--text);
}

.text-blocks p:nth-of-type(even) {
    justify-self: end;
    text-align: right;
    color: var(--gold);
}

.filler {
    display: none;
}

/* ── Article 4: a-final ────────────────────────────── */

.a-final .fixed {
    z-index: 5;
}

.final-content {
    position: absolute;
    inset: 0;
    display: grid;
    align-content: center;
    justify-content: center;
    text-align: center;
    padding: 4rem;
    z-index: 2;
}

/* ── RSVP ──────────────────────────────────────────── */

.s-rsvp {
    position: relative;
    z-index: 20;
    background: var(--bg);
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 8rem 2rem;
    border-top: 1px solid var(--border);
}

.rsvp-inner {
    width: min(560px, 100%);
}

.rsvp-title {
    font-size: clamp(2.5rem, 5vw, 5rem);
    margin-top: 0.5rem;
}

.rsvp-deadline {
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    color: var(--accent);
    margin-top: 1rem;
    font-family: system-ui, sans-serif;
    text-transform: uppercase;
}

.rsvp-form {
    margin-top: 3rem;
    display: grid;
    gap: 1.5rem;
}

.form-group {
    display: grid;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
    font-family: system-ui, sans-serif;
}

.optional {
    text-transform: none;
    font-size: 0.85em;
    letter-spacing: 0;
    opacity: 0.6;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: rgba(240, 232, 222, 0.04);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.875rem 1rem;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.125rem;
    outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 0;
}

.form-group select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239e8a78' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--gold);
}

.form-group textarea {
    resize: vertical;
}

.form-group select option {
    background: #1a1714;
    color: var(--text);
}

.btn-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 0.5rem;
}

.btn-accept {
    background: var(--text);
    color: var(--bg);
    border: none;
    padding: 1rem 2rem;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-accept:hover {
    background: var(--gold);
}

.btn-decline {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--border);
    padding: 0.875rem 2rem;
    font-family: system-ui, sans-serif;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    cursor: pointer;
    transition:
        border-color 0.2s,
        color 0.2s;
    text-align: left;
}

.btn-decline:hover {
    border-color: var(--accent);
    color: var(--text);
}

.form-status {
    font-size: 0.9rem;
    color: var(--accent);
    min-height: 1.5rem;
    font-family: system-ui, sans-serif;
    text-align: center;
}

.form-status.error {
    color: #e07070;
}

.form-status.success {
    color: #70c0a0;
}

/* ── Footer ────────────────────────────────────────── */

.s-footer {
    position: relative;
    z-index: 20;
    background: var(--bg);
    padding: 2rem;
    text-align: center;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--accent);
    font-family: system-ui, sans-serif;
}

/* ── CSS scroll-driven animations ──────────────────── */

@supports (animation-timeline: scroll()) {
    @media (prefers-reduced-motion: no-preference) {
        article {
            view-timeline: --article;
        }

        .fixed {
            position: fixed;
            inset: 0;
            will-change: transform, opacity;
        }

        .static {
            position: absolute;
            inset: 0;
            z-index: 6;
        }

        .filler {
            display: block;
            width: 100%;
            position: absolute;
            bottom: 30vh;
            padding: 1rem 4rem;
        }

        /* ── Hero: scale-and-move + fade on exit ── */
        .s-hero {
            view-timeline: --section;
        }

        .s-hero .fixed {
            animation:
                scale-and-move both linear,
                fade-out both linear;
            animation-timeline: --section;
            animation-range:
                exit 0% exit 50%,
                exit 0% exit 25%;
            transform-origin: 50% 0;
        }

        /* ── a-story: clip-path reveal from below ── */
        .a-story .fixed {
            clip-path: ellipse(220% 200% at 50% 300%);
            animation: unclip both linear;
            animation-timeline: --article;
            animation-range: entry 0% entry 100%;
        }

        /* ── a-story image: dramatic scale-down on entry ── */
        .a-story img {
            animation: scale-down both linear;
            animation-timeline: --article;
            animation-range: entry;
        }

        /* ── a-story text: mask reveal + slide-up ── */
        .loud-wrap {
            clip-path: inset(0 0 0 0);
            animation: unmask both linear;
            animation-timeline: --article;
            animation-range: entry 20% entry 80%;
            mask: linear-gradient(white 50%, transparent) 0 100% / 100% 200% no-repeat;
        }

        .text-wrap {
            position: sticky;
            bottom: 4rem;
            transform-origin: 50% 0;
            animation:
                fade-away both linear,
                fade-out both linear;
            animation-timeline: --article;
            animation-range:
                exit 40% exit 75%,
                exit 70% exit 100%;
        }

        /* ── a-details: fade in ── */
        .a-details .fixed {
            animation: fade-in both linear;
            animation-fill-mode: both;
            animation-timing-function: linear;
            animation-timeline: --article;
            animation-range: entry 60% exit 30%;
        }

        /* ── a-details h2: slide+fade in then blur out ── */
        .a-details h2 {
            animation: slide-in, fade-in, fade-away, fade-out;
            animation-fill-mode: both;
            animation-timing-function: linear;
            animation-timeline: view(), view(), --article, --article;
            animation-range:
                entry 100% cover 25%,
                entry 100% cover 35%,
                exit 20% exit 40%,
                exit 40% exit 50%;
        }

        /* ── a-vows: 400 vh long scroll ── */
        .a-vows {
            height: 400vh;
        }

        .a-vows h2 {
            margin-top: 80vh;
        }

        .a-vows .fixed {
            animation:
                fade-in both linear,
                fade-out both linear;
            animation-timeline: --article, --article;
            animation-range:
                entry 45% exit-crossing 0%,
                exit 0% exit 15%;
        }

        /* ── Text blocks: staggered slide-in ── */
        .text-blocks p {
            animation: slide-in, fade-in;
            animation-fill-mode: both;
            animation-timing-function: linear;
            animation-timeline: --article;
        }

        .text-blocks p:nth-of-type(1) {
            animation-range: entry-crossing 48% entry-crossing 54%;
        }
        .text-blocks p:nth-of-type(2) {
            animation-range: entry-crossing 54% entry-crossing 60%;
        }
        .text-blocks p:nth-of-type(3) {
            animation-range: entry-crossing 60% entry-crossing 66%;
        }
        .text-blocks p:nth-of-type(4) {
            animation-range: entry-crossing 66% entry-crossing 72%;
        }
        .text-blocks p:nth-of-type(5) {
            animation-range: entry-crossing 72% entry-crossing 78%;
        }

        .text-blocks {
            animation: fade-out both linear;
            animation-timeline: --article;
            animation-range: entry-crossing 75% entry-crossing 100%;
        }

        .filler h2 {
            animation:
                fade-away both linear,
                fade-out both linear;
            animation-timing-function: linear;
            animation-fill-mode: both;
            animation-timeline: --article;
            animation-range:
                exit 40% exit 75%,
                exit 70% exit 90%;
        }

        /* ── a-final: clip-path reveal + fade out on exit ── */
        .a-final {
            z-index: 5;
        }

        .a-final .fixed {
            clip-path: ellipse(220% 200% at 50% 300%);
            animation:
                unclip both linear,
                fade-out both linear;
            animation-timeline: --article, --article;
            animation-range:
                entry 20% entry 80%,
                exit 0% exit 60%;
        }

        /* ── Keyframes ── */
        @keyframes slide-in {
            0% {
                translate: 0 100%;
            }
        }

        @keyframes slide-up {
            0% {
                translate: 0 100%;
            }
        }

        @keyframes fade-in {
            0% {
                opacity: 0;
            }
        }

        @keyframes fade-out {
            to {
                opacity: 0;
            }
        }

        @keyframes fade-away {
            to {
                filter: blur(4rem);
            }
        }

        @keyframes unmask {
            to {
                mask-position: 0 0;
            }
        }

        @keyframes scale-down {
            0% {
                scale: 5;
            }
        }

        @keyframes unclip {
            to {
                clip-path: ellipse(220% 200% at 50% 175%);
            }
        }

        @keyframes scale-and-move {
            to {
                translate: 0 -10%;
                scale: 0.35 0.5;
            }
        }
    }
}

/* ── Mobile ────────────────────────────────────────── */

@media (max-width: 600px) {
    .hero-content {
        padding: 4rem 2rem;
    }

    .s-story .content {
        padding: 2rem;
    }

    .details-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .text-blocks {
        width: 100%;
    }

    .final-content {
        padding: 2rem;
    }

    .s-rsvp {
        padding: 5rem 1.5rem;
    }
}
