/* Card tools (tools/sitegen/pages/card_tools.py): printable score sheets and the cribbage hand counter.
   Loaded only on those pages, after site.css, whose tokens and components it builds on.
   [hidden] wins over the display these set, so a part that waits for its script stays out of sight without it. */
.tool-hero .title-hero-grid { padding-bottom: calc(var(--space) * 6); }
.tool-hero > .container > h1 { max-width: 22ch; }
.tool-hero > .container { padding-bottom: calc(var(--space) * 7); }
.tool-hero .game-logo { margin: 0 auto; }
.tool-hero .btn-row { margin-top: calc(var(--space) * 2); }
.tool-links { margin-top: calc(var(--space) * 4); justify-content: center; }
.tool-subhead { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: calc(var(--space) * 3); text-align: center; }
.tool-subhead + .chips { justify-content: center; }
.crib-counter[hidden] { display: none; }

/* A score sheet: on screen, a sheet of paper; in print, the only thing on the page */
.sheet-scroll { overflow-x: auto; padding: 4px 4px 12px; }
.sheet { min-width: 680px; max-width: 980px; margin: 0 auto; background: #fff; color: #1E2733; border: 3px solid var(--ink); border-radius: var(--radius-tile); box-shadow: var(--pop); padding: calc(var(--space) * 4); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 2px solid #1E2733; padding-bottom: 8px; }
.sheet-logo { height: 80px; width: auto; flex: none; align-self: center; }
.sheet-name { font-size: 1.6rem; line-height: 1.1; margin-right: auto; }
.sheet-target { font-family: var(--font-display); font-weight: 800; font-size: 1.1rem; }
.sheet-blanks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 24px; margin: 16px 0 18px; }
.blank { display: flex; align-items: flex-end; gap: 8px; font-size: .9rem; }
.blank b { white-space: nowrap; font-weight: 800; }
.blank i { flex: 1; border-bottom: 1px solid #8A93A3; height: 1.4em; }
.sheet-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: .875rem; font-variant-numeric: tabular-nums; }
.sheet-table th, .sheet-table td { border: 1px solid #A9B1BE; padding: 2px 4px; text-align: center; }
.sheet-table thead th { font-weight: 800; line-height: 1.15; }
.sheet-table th.side { font-family: var(--font-display); font-size: 1rem; border-bottom-width: 2px; border-bottom-color: #1E2733; }
.sheet-table tbody tr { height: 34px; }
.sheet-table .lead-col { color: #566175; font-weight: 700; }
.sheet-table th.hand-col { width: 3.2em; }
.sheet-table th.note-col { width: 6.5em; }
.sheet-table td.lead-col { font-size: .8125rem; }
.sheet-table .first { border-left: 2px solid #1E2733; }
.sheet-table .total { border-left-color: #566175; border-left-width: 2px; font-weight: 800; }
.sheet-table tr.foot th, .sheet-table tr.foot td { border-top: 2px solid #1E2733; }
.sheet-table tr.foot th { text-align: right; }
.sheet-key { margin-top: 12px; font-size: .875rem; line-height: 1.45; }
.sheet-foot { margin-top: 6px; font-size: .75rem; color: #566175; }

/* The cribbage hand counter */
.crib-counter { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: calc(var(--space) * 4); align-items: start; padding: calc(var(--space) * 4); }
.crib-slots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: calc(var(--space) * 3); }
.crib-slot { min-height: 84px; border-radius: 12px; border: 3px dashed #A9B1BE; background: var(--bg); color: var(--ink-2); font: 700 .875rem var(--font-body); cursor: default; }
.crib-slot.starter { border-color: var(--gold); background: #FFF8E2; }
.crib-slot.filled { border-style: solid; border-color: var(--ink); background: #fff; color: var(--ink); font: 900 1.6rem var(--font-display); box-shadow: 0 4px 0 var(--ink); cursor: pointer; }
.crib-slot.filled.red, .crib-card.red { color: var(--red); }
.crib-type { display: block; margin-bottom: 6px; }
.crib-type small { display: block; color: var(--ink-2); font-size: .9rem; }
.crib-input { width: 100%; min-height: 52px; padding: 0 16px; border: 3px solid var(--ink); border-radius: 14px; font: 800 1.15rem var(--font-body); letter-spacing: .04em; color: var(--ink); background: #fff; }
.crib-or { margin: 14px 0 8px; color: var(--ink-2); font-size: .9375rem; }
.crib-grid { display: grid; gap: 6px; }
.crib-suit { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 4px; }
.crib-card { min-height: var(--tap); border: 2px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink); font: 800 .9375rem var(--font-body); line-height: 1; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 2px 0; }
.crib-card span { font-size: .9em; }
.crib-card:hover { background: var(--lynx-soft); }
.crib-card[aria-pressed="true"] { background: var(--ink); color: #fff; }
.crib-card.red[aria-pressed="true"] { background: var(--red); color: #fff; border-color: var(--red); }
.crib-card:disabled { opacity: .35; cursor: default; background: #fff; }
.crib-options { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: calc(var(--space) * 2.5); }
.crib-check { display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap); font-weight: 800; cursor: pointer; }
.crib-check input { width: 24px; height: 24px; accent-color: var(--felt); }
.crib-result { position: sticky; top: 90px; background: var(--ivory); border: 3px solid var(--ink); border-radius: var(--radius-tile); padding: calc(var(--space) * 3); min-height: 200px; }
.crib-total { font-weight: 700; color: var(--ink-2); }
.crib-total.crib-error { color: var(--red); }
.crib-big { font: 900 4rem/1 var(--font-display); color: var(--ink); }
.crib-of { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; color: var(--ink); }
.crib-breakdown { margin-top: 14px; display: grid; gap: 12px; }
.crib-line { display: flex; justify-content: space-between; gap: 12px; border-bottom: 2px solid var(--ink); padding-bottom: 2px; }
.crib-line b { font-family: var(--font-display); font-weight: 800; }
.crib-pts { font-weight: 800; white-space: nowrap; }
.crib-breakdown ul { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .9375rem; color: var(--ink-2); }
.crib-zero, .crib-note { margin-top: 12px; font-size: .9375rem; }
.crib-noscript { text-align: center; }
.table-scroll { overflow-x: auto; margin: 0 0 calc(var(--space) * 2); }
.worked { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.worked th, .worked td { text-align: left; vertical-align: top; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.worked thead th { font-family: var(--font-display); font-weight: 800; border-bottom: 2px solid var(--ink); }
.worked tbody th { white-space: nowrap; }
.worked tbody th a { font-size: 1.05rem; }
.worked .num { font-family: var(--font-display); font-weight: 900; font-size: 1.25rem; text-align: center; }
@media (max-width: 860px) {
  .crib-counter { grid-template-columns: 1fr; padding: calc(var(--space) * 2.5); }
  .crib-result { position: static; min-height: 0; }
  .tool-hero .title-hero-art { display: none; }
  .tool-hero .title-hero-grid { padding-bottom: calc(var(--space) * 4); }
}
@media (max-width: 640px) {
  .crib-suit { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .crib-slots { gap: 6px; }
  .crib-slot { min-height: 64px; font-size: .75rem; }
  .crib-slot.filled { font-size: 1.25rem; }
  .crib-big { font-size: 3.2rem; }
}

@media print {
  @page { margin: 12mm; }
  .sheet-page .skip, .sheet-page .site-header, .sheet-page .site-footer, .sheet-page main > :not(.sheet-band), .sheet-page .no-print { display: none !important; }
  .sheet-page, .sheet-page main, .sheet-band { background: #fff !important; }
  .sheet-band { padding: 0; }
  .sheet-band .container { max-width: none; padding: 0; }
  .sheet-scroll { overflow: visible; padding: 0; }
  .sheet { min-width: 0; max-width: none; border: 0; border-radius: 0; box-shadow: none; padding: 0; color: #000; }
  .sheet-head { border-bottom: .4mm solid #000; padding-bottom: 2mm; }
  .sheet-logo { height: 22mm; }
  .sheet-name { font-size: 18pt; }
  .sheet-target { font-size: 12pt; }
  .sheet-blanks { grid-template-columns: repeat(4, 1fr); gap: 3mm 6mm; margin: 4mm 0; }
  .blank { font-size: 9pt; }
  .blank i { border-bottom: .25mm solid #777; }
  .sheet-table { font-size: 8.5pt; page-break-inside: avoid; break-inside: avoid; }
  .sheet-table th, .sheet-table td { border: .2mm solid #999; padding: .6mm 1mm; }
  .sheet-table tbody tr { height: min(12mm, calc(182mm / var(--rows))); }
  .sheet-table th.side { font-size: 10pt; border-bottom: .4mm solid #000; }
  .sheet-table .first { border-left: .5mm solid #000; }
  .sheet-table .total { border-left: .4mm solid #555; }
  .sheet-table tr.foot th, .sheet-table tr.foot td { border-top: .4mm solid #000; }
  .sheet-table .lead-col, .sheet-foot { color: #444; }
  .sheet-key { font-size: 8.5pt; margin-top: 3mm; }
  .sheet-foot { font-size: 7.5pt; margin-top: 1.5mm; }
}
