/* Bets by contestant (/print). Each contestant's bets as a slip: the horse
   (silks, saddlecloth number, name) leads each row, then the bet and what it
   pays for each place. Reads on screen and prints cleanly on A4. */

:root {
  --turf: #1C4A2D;
  --turf-deep: #123420;
  --rail: #F2F4EE;
  --paper: #FFFFFF;
  --chalk: #FFFFFF;
  --ink: #0F2419;
  --ink-soft: rgb(15 36 25 / 0.65);
  --rule: rgb(15 36 25 / 0.14);
  --brass: #D8B24A;
  --rose: #C4203A;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0 1rem 2rem;
  background: var(--rail);
  color: var(--ink);
  font-family: 'Archivo', 'Roboto Condensed', 'Arial Narrow', sans-serif-condensed, system-ui, sans-serif;
  line-height: 1.3;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

a { color: inherit; }

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.print-button {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 0.4rem;
  height: 2.5rem;
  padding: 0 0.9rem;
  border: 0;
  border-radius: 3px;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-weight: 700;
  font-stretch: 85%;
  cursor: pointer;
}

.print-button .icon {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The shared header (header.css), lined up with the content below it */
.meet {
  max-width: 76rem;
  margin: 0 auto;
  padding-inline: 0;
}

/* When the figures are from, and the Print button */
.print-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 76rem;
  margin: 0 auto 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--rule);
}

.print-bar__asat {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-stretch: 88%;
}

/* Prize pool */

.purse {
  max-width: 76rem;
  margin: 0 auto 1.25rem;
}

.purse dl {
  display: grid;
  grid-template-columns: 1.3fr repeat(4, 1fr);
  margin: 0;
  border-top: 3px solid var(--brass);
  background: var(--ink);
  color: var(--rail);
}

.purse dl > div {
  min-width: 0;
  padding: 0.4rem 0.7rem 0.5rem;
}

.purse dl > div + div { border-left: 1px solid rgb(242 244 238 / 0.15); }

.purse dt {
  color: rgb(242 244 238 / 0.85);
  font-size: 0.85rem;
  font-stretch: 85%;
}

.purse__share { color: rgb(242 244 238 / 0.55); }

.purse dd {
  margin: 0;
  color: var(--brass);
  font-size: clamp(1rem, 3.5vw, 1.4rem);
  font-weight: 850;
  font-stretch: 70%;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.purse .purse__total { background: var(--brass); }
.purse .purse__total dt,
.purse .purse__total dd { color: var(--ink); }

.purse__note {
  margin: 0.4rem 0 0;
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-stretch: 88%;
}

/* Contestants */

.punters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 30rem), 1fr));
  align-items: start;
  gap: 1.25rem 1.5rem;
  max-width: 76rem;
  margin: 0 auto;
}

.empty {
  grid-column: 1 / -1;
  padding: 2rem 0;
  text-align: center;
}

.punter {
  border-top: 4px solid var(--turf);
  background: var(--paper);
  break-inside: avoid;
}

.punter__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0.75rem 0.4rem;
}

.punter__head h2 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 850;
  font-stretch: 62%;
  line-height: 1;
}

.punter__head p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-stretch: 88%;
}

.punter__head strong {
  color: var(--ink);
  font-weight: 800;
  font-stretch: 70%;
  font-size: 1.1em;
}

/* A contestant's slip: one row per horse */

.slip {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.slip thead th {
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 500;
  font-stretch: 88%;
  text-align: right;
}

.slip thead .slip__horse-col {
  padding-left: 0.75rem;
  text-align: left;
}

.slip tbody tr + tr { border-top: 1px solid var(--rule); }

.slip td {
  padding: 0.3rem 0.5rem;
  font-size: 0.95rem;
  font-stretch: 85%;
  text-align: right;
  white-space: nowrap;
}

.slip td:last-child { padding-right: 0.75rem; }

.slip .slip__bet {
  font-weight: 800;
  font-stretch: 70%;
}

/* The horse leads each row: silks, saddlecloth, name */
.slip__horse {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.3rem 0.5rem 0.3rem 0.75rem;
  text-align: left;
}

.slip__silk {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.5rem;
  height: 3.1rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--paper);
}

