/* Bingo generator: the maker hero (form + live card), the printable pages and print.
   One .sheet = one printed page. Sizes inside a sheet are container units, so the
   same markup is a scaled preview on screen and true size on paper. */

/* ---- the maker: heading and form on the left, the live card pinned on the right */
.maker {
  display: grid; gap: 22px 48px; align-items: start; padding-top: 8px;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  grid-template-areas: "head preview" "form preview";
}
.maker-head { grid-area: head; }
.maker-head .lead { margin-bottom: 0; }
.maker-preview { grid-area: preview; position: sticky; top: 16px; padding: 26px 8px 8px; }
.maker-form { grid-area: form; }
@media (max-width: 880px) {
  .maker { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "preview" "form"; }
  .maker-preview { position: static; padding: 18px 6% 6px; }
}

/* The live card looks like a printout taped to the wall. */
.pinned {
  position: relative; background: #fff; padding: 7% 7% 4%; transform: rotate(-1.8deg);
  box-shadow: 0 1px 0 rgba(0,0,0,.08), 6px 10px 0 rgba(27,27,31,.14), 0 18px 30px rgba(27,27,31,.12);
  max-width: 480px; margin: 0 auto;
}
.pinned::before {
  content: ""; position: absolute; top: -16px; left: 50%; width: 120px; height: 32px; transform: translateX(-50%) rotate(3deg);
  background: rgba(255, 210, 63, .78); border-left: 2px dashed rgba(27,27,31,.18); border-right: 2px dashed rgba(27,27,31,.18);
}
.pinned .card { width: 100%; }
.pinned[data-kind="90"] { padding: 6% 5% 3%; }
.preview-wait { font: 600 20px/1.3 var(--display); text-align: center; padding: 30% 0; margin: 0; color: var(--ink-soft); }

/* ---- the form --------------------------------------------------------------- */
.bingo-form {
  background: var(--white); border: var(--line); border-radius: var(--wobble); box-shadow: var(--pop);
  padding: 22px; display: grid; gap: 16px;
}
.bingo-form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; align-items: end; }
.bingo-form .code-row { grid-template-columns: minmax(0, 220px) auto; justify-content: start; }
.field { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 6px; }
.field legend, .field > label { font: 600 18px/1.2 var(--display); padding: 0; margin-bottom: 2px; }
.bingo-form input:not([type=radio]):not([type=checkbox]), .bingo-form select, .bingo-form textarea {
  width: 100%; min-height: 50px; padding: 10px 12px; font: 18px/1.3 var(--body); color: var(--ink);
  background: var(--paper); border: var(--line); border-radius: 12px;
}
.bingo-form textarea { resize: vertical; min-height: 150px; }
.bingo-form #bg-code { text-transform: uppercase; letter-spacing: .14em; font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; }
.seg { display: flex; flex-wrap: wrap; gap: 10px; }
.seg label {
  display: inline-flex; align-items: center; gap: 8px; min-height: 50px; padding: 0 14px;
  border: var(--line); border-radius: 14px 10px 14px 10px; cursor: pointer; font: 600 17px/1 var(--display); background: var(--white);
}
.seg label:has(input:checked) { background: var(--sun); box-shadow: 3px 3px 0 var(--ink); }
.seg label:has(input:focus-visible) { outline: 3px dashed var(--ink); outline-offset: 3px; }
.seg small { font: 700 13px/1 var(--body); padding: 3px 6px; border-radius: 6px; background: var(--ink); color: var(--paper); }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 48px; font: 600 17px/1.2 var(--display); cursor: pointer; }
.seg input, .check input { width: 22px; height: 22px; accent-color: var(--ink); margin: 0; }
.checks { align-content: end; }
.hint { color: var(--ink-soft); font-size: 16px; margin: 0; }
.error { margin: 0; padding: 12px 14px; border-radius: 12px; border: var(--line); background: var(--peach); font-weight: 700; }
.actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }

#bingo:not([data-kind=words]) .words-only { display: none; }
#bingo[data-kind="90"] .free-only { display: none; }

/* ---- the printable pages ------------------------------------------------------ */
.print-area { margin-top: 48px; }
.pages-title { margin: 0 0 6px; }
.sheets { display: grid; justify-items: center; gap: 28px; margin-top: 20px; }
.sheet {
  container-type: size; width: 100%; max-width: 620px; aspect-ratio: var(--sheet-ratio, 190 / 277);
  background: #fff; color: #161616; box-shadow: 0 1px 0 rgba(0,0,0,.08), 5px 8px 0 rgba(27,27,31,.12);
  display: grid; gap: 2cqh; padding: 0; overflow: hidden;
}
.per-1 { grid-template-rows: 1fr; }
.per-2 { grid-template-rows: repeat(2, 1fr); }
.per-3 { grid-template-rows: repeat(3, 1fr); }
.per-4 { grid-template: repeat(2, 1fr) / repeat(2, 1fr); }
.per-6 { grid-template-rows: repeat(6, 1fr); gap: 1cqh; }
.slot { container-type: size; display: grid; place-items: center; min-height: 0; min-width: 0; }

