/* ==========================================================================
   Mabrook — Guest surfaces (invitation, RSVP, lookup, upload, gallery)
   Design system v5 (prototype parity): stationery card with a double frame,
   Marcellus display type, Outfit body, Amiri for Arabic.
   Every colour comes from the per-event theme tokens (--mbi-*) that the PHP
   injects on the wrapper; the prototype palette equals their defaults.
   Doubled-class selectors (.mabrook-invitation.mabrook-invitation) are
   deliberate: they out-rank the !important rules in mabrook-reset.css,
   which always loads after this file. RTL-safe via logical properties.
   ========================================================================== */

.mabrook-invitation {
    background: var(--mbi-bg);
    color: var(--mbi-text);
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 70px 16px 90px;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

.mabrook-invitation > * { width: 100%; }

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

.mabrook-invitation.is-rtl { font-family: 'Amiri', serif; }

.mabrook-invitation ::selection { color: var(--mbi-bg); background: var(--mbi-primary); }

/* --------------------------------------------------------------------------
   Preview band (hosts previewing an unpublished invitation)
   -------------------------------------------------------------------------- */

.mbi-preview-band {
    max-width: 680px;
    margin: 0 auto 16px;
    background: var(--mbi-primary);
    color: var(--mbi-bg);
    text-align: center;
    font-size: 13px;
    font-weight: 650;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 9px 12px;
}

.mabrook-invitation.is-rtl .mbi-preview-band {
    letter-spacing: 0;
    text-transform: none;
}

/* --------------------------------------------------------------------------
   The card. The invitation gets the stationery double frame; the RSVP and
   media cards are plain guest cards (frame cancelled further down).
   -------------------------------------------------------------------------- */

.mbi-card {
    position: relative;
    max-width: 680px;
    margin: 0 auto;
    background: var(--mbi-surface);
    border: 1px solid var(--mbi-line);
    box-shadow: 0 20px 50px rgba(38, 24, 33, .08);
    padding: 54px 22px 38px;
    text-align: center;
}

.mbi-card::before {
    content: "";
    position: absolute;
    inset: 14px;
    border: 1px solid var(--mbi-line);
    pointer-events: none;
}

.mbi-card > * { position: relative; }

.mabrook-rsvp .mbi-card::before,
.mabrook-media-page .mbi-card::before { content: none; }

.mabrook-rsvp .mbi-card,
.mabrook-media-page .mbi-card {
    max-width: 520px;
    padding: 28px 20px;
}

/* --------------------------------------------------------------------------
   Ornament: a restrained accent hairline
   -------------------------------------------------------------------------- */

.mbi-ornament {
    width: 46px;
    height: 1px;
    background: var(--mbi-accent);
    margin: 0 auto 32px;
}

.mbi-ornament-end { margin: 38px auto 0; }

/* --------------------------------------------------------------------------
   Type
   -------------------------------------------------------------------------- */

.mabrook-invitation.mabrook-invitation .mbi-kicker {
    margin: 0 0 16px;
    color: var(--mbi-accent) !important;
    font-size: 12px !important;
    font-weight: 700;
    letter-spacing: 2.5px !important;
    text-transform: uppercase !important;
}

.mbi-names {
    font-family: 'Marcellus', serif;
    font-size: clamp(38px, 8vw, 62px);
    font-weight: 400;
    line-height: 1.08;
    color: var(--mbi-primary);
    margin: 12px 0 14px;
}

.mabrook-invitation.is-rtl .mbi-names {
    font-family: 'Amiri', serif;
    line-height: 1.3;
}

.mabrook-rsvp .mbi-names,
.mabrook-media-page .mbi-names {
    font-size: clamp(27px, 5vw, 39px);
    margin: 0 0 8px;
}

.mabrook-gallery-card .mbi-names { font-size: clamp(30px, 6vw, 50px); }

.mbi-families {
    font-size: 15px;
    color: var(--mbi-muted);
    margin: 0 0 18px;
}

.mbi-message {
    max-width: 400px;
    margin: 0 auto 8px;
    font-family: 'Marcellus', serif;
    font-size: 16px;
    line-height: 1.8;
    color: var(--mbi-muted);
}

.mabrook-invitation.is-rtl .mbi-message { font-family: 'Amiri', serif; }

.mabrook-rsvp .mbi-message,
.mabrook-media-page .mbi-message {
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    max-width: 420px;
}

.mabrook-rsvp.is-rtl .mbi-message,
.mabrook-media-page.is-rtl .mbi-message { font-family: 'Amiri', serif; }

.mbi-divider { margin: 26px 0; }

.mbi-divider span {
    display: inline-block;
    width: 40px;
    height: 1px;
    background: var(--mbi-line);
}

/* Date band: hairlines above and below, display type between them. */
.mbi-date {
    font-family: 'Marcellus', serif;
    font-size: clamp(21px, 4vw, 27px);
    line-height: 1.3;
    color: var(--mbi-primary);
    max-width: 360px;
    margin: 28px auto 0;
    padding-block: 16px 4px;
    border-block-start: 1px solid var(--mbi-line);
}

.mabrook-invitation.is-rtl .mbi-date { font-family: 'Amiri', serif; }

.mbi-time {
    font-size: 15px;
    color: var(--mbi-text);
    max-width: 360px;
    margin: 0 auto 24px;
    padding-block-end: 16px;
    border-block-end: 1px solid var(--mbi-line);
}

.mabrook-rsvp .mbi-date {
    font-size: 14px;
    max-width: none;
    margin: 0 0 6px;
    padding: 0;
    border: 0;
    color: var(--mbi-muted);
    letter-spacing: .4px;
}

.mbi-venue {
    font-size: 16px;
    font-weight: 500;
    color: var(--mbi-primary);
    margin: 0 0 4px;
}

.mbi-address {
    font-size: 14px;
    line-height: 1.7;
    color: var(--mbi-muted);
    max-width: 380px;
    margin: 0 auto 14px;
}

/* Dress code, RSVP deadline: the invite-note pattern (label over value). */
.mbi-detail {
    font-size: 14px;
    color: var(--mbi-text);
    max-width: 420px;
    margin: 20px auto 0;
}

.mbi-detail span {
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--mbi-muted);
    margin-block-end: 4px;
}

