/* The SBC page: a tile per SBC set, and the squad the builder puts together, drawn on
   a pitch like the one on the home page. Shared pieces (buttons, chips, the platform
   switch, the player card) come from site.css. */

/* ---------- above the list ---------- */
/* a search that found nothing: the line says so, the button under it clears the search (the same on the price list) */
.state-act { display: flex; justify-content: center; margin: -22px 0 30px; }
/* the box that narrows the list by name: a normal field, on a phone a whole line of its own */
.search-bar .find { flex: 0 1 260px; min-width: 180px; }
@media (max-width: 620px) { .search-bar .find { flex: 1 1 100%; } }
.club-note { flex: 1 1 260px; max-width: 420px; color: var(--dim); font-size: 13.5px; line-height: 1.45; }
.club-note b { color: var(--brand); font-weight: 650; }
.club-note .link { color: var(--mute); }
.club-note .link:hover { color: var(--chalk); }

.sbc-tabs { margin: 4px 0 18px; }
.chip-n { margin-left: 4px; color: var(--dim); font-weight: 600; }
.chip[aria-pressed="true"] .chip-n { color: inherit; }

/* ---------- the tiles, one per SBC set ---------- */
.sbcs {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(400px, 100%), 1fr)); gap: 14px; align-items: start;
}
.sbc {
  min-width: 0; display: flex; flex-direction: column; gap: 12px; padding: 16px 18px 14px;
  background: var(--stand); border: 1px solid var(--line-soft); border-radius: var(--r);
  transition: border-color .15s ease;
}
.sbc:hover { border-color: var(--line); }
.sbc.finished { border-color: rgba(0, 229, 138, .32); }
.sbc.open { grid-column: 1 / -1; border-color: rgba(0, 229, 138, .45); }

.sbc-top { display: flex; align-items: flex-start; gap: 14px; cursor: pointer; }
/* Our own badge per kind of SBC, shaped like EA's SBC crests: a metal rim (--m1 to --m3)
   around a dark shield (--f1, --f2), with the sign of the kind in the rim's light colour.
   The shape is cut twice, the rim and then the field 3px inside it. */
