/*
 * groupchat layout, skinned with the 2222 theme pack (/theme/theme.css, copied from
 * ~/git/second-stop/app/static/theme). Burnt-orange grain, cream ink, Crimson Pro.
 * Component names (.login, .card, .chip, .candidate-actions, dialogs, .linkbtn)
 * follow 2222's style.css so the two apps read as siblings.
 */

* { box-sizing: border-box; }
body {
  margin: 0;
  font-size: 16px;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button, input, select, textarea { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
/* No double-tap zoom or tap delay: every tap is a tap. */
html { touch-action: manipulation; }
.hidden { display: none !important; }

header, main, footer { width: min(560px, calc(100% - 32px)); margin: 0 auto; }
header { height: 60px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--veil-2); }
.wordmark { color: var(--ink); text-decoration: none; font-size: 18px; font-weight: 600; letter-spacing: -.3px; font-style: italic; }
.header-actions { display: flex; align-items: center; gap: 8px; }
main { min-height: 60vh; padding-top: 24px; }
footer { padding: 32px 0 24px; }
footer p { margin: 0; font-size: 12px; color: var(--ink-4); font-style: italic; }

h1 { font-size: 30px; line-height: 1.15; font-weight: 400; letter-spacing: -.5px; margin: 0 0 6px; overflow-wrap: anywhere; }
h2 { font-size: 22px; line-height: 1.3; font-weight: 500; letter-spacing: -.3px; margin: 0 0 8px; }
.login h1 { font-style: italic; }
p { margin: 0 0 12px; }

/* ---------- buttons (2222: cream primary, quiet outline, accent for the one big action) ---------- */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: var(--r-sm); background: var(--cream); color: var(--ground-1);
  padding: 11px 16px; font-weight: 500; cursor: pointer; text-decoration: none; line-height: 1.2;
}
button:hover, .button:hover { background: var(--cream-bright); }
button:disabled { opacity: .45; cursor: default; }
.quiet { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--veil-3); font-weight: 400; }
.quiet:hover { background: var(--veil-2); }
header .quiet { padding: 7px 12px; font-size: 15px; }
.linkbtn { background: transparent; box-shadow: none; color: var(--muted); font-size: 14px; font-weight: 300; padding: 6px 2px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--veil-3); }
.linkbtn:hover { background: transparent; color: var(--ink); }
.linkbtn.danger { color: var(--danger); }
.close { background: transparent !important; box-shadow: none !important; color: var(--muted); font-size: 28px; line-height: 1; padding: 0 4px; font-weight: 300; }

/* ---------- text ---------- */
.muted { color: var(--muted); font-size: 15px; }
.fine { color: var(--ink-3); font-size: 13px; font-style: italic; margin: 0; }
.fine.as { margin-top: 14px; text-align: center; font-size: 15px; }
.fine.as .linkbtn { font-size: 15px; font-style: italic; }
.privacy { margin-top: 18px; text-align: center; color: var(--ink-4); }
.error { color: var(--danger); font-size: 14px; white-space: pre-line; margin: 10px 0 0; }
.error:empty { display: none; }

/* ---------- onboarding column (2222 .login) ---------- */
.login { max-width: 360px; margin: 24px auto 48px; }
.login form, .profile { display: grid; gap: 4px; margin-top: 20px; }
dialog .profile { margin-top: 8px; }
label { display: block; font-size: 15px; margin: 16px 0 7px; color: var(--ink-2); }
input, textarea {
  width: 100%; padding: 14px 15px; font-size: 19px; /* ≥16px stops iOS zooming on focus */
  background: var(--veil-2); border: 1px solid var(--veil-3); border-radius: var(--r-sm); color: var(--ink);
}
textarea { resize: vertical; min-height: 72px; line-height: 1.4; }
input::placeholder, textarea::placeholder { color: var(--ink-4); }
input:focus, textarea:focus { outline: none; border-color: var(--veil-4); }
/* Keep autofilled fields on-theme (browsers force light backgrounds). */
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink); caret-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px var(--veil-2) inset; box-shadow: 0 0 0 1000px var(--veil-2) inset;
  border-color: var(--veil-3); transition: background-color 9999s ease-out 0s;
}
.login form > button[type=submit], .profile > button[type=submit], button.block, .button.block {
  margin-top: 20px; width: 100%; min-height: 58px; padding: 14px 16px; font-size: 20px;
}