.slip__silk img {
  width: 2.2rem;
  height: auto;
}

.cloth {
  flex: none;
  min-width: 1.6rem;
  padding: 0.12em 0.2em 0.04em;
  border-radius: 2px;
  background: var(--ink);
  color: var(--paper);
  font-size: 1.35rem;
  font-weight: 900;
  font-stretch: 62%;
  line-height: 0.95;
  text-align: center;
}

.slip__name {
  min-width: 0;
  overflow: hidden;
  font-size: 1.2rem;
  font-weight: 750;
  font-stretch: 70%;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slip__scratched {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05em 0.35em;
  border-radius: 2px;
  background: var(--rose);
  color: var(--paper);
  font-size: 0.65em;
  font-weight: 650;
  font-stretch: 88%;
  vertical-align: 0.15em;
}

.slip tr.is-scratched .slip__silk { filter: grayscale(1); }
.slip tr.is-scratched .slip__name { color: var(--ink-soft); }
.slip tr.is-scratched td { color: var(--ink-soft); }

/* Phones: each row stacks, horse on top and the bet and payouts in a row
   beneath, each with its own label. Screens only: printing from a phone
   must give the same table as printing from a desktop. */
@media screen and (max-width: 599px) {
  body { padding-inline: 0.5rem; }

  .purse dl { grid-template-columns: repeat(4, 1fr); }
  .purse .purse__total {
    display: flex;
    grid-column: 1 / -1;
    align-items: baseline;
    justify-content: space-between;
  }
  .purse dl > div:nth-child(2) { border-left: 0; }

  .slip thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .slip tbody tr {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 0.35rem 0 0.45rem;
  }

  .slip__horse { grid-column: 1 / -1; padding-bottom: 0.2rem; }

  .slip td {
    padding: 0 0.2rem;
    font-size: 0.9rem;
    text-align: center;
  }

  .slip td:last-child { padding-right: 0.2rem; }

  .slip td::before {
    content: attr(data-label);
    display: block;
    color: var(--ink-soft);
    font-size: 0.72rem;
    font-weight: 500;
  }
}

/* Printing: white paper, one column, no screen-only controls, and no
   contestant split across two pages */
@media print {
  @page { size: A4; margin: 12mm; }

  body {
    padding: 0;
    background: var(--paper);
    font-size: 10pt;
  }

  .print-button,
  .menu { display: none; }

  .meet { padding-top: 0; }

  /* Fixed sizes: the screen ones scale with the window (vw), which a phone
     would carry into its printout */
  .meet h1,
  .meet__page { font-size: 20pt; }
  .pool { font-size: 10pt; }
  .purse dd { font-size: 14pt; }

  .meet,
  .print-bar,
  .purse,
  .punters { max-width: none; }

  /* Pool as outlined boxes rather than a solid band, to save ink */
  .purse dl {
    border: 1px solid var(--ink);
    border-top-width: 3px;
    background: none;
    color: var(--ink);
  }
  .purse dl > div + div { border-left-color: var(--rule); }
  .purse dt,
  .purse__share { color: var(--ink-soft); }
  .purse dd { color: var(--ink); }
  .purse .purse__total { background: none; }

  .punters {
    display: block;
    columns: 1;
  }

  /* Keep each contestant's bets together on one page. break-inside is the
     standard rule (Chrome, Edge, Firefox); page-break-inside is its older
     form; and Safari won't split an inline-block across pages, which covers
     printing from an iPhone or iPad, where the other two are ignored. */
  .punter {
    display: inline-block;
    width: 100%;
    margin-bottom: 5mm;
    border-top: 2px solid var(--ink);
    vertical-align: top;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* If a contestant ever has more bets than fit on a page, still never
     split a row or leave their name alone at the foot of a page */
  .slip tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .punter__head {
    break-after: avoid;
    page-break-after: avoid;
  }

  .cloth {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}
