/*
  styles.css — all styling for index.html.
  Layout: single narrow column, thumb-friendly; person cards stack; fixed action bar at the bottom.
  Colors are tokens on :root with a dark-mode override, so components never use literal colors.
*/
:root {
  --bg: #f6f4f1;
  --surface: #ffffff;
  --ink: #1d1a17;
  --muted: #6d655d;
  --line: #e4ded6;
  --accent: #c4271b;
  --accent-ink: #ffffff;
  --soft: #fbecea;
  --ok: #2f7d4f;
  --warn: #a35a00;
  --font-display: "Bricolage Grotesque", "Arial Black", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", system-ui, -apple-system, sans-serif;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151312; --surface: #201d1b; --ink: #f2ede8; --muted: #a59c93;
    --line: #35302c; --accent: #ef5a4c; --accent-ink: #1a0d0b; --soft: #3a1f1c;
    --ok: #6cc28f; --warn: #e2a54a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 17px; line-height: 1.4;
  padding-top: env(safe-area-inset-top, 0px); }
[hidden] { display: none !important; }
a { color: var(--accent); }

.wrap { max-width: 560px; margin: 0 auto; padding-inline: 16px; padding-block: 20px 120px; display: grid; gap: 16px; }

/* ---------- Header ---------- */
header { display: grid; gap: 4px; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
h1 { font-family: var(--font-display); font-weight: 800; font-size: 1.9rem; line-height: 1; margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
.count { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.status { font-size: 0.8rem; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; }
.status[data-state="saved"] { color: var(--ok); }
.status[data-state="offline"], .status[data-state="error"] { color: var(--warn); border-color: currentColor; }

/* ---------- Inputs & buttons ---------- */
input[type="text"] {
  flex: 1; min-width: 0; font: inherit; color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 10px; padding: 12px 14px;
}
input[type="text"]:focus { outline: none; border-color: var(--accent); }
button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: 0.35; cursor: default; }
.btn { display: inline-block; background: var(--accent); color: var(--accent-ink); font-weight: 700; padding: 12px 16px; white-space: nowrap; text-decoration: none; text-align: center; border-radius: 10px; }
.btn-ghost { background: transparent; color: var(--muted); padding: 8px 10px; font-size: 0.9rem; }
.btn-ghost:hover { color: var(--ink); }
.note { color: var(--muted); font-size: 0.85rem; margin: 0; }

/* ---------- Share link ---------- */
.share { display: grid; gap: 6px; }
.share-label { margin: 0; font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.share-row { display: flex; gap: 8px; }
.share-row input[type="text"] { font-size: 0.9rem; padding: 10px 12px; color: var(--muted); }
.share-status:empty { display: none; }

.new-person { display: flex; gap: 8px; }

/* ---------- Person cards ---------- */
#people { display: grid; gap: 12px; }
.person { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 14px 12px; display: grid; gap: 8px; }
.person-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.person-head h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.35rem; margin: 0; min-width: 0; overflow-wrap: anywhere; }
.person-actions { display: flex; gap: 2px; flex: none; }

.dup-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; background: var(--soft); border-radius: 10px; padding: 10px; }
.dup-form label { flex-basis: 100%; font-size: 0.9rem; font-weight: 700; }
.dup-form input[type="text"] { flex: 1 1 10em; }

/* Item row: [name + add-ons] [qty] [×] */
.items { list-style: none; margin: 0; padding: 0; display: grid; }
.item { display: grid; grid-template-columns: 1fr auto auto; align-items: start; column-gap: 8px; padding: 10px 2px; border-bottom: 1px dashed var(--line); }
.item:last-child { border-bottom: 0; }
.item-body { min-width: 0; display: grid; gap: 6px; }
.item-name { font-weight: 700; overflow-wrap: anywhere; padding-top: 4px; }

.mods { list-style: disc; margin: 0; padding-left: 1.2em; display: grid; gap: 2px; font-size: 0.95rem; }
.mods li::marker { color: var(--accent); }
.mods li span { overflow-wrap: anywhere; }
.mod-x { background: transparent; color: var(--muted); padding: 0 6px; font-size: 1rem; line-height: 1; }

.add-mod { position: relative; }
.add-mod input[type="text"] { width: 100%; padding: 6px 10px; font-size: 0.9rem; border-style: dashed; background: transparent; }

.qty { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; }
.qty button { background: transparent; color: var(--ink); width: 32px; height: 32px; border-radius: 999px; font-size: 1.1rem; line-height: 1; }
.qty output { min-width: 1.6em; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.item .remove { background: transparent; color: var(--muted); font-size: 1.3rem; line-height: 1; padding: 6px 4px 6px 6px; }
.empty { color: var(--muted); font-size: 0.95rem; padding: 4px 2px; margin: 0; }

/* ---------- Autocomplete ---------- */
.add-item { position: relative; display: flex; gap: 8px; }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 5; list-style: none; margin: 0; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgb(0 0 0 / 0.14);
  max-height: 260px; overflow-y: auto; }
.suggest li { padding: 10px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--soft); }
.tag { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); font-weight: 700; align-self: center; white-space: nowrap; }

/* ---------- Combined order ---------- */
.summary { background: var(--surface); border: 2px solid var(--accent); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; }
.summary h2 { font-family: var(--font-display); font-size: 1.2rem; margin: 0; }
.order { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; font-size: 1.2rem; }
.order-line { font-weight: 700; }
.order-line .n { color: var(--accent); font-variant-numeric: tabular-nums; }
.order .mods { font-size: 1.05rem; font-weight: 400; margin-top: 4px; }
.summary-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Footer & tip ---------- */
footer { display: grid; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.tip { display: grid; gap: 8px; justify-items: start; }
.tip p:first-child { margin: 0; }
.btn-tip { padding: 10px 16px; }

/* ---------- Bottom bar ---------- */
.bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--line); }
.bar-inner { max-width: 560px; margin: 0 auto; display: flex; gap: 8px; }
.bar .btn { flex: 1; }
.bar .btn-ghost { flex: none; }
.confirm { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 0.95rem; }

@media (prefers-reduced-motion: no-preference) {
  .item, .person { transition: background-color .15s, opacity .15s; }
}
