/* Potluck Clipboard: one bond sheet clipped to a manila board. Ballpoint blue for names and the primary
   action, red pen for open courses, pencil grey for meta. Standard controls throughout. */
:root {
  --board: #D8BE86;
  --board-grain: #CDB277;
  --sheet: #FFFEF9;
  --ink: #23211C;
  --pencil: #5E5A52;
  --rule: #D3DCEA;
  --rule-strong: #23211C;
  --blue: #1F3A93;
  --blue-hover: #172C72;
  --on-blue: #FFFFFF;
  --blue-wash: #E8EDFA;
  --red: #B3261E;
  --red-wash: #FCEBEA;
  --warn-bg: #FFF3D4;
  --warn-ink: #614300;
  --warn-line: #E8C76B;
  --field: #FFFFFF;
  --field-line: #8A8578;
  --clip: #8C939A;
  --clip-hi: #C9CED3;
  --clip-shadow: rgba(35, 33, 28, .28);
  --sheet-shadow: 0 1px 2px rgba(35, 33, 28, .18), 0 12px 28px -18px rgba(35, 33, 28, .45);

  --f-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-hand: "Caveat", "Bradley Hand", "Segoe Print", cursive;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --radius: 6px;
  color-scheme: light;
  accent-color: var(--blue);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--board-grain) var(--board); }
body {
  margin: 0;
  background: var(--board);
  color: var(--ink);
  font: 400 16px/1.5 var(--f-body);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
::selection { background: var(--blue-wash); color: var(--ink); }
input, select { caret-color: var(--blue); }
button, input, select { font: inherit; color: inherit; }
h1, h2, p { margin: 0; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 4px; }

.skip { position: absolute; left: var(--s4); top: -60px; z-index: 20; background: var(--blue); color: var(--on-blue); padding: var(--s2) var(--s4); border-radius: var(--radius); font-weight: 700; text-decoration: none; }
.skip:focus { top: calc(env(safe-area-inset-top, 0px) + var(--s2)); }

/* ---------- Board and sheet ---------- */
.board {
  min-height: 100vh;
  padding-block: calc(env(safe-area-inset-top, 0px) + 26px) calc(env(safe-area-inset-bottom, 0px) + 96px);
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
}
.sheet {
  position: relative;
  max-width: 1080px;
  margin: 0 auto;
  background: var(--sheet);
  border-radius: 3px;
  box-shadow: var(--sheet-shadow);
  padding: 44px var(--s4) var(--s5);
}
.clip {
  position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
  width: 148px; height: 40px; border-radius: 10px 10px 6px 6px;
  background: var(--clip);
  box-shadow: 0 3px 4px -1px var(--clip-shadow);
}
.clip span { position: absolute; left: 50%; top: 8px; transform: translateX(-50%); width: 46px; height: 10px; border-radius: 5px; background: var(--board); }

.sheet-head { display: grid; gap: var(--s2); padding-bottom: var(--s4); border-bottom: 2px solid var(--rule-strong); }
h1 { font-size: clamp(26px, 6.4vw, 38px); line-height: 1.1; font-weight: 700; letter-spacing: -0.015em; text-wrap: balance; }
.sub { color: var(--pencil); font-size: 15px; max-width: 52ch; }
.tally { font-size: 15px; color: var(--pencil); font-variant-numeric: tabular-nums; }
.tally b { color: var(--ink); font-weight: 700; font-size: 21px; }
.tally .open { color: var(--red); font-weight: 700; }

.banner { margin-top: var(--s4); padding: var(--s3) var(--s4); background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); border-radius: var(--radius); font-size: 15px; }

.sheet-body { display: grid; gap: var(--s6); margin-top: var(--s5); }
.lists { display: grid; gap: var(--s6); min-width: 0; }
.section-h { font-size: 19px; font-weight: 700; margin-bottom: var(--s3); display: flex; align-items: baseline; gap: var(--s2); }
.count { color: var(--pencil); font-weight: 400; font-size: 16px; font-variant-numeric: tabular-nums; }

