/* Teamspin, on top of kit/kit.css.
   The first visit is a short pitch beside the class form; after that the tool is a stage (wheel, groups or order)
   beside a rail with the controls and who is here today. Groups and order take the class wheel's colours. */

/* ---------- first visit ---------- */
.ts-start { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: center; gap: clamp(24px, 5vw, 72px); min-height: calc(100vh - 120px); padding-block: 10px 20px; }
.ts-start-copy { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ts-start-copy > * { animation: rise .6s cubic-bezier(.2,.9,.3,1) both; }
.ts-start-copy > :nth-child(2) { animation-delay: .06s; } .ts-start-copy > :nth-child(3) { animation-delay: .12s; } .ts-start-copy > :nth-child(4) { animation-delay: .18s; }
.ts-title { font-size: clamp(52px, 7.6vw, 108px); line-height: .96; }
.ts-lead { margin: 0; max-width: 36ch; font-size: clamp(18px, 1.7vw, 22px); line-height: 1.45; }
.ts-points { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 0; padding: 0; list-style: none; font-size: 17px; }
.ts-points li { display: flex; align-items: center; gap: 12px; }
.ts-points i { flex: none; width: 16px; height: 16px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 3px rgba(0,0,0,.12); }
.ts-form { gap: 10px; max-width: 560px; width: 100%; justify-self: center; padding: clamp(20px, 3vw, 30px); animation: pop .6s .1s cubic-bezier(.2,1.3,.4,1) both; }
.ts-form-title { margin: 0 0 4px; font-size: 28px; font-weight: 900; }
.ts-names { min-height: 220px; font-weight: 700; }
.ts-form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.ts-private { display: flex; align-items: flex-start; gap: 8px; margin: 4px 0 0; color: var(--muted); font-size: 14px; font-weight: 700; line-height: 1.4; }
.ts-private svg { flex: none; width: 18px; height: 18px; margin-top: 1px; color: var(--link); }

/* ---------- the tool ---------- */
.ts-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 18px; padding-block: 12px 18px; }
.ts-class { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; min-width: 0; }
.ts-class .dd-btn { min-height: 46px; padding: 9px 18px; font-size: 18px; font-weight: 900; }
.ts-count { margin: 0; color: var(--muted); font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; }
.ts-modes { margin-inline: auto; }
.ts-modes button { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; font-size: 15px; }
.ts-modes svg { width: 18px; height: 18px; flex: none; }
.ts-bar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ts-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 390px); gap: clamp(18px, 3vw, 44px); align-items: start; }
.ts-stage { min-width: 0; }
.ts-rail { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ts-rail > * { animation: rise .55s cubic-bezier(.2,.9,.3,1) both; }
.ts-rail > :nth-child(4) { animation-delay: .1s; }
.ts-make { width: 100%; }
.ts-make svg { width: 22px; height: 22px; }
.ts-sizes { border-radius: 22px; }

/* pick a student */
.ts-wheel-stage { position: relative; display: flex; justify-content: center; align-items: center; min-height: 320px; }
.ts-winner { position: absolute; left: 0; right: 0; bottom: 3%; z-index: 3; width: max-content; max-width: 94%; margin-inline: auto; padding: 12px 30px 18px; border-radius: 28px; background: var(--surface); box-shadow: var(--shadow-pop); border-top: 8px solid var(--seg); text-align: center; pointer-events: none; }
.ts-winner.is-in { animation: winnerIn .7s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes winnerIn { from { opacity: 0; transform: translateY(30px) scale(.6) rotate(-3deg); } to { opacity: 1; transform: none; } }
.ts-winner-kick { display: block; font-size: 14px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; color: var(--link); }
.ts-winner-name { display: block; margin-top: 2px; font-size: clamp(40px, 6.4vw, 92px); font-weight: 900; line-height: 1.02; letter-spacing: -.015em; overflow-wrap: anywhere; }
.ts-done { position: absolute; inset: 0; display: grid; place-items: center; z-index: 4; }
.ts-need { position: absolute; margin: 0; padding: 12px 18px; border-radius: var(--r-sm); background: var(--surface); box-shadow: var(--shadow); font-weight: 900; color: var(--muted); }
.ts-look { display: flex; flex-direction: column; gap: 8px; }
.ts-look-row { display: flex; flex-wrap: wrap; gap: 6px; }
.ts-look-tile { display: grid; place-items: center; width: 50px; height: 50px; padding: 0; border: 2px solid transparent; border-radius: 14px; background: var(--surface-2); cursor: pointer; transition: transform .2s; }
.ts-look-tile:hover { transform: translateY(-2px); }
.ts-look-tile canvas { width: 40px; height: 40px; }
.ts-look-tile[aria-pressed="true"] { border-color: var(--fg); background: var(--surface-3); }
.ts-picked { display: flex; flex-direction: column; gap: 2px; max-height: 200px; overflow-y: auto; margin: 8px 0 4px; padding: 0; list-style: none; }
.ts-picked li { display: flex; align-items: center; gap: 10px; padding: 5px 6px; border-radius: 10px; font-weight: 800; font-size: 15px; }
.ts-picked li:first-child:not(.empty) { background: var(--hover); animation: rise .45s cubic-bezier(.2,.9,.3,1); }
.ts-picked .dot { flex: none; width: 14px; height: 14px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 2px rgba(20,41,38,.25); }
.ts-picked .empty { color: var(--muted); font-weight: 700; font-size: 14px; }

/* who is here today */
.ts-names-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.ts-name { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px 5px 9px; border-radius: var(--r-pill); border: 2px solid transparent; background: var(--surface-2); font-weight: 800; font-size: 14px; cursor: pointer; transition: background .15s, opacity .15s; }
.ts-name::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--teal); }
.ts-name:hover { background: var(--hover); }
.ts-name[aria-pressed="false"] { background: transparent; border: 2px dashed var(--border-strong); color: var(--muted); text-decoration: line-through; }
.ts-name[aria-pressed="false"]::before { background: var(--track); }

