/* ---------- Theme ---------- */
:root {
    --bg: #0b132b;
    --bg-deep: #060a1a;
    --panel: #141b34;
    --panel-2: #1c2547;
    --border: #243056;
    --text: #f4f6fb;
    --muted: #9aa6c5;
    --amber: #ff9f1c;
    --amber-soft: rgba(255, 159, 28, 0.18);
    --cyan: #00b4d8;
    --cyan-soft: rgba(0, 180, 216, 0.18);
    --danger: #ef476f;
    --radius: 14px;
    --shadow: 0 6px 30px rgba(0, 0, 0, 0.35);
    --glow-amber: 0 0 12px rgba(255, 159, 28, 0.55), 0 0 28px rgba(255, 159, 28, 0.25);
    --glow-cyan: 0 0 12px rgba(0, 180, 216, 0.55), 0 0 28px rgba(0, 180, 216, 0.25);
}

* { box-sizing: border-box; }

/* Fireworks canvas paints behind the gate (z-index: -1 with position:fixed
   keeps it under in-flow content but on top of the body's gradient). */
#fireworksCanvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    display: none; /* fireworks.js flips this to block on start() */
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(0, 180, 216, 0.12), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(255, 159, 28, 0.10), transparent 60%),
        var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.9rem; margin: 0 0 0.4rem; }
h2 { font-size: 1.25rem; margin: 0 0 0.8rem; }
h3 { font-size: 1rem; margin: 0 0 0.6rem; }

/* Section headers ("RSVP", "Party Chat", and the hero title) get the
   display font + amber→cyan gradient text so the whole page reads as a
   single themed surface, not just a flat form. NOTE: must be a descendant
   selector, not `.card > h2` — the h2s now live inside `.rsvp-header` /
   `.chat-header` wrappers, not as direct children of the card. */
.card h2,
.host-header h1 {
    font-family: 'Boogaloo', 'Trebuchet MS', system-ui, sans-serif;
    font-weight: 400;
    font-size: 1.7rem;
    letter-spacing: 0.02em;
    background: linear-gradient(90deg, var(--amber), var(--cyan));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.muted { color: var(--muted); }
.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.72rem;
    color: var(--amber);
    margin: 0 0 0.6rem;
}

/* ---------- Layout ---------- */
.app {
    max-width: 760px;
    margin: 0 auto;
    padding: 2rem 1.1rem 4rem;
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
}

.host-app { max-width: 1100px; }

.card {
    background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.6rem 1.4rem;
    box-shadow: var(--shadow);
}

.hero-title {
    font-family: 'Boogaloo', 'Trebuchet MS', system-ui, sans-serif;
    font-weight: 400;
    font-size: 2.8rem;
    line-height: 1.05;
    letter-spacing: 0.015em;
    background: linear-gradient(90deg, var(--amber), var(--cyan));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0 0 0.5rem;
}

.hero-tagline {
    font-family: 'Pacifico', cursive;
    font-size: 1.15rem;
    margin: 0 0 0.6rem;
    color: var(--amber);
}
.hero-desc { margin: 0 0 1.2rem; color: var(--muted); }

.meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.6rem 1.4rem;
    margin: 1rem 0 1.4rem;
}
.meta > div { border-left: 2px solid var(--amber-soft); padding-left: 0.7rem; }
.meta dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.16em; color: var(--muted); }
.meta dd { margin: 0.15rem 0 0; }

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

/* ---------- Forms ---------- */
.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 0.8rem 0;
}
.field > span { font-size: 0.86rem; color: var(--muted); }
.field .row {
    display: flex;
    gap: 0.5rem;
}
.field .row input { flex: 1; }

input[type="text"],
input[type="number"],
input[type="tel"],
input[type="password"] {
    width: 100%;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    padding: 0.7rem 0.85rem;
    font: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px var(--cyan-soft);
}

/* The potluck fieldset is its own little card-within-the-card so it reads
   as a distinct "now this part is about food" section, not flat continuation
   of the name/party-size inputs above. */
