/* =========================================
   Variables & Theming
   ========================================= */
:root {
    /* Colors */
    --clr-bg: #FCF9F6; 
    --clr-primary: #5A1E2B; 
    --clr-secondary: #D4A373; 
    --clr-accent: #E8D0D3; 
    --clr-text-main: #333333;
    --clr-text-light: #666666;
    
    /* Richer Gold Gradient for better contrast on light backgrounds */
    --gold-grad: linear-gradient(to right, #A67C00, #BF953F, #735000, #BF953F, #8B6508);
    
    /* Fonts */
    --font-serif: 'Cormorant Garamond', serif;
    --font-script: 'Great Vibes', cursive;
    
    /* Timing & Animation */
    --transition-speed: 0.3s;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    background-color: #000; /* Dark outside to make it pop */
    color: var(--clr-text-main);
    font-family: var(--font-serif);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

/* Utility */
.hidden {
    display: none !important;
}

/* =========================================
   Layout
   ========================================= */
main {
    max-width: 500px;
    margin: 0 auto;
    background-color: var(--clr-bg);
    box-shadow: 0 0 40px rgba(255, 255, 255, 0.1);
    height: 100vh;
    /* dvh tracks the real, current visible viewport as mobile Safari/Chrome's
       address bar collapses on scroll, instead of a snapshot taken once (vh).
       Plain vh is a fallback for older browsers - cascade means it's simply
       overridden below on anything that understands dvh. Without this, each
       section's fixed vh height falls out of sync with the actually-visible
       viewport mid-scroll (only noticeable scrolling down, since that's the
       direction that collapses the toolbar), forcing a corrective re-snap
       that reads as a rough bounce-back. */
    height: 100dvh;
    position: relative;
    overflow-y: scroll;
    overflow-x: hidden;
    scroll-snap-type: y mandatory;
    /* No scroll-behavior:smooth here on purpose - on touch devices it fights
       the browser's own momentum/snap physics (two different easing curves
       trying to animate the same scroll at once), which is what was causing
       the rough, double-animated bounce-back past a section boundary. The
       native snap engine already has well-tuned physics for this; letting
       it run alone is smoother than layering CSS smoothing on top of it. */
    overscroll-behavior-y: contain;
}

section {
    scroll-snap-align: start;
    /* Without this, a fast flick on iOS Safari can carry momentum PAST the
       very next section before scroll-snap-type:mandatory corrects it back -
       that correction is what reads as an abrupt "overshoot then bounce
       back". This forces the browser to stop at each section instead of
       letting a fling skip through it, so there's nothing left to correct. */
    scroll-snap-stop: always;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    position: relative;
    text-align: center;
    background-color: var(--clr-bg);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Scrolling lives on this inner wrapper, clipped well inside the floral
   border artwork's irregular (arch-shaped) frame - so tall content is
   hidden before it ever reaches the florals, instead of visibly scrolling
   underneath/through them. Generous default for sections whose text sits
   directly on the border image with no opaque card behind it; .location
   below gets its own smaller inset since its venue cards are opaque white
   and its content was already tuned to fit without scrolling. */
.section-scroll {
    position: absolute;
    /* The redesigned border art uses a pointed arch, which peaks higher at
       center than the previous rounded-oval frames did - 25% left text
       crossing the arch outline, so this needed to go up again even after
       trimming content to compensate. */
    top: 28%; left: 11%; right: 11%; bottom: 24%;
    overflow-y: auto;
    padding: 0.5rem 0.4rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* "safe" falls back to start-alignment exactly when centering would
       push content out of scrollable reach - without it, a card taller
       than its box can leave its top portion permanently unscrollable-to,
       since centered overflow extends above the container's reachable
       scroll origin. No visual change for cards that already fit. */
    justify-content: safe center;
    align-items: center;
}

/* Text Gradients */
.text-gold {
    background: var(--gold-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0px 0px 20px rgba(212, 163, 115, 0.4);
}

.section-title {
    font-family: var(--font-script);
    font-size: 2.6rem;
    /* Extra clearance below a script font's descenders (e.g. the long
       swash on "Your") - the computed line box doesn't reach as far as
       the glyph actually renders, so a plain 1rem gap let the tail
       visually cross into the text below it. */
    margin-bottom: 2rem;
    font-weight: normal;
    background: var(--gold-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); /* Stronger dark shadow for contrast */
}

/* =========================================
   Animations (Fade & Rise)
   ========================================= */
/* Opacity-only - no transform/translateY here. That used to run its own
   1s slide-up animation on the exact same element whose scroll position
   the browser's scroll-snap is independently settling at the same moment,
   which looked exactly like a scroll overshoot-then-bounce (it wasn't -
   the scroll had already arrived, the section's own content was still
   sliding). Confirmed by it only ever happening on a section's FIRST
   reveal - once .visible is set (and nothing ever removes it), re-scrolling
   past an already-visited section triggers no animation and no "bounce". */
.section-animate {
    opacity: 0;
    transition: opacity 1s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.section-animate.visible {
    opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
    .section-animate {
        transition: none;
        opacity: 1;
    }
}

/* =========================================
   Gatefold Intro
   Two doors swing open on their outer edges (3D rotate), like a
   cabinet opening toward the viewer - not a flat side-to-side slide.
   ========================================= */
.gatefold-screen {
    position: fixed;
    top: 0; left: 0; right: 0;
    /* Match main's mobile-card width instead of stretching full browser width -
       this is what was blowing up the door photos past their native resolution
       and making them pixelated on anything wider than a phone. */
    max-width: 500px;
    margin: 0 auto;
    height: 100vh;
    height: 100dvh;
    z-index: 100;
    perspective: 1600px;
    cursor: pointer;
    transition: opacity 1s ease 1.1s, visibility 1s ease 1.1s;
}

.gatefold-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.gate {
    position: absolute;
    top: 0; width: 50%; height: 100%;
    background-color: #F2E1D6;
    background-repeat: no-repeat;
    background-size: cover;
    /* A standard, well-behaved ease-in-out curve - the previous curve's
       control points weren't monotonic in time, which produced a subtly
       jerky, uneven swing rather than a smooth one. */
    transition: transform 1.9s cubic-bezier(0.65, 0, 0.35, 1);
    transform-style: preserve-3d;
    backface-visibility: hidden;
    box-shadow: 0 0 50px rgba(0,0,0,0.15);
}

.gate-left {
    left: 0;
    transform-origin: left center;
    background-image: url('../assets/images/gatefold-left.jpg');
    background-position: right center;
    overflow: visible;
    z-index: 2;
}

/* The right half of the seal is attached directly to the left door's right
   seam edge (left: 100%). It seamlessly completes the intact oval seal when closed,
   and swings open with the left door, leaving the right door completely plain. */
.gate-seal {
    position: absolute;
    top: 50%;
    left: 100%;
    transform: translateY(-50%);
    width: calc(100dvh * (76 / 1376));
    height: calc(100dvh * (184 / 1376));
    background: url('../assets/images/gate-seal-right.png') left center / 100% 100% no-repeat;
    pointer-events: none;
    z-index: 10;
}

.gate-right {
    right: 0;
    transform-origin: right center;
    background-image: url('../assets/images/gatefold-right-plain.jpg');
    background-position: left center;
    z-index: 1;
}

.gatefold-screen.is-open .gate-left {
    transform: rotateY(-108deg);
}

.gatefold-screen.is-open .gate-right {
    transform: rotateY(108deg);
}

.tap-to-open {
    position: absolute;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-serif);
    color: var(--clr-primary);
    font-weight: 600;
    font-style: italic;
    font-size: 1.15rem;
    letter-spacing: 2px;
    text-shadow: 0 0 8px rgba(255,255,255,0.95), 0 0 16px rgba(255,255,255,0.8), 0 1px 2px rgba(255,255,255,0.9);
    z-index: 5;
    white-space: nowrap;
    animation: pulse 2s infinite;
}

.gatefold-screen.is-open .tap-to-open {
    opacity: 0;
}

/* =========================================
   Music Toggle
   ========================================= */
.music-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 50;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: var(--clr-primary);
    color: var(--clr-secondary);
    border: 1px solid var(--clr-secondary);
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3), 0 0 15px rgba(212, 163, 115, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0.7;
    transition: opacity 0.3s, transform 0.3s;
}

.music-toggle:hover {
    opacity: 1;
    transform: scale(1.05);
}

.music-toggle svg {
    width: 20px;
    height: 20px;
}

/* =========================================
   Deckled Edge (Torn Paper)
   ========================================= */
.deckled-edge {
    position: absolute;
    left: 0;
    width: 100%;
    height: 35px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 40' preserveAspectRatio='none'%3E%3Cpath d='M0,40 L0,15 L25,18 L45,10 L70,22 L95,12 L115,25 L145,5 L170,20 L195,10 L220,25 L245,15 L270,8 L295,22 L320,12 L345,28 L370,15 L395,5 L420,22 L445,10 L470,25 L495,8 L520,20 L545,12 L570,25 L595,15 L620,8 L645,22 L670,12 L695,28 L720,15 L745,5 L770,22 L795,10 L820,25 L845,8 L870,20 L895,12 L920,25 L945,15 L970,8 L995,22 L1020,12 L1045,28 L1070,15 L1095,5 L1120,22 L1145,10 L1170,25 L1195,8 L1200,15 L1200,0 L0,0 Z' fill='%23FCF9F6'/%3E%3C/svg%3E");
    background-repeat: repeat-x;
    background-size: 100% 35px;
    z-index: 10;
}

.deckled-edge.bottom {
    bottom: -15px;
    transform: rotate(180deg);
    filter: drop-shadow(0 -5px 5px rgba(0,0,0,0.04));
}

/* =========================================
   Hero Section
   ========================================= */
.hero {
    background-image: url('../assets/borders/hero-border.jpg');
}

/* hero-border.jpg's floral clusters are noticeably thinner than the
   programme-card images the default inset is sized for, and this is the
   very first thing a guest sees - give it back the extra room rather than
   relying on an inner scroll just to see the couple's names. */
.hero .section-scroll {
    top: 17%; bottom: 15%;
}

.hero-content {
    /* No background/blur card - the floral border's own ivory center is
       already clean, and a translucent white card on top of it just washed
       the artwork out into a hazy blur. */
    position: relative;
    z-index: 2;
    width: 90%;
    text-align: center;
    padding: 3rem 1.5rem;
}

.wedding-day-text {
    font-family: var(--font-script);
    font-size: 2rem;
    color: var(--clr-primary);
    margin-bottom: 0.25rem;
    text-shadow: 0 0 10px rgba(255,255,255,0.8);
}

.wedding-date {
    font-size: 1.1rem;
    letter-spacing: 3px;
    color: var(--clr-primary);
    margin-bottom: 1rem;
    font-weight: 600;
}

.couple-names {
    font-family: var(--font-script);
    font-size: 2.5rem;
    line-height: 1.1;
    margin-bottom: 0.5rem;
    color: var(--clr-primary);
    white-space: pre-wrap;
    text-shadow: 0 0 15px rgba(255,255,255,1), 0 0 25px rgba(212, 163, 115, 0.9), 0 2px 4px rgba(0,0,0,0.5); /* Highlight effect */
}

.generic-message {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--clr-text-main);
    margin-top: 1rem;
    margin-bottom: 1.5rem;
}

.scroll-indicator {
    position: relative;
    margin-top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0.8;
    animation: bounce 2s infinite;
    z-index: 2;
}

.scroll-indicator p {
    font-family: var(--font-script);
    font-size: 1.4rem;
    color: var(--clr-primary);
    margin-bottom: 5px;
    text-shadow: 0 0 5px rgba(255,255,255,0.8);
}

.chevron {
    width: 15px;
    height: 15px;
    border-right: 2px solid var(--clr-primary);
    border-bottom: 2px solid var(--clr-primary);
    transform: rotate(45deg);
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translate(-50%, 0); }
    40% { transform: translate(-50%, -10px); }
    60% { transform: translate(-50%, -5px); }
}

/* =========================================
   Blessing Section
   ========================================= */
#blessing-section {
    background-image: url('../assets/borders/blessing-border.jpg');
}