/* --------------------------------------------------------------------------
   Optional content sections
   -------------------------------------------------------------------------- */

.mbi-section {
    margin: 32px auto 0;
    padding-block-start: 24px;
    border-block-start: 1px solid var(--mbi-line);
}

.mbi-section h2 {
    font-family: 'Marcellus', serif;
    font-size: 18px;
    font-weight: 400;
    letter-spacing: 1px;
    color: var(--mbi-primary);
    margin: 0 0 10px;
}

.mabrook-invitation.is-rtl .mbi-section h2 {
    font-family: 'Amiri', serif;
    letter-spacing: 0;
}

.mbi-section p {
    font-size: 14px;
    line-height: 1.8;
    color: var(--mbi-text);
    margin: 0;
}

.mbi-schedule {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 340px;
    margin: 0 auto;
}

.mbi-schedule-item {
    display: flex;
    align-items: baseline;
    gap: 16px;
    text-align: start;
}

.mbi-schedule-time {
    flex: 0 0 84px;
    font-family: 'Marcellus', serif;
    font-size: 13px;
    letter-spacing: 1px;
    color: var(--mbi-accent);
}

.mabrook-invitation.is-rtl .mbi-schedule-time {
    font-family: 'Amiri', serif;
    letter-spacing: 0;
}

.mbi-schedule-label {
    font-size: 14px;
    line-height: 1.7;
    color: var(--mbi-text);
}

.mbi-hosts {
    margin: 30px 0 0;
    font-size: 14px;
    color: var(--mbi-muted);
}

.mbi-contact {
    font-size: 13px;
    color: var(--mbi-muted);
    margin: 6px 0 0;
}

/* --------------------------------------------------------------------------
   Links and actions. Doubled selectors + !important out-rank the pill
   styling that mabrook-reset.css still enforces on .mbi-map / .mbi-cal-btn.
   -------------------------------------------------------------------------- */

.mabrook-invitation.mabrook-invitation .mbi-map {
    display: inline-block;
    color: var(--mbi-primary) !important;
    background: transparent !important;
    border: 0 !important;
    border-block-end: 1px solid var(--mbi-accent) !important;
    border-radius: 0 !important;
    padding: 2px 1px;
    font-size: 14px;
    font-weight: 650;
    letter-spacing: .3px;
    text-decoration: none;
    margin: 2px 0 8px;
}

