/* ==========================================================================
   Kings in the Corner - "Match Strategy: Eight Rounds"
   Loaded only by /match-strategy/, after styles.css, pages.css and rules.css.

   A card-club scorebook. This is the one page on the site with a near-black
   ground, as the brief asks: the interior tokens are flipped in one place so
   every shared component follows, and the score sheets sit on it as cream
   paper. No gradients anywhere.

   1. Dark page: the interior tokens, flipped
   2. Score sheet (the eight-round table)
   3. Pull line
   4. Cumulative score tables
   5. Margin note
   6. Final-round arithmetic
   7. Choice illustrations
   8. Responsive
   9. Print
   ========================================================================== */

/* ------------------- 1. Dark page: tokens, flipped ---------------------- */
/* Every interior component reads these, so overriding them here recolours
   the panels, rules and body copy together instead of one selector at a
   time. Measured against the painted background, not guessed. */
.matchpage {
  --ipage:   #14120E;   /* near-black, slight warm cast */
  --ipanel:  #1D1A14;
  --iline:   #343026;
  --ilink:   #E8C784;
  --ink:     #F3ECDC;   /* headings */
  --text:    #DAD2C2;   /* body copy */
  --muted:   #ADA491;

  --m-paper:   #F0EAD9;   /* the score sheet */
  --m-paper-2: #E6DFCB;
  --m-rule:    #B4A98F;   /* taupe-grey ruling */
  --m-ink:     #201D16;
  --m-ink-2:   #4E4838;
  --m-win:     #2F6B44;   /* match winner */
  --m-round:   #3A5C86;   /* round winner */
  --m-limit:   #99302A;   /* limit reached */
}
.matchpage .prose p { color: var(--text); }
.matchpage .rsec h2, .matchpage .rsec h3 { color: var(--ink); }
.matchpage .prose strong, .matchpage .prose b { color: var(--ink); }
.matchpage .prose ul li, .matchpage .prose ol li { color: var(--text); }
.matchpage .layout__main a { color: var(--ilink); }
.matchpage .layout__main a:hover { color: #F6DDAA; }
/* the fact strip is a white slab by default */
.matchpage .factstrip__inner { background: var(--ipanel); border-color: var(--iline); }
.matchpage .factstrip b { color: var(--ink); }
.matchpage .factstrip span { color: var(--muted); }
/* the sources green is tuned for a white panel and measured 3.11:1 here */
.matchpage .page .sources__list a,
.matchpage .sources__list a { color: #7CC79B; }
.matchpage .sources__list a:hover { color: #A6DDBE; }

/* --------------------------- 2. Score sheet ----------------------------- */
.sheetwrap {
  --c1: 104px;
  --c2: 78px;
  overflow-x: auto;
  margin: 22px 0 10px;
  background: var(--m-paper);
  border: 1px solid var(--m-rule);
}
.sheet {
  width: 100%;
  min-width: 480px;
  border-collapse: separate; border-spacing: 0;
  background: var(--m-paper);
  font-size: 15px;
  color: var(--m-ink);
}
.sheet caption {
  padding: 12px 16px 10px;
  text-align: left;
  font-family: var(--serif); font-size: 17px; color: var(--m-ink);
  background: var(--m-paper);
}
.sheet th, .sheet td {
  padding: 9px 14px;
  text-align: right;
  border-bottom: 1px solid var(--m-rule);
  font-variant-numeric: tabular-nums lining-nums;
  white-space: nowrap;
}
.sheet thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--m-paper-2);
  border-bottom: 2px solid var(--m-ink);
  font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--m-ink-2);
}
.sheet tbody th { text-align: left; font-weight: 400; color: var(--m-ink); }
/* the round column and the first player column stay put while the rest scrolls */
.sheet th:first-child, .sheet td:first-child {
  position: sticky; left: 0; z-index: 2;
  width: var(--c1); min-width: var(--c1);
  background: var(--m-paper);
  text-align: left;
}
.sheet thead th:first-child { z-index: 4; background: var(--m-paper-2); }
.sheet th:nth-child(2), .sheet td:nth-child(2) {
  position: sticky; left: var(--c1); z-index: 2;
  min-width: var(--c2);
  background: var(--m-paper);
  box-shadow: 1px 0 0 var(--m-rule);
}
.sheet thead th:nth-child(2) { z-index: 4; background: var(--m-paper-2); }

/* the scorekeeper's ring around a round win */
.win {
  display: inline-grid; place-items: center;
  min-width: 26px; min-height: 26px; padding: 1px 5px;
  border: 1.5px solid var(--m-round);
  border-radius: 50%;
  color: var(--m-ink);
}
.sheet tbody tr:last-child th,
.sheet tbody tr:last-child td {
  border-top: 2px solid var(--m-ink);
  border-bottom: 0;
  font-weight: 700;
}
.sheet__note { margin: 0; padding: 10px 16px 12px; font-size: 12.5px; color: var(--m-ink-2); }

