/* rails.css, owner: track D2. Holds: the strip row under the bar, the two rails (score, contract, auction, tracker, last trick, Meld at a Glance, the Coach card's room, Table Talk's room),
   the right strip, the drawers and bottom sheets (Table Talk, the Coach's details, the Scoreboard), and the bid history lists.
   Load order 9 of 15: base, primitives, frame, home, room, friends, center, table, rails, chat, coach, meld, peek, results, dialogs.
   Rail text is rem, so it grows with the root (3.3). A rail that is short gives sections up in a fixed order (7.6): This hand, then the Last Trick faces, then the tracker caption,
   then Meld at a Glance, then it scrolls with a fade. The tests of AC-22 forbid the scroll at 1280 x 720 and 1366 x 650. */

/* ---- 7.1, 7.7: the bar and the Coach strip are two rows of the grid; the rails run beside both ---- */
@media (min-width: 1024px) {
  body.at-table .table-app { grid-template-rows: auto auto minmax(0, 1fr); grid-template-areas: "bar bar bar" "left strip right" "left stage right"; }
  body.at-table .table-app > .top-chrome { display: contents; }
  body.at-table #toolbar-slot { display: none; }
  body.at-table #score-bar-slot { grid-area: bar; position: relative; z-index: var(--z-bar); min-width: 0; }
  body.at-table.menu-open #score-bar-slot { z-index: calc(var(--z-menu) + 1); }
  body.at-table #coach-slot { grid-area: strip; position: relative; min-width: 0; }
  /* The tricks needed and the tricks played have their place in the left rail now; the felt's corners are free (Larger Text keeps them in the felt: the rail
     is hidden). */
  body.at-table:not(.large-text) .stage .trick-history, body.at-table:not(.large-text) .center-zone > .bid-progress { display: none; }
}
/* one rem square, never seen: rails.js watches it to learn that the text size changed (review R2) */
.rem-probe { position: fixed; top: 0; left: 0; width: 1rem; height: 1rem; visibility: hidden; pointer-events: none; }
/* over the bar and the rails, under an open Menu (the bar rises above it, table.css) and under every drawer (--z-drawer, 960 once dialogs.css loads) */
#bubble-layer {
  z-index: var(--z-menu);
}

/* ---- the rails ---- */
.rail--left .rail__scroll, .rail-drawer__body { display: flex; flex-direction: column; gap: var(--sp-4); min-height: 0; padding: var(--sp-4); }
/* the fallback of 7.6: it scrolls, with a fade at the foot */
.rail--left .rail__scroll.is-over {
  mask-image: linear-gradient(to bottom, var(--white) calc(100% - 1.5rem), transparent);
}
.rail--left .rail__scroll:not(:hover):not(:focus-within) { scrollbar-width: none; }
.rs { flex: none; min-width: 0; }
.rs + .rs { padding-top: var(--sp-4); border-top: 1px solid var(--hair); }
.rs-eyebrow {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-2); color: var(--text-faint);
  font: var(--t-eyebrow); letter-spacing: 0.08em; text-transform: uppercase;
}
.rs-eyebrow__aside { color: var(--text-dim); letter-spacing: 0.02em; text-transform: none; }
.rs-sentence { color: var(--text); font: var(--t-small); }
.rs-sentence.is-faint { color: var(--text-dim); }
.rs-note { margin-top: var(--sp-1); color: var(--text-dim); font: var(--t-caption); }
.rs-sub { color: var(--text-dim); font: var(--t-caption); }
.rs-high__top { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 var(--sp-3); }
.rs-big { color: var(--gold-strong); font-size: max(2.25rem, 12px); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.rs-bar { position: relative; height: 6px; overflow: hidden; border-radius: var(--r-xs); background: var(--track); }
.rs-bar > span { display: block; height: 100%; border-radius: var(--r-xs); background: var(--gold); }
.rs-bar.is-good > span { background: var(--good); }
.rs-bar.is-bad > span { background: var(--bad); }
.rs-bar.is-team > span { background: var(--text-dim); }
.rs-bar__tick { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); }

