:root {
    --invitation-width: min(100vw, 480px);
    --invitation-height: 100vh;
    color-scheme: light;
    --ink: #75501d;
    --gold: #b88a4e;
    --paper: #eee5d7;
    --ease: cubic-bezier(.22, 1, .36, 1);
}

@supports (height:100dvh) {
    :root {
        --invitation-height: 100dvh;
    }
}

* {
    box-sizing: border-box;
}

html {
    height: 100%;
    background: #e5ded2;
    overscroll-behavior: none;
}

body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    color: var(--ink);
    font-family: InvitationArabic, serif;
    -webkit-tap-highlight-color: transparent;
}

button,
input,
textarea {
    font: inherit;
    color: inherit;
}

button,
a,
input,
textarea {
    touch-action: manipulation;
}

button {
    cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
[role=button]:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 4px;
}

img {
    display: block;
    max-width: 100%;
}

[hidden] {
    display: none !important;
}

.app {
    width: var(--invitation-width);
    height: var(--invitation-height);
    position: fixed;
    inset: 0;
    margin: auto;
    container-type: inline-size;
}

.fixed-background,
.opening-door {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.fixed-background {
    z-index: 0;
    pointer-events: none;
    background: var(--paper);
}

.fixed-background img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scroll-content {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: hidden;
    overscroll-behavior-y: contain;
    scroll-snap-type: none;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.scroll-content::-webkit-scrollbar {
    display: none;
}

body[data-state=invitation] .scroll-content {
    overflow-y: auto;
}

.invitation-section {
    position: relative;
    min-height: var(--invitation-height);
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    scroll-snap-align: start;
    padding: calc(var(--invitation-height) * .11 + env(safe-area-inset-top)) 10% calc(var(--invitation-height) * .12 + env(safe-area-inset-bottom));
}

.section-content {
    width: 100%;
    max-width: 380px;
    padding-block: 20px;
}

.reveal {
    opacity: 0;
    transform: translateY(20px) scale(.98);
    filter: blur(7px);
    transition: opacity 1100ms var(--ease), transform 1100ms var(--ease), filter 1100ms var(--ease);
    transition-delay: var(--delay, 0ms);
}

.is-visible .reveal {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
}

h1,
h2,
h3,
p {
    margin: 0;
    font-weight: 400;
}

h2 {
    font-size: clamp(22px, 6.5cqw, 31px);
    line-height: 1.6;
}

p {
    font-size: clamp(17px, 4.7cqw, 22px);
    line-height: 1.8;
}

.eyebrow {
    font-size: 16px;
    line-height: 1.7;
}

.divider {
    width: 68%;
    height: auto;
    margin: 26px auto;
}

.islamic-title {
    width: 80%;
    margin: 0 auto 42px;
}

.names {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 3%;
    width: 100%;
    min-height: 185px;
}

.name {
    width: 36%;
    font-family: InvitationNames, serif;
    font-size: clamp(41px, 12cqw, 59px);
    line-height: 1.9;
    padding-bottom: 18px;
    white-space: nowrap;
}

.monogram {
    width: 20%;
    height: 185px;
    object-fit: contain;
}

.hero .section-content {
    transform: translateY(calc(var(--invitation-height) * -.01));
}

.hero .names {
    margin-block: 10px 14px;
}

.hero .names .name {
    font-size: clamp(33px, 9.6cqw, 47px);
}

.hero .names .name:first-child {
    font-size: clamp(42px, 12cqw, 58px);
}

.hero .occasion {
    font-size: 16px;
    margin-top: 14px;
}

.hero .date-line {
    margin-top: 20px;
    font: 16px Georgia, serif;
    letter-spacing: 3px;
    direction: ltr;
}

.message .names {
    min-height: 120px;
}

.message .monogram {
    height: 125px;
    width: 15%;
}

.message .name {
    font-size: clamp(36px, 10cqw, 49px);
}

.message-lines {
    margin-block: 12px 24px;
}

.families {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 22px;
}

.families p {
    width: 50%;
    font-size: clamp(14px, 3.7cqw, 18px);
    line-height: 1.9;
}

.art-window {
    position: relative;
    overflow: hidden;
    margin-inline: auto;
    direction: ltr;
}

.art-window>.artwork {
    position: absolute;
    max-width: none;
    height: auto;
    pointer-events: none;
}

.date-art {
    width: 88%;
    aspect-ratio: 612/818;
    margin-top: 24px;
}

.date-art>.artwork {
    width: 155.882353%;
    left: -28.104575%;
    top: -44.00978%;
}

.date-main {
    position: absolute;
    top: 15%;
    left: 28%;
    width: 44%;
    height: 43%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    direction: rtl;
}

.date-day {
    font: clamp(44px, 14cqw, 67px)/1.2 Georgia, serif;
}

.date-month {
    font-size: clamp(20px, 5.4cqw, 26px);
    margin-top: 8px;
}

.date-year {
    font: 18px Georgia, serif;
    margin-top: 12px;
}

.date-badge {
    position: absolute;
    top: 79%;
    width: 46%;
    height: 14%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(17px, 4.4cqw, 21px);
}

.date-badge.right {
    left: 53%;
}

.date-badge.left {
    left: 1%;
    direction: ltr;
}

.location-art {
    width: 97%;
    aspect-ratio: 624/1013;
    margin-top: 14px;
}

.location-art>.artwork {
    width: 152.884615%;
    left: -26.602564%;
    top: -27.245805%;
    z-index: 2;
}

.map-clip {
    position: absolute;
    left: 7.8%;
    top: 5.8%;
    width: 84.7%;
    height: 63%;
    overflow: hidden;
    z-index: 1;
}

.map-clip img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 100% 20%;
    transform: scale(2);
    transform-origin: 50% 47%;
}

.location-name {
    position: absolute;
    z-index: 3;
    top: 68.5%;
    left: 18%;
    width: 65%;
    height: 13%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.location-name strong {
    font: clamp(21px, 6.4cqw, 30px)/1.1 Georgia, serif;
}

.location-name span {
    font-size: 16px;
    margin-top: 5px;
}

.directions {
    position: absolute;
    z-index: 3;
    left: 20.7%;
    top: 90.6%;
    width: 59%;
    height: 9.4%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 17px;
    color: var(--ink);
}

.time-art {
    width: 51%;
    aspect-ratio: 290/230;
    margin-top: 24px;
}

.time-art>.artwork {
    width: 328.9655%;
    left: -59.3103%;
    top: -408.7%;
}

.time-label {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
}

.time-digits {
    font: clamp(58px, 18cqw, 87px)/1.2 Georgia, serif;
    letter-spacing: 2px;
    direction: ltr;
    margin-block: 28px 6px;
}

.time .closing {
    font-size: 19px;
}

.schedule-item {
    margin-block: 22px;
}

.schedule-item h3 {
    font-size: 23px;
}

.schedule-item time {
    font-size: 18px;
}

.schedule-item p {
    font-size: 16px;
}

.rsvp .section-content {
    max-width: 300px;
}

.rsvp h2 {
    margin-bottom: 6px;
}

.rsvp .deadline {
    font-size: 14px;
    line-height: 1.6;
}

.rsvp .children-note {
    font-size: 19px;
    margin-block: 10px 18px;
}

.rsvp-form {
    text-align: right;
}

.field {
    display: block;
    margin-bottom: 13px;
}

.field>span,
legend,
.guests-label {
    display: block;
    font-size: 15px;
    margin-bottom: 6px;
}

input[type=text],
textarea {
    display: block;
    width: 100%;
    min-height: 46px;
    padding: 10px 13px;
    border: 1px solid #b08c586b;
    border-radius: 8px;
    background: #fffaf175;
    font-size: 16px;
    outline-offset: 2px;
}

input::placeholder {
    color: #977c55;
}

textarea {
    resize: vertical;
    min-height: 66px;
}

fieldset {
    border: 0;
    margin: 0 0 12px;
    padding: 0;
    min-width: 0;
}

.choice {
    display: flex;
    gap: 8px;
    align-items: center;
    min-height: 44px;
    font-size: 15px;
}

input[type=radio] {
    accent-color: var(--ink);
    width: 18px;
    height: 18px;
    margin: 0;
}

.guest-field {
    text-align: center;
    margin-block: 12px;
}

.stepper {
    display: flex;
    direction: ltr;
    justify-content: center;
    gap: 19px;
    align-items: center;
}

.stepper button {
    width: 44px;
    height: 44px;
    border: 1px solid #b08c586b;
    border-radius: 50%;
    background: #fffaf154;
    font: 25px Georgia, serif;
}

.stepper button:disabled {
    opacity: .38;
    cursor: default;
}

.stepper output {
    min-width: 25px;
    font: 22px Georgia, serif;
}

.submit {
    display: block;
    min-height: 46px;
    min-width: 130px;
    margin: 18px auto 0;
    padding: 8px 26px;
    border: 1px solid var(--gold);
    background: #faf4e9;
    border-radius: 24px;
}

.local-notice,
.form-status {
    text-align: center;
    font-size: 13px;
    line-height: 1.7;
    margin-top: 12px;
}

.form-status {
    font-size: 15px;
}

.ending .names {
    margin-bottom: 22px;
}

.ending .signature {
    font-size: 16px;
    margin-top: 15px;
}

.ending time {
    display: block;
    font: 18px Georgia, serif;
    letter-spacing: 3px;
    direction: ltr;
}

.scroll-down {
    position: absolute;
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    min-width: 118px;
    min-height: 40px;
    border: 1px solid #d8c8ad;
    padding: 7px 16px;
    border-radius: 30px;
    background: #fffaf1eb;
    box-shadow: 0 2px 8px #6f4d2420;
    font-size: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: opacity 200ms;
}

.opening-door {
    z-index: 50;
    overflow: hidden;
    background-color: var(--paper);
    /* Real poster on top, tiny embedded placeholder beneath it (shows instantly, no network wait)
       so the video element is never left over a blank background while either is still loading. */
    background-image: url("./assets/opening-poster.jpg"), url("data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QBARXhpZgAATU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAEqADAAQAAAABAAAAIAAAAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/+ICpElDQ19QUk9GSUxFAAEBAAAClGFwcGwCEAAAbW50clJHQiBYWVogB9UABAABAAEAAQABYWNzcEFQUEwAAAAAQVBQTAAAAAAAAAAAAAAAAAAAAAAAAPbWAAEAAAAA0y1hcHBsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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KC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/bAEMABgYGBgYGCgYGCg4KCgoOEg4ODg4SFxISEhISFxwXFxcXFxccHBwcHBwcHCIiIiIiIicnJycnLCwsLCwsLCwsLP/bAEMBBwcHCwoLEwoKEy4fGh8uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLi4uLv/dAAQAAv/aAAwDAQACEQMRAD8A91Vyt04c9WOKhmUeSr4Jx2pdiyXchb+EnB9KXcskRTrt61xHSZvnTdnYD6mk86f/AJ6N+ZoOM8UlQUf/0Pcty+bMncuQKqhfJgOGJZjkk02aUrePtHRjz+NPlObYH2NcJ02KWPWjFMAcgHBpcP6GpuWf/9k=");
    background-size: cover, cover;
    background-position: center, center;
    background-repeat: no-repeat, no-repeat;
    transition: opacity 350ms ease;
    touch-action: none;
}

.opening-door video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* WebKit paints the video's own compositor surface black until a real frame decodes,
       covering whatever CSS background sits behind it. Stay hidden until app.js confirms
       (via the 'playing' event) that a frame is actually rendering, then fade in. */
    opacity: 0;
    transition: opacity 200ms linear;
}

.opening-door video.is-ready {
    opacity: 1;
}

.opening-door.is-fading {
    opacity: 0;
    pointer-events: none;
}

.opening-error {
    position: absolute;
    bottom: 12%;
    width: 74%;
    left: 13%;
    background: #fff7e9ed;
    border-radius: 10px;
    padding: 12px;
    text-align: center;
    font-size: 17px;
}

.noscript {
    position: fixed;
    inset: 35% 15% auto;
    z-index: 100;
    text-align: center;
    background: var(--paper);
    padding: 20px;
}

#debug {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    background: #fff;
    font: 12px monospace;
    color: #111;
}