.mabrook-invitation.mabrook-invitation .mbi-map:hover {
    background: transparent !important;
    color: var(--mbi-primary) !important;
    border-block-end-color: var(--mbi-text) !important;
}

.mbi-calendar-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    margin: 20px 0 0;
}

.mabrook-invitation.mabrook-invitation .mbi-cal-btn {
    display: inline-block;
    color: var(--mbi-primary) !important;
    background: transparent !important;
    border: 0 !important;
    border-block-end: 1px solid var(--mbi-line) !important;
    border-radius: 0 !important;
    padding: 2px 1px !important;
    font-size: 13px !important;
    font-weight: 650;
    letter-spacing: .3px;
    text-decoration: none;
}

.mabrook-invitation.mabrook-invitation .mbi-cal-btn:hover {
    color: var(--mbi-primary) !important;
    border-block-end-color: var(--mbi-accent) !important;
}

/* Primary action: the prototype button, themed. */
.mabrook-invitation.mabrook-invitation .mbi-rsvp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    background: var(--mbi-primary);
    color: var(--mbi-bg);
    border: 1px solid var(--mbi-primary);
    border-radius: 9px;
    padding: 12px 32px;
    font-size: 15px;
    font-weight: 650;
    letter-spacing: .3px;
    text-transform: none;
    text-decoration: none;
    margin: 26px 0 4px;
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 120ms ease;
}

.mabrook-invitation.mabrook-invitation .mbi-rsvp-btn:hover {
    background: var(--mbi-accent);
    border-color: var(--mbi-accent);
    color: var(--mbi-surface);
}

.mabrook-invitation.mabrook-invitation .mbi-rsvp-btn:active { transform: scale(.98); }

/* --------------------------------------------------------------------------
   Branding footer (white-label hides the whole block from PHP)
   -------------------------------------------------------------------------- */

.mbi-brand {
    text-align: center;
    margin: 28px 0 0;
    color: var(--mbi-muted);
}

.mbi-monogram {
    width: 42px;
    height: 42px;
    color: var(--mbi-muted);
}

.mbi-logo {
    max-height: 42px;
    max-width: 150px;
    opacity: .82;
}

/* --------------------------------------------------------------------------
   RSVP form
   -------------------------------------------------------------------------- */

.mabrook-rsvp .mbr-form {
    text-align: start;
    margin-block-start: 22px;
}

.mbr-alert { text-align: center; margin-block-start: 16px; }

/* Attend / decline choice */
.mbr-choice-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
    margin: 4px 0 22px;
}

.mbr-choice {
    display: block;
    margin: 0;
    cursor: pointer;
}

.mbr-choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.mbr-choice span {
    min-height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 14px;
    font-size: 15px;
    font-weight: 500;
    color: var(--mbi-text);
    background: var(--mbi-bg);
    border: 1px solid var(--mbi-line);
    transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.mbr-choice input:checked + span {
    color: var(--mbi-primary);
    background: var(--mbi-surface);
    border-color: var(--mbi-primary);
    box-shadow: inset 0 0 0 1px var(--mbi-primary);
    font-weight: 650;
}

.mbr-choice input:focus-visible + span {
    outline: 2px solid var(--mbi-accent);
    outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
    .mbr-choice:hover span { border-color: var(--mbi-primary); }
}

.mbi-section-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    color: var(--mbi-muted);
    margin: 0 0 12px;
}

.mabrook-rsvp.is-rtl .mbi-section-title {
    letter-spacing: 0;
    text-transform: none;
    font-size: 14px;
}

/* Guest attendance rows */
.mbr-guests {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-block-end: 14px;
}

.mbr-guest {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 12px;
    font-size: 14px;
    color: var(--mbi-text);
    background: var(--mbi-bg);
    border: 1px solid var(--mbi-line);
    cursor: pointer;
    margin: 0 0 8px;
    transition: border-color 150ms ease;
}

.mbr-guests .mbr-guest { margin: 0; }

@media (hover: hover) and (pointer: fine) {
    .mbr-guest:hover { border-color: var(--mbi-primary); }
}

.mabrook-invitation.mabrook-invitation .mbr-guest input {
    width: 18px !important;
    height: 18px !important;
    accent-color: var(--mbi-primary) !important;
}

