/* Kit pieces for the page builders: sheet, info popover, stat bars, progress bar and ring, chips, pager,
   data list, virtual list, unknown / not-recorded states, unit bust, live sprite. Loaded by the shell at boot. */

/* ---------------------------------------------------------------- sheet (bottom sheet on phones, centred on wide) */
.bfc-dialog__top { display: flex; align-items: flex-start; gap: 8px; }
.bfc-dialog__top .bfc-dialog__head { flex: 1; }
.bfc-dialog--sheet { max-width: 520px; text-align: left; }
.bfc-dialog--sheet .bfc-dialog__body { margin-bottom: 8px; }
.bfc-x {
  flex: none; width: var(--bfc-tap); height: var(--bfc-tap); margin: -6px -8px 0 0; border: 0; border-radius: 50%; cursor: pointer;
  background: url(../assets/ui/back.png) center / 30px auto no-repeat;
}
.bfc-x:hover { filter: brightness(1.2); }
@media (max-width: 599px) {
  .bfc-dialog-wrap--sheet { place-items: end stretch; padding: 0; }
  .bfc-dialog--sheet { max-width: none; max-height: 88dvh; border-bottom-width: 0; border-radius: 0; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  @media (prefers-reduced-motion: no-preference) { .bfc-dialog--sheet { animation: bfc-sheet-up .28s var(--bfc-ease-out); } }
}
@keyframes bfc-sheet-up { from { transform: translateY(40%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------------------------------------------------------- info popover */
.bfc-info {
  display: inline-grid; place-items: center; width: var(--bfc-tap); height: var(--bfc-tap); margin: -10px -8px; padding: 0;
  border: 0; background: none; cursor: pointer; vertical-align: middle;
}
.bfc-info > i {
  display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  font: 800 13px/1 Georgia, serif; font-style: italic; color: var(--bfc-ink-dark);
  background: radial-gradient(circle at 35% 30%, #fff6cf, var(--bfc-gold-2) 60%, var(--bfc-gold-3)); box-shadow: 0 0 0 1.5px #000;
}
.bfc-info[aria-expanded="true"] > i { box-shadow: 0 0 0 1.5px #000, 0 0 8px #ffe066; }
.bfc-role-btn { display: inline-flex; min-height: var(--bfc-tap); align-items: center; padding: 0; border: 0; background: none; cursor: pointer; }
.bfc-role-btn[aria-expanded="true"] .bfc-role { filter: brightness(1.25); }
.bfc-pop {
  position: fixed; z-index: var(--bfc-z-toast); padding: 10px 14px; text-align: left;
  border-style: solid; border-color: transparent; border-width: 10px;
  border-image: url(../assets/ui/frame-navi.png) 16 fill / 10px stretch;
  background: #05070d padding-box;          /* the navi frame's centre is see-through: never show the button under it */
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .6));
}
.bfc-pop__title { margin-bottom: 4px; font: 800 var(--bfc-fs-m)/1.25 var(--bfc-font-game); color: var(--bfc-ink-gold); text-shadow: var(--bfc-outline-thin); }
.bfc-pop__text, .bfc-pop__why { font-size: var(--bfc-fs-s); line-height: 1.4; color: var(--bfc-ink-soft); }
.bfc-pop__why { margin-top: 6px; color: var(--bfc-ink-dim); }

/* ---------------------------------------------------------------- unknown / not recorded */
.bfc-unknown { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: var(--bfc-fs-xs); font-weight: 700; color: var(--bfc-ink-dim); background: rgba(5, 10, 24, .7); box-shadow: inset 0 0 0 1px rgba(169, 184, 220, .3); }
.bfc-notrec { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--bfc-radius); background: rgba(5, 10, 24, .72); box-shadow: inset 0 0 0 1px rgba(214, 164, 62, .3); }
.bfc-notrec__mark { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; font: 800 17px/1 var(--bfc-font-game); color: var(--bfc-ink-dark); background: radial-gradient(circle at 35% 30%, #e7ecff, #8ea0cc 60%, #3c4870); box-shadow: 0 0 0 2px #000; }
.bfc-notrec__title { font: 800 var(--bfc-fs-m)/1.3 var(--bfc-font-game); color: #fff; text-shadow: var(--bfc-outline-thin); }
.bfc-notrec__why { margin-top: 2px; font-size: var(--bfc-fs-s); color: var(--bfc-ink-dim); }

/* ---------------------------------------------------------------- stat bar */
.bfc-stat { display: grid; grid-template-columns: minmax(64px, 30%) minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 26px; }
.bfc-stat__label { font: 800 var(--bfc-fs-s)/1.2 var(--bfc-font-game); color: var(--bfc-ink-gold); text-shadow: var(--bfc-outline-thin); }
.bfc-stat__bar { position: relative; height: 12px; border-radius: 6px; overflow: hidden; background: #0a0f1a; box-shadow: inset 0 1px 2px #000, 0 0 0 1px rgba(214, 164, 62, .35); }
.bfc-stat__bar > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: linear-gradient(#fff3c4, var(--bfc-gold-2) 45%, var(--bfc-gold-3)); }
.bfc-stat--hp .bfc-stat__bar > i { background: linear-gradient(var(--bfc-hp-b), var(--bfc-hp-a) 45%, #0b6fa0); }
.bfc-stat--atk .bfc-stat__bar > i, .bfc-stat--bad .bfc-stat__bar > i { background: linear-gradient(#ffd0c4, #e0503a 45%, #7a1a0c); }
.bfc-stat--def .bfc-stat__bar > i, .bfc-stat--blue .bfc-stat__bar > i { background: linear-gradient(#d6e6ff, #4f86e8 45%, #1d3a86); }
.bfc-stat--rec .bfc-stat__bar > i, .bfc-stat--good .bfc-stat__bar > i { background: linear-gradient(var(--bfc-nrg-b), #48d02a 45%, #1b6a07); }
.bfc-stat__val { min-width: 3ch; font: 800 var(--bfc-fs-s)/1 var(--bfc-font-game); color: #fff; text-align: right; text-shadow: var(--bfc-outline-thin); font-variant-numeric: tabular-nums; }
.bfc-stat.is-unknown .bfc-stat__val { font-family: var(--bfc-font); font-weight: 700; color: var(--bfc-ink-dim); }

/* ---------------------------------------------------------------- progress bar */
.bfc-prog__head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; font: 800 var(--bfc-fs-s)/1.2 var(--bfc-font-game); color: #fff; text-shadow: var(--bfc-outline-thin); }
.bfc-prog__val { color: var(--bfc-ink-gold); font-variant-numeric: tabular-nums; }
.bfc-prog__bar { position: relative; height: 8px; border-radius: 4px; overflow: hidden; background: #0a0f1a; box-shadow: inset 0 1px 2px #000, 0 0 0 1px rgba(214, 164, 62, .35); }
.bfc-prog__bar > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: linear-gradient(#fff3c4, var(--bfc-gold-2) 50%, var(--bfc-gold-3)); }
.bfc-prog--exp .bfc-prog__bar > i { background: linear-gradient(var(--bfc-exp-b), var(--bfc-exp-a) 50%, #d54a0c); }
.bfc-prog--good .bfc-prog__bar > i { background: linear-gradient(var(--bfc-nrg-b), var(--bfc-nrg-a) 50%, #1b9a07); }
.bfc-prog--blue .bfc-prog__bar > i { background: linear-gradient(var(--bfc-hp-b), var(--bfc-hp-a) 50%, #0b6fa0); }

/* ---------------------------------------------------------------- progress ring */
.bfc-ring { position: relative; display: inline-grid; place-items: center; width: var(--size, 64px); height: var(--size, 64px); flex: none; }
.bfc-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.bfc-ring__track { fill: rgba(5, 10, 24, .85); stroke: #0a0f1a; stroke-width: 8; }
.bfc-ring__fill { fill: none; stroke: var(--bfc-gold-1); stroke-width: 6; stroke-linecap: round; filter: drop-shadow(0 0 2px rgba(255, 210, 90, .6)); }
.bfc-ring--good .bfc-ring__fill { stroke: var(--bfc-nrg-a); }
.bfc-ring--blue .bfc-ring__fill { stroke: var(--bfc-hp-a); }
.bfc-ring__mid { position: relative; font: 800 calc(var(--size, 64px) * .24)/1 var(--bfc-font-game); color: #fff; text-shadow: var(--bfc-outline-thin); }

/* ---------------------------------------------------------------- chips */
.bfc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.bfc-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--bfc-tap); padding: 0 14px; border: 0; border-radius: 999px; cursor: pointer;
  font: 800 var(--bfc-fs-s)/1 var(--bfc-font-game); color: var(--bfc-ink-soft); text-shadow: var(--bfc-outline-thin);
  background: linear-gradient(#26314a, #121a2c); box-shadow: inset 0 0 0 1px rgba(214, 164, 62, .45), 0 2px 0 #000;
}
.bfc-chip:hover { filter: brightness(1.2); }
.bfc-chip[aria-pressed="true"] { color: var(--bfc-ink-dark); text-shadow: 0 1px 0 rgba(255, 255, 255, .5); background: linear-gradient(#fff3c4, #e2b450 60%, #b07a1c); box-shadow: 0 0 0 1px #000, inset 0 1px 0 #fffbe6, 0 2px 0 #000; }
.bfc-chip__n { padding: 2px 6px; border-radius: 999px; font-size: var(--bfc-fs-xs); background: rgba(0, 0, 0, .35); color: #fff; text-shadow: none; }
.bfc-chip .bfc-el { width: 20px; height: 20px; }

/* ---------------------------------------------------------------- pager */
.bfc-pager { display: flex; align-items: center; justify-content: center; gap: 10px; }
.bfc-pager__btn { width: var(--bfc-tap); height: var(--bfc-tap); border: 0; cursor: pointer; background: url(../assets/ui/arrow-r.png) center / 16px auto no-repeat; }
.bfc-pager__btn.is-prev { background-image: url(../assets/ui/arrow-l.png); }
.bfc-pager__btn:disabled { opacity: .3; cursor: default; }
.bfc-pager__at { min-width: 9ch; text-align: center; font: 800 var(--bfc-fs-s)/1 var(--bfc-font-game); color: #fff; text-shadow: var(--bfc-outline-thin); }

/* ---------------------------------------------------------------- data list (table on stone plates) */
.bfc-dlist { width: 100%; border-collapse: separate; border-spacing: 0 6px; font-size: var(--bfc-fs-s); }
.bfc-dlist__cap { caption-side: top; text-align: left; padding: 0 0 4px; font: 800 var(--bfc-fs-m)/1.2 var(--bfc-font-game); color: var(--bfc-ink-gold); text-shadow: var(--bfc-outline-thin); }
.bfc-dlist thead th { padding: 0 10px 2px; text-align: left; font: 800 10.5px/1.2 var(--bfc-font-game); letter-spacing: .06em; text-transform: uppercase; color: var(--bfc-ink-gold); text-shadow: var(--bfc-outline-thin); }
.bfc-dlist tbody th, .bfc-dlist tbody td { padding: 10px; text-align: left; vertical-align: middle; color: var(--bfc-ink-soft); text-shadow: 0 1px 0 #000; background: #2a333d; }
.bfc-dlist tbody th { font: 800 var(--bfc-fs-m)/1.25 var(--bfc-font-game); color: #fff; text-shadow: var(--bfc-outline-thin); border-radius: 6px 0 0 6px; }
.bfc-dlist tbody tr > :last-child { border-radius: 0 6px 6px 0; }
.bfc-dlist tbody tr > :only-child { border-radius: 6px; }
.bfc-dlist tbody tr { box-shadow: 0 2px 0 #000; }
.bfc-dlist tbody tr:nth-child(even) > * { background: #252d36; }
.bfc-dlist .is-end { text-align: right; font-variant-numeric: tabular-nums; }
.bfc-dlist tr.is-link { position: relative; cursor: pointer; }
.bfc-dlist__go { color: inherit; text-decoration: none; }
.bfc-dlist__go::after { content: ""; position: absolute; inset: 0; }
.bfc-dlist tr.is-link:hover > * { filter: brightness(1.18); }
.bfc-dlist__empty { padding: 12px; color: var(--bfc-ink-dim); text-align: center; }
@container pane (max-width: 420px) { .bfc-dlist .is-wide { display: none; } }

/* ---------------------------------------------------------------- virtual list */
.bfc-vlist { position: relative; contain: layout; }
.bfc-vlist__win { position: absolute; inset: 0 0 auto 0; display: grid; will-change: transform; }
.bfc-vlist__item { min-width: 0; }

/* ---------------------------------------------------------------- unit bust */
.bfc-bust { display: block; width: 100%; height: auto; aspect-ratio: 240 / 330; object-fit: cover; object-position: top center; }
.bfc-bust.is-missing, img.is-missing { visibility: hidden; }
/* the end of a unit chain is the game's 102 px "?" frame (art.js unitSilhouette): never blown up past its own size or
   stretched into a tall box; tall frames show it whole, high in the frame */
img[data-last] { object-fit: scale-down; object-position: 50% 30%; }

/* ---------------------------------------------------------------- live sprite (sprite.js) */
.bfc-sprite { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; }
.bfc-sprite__canvas { position: absolute; left: 0; top: 0; image-rendering: pixelated; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .5)); }

/* ---------------------------------------------------------------- route stub (a section not built yet) */
.bfc-stub__route { font-size: var(--bfc-fs-xs); color: var(--bfc-ink-dim); word-break: break-all; }

/* ---------------------------------------------------------------- unit power plate (the unit finder's tier + number) */
.bfc-pw { --bfc-tc: var(--bfc-tier-d); display: inline-flex; align-items: baseline; gap: 2px; padding: 0 4px 0 3px;
  border-radius: 6px; border: 1px solid var(--bfc-tc); background: linear-gradient(180deg, var(--bfc-navy-2), var(--bfc-navy-0));
  box-shadow: 0 1px 3px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .12);
  font: 800 11px/1.25 var(--bfc-font-game); color: var(--bfc-ink); text-shadow: var(--bfc-outline-thin);
  font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; }
.bfc-pw__t { color: var(--bfc-tc); font-weight: 900; }
.bfc-pw[data-tier="S"] { --bfc-tc: var(--bfc-tier-s); }
.bfc-pw[data-tier="A"] { --bfc-tc: var(--bfc-tier-a); }
.bfc-pw[data-tier="B"] { --bfc-tc: var(--bfc-tier-b); }
.bfc-pw[data-tier="C"] { --bfc-tc: var(--bfc-tier-c); }
.bfc-pw--l { font-size: 19px; gap: 4px; padding: 2px 8px 2px 7px; border-radius: 9px; border-width: 2px; }
.bfc-pwsum { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 0 6px; }
.bfc-pwsum__k { font: 800 12px/1.3 var(--bfc-font-game); color: var(--bfc-ink-gold); text-shadow: var(--bfc-outline-thin); }
.bfc-pwsum__n { font: 800 15px/1.3 var(--bfc-font-game); color: var(--bfc-ink); text-shadow: var(--bfc-outline-thin); font-variant-numeric: tabular-nums; }
.bfc-pwsum__note { font-size: 12px; color: var(--bfc-ink-dim); }