/* Score */
.rs-teams { display: flex; flex-direction: column; gap: var(--sp-3); }
.rs-team { display: grid; row-gap: var(--sp-1); }
.rs-team__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2); }
.rs-team__label { font-size: max(0.9375rem, 12px); font-weight: 700; }
.team-ns .rs-team__label, .rs-ledger .team-ns { color: var(--team-ns); }
.team-ew .rs-team__label, .rs-ledger .team-ew { color: var(--team-ew); }
.rs-team__score { color: var(--text); font-size: max(2rem, 12px); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.rs-team__names { overflow: hidden; color: var(--text-dim); font: var(--t-caption); text-overflow: ellipsis; white-space: nowrap; }
.rs-team.team-ns .rs-bar > span { background: var(--team-ns); }
.rs-team.team-ew .rs-bar > span { background: var(--team-ew); }
.rs-chip {
  justify-self: end; padding: 0 var(--sp-2); border-radius: var(--r-full); background: var(--good-wash); color: var(--good); font: var(--t-eyebrow);
  font-variant-numeric: tabular-nums;
}
.rs-chip.is-down { background: var(--bad-wash); color: var(--bad); }

/* The auction: one row per seat, in bidding order */
.rs-auction { display: flex; flex-direction: column; gap: var(--sp-1); list-style: none; }
.rs-bidrow {
  display: grid; grid-template-columns: 1.5rem minmax(0, 1fr) auto; align-items: center; gap: var(--sp-2); min-height: 2.75rem; padding: 0 var(--sp-2);
  border-radius: var(--r-md);
}
.rs-bidrow.is-high { background: var(--gold-wash); }
.rs-bidrow.is-pending { box-shadow: inset 0 0 0 1px var(--gold-line); }
.rs-avatar {
  display: grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--panel-2); font-size: max(0.8125rem, 12px);
  line-height: 1;
}
.rs-bidrow__who { display: flex; flex-direction: column; min-width: 0; font: var(--t-small); }
.rs-bidrow__name, .rs-bidrow__said { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-bidrow__said { color: var(--text-dim); font: var(--t-caption); font-family: var(--font-serif); font-style: italic; }
.rs-bidrow__bid { color: var(--text-dim); font: var(--t-label); font-variant-numeric: tabular-nums; }
.rs-bidrow.is-high .rs-bidrow__bid, .rs-bidrow.is-pending .rs-bidrow__bid { color: var(--gold-strong); }

/* The contract and its need lines */
.rs-contract__top { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-1); }
.rs-trump {
  padding: 0 var(--sp-3); border: 1px solid var(--hair); border-radius: var(--r-full); background: var(--white-04); font: var(--t-caption); font-weight: 700;
  line-height: 1.625rem; white-space: nowrap;
}
.rs-need { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-3); }
.rs-need__row { display: grid; gap: var(--sp-1); }
.rs-need__line { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 var(--sp-2); font-size: max(0.8125rem, 12px); font-weight: 600; }
.rs-need__left { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.rs-need__right { flex: none; margin-left: auto; color: var(--text-dim); text-align: right; }
.rs-need__right.is-gold { color: var(--gold-strong); }
.rs-need__right.is-good { color: var(--good); }
.rs-need__right.is-bad { color: var(--bad); }

/* The tracker: twenty cells in two rows of ten */
.rs-cells { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 0.1875rem; }
.rs-cell { display: block; height: 6px; border-radius: var(--r-xs); background: var(--track); }
.rs-cell.team-ns { background: var(--team-ns); }
.rs-cell.team-ew { background: var(--team-ew); }
.rs-cap { margin-top: var(--sp-2); color: var(--text-dim); font: var(--t-caption); white-space: nowrap; }
.rs-cap.is-teams { white-space: normal; }
.rs-cap.is-teams .rs-cap__count, .rs-cap.is-teams .rs-cap__score { display: block; }
.rs-cap.is-teams .rs-cap__dot { display: none; }
@container rail (max-width: 15.99rem) { .rs-cap__w { display: none; } }

/* The ledger */
.rs-ledger { width: 100%; border-collapse: collapse; font: var(--t-small); font-variant-numeric: tabular-nums; }
.rs-ledger th, .rs-ledger td { padding: var(--sp-1) 0; font-weight: 600; text-align: right; }
.rs-ledger tbody th { color: var(--text-dim); text-align: left; }
.rs-ledger tbody tr:last-child { color: var(--gold-strong); }

/* Last trick */
.rs-faces { display: flex; gap: 0.1875rem; margin-bottom: var(--sp-2); }
.rs-face { display: flex; flex: 1 1 0; flex-direction: column; align-items: center; gap: 0.125rem; min-width: 0; max-width: 3.1rem; }
.rs-face__card { --card-width: 3.1rem; --card-height: calc(var(--card-width) * 108 / 76); position: relative; flex: none; margin: 0; pointer-events: none; }
.rs-face.is-winner .rs-face__card { box-shadow: 0 0 0 2px var(--gold-strong); }
.rs-face__name { max-width: 100%; overflow: hidden; color: var(--text-dim); font-size: max(0.75rem, 12px); text-overflow: ellipsis; white-space: nowrap; }
.rs-last__line { display: none; }
.rs-alltricks { margin-top: var(--sp-1); }
.rs-alltricks > summary {
  display: flex; align-items: center; gap: var(--sp-2); min-height: var(--hit-sm); padding-block: 0; color: var(--gold-strong); font: var(--t-caption);
  font-weight: 600; list-style: none;
}
.rs-alltricks > summary::-webkit-details-marker { display: none; }
.rs-key { margin-left: auto; }
.rs-alltricks > summary .i, .rs-glance > summary .i {
  flex: none; width: 1rem; height: 1rem; color: var(--text-dim); transition: rotate var(--dur) var(--ease-out);
}
.rs-alltricks[open] > summary .i, .rs-glance[open] > summary .i { rotate: 180deg; }
.rs-tricklist { display: flex; flex-direction: column; list-style: none; }
.rs-tricklist li {
  display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-1) 0; border-top: 1px solid var(--hair); font-size: max(0.75rem, 12px);
}
.rs-tricklist__n { min-width: 1.125rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.rs-tricklist__cards { display: flex; gap: var(--sp-1); }
.rs-tricklist__who { margin-left: auto; overflow: hidden; max-width: 4rem; text-overflow: ellipsis; white-space: nowrap; }
.rs-tricklist li.team-ns .rs-tricklist__who { color: var(--team-ns); }
.rs-tricklist li.team-ew .rs-tricklist__who { color: var(--team-ew); }

/* Meld at a Glance */
.rs-glance > summary {
  display: flex; align-items: center; justify-content: space-between; min-height: var(--hit-sm); padding-block: 0; font: var(--t-eyebrow);
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint);
}
.rs-glance[open] > summary { margin-bottom: var(--sp-1); }
.rs-chartwrap.is-capped { max-height: 6rem; overflow-y: auto; }   /* (in the meld and the tricks only: the bidding has the room for the whole chart) */
.rs-chart { width: 100%; border-collapse: collapse; font: var(--t-caption); font-variant-numeric: tabular-nums; }
.rs-chart th, .rs-chart td { padding: var(--sp-1) 0; border-top: 1px solid var(--hair); font-weight: 500; }
.rs-chart th { color: var(--text); text-align: left; }
.rs-chart td { color: var(--gold-strong); text-align: right; }
.rs-chartlink { min-height: var(--hit-sm); padding-inline: 0; }

