/* TU Live Score — priority-players board (sidebar + mobile).
 *
 * Broadcast-grade dark scoreboard, deliberately consistent with the per-match
 * widget (widget.css): same DM Sans, same charcoal/clay tokens. Built to live in
 * a 283px desktop sidebar AND full-width on mobile — the layout is fluid and
 * degrades by truncating names, never by overflowing.
 *
 * Structure:
 *   .tu-board
 *     .tu-board__tabs        segmented pills: Svi / Uživo (n) / Završeni / Najavljeni
 *     .tu-board__body
 *       .tu-board__group     one tournament: header + matches
 *         .tu-board__match   time/status rail + two player rows
 *       .tu-board__empty     "Nema mečeva"
 */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700;9..40,800;9..40,900&display=swap');

.tu-board, .tu-board *, .tu-board *::before, .tu-board *::after { box-sizing: border-box; }

.tu-board {
  --tu-board-bg:    #14110d;
  --tu-board-bg-2:  #1c1812;
  --tu-board-bg-3:  #221d16;   /* row hover / raised surface */
  --tu-board-fg:    #f5ecd8;
  --tu-board-muted: #a89e89;
  --tu-board-dim:   #6f6757;   /* lowest-emphasis (loser sets, day labels) */
  --tu-board-line:  rgba(245, 236, 216, 0.09);
  --tu-board-line-2:rgba(245, 236, 216, 0.05);

  --tu-clay:        #c8472b;
  --tu-clay-soft:   rgba(200, 71, 43, 0.14);
  --tu-live:        #ef4444;

  --tu-font: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;

  font-family: var(--tu-font);
  font-feature-settings: 'ss01', 'cv11';
  color: var(--tu-board-fg);
  background: var(--tu-board-bg);
  border: 1px solid var(--tu-board-line);
  border-radius: 12px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  box-shadow: 0 18px 44px -30px rgba(0, 0, 0, 0.7);
}

/* ── Tabs ─────────────────────────────────────────────────────────────── */

.tu-board__tabs {
  display: flex;
  flex-wrap: nowrap;            /* explicit: all four tabs stay on one row */
  gap: 4px;
  padding: 9px 7px;
  background: linear-gradient(180deg, var(--tu-board-bg-2) 0%, var(--tu-board-bg) 100%);
  border-bottom: 1px solid var(--tu-board-line);
  overflow-x: auto;            /* safety net only; sized to fit at 283px */
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.tu-board__tabs::-webkit-scrollbar { display: none; }

.tu-board__tab {
  flex: 0 0 auto;
  appearance: none;
  border: 1px solid transparent;
  background: rgba(245, 236, 216, 0.06);
  color: var(--tu-board-muted);
  font-family: var(--tu-font);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.005em;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;          /* never wrap a tab label to two lines */
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
/* Defeat the theme's global `button span { display:block }` (style.css ~4217),
   which otherwise drops the "(n)" count onto its own line inside the live tab. */
.tu-board__tab span { display: inline-block; }
.tu-board__tab-count { white-space: nowrap; }
.tu-board__tab:hover { color: var(--tu-board-fg); background: rgba(245, 236, 216, 0.1); }

.tu-board__tab.is-active {
  background: var(--tu-board-fg);
  color: #14110d;
  font-weight: 700;
}

/* Live tab carries a count badge; turns clay-hot when matches are live. */
.tu-board__tab--live .tu-board__tab-count { font-variant-numeric: tabular-nums; }

/* Pulsing dot on the Uživo tab while matches are live (reuses tu-board-pulse). */
.tu-board__tab-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--tu-live);
  margin-right: 5px;
  vertical-align: 1px;
  animation: tu-board-pulse 1.6s ease-in-out infinite;
}
.tu-board__tab.is-active .tu-board__tab-dot { background: #fff; }
.tu-board__tab--live.has-live {
  color: #f3c4bb;
  background: var(--tu-clay-soft);
  border-color: rgba(239, 68, 68, 0.34);
}
.tu-board__tab--live.has-live.is-active {
  background: var(--tu-clay);
  color: #fff;
  border-color: transparent;
}

/* ── Body / groups ────────────────────────────────────────────────────── */

.tu-board__body { background: var(--tu-board-bg); }

.tu-board__group + .tu-board__group { border-top: 6px solid var(--tu-board-bg-2); }

.tu-board__group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 8px;
  background: var(--tu-board-bg-2);
}
.tu-board__group-logo {
  width: 18px; height: 18px;
  object-fit: contain;
  flex: 0 0 auto;
  opacity: 0.92;
}
.tu-board__group-meta { min-width: 0; line-height: 1.2; }
.tu-board__group-name {
  display: block;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--tu-board-fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tu-board__group-sub {
  display: block;
  font-weight: 600;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tu-board-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Match ────────────────────────────────────────────────────────────── */

.tu-board__match {
  display: flex;
  align-items: stretch;
  gap: 9px;
  padding: 9px 10px 9px 0;
  text-decoration: none;
  color: inherit;
  position: relative;
  border-top: 1px solid var(--tu-board-line-2);
}
.tu-board__group-head + .tu-board__match { border-top: 0; }

/* Clickable rows (have an article) get an affordance; non-clickable stay flat. */
a.tu-board__match { cursor: pointer; }
a.tu-board__match::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--tu-clay);
  transform: scaleY(0);
  transform-origin: center;
  transition: transform .16s ease;
}
a.tu-board__match:hover { background: var(--tu-board-bg-3); }
a.tu-board__match:hover::before { transform: scaleY(1); }

