/* Critical styling for the Wedding RSVP app.
 *
 * This file is linked from the head of Streamlit's HTML shell (see scripts/inject_head.py) so it
 * applies from the very first paint, before Streamlit's JavaScript has loaded. theme.py injects the
 * same rules again at runtime as a fallback for setups where the shell was not patched.
 *
 * Never write a less-than sign anywhere in this file, even in a comment: Streamlit's HTML
 * sanitiser drops the whole style block if its text looks like it contains a tag.
 */
@font-face { font-family: 'Allison'; font-weight: 400; font-display: swap; src: url('/app/static/fonts/Allison-latin.woff2') format('woff2'); }
@font-face { font-family: 'Playfair Display'; font-weight: 400 900; font-display: swap; src: url('/app/static/fonts/PlayfairDisplay-latin.woff2') format('woff2'); }
@font-face { font-family: 'Jost'; font-weight: 100 900; font-display: swap; src: url('/app/static/fonts/Jost-latin.woff2') format('woff2'); }

:root {
    --paper: #FFFEFC;
    --sky: #C6E6FA;
    --sky-soft: #E8F4FD;
    --sky-deep: #8FC1E6;
    --navy: #3A4766;
    --navy-dark: #2B3652;
    --navy-soft: #66728F;
    --delphinium: #4A63B0;
    --lavender: #D9D3F3;
    --blush: #F8D9DE;
    --butter: #FFEFB0;
    --sunflower: #F2C94C;
    --poppy: #E8794A;
    --sage: #CFE0CB;
    --line: rgba(58, 71, 102, 0.14);
    --card: rgba(255, 255, 255, 0.86);
    --radius: 18px;
    --script: 'Allison', cursive;
    --serif: 'Playfair Display', Georgia, serif;
    --sans: 'Jost', 'Helvetica Neue', Arial, sans-serif;
}

/* ---- page ---------------------------------------------------------- */
html {
    -webkit-text-size-adjust: 100%;
    background-color: var(--paper);
    background-image:
        radial-gradient(60% 34% at 0% 0%, rgba(198, 230, 250, 0.85), transparent 70%),
        radial-gradient(50% 30% at 100% 4%, rgba(217, 211, 243, 0.7), transparent 70%),
        radial-gradient(45% 26% at 100% 46%, rgba(255, 239, 176, 0.45), transparent 70%),
        radial-gradient(55% 28% at 0% 78%, rgba(248, 217, 222, 0.55), transparent 70%),
        radial-gradient(60% 26% at 100% 100%, rgba(207, 224, 203, 0.65), transparent 70%);
    background-repeat: no-repeat;
    background-attachment: fixed;
    min-height: 100%;
}

/* Streamlit shows pale placeholder blocks while its components load, which looks like flashing
 * rectangles and half-built cards. Hide the placeholders, and hold the page content back until none
 * are left, then fade it in. The animation is a safety net: after 3s the content shows regardless,
 * so a placeholder that never resolves can't leave the page blank. */
[data-testid="stSkeleton"] { visibility: hidden; }
[data-testid="stMainBlockContainer"] { transition: opacity 0.25s ease; }
[data-testid="stMainBlockContainer"]:has([data-testid="stSkeleton"]) {
    opacity: 0;
    animation: rsvp-reveal 0.01s 3s forwards;
}
@keyframes rsvp-reveal { to { opacity: 1; } }

/* Streamlit paints its own opaque cream on body and the app wrapper; let the wash on the html element show. */
body, .stApp, [data-testid="stApp"] { background: transparent !important; }
.stApp {
    color: var(--navy);
    font-family: var(--sans);
    overflow-x: hidden;
}

[data-testid="stHeader"], [data-testid="stToolbar"], [data-testid="stDecoration"],
[data-testid="stStatusWidget"], #MainMenu, footer { display: none !important; }

.block-container, [data-testid="stMainBlockContainer"] {
    max-width: 560px;
    padding: 1.25rem 1rem 3rem !important;
}

/* Tapping controls should never trigger double-tap zoom. */
button, input, textarea, select, [role="button"], [role="tab"] { touch-action: manipulation; }

/* ---- type ---------------------------------------------------------- */
/* :where() keeps this at zero specificity so every class below wins. Material icon glyphs are skipped. */
:where(.stApp *:not([data-testid="stIconMaterial"]):not(svg):not(path)) { font-family: var(--sans); }
.stApp { font-family: var(--sans); }
h1, h2, h3, h4, .stApp h1, .stApp h2, .stApp h3 {
    font-family: var(--serif) !important;
    color: var(--navy) !important;
    font-weight: 600 !important;
}
h3, .stApp h3 { font-size: 1.5rem !important; padding: 0.25rem 0 0.1rem !important; }
h5, .stApp h5 { font-family: var(--serif) !important; color: var(--navy) !important; font-weight: 600 !important; }
.stApp p, .stApp li, .stApp label { font-size: 1rem; line-height: 1.55; }
.stApp a { color: var(--delphinium); }

