/* Potluck Planner — mobile-first styles. Theme values come from CSS variables set in theme.js. */
:root {
  --accent: #e63946; --accent-ink: #fff; --accent-text: #c62f3b; --accent-text-sheet: #c62f3b;
  --card-bg: rgba(255,255,255,.95); --card-text: #1d1d1f; --card-muted: #5f6368;
  --card-border: rgba(0,0,0,.1); --card-blur: 0px;
  --sheet-bg: #fff; --sheet-text: #1d1d1f; --sheet-muted: #5f6368; --sheet-border: rgba(0,0,0,.12);
  --on-bg: #fff;
  --font-head: system-ui, sans-serif; --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --radius: 20px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font-family: var(--font-body); font-size: 16px; line-height: 1.45;
  color: var(--card-text); background: #0b1d3a;
  -webkit-tap-highlight-color: transparent;
}
#bg { position: fixed; inset: -40px; z-index: -2; background: #0b1d3a; transition: filter .2s; }
#bg-dim { position: fixed; inset: 0; z-index: -1; background: #000; opacity: 0; pointer-events: none; transition: opacity .2s; }

.wrap { max-width: 560px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 14px calc(110px + env(safe-area-inset-bottom)); }

.card {
  --line: var(--card-border); --mut: var(--card-muted); --acc-text: var(--accent-text);
  background: var(--card-bg); color: var(--card-text);
  border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px;
  -webkit-backdrop-filter: blur(var(--card-blur)); backdrop-filter: blur(var(--card-blur));
  box-shadow: 0 6px 24px rgba(0,0,0,.14);
}
.muted { color: var(--mut); }
.small { font-size: .88rem; }
/* Anything that sits on the background gets a solid pill behind it, so busy patterns stay readable. */
.on-bg { text-align: center; margin: 18px 0 0; }
.on-bg a, .loading span {
  display: inline-block; padding: 10px 18px; border-radius: 999px; font-weight: 650; text-decoration: none;
  background: var(--card-bg); color: var(--card-text); border: 1px solid var(--card-border);
  -webkit-backdrop-filter: blur(var(--card-blur)); backdrop-filter: blur(var(--card-blur));
}

h1, h2, h3 { font-family: var(--font-head); line-height: 1.15; }
h1 { font-size: clamp(1.75rem, 8vw, 2.4rem); margin: 0 0 6px; overflow-wrap: anywhere; }
h2 { font-size: 1.2rem; margin: 0 0 6px; }

/* hero */
.hero { text-align: center; padding: 22px 18px; }
.hero-pic { display: flex; justify-content: center; margin-bottom: 6px; }
.hero .meta { margin: 4px 0; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px; }
.hero .meta .ico { color: var(--acc-text); }
.hero .notes { margin: 10px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.hero-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border: 0; border-radius: 999px;
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--accent-ink);
  transition: transform .1s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.secondary { background: rgba(127,127,127,.16); color: inherit; }
.btn.danger { background: transparent; color: #d62828; border: 1.5px solid currentColor; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: .92rem; }
.btn.block { width: 100%; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(127,127,127,.16); color: inherit; font-size: 1.2rem;
}

.fab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; pointer-events: none;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); display: flex; justify-content: center;
}
.fab-bar .btn { pointer-events: auto; width: 100%; max-width: 532px; min-height: 58px; font-size: 1.1rem; box-shadow: 0 10px 30px rgba(0,0,0,.35); }

/* pictures + icons (drawn in icons.svg) */
.ico { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
.pic-xs { width: 22px; height: 22px; flex: none; }
.pic-sm { width: 30px; height: 30px; flex: none; }
.pic { width: 40px; height: 40px; }
.pic-lg { width: 72px; height: 72px; }
.icon-btn { display: inline-grid; place-items: center; }
.pic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; }
.pic-btn {
  display: grid; place-items: center; aspect-ratio: 1; border-radius: 14px; cursor: pointer; padding: 0;
  border: 1px solid var(--line); background: rgba(127,127,127,.08); color: inherit; font: inherit;
}
.pic-btn[aria-pressed="true"] { outline: 3px solid var(--acc-line, var(--accent)); outline-offset: 1px; background: rgba(127,127,127,.18); }
.pic-none { font-size: .8rem; color: var(--mut); }
.chip { display: inline-flex; align-items: center; gap: 6px; }