/* Fields */
.mbr-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
    font-weight: 650;
    color: var(--mbi-text);
    margin: 14px 0;
}

/* Out-rank the input lockdown in mabrook-reset.css (14px, min-height 0,
   surface background). Padding is left to the reset so the select arrow
   clearance survives. */
.mabrook-invitation.mabrook-invitation .mbr-field input,
.mabrook-invitation.mabrook-invitation .mbr-field select,
.mabrook-invitation.mabrook-invitation .mbr-field textarea {
    width: 100%;
    min-height: 46px !important;
    font-size: 16px !important;
    font-weight: 400;
    background-color: var(--mbi-bg) !important;
}

.mabrook-invitation.mabrook-invitation .mbr-field input:focus,
.mabrook-invitation.mabrook-invitation .mbr-field select:focus,
.mabrook-invitation.mabrook-invitation .mbr-field textarea:focus {
    background-color: var(--mbi-surface) !important;
}

.mbr-multi {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-weight: 400;
}

.mbr-multi .mbr-guest { margin: 0; }

/* Submit: colour, radius, and width are already locked to the right values
   by mabrook-reset.css; this fills in the rest of the prototype button. */
.mbr-submit {
    display: block;
    width: 100%;
    min-height: 48px;
    background: var(--mbi-primary);
    color: var(--mbi-bg);
    border: 1px solid var(--mbi-primary);
    border-radius: 9px;
    padding: 14px 20px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 650;
    letter-spacing: .3px;
    cursor: pointer;
    margin-block-start: 14px;
}

.mbr-submit:hover {
    background: var(--mbi-accent);
    border-color: var(--mbi-accent);
    color: var(--mbi-surface);
}

.mbr-submit:active { transform: scale(.99); }

/* --------------------------------------------------------------------------
   Lookup card ("find my invitation"): lives inside .mabrook-portal-wrap,
   so it needs the four-class stack to out-rank both mabrook-portal.css
   and mabrook-reset.css input rules.
   -------------------------------------------------------------------------- */

