/* Crono — race bib-number generator page. Loads after theme.css (this page does
   not load site.css), so it carries its own base + the print sheet. Token-driven. */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font-ui); background: var(--bg); color: var(--text); line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(closest-side at 12% 0%, rgba(var(--accent-4-rgb), .12), transparent 70%),
    radial-gradient(closest-side at 92% 100%, rgba(var(--accent-2-rgb), .08), transparent 70%);
  background-attachment: fixed; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

/* Bib theme presets — single source for the swatches, the preview and the print sheet. */
:root { --bib-orange: #ea580c; --bib-lime: #4d7c0f; --bib-blue: #1d4ed8; --bib-mono: #111111; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px 48px; }

/* Header */
.bibs-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px 0; }
.brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 700; font-size: 1.4rem;
  letter-spacing: -.4px; font-family: var(--font-display); color: var(--text); }
.brand .logo { width: 34px; height: 34px; color: var(--primary); }

.btn { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; border: 1px solid var(--border);
  background: transparent; color: var(--text); border-radius: 999px; padding: var(--btn-pad);
  font-size: .95rem; font-weight: 600;
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition); }
.btn:hover { border-color: var(--accent-4); color: var(--accent-4); }
.btn .icon { width: 1.1em; height: 1.1em; }
.btn.primary { background: var(--accent-4); border-color: var(--accent-4); color: var(--on-accent); font-weight: 700; }
.btn.primary:hover { filter: brightness(1.06); transform: translateY(-1px); color: var(--on-accent); }
.btn.primary:disabled { opacity: .5; cursor: not-allowed; filter: none; transform: none; }

/* Intro */
.bibs-intro { text-align: center; max-width: 660px; margin: 8px auto 28px; }
.eyebrow { display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .8px;
  text-transform: uppercase; color: var(--accent-4); margin-bottom: 10px; }
.bibs-intro h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.9rem, 4vw, 2.6rem);
  margin: 0 0 12px; letter-spacing: -.6px; line-height: 1.1; }
.bibs-intro p { margin: 0; color: var(--muted); }

/* Layout: form + live preview */
.bib-layout { display: grid; grid-template-columns: 1.1fr .9fr; gap: 28px; align-items: start;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.bib-form { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.bib-row { display: flex; gap: 14px; }
.bf { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0;
  font-size: .8rem; font-weight: 600; color: var(--muted); }
.bf.grow { flex: 2; }
.bf input { font: inherit; width: 100%; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--border); border-radius: var(--radius-input); padding: 10px 11px; font-weight: 400; }
.bf input::placeholder { color: var(--muted); opacity: .6; }
.bf input:focus { outline: 2px solid var(--accent-4); outline-offset: 2px; border-color: var(--accent-4); }
.bf-note { font-size: .75rem; font-weight: 400; color: var(--muted); }

/* Colour: presets + custom picker */
.bib-color-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.bib-swatches { display: flex; gap: 8px; }
.bib-sw { width: 32px; height: 32px; padding: 0; border-radius: 999px; border: 2px solid var(--border); cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition); }
.bib-sw:hover { transform: translateY(-1px); }
.bib-sw.sw-orange { background: var(--bib-orange); }
.bib-sw.sw-lime { background: var(--bib-lime); }
.bib-sw.sw-blue { background: var(--bib-blue); }
.bib-sw.sw-mono { background: var(--bib-mono); border-color: var(--muted); }
.bib-sw.is-on { border-color: var(--text); box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent-4); }
.bib-sw:focus-visible { outline: 2px solid var(--accent-4); outline-offset: 2px; }
.bib-color-pick { display: inline-flex; align-items: center; gap: 8px; font-size: .8rem; font-weight: 600; color: var(--muted); }
.bib-color-pick input[type="color"] { width: 42px; height: 32px; padding: 2px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-input); background: var(--panel-2); }

/* Logo */
.bib-logo-clear { align-self: flex-start; border: 1px solid var(--border); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 7px 14px; cursor: pointer; font-size: .82rem; }
.bib-logo-clear:hover { color: var(--danger); border-color: var(--danger); }

.bib-count { margin: 2px 0 0; font-size: .9rem; color: var(--muted); }
.bib-count.err { color: var(--danger); }
.bib-actions { display: flex; }
.bib-actions .btn.primary { width: 100%; justify-content: center; }