/* Collapse order (7.6): the rail's own height decides. The numbers are from the section heights (docs/web-redesign/track-d2.md): the faces and the ledger need more room than the spec's 37.5rem and 48.75rem (49rem and 55rem),
   because AC-22 forbids the scroll at 1280 x 720 (a rail of 41.5rem) and the ledger and the faces together are taller than a 1440 x 900 rail (52.75rem). */
/* A rail 64rem tall or more (2560 x 1440 and up) spends its spare height on air between the sections, so the foot is not an empty field (spec 10: 280 px at
   most; review R5) */
@container rail (min-height: 64rem) { .rail--left .rail__scroll { gap: var(--sp-5); } .rs + .rs { padding-top: var(--sp-5); } }
@container rail (max-height: 43.74rem) { .rs-hand { display: none; } .rs-hand + .rs { padding-top: 0; border-top: 0; } .rs-glancebox { display: none; } }   /* (the auction's rows keep their 44 px: the chart goes first, review R10) */
@container rail (max-height: 48.99rem) { .rs-faces, .rs-last__text { display: none; } .rs-last__line { display: block; } .rs-eyebrow { margin-bottom: var(--sp-1); } }
@container rail (max-height: 54.99rem) { .rs-ledgerbox { display: none; } }
@container rail (max-height: 37.49rem) { .rs-cap { display: none; } }
@container rail (max-height: 34rem) { .rs-glancebox { display: none; } }
@container rail (max-height: 31rem) { .rs-note { display: none; } }
/* The measured collapse (review round 2, M3): rails.js adds fit-1 to fit-5 until the rail no longer scrolls, in the order of 7.6 */
.fit-1 .rs-hand { display: none; }
.fit-1 .rs-hand + .rs { padding-top: 0; border-top: 0; }
.fit-2 .rs-faces, .fit-2 .rs-last__text { display: none; }
.fit-2 .rs-last__line { display: block; }
.fit-3 .rs-ledgerbox { display: none; }
.fit-4 .rs-cap { display: none; }
.fit-5 .rs-glancebox { display: none; }
@media (any-pointer: coarse) { .rs-alltricks > summary, .rs-glance > summary, .rs-chartlink { min-height: var(--hit); } }