.debug .invitation-section {
    outline: 1px dashed red;
}

@media (max-height:700px) {
    .invitation-section {
        padding-top: calc(var(--invitation-height) * .12);
        padding-bottom: calc(var(--invitation-height) * .13);
    }

    .islamic-title {
        margin-bottom: 24px;
    }

    .names,
    .monogram {
        min-height: 140px;
        height: 140px;
    }

    .date-art {
        width: 74%;
    }

    .location-art {
        width: 80%;
    }

    .rsvp .section-content {
        padding-block: 0;
    }
}

@media (prefers-reduced-motion:reduce) {
    .reveal {
        transform: none;
        filter: none;
        transition: opacity 150ms ease;
        transition-delay: 0ms;
    }

    .opening-door {
        transition-duration: 150ms;
    }
}

/* Balance the two supplied-font names and keep the RSVP within a phone screen. */
.names .name:first-child {
    font-size: clamp(53px, 15cqw, 72px);
}

.message .names .name:first-child {
    font-size: clamp(44px, 12.5cqw, 59px);
}

.rsvp .section-content {
    padding-block: 0;
}

.rsvp .children-note {
    margin-block: 6px 10px;
}

.rsvp .field {
    margin-bottom: 10px;
}

.rsvp .field>span {
    margin-bottom: 4px;
}

.rsvp textarea {
    height: 58px;
    min-height: 58px;
}

.rsvp .guest-field {
    margin-block: 6px;
}

.rsvp .submit {
    margin-top: 12px;
}

@media (prefers-reduced-motion:reduce) {
    .is-visible .reveal {
        filter: none;
        transform: none;
    }
}