/* pairs and groups */
.ts-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 16px; }
.ts-groups.is-few { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.ts-group { border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.ts-group h3 { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0; padding: 10px 18px; background: var(--c); color: var(--ink); font-size: 19px; font-weight: 900; }
.ts-group h3 small { display: grid; place-items: center; min-width: 28px; height: 28px; padding: 0 8px; border-radius: var(--r-pill); background: rgba(255,255,255,.3); font-size: 14px; font-weight: 900; }
.ts-group ul { margin: 0; padding: 8px 18px 14px; list-style: none; }
.ts-group li { padding: 7px 0; border-bottom: 2px dashed var(--border); font-size: clamp(18px, 1.5vw, 22px); font-weight: 800; line-height: 1.25; overflow-wrap: anywhere; }
.ts-group li:last-child { border-bottom: 0; }
.ts-groups.is-few li { font-size: clamp(22px, 2vw, 30px); }
.ts-groups.is-many li { font-size: 17px; padding: 4px 0; }
.ts-groups.is-new .ts-group { animation: pop .55s var(--d) cubic-bezier(.2,1.3,.4,1) both; }
.ts-groups.is-new li { animation: rise .45s var(--d2) cubic-bezier(.2,.9,.3,1) both; }

/* random order */
.ts-order { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 10px 14px; margin: 0; padding: 0; list-style: none; counter-reset: none; }
.ts-order button { display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px 16px 10px 10px; border: 0; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); text-align: left; cursor: pointer; transition: opacity .2s, transform .2s; }
.ts-order button:hover { transform: translateY(-2px); }
.ts-order b { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--c); color: var(--ink); font-size: 21px; font-weight: 900; font-variant-numeric: tabular-nums; }
.ts-order span { min-width: 0; font-size: clamp(19px, 1.7vw, 25px); font-weight: 900; overflow-wrap: anywhere; }
.ts-order button[aria-pressed="true"] { opacity: .45; }
.ts-order button[aria-pressed="true"] span { text-decoration: line-through; text-decoration-thickness: 3px; }
.ts-order.is-many span { font-size: 18px; }
.ts-order.is-many b { width: 38px; height: 38px; font-size: 17px; }
.ts-order.is-new li { animation: dealIn .45s var(--d) cubic-bezier(.2,1.3,.4,1) both; }
@keyframes dealIn { from { opacity: 0; transform: translateX(-26px) scale(.9); } to { opacity: 1; transform: none; } }

