/*
 * The event microsite (viva-events.co/e/<slug>).
 * Design: ~/Downloads/design_handoff_unbox_event_page, direction 1a "The Flyer" -- the
 * values below are the handoff's, not approximations of it. Spec:
 * docs/product/viva-wine/event-microsite.md
 *
 * PHONE FIRST: 375 px, and it must hold at 320 px. Rating targets 48 px, everything else
 * at least 44 px, inputs 16 px (below that iOS zooms). Light only: no shadows in 1a.
 */
:root {
    --sp-paper:  #F5EFE6;
    --sp-card:   #FBF8F3;
    --sp-ink:    #2B2320;
    --sp-brand:  #5A1E2B;
    --sp-gold:   #C6A15B;
    --sp-taupe:  #7A6A5E;
    --sp-orange: #D2692A;   /* the offline dot, only */
    --sp-green:  #3F7A4A;   /* the "Saved" dot, only */
    --sp-hair:   rgba(122, 106, 94, .2);
    --sp-edge:   rgba(198, 161, 91, .6);
    --sp-off:    rgba(90, 30, 43, .3);
    --sp-scrim:  rgba(43, 35, 32, .4);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--sp-paper);
    color: var(--sp-ink);
    font: 400 16px/1.5 'Public Sans', system-ui, -apple-system, sans-serif;
}
button, input, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.sp-page { max-width: 480px; margin: 0 auto; }
[hidden] { display: none !important; }

/* ── 1. Header: the double gold frame ───────────────────────────────────── */
.sp-head { padding: calc(44px + env(safe-area-inset-top)) 16px 8px; }
.sp-frame-outer { border: 1px solid var(--sp-gold); padding: 4px; }
.sp-frame-inner {
    border: 1px solid var(--sp-gold); padding: 22px 14px 20px;
    display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
}
.sp-eyebrow {
    margin: 0; font-size: 11px; font-weight: 600; line-height: 1.6;
    letter-spacing: .18em; text-transform: uppercase; color: var(--sp-taupe);
}
.sp-title {
    margin: 0; font-family: 'Pinyon Script', cursive; font-weight: 400;
    font-size: 52px; line-height: 1.05; color: var(--sp-brand);
}
.sp-rule { display: flex; align-items: center; gap: 10px; width: 70%; }
.sp-rule::before, .sp-rule::after { content: ''; flex: 1; height: 1px; background: var(--sp-gold); }
.sp-rule span { width: 7px; height: 7px; background: var(--sp-gold); transform: rotate(45deg); flex: none; }
.sp-rule-sm { width: 60%; margin: 10px 0 6px; }
.sp-rule-sm span { width: 6px; height: 6px; }
.sp-when { margin: 0; font-family: 'Playfair Display', Georgia, serif; font-weight: 600; font-size: 18px; }
.sp-where { margin: 0; font-size: 13px; line-height: 1.4; color: var(--sp-taupe); white-space: pre-line; }

/* ── 2. Category columns ────────────────────────────────────────────────── */
.sp-cats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding: 14px 16px 0; }
.sp-cat-btn {
    min-height: 48px; padding: 0;
    border: 0; border-top: 2px solid var(--sp-gold); background: transparent;
    font-size: 11px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase;
    color: var(--sp-taupe); cursor: pointer; white-space: nowrap;
}
/* "CHOCOLATE" is the longest label: at 320 px its column is ~69 px, so the tracking gives. */
@media (max-width: 360px) { .sp-cat-btn { font-size: 10px; letter-spacing: .04em; } }
/* One column per kind of vendor present: 2-5. Five is the flyer's four plus Food, and
   "CHOCOLATE" is what has to fit, so five columns set tighter. */
