/* The binder (stage 2, plan B, task 8), ported from v1 (game/index.html
   149-173, 298-305, 588-652, 773). The card faces (.bcard and what is inside
   it) are drawn by cards/art.js for every screen that shows a card - the
   binder, the reveal, the dugout's news - so their rules are not scoped
   under .binder; everything else here is. */

.bcard, .binder {
  --mono: ui-monospace, "Share Tech Mono", Menlo, Consolas, monospace;
  --chalk-dim: var(--muted);
  --good: #6CC070;
  --blue-lt: #7FB8E6;
}

/* ---- the card itself: a button that turns over ---- */
.bcard {
  position: relative; display: block; width: 100%; aspect-ratio: 2.5 / 3.5;
  background: none; border: 0; padding: 0; border-radius: 10px;
  font-weight: 400; color: var(--chalk); perspective: 900px; cursor: pointer;
}
.bcard-in { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .55s; }
@media (prefers-reduced-motion: reduce) { .bcard-in { transition: none; } }
.bcard.flipped .bcard-in { transform: rotateY(180deg); }
.bcard .face, .bcard .back {
  position: absolute; inset: 0; backface-visibility: hidden; border-radius: 10px; overflow: hidden;
  display: flex; flex-direction: column; border: 2px solid var(--line);
  background: linear-gradient(165deg, #242A20, #14170F);
}
.bcard .back { transform: rotateY(180deg); padding: 12px; text-align: left; justify-content: flex-start; }
.bcard.rare .face, .bcard.rare .back { border-color: var(--blue-lt); }
.bcard.gold .face, .bcard.gold .back { border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(253,184,39,.35), 0 6px 18px -8px rgba(253,184,39,.6); }
.bcard.rookie .face, .bcard.rookie .back { border-color: var(--chalk-dim); }
.bcard.star .face, .bcard.star .back { border-color: var(--blue-lt); }
.bcard.superstar .face, .bcard.superstar .back { border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(253,184,39,.35), 0 6px 18px -8px rgba(253,184,39,.6); }
.bcard.superstar .card-name { color: var(--gold); }
.bcard.legend .face, .bcard.legend .back { border-color: #0B0C09; box-shadow: inset 0 0 0 2px var(--gold); }
.bcard.locked .face { filter: grayscale(1) brightness(.45); }
/* a missing player card is a slot, not a smudge: a dashed outline with a
   silhouette and its number, so the binder reads as "here is what is still
   out" instead of empty space */
.bcard.player.locked .face { filter: none; background: #1A1D17; border: 1px dashed var(--line); box-shadow: none; }
.bcard .locked-face { flex: 1; min-height: 0; width: 100%; }
.bcard.player.locked .locked-face {
  background:
    radial-gradient(circle at 50% 34%, var(--line) 0 14%, transparent 15%),
    radial-gradient(ellipse at 50% 78%, var(--line) 0 30%, transparent 31%);
  opacity: .55;
}
.bcard.player.locked .card-num ~ .card-name { display: none; }
.bcard.player.locked:has(.card-num) .locked-face { opacity: .18; }
.bcard.player.locked .face .card-name { filter: none; letter-spacing: .2em; }
.bcard.player.locked { opacity: .75; }
.bcard .card-num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 15px; color: var(--chalk-dim); opacity: .9; z-index: 1;
}
.bcard .card-art { flex: 1; min-height: 0; display: block; width: 100%; }
.bcard .photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.bcard .icon-badge { position: absolute; top: 6px; left: 6px; color: var(--gold); opacity: .9;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.6)); }
.bcard.locked .icon-badge { opacity: .35; }
.bcard .card-name { font-family: var(--display); font-size: 12px; line-height: 1.15; padding: 7px 8px 3px;
  color: var(--chalk); text-align: center; }
.bcard.gold .card-name { color: var(--gold); }
.bcard .card-pos { font-family: var(--mono); font-size: 10px; color: var(--chalk-dim);
  text-align: center; padding-bottom: 8px; letter-spacing: .08em; min-height: 1.2em; }
.bcard .back h5 { font-family: var(--display); font-size: 13px; margin: 0 0 6px; color: var(--gold); font-weight: 400; }
.bcard .back h5.word-big { font-size: 22px; letter-spacing: .03em; overflow-wrap: anywhere; }
.bcard .back p { font-size: 12px; line-height: 1.45; color: var(--chalk-dim); margin: 0 0 8px; font-style: italic; }
.bcard .back .stat-line { font-family: var(--mono); font-size: 11px; color: var(--chalk);
  border-top: 1px solid var(--line); padding-top: 7px; margin-top: auto; }