.mabrook-portal-wrap.mabrook-portal-wrap .mabrook-auth-card input.mabrook-code-input {
    min-height: 64px !important;
    padding: 10px !important;
    text-align: center;
    font-size: 26px !important;
    font-weight: 700;
    letter-spacing: 10px;
    text-transform: uppercase;
    color: var(--mb-wine, #7e2647) !important;
    border-radius: 0 !important;
}

.mabrook-portal-wrap.mabrook-portal-wrap .mabrook-auth-card input.mabrook-code-input::placeholder {
    color: var(--mb-line-strong, #d9cec4);
    font-weight: 400;
}

/* --------------------------------------------------------------------------
   Media pages: upload (wide, start-aligned) and gallery (wide, centered)
   -------------------------------------------------------------------------- */

.mabrook-media-page .mbi-card {
    max-width: 720px;
    text-align: start;
}

.mabrook-media-page .mbi-ornament { margin-inline: 0; }

.mabrook-media-page .mbi-message {
    margin-inline: 0;
    max-width: 560px;
}

.mabrook-media-page .mbr-alert { text-align: start; }
.mabrook-media-page .mbi-calendar-row { justify-content: flex-start; }
.mabrook-media-page .mbi-brand { text-align: center; }

/* The file input becomes the drop zone. Four-class + attribute specificity
   out-ranks the fixed-palette rule in mabrook-portal.css. */
.mabrook-invitation.mabrook-invitation .mabrook-media-form input[type="file"] {
    display: block;
    width: 100%;
    min-height: 170px !important;
    padding: 24px 18px !important;
    color: var(--mbi-muted) !important;
    background-color: var(--mbi-bg) !important;
    border: 1px dashed var(--mbi-primary) !important;
    border-radius: 0 !important;
    font-size: 13px !important;
    cursor: pointer;
    transition: border-color 150ms ease, background-color 150ms ease;
}

.mabrook-invitation.mabrook-invitation .mabrook-media-form input[type="file"]:hover {
    border-color: var(--mbi-accent) !important;
}

.mbr-dropzone { margin-block-start: 20px; }

.mabrook-invitation .mabrook-lead {
    margin: 0 0 6px;
    color: var(--mbi-muted);
    font-size: 13px;
    line-height: 1.6;
    max-width: none;
}

/* Gallery: the grid itself comes from mabrook-portal.css; retint the tiles
   with the event theme and centre the intro. */
.mabrook-media-page .mbi-card.mabrook-gallery-card {
    max-width: 940px;
    text-align: center;
}

.mabrook-gallery-card .mbi-ornament { margin-inline: auto; }
.mabrook-gallery-card .mbi-message { margin-inline: auto; }
.mabrook-gallery-card .mbi-calendar-row { justify-content: center; }

.mabrook-invitation .mabrook-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px;
    margin: 26px 0;
}

.mabrook-invitation .mabrook-gallery-item {
    background: var(--mbi-bg);
    border: 1px solid var(--mbi-line);
    overflow: hidden;
    margin: 0;
}

.mabrook-invitation .mabrook-gallery-item img,
.mabrook-invitation .mabrook-gallery-item video {
    width: 100%;
    height: 170px;
    object-fit: cover;
    display: block;
    background: var(--mbi-text);
}

.mabrook-invitation .mabrook-gallery-item figcaption {
    padding: 7px 10px;
    font-size: 12px;
    color: var(--mbi-muted);
    text-align: center;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (min-width: 40rem) {
    .mbi-card { padding: 68px 50px 48px; }
    .mabrook-rsvp .mbi-card,
    .mabrook-media-page .mbi-card { padding: 40px; }
    .mbr-choice-row { grid-template-columns: repeat(2, 1fr); }
    .mabrook-invitation .mabrook-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    }
}

@media (max-width: 30rem) {
    .mabrook-invitation { padding: 40px 12px 60px; }
    .mbi-card { padding: 46px 20px 34px; }
    .mabrook-rsvp .mbi-card,
    .mabrook-media-page .mbi-card { padding: 26px 16px; }
    .mbi-names { font-size: clamp(30px, 9vw, 38px); }
}

@media (prefers-reduced-motion: reduce) {
    .mabrook-invitation *,
    .mabrook-invitation *::before,
    .mabrook-invitation *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* --------------------------------------------------------------------------
   Invitation opening animations (client-selected per event).
   Envelope artwork adapted from Twemoji (Copyright Twitter, CC BY 4.0).
   Colors follow the event theme through the --mbi-* variables.
   -------------------------------------------------------------------------- */

@keyframes mbiRevealIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.mbi-reveal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    overflow: hidden;
    cursor: pointer;
    transition: opacity .45s ease;
}
.mbi-reveal.is-done { opacity: 0; pointer-events: none; }

/* Envelope */
.mbi-reveal-envelope { background: var(--mbi-bg); display: grid; place-items: center; }
.mbi-env {
    position: relative;
    width: min(86vw, 420px);
    height: min(86vw, 420px);
    perspective: 1100px;
    filter: drop-shadow(0 20px 34px rgba(0, 0, 0, .28));
    animation: mbiEnvRide 4.6s cubic-bezier(.23, 1, .32, 1) forwards;
}
.mbi-env-inner {
    position: absolute;
    left: 2px;
    right: 2px;
    top: 13.9%;
    height: 71%;
    background: var(--mbi-primary);
    background: color-mix(in srgb, var(--mbi-primary), black 45%);
    border-radius: 9%;
}
.mbi-env-base, .mbi-env-flap {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}
.mbi-env-body { fill: var(--mbi-primary); stroke: var(--mbi-accent); stroke-width: .4; }
.mbi-env-crease { fill: var(--mbi-accent); opacity: .45; }
.mbi-env-flap { transform-origin: 50% 13.9%; animation: mbiEnvFlap 4.6s cubic-bezier(.23, 1, .32, 1) forwards; }
.mbi-env-trim { fill: var(--mbi-accent); }
.mbi-env-face { fill: var(--mbi-primary); fill: color-mix(in srgb, var(--mbi-primary), white 12%); }
.mbi-env-seal {
    position: absolute;
    top: 68%;
    left: 50%;
    width: 15%;
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    display: grid;
    place-items: center;
    color: var(--mbi-primary);
    background: var(--mbi-accent);
    background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--mbi-accent), white 25%) 0%, var(--mbi-accent) 55%, color-mix(in srgb, var(--mbi-accent), black 25%) 100%);
    border-radius: 50%;
    font-family: 'Marcellus', serif;
    font-size: clamp(18px, 6vw, 30px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, .35), inset 0 0 0 3px rgba(0, 0, 0, .12);
    animation: mbiEnvSeal 4.6s cubic-bezier(.23, 1, .32, 1) forwards;
}
.mbi-env-paper {
    position: absolute;
    left: 19%;
    bottom: 16%;
    width: 62%;
    height: 58%;
    z-index: 0;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 9%;
    padding: 8%;
    background: var(--mbi-surface);
    border: 1px solid var(--mbi-line);
    border-radius: 2%;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
    animation: mbiEnvPaper 4.6s cubic-bezier(.23, 1, .32, 1) forwards;
}
.mbi-env-paper span {
    display: block;
    width: 70%;
    height: 2px;
    background: var(--mbi-line);
}
.mbi-env-paper span:first-child {
    width: 26%;
    height: 3px;
    background: var(--mbi-accent);
}
.mbi-env-inner { z-index: -1; }
.mbi-env-base, .mbi-env-flap { z-index: 1; }
.mbi-env-seal { z-index: 2; }
@keyframes mbiEnvPaper {
    0%, 48% { transform: translateY(0); }
    78%, 100% { transform: translateY(-130%); }
}
@keyframes mbiEnvSeal {
    0%, 14% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; }
    19% { transform: translate(-50%, -50%) scale(1.12) rotate(-6deg); }
    24% { transform: translate(-50%, -50%) scale(1.08) rotate(5deg); }
    32%, 100% { transform: translate(-50%, -50%) scale(.4) rotate(14deg); opacity: 0; }
}
@keyframes mbiEnvFlap {
    0%, 26% { transform: rotateX(0); }
    58%, 100% { transform: rotateX(-178deg); }
}
@keyframes mbiEnvRide {
    0%, 74% { transform: scale(1) translateY(0); opacity: 1; }
    100% { transform: scale(2.4) translateY(26%); opacity: 0; }
}