/* ---- the right rail: docked from 1440, otherwise a strip ---- */
.rail--right .rail__scroll { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); padding: var(--sp-2) 0; overflow-x: hidden; }
.rail--right .rail__scroll.is-docked { align-items: stretch; gap: var(--sp-3); padding: var(--sp-4); overflow: hidden; }
.rail--right .rail__scroll:not(.is-docked) .rail-dock { display: none; }
.rail-dock { display: flex; flex: 1 1 auto; flex-direction: column; gap: var(--sp-3); min-height: 0; }
.rail-dock__coach { flex: none; }
.rail-dock__coach:empty { display: none; }
.rail-dock__chat { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.rail-strip { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); }
.rail-strip__btn {
  position: relative; display: grid; place-items: center; width: var(--hit); height: var(--hit); border: 1px solid var(--hair); border-radius: var(--r-lg);
  background: var(--panel); color: var(--text); cursor: pointer;
}
.rail-strip__btn .i { width: 1.375rem; height: 1.375rem; }
.rail-strip__btn.is-on { background: var(--gold-wash); color: var(--gold-strong); }
@media (hover: hover) and (pointer: fine) { .rail-strip__btn:hover { background: var(--wash-hover); } }
.rail-strip__btn:active { background: var(--wash-press); }
.rail-strip__dot {
  position: absolute; top: var(--sp-1); right: var(--sp-1); width: 10px; height: 10px; border-radius: 50%; background: var(--text-faint);
  box-shadow: 0 0 0 2px var(--ink-0);
}
.rail-strip__dot.is-on { background: var(--good); }
.rail-strip .badge { position: absolute; top: 0; right: 0; }

/* the score pills, where no left rail shows, are the way into the Scoreboard */
.score-pills[role="button"] { cursor: pointer; }
@media (any-pointer: coarse) { .score-pills[role="button"] { min-height: var(--hit); align-items: stretch; } }

