/* The player's Reports page (public/js/views/reports.js and its graphics, views/reports/graphics.js; prefix rp-), and
   the quiet link the statement shares (c-link). Colours are the tokens in styles.css: charts in ink, win and loss; red
   only ever means a loss, and gold stays off the page (it belongs to a pick and the Place button); claret marks the
   period chosen, as it marks where you are everywhere. Lengths come from data-style, set by script, because the page
   allows no inline styles. Text on a card is in the inks test/themes.test.js checks there: text, muted and faint, win
   and loss on the card, win and loss-ink on its second surface. */

/* A link in the page's own ink. */
.c-link { display: inline-flex; align-items: center; min-height: 44px; font-size: calc(14px * var(--type)); color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.c-link:hover { color: var(--text); }

/* The page: the head (the title and the period switch), the blocks, and the foot. One column on a phone, in the
   page's order; from 900px twelve columns: the result across, then the three breakdowns, then the biggest win and
   loss beside the plain facts. Changing period cross-fades the blocks (180ms, reports.js). */
.rp { display: grid; gap: 12px; padding-bottom: 24px; }
.rp-head { display: grid; gap: 14px; padding: 20px 0 4px; }
.rp-body { display: grid; gap: 12px; align-items: stretch; }
.rp-body > .card + .card { margin-top: 0; }
.rp-title { margin: 0; font-size: calc(16px * var(--type)); font-weight: 600; }
.rp-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; margin: -4px 0 6px; }
.rp-tip { margin: 0 0 12px; }
/* The foot: the statement and the player's limits, then the 18+ sign-off (styles.css .signoff) with its clear space. */
.rp-foot { display: grid; justify-items: start; gap: 12px; padding: 4px 4px 0; }
.rp-links { display: flex; flex-wrap: wrap; gap: 0 20px; }

/* The period switch: three links, each a period's name over its own result with its direction mark; the one chosen
   is the claret block, its figure in the block's ink (the sign and the mark still say which way). */