/* ---- hero: the arch from the invitation ---------------------------- */
.hero {
    /* A true arch: the top corners are half the hero's width, like the sign on the invitation. */
    --arch: min(calc(50vw - 1rem), 220px);
    text-align: center; padding: calc(var(--arch) * 0.5) 1.25rem 1.2rem; margin: 0.25rem auto 1.1rem;
    max-width: 440px;
    background: linear-gradient(180deg, var(--sky) 0%, #D6EDFB 100%);
    border-radius: var(--arch) var(--arch) 24px 24px;
    box-shadow: 0 14px 34px rgba(143, 193, 230, 0.35);
}
.hero .eyebrow {
    font-family: var(--serif); font-weight: 700; font-size: 0.74rem; letter-spacing: 0.22em;
    text-transform: uppercase; color: var(--navy);
}
.hero .names {
    font-family: var(--script); font-size: clamp(3.2rem, 14.5vw, 5rem); line-height: 1.05;
    color: var(--navy); margin: 0.4rem 0 0.25rem; font-weight: 400; overflow-wrap: anywhere;
}
.hero .sub { font-family: var(--serif); font-weight: 700; font-size: 1.12rem; color: var(--navy); letter-spacing: 0.02em; }
.hero .welcome { color: var(--navy-soft); font-size: 0.97rem; margin: 0.7rem auto 0; max-width: 28rem; }
.ornament { margin: 0.9rem auto 0.1rem; font-size: 1rem; letter-spacing: 0.5rem; text-indent: 0.5rem; }
.ornament span:nth-child(1) { color: var(--sunflower); }
.ornament span:nth-child(2) { color: #8DA2E0; }
.ornament span:nth-child(3) { color: #F2A3B3; }
.ornament span:nth-child(4) { color: var(--poppy); }
.ornament span:nth-child(5) { color: #B7A7E8; }
.hero.compact { padding: 1.1rem 1rem 0.8rem; border-radius: 24px; max-width: none; }
.hero.compact .names { font-size: clamp(2.6rem, 10vw, 3.4rem); margin: 0.1rem 0 0; }

/* ---- cards --------------------------------------------------------- */
.card, [data-testid="stForm"] {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 10px 28px rgba(58, 71, 102, 0.08);
}
.card { padding: 1.1rem 1.15rem; margin: 0.5rem 0 1rem; }
[data-testid="stForm"] { padding: 1.1rem 1.15rem 1.25rem; }
.card .row { display: flex; gap: 0.75rem; padding: 0.6rem 0; border-top: 1px solid var(--line); }
.card .row:first-of-type { border-top: 0; padding-top: 0; }
.card .label {
    flex: 0 0 5.2rem; font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase;
    color: var(--navy-soft); font-weight: 500; padding-top: 0.25rem;
}
.card .value { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.card .value strong { font-family: var(--serif); font-weight: 600; font-size: 1.02rem; }
.card .value .muted { color: var(--navy-soft); font-size: 0.93rem; }

/* the rehearsal dinner details, nested inside the RSVP form: lighter than the main card */
.card.inset { background: var(--sky-soft); box-shadow: none; margin: 0.5rem 0 0.4rem; padding: 0.95rem 1rem; }
.card .desc { margin-top: 0.7rem; padding-top: 0.7rem; border-top: 1px solid var(--line); color: var(--navy-soft); font-size: 0.93rem; font-style: italic; }
.card .row:first-child + .desc { border-top: 0; margin-top: 0; padding-top: 0; }

.section-title {
    font-family: var(--serif); font-size: 1.4rem; font-weight: 600; color: var(--navy);
    margin: 1.1rem 0 0.2rem; display: flex; align-items: center; gap: 0.6rem;
}
.section-title::after { content: ""; flex: 1; height: 2px; border-radius: 2px; background: linear-gradient(90deg, var(--sky-deep), var(--lavender), transparent); }
.section-note { color: var(--navy-soft); font-size: 0.93rem; margin: 0 0 0.4rem; }
.guest-name {
    font-family: var(--serif); font-size: 1.12rem; font-weight: 600; color: var(--navy);
    margin: 0.9rem 0 0.3rem;
}

/* ---- confirmation ---------------------------------------------------- */
.confirm { text-align: center; padding: 1.5rem 1.15rem 1.25rem; }
.confirm .check {
    width: 3.4rem; height: 3.4rem; border-radius: 50%; margin: 0 auto 0.7rem;
    background: var(--sky); color: var(--navy); display: flex; align-items: center; justify-content: center;
    font-size: 1.7rem; box-shadow: 0 0 0 6px var(--sky-soft);
}
.confirm .confirm-title { font-family: var(--serif); font-weight: 700; font-size: 1.6rem; color: var(--navy); margin: 0.2rem 0 0.3rem; }
.confirm .message { color: var(--navy-soft); margin: 0 auto 1rem; max-width: 26rem; }
.summary { text-align: left; border-top: 1px solid var(--line); margin-top: 0.5rem; }
.summary .person { padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
.summary .person-name { font-family: var(--serif); font-weight: 600; font-size: 1.05rem; }
.summary .note { color: var(--navy-soft); white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 0.15rem; }
.badges { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.3rem; }
.badge {
    display: inline-block; padding: 0.15rem 0.7rem; border-radius: 999px; font-size: 0.82rem; font-weight: 500;
    border: 1px solid transparent;
}
.badge.yes { background: var(--sky); color: var(--navy-dark); }
.badge.no { background: var(--blush); color: #7A3B4B; }

/* ---- inputs (16px+ stops iOS Safari zooming in on focus) ------------ */
.stApp input, .stApp textarea, .stApp select,
.stApp [data-baseweb="input"] input, .stApp [data-baseweb="textarea"] textarea,
.stApp [data-baseweb="select"] input {
    font-size: 16px !important;
}
[data-testid="stTextInputRootElement"] { min-height: 46px; }
[data-testid="stTextInputRootElement"]:focus-within, [data-testid="stTextArea"] textarea:focus {
    box-shadow: 0 0 0 3px rgba(143, 193, 230, 0.45);
}

/* ---- buttons ------------------------------------------------------- */
.stApp .stButton > button, .stApp .stFormSubmitButton > button, .stApp .stDownloadButton > button, .stApp .stLinkButton > a {
    min-height: 48px; border-radius: 999px; font-weight: 500; font-size: 1rem;
    border: 1px solid var(--navy); letter-spacing: 0.02em;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}
.stApp button[kind="primary"], .stApp button[kind="primaryFormSubmit"] {
    background: var(--navy); color: #fff; border-color: var(--navy);
    box-shadow: 0 6px 16px rgba(58, 71, 102, 0.22);
}
.stApp button[kind="primary"]:hover, .stApp button[kind="primaryFormSubmit"]:hover {
    background: var(--navy-dark); border-color: var(--navy-dark); color: #fff;
}
.stApp button[kind="secondary"], .stApp button[kind="secondaryFormSubmit"] {
    background: rgba(255, 255, 255, 0.9); color: var(--navy); border-color: var(--sky-deep);
}
.stApp button[kind="secondary"]:hover { background: var(--sky-soft); border-color: var(--navy); color: var(--navy); }
.stApp .stButton > button[kind="tertiary"] {
    color: var(--navy-soft); min-height: 40px; background: transparent; border: 0; box-shadow: none;
    text-decoration: underline; padding-left: 0;
}

/* ---- yes/no choice ------------------------------------------------- */
[data-testid="stButtonGroup"] { width: 100%; }
[data-testid="stButtonGroup"] button {
    min-height: 46px; font-size: 1rem; flex: 1 1 0;
    border: 1px solid var(--line); background: rgba(255, 255, 255, 0.95); color: var(--navy);
}
[data-testid="stButtonGroup"] button[aria-checked="true"],
[data-testid="stButtonGroup"] button[aria-pressed="true"],
[data-testid="stButtonGroup"] button[kind="segmented_controlActive"] {
    background: var(--sky) !important; border-color: var(--navy) !important;
    color: var(--navy-dark) !important; font-weight: 600;
}

/* ---- alerts / spinner ---------------------------------------------- */
[data-testid="stAlert"], [data-testid="stNotification"] { border-radius: 14px; border: 1px solid var(--line); }
[data-testid="stAlert"] p { font-size: 0.97rem; }
[data-testid="stSpinner"] { justify-content: center; color: var(--navy-soft); }

/* ---- admin: tabs, metrics, tables ---------------------------------- */
[data-baseweb="tab-list"] { gap: 0.25rem; overflow-x: auto; }
[data-baseweb="tab"] { font-size: 1rem !important; min-height: 44px; }
[data-testid="stMetric"] {
    background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0.7rem 0.9rem;
}
[data-testid="stHorizontalBlock"]:has([data-testid="stMetric"]) { flex-direction: row !important; flex-wrap: wrap; gap: 0.6rem !important; }
[data-testid="stHorizontalBlock"]:has([data-testid="stMetric"]) > [data-testid="stColumn"] {
    flex: 1 1 calc(50% - 0.6rem) !important; min-width: calc(50% - 0.6rem) !important; width: auto !important;
}
[data-testid="stMetricLabel"] p { font-size: 0.78rem !important; text-transform: uppercase; letter-spacing: 0.1em; color: var(--navy-soft); }
[data-testid="stMetricValue"] { font-family: var(--serif); color: var(--navy); }

@media (max-width: 380px) {
    .card .label { flex-basis: 4.4rem; }
}