/* ---------- privacy & terms (same shape as 2222's /privacy) ---------- */
.policy { max-width: 560px; }
.policy h2 { margin-top: 28px; }
.policy p { font-size: 17px; color: var(--ink-2); }
.policy .back { margin-top: 28px; }
.privacy a { color: inherit; }

/* ---------- list label + live status ---------- */
.list-label { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 22px 0 8px; font-size: 13px; color: var(--muted); }
.list-label b { font-weight: 500; color: var(--ink-2); font-style: italic; }
.tiny { font-size: 12px; font-style: italic; display: inline-flex; align-items: center; gap: 6px; }
.tiny.ok { color: var(--accent); }
.tiny.bad { color: var(--danger); }
.spinner { display: inline-block; width: 10px; height: 10px; border: 2px solid var(--veil-3); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- rows (2222 .card: hairline-separated, whole row tappable) ---------- */
.list { border-top: 1px solid var(--veil-2); }
.card { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 15px 2px; border-bottom: 1px solid var(--veil-2); color: inherit; text-decoration: none; }
.card.tap { cursor: pointer; }
.card.tap:hover { background: var(--veil-1); }
.card.tap:active { background: var(--veil-2); }
.card .who { flex: 1; min-width: 0; }
.where { font-weight: 500; font-size: 21px; line-height: 1.25; letter-spacing: -.2px; margin: 0; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.what { font-size: 16px; line-height: 1.4; color: var(--muted); margin: 1px 0 0; font-variant-numeric: tabular-nums; }
.chev { color: var(--ink-4); font-size: 24px; line-height: 1; }
.card.tap:hover .chev { color: var(--accent); }
/* 2222's in-row status word: plain italic text, not theme.css's outlined chip. */
.chip { font-size: 15px; font-style: italic; color: var(--ink-3); white-space: nowrap; border: 0; background: transparent; padding: 0; border-radius: 0; }
.card .row-actions { flex-basis: 100%; display: flex; gap: 20px; }
.card .row-actions .linkbtn { font-size: 17px; padding: 8px 0; }
.card.fresh { animation: fresh 2.4s ease-out; }
@keyframes fresh { 0%, 35% { background: var(--accent-soft); } 100% { background: transparent; } }
.empty { padding: 18px 2px; color: var(--muted); font-style: italic; font-size: 15px; }

.avatar {
  flex: none; width: 42px; height: 42px; border-radius: 50%;
  display: inline-grid; place-items: center; object-fit: cover;
  background: var(--ground-4); color: var(--cream); box-shadow: inset 0 0 0 .8px var(--veil-4);
  font-size: 16px; font-style: italic; font-weight: 500; letter-spacing: .02em;
}
.avatar.ghost { background: var(--veil-2); color: var(--ink-3); font-style: normal; font-size: 18px; }


/* ---------- scan: the QR stays put at the top of the room ---------- */
.scan { text-align: center; }
.scan h1 { font-style: italic; margin-top: 4px; font-size: 32px; }
.scan .tiny { justify-content: center; min-height: 18px; margin: 4px 0 0; color: var(--muted); }
.qr { display: flex; justify-content: center; padding: 10px 0 2px; }
.qr svg { width: min(280px, 74vw); height: auto; background: #fff; border-radius: 12px; padding: 10px; box-shadow: 0 2px 12px #0006; }

/* "Add someone who isn't here": reads as one more row in the list. */
.addrow {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 2px; border-radius: 0;
  background: transparent; color: var(--ink-2); font-weight: 400; font-style: italic; font-size: 18px; min-height: 64px;
  border-bottom: 1px solid var(--veil-2); justify-content: flex-start;
}
.addrow:hover { background: var(--veil-1); color: var(--ink); }
.or { text-align: center; margin: 14px 0 -8px; }

/* ---------- pinned action bar (appears once there's someone to text) ---------- */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 12px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--grain), linear-gradient(180deg, var(--ground-2), var(--ground-1));
  border-top: 1px solid var(--veil-3); box-shadow: 0 -10px 30px #0006;
  animation: barIn .25s ease-out;
}
.bar-inner { width: min(560px, 100%); margin: 0 auto; display: flex; gap: 8px; }
.actionbar .fine { width: min(560px, 100%); margin: 7px auto 0; text-align: center; }
.actionbar .primary { flex: 1; background: var(--accent); color: var(--ground-0); border-radius: var(--r-pill); font-size: 19px; min-height: 56px; padding: 14px 16px; }
.actionbar .primary:hover { background: var(--accent); filter: brightness(1.07); }
.actionbar .quiet { border-radius: var(--r-pill); min-height: 56px; padding: 14px 16px; font-size: 16px; white-space: nowrap; }
.actionbar .button.quiet { color: var(--ink); }
.bar-note { width: min(560px, 100%); margin: 0 auto 10px; text-align: center; font-size: 16px; font-style: italic; color: var(--cream); }
.bar-note:empty, .actionbar .fine:empty { display: none; }
.actionbar .fine a { color: var(--ink-2); }
body.with-bar main { padding-bottom: 150px; }
@keyframes barIn { from { transform: translateY(100%); } }
.candidate-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; justify-content: center; }