.sp-cats[data-cols="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sp-cats[data-cols="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sp-cats[data-cols="5"] { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.sp-cats[data-cols="5"] .sp-cat-btn { font-size: 10px; letter-spacing: .02em; }   /* measured: CHOCOLATE 65 px in a 65 px column at 375 */
/* Below 360 px no legible size fits five across (9 px still needs 55 px of a 54 px column),
   so the row becomes its own sideways strip -- the page never scrolls sideways. */
@media (max-width: 360px) {
    .sp-cats[data-cols="5"] { grid-template-columns: repeat(5, 64px); overflow-x: auto; scrollbar-width: none; }
    .sp-cats[data-cols="5"]::-webkit-scrollbar { display: none; }
}
.sp-cat-btn[aria-pressed="true"] {
    border-top-width: 5px; background: var(--sp-card); color: var(--sp-brand); font-weight: 700;
}

/* ── 3. Privacy line ────────────────────────────────────────────────────── */
.sp-private {
    display: flex; align-items: center; gap: 6px; margin: 0;
    padding: 14px 20px 10px; font-size: 13px; color: var(--sp-taupe);
}
.sp-private svg { width: 14px; height: 14px; flex: none; }

/* ── 4. Vendor cards ────────────────────────────────────────────────────── */
.sp-list { display: flex; flex-direction: column; gap: 12px; padding: 0 16px; }
.sp-card {
    background: var(--sp-card); border: 1px solid var(--sp-edge); border-radius: 4px;
    padding: 16px 16px 0; scroll-margin-top: 12px;
}
.sp-card.sp-here { outline: 3px solid var(--sp-gold); outline-offset: 2px; }
.sp-card-cat { font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--sp-taupe); }
.sp-vendor { margin: 4px 0 0; font-family: 'Playfair Display', Georgia, serif; font-weight: 600; font-size: 22px; line-height: 1.2; color: var(--sp-ink); }
.sp-blurb { margin: 4px 0 0; font-size: 14px; line-height: 1.45; color: var(--sp-taupe); }

.sp-wines { margin-top: 10px; }
.sp-item { border-top: 1px solid var(--sp-hair); padding: 12px 0; }
.sp-wines .sp-item:first-child { border-top: 1px solid var(--sp-hair); }
.sp-item-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sp-wine-name { font-size: 16px; font-weight: 600; line-height: 1.25; min-width: 0; overflow-wrap: anywhere; }
.sp-vintage { display: block; margin-top: 2px; font-size: 13px; font-weight: 400; color: var(--sp-taupe); }
.sp-status { font-size: 13px; color: var(--sp-taupe); }
.sp-vendor-item { margin-top: 10px; }
.sp-none { margin: 10px 0 0; padding: 12px 0; border-top: 1px solid var(--sp-hair); font-size: 14px; font-style: italic; color: var(--sp-taupe); }

/* Rating buttons: 48 px circles, outline icon off, filled icon + filled ground on. */
.sp-rates { display: flex; gap: 8px; flex: none; }
.sp-rate {
    width: 48px; height: 48px; padding: 0; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1.5px solid var(--sp-off); background: transparent; color: var(--sp-brand); cursor: pointer;
}
.sp-rate svg { width: 21px; height: 21px; }
.sp-rate[data-rate="love"] svg { width: 22px; height: 22px; }
.sp-rate svg path { fill: none; }
.sp-rate[aria-pressed="true"] { background: var(--sp-brand); border-color: var(--sp-brand); color: var(--sp-card); }
.sp-rate[aria-pressed="true"][data-rate="pass"] { background: var(--sp-ink); border-color: var(--sp-ink); }
.sp-rate[aria-pressed="true"] svg path:last-child { fill: currentColor; }

/* The note: inline, never a dialog. */
.sp-note-btn {
    display: inline-flex; align-items: center; min-height: 44px; padding: 0;
    background: none; border: 0; cursor: pointer;
    font-size: 14px; font-weight: 600; color: var(--sp-brand);
    text-decoration: underline; text-underline-offset: 3px;
}
.sp-note-shown { margin: 8px 0 0; font-family: 'Playfair Display', Georgia, serif; font-style: italic; font-weight: 500; font-size: 15px; color: var(--sp-brand); overflow-wrap: anywhere; }
.sp-note-edit { margin-top: 8px; }
.sp-note {
    display: block; width: 100%; padding: 10px 12px;
    border: 1.5px solid var(--sp-gold); border-radius: 6px; background: #fff;
    font-size: 16px; line-height: 1.4; resize: none;
}
.sp-note:focus { outline: 2px solid var(--sp-brand); outline-offset: 1px; }
.sp-note-done { display: flex; justify-content: flex-end; margin-top: 8px; }
.sp-pill {
    min-height: 44px; padding: 0 18px; border: 0; border-radius: 22px;
    background: var(--sp-brand); color: var(--sp-card); font-size: 14px; font-weight: 600; cursor: pointer;
}

/* The holiday bag (§9 of the spec). Not in the 1a handoff: built in its language --
   burgundy outline, 44 px targets, the header's gold frame for the summary. A quantity is
   in CASES for wine, items otherwise. */
.sp-bag { display: flex; justify-content: flex-end; margin-top: 8px; }
.sp-bag-add {
    display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px;
    border: 1.5px solid var(--sp-off); border-radius: 22px; background: transparent;
    color: var(--sp-brand); font-size: 14px; font-weight: 600; cursor: pointer;
}
.sp-bag-add svg { width: 16px; height: 16px; }
.sp-stepper {
    display: inline-flex; align-items: center; min-height: 44px;
    border: 1.5px solid var(--sp-brand); border-radius: 22px; background: var(--sp-card);
}
.sp-step {
    width: 44px; height: 44px; padding: 0; border: 0; background: transparent; cursor: pointer;
    font-size: 20px; font-weight: 600; line-height: 1; color: var(--sp-brand);
}
.sp-step[disabled] { opacity: .35; cursor: default; }
.sp-step-qty { min-width: 72px; text-align: center; font-size: 14px; font-weight: 700; color: var(--sp-brand); }
.sp-bagsum { border: 1px solid var(--sp-gold); padding: 4px; background: var(--sp-paper); }
.sp-bagsum > * { margin: 0; }
.sp-bagsum h2 {
    padding: 14px 14px 0; font-family: 'Playfair Display', Georgia, serif; font-weight: 600; font-size: 20px;
}
.sp-bagsum-sub { padding: 4px 14px 0; font-size: 14px; line-height: 1.45; color: var(--sp-taupe); }
.sp-bag-lines { list-style: none; padding: 10px 14px 14px; }
.sp-bag-lines li { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--sp-hair); font-size: 15px; }
.sp-bag-q { flex: none; min-width: 64px; font-weight: 700; color: var(--sp-brand); }
.sp-bag-v { display: block; font-size: 13px; color: var(--sp-taupe); }
.sp-bag-add:focus-visible, .sp-step:focus-visible { outline: 3px solid var(--sp-gold); outline-offset: 2px; }