/* Gates */
.mbi-reveal-gates { perspective: 1400px; }
.mbi-gate {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50.5%;
    background: var(--mbi-primary);
    background: linear-gradient(115deg, color-mix(in srgb, var(--mbi-primary), black 30%) 0%, var(--mbi-primary) 60%, color-mix(in srgb, var(--mbi-primary), white 8%) 100%);
}
.mbi-gate-l { left: 0; transform-origin: left center; border-right: 1px solid var(--mbi-accent); animation: mbiGateL 3.2s .5s cubic-bezier(.23, 1, .32, 1) forwards; }
.mbi-gate-r { right: 0; transform-origin: right center; border-left: 1px solid var(--mbi-accent); animation: mbiGateR 3.2s .5s cubic-bezier(.23, 1, .32, 1) forwards; }
.mbi-gate-mono {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 84px;
    height: 84px;
    transform: translate(-50%, -50%);
    display: grid;
    place-items: center;
    color: var(--mbi-accent);
    border: 1px solid var(--mbi-accent);
    border-radius: 50%;
    font-family: 'Marcellus', serif;
    font-size: 34px;
    animation: mbiGateMono 1s .3s ease forwards;
}
@keyframes mbiGateMono { to { opacity: 0; transform: translate(-50%, -50%) scale(.8); } }
@keyframes mbiGateL { to { transform: rotateY(-108deg); } }
@keyframes mbiGateR { to { transform: rotateY(108deg); } }

