/* Pitchside shell (D-158): the page, the masthead, the tab bar and its More
 * sheet, the desktop rail, the Ready bar, the chat panel, the confirm sheet,
 * toasts and flash messages. Colours come only from tokens.css.
 *
 * The bottom furniture is a stack on a phone: the tab bar sits on the Ready
 * bar, both fixed, both sized from --continue-h (base.html raises it when
 * the Ready bar carries the open-window line).
 */

*, *::before, *::after { box-sizing: border-box; }
/* The hidden attribute always wins. Any author rule that sets display would
   otherwise beat the browser's own [hidden]{display:none} -- the matchday's
   after-full-time block showed from kick-off that way. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font); font-size: 16px; line-height: 1.5;
  color: var(--ink); background: var(--bg);
  padding-bottom: calc(var(--tabbar-h) + var(--continue-h) + env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
}

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
h1 { margin: 0 0 4px; font-size: 24px; font-weight: 800; }
h2 { margin: 24px 0 8px; font-size: 16px; font-weight: 700; }
h3 { margin: 0 0 4px; font-size: 15px; font-weight: 700; }

a { color: var(--ink); text-decoration-color: var(--muted); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--club-ink); }

.muted, .lede, .dim { color: var(--muted); }
.lede { margin: 0 0 16px; font-size: 15px; }
.meta { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

/* Scores, wages, minutes, clocks: a column that does not line up is a
   column nobody trusts. */
table, .num, .money, .score, .clock, .joblog, .md-n, .md-clock, .md-min {
  font-variant-numeric: tabular-nums;
}

.skip { position: absolute; left: -9999px; }
.skip:focus {
  left: var(--gutter); top: 8px; z-index: 50;
  padding: 8px 12px; background: var(--card); border-radius: var(--r-input);
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------- masthead */

.masthead {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: var(--masthead-h);
  padding: calc(8px + env(safe-area-inset-top, 0px)) var(--gutter) 8px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.wordmark {
  display: inline-flex; align-items: center; min-height: 44px;
  font-size: 17px; font-weight: 800; letter-spacing: -0.01em;
  color: var(--ink); text-decoration: none; white-space: nowrap;
}
.clock { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; }
.clock .pill {
  padding: 4px 10px; border-radius: var(--r-pill);
  font-weight: 600; white-space: nowrap;
  color: var(--ink-2); background: var(--card-2);
}
.clock .who {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600; color: var(--ink);
}

/* --------------------------------------------------------------- layout */

.frame { display: block; }
.content { max-width: 72ch; padding: 20px var(--gutter) 32px; }

.flash {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 0 0 12px; padding: 12px 14px;
  font-weight: 600;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--r-card); box-shadow: var(--shadow), inset 3px 0 0 var(--club-ink);
}

/* ---------------------------------------------- the phone tab bar, More */

.rail { display: none; }

.tabbar {
  position: fixed; left: 0; right: 0; z-index: 25;
  bottom: calc(var(--continue-h) + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: stretch; height: var(--tabbar-h);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabbar > a, .tabbar summary {
  flex: 1 1 0; min-width: 44px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-decoration: none; list-style: none; cursor: pointer;
}
.tabbar summary::-webkit-details-marker { display: none; }
.tabbar > a.is-active, .tabbar > a[aria-current="page"], .more.is-active > summary {
  color: var(--club-ink);
}
.more { flex: 1 1 0; display: flex; }
.more[open] > summary { color: var(--ink); }
.more-sheet {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + var(--continue-h) + env(safe-area-inset-bottom, 0px));
  display: grid; gap: 2px; padding: 8px 8px 12px;
  background: var(--card); border-top: 1px solid var(--line);
  border-radius: 20px 20px 0 0; box-shadow: 0 -8px 24px var(--scrim);
}
.more-sheet::before {
  content: ""; justify-self: center; width: 40px; height: 4px; margin: 0 0 6px;
  border-radius: var(--r-pill); background: var(--line);
}
.more-sheet a {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 14px;
  font-size: 15px; font-weight: 600; color: var(--ink); text-decoration: none;
  border-radius: var(--r-ctl);
}
.more-sheet a:hover { background: var(--card-2); }
.more-sheet a[aria-current="page"] { color: var(--club-ink); background: var(--card-2); }

/* ---------------------------------------------------------- the Ready bar */

.continuebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 26;
  padding: 8px var(--gutter) calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--card); border-top: 1px solid var(--line);
}
.continue {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; min-height: 48px; padding: 6px 16px;
  font: inherit; font-size: 16px; font-weight: 800; line-height: 1.25;
  color: var(--on-club); background: var(--club);
  border: 0; border-radius: var(--r-ctl);
  box-shadow: inset 0 0 0 1px var(--club-edge);
  text-decoration: none; cursor: pointer;
}
.continue .readyline { display: block; font-size: 12px; font-weight: 500; }
.continue .readyline:empty { display: none; }
/* Ready pressed (data-next="false", static/js/ready.js keeps it current):
   "Waiting for Adam…" is a quiet button, the deadline in --muted. */
.continue[data-next="false"]:not(:disabled) {
  color: var(--ink); background: var(--card-2); box-shadow: inset 0 0 0 1px var(--line);
}
.continue[data-next="false"]:not(:disabled) .readyline { color: var(--muted); }
.continue:disabled { color: var(--muted); background: var(--card-2); box-shadow: none; cursor: default; }