/* Preview column */
.bib-preview-col { position: sticky; top: 20px; }
.bib-preview-label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.bib-preview { --bibc: var(--bib-orange); --bibtext: #fff; width: 100%; aspect-ratio: 186 / 128;
  background: #fff; color: #111; border: 3px solid var(--bibc); border-radius: 12px; overflow: hidden;
  display: flex; flex-direction: column; box-shadow: var(--shadow-soft); }
.bib-preview .bib-head { display: flex; align-items: center; gap: 12px; padding: 9px 14px;
  background: var(--bibc); color: var(--bibtext); }
.bib-preview .bib-head[hidden] { display: none; }
.bib-preview .bib-logo { height: 34px; width: auto; max-width: 96px; object-fit: contain; background: #fff; padding: 2px; border-radius: 4px; }
.bib-preview .bib-ev { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.bib-preview .bib-name { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bib-preview .bib-race { font-family: var(--font-display); font-size: .92rem; opacity: .95; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bib-preview .bib-date { font-size: .78rem; opacity: .9; }
.bib-preview .bib-name[hidden], .bib-preview .bib-race[hidden], .bib-preview .bib-date[hidden] { display: none; }
.bib-preview .bib-no { flex: 1; display: flex; align-items: center; justify-content: center; font-family: var(--font-display);
  font-weight: 700; color: var(--bibc); font-size: clamp(3rem, 12vw, 6rem); line-height: 1; letter-spacing: -1px; }
.bib-hint { color: var(--muted); font-size: .82rem; margin: 10px 0 0; }

/* Footer */
.bibs-footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 28px 0 0; }
.bibs-footer a { color: var(--muted); text-decoration: underline; }
.bibs-footer a:hover { color: var(--accent-4); }

@media (max-width: 760px) {
  .bib-layout { grid-template-columns: 1fr; gap: 22px; padding: 18px; }
  .bib-preview-col { position: static; }
}
@media (max-width: 480px) {
  .bib-row { flex-direction: column; }
}

/* Service-worker "new version" toast (shared component; token-styled, like the app's). */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 1300;
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; max-width: 92vw; }
.toast-update { pointer-events: auto; display: flex; align-items: center; gap: 12px;
  background: var(--panel); color: var(--text); border: 1px solid var(--border); border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm); padding: 10px 16px; font-size: .92rem; box-shadow: var(--shadow-pop); }
.toast-reload { border: 1px solid var(--primary); background: var(--primary); color: var(--on-accent);
  padding: 5px 12px; border-radius: 999px; font-size: .85rem; font-weight: 700; cursor: pointer; }
.toast-dismiss { border: none; background: transparent; color: var(--muted); font-size: 1.2rem; line-height: 1;
  padding: 2px 4px; border-radius: 999px; cursor: pointer; }
.toast-dismiss:hover { color: var(--text); }

/* ===== Printable bib sheet (built into #printArea, printed via window.print) ===== */
#printArea { display: none; }
@media print {
  @page { size: A4 portrait; margin: 12mm; }
  body { background: #fff !important; background-image: none !important; }
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; }
  #printArea .bib-card { box-sizing: border-box; height: 128mm; margin: 0 0 8mm; display: flex; flex-direction: column;
    overflow: hidden; color: #111; border: 1.4mm solid var(--bibc); border-radius: 5mm; page-break-inside: avoid;
    -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #printArea .bib-card:nth-child(2n) { page-break-after: always; margin-bottom: 0; }
  #printArea .bib-card:last-child { page-break-after: auto; }
  #printArea .bib-head { display: flex; align-items: center; gap: 6mm; padding: 6mm 8mm;
    background: var(--bibc); color: var(--bibtext);
    -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #printArea .bib-logo { height: 16mm; width: auto; max-width: 42mm; object-fit: contain; background: #fff; padding: 1mm; border-radius: 2mm; }
  #printArea .bib-ev { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
  #printArea .bib-name { font-family: var(--font-display); font-weight: 700; font-size: 17pt; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #printArea .bib-race { font-family: var(--font-display); font-size: 12pt; opacity: .95; }
  #printArea .bib-date { font-size: 11pt; opacity: .92; }
  #printArea .bib-no { flex: 1; display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700; color: var(--bibc); font-size: 120pt; line-height: 1; letter-spacing: -2pt; }
}
