/* =====================================================================
   Scout Team Builder — build-your-own-lineup tool.
   Extends scout_hub/_base.html, so it inherits the scout-hub design
   tokens (--bg-*, --text-*, --border-*, --accent-primary, --font-*,
   --radius-*, --shadow-*). Everything below references those vars so the
   page matches the rest of the Scout Hub exactly.
   ===================================================================== */

#tb{ --gold:#E8B923; --silver:#B9BDC6; --bronze:#C8825A; }

/* ── Header ─────────────────────────────────────────────────────── */
.tb-header{ align-items:flex-start; gap:24px; flex-wrap:wrap; }
.tb-header-actions{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }

.tb-clubpick{ position:relative; min-width:240px; }
.tb-clubpick > svg{
  position:absolute; left:11px; top:50%; transform:translateY(-50%);
  width:15px; height:15px; color:var(--text-tertiary); pointer-events:none;
}
.tb-clubpick .filter-input{ width:100%; padding-left:34px; }
.tb-clubpick-results{
  position:absolute; top:calc(100% + 4px); left:0; right:0; z-index:60;
  background:var(--bg-elevated); border:1px solid var(--border-medium);
  border-radius:var(--radius-md); max-height:320px; overflow:auto;
  box-shadow:var(--shadow-lg); display:none;
}
.tb-clubpick-results.open{ display:block; }
.tb-clubpick-opt{
  display:flex; align-items:center; gap:10px; padding:9px 12px; cursor:pointer;
  border-bottom:1px solid var(--border-subtle);
}
.tb-clubpick-opt:last-child{ border-bottom:none; }
.tb-clubpick-opt:hover,.tb-clubpick-opt.active{ background:var(--bg-hover); }
.tb-clubpick-opt img{ width:22px; height:22px; object-fit:contain; }
.tb-clubpick-opt .nm{ font-size:13px; color:var(--text-primary); }

/* ── Layout ─────────────────────────────────────────────────────── */
/* Pitch in a fixed-ish left column; the player panel fills the rest of
   the width so there's no dead space on wide desktops. */
.tb-layout{
  display:grid; grid-template-columns:minmax(380px,480px) minmax(0,1fr);
  gap:28px; align-items:start;
}
.tb-pitch-col{ min-width:0; }