/* The bag sheet: every line, grouped by who arranges it, and one Request button. */
.sp-bagbtn {
    display: inline-flex; align-items: center; gap: 6px; flex: none;
    min-height: 44px; padding: 0 14px; border-radius: 22px;
    border: 1.5px solid var(--sp-brand); background: var(--sp-brand); color: var(--sp-card);
    font-size: 15px; font-weight: 600; cursor: pointer;
}
.sp-bagbtn svg { width: 16px; height: 16px; }
.sp-bagsheet { max-height: 85vh; max-height: 85dvh; overflow-y: auto; overscroll-behavior: contain; }
.sp-bag-group { margin-top: 4px; }
.sp-bag-group h3 {
    margin: 0 0 4px; font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
    color: var(--sp-taupe);
}
.sp-bag-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--sp-hair); }
.sp-bag-row .sp-bag { margin-top: 0; }
.sp-bag-item { min-width: 0; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.sp-bag-lead { margin: 0 0 4px; }
.sp-bag-sent { margin: 12px 0 0; padding: 10px 12px; border-left: 3px solid var(--sp-green); background: var(--sp-card); font-size: 14px; line-height: 1.45; }
.sp-bag-fine { margin: 0; font-size: 13px; line-height: 1.45; color: var(--sp-taupe); }
#bagRequestArea { display: flex; flex-direction: column; gap: 10px; }
.sp-bagsum-act { display: flex; justify-content: flex-end; padding: 0 14px 14px; }

/* Card footer: Order */
.sp-order { display: flex; align-items: center; min-height: 48px; border-top: 1px solid var(--sp-hair); margin-top: 0; }
.sp-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-size: 15px; font-weight: 600; color: var(--sp-brand); text-decoration: none; }
.sp-link svg { width: 16px; height: 16px; }
.sp-soon { font-size: 14px; color: var(--sp-taupe); }