/* ---- one card ------------------------------------------------------------------- */
.card { container-type: inline-size; font-family: var(--display); color: #161616; }
.card.card-5 { width: min(96cqw, 74cqh); }
.card.card-90 { width: min(100cqw, 230cqh); }
.pinned .card.card-5, .pinned .card.card-90 { width: 100%; }
.card-title { text-align: center; font-weight: 700; font-size: 7.5cqw; line-height: 1.1; margin-bottom: 2cqw; overflow-wrap: anywhere; }
.card-90 .card-title { font-size: 3.4cqw; margin-bottom: .8cqw; text-align: left; }
.card .card-grid {
  display: grid; grid-template-columns: repeat(5, 1fr);
  border-top: .5cqw solid #161616; border-left: .5cqw solid #161616;
}
.card-90 .card-grid { grid-template-columns: repeat(9, 1fr); border-width: .4cqw; }
.cell {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-right: .5cqw solid #161616; border-bottom: .5cqw solid #161616;
  text-align: center; line-height: 1.08; padding: .6cqw; min-width: 0; overflow: hidden;
}
.card-90 .cell { border-width: .4cqw; padding: .2cqw; }
.cell.head { aspect-ratio: auto; padding: 1.4cqw 0; font-weight: 700; font-size: 9cqw; color: #fff; background: #B8321E; }
.cell.num { font-weight: 600; font-size: 9cqw; font-variant-numeric: tabular-nums; }
.card-90 .cell.num { font-size: 4.6cqw; }
.cell.blank { background: transparent; }
.cell.word { font-family: var(--body); font-weight: 700; font-size: 4.4cqw; overflow-wrap: normal; word-break: normal; }
.cell.free { color: #B8321E; font-weight: 700; font-size: 3.4cqw; }
.cell.free .star { font-size: 8cqw; line-height: 1; }
.card-foot { font-family: var(--body); font-size: 2.3cqw; color: #555; text-align: right; margin-top: 1cqw; letter-spacing: .02em; }
.card-90 .card-foot { font-size: 1.5cqw; margin-top: .4cqw; }

/* ---- caller sheet ----------------------------------------------------------------- */
.sheet.caller { display: block; padding: 4cqw; }
.caller-title { font: 700 4.6cqw/1.1 var(--display); margin: 0 0 1cqw; color: #161616; }
.caller-note { font: 2.4cqw/1.3 var(--body); color: #444; margin: 0 0 2.5cqw; }
.caller-groups { display: grid; gap: 1.6cqw; font-family: var(--body); }
.caller-75 { grid-template-columns: repeat(5, 1fr); }
.caller-90 { grid-template-columns: repeat(9, 1fr); gap: 1cqw; }
.caller-group { display: grid; gap: .8cqw; align-content: start; }
.caller-label { font-weight: 700; font-size: 3.2cqw; text-align: center; color: #B8321E; font-family: var(--display); }
.caller-item { border: .25cqw solid #161616; border-radius: .8cqw; text-align: center; font-weight: 700; font-size: 2.8cqw; padding: .5cqw 0; font-variant-numeric: tabular-nums; }
.caller-90 .caller-item { font-size: 2.4cqw; }
.caller-words .caller-group { display: block; columns: 3; column-gap: 3cqw; }
.caller-words .caller-item { text-align: left; border: 0; font-size: 2.4cqw; padding: .4cqw 0; break-inside: avoid; }
.caller-words .caller-item::before {
  content: ""; display: inline-block; width: 2cqw; height: 2cqw; border: .25cqw solid #161616;
  border-radius: .4cqw; margin-right: 1.2cqw; vertical-align: -0.3cqw;
}

/* ---- print: only the pages, plain black on white ---------------------------------- */
@media print {
  body:has(#bingo-sheets) main > :not(.print-area), .print-area > :not(#bingo-sheets) { display: none !important; }
  .print-area { margin: 0; padding: 0; max-width: none; }
  .sheets { display: block; margin: 0; }
  .sheet {
    width: var(--sheet-w); height: var(--sheet-h); max-width: none; aspect-ratio: auto;
    box-shadow: none; break-after: page; page-break-after: always;
  }
  .sheet:last-child { break-after: auto; page-break-after: auto; }
  .card, .card-title, .cell, .caller-title, .caller-note, .card-foot { color: #000; }
  .cell.head { background: none; color: #000; border-bottom-width: 1cqw; }
  .cell.free, .caller-label { color: #000; }
}