/* ---- drawers and bottom sheets: Table Talk, the Coach's details, the Scoreboard ---- */
.sheet {
  position: fixed; top: calc(var(--rail-top, 3.5rem)); right: 0; bottom: 0; z-index: var(--z-drawer); display: flex; flex-direction: column;
  width: min(24rem, 100vw); overflow: hidden; border-left: 1px solid var(--line); border-radius: var(--r-xl) 0 0 0; background: var(--ink-0);
  box-shadow: var(--e-2); color: var(--text); animation: rail-drawer-in var(--dur) var(--ease-out);
}
.sheet.is-left {
  right: auto; left: 0; border-right: 1px solid var(--line); border-left: 0; border-radius: 0 var(--r-xl) 0 0; animation-name: rail-drawer-in-left;
}
@keyframes rail-drawer-in { from { translate: 100% 0; } to { translate: 0 0; } }
@keyframes rail-drawer-in-left { from { translate: -100% 0; } to { translate: 0 0; } }
@keyframes rail-sheet-in-up { from { translate: 0 100%; } to { translate: 0 0; } }
.sheet-head {
  position: relative; display: flex; flex: none; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--hair);
}
.sheet-grip { display: none; }
.sheet-title { flex: 1; font: var(--t-title-3); color: var(--text); }
.sheet-head-extra { display: flex; align-items: center; }
.sheet-close, .sheet-hide {
  display: grid; place-items: center; width: var(--hit); height: var(--hit); border: 0; border-radius: var(--r-lg); background: transparent;
  color: var(--text-dim); font-size: max(1.05rem, 12px); cursor: pointer;
}
.sheet-close .i, .sheet-hide .i { width: 1.25rem; height: 1.25rem; }
@media (hover: hover) and (pointer: fine) { .sheet-close:hover, .sheet-hide:hover { background: var(--wash-hover); color: var(--text); } }
.sheet-body { display: flex; flex: 1; flex-direction: column; min-height: 0; overflow: hidden; }
.sheet-score .sheet-body { overflow-y: auto; }
@media (max-width: 599.98px) {
  .sheet, .sheet.is-left {
    top: auto; right: 0; bottom: 0; left: 0; width: auto; height: min(36rem, 92dvh); border: 0; border-top: 1px solid var(--line);
    border-radius: var(--r-2xl) var(--r-2xl) 0 0; animation-name: rail-sheet-in-up;
  }
  .sheet-head { padding-top: var(--sp-4); }
  .sheet-grip {
    display: block; position: absolute; top: var(--sp-2); left: 50%; width: 2.5rem; height: 4px; margin-left: calc(var(--sp-5) * -0.8);
    border-radius: var(--r-xs); background: var(--white-30);
  }
}
@media (prefers-reduced-motion: reduce) { .sheet, .sheet.is-left { animation: none; } }   /* (.sheet.is-left and the phone sheet name an animation at a higher specificity than a bare .sheet; review round 2 M8) */

/* ---- the auction as the bid panel and the held history draw it (render/center.js, render/auction-review.js) ---- */
.bid-history {
  display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-1); max-width: 100%; padding: var(--sp-2); border: 1px solid var(--hair);
  border-radius: var(--r-md);
}
.bid-history-entry {
  max-width: 100%; padding: 0 var(--sp-2); border-radius: var(--r-lg); color: var(--text-dim); font-size: max(0.78rem, 12px); overflow-wrap: break-word;
  text-align: center;
}
.bid-history-entry.is-cut { visibility: hidden; }
.bid-history-entry.is-newest { background: var(--wash-hover); color: var(--text); font-weight: 700; }
/* Fix round 3 m3 (7.5): with the left rail on screen (1024 and wider, not at Larger Text) the auction and the rule line live in the rail, not again in the bid panel. */
@media (min-width: 1024px) { body.at-table:not(.large-text) .bid-panel :is(.bid-history, .panel-hint) { display: none; } }
.auction-review .bid-history { max-height: 36vh; margin: var(--sp-2) 0; overflow-y: auto; }
@media (min-width: 600px) { .bid-history-entry { font-size: max(0.92rem, 12px); } }
@media (max-height: 500px) and (orientation: landscape) { .bid-history-entry { font-size: max(0.78rem, 12px); } }

/* 500: the Avondale bid table in the rail. */
.rs-bidtable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font: var(--t-caption); }
.rs-bidtable th, .rs-bidtable td { text-align: center; padding: var(--sp-1) 0; }
.rs-bidtable th { color: var(--text-dim); font-weight: 600; }
.rs-bidtable td.is-high { background: var(--gold); color: var(--ink-on-gold); border-radius: var(--r-xs); font-weight: 700; }