fieldset.potluck {
    border: 1px solid rgba(255, 159, 28, 0.35);
    border-radius: 14px;
    margin: 1.4rem 0 0.6rem;
    padding: 1.1rem 1.15rem 1.2rem;
    background:
        radial-gradient(420px 220px at 10% -10%, rgba(255, 159, 28, 0.10), transparent 65%),
        radial-gradient(420px 220px at 100% 110%, rgba(0, 180, 216, 0.08), transparent 65%),
        var(--panel-2);
    box-shadow: inset 0 0 14px rgba(255, 159, 28, 0.06);
}
fieldset.potluck legend {
    padding: 0.18rem 0.7rem;
    color: var(--amber);
    background: var(--panel);
    border: 1px solid rgba(255, 159, 28, 0.5);
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.92rem;
    letter-spacing: 0.02em;
}
fieldset.potluck legend::before { content: "✨ "; }
fieldset.potluck > .muted { margin: 0.2rem 0 0.8rem; }

.potluck-list {
    list-style: none;
    padding: 0;
    margin: 0.4rem 0 0.6rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.3rem 1rem;
}
.potluck-list li {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.3rem 0;
}
.potluck-list input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--amber);
}
.potluck-list li.claimed {
    color: var(--muted);
    text-decoration: line-through;
    opacity: 0.6;
}
.potluck-list li.claimed .by { font-style: italic; font-size: 0.8em; }
.potluck-list li.mine { color: var(--amber); }
.potluck-list li.write-in-mine::before { content: "✨ "; }

/* Host-set quantity hint shown next to the item name, both on the guest
   checklist and in the host's potluck list. Italic + muted so it reads
   as a side-note, not as the item label itself. */
.qty-hint {
    color: var(--cyan);
    font-style: italic;
    font-size: 0.85em;
    font-weight: 500;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.7rem 1.2rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    background: var(--panel-2);
    color: var(--text);
    transition: transform 0.08s ease, box-shadow 0.18s ease, background 0.18s ease;
    text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
    background: linear-gradient(90deg, var(--amber), #ffb454);
    color: #1a1305;
    border-color: rgba(255, 159, 28, 0.6);
}
.btn-secondary {
    background: transparent;
    border-color: var(--cyan);
    color: var(--cyan);
}
.btn-secondary:hover { box-shadow: var(--glow-cyan); }
.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}

@keyframes sparkler-pulse {
    0%, 100% { box-shadow: var(--glow-amber); }
    50%      { box-shadow: 0 0 18px rgba(255, 159, 28, 0.85), 0 0 36px rgba(255, 159, 28, 0.35); }
}
.btn-glow { animation: sparkler-pulse 2.6s ease-in-out infinite; }

/* ---------- Gate ---------- */
.gate {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 1.2rem;
    /* Soft scrim only — heavy darkening was hiding the fireworks canvas
       behind. The card's own solid panel background still provides plenty
       of contrast for the form fields. */
    background: radial-gradient(800px 400px at 50% 30%, rgba(0, 180, 216, 0.12), transparent 60%);
    backdrop-filter: blur(1.5px);
}
.gate-card {
    width: min(420px, 100%);
    background: rgba(20, 27, 52, 0.88);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 1.8rem;
    box-shadow: var(--shadow);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    backdrop-filter: blur(8px);
}
.gate-title {
    margin: 0;
    font-family: 'Boogaloo', 'Trebuchet MS', system-ui, sans-serif;
    font-size: 2.2rem;
    letter-spacing: 0.02em;
    background: linear-gradient(90deg, var(--amber), var(--cyan));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.gate-sub { color: var(--muted); margin: 0 0 0.4rem; }
.gate-error { color: var(--danger); margin: 0; font-size: 0.9rem; }
/* `.gate { display: grid }` would otherwise beat the UA `[hidden]` rule,
   so the identify stage would flash visible on first paint. */
.gate[hidden] { display: none; }

/* ---------- "Logged in as" strip on the RSVP card ---------- */
.rsvp-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.identity-line { margin: 0; font-size: 0.9rem; }
.identity-line strong { color: var(--text); font-weight: 600; }
.link-btn {
    background: none;
    border: none;
    color: var(--cyan);
    cursor: pointer;
    padding: 0 0.25rem;
    font: inherit;
    text-decoration: underline;
}
.link-btn:hover { color: var(--amber); }

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}
.chat-header h2 { margin: 0; }