/* Time / status rail */
.tu-board__time {
  flex: 0 0 auto;
  width: 44px;
  padding-left: 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 2px;
  border-right: 1px solid var(--tu-board-line-2);
}
.tu-board__time-main {
  font-weight: 700;
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  color: var(--tu-board-muted);
  line-height: 1;
  letter-spacing: 0.01em;
}
.tu-board__time-sub {
  font-weight: 600;
  font-size: 0.56rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tu-board-dim);
  line-height: 1;
}
/* Finished marker */
.tu-board__match--finished .tu-board__time-main { color: var(--tu-board-dim); }
/* Live marker: clay time + pulsing dot */
.tu-board__match--live .tu-board__time-main { color: var(--tu-live); }
.tu-board__live-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--tu-live);
  margin-right: 1px;
  vertical-align: 1px;
  animation: tu-board-pulse 1.6s ease-in-out infinite;
}
@keyframes tu-board-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

/* Players block */
.tu-board__players {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.tu-board__row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.tu-board__flag {
  flex: 0 0 auto;
  width: 17px; height: 17px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--tu-board-bg-3);
  box-shadow: 0 0 0 1px var(--tu-board-line);
}
.tu-board__flag--empty { /* keeps alignment when no flag (neutral player) */
  background: var(--tu-board-bg-3);
}
.tu-board__name {
  /* content-width (not grow) so the serve dot sits right after the name; the
     scores get pushed to the right edge via .tu-board__sets margin-left:auto */
  flex: 0 1 auto;
  min-width: 0;
  font-weight: 600;
  font-size: 0.86rem;
  line-height: 1.15;
  color: var(--tu-board-fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Serve indicator (live) — small clay dot immediately after the server's name */
.tu-board__serve {
  flex: 0 0 auto;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--tu-clay);
  margin-left: 6px;
}

/* Set score cells, pushed to the right edge */
.tu-board__sets {
  flex: 0 0 auto;
  display: flex;
  gap: 2px;
  margin-left: auto;
  padding-left: 6px;
}
.tu-board__set {
  min-width: 12px;
  text-align: center;
  font-weight: 600;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: var(--tu-board-dim);
  line-height: 1.15;
}
.tu-board__set--won { color: var(--tu-board-fg); font-weight: 800; }
.tu-board__set-tb {
  font-size: 0.6em;
  font-weight: 700;
  vertical-align: super;
  margin-left: 0.5px;
  opacity: 0.8;
}

/* Winner / loser emphasis (finished matches) */
.tu-board__row--winner .tu-board__name { color: var(--tu-board-fg); font-weight: 800; }
.tu-board__row--loser  .tu-board__name { color: var(--tu-board-muted); font-weight: 600; }
.tu-board__row--loser  .tu-board__flag { opacity: 0.6; }
.tu-board__row--winner .tu-board__set--won { color: var(--tu-board-fg); }

/* ── "Prikaži sve" expander (sidebar cap) ─────────────────────────────────
 * Same interaction as the per-match widget's "Učitaj još": caps the list and
 * reveals the rest on click. Sits at the bottom of the board, inside it. */
.tu-board__more {
  display: block;
  width: 100%;
  margin: 0;
  padding: 11px 14px;
  border: 0;
  border-top: 1px solid var(--tu-board-line);
  background: var(--tu-board-bg-2);
  color: #f3c4bb;
  font-family: var(--tu-font);
  font-weight: 700;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-align: center;
  cursor: pointer;
  transition: background .15s ease;
}
.tu-board__more:hover, .tu-board__more:focus { background: var(--tu-board-bg-3); }

/* ── Empty state ──────────────────────────────────────────────────────── */

.tu-board__empty {
  padding: 34px 18px;
  text-align: center;
  color: var(--tu-board-dim);
  font-weight: 600;
  font-size: 0.86rem;
  letter-spacing: 0.02em;
}
.tu-board__empty::before {
  content: '';
  display: block;
  width: 26px; height: 26px;
  margin: 0 auto 10px;
  border-radius: 50%;
  border: 2px solid var(--tu-board-line);
  background:
    radial-gradient(circle at 50% 50%, transparent 6px, var(--tu-board-line) 6px 7px, transparent 7px);
  opacity: 0.7;
}

/* ── Loading skeleton ─────────────────────────────────────────────────── */

.tu-board__loading {
  padding: 30px 18px;
  text-align: center;
  color: var(--tu-board-dim);
  font-size: 0.82rem;
  font-style: italic;
}
.tu-board__loading::before {
  content: '●';
  margin-right: 7px;
  color: var(--tu-clay);
  animation: tu-board-pulse 1.4s ease-in-out infinite;
}

/* ── Mobile / wider container: a touch more air ───────────────────────── */
@media (min-width: 480px) {
  .tu-board__name { font-size: 0.92rem; }
  .tu-board__set  { font-size: 0.88rem; min-width: 15px; }
  .tu-board__time { width: 50px; }
  .tu-board__match { padding-top: 11px; padding-bottom: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .tu-board *, .tu-board *::before, .tu-board *::after { animation: none !important; transition: none !important; }
}

/* ── Mount visibility (theme placement) ───────────────────────────────────
 * Aligns with the theme's 768px breakpoint. The desktop mount lives at the top
 * of the sidebar; the mobile mount lives under the homepage carousel. Each is
 * shown in exactly one context so only one ever renders/polls per viewport. */
.tu-board--desktop-only { display: block; margin-bottom: 18px; }
.tu-board--mobile-only  { display: none; }
@media (max-width: 768px) {
  .tu-board--desktop-only { display: none; }
  .tu-board--mobile-only  {
    display: block;
    /* 10px L/R inset + 4px radius like the post cards. Vertical margins are
       asymmetric to produce EQUAL ~13px VISIBLE gaps on a REAL phone (headless
       browsers render this carousel differently, so this was calibrated on-device):
       the carousel above (.wpcp-carousel-wrapper) eats ~7px via a negative
       margin-bottom (top 20 -> ~13 visible) and #posts below adds ~6px (bottom 7 ->
       ~13 visible). margin-top:0 sits flush against the carousel (verified on phone). */
    margin: 20px 10px 7px;
    border-radius: 4px;
  }
}