.windowwarn {
  margin: 0 0 6px; padding: 4px 12px;
  font-size: 13px; text-align: center;
  color: var(--warn-ink); background: var(--warn-bg); border-radius: var(--r-pill);
}
.windowwarn .icon { width: 16px; height: 16px; vertical-align: -3px; }
/* The moves left: emphasised by weight, not the club colour, which is not
   guaranteed readable on the warning's own background. */
.windowwarn strong { font-weight: 800; font-variant-numeric: tabular-nums; }
.windowwarn a { display: inline-block; padding: 12px 4px; margin: -12px 0; font-weight: 700; color: inherit; }

/* The round's own story, in the sports-desk voice. */
.joblog {
  list-style: none; margin: 8px 0 0; padding: 0;
  max-height: 22vh; overflow-y: auto;
  font-size: 13px; color: var(--muted);
}
.joblog li { padding: 2px 0; border-bottom: 1px solid var(--line); }
.joblog li.loss { color: var(--loss); }

/* ----------------------------------------------------------- chat panel */

.chatpanel {
  margin: 0 var(--gutter) 24px; padding: 14px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--r-card); box-shadow: var(--shadow);
}
.chatpanel h2 { margin: 0 0 8px; }
.chatlog { display: grid; gap: 8px; margin: 8px 0; max-height: 46vh; overflow-y: auto; }
.bubble {
  padding: 8px 12px; border-radius: var(--r-ctl);
  font-size: 14px; line-height: 1.45; white-space: pre-wrap;
}
.bubble.you {
  justify-self: end; max-width: 85%;
  color: var(--on-club); background: var(--club); box-shadow: inset 0 0 0 1px var(--club-edge);
}
.bubble.them { background: var(--card-2); }
.bubble.system { padding: 2px 6px; font-size: 13px; color: var(--muted); }
.bubble.bad { color: var(--loss); }
.chatform { display: flex; gap: 8px; }
.chatform input { flex: 1; }
.chatform button { flex: none; }

.propcard {
  padding: 12px; font-size: 14px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: var(--r-ctl);
}
.propcard h3 { margin: 0 0 4px; }
.propcard .summary { margin: 0 0 6px; color: var(--muted); }
.propcard ul, .sheetcard ul { list-style: none; margin: 0 0 8px; padding: 0; }
.propcard .effects li { padding: 2px 0; }
.propcard button { width: 100%; margin-top: 6px; }
.risks li {
  margin: 6px 0; padding: 8px 10px; border-radius: var(--r-input);
  color: var(--warn-ink); background: var(--warn-bg);
}

/* ----------------------------------------- the confirm sheet, and toasts */

.confirmsheet {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: end center;
  background: var(--scrim);
}
.sheetcard {
  width: 100%; max-width: 32rem;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  background: var(--card); border-radius: 20px 20px 0 0;
}
.sheetcard::before {
  content: ""; display: block; width: 40px; height: 4px; margin: 0 auto 12px;
  border-radius: var(--r-pill); background: var(--line);
}
.sheetcard h2 { margin: 0 0 10px; font-size: 18px; font-weight: 800; }
.sheetcard .effects li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.sheetcard .effects li:last-child { border-bottom: 0; }
.sheetacts { display: flex; gap: 8px; margin-top: 14px; }
.sheetacts button { flex: 1; }
@media (min-width: 640px) {
  .confirmsheet { place-items: center; }
  .sheetcard { padding-top: 18px; border-radius: 20px; }
  .sheetcard::before { display: none; }
}

.toast {
  position: fixed; left: 50%; z-index: 70; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--continue-h) + 12px + env(safe-area-inset-bottom, 0px));
  max-width: min(90vw, 28rem); padding: 12px 16px;
  font-size: 14px; font-weight: 600;
  color: var(--card); background: var(--ink);
  border-radius: var(--r-ctl); box-shadow: 0 6px 20px var(--scrim);
}
.toast.bad { color: var(--loss-ink); background: var(--loss); }

/* -------------------------------------------------------------- desktop */

@media (min-width: 900px) {
  body { padding-bottom: 0; }

  .frame {
    display: grid; align-items: start;
    grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--chat-w);
  }

  .rail {
    display: block; position: sticky; top: var(--masthead-h);
    min-height: calc(100vh - var(--masthead-h));
    padding: 16px 12px; border-right: 1px solid var(--line);
  }
  .rail ul { display: grid; gap: 2px; list-style: none; margin: 0; padding: 0; }
  .rail a {
    display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px;
    font-size: 15px; font-weight: 600; color: var(--ink-2); text-decoration: none;
    border-radius: var(--r-ctl);
  }
  .rail a:hover { background: var(--card-2); }
  .rail a.is-active, .rail a[aria-current="page"] { color: var(--club-ink); background: var(--card-2); }

  .content { padding: 24px 32px 104px; }
  .tabbar { display: none; }

  .chatpanel {
    position: sticky; top: calc(var(--masthead-h) + 16px);
    max-height: calc(100vh - var(--masthead-h) - 32px); overflow-y: auto;
    margin: 16px 16px 16px 0;
  }

  .continuebar {
    left: var(--rail-w); right: var(--chat-w);
    display: flex; align-items: center; gap: 16px;
    background: var(--bg); border-top: 1px solid var(--line);
  }
  .windowwarn { margin: 0; }
  .continue { width: auto; min-width: 18rem; }
  .joblog { flex: 1; margin: 0; max-height: 3.4rem; }
  .toast { bottom: 96px; }
}

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