/* Greeting card: the cover opens straight onto the real invitation */
.mbi-reveal-card {
    display: grid;
    place-items: center;
}
.mbi-reveal-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--mbi-bg);
    animation: mbiCardBg 3s cubic-bezier(.23, 1, .32, 1) forwards;
}
.mbi-book {
    position: relative;
    width: min(78vw, 340px);
    aspect-ratio: 3 / 4;
    perspective: 1400px;
}
.mbi-book-cover {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 16px;
    text-align: center;
    background: var(--mbi-primary);
    background: radial-gradient(120% 120% at 50% 0%, color-mix(in srgb, var(--mbi-primary), white 10%) 0%, color-mix(in srgb, var(--mbi-primary), black 25%) 75%);
    border: 1px solid var(--mbi-accent);
    box-shadow: 0 20px 34px rgba(0, 0, 0, .25);
    transform-origin: left center;
    backface-visibility: hidden;
    animation: mbiCoverOpen 3s cubic-bezier(.23, 1, .32, 1) forwards;
}
.mbi-cover-mono {
    width: 84px;
    height: 84px;
    display: grid;
    place-items: center;
    color: var(--mbi-accent);
    border: 1px solid var(--mbi-accent);
    border-radius: 50%;
    font-family: 'Marcellus', serif;
    font-size: 36px;
}
.mabrook-invitation .mbi-cover-img { display: block; width: 74px; height: auto; }
.mbi-cover-line {
    color: var(--mbi-accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
}
@keyframes mbiCoverOpen {
    0%, 20% { transform: rotateY(0); opacity: 1; }
    68% { transform: rotateY(-150deg); opacity: 1; }
    100% { transform: rotateY(-150deg); opacity: 0; }
}
@keyframes mbiCardBg {
    0%, 26% { opacity: 1; }
    66%, 100% { opacity: 0; }
}

/* Wax seal letter */
.mbi-fold {
    position: absolute;
    left: 0;
    right: 0;
    height: 50.2%;
    background: var(--mbi-surface);
    background: linear-gradient(180deg, var(--mbi-surface) 0%, color-mix(in srgb, var(--mbi-surface), var(--mbi-primary) 8%) 100%);
    border: 1px solid var(--mbi-line);
}
.mbi-fold-top { top: 0; transform-origin: top center; animation: mbiFoldTop 3.8s cubic-bezier(.23, 1, .32, 1) forwards; }
.mbi-fold-bottom { bottom: 0; transform-origin: bottom center; animation: mbiFoldBottom 3.8s cubic-bezier(.23, 1, .32, 1) forwards; }
.mbi-wax {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 84px;
    height: 84px;
    transform: translate(-50%, -50%);
    display: grid;
    place-items: center;
    color: var(--mbi-surface);
    background: var(--mbi-primary);
    background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--mbi-primary), white 22%) 0%, var(--mbi-primary) 55%, color-mix(in srgb, var(--mbi-primary), black 30%) 100%);
    border-radius: 50%;
    font-family: 'Marcellus', serif;
    font-size: 32px;
    box-shadow: 0 5px 14px rgba(0, 0, 0, .35), inset 0 0 0 3px rgba(0, 0, 0, .15);
    animation: mbiWax 3.8s cubic-bezier(.23, 1, .32, 1) forwards;
}
@keyframes mbiWax {
    0%, 16% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; }
    26% { transform: translate(-50%, -50%) scale(1.15) rotate(-7deg); }
    34% { transform: translate(-50%, -50%) scale(1.1) rotate(6deg); }
    48%, 100% { transform: translate(-50%, -55%) scale(.3) rotate(20deg); opacity: 0; }
}
@keyframes mbiFoldTop {
    0%, 30% { transform: perspective(1200px) rotateX(0); opacity: 1; }
    78%, 100% { transform: perspective(1200px) rotateX(155deg); opacity: 0; }
}
@keyframes mbiFoldBottom {
    0%, 30% { transform: perspective(1200px) rotateX(0); opacity: 1; }
    78%, 100% { transform: perspective(1200px) rotateX(-155deg); opacity: 0; }
}

/* Silk curtains */
.mbi-curtain {
    position: absolute;
    top: -2%;
    bottom: -2%;
    width: 56%;
}
.mbi-curtain-l {
    left: -3%;
    background: repeating-linear-gradient(90deg, var(--mbi-primary) 0 18px, var(--mbi-primary) 18px 42px);
    background: repeating-linear-gradient(90deg, color-mix(in srgb, var(--mbi-primary), black 25%) 0 18px, var(--mbi-primary) 18px 42px);
    border-right: 3px solid var(--mbi-accent);
    animation: mbiCurL 2.8s .4s cubic-bezier(.23, 1, .32, 1) forwards;
}
.mbi-curtain-r {
    right: -3%;
    background: repeating-linear-gradient(90deg, var(--mbi-primary) 0 24px, var(--mbi-primary) 24px 42px);
    background: repeating-linear-gradient(90deg, var(--mbi-primary) 0 24px, color-mix(in srgb, var(--mbi-primary), black 25%) 24px 42px);
    border-left: 3px solid var(--mbi-accent);
    animation: mbiCurR 2.8s .4s cubic-bezier(.23, 1, .32, 1) forwards;
}
@keyframes mbiCurL {
    60% { transform: translateX(-86%) skewX(3deg) scaleX(.62); }
    100% { transform: translateX(-108%) skewX(0) scaleX(.6); }
}
@keyframes mbiCurR {
    60% { transform: translateX(86%) skewX(-3deg) scaleX(.62); }
    100% { transform: translateX(108%) skewX(0) scaleX(.6); }
}

