/* Fonts are bundled (no external requests): Young Serif for headings, Figtree for text. Both SIL OFL. */
@font-face {
  font-family: "Young Serif";
  src: url("/fonts/young-serif-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Figtree";
  src: url("/fonts/figtree-latin-wght-normal.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- themes: each one is a tablecloth ---------- */
:root,
[data-theme="picnic"] {
  --bg: #fbf9f7; --surface: #ffffff; --ink: #251c1b; --muted: #6b5e5c; --line: #e9dfdc;
  --accent: #c62f2f; --accent-ink: #ffffff; --accent-text: #b02525; --tint: #fbe9e7;
  --danger: #b3261e; --cloth: #c62f2f; --cloth-base: #ffffff; color-scheme: light;
}
[data-theme="blueberry"] {
  --bg: #f6f8fc; --surface: #ffffff; --ink: #17223a; --muted: #55617a; --line: #dbe2ef;
  --accent: #2b59b0; --accent-ink: #ffffff; --accent-text: #24509f; --tint: #e4ecfa;
  --danger: #b3261e; --cloth: #2b59b0; --cloth-base: #ffffff; color-scheme: light;
}
[data-theme="basil"] {
  --bg: #f5f9f5; --surface: #ffffff; --ink: #17281d; --muted: #566b5c; --line: #dae7dc;
  --accent: #2b7a48; --accent-ink: #ffffff; --accent-text: #256b3e; --tint: #e0f1e5;
  --danger: #b3261e; --cloth: #2b7a48; --cloth-base: #ffffff; color-scheme: light;
}
[data-theme="lemon"] {
  --bg: #fffdf3; --surface: #ffffff; --ink: #2a2412; --muted: #6e6549; --line: #efe6bd;
  --accent: #f0b400; --accent-ink: #2a2412; --accent-text: #7d5800; --tint: #fff1bd;
  --danger: #b3261e; --cloth: #f0b400; --cloth-base: #ffffff; color-scheme: light;
}
[data-theme="pumpkin"] {
  --bg: #fbf6f0; --surface: #ffffff; --ink: #2b1c10; --muted: #705a48; --line: #ecdccb;
  --accent: #b84f08; --accent-ink: #ffffff; --accent-text: #a24504; --tint: #fbe6d2;
  --danger: #b3261e; --cloth: #d9711f; --cloth-base: #ffffff; color-scheme: light;
}
[data-theme="plum"] {
  --bg: #1a1223; --surface: #241a30; --ink: #f4ecff; --muted: #b7a8ca; --line: #3a2c4b;
  --accent: #ff9f43; --accent-ink: #1a1223; --accent-text: #ffb066; --tint: #3a2a4d;
  --danger: #ff8a80; --cloth: #9a5ce0; --cloth-base: #1a1223; color-scheme: dark;
}
[data-theme="evergreen"] {
  --bg: #f7f8f4; --surface: #ffffff; --ink: #1c2a20; --muted: #5b6b5f; --line: #dfe5da;
  --accent: #a5202e; --accent-ink: #ffffff; --accent-text: #941b28; --tint: #f7e0e2;
  --danger: #b3261e; --cloth: #1f6b45; --cloth-base: #ffffff; color-scheme: light;
}
[data-theme="night"] {
  --bg: #0f141b; --surface: #171e28; --ink: #e9eef5; --muted: #9fadbd; --line: #263140;
  --accent: #79b6ff; --accent-ink: #0b1422; --accent-text: #8cc2ff; --tint: #1c2a3d;
  --danger: #ff8a80; --cloth: #3f78c4; --cloth-base: #0f141b; color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.5 "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
h1, h2, h3 {
  font-family: "Young Serif", Georgia, "Times New Roman", serif;
  font-weight: 400;
  line-height: 1.15;
  margin: 0;
}
a { color: var(--accent-text); }
.page { max-width: 640px; margin: 0 auto; padding-bottom: 56px; }

/* ---------- hero: the tablecloth, or the banner photo ---------- */
.hero {
  height: clamp(170px, 42vw, 260px);
  background-color: var(--cloth-base);
  background-image:
    repeating-linear-gradient(90deg, color-mix(in srgb, var(--cloth) 38%, transparent) 0 20px, transparent 20px 40px),
    repeating-linear-gradient(0deg, color-mix(in srgb, var(--cloth) 38%, transparent) 0 20px, transparent 20px 40px);
}
.hero.has-banner { background-size: cover; background-position: center; }

/* ---------- place card: title, date, location ---------- */
.placecard {
  position: relative;
  margin: -48px 16px 0;
  padding: 22px 22px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 18px 30px -22px rgba(20, 10, 10, 0.5);
}
.placecard h1 { font-size: clamp(28px, 7.5vw, 38px); overflow-wrap: anywhere; }
.tagline { margin: 6px 0 0; color: var(--muted); }
.when { margin: 18px 0 0; padding-top: 16px; border-top: 1px dashed var(--line); }
.when-date { margin: 0; font-weight: 700; font-size: 20px; }
.when-meta { margin: 2px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.intro { margin: 22px 22px 0; white-space: pre-line; overflow-wrap: anywhere; }

/* ---------- sections ---------- */
.section { margin: 38px 16px 0; }
.section > h2 { font-size: 25px; margin: 0 6px 4px; }
.section-note { margin: 0 6px 14px; color: var(--muted); font-size: 15px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
}

/* ---------- forms ---------- */
.field { display: block; margin: 0 0 18px; }
.label { display: block; font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.hint { display: block; color: var(--muted); font-size: 14px; margin-top: 6px; }
input[type="text"], input[type="tel"], input[type="password"], input[type="date"], input[type="time"], select, textarea {
  width: 100%;
  min-height: 48px;
  font: inherit;
  font-size: 16px; /* 16px stops iOS zooming on focus */
  color: var(--ink);
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
textarea { min-height: 104px; line-height: 1.4; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: var(--accent);
}
.note { min-height: 1.4em; margin: 6px 0 0; font-size: 14px; color: var(--muted); }
.note.ok { color: var(--accent-text); font-weight: 600; }
.note.err { color: var(--danger); font-weight: 600; }

/* yes / no switch */
.switch { position: relative; display: flex; align-items: center; gap: 14px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.track {
  position: relative; flex: none; width: 96px; height: 46px; border-radius: 999px;
  background: var(--line); transition: background 0.2s;
}
.track .txt { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; font-weight: 700; font-size: 15px; transition: opacity 0.15s; }
.track .txt-on { left: 17px; color: var(--accent-ink); opacity: 0; }
.track .txt-off { right: 18px; color: var(--muted); }
.thumb {
  position: absolute; top: 4px; left: 4px; width: 38px; height: 38px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); transition: transform 0.2s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track .thumb { transform: translateX(50px); }
.switch input:checked + .track .txt-on { opacity: 1; }
.switch input:checked + .track .txt-off { opacity: 0; }
.switch input:focus-visible + .track { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 3px; }
.switch-label { font-weight: 600; }

/* buttons */
.btn {
  appearance: none; border: 0; cursor: pointer; width: 100%;
  min-height: 52px; padding: 0 26px; border-radius: 999px;
  font: inherit; font-weight: 700;
  background: var(--accent); color: var(--accent-ink);
}
.btn:disabled { opacity: 0.6; cursor: default; }
.btn:focus-visible, .btn-quiet:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 3px; }
.btn-quiet {
  appearance: none; cursor: pointer; width: auto; min-height: 44px; padding: 0 18px;
  border-radius: 999px; font: inherit; font-weight: 600;
  background: transparent; color: var(--ink); border: 1.5px solid var(--line);
  display: inline-flex; align-items: center; text-decoration: none;
}
.btn-quiet.danger { color: var(--danger); }
.btn-small { min-height: 38px; padding: 0 14px; font-size: 15px; }

/* ---------- sign-up sheet ---------- */
.sheet { list-style: none; margin: 0; padding: 0; }
.sheet li { padding: 14px 4px; border-bottom: 1px solid var(--line); }
.sheet li:last-child { border-bottom: 0; }
.sheet .who { font-weight: 700; overflow-wrap: anywhere; }
.sheet .dish { color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.empty { margin: 0; padding: 6px 4px; color: var(--muted); }

/* ---------- the bin ---------- */
.bin { display: grid; gap: 10px; }
.bin details { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.bin summary { list-style: none; cursor: pointer; display: flex; gap: 10px; align-items: center; padding: 14px 16px; font-weight: 700; }
.bin summary::-webkit-details-marker { display: none; }
.bin summary::after {
  content: ""; margin-left: auto; flex: none; width: 8px; height: 8px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); transition: transform 0.2s;
}
.bin details[open] summary::after { transform: rotate(225deg); }
.bin summary:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 14px; }
.bin-body { padding: 0 16px 16px; white-space: pre-line; overflow-wrap: anywhere; }
.kind { flex: none; font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--tint); color: var(--accent-text); }

.foot { margin: 40px 16px 0; text-align: center; font-size: 14px; color: var(--muted); }

/* ---------- admin ---------- */
.bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 22px 16px 0; }
.bar h1 { font-size: 28px; margin-right: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card h2 { font-size: 22px; margin-bottom: 14px; }
.card h3 { font-family: "Figtree", system-ui, sans-serif; font-weight: 700; font-size: 16px; margin: 20px 0 8px; }
.stack > * + * { margin-top: 14px; }
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.swatch {
  appearance: none; cursor: pointer; padding: 0; overflow: hidden; text-align: left;
  font: inherit; font-size: 14px; font-weight: 600;
  background: var(--surface); color: var(--ink);
  border: 2px solid var(--line); border-radius: 12px;
}
.swatch .cloth {
  display: block; height: 34px; background-color: var(--cloth-base);
  background-image:
    repeating-linear-gradient(90deg, color-mix(in srgb, var(--cloth) 38%, transparent) 0 8px, transparent 8px 16px),
    repeating-linear-gradient(0deg, color-mix(in srgb, var(--cloth) 38%, transparent) 0 8px, transparent 8px 16px);
}
.swatch .name { display: block; padding: 6px 9px 7px; }
.swatch[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.swatch:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.banner-preview { width: 100%; height: 150px; border-radius: 12px; border: 1px solid var(--line); background-size: cover; background-position: center; margin-bottom: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.editor { border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; background: var(--bg); }
.editor .field { margin-bottom: 12px; }
.rsvp { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rsvp:last-child { border-bottom: 0; }
.rsvp .who { font-weight: 700; overflow-wrap: anywhere; }
.rsvp .phone, .rsvp .dish { color: var(--muted); font-size: 15px; overflow-wrap: anywhere; white-space: pre-line; }
.pill { font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: 999px; }
.pill.yes { background: var(--tint); color: var(--accent-text); }
.pill.no { background: var(--line); color: var(--muted); }
#toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 10; max-width: 90vw;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 12px 20px; border-radius: 999px; font-weight: 600;
  background: var(--ink); color: var(--bg);
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); color: #fff; }

@media (max-width: 460px) {
  .swatches { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 340px) {
  .grid2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