.bismillah {
    font-size: 2.4rem;
    background: var(--gold-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.75rem;
    text-shadow: 0 0 15px rgba(212, 163, 115, 0.2);
}

.blessing-text,
.invitation-text {
    font-size: 1.08rem;
    line-height: 1.38;
    color: var(--clr-primary);
    white-space: pre-line;
    font-style: italic;
}

.invitation-text {
    font-size: 1.08rem;
    font-family: var(--font-serif);
    padding: 0 0.5rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* Plain bold emphasis (e.g. "followed by dinner") - distinct from
   .highlight-name, which is for names and uses a decorative gold script
   instead of just adding weight. */
.text-bold {
    font-weight: 700;
}

/* Walima's formal invite is the single longest card on the site (Bismillah
   opener + full formal address + two names each with a relation line) -
   a small, targeted reduction here instead of shrinking every card's text
   to fit this one outlier. */
.card-walima.card-type-invitation .invitation-text {
    font-size: 1.02rem;
    line-height: 1.32;
}

.card-walima.card-type-invitation .highlight-name {
    font-size: 1.5rem;
}

/* walima-border.jpg's roses sit further into the corners than the other
   border images (rather than a full-width top/bottom garland), leaving
   more clear ivory above/below centered text - reclaiming that room here
   specifically to afford this card's larger font without re-trimming
   every other section's shared inset. */
.card-walima .section-scroll {
    top: 23%;
    bottom: 19%;
}

.highlight-name {
    font-family: var(--font-script);
    font-size: 1.6rem;
    font-style: normal;
    font-weight: 600;
    background: var(--gold-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0px 0px 20px rgba(212, 163, 115, 0.4);
}

/* Eyebrow label on "Programme" style cards (Barat, Walima programme) */
.programme-label {
    font-family: var(--font-serif);
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 3px;
    /* letter-spacing adds trailing space after the last character too, which
       isn't balanced by anything - that pulls the visible text left of true
       center. Cancel just that trailing gap so it centers correctly. */
    margin-right: -3px;
    text-transform: uppercase;
    color: var(--clr-secondary);
    margin-bottom: 0.5rem;
}

/* "With Best Compliments" block on cards that opt in via showCompliments
   (see js/main.js) - pinned to the bottom-right of the card instead of
   centered with the rest of its text, matching the physical card. */
.card-compliments {
    /* max-width stops the script font (wide per-character) from growing
       past the available column and getting clipped by the floral artwork
       at the right edge - a block element otherwise sizes to its own
       unwrapped content width here, not the flex container's. */
    max-width: 100%;
    align-self: center;
    /* Deliberately NOT margin-top:auto/pinned to the bottom edge - that
       pushed it down into the dense bottom floral corner art on the Walima
       card. Instead it flows as part of the centered content block, with
       just a gap below "followed by dinner". */
    margin-top: 1.25rem;
    text-align: center;
    font-family: var(--font-script);
    font-size: 1.05rem;
    line-height: 1.3;
    white-space: pre-line;
    background: var(--gold-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Per-event floral borders on the dynamically-generated invitation/
   programme cards (see js/main.js) - both Walima cards share one image. */
.card-ijtema { background-image: url('../assets/borders/ijtema-border.jpg'); }
.card-barat { background-image: url('../assets/borders/barat-border.jpg'); }
.card-walima { background-image: url('../assets/borders/walima-border.jpg'); }

/* =========================================
   Countdown Section
   ========================================= */
.countdown {
    background: radial-gradient(circle, rgba(232, 208, 211, 0.4) 0%, var(--clr-bg) 70%);
}

.countdown-timer {
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    gap: 6px;
    font-family: var(--font-serif);
    background: rgba(255, 255, 255, 0.6);
    padding: 1.5rem 0.5rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
    border: 1px solid rgba(212, 163, 115, 0.2);
    box-sizing: border-box;
}

.time-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 54px;
    flex-shrink: 0;
}

.time-block span {
    font-size: 2.1rem;
    background: var(--gold-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 600;
}

.time-block label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--clr-primary);
    margin-top: 5px;
}

.time-separator {
    font-size: 2.1rem;
    color: var(--clr-primary);
    line-height: 1.2;
    opacity: 0.5;
    flex-shrink: 0;
}

/* =========================================
   Schedule Section
   ========================================= */
.schedule {
    background-image: url('../assets/borders/schedule-border.jpg');
}

.timeline {
    position: relative;
    max-width: 320px;
    margin: 0 auto;
}

.timeline::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    background: var(--gold-grad);
    transform: translateX(-50%);
    opacity: 0.5;
}

.timeline-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.1rem;
    position: relative;
}

.timeline-time {
    width: 45%;
    text-align: right;
    font-weight: 600;
    color: var(--clr-primary);
    font-size: 1.05rem;
}

.timeline-node {
    width: 14px;
    height: 14px;
    background: var(--gold-grad);
    border: 3px solid var(--clr-bg);
    border-radius: 50%;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 10px rgba(212, 163, 115, 0.6);
}

.timeline-title {
    width: 45%;
    text-align: left;
    font-size: 1.05rem;
    color: var(--clr-text-main);
}

.timeline-title small {
    font-size: 0.75rem;
    white-space: nowrap;
}

/* =========================================
   Location Section
   Sized to fit all venues (up to 3) on one screen without scrolling, so
   invitees can't miss a location by not noticing they need to scroll.
   ========================================= */
.location {
    background-image: url('../assets/borders/schedule-border.jpg');
}

.location .section-scroll {
    /* Top needs to clear the hanging lanterns baked into this border image
       (they hang lower than the florals above them, down to roughly a
       third of the image height) - the venue cards are still opaque
       white, so they stay legible even sitting closer to the artwork on
       the sides/bottom, and the "Locations" title was dropped (the arch +
       lantern framing already reads as a locations/venue section) to
       recover the room this costs. */
    top: 32%; bottom: 13%; left: 13%; right: 13%;
    padding: 0.3rem 0.75rem;
}

.location .section-title {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.venue-card {
    width: 100%;
    margin-bottom: 0.2rem;
    padding: 0.25rem 0.6rem;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 6px 14px rgba(0,0,0,0.03);
    border: 1px solid rgba(232, 208, 211, 0.5);
}

.venue-card:last-child {
    margin-bottom: 0;
}

.venue-card h3 {
    font-family: var(--font-script);
    font-size: 1.1rem;
    color: var(--clr-primary);
    margin-bottom: 0.1rem;
}

.venue-card h4 {
    font-size: 0.84rem;
    margin-bottom: 0.1rem;
    color: var(--clr-text-main);
}

.venue-card p {
    color: var(--clr-text-light);
    margin-bottom: 0.25rem;
    font-size: 0.73rem;
    line-height: 1.25;
}

/* Only present on single-event editions (one venue card, more room to
   spare) - no API key needed, this is Google's plain embeddable query form. */
.venue-map {
    width: 100%;
    height: 150px;
    border: 1px solid rgba(212, 163, 115, 0.3);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.btn-map {
    display: inline-block;
    padding: 0.2rem 0.75rem;
    background: transparent;
    color: var(--clr-primary);
    text-decoration: none;
    text-transform: uppercase;
    font-size: 0.55rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    border: 1px solid var(--clr-secondary);
    border-radius: 30px;
    transition: background var(--transition-speed), color var(--transition-speed), border-color var(--transition-speed);
}

.btn-map:hover {
    background: var(--gold-grad);
    color: #fff;
    border-color: transparent;
}

/* =========================================
   Closing Section
   ========================================= */
.closing {
    background-image: url('../assets/borders/rsvp-border.jpg');
}

/* rsvp-border.jpg has continuous vertical border columns down both sides
   (unlike the corner-only floral art elsewhere), so this section needs a
   wider horizontal inset than the site default to keep text clear of them. */
.closing .section-scroll {
    left: 16%;
    right: 16%;
    padding-bottom: 1.5rem;
}
.closing-content {
    font-family: var(--font-script);
    font-size: 1.5rem;
    background: var(--gold-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: pre-line;
    line-height: 1.4;
    text-shadow: 0 0 15px rgba(212, 163, 115, 0.2);
}

