/* FoxP1 5K & Fun Run race timer - Bib Sheet style.
   Light only on purpose: black on near-white holds up in direct sun at the finish line. */
:root {
  --paper: #F4F5F3;       /* Tyvek */
  --card: #FFFFFF;
  --ink: #121416;         /* bib ink */
  --ink-2: #4B5359;
  --ink-3: #5F676C;
  --pin: #8E969B;         /* safety pin */
  --line: #D5DAD7;
  --line-2: #B9BFBB;
  --muted-bg: #EEF0EE;
  --fox: #E3540B;         /* fox orange: bands, accents */
  --fox-deep: #C4490A;    /* filled buttons with white text */
  --fox-soft: #FBE3D5;
  --ember: #FF9A62;       /* times on ink */
  --ok: #1E6B3A;
  --err: #B3261E;
  --err-soft: #FBE4E2;
  --rule: #E1E4E1;         /* hairlines between rows */
  --faint: #A3AAAE;        /* placeholders, disabled digits */
  --on-ink: #A9B1B6;       /* quiet text on ink */
  --ink-raised: #2E3439;   /* bands on dark tiles */
  --fox-text: #7A2C05;     /* text on fox-soft */
  --focus-ring: 0 0 0 3px rgba(227, 84, 11, 0.35);

  --f-ui: "Open Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-num: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --f-time: "Azeret Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --appbar-h: 56px;
  --tabbar-h: 62px;
  --gutter: max(16px, env(safe-area-inset-left));
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.5 var(--f-ui);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
code { font: 500 0.9em var(--f-time); background: var(--muted-bg); padding: 1px 5px; border-radius: 4px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--fox); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.bi { width: 1em; height: 1em; fill: currentColor; flex: none; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 50; background: var(--card); padding: 8px 12px; border-radius: 6px; }
.skip:focus { top: 8px; }

/* ---------- app bar + navigation ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px 24px;
  height: var(--appbar-h); padding-inline: var(--gutter);
  background: var(--ink); color: #fff;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand img { width: 34px; height: 34px; flex: none; }
.brand span {
  font: 800 19px/1 var(--f-num); letter-spacing: 0.08em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand b { color: #FF7A33; font-weight: 800; }
@media (max-width: 479px) { body:not(.page-race) .brand span { display: none; } }  /* room for the clock chip */
.topnav { display: none; gap: 4px; }
.topnav a, .tabbar a {
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none;
  font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.topnav a { position: relative; padding: 8px 11px; color: var(--on-ink); border-radius: 6px; }
.topnav a:hover { color: #fff; }
.topnav a[aria-current="page"] { color: #fff; box-shadow: inset 0 -3px 0 var(--fox); border-radius: 0; }
.appbar-end { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.appbar-end form { margin: 0; }
.signout {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 8px;
  border: 0; background: transparent; color: var(--on-ink); font-size: 13px; font-weight: 600; cursor: pointer;
}
.signout:hover { color: #fff; }
.signout .bi { width: 18px; height: 18px; }
.signout span { display: none; }
.whoami { display: inline-flex; align-items: center; gap: 6px; min-width: 0; color: var(--on-ink); font-size: 13px; font-weight: 600; }
.whoami .bi { width: 18px; height: 18px; }
.whoami span { display: none; max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-badge {
  position: absolute; top: -1px; right: -7px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--fox); color: #fff;
  font: 700 11px/18px var(--f-ui); font-style: normal; letter-spacing: 0; text-align: center;
}
.net-off { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 4px; background: var(--err); font-size: 12px; font-weight: 700; }
.net-off span { display: none; }
.clock-chip { display: inline-flex; align-items: baseline; gap: 8px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--on-ink); }
.clock-chip .t { font: 600 15px/1 var(--f-time); letter-spacing: -0.03em; color: var(--ember); font-variant-numeric: tabular-nums; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--paper); border-top: 2px solid var(--ink);
}
.tabbar a { position: relative; flex-direction: column; justify-content: center; gap: 3px; font-size: 10.5px; letter-spacing: 0.04em; color: var(--ink-3); }
.tabbar .nav-badge { top: 5px; right: calc(50% - 26px); }
.tabbar a .bi { width: 22px; height: 22px; }
.tabbar a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 3px 0 var(--fox); }
.tabbar a:active { background: var(--muted-bg); }

.main {
  width: 100%; max-width: 1200px; margin-inline: auto;
  padding: 16px var(--gutter) calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
}

@media (min-width: 560px) {
  .signout span, .net-off span, .whoami span { display: inline; }
}
@media (min-width: 900px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  .main { padding-block: 24px 48px; }
}
@media (min-width: 900px) and (max-width: 1279px) {
  .brand span, .signout span { display: none; }  /* room for five tabs */
}
@media (min-width: 900px) and (max-width: 1059px) {
  .whoami span, .topnav a .bi { display: none; }
}

/* ---------- buttons, fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 16px;
  border: 1.5px solid var(--ink); border-radius: 8px;
  background: var(--card); color: var(--ink);
  font-size: 15px; font-weight: 700; line-height: 1.1; text-decoration: none; text-align: center;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
}
.btn .bi { width: 15px; height: 15px; }
.btn:active { background: var(--ink); color: #fff; }
.btn-primary { background: var(--fox-deep); border-color: var(--fox-deep); color: #fff; }
.btn-primary:active { background: var(--ink); border-color: var(--ink); }
.btn-danger { background: var(--card); border-color: var(--err); color: var(--err); }
.btn-danger:active { background: var(--err); border-color: var(--err); color: #fff; }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: 13px; }
.btn-sm .bi { width: 13px; height: 13px; }
.btn-block { width: 100%; }
/* ---------- drop-down menu ---------- */
.menu { position: relative; display: inline-flex; }
.menu > .btn { width: 100%; }
.menu-chev { display: inline-flex; margin-left: -2px; transition: transform 0.15s; }
[aria-expanded="true"] > .menu-chev { transform: rotate(180deg); }
.menu-list {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30;
  display: grid; gap: 2px; min-width: 230px; padding: 6px;
  background: var(--card); border: 1.5px solid var(--ink); border-radius: 8px;
  box-shadow: 0 10px 28px rgba(18, 20, 22, 0.18);
}
.menu.up .menu-list { top: auto; bottom: calc(100% + 6px); }
.menu.flip .menu-list { right: auto; left: 0; }
.menu-list a {
  display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 8px 10px;
  border-radius: 6px; color: var(--ink); text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.menu-list a:hover, .menu-list a:focus-visible { background: var(--muted-bg); outline: none; }
.menu-list a:active { background: var(--fox-soft); }
.menu-list .bi { flex: none; width: 24px; height: 24px; color: var(--fox-deep); }
.menu-list span { display: grid; gap: 1px; }
.menu-list b { font-size: 14px; }
.menu-list small { font-size: 12px; color: var(--ink-3); white-space: nowrap; }

.btn:disabled { background: var(--muted-bg); border-color: var(--line); color: #8A9297; cursor: not-allowed; }
.btn.busy { cursor: progress; opacity: 0.75; }

.field { display: grid; gap: 5px; font-size: 13px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; min-width: 0; height: 46px; padding: 0 12px;
  border: 1.5px solid var(--line-2); border-radius: 8px; background: var(--card); color: var(--ink);
  font-size: 16px; font-weight: 500;
}
.field textarea { height: auto; min-height: 64px; padding: 10px 12px; resize: vertical; line-height: 1.4; }
.field select { padding-right: 8px; }
.field input:focus, .field select:focus, .field textarea:focus, .find:focus-within { outline: none; border-color: var(--ink); box-shadow: var(--focus-ring); }
.field input:disabled, .field select:disabled, .field textarea:disabled { background: var(--muted-bg); color: var(--pin); }
.pw { position: relative; display: block; }
.pw input { padding-right: 48px; }
.pw-toggle {
  position: absolute; right: 2px; top: 2px; bottom: 2px; width: 44px;
  display: grid; place-items: center; border: 0; background: transparent; color: var(--ink-3); cursor: pointer;
}
.pw-toggle .bi { width: 18px; height: 18px; }
.hint { font-size: 13px; color: var(--ink-3); }
.msg { display: flex; align-items: center; gap: 8px; min-height: 1.4em; font-size: 14px; font-weight: 600; }
.msg.err { color: var(--err); }
.msg.ok { color: var(--ok); }
.empty { padding: 18px; text-align: center; color: var(--ink-3); }
.role-note {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 8px;
  background: var(--muted-bg); color: var(--ink-2); font-size: 13.5px;
}
.role-note .bi { width: 14px; height: 14px; color: var(--ink-3); }
.role-note b { color: var(--ink); }
.empty b { color: var(--ink); }

.find {
  display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 4px 0 12px;
  border: 1.5px solid var(--line-2); border-radius: 8px; background: var(--card); color: var(--ink-3);
}
.find > .bi { width: 16px; height: 16px; }
.find input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; color: var(--ink); font-size: 16px; outline: none; }
.find input::-webkit-search-cancel-button { display: none; }
.find-clear { display: grid; place-items: center; width: 40px; height: 40px; border: 0; background: transparent; color: var(--ink-3); cursor: pointer; }

/* ---------- cards cut like a bib: pin holes + header band ---------- */
.card-bib {
  --pin-inset: 6px; --pin-size: 6px;
  position: relative; background: var(--card); border: 1.5px solid var(--ink); border-radius: 8px;
}
.card-bib::before, .card-bib::after, .bib::before, .bib::after {
  content: ""; position: absolute; top: var(--pin-inset); z-index: 1;
  width: var(--pin-size); height: var(--pin-size); border-radius: 50%;
  background: var(--paper); box-shadow: 0 0 0 1px var(--pin);
}
.card-bib::before, .bib::before { left: var(--pin-inset); }
.card-bib::after, .bib::after { right: var(--pin-inset); }
.card-bib > .band {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 11px 20px 10px; border-radius: 6px 6px 0 0;
  background: var(--fox); color: #fff;
}
.card-bib > .band.ink { background: var(--ink); }
.card-bib > .band h1, .card-bib > .band h2 {
  display: flex; align-items: center; gap: 10px;
  font: 800 18px/1 var(--f-num); letter-spacing: 0.1em; text-transform: uppercase;
}
.card-bib > .band h1 .bi { width: 16px; height: 16px; }
.card-bib > .band small { font-size: 12.5px; font-weight: 600; opacity: 0.92; white-space: nowrap; }

/* ---------- the bib tile ---------- */
.bib {
  --pin-inset: 4px; --pin-size: 5px;
  position: relative; display: grid; align-content: start; padding: 0 0 9px; text-align: center;
  background: var(--card); color: var(--ink); border: 1.5px solid var(--ink); border-radius: 6px;
  font: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.bib .band {
  display: block; padding: 5px 12px 4px; border-radius: 4px 4px 0 0;
  background: var(--fox); color: #fff;
  font: 800 10px/1 var(--f-num); letter-spacing: 0.12em; text-transform: uppercase; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.bib .no { display: block; margin-top: 5px; font: 900 38px/1 var(--f-num); }
.bib .nm { display: block; padding: 2px 6px 0; font-size: 11.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bib .tm { display: block; min-height: 1em; margin-top: 4px; font: 500 11px/1 var(--f-time); letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.bib:active { transform: scale(0.96); }
.bib.done { background: var(--ink); color: #fff; }
.bib.done .band { background: var(--ink-raised); color: var(--ember); }
.bib.done .nm { color: var(--on-ink); }
.bib.done .tm { color: var(--ember); }
.bib.pending { background: var(--ink); color: #fff; border-style: dashed; }
.bib.pending .band { background: var(--ink-raised); color: #fff; }
.bib.pending .nm { color: var(--on-ink); }
.bib.pending .tm { color: #fff; }
.bib.hit { animation: stamp 0.35s ease-out; }
.bib.preview { cursor: default; pointer-events: none; }
.bib .ph { color: var(--faint); }

/* ---------- confirmation sheet ---------- */
dialog.sheet {
  width: 100%; max-width: 520px; max-height: 92dvh; margin: auto auto 0; padding: 0;
  border: 0; border-top: 2px solid var(--ink); border-radius: 22px 22px 0 0;
  background: var(--paper); color: var(--ink); overflow: auto;
}
dialog.sheet[open] { animation: rise 0.2s ease-out; }
dialog.sheet::backdrop { background: rgba(18, 20, 22, 0.5); }
@media (min-width: 700px) {
  dialog.sheet { margin: auto; border: 2px solid var(--ink); border-radius: 16px; }
}
.sheet-body { display: grid; gap: 12px; padding: 10px 18px calc(22px + env(safe-area-inset-bottom)); }
.sheet .grab { justify-self: center; width: 40px; height: 4px; border-radius: 2px; background: var(--line-2); }
.sheet h2 { font: 900 28px/1 var(--f-num); letter-spacing: 0.02em; text-transform: uppercase; }
.sheet p { font-size: 14.5px; color: var(--ink-2); }
.sheet p b { color: var(--ink); font-family: var(--f-time); font-weight: 600; }
.sheet p .warn-text { display: block; margin-top: 8px; color: var(--err); font-weight: 700; }
.sheet fieldset { display: grid; gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; }
.opt {
  display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; padding: 12px;
  border: 1.5px solid var(--line-2); border-radius: 12px; background: var(--card); cursor: pointer;
}
.opt:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.opt input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--fox-deep); }
.opt b { display: block; font-size: 15px; line-height: 1.3; }
.opt small { display: block; margin-top: 2px; font-size: 13px; line-height: 1.4; color: var(--ink-3); }
.sheet-field small { font-size: 12.5px; font-weight: 500; color: var(--ink-3); }
.sheet-acts { display: grid; grid-template-columns: 1fr 1.3fr; gap: 8px; margin-top: 4px; }
.sheet-acts .btn { min-height: 54px; }
[data-s-yes] { position: relative; overflow: hidden; }
[data-s-yes].danger { background: var(--ink); border-color: var(--ink); }
[data-s-yes] .fill { position: absolute; inset: 0; background: var(--fox); transform: scaleX(0); transform-origin: left center; }
[data-s-yes].holding .fill { transform: scaleX(1); transition: transform 1.5s linear; }
[data-s-yes] .lbl { position: relative; }
[data-s-yes].hold { touch-action: none; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px); z-index: 60;
  transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px);
  padding: 12px 16px; border-radius: 10px; background: var(--ink); color: #fff;
  font-size: 14px; font-weight: 600; box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.2s ease-out;
}
.toast.err { background: var(--err); }
@media (min-width: 900px) { .toast { bottom: 24px; } }

@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@keyframes toast-in { from { transform: translate(-50%, 24px); opacity: 0; } }
@keyframes stamp { from { transform: scale(1.1); filter: brightness(1.5); } }
@keyframes pulse { 50% { opacity: 0.25; } }

/* ---------- page transitions: the bars stay put, the screen swaps with a quick fade ---------- */
@view-transition { navigation: auto; }
.appbar { view-transition-name: appbar; }
.tabbar { view-transition-name: tabbar; }
.main { view-transition-name: main; }
::view-transition-group(appbar), ::view-transition-group(tabbar) { animation-duration: 160ms; }
::view-transition-group(main) { animation-duration: 180ms; }
::view-transition-old(main) { animation: 90ms ease-in both vt-out; }
::view-transition-new(main) { animation: 180ms cubic-bezier(0.2, 0.7, 0.3, 1) both vt-in; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