/* nothing made yet */
.ts-empty { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: clamp(30px, 8vh, 90px) 20px; text-align: center; }
.ts-empty p { margin: 0; max-width: 34ch; color: var(--muted); font-size: 18px; font-weight: 800; }
.ts-empty-art { display: grid; grid-template-columns: repeat(2, 34px); gap: 10px; }
.ts-empty-art i { width: 34px; height: 34px; border-radius: 50%; background: var(--c1); animation: hop 1.8s ease-in-out infinite; }
.ts-empty-art i:nth-child(2) { background: var(--c3); animation-delay: .15s; }
.ts-empty-art i:nth-child(3) { background: var(--c5); animation-delay: .3s; }
.ts-empty-art i:nth-child(4) { background: var(--c2); animation-delay: .45s; }
.ts-empty-order { grid-template-columns: 34px; gap: 6px; }
.ts-empty-order i { width: 120px; height: 18px; border-radius: var(--r-pill); }
@keyframes hop { 50% { transform: translateY(-8px); } }

/* ---------- add or edit a class ---------- */
.ts-edit-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 14px; padding-block: 16px 20px; }
.ts-edit-head h1 { font-size: clamp(38px, 5vw, 60px); }
.ts-edit-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.ts-edit-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: clamp(18px, 3vw, 36px); align-items: start; }
.ts-edit-grid .ts-names { min-height: 380px; }
.ts-edit-side { display: flex; flex-direction: column; gap: 16px; align-items: flex-start; }
.ts-edit-side .panel { width: 100%; }
.ts-apart-add { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ts-apart-add > span { font-weight: 900; color: var(--muted); }
.ts-apart-add .dd { flex: 1 1 140px; min-width: 0; }
.ts-apart-add .dd-btn { width: 100%; justify-content: space-between; }
.ts-apart { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }
.ts-apart li { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 6px 10px; border-radius: 12px; background: var(--surface-2); font-weight: 800; }
.ts-apart li i { font-style: normal; color: var(--muted); }
.ts-apart li .linkbtn { margin-left: auto; font-size: 14px; }
.ts-apart .empty { background: none; color: var(--muted); font-weight: 700; padding-left: 0; }
.btn-danger.is-sure { background: var(--danger); border-color: var(--danger); color: var(--paper); }

.foot-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.foot-tools a { color: var(--link); font-weight: 800; }
:root:fullscreen .foot { display: none; }

@media (max-width: 1050px) {
  .ts-modes { margin-inline: 0; }
}
@media (max-width: 900px) {
  .ts-start { grid-template-columns: minmax(0, 1fr); min-height: 0; text-align: center; }
  .ts-start-copy { align-items: center; }
  .ts-points { align-items: flex-start; text-align: left; }
  .ts-body { grid-template-columns: minmax(0, 1fr); }
  .ts-rail { display: contents; }   /* controls above groups and order, below the wheel */
  .ts-ctrl { order: -1; }
  body[data-mode="pick"] .ts-ctrl { order: 1; }
  .ts-att { order: 2; }
  .ts-edit-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .ts-modes { width: 100%; }
  .ts-modes button { flex: 1 1 auto; justify-content: center; padding: 9px 10px; font-size: 14px; }
  .ts-modes svg { display: none; }
  .ts-winner { padding: 8px 18px 12px; }
  .ts-edit-grid .ts-names { min-height: 260px; }
}
