/* ============================================================
   Social Bingo — UI patterns
   New components (not yet in design-system.md §10 — document on merge)
   ============================================================ */

/* ---------- Filter chips ---------- */
.chips{ display:flex; gap:var(--sp-2); flex-wrap:wrap; }
.filter-chip{
  font-family:var(--font-body); font-size:13px; font-weight:800; letter-spacing:0.3px;
  background:var(--surface); border:1px solid var(--border); color:var(--text-muted);
  padding:9px 16px; border-radius:var(--radius-pill); cursor:pointer; min-height:38px;
  display:inline-flex; align-items:center; gap:6px;
  transition:background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.filter-chip:hover{ background:var(--surface-hover); color:var(--cream); }
.filter-chip[aria-pressed="true"]{ background:var(--magenta); border-color:var(--magenta); color:#fff; }

/* ---------- Tabs ---------- */
.tabs{ display:flex; gap:var(--sp-1); background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius-pill); padding:4px; }
.tabs a,
.tabs button{
  flex:1; background:transparent; border:none; cursor:pointer; padding:10px 14px; min-height:40px;
  border-radius:var(--radius-pill); font-family:var(--font-body); font-weight:800; font-size:13px;
  color:var(--text-muted); transition:background var(--dur-fast), color var(--dur-fast);
  /* Tabs are sometimes links (a real URL per tab, so they can be shared and
     the back button works) and sometimes buttons — both must look identical. */
  display:flex; align-items:center; justify-content:center; text-align:center; text-decoration:none;
}
.tabs a[aria-selected="true"],
.tabs button[aria-selected="true"]{ background:var(--surface-strong); color:var(--cream); }

/* ---------- Accordion (FAQ) ---------- */
.accordion{ border-top:1px solid var(--border); }
.accordion details{ border-bottom:1px solid var(--border); }
.accordion summary{
  list-style:none; cursor:pointer; padding:var(--sp-5) 0; display:flex; align-items:center;
  justify-content:space-between; gap:var(--sp-4);
  font-family:var(--font-display); font-weight:600; font-size:17px;
}
.accordion summary::-webkit-details-marker{ display:none; }
.accordion summary::after{
  content:"+"; font-family:var(--font-display); font-size:24px; color:var(--gold);
  transition:transform var(--dur-base) ease; flex-shrink:0; line-height:1;
}
.accordion details[open] summary::after{ transform:rotate(45deg); }
.accordion .acc-body{ padding:0 0 var(--sp-5); color:var(--text-muted); font-size:15px; line-height:1.65; }

/* ---------- Countdown ---------- */
.countdown{ display:inline-flex; align-items:center; gap:var(--sp-2);
  font-family:var(--font-display); font-weight:700; font-size:15px; color:var(--gold); }
.countdown .ring{
  width:22px; height:22px; border-radius:50%; border:2.5px solid rgba(255,203,61,0.25);
  border-top-color:var(--gold); animation:spin 1.2s linear infinite;
}

/* ---------- Toast ---------- */
.toast-stack{ position:fixed; bottom:var(--sp-6); left:50%; transform:translateX(-50%);
  z-index:var(--z-toast); display:flex; flex-direction:column; gap:var(--sp-2); width:min(400px, calc(100vw - 32px)); }
.toast{
  background:rgba(21,8,38,0.95); backdrop-filter:blur(10px);
  border:1px solid var(--border-strong); border-radius:var(--radius-md);
  padding:14px 16px; display:flex; align-items:center; gap:var(--sp-3);
  font-size:14px; font-weight:700; box-shadow:var(--shadow-md);
  animation:toastIn var(--dur-slow) var(--ease-pop);
}
.toast.is-success{ border-left:4px solid var(--teal); }
.toast.is-error{ border-left:4px solid var(--danger); }
@keyframes toastIn{ from{opacity:0; transform:translateY(16px);} to{opacity:1; transform:translateY(0);} }

/* ---------- Bottom sheet / modal ---------- */
.sheet-backdrop{
  position:fixed; inset:0; background:rgba(21,8,38,0.72); backdrop-filter:blur(4px);
  z-index:var(--z-sheet); display:none; align-items:center; justify-content:center; padding:var(--sp-4);
}
.sheet-backdrop.show{ display:flex; }
.sheet{
  background:linear-gradient(180deg, #2b0f4f, #1d0a36);
  border:1px solid var(--border-strong); border-radius:var(--radius-lg);
  padding:var(--sp-6); width:100%; max-width:420px; box-shadow:var(--shadow-lg);
  animation:sheetIn var(--dur-slow) var(--ease-pop); max-height:90vh; overflow-y:auto;
}
@keyframes sheetIn{ from{opacity:0; transform:translateY(24px) scale(0.97);} to{opacity:1; transform:none;} }
@media (max-width:520px){
  .sheet-backdrop{ align-items:flex-end; padding:0; }
  .sheet{ max-width:none; border-radius:var(--radius-lg) var(--radius-lg) 0 0;
    padding-bottom:calc(var(--sp-6) + env(safe-area-inset-bottom)); }
  @keyframes sheetIn{ from{transform:translateY(100%);} to{transform:none;} }
}

/* ---------- Skeleton ---------- */
.skeleton{
  background:linear-gradient(90deg, rgba(255,255,255,0.05), rgba(255,255,255,0.12), rgba(255,255,255,0.05));
  background-size:200% 100%; animation:shimmer 1.4s linear infinite; border-radius:var(--radius-sm);
}
@keyframes shimmer{ to{ background-position:-200% 0; } }

/* ---------- Empty state ---------- */
.empty{ text-align:center; padding:var(--sp-12) var(--sp-6); }
/* A stroke icon at the same size reads lighter than the emoji it replaced, so
   it gets the brand colour rather than sitting grey in the middle of nothing. */
.empty .emoji{ font-size:48px; margin-bottom:var(--sp-4); line-height:1; color:var(--gold); }
.empty h3{ margin-bottom:var(--sp-2); }
.empty p{ color:var(--text-muted); max-width:38ch; margin:0 auto var(--sp-5); font-size:14px; }

/* ---------- Bot badge (rules.md R-BOT-01 — always visible) ---------- */
.bot-badge{
  display:inline-flex; align-items:center; gap:var(--sp-1);
  font-size:9px; font-weight:800; letter-spacing:0.6px; text-transform:uppercase;
  background:var(--g); color:#fff; border-radius:var(--radius-pill); padding:2px 7px;
}

/* ---------- Cookie bar ---------- */
.cookie-bar{
  position:fixed; bottom:0; left:0; right:0; z-index:var(--z-toast);
  background:rgba(21,8,38,0.96); backdrop-filter:blur(12px); border-top:1px solid var(--border-strong);
  padding:var(--sp-4) var(--sp-6) calc(var(--sp-4) + env(safe-area-inset-bottom));
  display:flex; align-items:center; justify-content:center; gap:var(--sp-4); flex-wrap:wrap;
}
.cookie-bar p{ font-size:13px; color:var(--text-muted); max-width:60ch; }
.cookie-bar a{ color:var(--gold); }

/* ---------- Pagination ---------- */
.pagination{ display:flex; gap:var(--sp-2); justify-content:center; align-items:center; margin-top:var(--sp-10); }
.pagination a,.pagination span{
  min-width:42px; min-height:42px; display:inline-flex; align-items:center; justify-content:center;
  border-radius:var(--radius-md); border:1px solid var(--border); background:var(--surface);
  text-decoration:none; font-weight:800; font-size:14px; color:var(--text-muted);
}
.pagination a:hover{ background:var(--surface-hover); color:var(--cream); }
.pagination [aria-current="page"]{ background:var(--magenta); border-color:var(--magenta); color:#fff; }

/* ---------- Auth sheet (inline sign-in) ---------- */
.auth-sheet .sheet{ position:relative; }
.sheet-close{
  position:absolute; top:12px; right:12px; width:34px; height:34px; border-radius:50%;
  background:var(--surface); border:1px solid var(--border); color:var(--cream);
  font-size:20px; line-height:1; cursor:pointer;
}
.sheet-close:hover{ background:var(--surface-hover); }
.sheet-h{ font-family:var(--font-display); font-weight:700; font-size:24px; margin:0 0 var(--sp-2); }
.sheet-sub{ font-size:14px; color:var(--text-muted); line-height:1.55; margin-bottom:var(--sp-5); }
.sheet-foot{ margin-top:var(--sp-4); text-align:center; font-size:11px; color:var(--text-dim); line-height:1.6; }
.sheet-foot a{ color:var(--text-muted); }
.linkish{
  background:none; border:none; padding:0; cursor:pointer; color:var(--gold);
  font-family:var(--font-body); font-weight:800; font-size:inherit; text-decoration:underline;
}
.rejoin{
  display:flex; align-items:center; gap:var(--sp-3);
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius-md); padding:12px 14px; margin-bottom:var(--sp-5);
}
.rejoin .title{ font-size:13px; font-weight:800; }
.rejoin .sub{ font-size:12px; color:var(--text-muted); }
.code-status{ text-align:center; min-height:20px; margin:var(--sp-3) 0; font-size:13px; font-weight:700; }
.code-status.is-error{ color:var(--danger); }
.name-row{ position:relative; }
.name-state{ position:absolute; right:14px; top:38px; font-size:12px; font-weight:800; }
.name-state.is-ok{ color:var(--teal); }
.name-state.is-bad{ color:var(--danger); }

/* ---------- Error pages ----------
   A caller ball with the status code in it, because a 404 is a good place to
   sound like the rest of the site rather than like a server. */
.error-page{ text-align:center; padding:var(--sp-12) var(--sp-4) var(--sp-10); max-width:52ch; margin:0 auto; }
.error-page .ball{ margin:0 auto var(--sp-5); width:96px; height:96px; font-size:28px; }
.error-page h1{ margin-bottom:var(--sp-3); }
.error-page .lede{ margin-bottom:var(--sp-7); }
.error-page .cta-row{ display:flex; gap:var(--sp-3); flex-wrap:wrap; justify-content:center; }

/* ---------- Coming soon ----------
   One screen, centred, nothing to click. The caller ball carries the brand so
   the page still feels like the product rather than a holding message. */
.soon{
  min-height:clamp(420px, 68dvh, 720px);
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  text-align:center; padding:var(--sp-8) var(--sp-4); margin:0 auto;
  /* Wide enough that the headline lands on two lines on a desktop rather
     than stacking into four. balance evens them out from there. */
  max-width:46rem;
}
.soon-mark{ margin-bottom:var(--sp-8); animation:soonFloat 6s ease-in-out infinite; }
.soon-mark .ball{ width:86px; height:86px; font-size:28px; }
.soon h1{
  font-size:clamp(34px, 7vw, 58px); line-height:1.08; margin:0 0 var(--sp-5);
  text-wrap:balance;
}
.soon-sub{
  font-size:clamp(15px, 2.4vw, 18px); line-height:1.6; color:var(--text-muted);
  max-width:34rem; margin:0 0 var(--sp-10); text-wrap:balance;
}
.soon-note{
  font-size:12px; font-weight:800; letter-spacing:1.4px; text-transform:uppercase;
  color:var(--gold); margin:0;
}

@keyframes soonFloat{
  0%,100%{ transform:translateY(0) rotate(-4deg); }
  50%{ transform:translateY(-10px) rotate(4deg); }
}
@media (prefers-reduced-motion:reduce){
  .soon-mark{ animation:none; }
}

/* Staff-only error detail on the 500 page. Deliberately plain — it is a
   diagnostic, not part of the design. */
.staff-error{
  margin-top:var(--sp-8); padding:var(--sp-4); text-align:left;
  background:rgba(0,0,0,0.35); border:1px solid rgba(255,90,110,0.4); border-radius:var(--radius-md);
}
.staff-error .k{ font-size:10px; font-weight:800; letter-spacing:1px; text-transform:uppercase; color:var(--danger); margin-bottom:8px; }
.staff-error .msg{ font-family:ui-monospace,Menlo,monospace; font-size:13px; line-height:1.6; margin:0 0 6px; word-break:break-word; }
.staff-error .where{ font-family:ui-monospace,Menlo,monospace; font-size:11px; color:var(--text-dim); margin:0; }

/* ---------- Room hero: words left, action right ----------
   The join button is the point of the page. Stacked under the lede it sat
   below the fold on a laptop, which is a strange place for the only thing
   the page is asking you to do. */
.room-hero .hero-split{
  display:grid; grid-template-columns:1fr minmax(220px, 260px);
  gap:var(--sp-6); align-items:start;
}
.room-hero .hero-words h1{ margin:0 0 var(--sp-3); }
.room-hero .hero-words .lede{ margin:0; }
.room-hero .hero-action{ padding-top:var(--sp-2); }
.room-hero .hero-hint{
  font-size:12px; color:var(--text-dim); text-align:center; margin:var(--sp-3) 0 0;
}
@media (max-width:820px){
  .room-hero .hero-split{ grid-template-columns:1fr; gap:var(--sp-5); }
  .room-hero .hero-action{ padding-top:0; }
}

/* ---------- Tables in a room ----------
   A list of tables to pick from, not a data grid. Four columns on a desktop —
   name, status, seats, actions — collapsing to a stacked card on a phone so
   nothing scrolls sideways.

   Full width of its panel: the columns are sized so the actions sit hard
   right, which is where the eye goes to choose. */
.session-list{ list-style:none; margin:0; padding:0; width:100%; }

/* Fixed widths on the last two columns, not `auto`.
   With auto, a row holding one button sized differently from a row holding
   two, which dragged the seats column out of line between rows — the columns
   only line up if every row agrees on where they start. */
.session-row{
  display:grid;
  grid-template-columns:minmax(90px, 1fr) minmax(120px, 1.4fr) 88px 248px;
  align-items:center; gap:var(--sp-4);
  padding:var(--sp-4) 0;
  border-bottom:1px solid var(--border);
}
.session-row:last-child{ border-bottom:0; padding-bottom:0; }
.session-row:first-child{ padding-top:0; }

.session-row.is-mine .s-name b{ color:var(--gold); }
.session-row.is-empty{ display:block; padding:var(--sp-2) 0; }

.session-row .s-name{ display:flex; align-items:center; gap:var(--sp-2); flex-wrap:wrap; }
.session-row .s-name b{ font-family:var(--font-display); font-size:15px; }

.session-row .s-status{ font-size:13px; color:var(--text-muted); display:flex; align-items:center; gap:6px; }
.session-row .s-status .pulse{ flex-shrink:0; }

.session-row .s-players{ font-size:13px; color:var(--text-muted); white-space:nowrap; text-align:right; }
.session-row .s-players b{ color:var(--cream); font-size:15px; }
.session-row .s-players .muted{ margin-left:6px; }

/* Hard right, on ONE line. Wrapping made a row taller than its neighbour and
   threw every column out of alignment — the thing this list is meant to make
   easy is comparing tables at a glance. */
.session-row .s-actions{
  display:flex; align-items:center; justify-content:flex-end;
  gap:var(--sp-3); flex-wrap:nowrap;
}
.session-row .s-actions form{ margin:0; display:contents; }
.session-row .s-actions .btn{ white-space:nowrap; }

/* ---------- Phone: a card per table, not a squeezed row ----------
   Four columns at 375px is four cramped columns. Each table becomes its own
   card: what it is and how busy on the top line, what it is doing under it,
   and the actions as full-width targets you can hit with a thumb. */
@media (max-width:760px){
  .session-list{ display:flex; flex-direction:column; gap:var(--sp-3); }

  .session-row{
    grid-template-columns:1fr auto;
    grid-template-areas:
      "name    players"
      "status  status"
      "actions actions";
    gap:var(--sp-1) var(--sp-3);
    padding:var(--sp-4);
    border:1px solid var(--border);
    border-radius:var(--radius-lg);
    background:var(--surface);
  }
  .session-row:first-child,
  .session-row:last-child{ padding:var(--sp-4); }
  .session-row.is-mine{ border-color:var(--gold); }

  .session-row .s-name{ grid-area:name; }
  .session-row .s-name b{ font-size:16px; }
  .session-row .s-players{ grid-area:players; text-align:right; }
  .session-row .s-status{ grid-area:status; margin-top:2px; }

  .session-row .s-actions{
    grid-area:actions; margin-top:var(--sp-3);
    display:grid; grid-template-columns:1fr 1fr; gap:var(--sp-3);
  }
  /* Buttons fill their half — a thumb target, not a link to aim at. The
     ghost variant has no bounds of its own, which reads as a stray link
     floating in half a card rather than the button it is. */
  .session-row .s-actions .btn{ width:100%; }
  .session-row .s-actions .btn-ghost{
    border:1.5px solid var(--border); color:var(--cream);
  }
  .session-row .s-actions form{ display:block; }
  /* A lone action spans the width rather than sitting half-empty */
  .session-row .s-actions > :only-child{ grid-column:1 / -1; }

  .session-row.is-empty{ padding:var(--sp-4); }
}

/* The table somebody was invited to, so an invite link lands on something
   obvious rather than a list the friend has to read carefully. */
.session-row.is-invited{
  border-color:var(--gold);
  box-shadow:inset 0 0 0 1px rgba(255,203,61,0.35);
  background:rgba(255,203,61,0.06);
}

/* The invite field appears outside the game page too, so its styling cannot
   live only in game.css. */
.invite-link{ display:flex; gap:var(--sp-2); }
.invite-link input{
  flex:1; min-width:0; font-size:13px; padding:10px 12px; border-radius:var(--r-sm);
  border:1px solid var(--border); background:var(--surface-strong); color:var(--text);
}
