/* Shared application chrome. Tokens live in tokens.css; see docs/STYLE.md. */
@import url("tokens.css");
@import url("cards.css");

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--step-0)/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0;
}
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-1); }

a { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* --- app frame --- */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-5);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar .brand {
  font-family: var(--font-display);
  font-size: var(--step-1);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.topbar .brand small {
  display: block;
  font-family: var(--font-body);
  font-size: var(--step--1);
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-muted);
}
.topbar .spacer { flex-grow: 1; }
.topbar .who { color: var(--text-muted); font-size: var(--step--1); }

main { padding: var(--s-6) var(--s-5); max-width: 940px; margin: 0 auto; }

/* --- controls --- */
button, .button {
  font: inherit;
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: var(--s-2) var(--s-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .button:hover { border-color: var(--text-muted); }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
button.primary:hover { filter: brightness(1.08); }
button.quiet { background: transparent; border-color: transparent; color: var(--text-muted); }
button:disabled { opacity: 0.5; cursor: default; }

label { display: block; font-size: var(--step--1); color: var(--text-muted); margin-bottom: var(--s-1); }
input[type=email], input[type=password], input[type=text], select {
  font: inherit;
  width: 100%;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  background: var(--surface);
  color: var(--text);
}
.field { margin-bottom: var(--s-4); }

/* --- panels --- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: var(--s-5);
}
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.row { display: flex; align-items: center; gap: var(--s-3); }

/* A plain notice is neutral rather than bare: padding with no background
   reads as a box somebody forgot to colour in. */
.notice { padding: var(--s-3); border-radius: var(--r-2); font-size: var(--step--1);
          background: var(--surface-2); border: 1px solid var(--line); }
.notice.bad { background: #f6dcd9; color: #7d1f19; border: 1px solid #e0b3ad; }
.notice.good { background: #dfe9d4; color: #35501f; border: 1px solid #bed0ab; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .notice.bad { background: #3a1f1c; color: #f2c3bd; border-color: #5d2f29; }
  :root:not([data-theme="light"]) .notice.good { background: #24301b; color: #cbe0b4; border-color: #3c4f2c; }
}

.muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); font-size: var(--step--1); }

/* --- lobby --- */
.games { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-3); }
.game {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: var(--r-2);
}
.game.your-turn { border-left-color: var(--accent); }
.game.finished { opacity: 0.72; }
.game .meta { flex-grow: 1; min-width: 0; }
.game .name { font-family: var(--font-display); font-size: var(--step-1); letter-spacing: 0.03em; }
.game .sub { font-size: var(--step--1); color: var(--text-muted); }
.badge {
  font-family: var(--font-display); font-size: var(--step--1);
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px var(--s-2); border-radius: var(--r-1);
  background: var(--surface-2); color: var(--text-muted);
}
.badge.turn { background: var(--accent); color: var(--accent-ink); }

.teams { display: flex; gap: var(--s-1); }
.pip { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,.3); }

.empty { text-align: center; padding: var(--s-7) var(--s-4); color: var(--text-muted); }

@media (max-width: 560px) {
  main { padding: var(--s-4) var(--s-3); }
  .game { flex-wrap: wrap; }
}

/* --- game setup roster --- */
.roster { border: 1px solid var(--line); border-radius: var(--r-2); padding: var(--s-3); margin: 0; }
.roster legend { font-family: var(--font-display); font-size: var(--step--1);
                 letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted);
                 padding: 0 var(--s-2); }
.seat { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) 0; }
.seat + .seat, .picker + .seat { border-top: 1px solid var(--line); }
.seat .pip { flex: 0 0 auto; width: 16px; height: 16px; }
.seat .team { flex-grow: 1; font-family: var(--font-display); letter-spacing: .04em; }
.seat .role { flex: 0 0 auto; }
.seat select { width: auto; min-width: 130px; }
.seat.empty-seat .team { color: var(--text-muted); }
.seat .tag { font-size: var(--step--1); color: var(--text-muted); }

/* The new-game seat: which side it is sits with the team's name, and who
   plays it sits on the right with a button to change that. */
.seat .side { flex: 0 0 9rem; display: flex; flex-direction: column; line-height: 1.25; }
.seat .side .team { flex-grow: 0; }
.seat .holder { flex: 1 1 auto; min-width: 0; text-align: right; }
.seat .holder .muted { font-size: var(--step--1); }
.seat.open { background: var(--surface-2); margin: 0 calc(-1 * var(--s-3));
             padding-left: var(--s-3); padding-right: var(--s-3); }
.seat .change { flex: 0 0 auto; padding: var(--s-1) var(--s-3); font-size: var(--step--1); }

/* The picker that opens under a seat: what kind of player, then which. */
.picker { background: var(--surface-2); margin: 0 calc(-1 * var(--s-3));
          padding: var(--s-2) var(--s-3) var(--s-4); }
.picker .segmented { margin-bottom: var(--s-3); }
.picker .hint { font-size: var(--step--1); color: var(--text-muted); margin: 0 0 var(--s-3); }
.picker h4 { font-family: var(--font-display); font-weight: 500; font-size: var(--step--1);
             letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted);
             margin: var(--s-3) 0 var(--s-2); }
.picker input[type=search] { font: inherit; width: 100%; padding: var(--s-2) var(--s-3);
             border: 1px solid var(--line-strong); border-radius: var(--r-2);
             background: var(--surface); color: var(--text); }
.options { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.options.list { flex-direction: column; flex-wrap: nowrap; max-height: 14rem; overflow-y: auto;
                margin-top: var(--s-2); }
.option { text-transform: none; letter-spacing: 0; font-family: var(--font-body);
          text-align: left; display: flex; flex-direction: column; line-height: 1.3;
          padding: var(--s-2) var(--s-3); }
.option small { color: var(--text-muted); font-size: var(--step--1); }
.option[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.picker .none-found { font-size: var(--step--1); color: var(--text-muted); padding: var(--s-2) 0; }

/* Click-to-choose: every option on screen, the chosen one filled. */
.segmented { display: flex; flex-wrap: wrap; gap: 0; }
.segmented button { border-radius: 0; margin-left: -1px; line-height: 1.25;
                    display: inline-flex; flex-direction: column; align-items: center; }
.segmented button:first-child { border-radius: var(--r-2) 0 0 var(--r-2); margin-left: 0; }
.segmented button:last-child { border-radius: 0 var(--r-2) var(--r-2) 0; }
.segmented button small { font-family: var(--font-body); text-transform: none; letter-spacing: 0;
                          font-size: var(--step--1); color: var(--text-muted); }
.segmented button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent);
                                         color: var(--accent-ink); position: relative; }
.segmented button[aria-pressed="true"] small { color: inherit; opacity: .85; }

.terms { margin-bottom: var(--s-4); }
.term { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; padding: var(--s-2) 0; }
.term + .term { border-top: 1px solid var(--line); }
.term-label { flex: 0 0 6rem; font-family: var(--font-display); letter-spacing: .04em; }

@media (max-width: 560px) {
  .seat { flex-wrap: wrap; }
  .seat .side { flex-basis: auto; flex-grow: 1; }
  .seat .holder { flex-basis: 100%; order: 3; text-align: left; padding-left: calc(16px + var(--s-3)); }
  .segmented button { flex: 1 1 auto; }
}

.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
                   overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