/* forms */
label.field { display: block; font-weight: 650; font-size: .95rem; margin: 14px 0 6px; }
label.field .opt { font-weight: 400; color: var(--mut); }
input, textarea, select {
  width: 100%; min-height: 48px; padding: 12px 14px;
  font: inherit; font-size: 16px; /* 16px stops iOS zooming in */
  color: inherit; background: rgba(127,127,127,.09);
  border: 1px solid var(--line); border-radius: 12px; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
textarea { min-height: 84px; resize: vertical; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.row > div { min-width: 0; }
@media (max-width: 359px) { .row { grid-template-columns: minmax(0, 1fr); gap: 0; } }
/* Phone browsers give date/time boxes a built-in minimum width; let them fit their column. */
input[type="date"], input[type="time"] {
  -webkit-appearance: none; appearance: none; display: block;
  min-width: 0; max-width: 100%; text-align: left;
}
input::-webkit-date-and-time-value { text-align: left; }
.row label.field { margin-top: 14px; }
.hint { font-size: .85rem; color: var(--mut); margin-top: 6px; overflow-wrap: anywhere; }

/* chips + swatches */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 42px; min-width: 42px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: inherit; font: inherit; font-size: .95rem;
}
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--acc-line, transparent); font-weight: 700; }

.swatches { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.swatch {
  position: relative; aspect-ratio: 1.25; border-radius: 14px; cursor: pointer; overflow: hidden;
  border: 1px solid rgba(0,0,0,.15); padding: 0;
}
.swatch span {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 6px;
  font-size: .75rem; font-weight: 700; color: #fff; background: rgba(0,0,0,.45);
}
.swatch:last-child:nth-child(odd) { grid-column: 1 / -1; aspect-ratio: 2.6; }
.swatch[aria-pressed="true"] { outline: 3px solid var(--acc-line, var(--accent)); outline-offset: 2px; }

.color-dots { display: flex; flex-wrap: wrap; gap: 10px; }
.dot {
  position: relative; width: 42px; height: 42px; border-radius: 50%; cursor: pointer; padding: 0;
  border: 2px solid rgba(255,255,255,.9); box-shadow: 0 0 0 1px rgba(0,0,0,.2);
}
.dot[aria-pressed="true"] { outline: 3px solid currentColor; outline-offset: 2px; }
.dot.custom {
  display: grid; place-items: center; font-weight: 800; font-size: 1.3rem; color: #fff;
  background: conic-gradient(#e63946, #e9c46a, #2b9348, #0077b6, #7b2ff7, #e63946);
}
.dot.custom span { text-shadow: 0 1px 2px rgba(0,0,0,.5); pointer-events: none; }
.dot.custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; min-height: 0; padding: 0; cursor: pointer; }

/* tally + list */
.tally { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 0 0 14px; }
.tally-chip {
  display: inline-flex; gap: 6px; align-items: center; padding: 6px 12px; border-radius: 999px; font-size: .9rem;
  background: var(--card-bg); color: var(--card-text); border: 1px solid var(--card-border);
  -webkit-backdrop-filter: blur(var(--card-blur)); backdrop-filter: blur(var(--card-blur));
}
button.tally-chip { font: inherit; font-size: .9rem; min-height: 40px; cursor: pointer; transition: transform .1s; }
button.tally-chip:active { transform: scale(.96); }
.tally-chip.zero { color: var(--card-muted); }
.tally-chip[aria-pressed="true"] {
  background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.tally .tally-chip[aria-pressed="true"] svg { opacity: 1; }
.tally-chip.show-all { font-weight: 650; }
.tally-chip.zero svg { opacity: .5; }
.cat { padding: 14px 18px 6px; }
.cat h2 { display: flex; justify-content: space-between; align-items: center; color: var(--acc-text); margin-bottom: 4px; }
.cat-title { display: inline-flex; align-items: center; gap: 10px; }
.cat h2 .count { font-size: .9rem; color: var(--mut); font-family: var(--font-body); }
.item {
  display: flex; gap: 12px; align-items: center; width: 100%; padding: 12px 0; min-height: 56px;
  background: none; border: 0; border-top: 1px solid var(--line); color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.item:first-of-type { border-top: 0; }
.item-main { flex: 1; min-width: 0; }
.item .dish { font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; }
.item .who { color: var(--mut); font-size: .9rem; }
.item .note { font-size: .88rem; margin-top: 2px; overflow-wrap: anywhere; }
.item .edit { color: var(--mut); font-size: 1.1rem; padding: 4px; }
.empty { text-align: center; padding: 28px 18px; }
.empty p { margin: 6px 0; }

/* welcome / share */
.share-box {
  display: flex; gap: 8px; align-items: center; margin: 12px 0; padding: 8px 8px 8px 14px;
  border: 1px dashed var(--line); border-radius: 14px; background: rgba(127,127,127,.08);
}
.share-box code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: .95rem; font-family: inherit; font-weight: 650; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

/* recent list on home */
.recent a {
  display: flex; gap: 10px; align-items: center; min-height: 48px; padding: 8px 0;
  color: inherit; text-decoration: none; border-top: 1px solid var(--line); font-weight: 650;
}
.recent a:first-of-type { border-top: 0; }
.recent a .chev { margin-left: auto; color: var(--mut); }

/* bottom sheets */
dialog.sheet {
  --line: var(--sheet-border); --mut: var(--sheet-muted); --acc-line: var(--accent-text-sheet);
  width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh;
  margin: auto auto 0; padding: 0; border: 0; border-radius: 22px 22px 0 0;
  background: var(--sheet-bg); color: var(--sheet-text); overflow: auto;
  overscroll-behavior: contain; box-shadow: 0 -10px 40px rgba(0,0,0,.3);
}
dialog.sheet[open] { animation: slide-up .22s ease-out; }
dialog.sheet::backdrop { background: rgba(0,0,0,.45); }
dialog.sheet.peek { max-height: 64vh; max-height: 64dvh; }
dialog.sheet.peek::backdrop { background: transparent; }
@keyframes slide-up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) {
  dialog.sheet { margin: auto; border-radius: 22px; }
  dialog.sheet.peek { margin: auto auto 16px; }
}
.sheet form { margin: 0; }
.sheet-head {
  position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px 10px 20px; background: var(--sheet-bg); border-bottom: 1px solid var(--line);
}
.sheet-head h2 { margin: 0; }
.sheet-body { padding: 4px 20px 20px; }
.sheet-body h3 { font-size: 1rem; margin: 20px 0 10px; }
.sheet-body h3:first-child { margin-top: 14px; }
.sheet-body .sub { font-size: .88rem; color: var(--mut); margin: 14px 0 8px; font-weight: 600; }
.sheet-foot {
  position: sticky; bottom: 0; display: flex; gap: 10px;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); background: var(--sheet-bg); border-top: 1px solid var(--line);
}
.sheet-foot .btn { flex: 1; }
.sheet-foot .btn.danger { flex: 0 0 auto; }

.range { display: block; margin: 14px 0 4px; }
.range-head { display: flex; justify-content: space-between; font-size: .88rem; font-weight: 600; color: var(--mut); }
input[type="range"] { padding: 0; min-height: 40px; background: none; border: 0; accent-color: var(--accent); box-shadow: none; }

/* toast */
#toast {
  position: fixed; left: 14px; right: 14px; top: calc(14px + env(safe-area-inset-top)); z-index: 100;
  width: fit-content; max-width: 520px; margin: 0 auto; text-align: center;
  transform: translateY(-160%); transition: transform .25s;
  padding: 12px 18px; border-radius: 18px;
  background: #111; color: #fff; font-weight: 650; box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
#toast.show { transform: none; }
#toast.error { background: #b3261e; }

.loading { text-align: center; padding-top: 30vh; font-size: 1.1rem; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