/* Empty "Mine" */
.sp-empty { margin: 8px 0; padding: 28px 20px; border: 1px dashed var(--sp-gold); text-align: center; }
.sp-empty h2 { margin: 0; font-family: 'Playfair Display', Georgia, serif; font-weight: 600; font-size: 20px; }
.sp-empty p { margin: 6px 0 0; font-size: 14px; line-height: 1.5; color: var(--sp-taupe); }
.sp-text-btn {
    min-height: 44px; padding: 0; background: none; border: 0; cursor: pointer;
    font-size: 15px; font-weight: 600; color: var(--sp-brand);
}
.sp-empty .sp-text-btn { margin-top: 6px; text-decoration: underline; text-underline-offset: 3px; }
.sp-state { text-align: center; padding: 40px 12px; color: var(--sp-taupe); }
.sp-state h2 { margin: 0 0 6px; font-family: 'Playfair Display', Georgia, serif; font-weight: 600; font-size: 20px; color: var(--sp-ink); }

/* ── 5. Footer ──────────────────────────────────────────────────────────── */
.sp-foot {
    display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
    padding: 32px 20px calc(120px + env(safe-area-inset-bottom));
}
.sp-signoff { margin: 0; font-family: 'Pinyon Script', cursive; font-size: 26px; line-height: 1.3; color: var(--sp-brand); }
.sp-presented, .sp-presented-name { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: var(--sp-taupe); }
.sp-presented-name:empty { display: none; }
.sp-logo { width: 132px; height: auto; margin-bottom: 8px; }
.sp-legal { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--sp-taupe); }

/* ── Not published ──────────────────────────────────────────────────────── */
.sp-soon-page {
    min-height: 100vh; min-height: 100dvh; padding: 24px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center;
}
.sp-soon-page .sp-title { font-size: 48px; }
.sp-soon-head { margin: 0; font-family: 'Playfair Display', Georgia, serif; font-weight: 600; font-size: 22px; }
.sp-soon-sub { margin: 0; font-size: 15px; color: var(--sp-taupe); max-width: 320px; }

/* ── Bottom bar ─────────────────────────────────────────────────────────── */
.sp-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: var(--sp-card); border-top: 1px solid var(--sp-gold);
}
.sp-bar-mid {
    flex: 1; min-width: 0; min-height: 44px; padding: 0 4px;
    background: none; border: 0; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.sp-favs {
    display: inline-flex; align-items: center; gap: 6px; flex: none;
    min-height: 44px; padding: 0 14px; border-radius: 22px;
    border: 1.5px solid var(--sp-brand); background: transparent; color: var(--sp-brand);
    font-size: 15px; font-weight: 600; cursor: pointer;
}
.sp-favs svg { width: 16px; height: 16px; }
.sp-favs[aria-pressed="true"] { background: var(--sp-brand); color: var(--sp-card); }
.sp-favs[aria-pressed="true"] svg path { fill: currentColor; }
.sp-favs:focus-visible, .sp-bagbtn:focus-visible, .sp-bar-mid:focus-visible { outline: 3px solid var(--sp-gold); outline-offset: 2px; }
.sp-favs-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 14px; border: 1px dashed var(--sp-gold);
}
.sp-favs-head p { margin: 0; font-size: 14px; color: var(--sp-taupe); }
/* Between Favs and Bag there is ~120 px at 375: the status wraps to two short centred lines
   rather than clipping "add email", the one part of it that asks for something. */