/* ---------- Course table ---------- */
.table-wrap { overflow-x: auto; }
.courses { width: 100%; border-collapse: collapse; font-size: 16px; }
.courses thead th { text-align: left; font-size: 13px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--pencil); padding: 0 var(--s2) var(--s2) 0; border-bottom: 2px solid var(--rule-strong); }
.courses td, .courses tbody th { padding: 9px var(--s2) 9px 0; border-bottom: 1px solid var(--rule); vertical-align: top; text-align: left; line-height: 24px; }
.courses tfoot td { padding: 12px 0 4px; border-bottom: 0; }
.open-line { display: block; color: var(--pencil); font-style: italic; text-decoration: none; border-bottom: 1.5px dashed var(--field-line); padding-bottom: 6px; }
.open-line:hover { color: var(--blue); border-bottom-color: var(--blue); }
.courses tbody th { font-weight: 700; font-size: 15px; width: 88px; white-space: nowrap; }
.courses tbody tr:last-child > * { border-bottom-color: var(--rule); }
.courses tbody + tbody tr:first-child > * { border-top: 1px solid var(--rule); }
.courses .item { overflow-wrap: anywhere; }
.courses .who { width: 38%; }
.courses .gap th, .courses .gap td { color: var(--red); }
.courses .gap td { font-weight: 700; }
.courses .gap .hint { font-weight: 400; }
.courses .loading { color: var(--pencil); padding-block: var(--s4); }

.hand { font-family: var(--f-hand); font-weight: 700; font-size: 23px; line-height: 24px; color: var(--blue); overflow-wrap: anywhere; display: inline-block; vertical-align: top; }
.you { font-size: 13px; color: var(--pencil); font-weight: 400; font-family: var(--f-body); margin-left: var(--s1); white-space: nowrap; }

/* Signature: a name written onto the sheet appears left to right, once. */
.write-in { animation: write-in 900ms cubic-bezier(.16, 1, .3, 1) both; }
@keyframes write-in { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

/* ---------- Roster ---------- */
.roster { list-style: none; margin: 0; padding: 0; display: grid; }
.roster { grid-template-columns: minmax(0, 1fr); column-gap: var(--s4); }
.roster li { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; gap: 2px var(--s4); padding: 10px 0; border-bottom: 1px solid var(--rule); align-items: start; line-height: 24px; }
.roster .loading { color: var(--pencil); }
.roster li:first-child { border-top: 2px solid var(--rule-strong); }
.roster .what { color: var(--ink); font-size: 15px; overflow-wrap: anywhere; }
.roster .none { color: var(--pencil); font-style: italic; }
.roster .empty { grid-template-columns: 1fr; color: var(--pencil); }

/* ---------- Sign-up ---------- */
.signup { min-width: 0; border-top: 2px solid var(--rule-strong); padding-top: var(--s5); scroll-margin-top: var(--s5); }
.form-sub { color: var(--pencil); font-size: 15px; margin: calc(var(--s2) * -1) 0 var(--s4); }
form { display: grid; gap: var(--s5); }
.field { display: grid; gap: var(--s2); margin: 0; padding: 0; border: 0; min-width: 0; }
.field label, .field legend { font-weight: 700; font-size: 15px; padding: 0; margin-bottom: var(--s2); }
.field legend { float: left; width: 100%; }
.field legend + * { clear: both; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 40px !important;
  background-image: linear-gradient(45deg, transparent 50%, var(--pencil) 50%), linear-gradient(135deg, var(--pencil) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px; background-repeat: no-repeat;
}
input[type="text"], input:not([type]), select {
  width: 100%; min-height: 48px; padding: 0 var(--s3);
  background-color: var(--field); color: var(--ink);
  border: 1.5px solid var(--field-line); border-radius: var(--radius);
  font-size: 16px; transition: border-color 120ms ease, box-shadow 120ms ease;
}
input:hover, select:hover { border-color: var(--ink); }
input:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-wash); }
input[aria-invalid="true"] { border-color: var(--red); }
input:disabled, select:disabled { opacity: .5; cursor: not-allowed; }
.err { color: var(--red); font-size: 14px; font-weight: 700; }

.items { display: grid; gap: var(--s4); }
.item-row { display: grid; gap: var(--s2); }
.item-row + .item-row { padding-top: var(--s4); border-top: 1.5px dashed var(--rule); }
.item-fields { display: grid; grid-template-columns: minmax(0, 1fr) 48px; grid-template-areas: "name rm" "cat cat"; gap: var(--s2); }
.item-fields input { grid-area: name; }
.item-fields select { grid-area: cat; }
.item-fields .rm { grid-area: rm; }
.dup { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); padding: var(--s3); background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); border-radius: var(--radius); font-size: 15px; }
.dup p { flex: 1 1 14rem; min-width: 0; }
.dup-ok { font-size: 14px; color: var(--pencil); }