/* ── Formation row ──────────────────────────────────────────────── */
.tb-formrow{ display:flex; align-items:center; gap:12px; margin-bottom:14px; flex-wrap:wrap; }
.tb-pills{ display:flex; gap:6px; flex-wrap:wrap; }
.tb-pill{
  height:30px; padding:0 12px; border-radius:var(--radius-sm); cursor:pointer;
  font-family:var(--font-display); font-size:12px; font-weight:500;
  border:1px solid var(--border-subtle); background:var(--bg-primary); color:var(--text-secondary);
  transition:all var(--transition-fast,.15s);
}
.tb-pill.active{ background:var(--accent-primary); border-color:var(--accent-primary); color:#fff; }
.tb-pill:hover:not(.active){ color:var(--text-primary); border-color:var(--border-medium); }
.tb-theme{
  display:flex; gap:2px; margin-left:auto; padding:3px;
  background:var(--bg-primary); border:1px solid var(--border-subtle); border-radius:var(--radius-sm);
}
.tb-theme button{
  height:24px; padding:0 11px; border:none; background:transparent; border-radius:4px;
  font-family:var(--font-display); font-size:11px; font-weight:500; color:var(--text-tertiary); cursor:pointer;
}
.tb-theme button.active{ background:var(--accent-primary); color:#fff; }

/* ── Pitch ──────────────────────────────────────────────────────── */
.tb-pitch-wrap{
  position:relative; width:100%; margin:0 auto;
  aspect-ratio:1 / 1.34;
  border-radius:var(--radius-lg); overflow:hidden;
  border:1px solid var(--border-subtle); box-shadow:var(--shadow-md);
  background:#0c1f14;
}
.tb-pitch-meta{
  margin-top:12px; text-align:center;
  font-family:var(--font-display); font-size:12px; color:var(--text-tertiary);
}
@supports not (aspect-ratio:1/1.34){ .tb-pitch-wrap{ padding-bottom:134%; } }
.tb-pitch-bg{ position:absolute; inset:0; width:100%; height:100%; object-fit:cover; }
.tb-pitch{ position:absolute; inset:0; }

.tb-slot{
  position:absolute; transform:translate(-50%,-50%);
  width:clamp(54px,8.4vw,72px);
  display:flex; flex-direction:column; align-items:center; gap:5px; cursor:pointer;
}
.tb-slot-circle{
  width:clamp(46px,7vw,58px); height:clamp(46px,7vw,58px); border-radius:50%;
  background:#fff; border:2.5px solid rgba(255,255,255,.55);
  display:grid; place-items:center; overflow:hidden; position:relative;
  box-shadow:0 3px 10px rgba(0,0,0,.4); transition:transform .15s, border-color .15s, box-shadow .15s;
}
.tb-slot:hover .tb-slot-circle{ transform:scale(1.06); }
.tb-slot.filled .tb-slot-circle{ border-color:var(--accent-primary); }
.tb-slot.is-transfer .tb-slot-circle{ border-color:var(--gold); }
/* Active slot (chosen to swap) — pulsing orange ring + scale, name pill goes
   solid orange, and every other slot dims so it's unmistakable. */
.tb-slot{ transition:opacity .15s; }
.tb-slot.is-active{ z-index:6; }
.tb-slot.is-active .tb-slot-circle{
  border-color:var(--accent-primary); border-width:3px;
  transform:scale(1.14);
  animation:tb-slot-pulse 1.25s ease-in-out infinite;
}
@keyframes tb-slot-pulse{
  0%,100%{ box-shadow:0 0 0 4px rgba(232,101,46,.55), 0 0 14px rgba(232,101,46,.45), 0 3px 10px rgba(0,0,0,.4); }
  50%    { box-shadow:0 0 0 8px rgba(232,101,46,.18), 0 0 24px rgba(232,101,46,.7),  0 3px 10px rgba(0,0,0,.4); }
}
.tb-slot.is-active .tb-slot-name{ background:var(--accent-primary); color:#fff; text-shadow:none; }
#tb.tb-has-active .tb-slot:not(.is-active){ opacity:.45; }
.tb-slot:not(.filled) .tb-slot-circle{ background:rgba(0,0,0,.32); border-style:dashed; }
.tb-slot-circle img{ width:100%; height:100%; object-fit:cover; }
.tb-slot-circle .ini{ font-family:var(--font-display); font-size:15px; font-weight:500; color:#333; }
.tb-slot-circle .plus{ font-size:24px; font-weight:300; color:rgba(255,255,255,.7); }

.tb-slot-xfer{
  position:absolute; top:-7px; right:-7px; z-index:2;
  font-family:var(--font-display); font-size:8px; font-weight:600;
  background:var(--gold); color:#000; border-radius:5px; padding:2px 4px; line-height:1;
}
.tb-slot-name{
  /* Always two lines tall so every pill matches; single-line names sit
     vertically centred. Names can run wider than the circle and wrap. */
  max-width:clamp(84px, 11vw, 108px); min-height:2.24em;
  display:flex; align-items:center; justify-content:center; text-align:center;
  font-size:11px; font-weight:600; line-height:1.12; color:#fff;
  background:rgba(0,0,0,.55); border-radius:5px; padding:2px 7px;
  text-shadow:0 1px 2px rgba(0,0,0,.5);
}
.tb-slot-name > span{
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
}
.tb-slot-name.empty{ background:rgba(0,0,0,.3); color:rgba(255,255,255,.75); font-weight:500; }
.tb-rating-stars{ display:inline-flex; gap:1px; }
.tb-slot .sr-star{ width:11px; height:11px; }

/* Star tier colours */
.tb-stars .sr-star{ color:#444; }
.tb-stars.tier-gold .sr-star{ color:var(--gold); }
.tb-stars.tier-silver .sr-star{ color:var(--silver); }
.tb-stars.tier-bronze .sr-star{ color:var(--bronze); }
.tb-slot .tb-stars .sr-star path{ stroke:rgba(0,0,0,.55); stroke-width:1.1; paint-order:stroke; }
.sr-star-empty{ color:rgba(255,255,255,.22) !important; }

/* ── Side panel ─────────────────────────────────────────────────── */
.tb-side{
  background:var(--bg-primary); border:1px solid var(--border-subtle);
  border-radius:var(--radius-md); overflow:hidden; position:sticky; top:20px;
}
.tb-side-handle{ display:none; }
.tb-tabs{ display:flex; border-bottom:1px solid var(--border-subtle); }
.tb-tab{
  flex:1; height:44px; border:none; background:transparent; cursor:pointer;
  font-family:var(--font-display); font-size:12px; font-weight:500; color:var(--text-tertiary);
  border-bottom:2px solid transparent; transition:color .15s;
}
.tb-tab.active{ color:var(--text-primary); border-bottom-color:var(--accent-primary); }
.tb-tabpane{ padding:16px; max-height:700px; overflow:auto; }

.tb-active-hint{
  display:none; font-size:12px; font-weight:500; color:var(--accent-primary);
  background:rgba(232,101,46,.1); border:1px solid rgba(232,101,46,.25);
  border-radius:var(--radius-sm); padding:8px 11px; margin-bottom:12px;
}
.tb-active-hint.show{ display:block; }

.tb-search-input{ position:relative; margin-bottom:12px; }
.tb-search-input svg{ position:absolute; left:11px; top:50%; transform:translateY(-50%); width:15px; height:15px; color:var(--text-tertiary); pointer-events:none; }
.tb-search-input .filter-input{ width:100%; padding-left:34px; }

.tb-filters{ display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-bottom:14px; }
.tb-filter{ display:flex; flex-direction:column; gap:5px; }
.tb-filter label{ font-size:10px; font-weight:600; text-transform:uppercase; letter-spacing:.06em; color:var(--text-tertiary); }
.tb-filter .filter-input,.tb-filter .filter-select{ width:100%; }

.tb-plist{
  margin:0; padding:0;
  display:grid; grid-template-columns:repeat(auto-fill, minmax(248px, 1fr)); gap:8px;
}
.tb-prow{
  display:flex; align-items:center; gap:11px; padding:9px 11px;
  border:1px solid var(--border-subtle); border-radius:var(--radius-sm);
  background:var(--bg-elevated); cursor:pointer; transition:border-color .15s, background .15s;
}
.tb-prow:hover{ border-color:var(--accent-primary); background:var(--bg-hover); }
.tb-prow.in-xi{ opacity:.4; }
.tb-prow-photo{ width:40px; height:40px; border-radius:50%; overflow:hidden; flex-shrink:0; background:var(--bg-interactive); display:grid; place-items:center; }
.tb-prow-photo img{ width:100%; height:100%; object-fit:cover; }
.tb-prow-photo .ini{ font-family:var(--font-display); font-size:13px; color:var(--text-tertiary); }
.tb-prow-body{ min-width:0; flex:1; }
.tb-prow-name{ font-size:13.5px; font-weight:600; color:var(--text-primary); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.tb-prow-meta{ font-size:11px; color:var(--text-tertiary); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:2px; }
.tb-prow-club{ color:var(--text-secondary); }
.tb-prow-side{ display:flex; flex-direction:column; align-items:flex-end; gap:3px; flex-shrink:0; }
.tb-prow-side .sr-star{ width:12px; height:12px; }
.tb-prow-val{ font-family:var(--font-display); font-size:11px; color:var(--text-secondary); }
.tb-plist-empty{ grid-column:1/-1; text-align:center; color:var(--text-tertiary); font-size:13px; padding:36px 16px; line-height:1.6; }
.tb-plist-empty strong{ color:var(--text-secondary); font-weight:600; }
.tb-loading{ grid-column:1/-1; text-align:center; color:var(--text-tertiary); font-size:13px; padding:24px; }

/* ── Share result overlay ───────────────────────────────────────── */
.tb-share-overlay{
  position:fixed; inset:0; z-index:2000; background:rgba(0,0,0,.82);
  display:flex; align-items:center; justify-content:center; padding:24px;
}
.tb-share-overlay[hidden]{ display:none; }
.tb-share-card{
  background:var(--bg-elevated); border:1px solid var(--border-medium);
  border-radius:var(--radius-lg); padding:18px; max-width:440px; width:100%;
  max-height:90vh; display:flex; flex-direction:column; gap:14px;
}
.tb-share-card.is-regenerating{ opacity:.5; pointer-events:none; }
.tb-share-card-head{ display:flex; align-items:center; justify-content:space-between; }
.tb-share-preview-wrap{ flex:1; min-height:0; overflow:auto; border-radius:var(--radius-md); }
.tb-share-preview-wrap img{ width:100%; display:block; border-radius:var(--radius-md); }
.tb-share-actions{ display:flex; gap:8px; }
.tb-share-actions .btn{ flex:1; justify-content:center; }

.tb-capture-frame{ position:fixed; left:-9999px; top:0; width:1080px; height:1400px; border:0; opacity:0; pointer-events:none; }

/* ── Toast ──────────────────────────────────────────────────────── */
.tb-toast{
  position:fixed; left:50%; bottom:88px; transform:translateX(-50%) translateY(12px);
  background:#0A0A0A; color:#fff; border:1px solid var(--border-medium);
  border-radius:var(--radius-md); padding:11px 18px; font-size:13px; font-weight:500;
  z-index:2100; opacity:0; transition:opacity .2s, transform .2s; pointer-events:none;
  max-width:90vw; text-align:center;
}
.tb-toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }
.tb-toast.error{ border-color:#7f1d1d; }

.tb-sheet-backdrop{ display:none; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width:980px){
  .tb-layout{ grid-template-columns:1fr; }
  .tb-side{
    position:fixed; left:0; right:0; bottom:0; z-index:1900; top:auto;
    border-radius:var(--radius-lg) var(--radius-lg) 0 0; max-height:74vh;
    transform:translateY(106%); transition:transform .26s cubic-bezier(.2,.7,.3,1);
    box-shadow:0 -16px 40px rgba(0,0,0,.5);
  }
  #tb.picker-open .tb-side{ transform:translateY(0); }
  #tb.picker-open ~ .tb-sheet-backdrop{ display:block; position:fixed; inset:0; z-index:1880; background:rgba(0,0,0,.55); }
  .tb-side-handle{ display:block; height:5px; width:40px; margin:8px auto 4px; border-radius:3px; background:var(--border-medium); }
}