.decline-line { margin: 0.7rem 0 0; text-align: center; }

/* ---------- Chat ---------- */
.chat-card { display: flex; flex-direction: column; }
.chat-stream {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.6rem 0.8rem;
    margin: 0.6rem 0 0.8rem;
    background: var(--bg-deep);
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.chat-msg {
    padding: 0.45rem 0.7rem;
    border-radius: 10px;
    background: rgba(0, 180, 216, 0.07);
    border: 1px solid var(--cyan-soft);
    animation: pop-in 0.25s ease;
}
.chat-msg.mine { background: rgba(255, 159, 28, 0.10); border-color: var(--amber-soft); }
.chat-msg .who { font-weight: 600; color: var(--amber); margin-right: 0.5rem; }
.chat-msg .when { float: right; color: var(--muted); font-size: 0.75rem; }
.chat-msg .body { display: block; word-wrap: break-word; }

@keyframes pop-in {
    from { transform: translateY(4px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

.chat-form { display: flex; gap: 0.5rem; }
.chat-form input { flex: 1; }

/* ---------- Host ---------- */
.host-header { padding: 1rem 0 0.5rem; }

.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.9rem;
}
.metric { display: flex; flex-direction: column; gap: 0.3rem; padding: 1.2rem; }
.metric-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.18em; color: var(--muted); }
.metric-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--amber);
    text-shadow: 0 0 12px rgba(255, 159, 28, 0.35);
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.4rem;
    font-size: 0.95rem;
}
.table th, .table td {
    text-align: left;
    padding: 0.55rem 0.6rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.table th { color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.72rem; }
.table tr:last-child td { border-bottom: none; }

.potluck-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.4rem;
}
@media (max-width: 640px) {
    .potluck-grid { grid-template-columns: 1fr; }
}

/* ---------- Misc ---------- */
.status {
    margin: 0.6rem 0 0;
    padding: 0.55rem 0.8rem;
    border-radius: 10px;
}
.status.ok { background: rgba(0, 180, 216, 0.12); border: 1px solid var(--cyan-soft); }
.status.err { background: rgba(239, 71, 111, 0.12); border: 1px solid rgba(239, 71, 111, 0.4); color: #ffb1c3; }

.footer { text-align: center; padding-top: 1rem; font-size: 0.85rem; }

/* ---------- Host editing controls ---------- */
.row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin: 0.6rem 0;
}
.row > input[type="text"] { flex: 1; min-width: 180px; }