/* Golden shimmer, applied to the invitation card itself */
.mbi-reveal-mode-shimmer .mbi-card { position: relative; overflow: hidden; }
.mbi-reveal-mode-shimmer .mbi-card > * {
    opacity: 0;
    transform: translateY(14px);
    animation: mbiRevealIn .9s cubic-bezier(.23, 1, .32, 1) forwards;
}
.mbi-reveal-mode-shimmer .mbi-card > *:nth-child(1) { animation-delay: .15s; }
.mbi-reveal-mode-shimmer .mbi-card > *:nth-child(2) { animation-delay: .3s; }
.mbi-reveal-mode-shimmer .mbi-card > *:nth-child(3) { animation-delay: .45s; }
.mbi-reveal-mode-shimmer .mbi-card > *:nth-child(4) { animation-delay: .6s; }
.mbi-reveal-mode-shimmer .mbi-card > *:nth-child(5) { animation-delay: .75s; }
.mbi-reveal-mode-shimmer .mbi-card > *:nth-child(6) { animation-delay: .9s; }
.mbi-reveal-mode-shimmer .mbi-card > *:nth-child(7) { animation-delay: 1.05s; }
.mbi-reveal-mode-shimmer .mbi-card > *:nth-child(8) { animation-delay: 1.2s; }
.mbi-reveal-mode-shimmer .mbi-card > *:nth-child(9) { animation-delay: 1.35s; }
.mbi-reveal-mode-shimmer .mbi-card > *:nth-child(10) { animation-delay: 1.5s; }
.mbi-reveal-mode-shimmer .mbi-card > *:nth-child(n+11) { animation-delay: 1.65s; }
.mbi-reveal-mode-shimmer .mbi-card::after {
    content: "";
    position: absolute;
    inset: -30% -60%;
    background: linear-gradient(115deg, transparent 40%, color-mix(in srgb, var(--mbi-accent), transparent 55%) 50%, transparent 60%);
    transform: translateX(-130%);
    animation: mbiSweep 1.5s 1.9s ease-in-out forwards;
    pointer-events: none;
}
@keyframes mbiSweep { to { transform: translateX(130%); } }

.mbi-lang-toggle {
    position: fixed;
    top: 14px;
    inset-inline-end: 14px;
    z-index: 500;
    display: inline-flex;
    align-items: center;
    width: auto;
    min-height: 38px;
    margin: 0;
    padding: 6px 16px;
    color: var(--mbi-primary);
    background: var(--mbi-surface);
    border: 1px solid var(--mbi-line);
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .12);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}
.mbi-lang-toggle:hover { border-color: var(--mbi-accent); }

.mabrook-invitation .mbi-mark {
    display: block;
    width: 46px;
    height: auto;
    margin: 0 auto 26px;
}
.mabrook-invitation .mbi-wordmark {
    display: block;
    width: 112px;
    height: auto;
    margin: 30px auto 0;
    opacity: .9;
}
.mabrook-invitation .mbi-wax-img { display: block; width: 40px; height: auto; }
.mabrook-invitation.is-rtl .mbi-kicker,
.mabrook-invitation.is-rtl .mbi-families,
.mabrook-invitation.is-rtl .mbi-venue,
.mabrook-invitation.is-rtl .mbi-address,
.mabrook-invitation.is-rtl .mbi-detail,
.mabrook-invitation.is-rtl .mbi-hosts,
.mabrook-invitation.is-rtl .mbi-contact { font-family: 'Amiri', serif; letter-spacing: 0; }
.mabrook-invitation.is-rtl bdi[dir="ltr"] { unicode-bidi: isolate; }

@media (prefers-reduced-motion: reduce) {
    .mbi-reveal { display: none; }
    .mbi-reveal-mode-shimmer .mbi-card > * { animation: none; opacity: 1; transform: none; }
    .mbi-reveal-mode-shimmer .mbi-card::after { animation: none; }
}