.check { display: flex; align-items: center; gap: var(--s3); min-height: 48px; cursor: pointer; font-weight: 700; font-size: 15px; }
.check input {
  appearance: none; -webkit-appearance: none; width: 24px; height: 24px; margin: 0; flex: none;
  border: 1.5px solid var(--field-line); border-radius: 4px; background: var(--field);
  display: grid; place-content: center; cursor: pointer; transition: background-color 120ms ease, border-color 120ms ease;
}
.check input::before { content: ""; width: 11px; height: 6px; border-left: 2.5px solid var(--on-blue); border-bottom: 2.5px solid var(--on-blue); transform: translateY(-2px) rotate(-45deg) scale(0); transition: transform 120ms ease; }
.check input:checked { background: var(--blue); border-color: var(--blue); }
.check input:checked::before { transform: translateY(-2px) rotate(-45deg) scale(1); }
.check:hover input { border-color: var(--ink); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 48px; padding: 0 var(--s4); border-radius: var(--radius);
  border: 1.5px solid transparent; background: none; cursor: pointer;
  font-weight: 700; font-size: 16px; text-decoration: none;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--blue); color: var(--on-blue); width: 100%; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-line { border-color: var(--field-line); color: var(--ink); justify-self: start; }
.btn-line:hover { border-color: var(--ink); }
.btn-quiet { color: var(--pencil); text-decoration: underline; text-underline-offset: 3px; justify-self: center; }
.btn-quiet:hover { color: var(--red); }
.btn-danger { background: var(--red); color: var(--sheet); }
.btn-danger:hover { filter: brightness(.92); }
.rm { width: 48px; height: 48px; padding: 0; border: 1.5px solid var(--field-line); border-radius: var(--radius); background: none; color: var(--pencil); display: grid; place-items: center; cursor: pointer; }
.rm:hover:not(:disabled) { color: var(--red); border-color: var(--red); }
.rm:disabled { opacity: .5; cursor: not-allowed; }
.ico { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.actions { display: grid; gap: var(--s3); }
.status { font-weight: 700; color: var(--blue); font-size: 15px; }
.status.bad { color: var(--red); }
.status:empty { display: none; }
.confirm { display: grid; gap: var(--s3); padding: var(--s4); border: 1.5px solid var(--red); border-radius: var(--radius); background: var(--red-wash); }
.confirm-row { display: flex; flex-wrap: wrap; gap: var(--s2); }
.notice { padding: var(--s4); border: 1.5px dashed var(--field-line); border-radius: var(--radius); color: var(--pencil); font-size: 15px; }
.notice strong { display: block; color: var(--ink); margin-bottom: var(--s1); }

.sheet-foot { margin-top: var(--s6); padding-top: var(--s3); border-top: 1px solid var(--rule); color: var(--pencil); font-size: 14px; }

/* ---------- Pinned action (phones) ---------- */
.pin {
  position: fixed; z-index: 10;
  left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px));
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  min-height: 52px; display: grid; place-items: center; border-radius: var(--radius);
  background: var(--blue); color: var(--on-blue); font-weight: 700; font-size: 17px; text-decoration: none;
  box-shadow: 0 6px 16px -8px rgba(0, 0, 0, .5);
  transition: transform 160ms ease, opacity 160ms ease;
}
.pin:hover { background: var(--blue-hover); }
.pin.away { transform: translateY(140%); opacity: 0; pointer-events: none; }

/* ---------- Wider screens ---------- */
@media (min-width: 640px) {
  .board { padding-top: calc(env(safe-area-inset-top, 0px) + 40px); }
  .sheet { padding: 52px var(--s6) var(--s6); }
  .item-fields { grid-template-columns: minmax(0, 1fr) 150px 48px; grid-template-areas: "name cat rm"; }
  /* One shared name track for every row, so the items column lines up down the roster. */
  .roster { grid-template-columns: fit-content(18rem) minmax(0, 1fr); }
  .roster li.empty, .roster li.loading { grid-template-columns: none; }
  .roster li.empty > *, .roster li.loading > * { grid-column: 1 / -1; }
}
@media (min-width: 1024px) {
  .board { padding-top: calc(env(safe-area-inset-top, 0px) + 30px); padding-bottom: 56px; }
  .sheet { padding: 44px var(--s7) var(--s6); }
  .sheet-body { margin-top: var(--s4); }
  form { gap: 20px; }
  .sheet-body { grid-template-columns: minmax(0, 1fr) 360px; gap: var(--s7); align-items: start; }
  .signup { border-top: 0; padding-top: 0; border-left: 1px solid var(--rule); padding-left: var(--s6); }
  .item-fields { grid-template-columns: minmax(0, 1fr) 48px; grid-template-areas: "name rm" "cat cat"; }
  .pin { display: none; }
}

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