.host-list {
    list-style: none;
    padding: 0;
    margin: 0.6rem 0 0;
}
.host-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.host-list li:last-child { border-bottom: none; }
.host-list .main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.host-list .main .meta-row {
    font-size: 0.78rem;
    color: var(--muted);
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.host-list .badge {
    display: inline-block;
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    font-size: 0.7rem;
    background: rgba(255, 159, 28, 0.18);
    color: var(--amber);
    border: 1px solid rgba(255, 159, 28, 0.5);
}
.host-list .actions {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.btn-mini {
    padding: 0.3rem 0.6rem;
    font-size: 0.78rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-deep);
    color: var(--text);
    cursor: pointer;
}
.btn-mini:hover { border-color: var(--cyan); color: var(--cyan); }
.btn-mini.danger:hover { border-color: var(--danger); color: #ffb1c3; }

.btn-danger {
    background: rgba(239, 71, 111, 0.15);
    border: 1px solid var(--danger);
    color: #ffb1c3;
}
.btn-danger:hover { background: rgba(239, 71, 111, 0.28); }

.danger-zone { border-color: rgba(239, 71, 111, 0.45); }
.danger-row { gap: 0.6rem; }
@media (max-width: 520px) {
    /* Stack wipe buttons full-width on narrow screens so the page doesn't
       horizontal-scroll. flex-wrap alone won't save us if any single
       button is wider than the viewport. */
    .danger-row { flex-direction: column; align-items: stretch; }
    .danger-row .btn { width: 100%; }
}

/* Table action-cell sizing */
.table td .btn-mini { white-space: nowrap; }

/* ---------- "Can't make it?" red button ---------- */
/* Falling back to a plain styled red button. The earlier mask-image bite
   notch was unreliable across browsers and read more like a glitch than
   a bite. The 🌭 emoji prefix carries the hot-dog reference cleanly. */
.btn-hotdog {
    background: linear-gradient(180deg, #d94f30 0%, #9b3417 100%);
    color: #fff7ee;
    border-color: #f3a85a;
    box-shadow: 0 4px 14px rgba(217, 79, 48, 0.35);
}
.btn-hotdog::before {
    content: "🌭 ";
    margin-right: 0.05rem;
}
.btn-hotdog:hover {
    background: linear-gradient(180deg, #e85d3c 0%, #b54124 100%);
    box-shadow: 0 6px 18px rgba(217, 79, 48, 0.5);
}

/* Centered "Count me in" submit, sitting on its own row beneath the
   potluck fieldset so it reads as the conclusion of the whole form. */
.rsvp-submit-row {
    display: flex;
    justify-content: center;
    margin-top: 1.3rem;
}
.rsvp-submit-row .btn { min-width: 220px; }

/* ---------- Party-page background (burgers + dogs drifting) ---------- */
#party-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: -1;
}
#party-bg[hidden] { display: none; }
#party-bg .grill-item {
    position: absolute;
    font-size: 2.4rem;
    opacity: 0.16;
    will-change: transform;
    user-select: none;
    /* Drift is applied to the outer span; rotor span handles the spin
       so the two transforms don't fight each other. */
}
#party-bg .grill-item .rotor {
    display: inline-block;
    will-change: transform;
}

/* Lanes — different y positions, durations, start offsets so nothing
   ever lines up too cleanly. */
#party-bg .b1 { top: 12%;  left: -8vw;   animation: drift-right 78s linear infinite; }
#party-bg .b1 .rotor { animation: burger-flip 11s ease-in-out infinite; }
#party-bg .b2 { top: 58%;  left: 105vw;  animation: drift-left  92s linear infinite -25s; }
#party-bg .b2 .rotor { animation: burger-flip 13s ease-in-out infinite -4s; }

#party-bg .h1 { top: 35%;  left: -8vw;   animation: drift-right 105s linear infinite -45s; }
#party-bg .h1 .rotor { animation: hotdog-roll 6.5s linear infinite; }
#party-bg .h2 { top: 78%;  left: 105vw;  animation: drift-left  120s linear infinite -65s; }
#party-bg .h2 .rotor { animation: hotdog-roll 8s linear infinite -2s; }

#party-bg .s1 { top: 22%;  left: 75%;    animation: twinkle 4s ease-in-out infinite; font-size: 1.6rem; }
#party-bg .s2 { top: 70%;  left: 18%;    animation: twinkle 5.5s ease-in-out infinite -1.5s; font-size: 1.4rem; }

@keyframes drift-right {
    from { transform: translateX(0); }
    to   { transform: translateX(120vw); }
}
@keyframes drift-left {
    from { transform: translateX(0); }
    to   { transform: translateX(-120vw); }
}
@keyframes burger-flip {
    /* Mostly still, occasional flip — a spatula flick */
    0%, 78%, 100% { transform: rotateX(0deg); }
    88%           { transform: rotateX(180deg); }
}
@keyframes hotdog-roll {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
@keyframes twinkle {
    0%, 100% { opacity: 0.05; transform: scale(0.9); }
    50%      { opacity: 0.22; transform: scale(1.1); }
}

@media (prefers-reduced-motion: reduce) {
    /* No drift, no flip — just static decorations. */
    #party-bg .grill-item,
    #party-bg .grill-item .rotor { animation: none !important; }
}

@media (max-width: 520px) {
    h1 { font-size: 1.6rem; }
    .hero-title { font-size: 2rem; }
    .card { padding: 1.2rem 1rem; }
    .btn { padding: 0.6rem 0.95rem; }
    #party-bg .grill-item { font-size: 1.8rem; }
}