.rp-periods { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 20px; background: var(--surface-2); }
.rp-period { display: grid; gap: 1px; justify-items: center; align-content: center; min-height: 56px; padding: 6px 8px; border-radius: 16px; transition: background-color .18s, color .18s; }
.rp-period-name { font-size: calc(13px * var(--type)); font-weight: 500; color: var(--muted); }
.rp-period-fig { display: inline-flex; align-items: center; gap: 4px; font-size: calc(15px * var(--type)); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-period:hover .rp-period-name { color: var(--text); }
.rp-period.is-active { background: var(--block); color: var(--block-ink); }
.rp-period.is-active .rp-period-name, .rp-period.is-active .rp-period-fig { color: var(--block-ink); }
/* In the dark theme the chosen period wears the chosen chip's ring as well (styles.css, after .seg). */
:root:not([data-theme="light"]) .rp-period.is-active { box-shadow: inset 0 0 0 2px var(--switch-on); }
.rp-arrow { flex: none; width: 9px; height: 9px; fill: currentColor; }

/* The result: the word and the figure, one size and weight for a loss as for a profit, the line of words under it,
   then the trace. The figure fits its column: 52px, smaller only when the column is narrow. */
.rp-result { display: grid; gap: 14px; padding: 16px 16px 14px; }
.rp-sum { display: grid; align-content: start; min-width: 0; container-type: inline-size; }
.rp-sum-head { display: flex; align-items: center; gap: 2px; min-height: 32px; }
.rp-word { margin: 0 auto 0 0; font-size: calc(16px * var(--type)); font-weight: 600; }
.rp-fig { display: block; margin: 2px 0 6px; font-size: calc(52px * var(--type)); font-size: min(calc(52px * var(--type)), 15.5cqi); font-weight: 600; letter-spacing: -0.03em; line-height: 1.02; white-space: nowrap; }
.rp-read { min-height: 1.45em; font-size: calc(14px * var(--type)); line-height: 1.45; color: var(--muted); font-variant-numeric: tabular-nums; }
.rp-chart { min-width: 0; }
.rp-mid, .rp-wide { display: none; }

/* The trace is SVG drawn at a set size and scaled to its card. As the page or a period arrives (is-drawing, set by
   reports.js and taken off again) the line draws once from left to right (700ms), then its ground and the day bars
   fade in; the same for a loss and a profit. It never draws again for a window made wider or a drawing swapped. A
   finger or the pointer along it, or the arrow keys, read a day (bindTrace). */
.rp-trace { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; cursor: crosshair; }
.rp-trace.is-empty { cursor: default; }
.rp-trace:focus-visible { outline: 2px solid var(--text); outline-offset: 4px; border-radius: 8px; }
.rp-trace text { font-family: var(--sans); font-variant-numeric: tabular-nums; }
.rp-trace .axis { font-size: 11px; fill: var(--faint); }
.rp-trace .axis.is-zero { fill: var(--text); font-weight: 600; }
.rp-trace .grid, .rp-trace .rule { stroke: var(--line); stroke-width: 1; }
.rp-trace .zero { stroke: var(--line-strong); stroke-width: 1.5; }
.rp-trace .up { fill: var(--win); fill-opacity: .16; }
.rp-trace .down { fill: var(--loss); fill-opacity: .16; }
.is-drawing .rp-trace .up, .is-drawing .rp-trace .down { animation: rp-ground .3s .55s ease-out both; }
.rp-trace .line { fill: none; stroke: var(--text); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.is-drawing .rp-trace .line { stroke-dasharray: 1; animation: rp-draw .7s var(--ease) both; }
.is-drawing .rp-trace .bars { animation: rp-in .3s .45s ease-out both; }
.rp-trace .bar.is-up { fill: var(--win); }
.rp-trace .bar.is-down { fill: var(--loss); }
.rp-trace .bar.is-flat { fill: var(--line-strong); }
.rp-trace .end { fill: var(--text); stroke: var(--surface); stroke-width: 2; }
.rp-trace .end.pos { fill: var(--win); }
.rp-trace .end.neg { fill: var(--loss); }
.rp-trace .none { font-size: 14px; fill: var(--muted); }
.rp-trace .scrub { visibility: hidden; pointer-events: none; }
.rp-trace.is-reading .scrub { visibility: visible; }
.rp-trace .scrub-rule { stroke: var(--text); stroke-width: 1; stroke-opacity: .45; }
.rp-trace .scrub-dot { fill: var(--surface); stroke: var(--text); stroke-width: 2; }
@keyframes rp-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes rp-ground { from { fill-opacity: 0; } }
@keyframes rp-in { from { opacity: 0; } }

/* The trace's two marks, named: the line, and the day bars (one up in the win colour, one down in the loss colour). */
.rp-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: calc(12.5px * var(--type)); color: var(--muted); }
.rp-legend li { display: inline-flex; align-items: center; gap: 6px; }
.rp-key { position: relative; display: block; flex: none; width: 14px; height: 12px; }
.rp-key.is-line { height: 2px; border-radius: 1px; background: var(--text); }
.rp-key.is-bars::before, .rp-key.is-bars::after { content: ''; position: absolute; width: 4px; height: 7px; border-radius: 1px; transform: skewX(calc(var(--lean) * -1)); }
.rp-key.is-bars::before { left: 2px; top: 0; background: var(--win); }
.rp-key.is-bars::after { right: 2px; bottom: 0; background: var(--loss); }

/* The table behind the trace, opened from the table button in the card's corner. */
.rp-table { overflow-x: auto; }
.rp-table table { width: 100%; border-collapse: collapse; font-size: calc(13px * var(--type)); font-variant-numeric: tabular-nums; }
.rp-table th, .rp-table td { padding: 8px 0 8px 12px; text-align: right; white-space: nowrap; }
.rp-table thead th { padding-top: 4px; font-weight: 500; color: var(--faint); }
.rp-table tbody th, .rp-table td { box-shadow: inset 0 1px var(--line); }
.rp-table tbody th { font-weight: 500; color: var(--text); }
.rp-table th:first-child { padding-left: 0; text-align: left; }

/* By sport, By bet type and By price: a mark, the name over its bets, the signed result, and the swing under them:
   a bar from the middle line, left for a loss and right for a profit, growing from the line once (500ms). */
.rp-rows { display: grid; }
.rp-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 7px 10px; align-items: center; padding: 11px 0 12px; }
.rp-row:first-child { padding-top: 2px; }
.rp-row:last-child { padding-bottom: 4px; }
.rp-row + .rp-row { box-shadow: inset 0 1px var(--line); }
.rp-mark { display: grid; place-items: center; width: 28px; }
.rp-mark .ico { width: 20px; height: 20px; }
.rp-what { display: grid; min-width: 0; }
.rp-what b { font-size: calc(15px * var(--type)); font-weight: 600; }
.rp-what span { font-size: calc(13px * var(--type)); color: var(--muted); }
.rp-what b .px, .rp-what b .px span { font-size: inherit; color: inherit; }
.rp-net { font-size: calc(15px * var(--type)); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-swing { position: relative; grid-column: 1 / -1; display: block; height: 6px; border-radius: 3px; background: linear-gradient(var(--line-strong), var(--line-strong)) center / 2px 100% no-repeat, var(--surface-2); }
.rp-swing i { position: absolute; top: 0; bottom: 0; width: max(3px, calc(var(--share, 0) * 50%)); }
.is-drawing .rp-swing i { animation: rp-swing .5s var(--ease) both; }
.rp-swing .is-pos { left: 50%; border-radius: 0 3px 3px 0; background: var(--win); transform-origin: 0 50%; }
.rp-swing .is-neg { right: 50%; border-radius: 3px 0 0 3px; background: var(--loss); transform-origin: 100% 50%; }
@keyframes rp-swing { from { transform: scaleX(0); } }
/* A bet type's mark: the logo's slanted bars in ink, one a selection; each way's second part in outline. A price's
   mark: the same bars as four steps, as many standing as the price is big. */
.rp-bars, .rp-steps { display: inline-flex; align-items: flex-end; gap: 2px; }
.rp-bars i, .rp-steps i { display: block; width: 5px; height: 13px; border-radius: 1px; transform: skewX(calc(var(--lean) * -1)); background: var(--text); }
.rp-bars i.is-part { background: none; box-shadow: inset 0 0 0 1.5px var(--text); }
.rp-steps i { width: 4px; }
.rp-steps i:nth-child(1) { height: 5px; }
.rp-steps i:nth-child(2) { height: 8px; }
.rp-steps i:nth-child(3) { height: 11px; }
.rp-steps i:nth-child(4) { height: 14px; }
.rp-steps i.is-off { background: var(--line-strong); }

/* The biggest win and loss: the ticket's notched card and stub (styles.css .ticket-body and .ticket-stub), side by
   side at every width, never dimmed. */
.rp-best { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.rp-best { grid-template-rows: 1fr auto; }
/* Each docket takes the pair's two rows, so the two stubs start on one line whatever each holds. */
.rp-docket { display: grid; grid-row: span 2; grid-template-rows: 1fr auto; grid-template-rows: subgrid; row-gap: 0; min-width: 0; }
.rp-docket-body, .rp-docket-stub { display: grid; gap: 3px; align-content: start; min-width: 0; }
.rp-docket-body {
  padding: 16px 16px 14px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface);
  -webkit-mask: radial-gradient(circle at 0 100%, #0000 7px, #000 7.5px) 0 0 / 51% 100% no-repeat, radial-gradient(circle at 100% 100%, #0000 7px, #000 7.5px) 100% 0 / 51% 100% no-repeat;
  mask: radial-gradient(circle at 0 100%, #0000 7px, #000 7.5px) 0 0 / 51% 100% no-repeat, radial-gradient(circle at 100% 100%, #0000 7px, #000 7.5px) 100% 0 / 51% 100% no-repeat;
}
.rp-docket.is-none .rp-docket-body { grid-row: span 2; border-radius: var(--radius); -webkit-mask: none; mask: none; }
.rp-docket-stub {
  padding: 12px 16px 14px;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface-2);
  -webkit-mask: radial-gradient(circle at 0 0, #0000 7px, #000 7.5px) 0 0 / 51% 100% no-repeat, radial-gradient(circle at 100% 0, #0000 7px, #000 7.5px) 100% 0 / 51% 100% no-repeat;
  mask: radial-gradient(circle at 0 0, #0000 7px, #000 7.5px) 0 0 / 51% 100% no-repeat, radial-gradient(circle at 100% 0, #0000 7px, #000 7.5px) 100% 0 / 51% 100% no-repeat;
}
.rp-docket .rp-title { margin-bottom: 8px; }
.rp-docket-pick { font-size: calc(15px * var(--type)); font-weight: 600; overflow-wrap: anywhere; }
.rp-docket-line { font-size: calc(13px * var(--type)); color: var(--muted); overflow-wrap: anywhere; }
.rp-docket-none { font-size: calc(15px * var(--type)); }
.rp-docket-figs { display: grid; gap: 5px; }
.rp-docket-figs > div { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 8px; }
.rp-docket-figs dt { font-size: calc(13px * var(--type)); color: var(--muted); }
.rp-docket-figs dd { font-size: calc(14px * var(--type)); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-docket-stub .pos { color: var(--win); }
.rp-docket-stub .neg { color: var(--loss-ink); }

/* The plain facts: the count of bets, how they finished as one bar in three parts with its three counts, then three
   figures a row each. */
.rp-facts { display: grid; gap: 12px; align-content: start; }
.rp-count { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.rp-count b { font-size: calc(34px * var(--type)); font-weight: 600; letter-spacing: -0.02em; line-height: 1; }
.rp-tally { display: grid; gap: 8px; }
.rp-tally-bar { display: flex; gap: 2px; height: 8px; border-radius: 4px; overflow: hidden; background: var(--surface-2); }
.rp-tally-bar i { flex: var(--share, 0) 1 0; min-width: 3px; }
.rp-tally-bar .is-pos { background: var(--win); }
.rp-tally-bar .is-flat { background: var(--line-strong); }
.rp-tally-bar .is-neg { background: var(--loss); }
.rp-tally-words { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: calc(13px * var(--type)); color: var(--muted); }
.rp-tally-words b { color: var(--text); }
.rp-facts-list { display: grid; }
.rp-facts-list > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 0; box-shadow: inset 0 1px var(--line); }
.rp-facts-list > div:last-child { padding-bottom: 0; }
.rp-facts-list dt { font-size: calc(14px * var(--type)); color: var(--muted); }
.rp-facts-list dd { font-size: calc(15px * var(--type)); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (min-width: 600px) {
  .rp-mid { display: block; }
  .rp-narrow { display: none; }
  .rp-head { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
  .rp-period { min-width: 124px; }
}
@media (min-width: 900px) {
  .rp-body { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .rp-result { grid-column: 1 / -1; gap: 10px; padding: 20px 20px 16px; }
  .rp-sum { grid-template-columns: minmax(0, 1fr) auto; column-gap: 24px; align-items: end; }
  .rp-sum-head, .rp-sum .rp-tip { grid-column: 1 / -1; }
  .rp-fig { margin-bottom: 0; font-size: calc(56px * var(--type)); }
  .rp-read { text-align: right; padding-bottom: 4px; }
  .rp-split { grid-column: span 4; }
  .rp-best, .rp-facts { grid-column: span 6; }
}

/* The widest drawing, from the width its figures are comfortable at. */
@media (min-width: 1100px) {
  .rp-wide { display: block; }
  .rp-mid { display: none; }
  .rp-wide .rp-trace .axis { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .is-drawing .rp-trace .line { stroke-dasharray: none; }
  .is-drawing .rp-trace .line, .is-drawing .rp-trace .up, .is-drawing .rp-trace .down, .is-drawing .rp-trace .bars, .is-drawing .rp-swing i { animation: none; }
}

/* On paper: the switch, the buttons, the links and the reading rule left off; the dockets whole. */
@media print {
  .rp-periods, .rp-links, .rp-sum-head .icon-btn, .rp-title-row .icon-btn, .rp-trace .scrub { display: none !important; }
  .rp .rp-docket { break-inside: avoid; box-shadow: inset 0 0 0 1px #ccc; }
  .rp .rp-docket-body, .rp .rp-docket-stub { -webkit-mask: none; mask: none; }
}
