/* The matrix page's own rules (templates/matrix.html, efforts/a3bbuild ticket 13). The page has
   no page of its own in the prototype: it is drawn from the sheet (the frame, the controls, the
   note type, the neutral steps) with the format page's matchup table, whose rules are in
   site.css. Linked after site.css. */

/* ---------- the title card ---------- */
.tc-matrix .matrix-share { margin-top: 0; }
.tc-matrix .matrix-share .boxlink-sm { margin-top: 0; }

/* ---------- 01 Timeline ----------
   The page's own chart, restyled with the sheet's rules: counted matches in the value ink, the
   left-out part in the hatched dim neutral, gaps in a fainter hatch, the selected range framed
   in the picked white, labels in the label face. Its key sits beside the section label. */
.tl-key { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; }
.tl-key li { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.tl-key-bar, .tl-key-gap { display: inline-block; width: 12px; height: 12px; }
.tl-key-bar { background: var(--val); }
.tl-key-bar.is-out { background: repeating-linear-gradient(135deg, var(--n-dim) 0 1.5px, transparent 1.5px 4px); box-shadow: inset 0 0 0 1px var(--n-dim); }
.tl-key-gap { background: repeating-linear-gradient(135deg, var(--n-line) 0 1px, transparent 1px 4px); box-shadow: inset 0 0 0 1px var(--n-line); }
.tl-key > li > .evs { width: 14px; height: 14px; margin: 0; }
.tl-key-paper { display: inline-block; width: 6px; height: 6px; background: var(--ink-2); }
.tl-wrap { padding-top: 4px; }
.tl-svg { display: block; width: 100%; overflow: visible; }
.tl-bar { fill: var(--val); }
.tl-bar.is-out { fill: url(#tl-out); }
#tl-out rect { fill: var(--n-mid); }
#tl-hatch rect { fill: var(--n-dim); }
.tl-gap { fill: url(#tl-hatch); }
.tl-axis, .tl-tick { stroke: var(--n-mid); stroke-width: 1; }
.tl-month { fill: var(--ink-2); font: 700 10px var(--label); letter-spacing: .14em; text-transform: uppercase; }
.tl-cap { fill: var(--ink-2); font: 700 9.5px var(--label); letter-spacing: .1em; text-transform: uppercase; }
.tl-seam { stroke: var(--n-mid); stroke-width: 1; stroke-dasharray: 3 3; }
/* The three-star mark over a day. Days a few px apart put two marks over each other: a halo in
   the field's colour keeps the front one apart from the one behind. */
.tl-star { fill: var(--val-2); stroke: var(--field); stroke-width: 2.6px; stroke-linejoin: round; paint-order: stroke; }
.tl-paper { fill: var(--ink-2); }
.tl-range { fill: rgb(243 239 228 / .05); stroke: var(--n-hi); stroke-width: 1.5; }

/* ---------- 02 View: one GET form ---------- */
.matrix-form { display: grid; gap: 22px; color: var(--ink); font: 400 15px/1.5 var(--body); }
.mf-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px 18px; }
.mf-f { display: flex; flex-direction: column; min-width: 0; }
.mf-f .fl { margin-bottom: 6px; }
.mf-sets { gap: 18px 32px; }
.mf-dates { flex: 0 1 580px; min-width: 0; }
.mf-plat { flex: 0 1 470px; min-width: 0; }
.mf-view { min-height: 38px; }
/* A date: the sheet's field box, the native control inside. */
.mf-date {
  min-height: 38px; padding: 4px 10px; border: 1px solid var(--n-mid); border-radius: 0; background: var(--field);
  color: var(--ink); font: 500 16px/1.2 var(--mono); font-variant-numeric: tabular-nums; color-scheme: dark;
}
.mf-date:hover { border-color: var(--n-hi); background: var(--n-lift); }
.mf-date:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-color: var(--n-hi); }

/* The drop list (site.css and frame.js): the server sends a native select, drawn as the closed
   cell; with script frame.js lays the cell's button over it (`data-dc`), in the select's own box,
   and puts the list under it; the select is then not painted. A long list scrolls. */
.dc-b, .dc-s {
  min-height: 38px; border: 1.5px solid var(--n-hi); border-radius: 0; background: var(--n-hi); color: #000;
  font: 600 16px/1.2 var(--body); white-space: nowrap; cursor: pointer;
}
.dc-b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: 4px 10px 4px 12px; }
.dc-s { appearance: none; padding: 4px 31px 4px 12px; }
.dc:not([data-dc])::after { content: ""; position: absolute; right: 11px; top: 50%; width: 10px; height: 6px; margin-top: -3px; background: #000; clip-path: polygon(0 0, 100% 0, 50% 100%); pointer-events: none; }
/* The select keeps its box, so the cell is as wide as its longest option either way. */
.dc[data-dc] .dc-s { visibility: hidden; }
.dc-pop { max-height: min(70vh, 30rem); overflow-y: auto; }
/* A box that scrolls on this page (the tournaments, a long drop list) has a thin bar in the
   frame's tones: the thumb in the stroke grey, white under the pointer, on the box's black, with
   no arrow buttons. Chrome and Safari draw it from the `::-webkit-scrollbar` rules (Chrome
   ignores them once `scrollbar-color` is set, and keeps its buttons then); Firefox from the
   standard properties. */
.dc-pop::-webkit-scrollbar, .matrix-events::-webkit-scrollbar { width: 6px; }
.dc-pop::-webkit-scrollbar-track, .matrix-events::-webkit-scrollbar-track { background: var(--field); }
.dc-pop::-webkit-scrollbar-thumb, .matrix-events::-webkit-scrollbar-thumb { min-height: 28px; background: var(--n-mid); }
.dc-pop::-webkit-scrollbar-thumb:hover, .matrix-events::-webkit-scrollbar-thumb:hover { background: var(--n-hi); }
@supports not selector(::-webkit-scrollbar) {
  .dc-pop, .matrix-events { scrollbar-width: thin; scrollbar-color: var(--n-mid) var(--field); }
}

/* The disclosure (the sheet's box with a plus, open a minus on white), then View, the form's one
   button, at the right end of the form. Open, the fold takes the line and View goes under it. */
.matrix-folds { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 40px; padding-top: 10px; border-top: 1px solid var(--n-line); }
.matrix-fold { flex: 0 1 auto; min-width: 0; }
.matrix-fold[open] { flex: 1 1 100%; }
.mf-go { margin: 0 0 0 auto; }
.matrix-fold > summary { display: flex; align-items: center; gap: 10px; padding: 4px 0; color: var(--n-hi); }
.mf-dt .sq-y { --sx: .55; --fs: 20px; }
.matrix-count { padding: 3px 6px; border: 1px solid var(--n-mid); color: var(--ink); font: 500 12px/1 var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.matrix-count.is-on { background: var(--n-hi); border-color: var(--n-hi); color: #000; }
.matrix-check { display: inline-flex; align-items: center; gap: 10px; min-height: 38px; color: var(--ink); font: 400 15px/1.3 var(--body); cursor: pointer; }
/* A check box: the native control in the picked white, with the sheet's focus ring. */
.matrix-check input, .matrix-event-box { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--n-hi); cursor: pointer; }
.matrix-check input:focus-visible, .matrix-event-box:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* The tournaments: a find field (the sheet's prompt), two box buttons, then rows by day in table
   text, the stars and the platform word as the events log draws them. A ticked row is left out:
   its name is struck through. */
.matrix-tools { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; margin: 10px 0 12px 32px; }
.matrix-tools[hidden] { display: none; }
.matrix-find-f { flex: 1 1 14rem; min-height: 34px; }
.matrix-find-f input { font-size: 15px; }
.matrix-events { position: relative; max-height: 22rem; margin: 0 0 0 32px; padding: 0 4px 0 0; overflow-y: auto; overscroll-behavior: contain; border-top: 1px solid var(--n-mid); color: var(--ink); font: 400 14px/1.4 var(--body); }
.matrix-day { position: sticky; top: 0; z-index: 1; padding: 10px 0 6px; background: var(--field); }
.matrix-event { display: flex; align-items: center; gap: 10px; padding: 0 6px; border-bottom: 1px solid var(--n-line); }
.matrix-event:hover { background: var(--n-lift); }
.matrix-event[hidden], .matrix-day[hidden] { display: none; }
.matrix-event label { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 14px; padding: 7px 0; cursor: pointer; }
.matrix-event-name { display: flex; align-items: baseline; gap: 8px; flex: 1 1 18rem; min-width: 0; }
/* The platform column holds "Paper", the wider word, so the names line up. */
.matrix-event-name .plat { flex: none; width: 56px; text-align: center; }
.matrix-event-n { min-width: 0; overflow-wrap: anywhere; }
.matrix-event-meta { color: var(--ink-2); font-size: 12px; white-space: nowrap; }
.matrix-event-box:checked + label .matrix-event-n { color: var(--ink-2); text-decoration: line-through; }
.matrix-events-empty { margin: 0; padding: 10px 0; }

/* A swap not answered within 250ms (frame.js marks `main` busy): the timeline and the table take
   the muted look of a list on its way, and keep what they show, so nothing moves. */
.matrix-page[aria-busy="true"] :is(.inst-tl, .inst-mx) { border-style: dotted; border-color: var(--n-dim); }
.matrix-page[aria-busy="true"] :is(.inst-tl, .inst-mx) > .inst-body { opacity: .45; }

/* ---------- 03 Matchups ---------- */
/* What the dates did, the pick's cap, and below the floor the warning and its fixes: the note
   type. A sentence about a change the server made to the request reads in ink, on a rule. */
.matrix-status { margin: 0 0 18px; }
.matrix-status > .matrix-note { margin: 0 0 8px; }
.matrix-note.is-clamp { padding-left: 10px; border-left: 2px solid var(--n-hi); color: var(--ink); }
.matrix-floor-links { margin-top: 10px; }
.matrix-floor-links .boxlink-sm { margin-top: 0; }

/* A grid wider than the prototype ever draws (more than twelve named decks: Top 16, Top 20, a
   share threshold; the heads are the corner, All, the decks and Other) keeps its cells at the
   size the format page gives them at 1440 (52px) and scrolls inside its own box, never the page.
   Twelve decks or fewer shrink to fit, as the prototype's do. Two columns wide, the read-out
   stays in view beside a tall table. */
@media (min-width: 641px) {
  .matrix-page .mx-table:has(thead th:nth-of-type(16)) td.mx { min-width: 52px; }
}
@media (min-width: 1241px) {
  .matrix-page .readout { position: sticky; top: 12px; align-self: start; }
}

/* ---------- a phone ---------- */
@media (max-width: 640px) {
  .mf-row { gap: 12px 12px; }
  /* A drop list takes the line (its longest option is too wide for half); the two dates share
     one. */
  .mf-row > .mf-f:has(.dc) { flex: 1 1 100%; }
  .mf-row > .mf-f:has(.dc) .dc, .mf-row > .mf-f:has(.dc) .dc-s { width: 100%; }
  .mf-f:has(.mf-date) { flex: 1 1 140px; }
  .mf-date { width: 100%; }
  .mf-go { flex: 1 1 100%; }
  .mf-view { width: 100%; justify-content: space-between; }
  .mf-dates, .mf-plat { flex: 1 1 100%; }
  .matrix-tools, .matrix-events { margin-left: 0; padding-left: 0; }
  .matrix-events { max-height: 60vh; }
  .matrix-event label { padding: 10px 0; }
  .matrix-event-name .plat { width: auto; }
  .matrix-fold, .matrix-fold[open] { flex-basis: 100%; }
}
@media (max-width: 640px) {
  .mf-sets .mstrip-pick .mode { padding: 4px; }
}