.sbc-pic {
  --m1: #f6e3a1; --m2: #c99a3c; --m3: #7d5a1c; --f1: #2e2412; --f2: #120d05; --ink: #f6db7b;
  --crest: polygon(50% 0, 63% 5%, 80% 7%, 97% 6%, 100% 11%, 100% 50%, 98% 63%, 92% 75%, 82% 85%, 67% 94%, 50% 100%,
    33% 94%, 18% 85%, 8% 75%, 2% 63%, 0 50%, 0 11%, 3% 6%, 20% 7%, 37% 5%);
  position: relative; flex: 0 0 auto; width: 44px; height: 50px;
  display: flex; align-items: center; justify-content: center; color: var(--ink);
  background: linear-gradient(155deg, var(--m1), var(--m2) 55%, var(--m3));
  clip-path: var(--crest);
}
.sbc-pic:before {
  content: ''; position: absolute; inset: 3px 3px 3.5px; clip-path: var(--crest);
  background:
    linear-gradient(200deg, rgba(255, 255, 255, .16), transparent 42%),
    linear-gradient(160deg, var(--f1), var(--f2));
}
.sbc-pic svg {
  position: relative; width: 23px; height: 23px; margin-top: -3px;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
/* upgrades bronze to gold, players gold on black like Team of the Week, challenges
   silver on navy, foundations teal like Squad Foundations, the rest violet */
.sbc-pic.k-upgrades { --m1: #f4c89a; --m2: #c27a3e; --m3: #6e3d17; --f1: #3a2412; --f2: #170c05; --ink: #f7d2a5; }
.sbc-pic.k-challenges { --m1: #f4f6f9; --m2: #a9b4c1; --m3: #5f6b78; --f1: #1d2a3e; --f2: #0b131f; --ink: #e9eef4; }
.sbc-pic.k-foundations { --m1: #b8fbf6; --m2: #3fcfc9; --m3: #116b67; --f1: #05433e; --f2: #021f1c; --ink: #9ff5f0; }
.sbc-pic.k-other { --m1: #d9ccff; --m2: #8a6ee0; --m3: #3f2a8c; --f1: #241552; --f2: #0e0826; --ink: #dcd0ff; }
.sbc-who { flex: 1; min-width: 0; }
.sbc-name {
  margin: 1px 0 4px; font-size: 21px; font-stretch: 78%; font-weight: 760; line-height: 1.12; letter-spacing: 0;
  overflow-wrap: anywhere;
}
.sbc-cat { margin: 0; color: var(--dim); font-size: 13.5px; line-height: 1.5; }
.sbc-cat .flag { margin-left: 4px; }
.flag {
  display: inline-flex; align-items: center; gap: 6px; padding: 0 7px; border-radius: 6px; vertical-align: 1px;
  border: 1px solid var(--line); color: var(--mute); font: 650 12.5px/1.6 var(--sans);
}
.flag.new { color: var(--blue); border-color: rgba(142, 184, 255, .45); }
.flag.done { color: var(--brand); border-color: rgba(0, 229, 138, .45); background: rgba(0, 229, 138, .1); }
/* done is said with a tick and a word, never by fading the tile */
.flag.done:before {
  content: ''; width: 8px; height: 4px; margin: -3px 1px 0 1px;
  border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg);
}

/* what our squad costs, and the gem score it needs */
.sbc-badges { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 7px; padding-top: 2px; }
.bg-coin { display: inline-flex; align-items: center; gap: 7px; color: var(--coin); font: 820 25px/1 var(--sans); font-stretch: 66%; }
.bg-coin:before { content: ''; flex: 0 0 auto; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--coin); }
.bg-coin.wait { color: var(--dim); font: 700 17px/1 var(--sans); letter-spacing: .06em; }
.bg-coin.wait:before { border-color: var(--line); }
.bg-gem { display: inline-flex; align-items: center; gap: 7px; color: var(--cyan); font: 700 14px/1 var(--sans); }
.bg-gem:before { content: ''; width: 8px; height: 8px; border-radius: 1.5px; background: var(--cyan); transform: rotate(45deg); }

.sbc-state { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 14px; margin: 0; color: var(--dim); font-size: 13px; }
.sbc-count { color: var(--mute); font-weight: 600; }
.sbc-count.ok { color: var(--brand); }
.sbc-prog { height: 4px; margin-top: -6px; border-radius: 2px; background: var(--line-soft); overflow: hidden; }
.sbc-prog i { display: block; height: 100%; border-radius: 2px; background: var(--brand); transition: width .2s ease; }

/* ---------- the reward ---------- */
.sbc-prize {
  display: flex; align-items: center; gap: 14px; padding: 10px 12px;
  border-radius: var(--r-sm); background: var(--well); border: 1px solid var(--line-soft);
}
/* a player reward is EA's full card, as large as the row allows */
.pz-pic { flex: 0 0 auto; width: 76px; height: 100px; display: flex; align-items: center; justify-content: center; }
/* the full card at a list size, like fut.gg's (name and stats readable); the picture's own
   transparent margin above and below the card is taken back */
.pz-pic:has(.bcard) { width: 100px; height: auto; }
.pz-pic .bcard { width: 100px; margin: -11px 0 -7px; }
.pz-who { min-width: 0; }
.pz-lab { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; color: var(--dim); font-size: 12.5px; line-height: 1.4; }
.pz-tag { padding: 0 6px; border-radius: 5px; border: 1px solid var(--line); color: var(--mute); font-size: 12px; font-weight: 600; }
.pz-what { margin: 3px 0 0; font-size: 15px; font-weight: 650; line-height: 1.3; }
.pz-note { margin: 2px 0 0; color: var(--dim); font-size: 12.5px; }

/* EA's own pack picture where we have one (.art, --art from /api/ea/pack/<n>.png), in
   the size of EA's pack (252 by 366), with the drawn pack underneath it: when the picture
   does not come, the drawn one shows. Coins and a player item keep their drawing. */
.pack {
  --pack-bg: linear-gradient(160deg, #3a4f6b, #1a2a40 65%);
  position: relative; display: flex; align-items: flex-end; justify-content: center; overflow: hidden;
  width: 40px; height: 54px; border-radius: 5px;
  background: var(--pack-bg);
  border: 1px solid rgba(255, 255, 255, .16);
  box-shadow: inset 0 10px 16px rgba(255, 255, 255, .07), 0 4px 10px rgba(0, 0, 0, .35);
}
/* the diagonal shine every drawn pack has */
.pack:before {
  content: ''; position: absolute; left: -40%; top: -30%; width: 60%; height: 170%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .22), transparent);
  transform: rotate(22deg);
}
/* the count sits on a solid chip, so it reads on every colour of pack */
.pack i {
  position: relative; margin-bottom: 4px; padding: 1px 4px; border-radius: 4px;
  background: rgba(0, 0, 0, .72); color: #fff; font: 800 10.5px/1.2 var(--sans); font-style: normal;
}
.pack-bronze { --pack-bg: linear-gradient(160deg, #c08552, #6b3f21 65%); }
.pack-silver { --pack-bg: linear-gradient(160deg, #cdd6df, #71808e 65%); }
.pack-gold { --pack-bg: linear-gradient(160deg, #f2d47a, #a6791f 65%); }
.pack-electrum { --pack-bg: linear-gradient(160deg, #7fe3f0, #1d6e8a 65%); }
.pack-premium { --pack-bg: linear-gradient(160deg, #b79bff, #4a2f8f 65%); }
.pack-mixed { --pack-bg: linear-gradient(160deg, #f2d47a 0%, #cdd6df 45%, #c08552 100%); }
.pack-iconpick { --pack-bg: linear-gradient(160deg, #fffaf0, #c9b88a 70%); }
.pack-coins {
  --pack-bg: radial-gradient(circle at 34% 30%, #ffe89a, #c9992a 70%);
  width: 42px; height: 42px; border-radius: 50%;
  border-color: rgba(255, 255, 255, .3);
}
.pack-coins:before { display: none; }
.pack.art {
  width: 46px; height: 67px; border: 0; border-radius: 3px; box-shadow: none;
  background: var(--art) center / 100% 100% no-repeat, var(--pack-bg);
}
.pack.art:before { display: none; }

.sbc-foot { display: flex; gap: 8px; margin-top: auto; }
.sbc-foot .btn { flex: 1; }
.sbc-foot .tick { flex: 0 0 auto; }
.sbc.finished .tick { border-color: rgba(0, 229, 138, .45); color: var(--brand); }

/* ---------- an open SBC ---------- */
.sbc-body { padding-top: 14px; border-top: 1px solid var(--line-soft); }
.sbc-about { margin: 0 0 12px; color: var(--mute); font-size: 15px; max-width: 72ch; }
.sbc-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 0 0 6px; }
.sbc-total { margin: 0 0 0 auto; text-align: right; }
.sbc-total span { display: block; color: var(--dim); font-size: 12.5px; }
.sbc-total b { color: var(--coin); font: 820 25px/1.1 var(--sans); font-stretch: 66%; }
.sbc-total:empty { display: none; }

.sbc-chs { list-style: none; margin: 0; padding: 0; }
.sbc-ch { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 16px 0; border-top: 1px solid var(--line-soft); }
.sbc-ch:first-child { border-top: 0; padding-top: 6px; }
.sbc-ch:last-child { padding-bottom: 4px; }
.sbc-ch-top { display: flex; align-items: center; gap: 12px; }
.sbc-ch-top h3 { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.3; min-width: 0; overflow-wrap: anywhere; }
.sbc-ch-top .flag { flex: 0 0 auto; }
.sbc-ch-cost { margin: 4px 0 0 40px; color: var(--dim); font-size: 13.5px; }

/* the box you tick for a challenge you already did: the tick is drawn and hidden with
   visibility, so Windows high contrast never shows a tick that is not there */
.tickbox {
  position: relative; flex: 0 0 auto; width: 28px; height: 28px; padding: 0; cursor: pointer;
  border-radius: var(--r-sm); border: 1.5px solid var(--dim); background: var(--well); color: var(--brand-ink);
}
.tickbox:hover { border-color: var(--chalk); }
.tickbox span {
  visibility: hidden; position: absolute; left: 7.5px; top: 7px; width: 10px; height: 5.5px;
  border-left: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor; transform: rotate(-45deg);
}
.tickbox.on { background: var(--brand); border-color: var(--brand); }
.tickbox.on span { visibility: visible; }
.tickbox.on:focus-visible { outline-color: var(--chalk); }

.reqs { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.reqs li {
  padding: 5px 10px; border-radius: var(--r-sm); background: var(--well); border: 1px solid var(--line-soft);
  color: var(--mute); font-size: 13.5px; line-height: 1.35;
}
.reqs li.gem { border-color: rgba(0, 184, 212, .5); color: var(--chalk); }

/* wide enough: what it asks on the left, the squad on the right */
@media (min-width: 1000px) {
  .sbc-ch { grid-template-columns: minmax(250px, 340px) minmax(0, 1fr); gap: 28px; align-items: start; }
}

/* ---------- the squad the builder found ---------- */
.sol { min-width: 0; border-radius: var(--r); }
.sol:focus-visible { outline-offset: 4px; }
.sq-busy { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.sq-busy .bar { flex: 1; max-width: 260px; margin: 0; }
.sq-busy span { color: var(--mute); font-size: 14px; }
.sq-warn {
  margin: 0 0 10px; padding: 8px 12px; border-left: 3px solid var(--red); border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: var(--well); color: var(--chalk); font-size: 14px;
}

.sq {
  max-width: 860px; overflow: hidden; container-type: inline-size;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--well);
}
.sq-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; padding: 12px 16px; }
.sq-facts { display: flex; flex-wrap: wrap; gap: 10px 26px; margin: 0; }
.sq-facts div { display: flex; flex-direction: column-reverse; }
.sq-facts dt { margin-top: 3px; color: var(--dim); font-size: 12.5px; }
.sq-facts dd { margin: 0; font: 820 24px/1 var(--sans); font-stretch: 66%; }
.sq-facts .coin dd { color: var(--coin); }
.sq-facts .gem dd { color: var(--cyan); }
.sq-facts .mine dd { color: var(--brand); }
.sq .sq-warn { margin: 0 16px 12px; }
.sq-note { margin: 0; padding: 10px 16px 12px; color: var(--dim); font-size: 13px; }

/* the pitch: turf stripes and chalk lines, like the home page; attackers at the top.
   EA's full card (name and stats) on every spot, as wide as the longest line allows
   (--per, set by sbc.js: 4 for a 4-4-2, 5 for a 4-5-1), up to 132 pixels. */
.pitch {
  --per: 5;
  --gap: 6px;
  --card-w: min(132px, calc((100cqw - 28px - (var(--per) - 1) * var(--gap)) / var(--per)));
  --pad-b: 24px;   /* below the keeper, down to the goal line */
  position: relative; display: flex; flex-direction: column; gap: 18px; padding: 26px 14px var(--pad-b);
  background: repeating-linear-gradient(180deg, var(--turf) 0 56px, var(--turf-2) 56px 112px);
  border-block: 1px solid var(--line-soft);
}
/* the touchlines, and the halfway line along the top */
.pitch:before {
  content: ''; position: absolute; inset: 8px; pointer-events: none;
  border: 1.5px solid var(--chalk-line); border-radius: 3px;
}
/* the centre circle, the half of it in our half */
.pitch:after {
  content: ''; position: absolute; top: 8px; left: 50%; translate: -50% 0; pointer-events: none;
  width: calc(var(--card-w) * 1.9); height: calc(var(--card-w) * .95);
  border: 1.5px solid var(--chalk-line); border-top: 0; border-radius: 0 0 999px 999px;
}
.pitch.loose:after { display: none; }

.sq-line { position: relative; z-index: 1; list-style: none; margin: 0; padding: 0; display: flex; justify-content: space-evenly; gap: var(--gap); }
.pitch.loose .sq-line { flex-wrap: wrap; justify-content: center; gap: 16px 10px; }
.sq-card { display: flex; min-width: 0; }
.sq-link { display: flex; flex-direction: column; align-items: center; border-radius: 6px; color: var(--chalk); }
/* no shadow under the card: fut.gg and the game draw none, and on the grass it read as a
   second, dark card behind it */
.sq-link:hover .bcard { filter: brightness(1.08); }
.sq-link:hover .sq-price { box-shadow: 0 0 0 1px currentColor; }
.sq-pic { position: relative; display: flex; }
/* under the card, on one plate: the spot the player fills when it is not his own
   position, and his chemistry as three diamonds, like the game */
.sq-under {
  position: relative; z-index: 2; display: flex; align-items: center; gap: 5px; min-height: 18px;
  margin-top: calc(var(--card-w) * -.1); padding: 3px 5px; border-radius: 4px;
  background: rgba(3, 20, 12, .9);
}
.sq-slot { color: var(--chalk); font: 760 10.5px/1 var(--sans); font-stretch: 85%; }
.sq-chem { display: flex; gap: 4px; }
.sq-chem i { width: 5px; height: 5px; border: 1px solid var(--dim); border-radius: 1px; transform: rotate(45deg); }
.sq-chem i.on { border-color: var(--brand); background: var(--brand); }
.sq-price {
  position: relative; z-index: 2; margin-top: 4px; padding: 3px 7px; border-radius: 5px; white-space: nowrap;
  background: rgba(3, 20, 12, .88); color: var(--coin); font: 700 12px/1 var(--sans);
}
.sq-card.mine .sq-price { color: var(--brand); }
.sq-gems {
  margin-top: 3px; padding: 2px 6px; border-radius: 4px; white-space: nowrap;
  background: rgba(3, 20, 12, .88); color: var(--cyan); font: 650 11.5px/1.1 var(--sans);
}

/* The penalty area, drawn around the keeper's own card so it fits whatever the card
   size: its top line runs above the keeper with the arc above that, both clear of the
   defenders' prices, and the six-yard line runs behind the keeper's card, so his price
   and chemistry stand inside the box with no line through them. */
.sq-line.gk { margin-top: calc(var(--card-w) * .26 + 14px); }
.sq-line.gk .sq-card { position: relative; }
.pitch-box {
  position: absolute; z-index: -1; left: 50%; top: -14px; bottom: calc(8px - var(--pad-b)); translate: -50% 0;
  width: min(62cqw, calc(var(--card-w) * 4.6)); pointer-events: none;
  border: 1.5px solid var(--chalk-line); border-bottom: 0;
}
.pitch-box i {
  position: absolute; left: 50%; bottom: 0; translate: -50% 0;
  top: calc(12.5px + var(--card-w) * .95); width: 46%;
  border: 1.5px solid var(--chalk-line); border-bottom: 0;
}
.pitch-box:before {
  content: ''; position: absolute; left: 50%; bottom: calc(100% + 1.5px); translate: -50% 0;
  width: 36%; height: calc(var(--card-w) * .26);
  border: 1.5px solid var(--chalk-line); border-bottom: 0; border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}

/* EA's full card (site.css), sized to the pitch it stands on; everything on it scales
   with its width */
.pitch .bcard { width: var(--card-w); }

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  .sbc { padding: 14px 14px 12px; }
  .sbc-name { font-size: 19px; }
  .sbc-pic { width: 40px; height: 40px; }
  .sbc-pic svg { width: 21px; height: 21px; }
  .sbc-state { flex-direction: column; }
  .sq-head { padding: 12px; }
  .sq-facts { gap: 10px 18px; }
  /* A phone has room for five cards of about 70 pixels. The squad runs to the edges of
     the tile, and the cards in a full line stand close enough that their clear edges
     (EA's card picture has some on both sides) overlap, never the cards themselves. */
  .sbc .sq { margin-inline: -14px; border-inline: 0; border-radius: 0; }
  .pitch {
    --pad-b: 22px; padding: 22px 6px var(--pad-b); gap: 16px;
    --card-w: calc((100cqw - 12px) / (var(--per) - (var(--per) - 1) * .06));
  }
  .pitch .sq-line { gap: 0; }
  .pitch .sq-card + .sq-card { margin-left: calc(var(--card-w) * -.06); }
  .pitch.loose .sq-card + .sq-card { margin-left: 0; }
  .sq-under { padding: 2px 4px; gap: 4px; }
  .sq-slot { font-size: 10px; }
  .sq .sq-warn { margin: 0 12px 12px; }
  .sq-note { padding: 10px 12px 12px; }
}
@media (max-width: 420px) {
  .sq-price { padding: 2px 5px; font-size: 10.5px; }
  .sq-gems { font-size: 10px; }
}

/* Windows high contrast: the drawn ticks and progress keep a visible edge */
@media (forced-colors: active) {
  .sbc-prog { border: 1px solid CanvasText; }
  .sbc-prog i { background: Highlight; }
  .tickbox.on { border-color: Highlight; }
  /* a filled diamond stays filled */
  .sq-chem i { forced-color-adjust: none; border-color: CanvasText; }
  .sq-chem i.on { background: CanvasText; }
}