/* ---------------------------- 3. Pull line ------------------------------ */
.pullline {
  margin: 6px 0 26px;
  font-family: var(--serif);
  font-size: clamp(22px, 3.2vw, 31px); line-height: 1.2;
  color: var(--ink);
}

/* --------------------- 4. Cumulative score tables ----------------------- */
.cumwrap { overflow-x: auto; margin: 18px 0 20px; }
.cum {
  border-collapse: collapse;
  min-width: 340px;
  background: var(--m-paper);
  border: 1px solid var(--m-rule);
  font-size: 14.5px; color: var(--m-ink);
}
.cum caption {
  padding: 0 0 7px;
  text-align: left;
  font-size: 13px; color: var(--muted);
}
.cum th, .cum td {
  padding: 8px 14px;
  text-align: right;
  border-bottom: 1px solid var(--m-rule);
  font-variant-numeric: tabular-nums lining-nums;
}
.cum thead th {
  background: var(--m-paper-2);
  border-bottom: 1.5px solid var(--m-ink);
  font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--m-ink-2);
}
.cum tbody th { text-align: left; font-weight: 400; }
.cum tr:last-child th, .cum tr:last-child td { border-bottom: 0; }
/* the lowest total: a pencil smudge, not a colour badge */
.lead { background: #DCD5C0; font-weight: 700; }

/* ---------------------------- 5. Margin note ---------------------------- */
.scorenote {
  margin: 20px 0;
  padding: 14px 0 14px 16px;
  border-left: 2px solid var(--m-rule);
  font-size: 14px; line-height: 1.55; color: var(--muted);
}
.scorenote b { display: block; margin-bottom: 4px; color: var(--ink); font-size: 12px;
               letter-spacing: .08em; text-transform: uppercase; }

/* ---------------------- 6. Final-round arithmetic ----------------------- */
.final { min-width: 420px; }
.final .mark {
  display: inline-block;
  padding: 2px 10px;
  font-variant-numeric: tabular-nums lining-nums;
}
.mark--win { border: 1.5px solid var(--m-win); border-radius: 999px; color: var(--m-ink); }
.mark--limit { border-bottom: 3px solid var(--m-limit); color: var(--m-ink); }
.mark--round { border-bottom: 2px solid var(--m-round); color: var(--m-ink); }

/* ------------------------ 7. Choice illustrations ----------------------- */
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 20px 0 22px; }
.choice {
  --cw: 44px;
  --ch: calc(var(--cw) * 1.44);
  --cr: calc(var(--cw) * .1);
  display: grid; gap: 10px; align-content: start;
  padding: 14px;
  border: 1px solid var(--iline);
  border-radius: 6px;
}
.choice__h {
  margin: 0;
  font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ilink);
}
.choice__row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.choice__slot {
  display: grid; place-items: center;
  min-width: var(--cw); height: var(--ch);
  padding: 4px 7px;
  border: 1.5px dashed var(--m-rule);
  border-radius: var(--cr);
  color: var(--muted); font-size: 10.5px; line-height: 1.2; text-align: center;
}
/* the label and the two cards it introduces stay on one line together */
.choice__hold { display: flex; align-items: center; gap: 8px; }
.choice__held {
  font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.choice__cap { margin: 0; font-size: 13px; line-height: 1.45; color: var(--text); }
.choice .card { box-shadow: 0 6px 14px rgba(0, 0, 0, .5); }

/* --------------------------- 8. Responsive ------------------------------ */
@media (max-width: 900px) {
  /* the note follows the paragraph it belongs to rather than sitting beside it */
  .scorenote { margin: 16px 0; }
  .choices { grid-template-columns: minmax(0, 1fr); }
  .sheetwrap { --c1: 88px; --c2: 66px; }
  .sheet, .cum, .final { font-size: 14px; }
  .sheet th, .sheet td { padding: 8px 11px; }
}

@media (max-width: 480px) {
  /* never shrink the figures past this: scroll instead */
  .sheet { font-size: 13.5px; }
  .choice { --cw: 38px; --ch: calc(var(--cw) * 1.44); --cr: calc(var(--cw) * .1); }
}

/* ------------------------------ 9. Print -------------------------------- */
@media print {
  .matchpage { --ipage: #FFF; --ipanel: #FFF; --iline: #999; --ink: #14120E; --text: #23201A; --muted: #4E4838; }
  .matchpage .factstrip__inner { background: #FFF; }
  .sheetwrap, .sheet, .cum, .final { background: #FAF6EA; }
  .sheet thead, .cum thead { display: table-header-group; }
  .sheet thead th, .cum thead th { position: static; background: #F2ECDC; }
  .sheet th:first-child, .sheet td:first-child,
  .sheet th:nth-child(2), .sheet td:nth-child(2) { position: static; box-shadow: none; }
  .cumwrap, .sheetwrap { overflow-x: visible; break-inside: avoid; page-break-inside: avoid; }
  /* the final table and the sentence that reads it stay on one page */
  .finalblock { break-inside: avoid; page-break-inside: avoid; }
  .choices, .choice, .scorenote { break-inside: avoid; page-break-inside: avoid; }
  .pullline { color: #14120E; }
}
