/* Potluck: shared styles. Tokens first, then base, then components. */

:root {
  color-scheme: light dark;

  /* neutrals (light) */
  --ground: #F2F4EE;
  --surface: #FBFCF9;
  --ink: #1F2420;
  --muted: #5A6258;
  --line: #D8DDD2;
  --field-line: #7A8376;

  /* accents: harvest is the default theme */
  --accent: #9E1F36;
  --on-accent: #FFFFFF;
  --secondary: #55652B;

  /* signature pip */
  --gold: #D69A16;
  --gold-edge: #8A5F00;

  --danger: #B3261E;
  --on-danger: #FFFFFF;
  --focus: var(--accent);

  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

  --gutter: max(16px, env(safe-area-inset-left, 0px));
  --radius: 10px;
  --tap: 48px;
}

:root[data-event-theme="holiday"]  { --accent: #1F5A3A; --on-accent: #FFFFFF; --secondary: #A8233A; }
:root[data-event-theme="cookout"]  { --accent: #B5301F; --on-accent: #FFFFFF; --secondary: #7A5A00; }
:root[data-event-theme="birthday"] { --accent: #6B2E8F; --on-accent: #FFFFFF; --secondary: #0F6663; }
:root[data-event-theme="classic"]  { --accent: #2D5478; --on-accent: #FFFFFF; --secondary: #55646F; }

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #141815;
    --surface: #1D221E;
    --ink: #ECEFE8;
    --muted: #A3AB9F;
    --line: #2E352F;
    --field-line: #7D877B;
    --accent: #E2627A;
    --on-accent: #1A0A0E;
    --secondary: #A3B86A;
    --gold: #E9B544;
    --gold-edge: #E9B544;
    --danger: #FF8A80;
    --on-danger: #1A0A0E;
  }
  :root[data-event-theme="holiday"]  { --accent: #7CC59A; --on-accent: #08150D; --secondary: #F08A9B; }
  :root[data-event-theme="cookout"]  { --accent: #FF8070; --on-accent: #200A06; --secondary: #E8C04A; }
  :root[data-event-theme="birthday"] { --accent: #C9A0EE; --on-accent: #150A1F; --secondary: #5CCFC9; }
  :root[data-event-theme="classic"]  { --accent: #8FB6DE; --on-accent: #0A1420; --secondary: #AAB7C3; }
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 16px;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(2rem, 8vw, 3rem); font-weight: 800; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 0.75em; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
ul, ol { margin: 0; padding: 0; list-style: none; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.vh {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.sr-copy { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; font-size: 16px; }

.skip {
  position: absolute; left: 8px; top: -60px; z-index: 50;
  background: var(--ink); color: var(--ground);
  padding: 10px 14px; border-radius: 8px;
}
.skip:focus { top: 8px; }

.muted { color: var(--muted); }
.opt { color: var(--muted); font-weight: 400; }
.num { font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */

.wrap {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 var(--gutter) 96px;
}

.brandbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding-top: 6px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px;
  font-family: var(--font-display); font-weight: 800; font-size: 1.15rem;
  color: var(--ink); text-decoration: none;
}
.brand-pips { display: inline-flex; gap: 4px; }
.brand-pips i {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--gold); border: 2px solid var(--gold-edge);
}
.brand-pips i:last-child { background: transparent; border-color: var(--field-line); }

.section {
  padding-top: 36px;
  margin-top: 36px;
  border-top: 1px solid var(--line);
}
.section > h2 { margin-bottom: 6px; }
.sec-sub { color: var(--muted); margin-bottom: 16px; }

.stack > * + * { margin-top: 16px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap);
  padding: 10px 20px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font: inherit; font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, transform .1s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; filter: none; transform: none; }

.btn-secondary {
  background: transparent; color: var(--accent);
  border-color: var(--accent);
}
.btn-secondary:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); filter: none; }

.btn-quiet {
  background: transparent; color: var(--ink);
  border-color: transparent;
  padding: 8px 12px;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--field-line);
}
.btn-quiet:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); filter: none; }

.btn-danger { background: var(--danger); color: var(--on-danger); }
.btn-danger-quiet { color: var(--danger); text-decoration-color: var(--danger); }

.btn-small { padding: 6px 14px; font-size: 0.95rem; }
.btn-block { width: 100%; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- forms ---------- */

.form { display: grid; gap: 20px; }
.field { display: grid; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field > label, .field > legend, .field-label {
  font-weight: 700; padding: 0; float: none; width: auto;
}
.hint { color: var(--muted); font-size: 0.93rem; margin: 0; }

input[type="text"], input[type="password"], input[type="date"], input[type="time"],
input[type="number"], select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--field-line);
  border-radius: 8px;
  font: inherit;
  line-height: 1.3;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .85; }
select { appearance: auto; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--focus);
}
input[readonly] { background: color-mix(in srgb, var(--ink) 5%, var(--surface)); }

.row-2 { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 520px) { .row-2 { grid-template-columns: 1fr 1fr; } }

.form-error {
  margin: 0; color: var(--danger); font-weight: 700;
}
.form-error:empty { display: none; }
.inline-error { margin: 6px 0 0; color: var(--danger); font-weight: 700; font-size: 0.95rem; }

/* toggle chips (checkbox) */
.chips-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; display: inline-flex; }
.chip > input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.chip > span, .chip-btn {
  display: inline-flex; align-items: center;
  min-height: 44px; padding: 6px 16px;
  border: 1.5px solid var(--field-line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit; font-size: 0.97rem;
  cursor: pointer;
  user-select: none;
}
.chip > input:checked + span,
.chip-btn[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700;
}
.chip > input:focus-visible + span,
.chip-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* segmented control (radio) */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1.5px solid var(--field-line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg label {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: var(--tap); padding: 8px 6px;
  font-weight: 700; cursor: pointer;
  border-left: 1.5px solid var(--field-line);
  line-height: 1.2;
}
.seg input:first-of-type + label { border-left: 0; }
.seg input:checked + label { background: var(--accent); color: var(--on-accent); }
.seg input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: -4px; }

/* steppers */
.steppers { display: flex; flex-wrap: wrap; gap: 20px 28px; }
.stepper { display: grid; gap: 6px; }
.stepper-label { font-weight: 700; }
.stepper-ctl { display: inline-flex; align-items: stretch; }
.stepper-ctl button {
  width: var(--tap); min-height: var(--tap);
  border: 1.5px solid var(--field-line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 1.4rem; font-weight: 700; line-height: 1; cursor: pointer;
}
.stepper-ctl button:first-child { border-radius: 8px 0 0 8px; }
.stepper-ctl button:last-child { border-radius: 0 8px 8px 0; }
.stepper-ctl button:hover { background: color-mix(in srgb, var(--ink) 7%, var(--surface)); }
.stepper-ctl button[disabled] { opacity: .4; cursor: not-allowed; }
.stepper-ctl input[type="number"] {
  width: 4rem; border-radius: 0; text-align: center; border-left: 0; border-right: 0;
  font-family: var(--font-display); font-weight: 700; font-size: 1.15rem;
  -moz-appearance: textfield; appearance: textfield;
}
.stepper-ctl input[type="number"]::-webkit-outer-spin-button,
.stepper-ctl input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* theme picker */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.theme-opt { position: relative; display: block; }
.theme-opt > input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.theme-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  min-height: 76px; padding: 10px 12px;
  border: 1.5px solid var(--field-line); border-radius: var(--radius);
  background: var(--surface);
}
.theme-name { font-weight: 700; font-size: 0.97rem; }
.swatch { width: 38px; height: 22px; border-radius: 999px; border: 1.5px solid color-mix(in srgb, var(--ink) 25%, transparent); }
.sw-harvest  { background: linear-gradient(90deg, #9E1F36 50%, #55652B 50%); }
.sw-holiday  { background: linear-gradient(90deg, #1F5A3A 50%, #A8233A 50%); }
.sw-cookout  { background: linear-gradient(90deg, #B5301F 50%, #D69A16 50%); }
.sw-birthday { background: linear-gradient(90deg, #6B2E8F 50%, #0F8F8A 50%); }
.sw-classic  { background: linear-gradient(90deg, #2D5478 50%, #7C8FA3 50%); }
.theme-opt > input:checked + .theme-card {
  border-color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.theme-opt > input:focus-visible + .theme-card { outline: 3px solid var(--focus); outline-offset: 2px; }

/* slots editor */
.slot-rows { display: grid; gap: 10px; margin-bottom: 12px; }
.slot-row {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 10px; align-items: end;
  padding: 10px 0 12px; border-bottom: 1px dashed var(--line);
}
.slot-row .slot-name { grid-column: 1 / -1; display: grid; gap: 4px; }
.slot-row .slot-name label, .slot-row .stepper-label { font-size: 0.9rem; font-weight: 700; color: var(--muted); }
.slot-note { margin: 4px 0 0; }

/* ---------- callouts, tags, toasts ---------- */

.callout {
  padding: 12px 14px; border-radius: 8px;
  border-left: 5px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}
.callout:empty { display: none; }
.callout p { margin: 0; }
.callout p + p { margin-top: 6px; }
.callout-warn { border-left-color: var(--gold-edge); background: color-mix(in srgb, var(--gold) 16%, var(--surface)); }
.callout-danger { border-left-color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, var(--surface)); }

.tag {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 700; line-height: 1.5;
  background: color-mix(in srgb, var(--accent) 13%, var(--ground)); color: var(--accent);
}
.tag-diet { background: color-mix(in srgb, var(--secondary) 14%, var(--ground)); color: var(--secondary); }

.toasts {
  position: fixed; left: var(--gutter); right: var(--gutter); bottom: 16px; z-index: 40;
  display: grid; gap: 8px; justify-items: start; pointer-events: none;
  max-width: 720px; margin: 0 auto;
}
.toast {
  background: var(--ink); color: var(--ground);
  padding: 12px 18px; border-radius: var(--radius); font-weight: 700;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .25);
  animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.net-banner {
  margin: 8px 0 0; padding: 10px 14px; border-radius: 8px;
  background: color-mix(in srgb, var(--gold) 20%, var(--surface));
  border: 1px solid var(--gold-edge); font-size: 0.95rem;
}

/* ---------- pips (signature) ---------- */

.pips { display: flex; flex-wrap: wrap; gap: 8px; }
.pip {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--field-line); background: transparent;
  transition: background-color .25s, border-color .25s;
}
.pip.is-on { background: var(--gold); border-color: var(--gold-edge); }
.pips-hero .pip { width: 30px; height: 30px; }

/* ---------- state panels ---------- */

.state { padding-top: 56px; }
.state h1 { font-size: clamp(1.7rem, 6vw, 2.4rem); margin-bottom: 12px; }
.state p { max-width: 36em; }
.loading-pips { display: flex; gap: 8px; margin-bottom: 14px; }
.loading-pips i {
  width: 18px; height: 18px; border-radius: 50%; background: var(--gold); border: 2px solid var(--gold-edge);
  animation: pulse 1.2s ease-in-out infinite;
}
.loading-pips i:nth-child(2) { animation-delay: .2s; }
.loading-pips i:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }

/* ---------- event page ---------- */

.event-head {
  margin-top: 6px; padding-top: 22px;
  border-top: 6px solid var(--accent);
}
.eyebrow { color: var(--secondary); font-weight: 700; margin-bottom: 6px; }
.event-head h1 { margin-bottom: 14px; }
.when { font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; line-height: 1.3; margin-bottom: 6px; }
.countdown {
  display: inline-block; margin: 2px 0 10px; padding: 3px 14px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 13%, var(--ground)); color: var(--accent);
  font-weight: 700;
}
.where { margin-bottom: 10px; }
.notes { white-space: pre-line; margin: 14px 0 18px; padding-left: 14px; border-left: 3px solid var(--line); }
.link-fallback { margin-top: 12px; display: grid; gap: 6px; }

.summary {
  display: grid; grid-template-columns: repeat(3, 1fr);
  margin-top: 28px; border-block: 1px solid var(--line);
}
.stat { padding: 14px 8px 14px 0; min-width: 0; }
.stat + .stat { padding-left: 14px; border-left: 1px solid var(--line); }
.stat-num { display: block; font-family: var(--font-display); font-weight: 800; font-size: 2.2rem; line-height: 1; }
.stat-label { display: block; margin-top: 6px; font-size: 0.93rem; line-height: 1.3; color: var(--muted); }
.stat-sub { display: block; font-size: 0.93rem; font-weight: 700; color: var(--secondary); }

.jump { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 8px; }
.jump a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 700; }

.tiles { display: grid; grid-template-columns: 1fr; border-top: 2px solid var(--ink); }
.tile {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 16px;
  padding-block: 14px; border-bottom: 1px solid var(--line);
}
.tile-main { display: grid; gap: 8px; min-width: 0; }
.tile-head { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.tile-label { font-size: 1.1rem; min-width: 0; }
.tile-count { font-family: var(--font-display); font-weight: 700; white-space: nowrap; color: var(--muted); font-size: 0.95rem; }
.tile.is-full .tile-label { color: var(--muted); }
.tile-done { margin: 0; color: var(--secondary); font-weight: 700; min-height: 44px; display: flex; align-items: center; }
.all-covered { font-weight: 700; color: var(--secondary); }

.filters { margin-bottom: 18px; display: grid; gap: 8px; }
.filter-label { font-weight: 700; font-size: 0.95rem; color: var(--muted); }

.dish-group + .dish-group { margin-top: 28px; }
.dish-group > h3 { display: flex; align-items: baseline; gap: 10px; padding-bottom: 6px; border-bottom: 2px solid var(--ink); }
.dish-group > h3 .muted { font-family: var(--font-body); font-weight: 400; font-size: 0.93rem; }
.dish { padding: 14px 0; border-bottom: 1px solid var(--line); }
.dish-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.dish-name { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; line-height: 1.25; }
.dish-by { color: var(--muted); }
.dish .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.dish-note { margin: 6px 0 0; color: var(--muted); }
.dish-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; margin-left: -12px; }

.empty { color: var(--muted); padding: 8px 0; }
.remove-ctl { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }

.edit-banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px;
  margin: 0 0 4px; padding: 8px 8px 8px 14px; border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border-left: 5px solid var(--accent);
}
.edit-banner p { margin: 0; }

/* rsvp */
.my-rsvp {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 14px 16px; margin-bottom: 18px;
  background: var(--surface); border: 1.5px solid var(--line); border-left: 5px solid var(--secondary); border-radius: var(--radius);
}
.my-rsvp-text { margin: 0; }
.my-rsvp-title { display: block; font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; }
.rsvp-groups { margin-top: 28px; }
.rsvp-group + .rsvp-group { margin-top: 22px; }
.rsvp-group > h3 { display: flex; align-items: baseline; gap: 10px; padding-bottom: 6px; border-bottom: 2px solid var(--ink); }
.rsvp-group > h3 .muted { font-family: var(--font-body); font-weight: 400; font-size: 0.93rem; }
.rsvp-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.rsvp-who { font-weight: 700; }
.rsvp-plus { font-family: var(--font-display); font-weight: 700; color: var(--secondary); margin-left: 6px; }
.rsvp-detail, .rsvp-note { display: block; color: var(--muted); font-size: 0.95rem; }

/* host panel */
.host-panel { margin-top: 36px; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.host-panel > summary {
  display: flex; align-items: center; min-height: 56px; padding: 8px 16px; cursor: pointer;
  font-family: var(--font-display); font-weight: 700; font-size: 1.2rem;
}
.host-panel > summary:focus-visible { outline-offset: -3px; }
.host-body { padding: 4px 16px 24px; display: grid; gap: 28px; }
.host-body h3 { margin-bottom: 10px; }
.link-box { display: grid; gap: 6px; }
.link-box + .link-box { margin-top: 14px; }
.link-line { display: flex; gap: 8px; }
.link-line input { flex: 1; min-width: 0; }
.link-line .btn { flex: none; }
.delete-zone { padding-top: 20px; border-top: 1px dashed var(--line); }

/* home page */
.hero { padding-top: 28px; }
.hero h1 { margin-bottom: 14px; }
.hero .lede { font-size: 1.2rem; max-width: 30em; color: var(--ink); }
.hero .pips { margin: 20px 0 8px; }
.hosted-list { display: grid; gap: 0; margin-top: 6px; }
.hosted-list a { display: flex; align-items: center; min-height: 52px; border-bottom: 1px solid var(--line); font-weight: 700; }

.success {
  padding: 22px 18px; background: var(--surface);
  border: 1.5px solid var(--line); border-top: 6px solid var(--gold-edge); border-radius: var(--radius);
  display: grid; gap: 22px;
}
.success h2 { font-size: 1.8rem; }

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 380px) {
  .stat-num { font-size: 1.9rem; }
  .seg label { font-size: 0.95rem; }
}
