/* Tool-specific layout only. Faces, buttons, fields, the title, the toolbar
   and the table come from ../assets/base.css over the vendored system. This
   file draws the count panel and the on-screen card. */

/* Anything typed that ends up printed goes in mono: the field is the machine's
   register, and the card is where the type is set properly. */
.field.num,
.field.seed,
.field.heading,
.field.subtitle,
.field.freelabel {
  font-family: var(--pp-font-mono);
  font-size: 0.86rem;
}
.field.num {
  width: 90px;
}
.field.num.narrow {
  width: 68px;
}
.field.seed {
  width: 132px;
}
.field.heading {
  width: 148px;
}
.field.subtitle {
  width: 190px;
}
.field.freelabel {
  width: 96px;
}

/* The presets sit in a group that already has a gap, so they close up against
   each other and read as one control. */
.group.presets {
  gap: 4px;
  margin-right: 4px;
}

/* ── The image ─────────────────────────────────────────────────────────── */

/* Everything that only exists once a file has been chosen, in one box so a
   single [hidden] governs the lot. The drawn <select> inside is wrapped by
   controls.js after this script has run, which is the other reason: hiding the
   real element would leave its replacement on the page. */
.mark-set {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* The file, named and shown. A tag by the system's reading — a label rather
   than a control — so it takes the pill, and the one control on it is the
   dismiss. */
.mark-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  max-width: 15rem;
  padding: 0.18rem 0.3rem 0.18rem 0.28rem;
  border: var(--pp-rule-line) solid var(--pp-line);
  border-radius: var(--pp-radius-pill);
}
.mark-thumb {
  width: 20px;
  height: 20px;
  object-fit: contain;
  border-radius: var(--pp-radius-sm);
  /* A logo saved with a transparent surround needs something behind it, and the
     something is the stock the card is drawn on — the same as a cell's, so the
     thumbnail and the preview agree about what the picture will look like. */
  background: var(--pp-surface);
}
.mark-name {
  font-family: var(--pp-font-mono);
  font-size: 0.72rem;
  letter-spacing: var(--w-track-label);
  color: var(--pp-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mark-drop {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: var(--pp-radius-sm);
  font-size: 0.9rem;
  line-height: 1;
  color: var(--pp-faint);
}
.mark-drop:hover {
  background: var(--pp-tint);
  color: var(--pp-ink);
}
.mark-drop:active {
  transform: var(--w-press);
}

.field.mark-where {
  font-family: var(--pp-font-mono);
  font-size: 0.86rem;
}

.card.prompt {
  font-size: 0.94rem;
  line-height: 1.62;
  color: var(--pp-muted);
}
.card.prompt strong {
  font-family: var(--pp-font-mono);
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--pp-ink);
}

/* The list and the count are one unit: typing a square moves the number, so
   they sit side by side. Below the measure they stack, list first. */
.bench {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 1.5rem 2rem;
  align-items: start;
  margin-bottom: 1.75rem;
}
@media (max-width: 880px) {
  .bench {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* The list is the one field holding prose in bulk, and it is still a field:
   same edge, same focus, mono because every line will be set on a card. */
.field.list {
  display: block;
  width: 100%;
  height: auto;
  padding: 0.7rem 0.8rem;
  font-family: var(--pp-font-mono);
  font-size: 0.82rem;
  line-height: 1.7;
  resize: vertical;
}

.entries .result-bar,
.count .section-label {
  margin-bottom: 0.85rem;
}

/* The count is the tool's main answer, so it is set at display size rather
   than as another row of figures. */
.count-body {
  padding: 1rem 0.8rem 0.9rem;
}

.count-big {
  margin: 0;
  font-family: var(--pp-font-display);
  font-weight: var(--pp-weight-head);
  font-size: clamp(1.5rem, 4.4vw, 2.1rem);
  letter-spacing: var(--pp-track-head);
  line-height: 1.1;
  overflow-wrap: anywhere;
}
/* An empty list is a state rather than a failure, so it takes the quiet ink
   rather than a plate. */
.count-big.is-none {
  color: var(--pp-faint);
}

/* The exact figure, under the readable one. It wraps anywhere, because the
   alternative is a sheet that scrolls sideways. */
.count-exact {
  margin: 0.5rem 0 0;
  font-family: var(--pp-font-mono);
  font-size: 0.72rem;
  line-height: 1.6;
  letter-spacing: var(--w-track-mono);
  color: var(--pp-faint);
  overflow-wrap: anywhere;
}
.count-exact:empty {
  display: none;
}

.count-facts {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 1rem;
  margin: 0.9rem 0 0;
  padding-top: 0.75rem;
  border-top: var(--pp-rule-hairline) solid var(--pp-hair);
  font-family: var(--pp-font-mono);
  font-size: var(--pp-size-label);
  letter-spacing: var(--w-track-label);
}
.count-facts dt {
  color: var(--pp-faint);
  padding: 0.24rem 0;
}
.count-facts dd {
  margin: 0;
  padding: 0.24rem 0;
  text-align: right;
  color: var(--pp-ink);
  overflow-wrap: anywhere;
}

/* The settings that produce the cards, separated from those that describe
   them. No bottom rule: the result appears directly underneath. */
.toolbar.make {
  border-bottom: 0;
  margin-bottom: 1.35rem;
}

/* ── The deal ──────────────────────────────────────────────────────────── */

.pager {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.8rem;
  border-bottom: var(--pp-rule-hairline) solid var(--pp-hair);
}
.pager-at,
.pager-note {
  font-family: var(--pp-font-mono);
  font-size: var(--pp-size-label);
  letter-spacing: var(--w-track-label);
  color: var(--pp-muted);
}
.pager-note {
  color: var(--pp-faint);
}
.pager-rule {
  flex: 1;
  height: 0;
  border-top: var(--pp-rule-hairline) solid var(--pp-hair);
}
.pager .preset {
  width: 32px;
  padding: 0;
  font-size: 1rem;
}

/* The card stands on the sheet as it will on the page: white stock, centred,
   with room around it. The stage keeps its own ground rather than the sheet's. */
.card-stage {
  position: relative;
  display: flex;
  justify-content: center;
  padding: 1.25rem 0.8rem 1.4rem;
  background: var(--w-wash-0);
}

/* The card and the band a corner image stands in, which is the part of the page
   the preview can honestly show. The band only exists when there is something
   to put in it, so a card with no image sits exactly where it always did. */
.card-page {
  position: relative;
  width: min(100%, 460px);
}
.card-page[data-mark^='t'] {
  padding-top: 58px;
}
.card-page[data-mark^='b'] {
  padding-bottom: 58px;
}

/* On the page the mark hangs off the frame's own edge, above the grid or below
   it, so it does here too. The stage is not the page — it has no heading and no
   footer — so this says which corner and roughly how big, and the PDF is where
   it lands for real. */
.stage-mark {
  position: absolute;
  width: 48px;
  height: 48px;
  object-fit: contain;
  background: var(--pp-surface);
}
.stage-mark[data-where='tl'] { top: 0; left: 0; }
.stage-mark[data-where='tr'] { top: 0; right: 0; }
.stage-mark[data-where='bl'] { bottom: 0; left: 0; }
.stage-mark[data-where='br'] { bottom: 0; right: 0; }

/* A picture in the free square, filling the cell the way it will on paper. */
.cell-mark {
  width: 100%;
  height: 100%;
  padding: 6%;
  object-fit: contain;
}

/* A bingo card. Square cells, one rule between them, a heavier edge around the
   whole, matching the three weights the printed page uses. The interior rules
   are the grid's ground showing through a 1px gap rather than borders on the
   cells, which would need the last row and column suppressed. */
.bingo {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), 1fr);
  gap: var(--pp-rule-line);
  width: min(100%, 460px);
  background: var(--pp-line);
  outline: var(--pp-rule-structure) solid var(--pp-edge);
  container-type: inline-size;
}

.bingo-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  padding: 4px;
  background: var(--pp-surface);
  /* Type scaled to the cell, not to the window: a 3×3 preview should read like
     a poster and an 8×8 one like a ticket, which is what they will do on
     paper. The clamp above is what a browser without container units gets. */
  font-size: clamp(0.44rem, 1.4vw, 0.6rem);
  font-size: max(7px, calc(100cqw / var(--cols, 5) * 0.155));
  line-height: 1.2;
  text-align: center;
  /* A cell on paper shrinks its type until the words fit. A cell on screen
     cannot, so it breaks anywhere and hides what still will not go: the
     preview says where each square lands and how crowded it is, and the PDF is
     where the fitting actually happens. */
  overflow: hidden;
  overflow-wrap: anywhere;
  hyphens: auto;
}

/* The free square, washed. --pp-tint is ink at an alpha, and every cell here
   is sitting on the grid's own --pp-line ground, so setting it as the
   background alone would let the rule colour up through it and print a mid
   grey. Laid over the stock as a second layer it comes out at the strength it
   is meant to be. */
.bingo-cell.is-free {
  background: linear-gradient(var(--pp-tint), var(--pp-tint)) var(--pp-surface);
  font-weight: var(--pp-weight-strong);
  letter-spacing: var(--w-track-label);
}

/* The seed a deal actually used, offered back as a control: pressing it puts
   the seed in the field so the same cards can be dealt again. Same object as
   the Random Number Generator's, because it is the same promise. */
.seed-tag {
  padding: 0.1rem 0.5rem;
  background: transparent;
  border: var(--pp-rule-line) solid var(--pp-line);
  border-radius: var(--pp-radius-sm);
  font-family: var(--pp-font-mono);
  font-size: 0.72rem;
  letter-spacing: var(--w-track-label);
  color: var(--pp-muted);
}
.seed-tag:hover {
  border-color: var(--pp-edge);
  color: var(--pp-ink);
}
.seed-tag:active {
  transform: var(--w-press);
}