/* ---------- dialogs (raised grain surfaces) ---------- */
dialog {
  color: var(--ink); width: min(440px, calc(100% - 24px)); max-height: 90dvh; overflow: auto; padding: 22px;
  background: var(--ground-2); background-image: var(--grain), linear-gradient(180deg, var(--ground-3), var(--ground-2));
  border: 1px solid var(--veil-3); border-radius: var(--r-lg); box-shadow: 0 24px 80px #0007;
}
dialog::backdrop { background: #000a; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 4px; }
.dialog-head h2 { margin: 0; }

/* ---------- "Didn't work?" sheet ---------- */
#help h3 { font-size: 16px; font-weight: 500; margin: 20px 0 8px; }
#help h3:first-of-type { margin-top: 10px; }
.help-list { display: grid; gap: 8px; }
.help-list .quiet { width: 100%; min-height: 52px; justify-content: space-between; font-size: 17px; padding: 12px 16px; color: var(--ink); }
.help-list small { font-family: var(--font-mono); font-size: 11px; color: var(--ink-4); }
#help .fine { margin: 0 0 10px; font-size: 14px; }
#help .fine.after { margin: 10px 0 0; }
.conn { margin-top: 22px; }
.conn > summary { font-size: 12px; color: var(--ink-4); font-style: italic; cursor: pointer; }
.actionbar .fine .linkbtn { font-size: 13px; padding: 0; color: var(--ink-2); }

/* ---------- test lab ---------- */
.lab { margin: 40px 0 0; padding: 0; }
.lab > summary { font-size: 12px; color: var(--ink-4); cursor: pointer; font-style: italic; text-align: center; list-style: none; }
.lab > summary::-webkit-details-marker { display: none; }
.lab[open] > summary { color: var(--ink-2); }
.lab-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.lab-btns .quiet { font-size: 14px; padding: 8px 12px; }
.debug { font-size: 11px; white-space: pre-wrap; word-break: break-all; background: var(--veil-1); border: 1px solid var(--veil-2); border-radius: var(--r-sm); padding: 10px; margin: 0; color: var(--ink-2); }

@media (max-width: 400px) {
  h1 { font-size: 27px; }
  .actionbar .quiet { padding: 13px 12px; }
}
@media (prefers-reduced-motion: reduce) { .spinner, .card.fresh, .actionbar { animation: none; } }