.bcard:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
/* a card no screen has shown him yet */
.bcard .new-tag {
  position: absolute; top: -6px; right: -6px; z-index: 3; padding: 2px 6px; border-radius: 8px;
  background: var(--gold); color: #1b1e19; font-family: var(--display); font-size: 10px; letter-spacing: .08em;
  box-shadow: 0 2px 6px rgba(0,0,0,.5); pointer-events: none;
}

/* ---- the binder screen ---- */
.binder h1 { text-align: center; font-family: var(--display); font-weight: 400; margin-bottom: .6rem; }
.binder .card-count { font-family: var(--mono); font-size: 13px; color: var(--chalk-dim); text-align: center; }
.binder .card-tabs, .binder .binder-chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.binder .tabbtn {
  font-family: var(--mono); font-size: 12px; font-weight: 400; letter-spacing: .04em; color: var(--chalk-dim);
  background: #1b1e19; border: 1px solid var(--line); border-radius: 20px; padding: 7px 14px; min-height: 38px;
}
.binder .tabbtn.active { color: var(--chalk); border-color: var(--gold); background: rgba(253,184,39,.12); }
.binder-swap {
  display: flex; align-items: center; gap: 11px; margin: 12px auto 0; max-width: 520px;
  background: #1b1e19; border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px;
}
.binder-swap .swap-icon { color: var(--gold); flex-shrink: 0; }
.binder-swap .grow { flex: 1; min-width: 0; }
.binder-swap b { display: block; font-size: 14px; color: var(--chalk); }
.binder-swap .sub { font-size: 12px; color: var(--chalk-dim); margin-top: 1px; }
.binder-swap .dots { display: flex; gap: 3px; flex-shrink: 0; }
.binder-swap .dots i { width: 7px; height: 7px; border-radius: 50%; border: 1px solid var(--line); display: block; }
.binder-swap .dots i.on { background: var(--gold); border-color: var(--gold); }
.binder-note { font-size: 13px; color: var(--chalk-dim); text-align: center; margin: 12px 0 0; line-height: 1.45; }
.binder-none { font-size: 13px; color: var(--chalk-dim); text-align: center; margin: 12px 0 0; }

.binder .cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); margin-top: 14px; }
/* the Players tab: a stack of sets, each with its own grid */
.binder .cards.grouped { display: block; }
.binder .set { margin-top: 18px; }
.binder .set-head {
  display: flex; align-items: baseline; gap: 8px; width: 100%; text-align: left;
  background: none; border: 0; border-radius: 6px; padding: 6px 0; color: inherit; font-weight: 400;
}
.binder .set-head .eyebrow { flex: 1; margin: 0; font-family: var(--display); font-size: 12px; letter-spacing: .12em;
  color: var(--gold); text-transform: uppercase; }
.binder .set-head .meta { font-family: var(--mono); font-size: 11px; color: var(--chalk-dim); }
.binder .set-head .chev { font-family: var(--mono); font-size: 16px; color: var(--gold); width: 18px; text-align: right; }
.binder .set.open .set-head { position: sticky; top: 0; z-index: 4; background: var(--panel);
  box-shadow: 0 8px 12px -8px rgba(0,0,0,.7); }
.binder .set-bar { height: 5px; border-radius: 3px; background: rgba(255,255,255,.12); overflow: hidden; margin-top: 7px; }
.binder .set-bar i { display: block; width: 0; height: 100%; background: var(--gold); }
.binder .set-bar i.near { background: var(--good); }
.binder .set-togo { font-size: 12px; color: var(--chalk-dim); margin-top: 8px; }
.binder .set-togo.near { color: var(--good); }
/* inside a set the cards are thumbnails: four across on a phone, more on
   the PC - tap one to turn it over */
.binder .cards.grouped .cards { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-top: 10px; }
.binder .cards.grouped .bcard .card-name { font-size: 8px; line-height: 1.1; padding: 4px 4px 2px; letter-spacing: .02em; }
.binder .cards.grouped .bcard .card-pos { font-size: 7px; padding-bottom: 5px; }
.binder .cards.grouped .bcard .back { padding: 6px; }
.binder .cards.grouped .bcard .back h5 { font-size: 9px; margin-bottom: 3px; }
.binder .cards.grouped .bcard .back p { font-size: 8px; line-height: 1.3; margin-bottom: 4px; }
.binder .cards.grouped .bcard .back .stat-line { font-size: 7px; padding-top: 4px; }
.binder .cards.grouped .bcard.player.locked .face .card-name { letter-spacing: .1em; }
.binder .cards.grouped .bcard .new-tag { font-size: 8px; top: -4px; right: -4px; }

.binder-foot { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; margin-top: 22px; }
.binder-foot > button { flex: 1 1 12rem; max-width: 20rem; }
.binder-foot > button.ghost { background: transparent; color: var(--chalk); border: 1px solid var(--line); }

@media (max-width: 420px) {
  .binder .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .binder .cards.grouped .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