.sp-save {
    display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 0;
    font-size: 12px; line-height: 1.25; color: var(--sp-taupe); text-align: center;
}
.sp-save span:last-child {
    min-width: 0; overflow-wrap: break-word;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* Below 360 px the two buttons drop their icons, so the status keeps room for two lines. */
@media (max-width: 360px) {
    .sp-favs svg, .sp-bagbtn svg { display: none; }
    .sp-favs, .sp-bagbtn { padding: 0 12px; }
    .sp-bar { gap: 8px; }
}
.sp-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: transparent; }
.sp-dot[data-state="saving"], .sp-dot[data-state="local"] { background: var(--sp-gold); }
.sp-dot[data-state="saved"] { background: var(--sp-green); }
.sp-dot[data-state="offline"] { background: var(--sp-orange); }

/* ── Sign-in sheet ──────────────────────────────────────────────────────── */
.sp-scrim { position: fixed; inset: 0; z-index: 30; background: var(--sp-scrim); }
.sp-sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
    max-width: 480px; margin: 0 auto;
    display: flex; flex-direction: column; gap: 14px;
    padding: 10px 20px calc(30px + env(safe-area-inset-bottom));
    background: var(--sp-card); border-top: 3px solid var(--sp-gold); border-radius: 18px 18px 0 0;
    transform: translateY(0); transition: transform 350ms cubic-bezier(.2, .8, .2, 1);
}
.sp-sheet.sp-sheet-in { transform: translateY(115%); }
.sp-handle { width: 40px; height: 4px; border-radius: 2px; background: rgba(122, 106, 94, .35); align-self: center; }
.sp-sheet h2 { margin: 0; font-family: 'Playfair Display', Georgia, serif; font-weight: 600; font-size: 21px; line-height: 1.3; }
.sp-sheet form { display: flex; flex-direction: column; gap: 10px; }
.sp-label { font-size: 13px; font-weight: 600; color: var(--sp-taupe); }
.sp-input {
    height: 50px; padding: 0 14px; margin-top: -6px;
    border: 1.5px solid var(--sp-gold); border-radius: 8px; background: #fff; font-size: 16px;
}
.sp-input:focus { outline: 2px solid var(--sp-brand); outline-offset: 1px; }
.sp-input[aria-invalid="true"] { border-color: #9B1C1C; }
.sp-sheet-msg { margin: 0; font-size: 14px; }
.sp-sheet-msg:empty { display: none; }
.sp-sheet-msg.sp-ok { color: var(--sp-green); }
.sp-sheet-msg.sp-err { color: #9B1C1C; }
.sp-btn-primary {
    min-height: 52px; border: 0; border-radius: 8px;
    background: var(--sp-brand); color: var(--sp-card); font-size: 16px; font-weight: 600; cursor: pointer;
}
.sp-btn-primary[disabled] { opacity: .6; cursor: default; }
.sp-code { font-size: 20px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; }
.sp-fine { margin: 0; font-size: 12px; line-height: 1.45; color: var(--sp-taupe); }
.sp-fine a { color: var(--sp-brand); }
#passForm { display: flex; flex-direction: column; gap: 10px; }
.sp-or { display: flex; align-items: center; gap: 10px; margin: 2px 0; font-size: 13px; color: var(--sp-taupe); }
.sp-or::before, .sp-or::after { content: ''; flex: 1; height: 1px; background: var(--sp-hair); }
.sp-check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; cursor: pointer; }
.sp-check input { width: 22px; height: 22px; margin: 0; accent-color: var(--sp-brand); flex: none; }
.sp-sheet-foot { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--sp-taupe); }

/* Focus, everywhere a finger can land. */
.sp-rate:focus-visible, .sp-cat-btn:focus-visible, .sp-link:focus-visible,
.sp-pill:focus-visible, .sp-note-btn:focus-visible, .sp-text-btn:focus-visible,
.sp-btn-primary:focus-visible { outline: 3px solid var(--sp-gold); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    .sp-sheet { transition: none; }
}
