/* ==========================================================================
   league-header.css — zwijane sekcje lig (desktop)
   Wymaga: variables.css
   ========================================================================== */

.category-leagues {
  position: relative;
  z-index: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
}

.category-leagues__empty {
  margin: 0;
  padding: var(--space-16);
  border: 1px solid var(--border);
  border-radius: var(--radius-12);
  background: var(--surface-1);
  color: var(--muted);
  font-size: var(--fs-14);
  text-align: center;
}

.league-header {
  border: 1px solid var(--border);
  border-radius: var(--radius-12);
  background: var(--surface-1);
  overflow: hidden;
}

.category-leagues__sentinel {
  height: 1px;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

html[data-theme="dark"] .league-header {
  background: #1f1f1f;
  border-color: rgba(255, 255, 255, 0.12);
}

.league-header__heading {
  margin: 0;
}

.league-header__head {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  width: 100%;
  min-height: 60px;
  max-height: 60px;
  padding: 10px 16px 10px 0px;
  isolation: isolate;
}

.league-header__actions {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.league-header__drag {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted-2);
  cursor: grab;
  opacity: 0.25;
  pointer-events: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

/* handle aktywny tylko dla ulubionych */
.league-header[data-fav="true"] .league-header__drag {
  opacity: 1;
  pointer-events: auto;
}

.league-header__drag:active {
  cursor: grabbing;
}

.league-header__drag:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.85);
  outline-offset: 2px;
}

.league-header__drag-dots {
  width: 10px;
  height: 28px;
  display: block;
  background-color: currentColor;
  /* 2 kolumny × 8 wierszy kropek */
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A//www.w3.org/2000/svg'%20width%3D'10'%20height%3D'28'%20viewBox%3D'0%200%2010%2028'%3E%3Cg%20fill%3D'%23000'%3E%3Ccircle%20cx%3D'3'%20cy%3D'2'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'7'%20cy%3D'2'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'3'%20cy%3D'6'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'7'%20cy%3D'6'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'3'%20cy%3D'10'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'7'%20cy%3D'10'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'3'%20cy%3D'14'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'7'%20cy%3D'14'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'3'%20cy%3D'18'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'7'%20cy%3D'18'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'3'%20cy%3D'22'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'7'%20cy%3D'22'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'3'%20cy%3D'26'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'7'%20cy%3D'26'%20r%3D'1.2'/%3E%3C/g%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A//www.w3.org/2000/svg'%20width%3D'10'%20height%3D'28'%20viewBox%3D'0%200%2010%2028'%3E%3Cg%20fill%3D'%23000'%3E%3Ccircle%20cx%3D'3'%20cy%3D'2'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'7'%20cy%3D'2'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'3'%20cy%3D'6'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'7'%20cy%3D'6'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'3'%20cy%3D'10'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'7'%20cy%3D'10'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'3'%20cy%3D'14'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'7'%20cy%3D'14'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'3'%20cy%3D'18'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'7'%20cy%3D'18'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'3'%20cy%3D'22'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'7'%20cy%3D'22'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'3'%20cy%3D'26'%20r%3D'1.2'/%3E%3Ccircle%20cx%3D'7'%20cy%3D'26'%20r%3D'1.2'/%3E%3C/g%3E%3C/svg%3E");
}

.league-header__fav {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.league-header__fav:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.85);
  outline-offset: 2px;
}

.league-header__fav[aria-pressed="true"] {
  color: #333333;
}

html[data-theme="dark"] .league-header__fav[aria-pressed="true"] {
  color: #ffffff;
}

.league-header__fav-icon {
  font-size: 16px;
  line-height: 1;
}

.league-header--dragging {
  opacity: 0.55;
  transform: scale(0.995);
}

.league-header--dragging .league-header__drag {
  cursor: grabbing;
}

.league-header--dragging .league-header__head {
  background: rgba(0, 0, 0, 0.04);
}

html[data-theme="dark"] .league-header--dragging .league-header__head {
  background: rgba(255, 255, 255, 0.06);
}

.league-header--floating {
  position: fixed;
  z-index: calc(var(--z-header) + 8);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.16);
  pointer-events: none;
  opacity: 1;
  transform: none;
}

html[data-theme="dark"] .league-header--floating {
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.4);
}

.league-header__placeholder {
  border: 2px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-12);
  background: rgba(0, 0, 0, 0.03);
}

html[data-theme="dark"] .league-header__placeholder {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
}

.league-header__toggle {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  width: 100%;
  min-height: 56px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--fg);
  font-family: var(--font-sans);
  text-align: left;
  cursor: pointer;
}

.league-header__brand {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: var(--space-12);
  min-width: 0;
}

.league-header__logo-wrap {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
}

.league-header__league-logo {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

html[data-theme="dark"] .league-header__league-logo--light {
  display: none;
}

html:not([data-theme="dark"]) .league-header__league-logo--dark {
  display: none;
}

.league-header__text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-4);
  min-width: 0;
}

.league-header__name {
  font-size: var(--fs-14);
  font-weight: var(--fw-600);
  line-height: var(--lh-tight);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.league-header__country-row {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  min-width: 0;
}

.league-header__country-flag {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  object-fit: cover;
  border-radius: 50%;
}

.league-header__country {
  font-size: var(--fs-12);
  font-weight: var(--fw-500);
  line-height: var(--lh-tight);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.league-header__status {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: var(--space-16);
}

.league-header__live {
  display: none;
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff0046;
  box-shadow: 0 0 0 0 rgba(255, 0, 68, 0.199);
  animation: league-header-live-pulse 1.8s ease-out infinite;
}

.league-header__live:not([hidden]) {
  display: inline-block;
}

@keyframes league-header-live-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 0, 68, 0.199);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(255, 0, 70, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 0, 70, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .league-header__live {
    animation: none;
  }
}

.league-header__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 22px;
  height: 22px;
  padding: 0 var(--space-6);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--fs-12);
  font-weight: var(--fw-600);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

html[data-theme="dark"] .league-header__count {
  background: #2a2a2a;
  color: rgba(240, 240, 240, 0.72);
}

.league-header__toggle-icon {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  position: relative;
  border-radius: 50%;
  background: var(--surface-2);
  flex-shrink: 0;
}

html[data-theme="dark"] .league-header__toggle-icon {
  background: #2a2a2a;
}

.league-header__chevron {
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: var(--fs-12);
  color: var(--muted-2);
  line-height: 1;
  transform: translate(-50%, -50%);
  transition: transform var(--dur-2) var(--ease-out), opacity var(--dur-2) var(--ease-out);
}

.league-header__spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid rgba(51, 51, 51, 0.18);
  border-top-color: #333333;
  border-radius: 50%;
  opacity: 0;
  visibility: hidden;
  animation: league-header-spin 0.75s linear infinite;
  transition: opacity var(--dur-2) var(--ease-out), visibility var(--dur-2) var(--ease-out);
}

html[data-theme="dark"] .league-header__spinner {
  border-color: rgba(255, 255, 255, 0.18);
  border-top-color: #ffffff;
}

@keyframes league-header-spin {
  to {
    transform: rotate(360deg);
  }
}

.league-header[data-loading="true"] .league-header__chevron {
  opacity: 0;
  visibility: hidden;
}

.league-header[data-loading="true"] .league-header__spinner {
  opacity: 1;
  visibility: visible;
}

.league-header__load-error {
  margin: 0;
  padding: var(--space-16);
  color: var(--muted);
  font-size: var(--fs-14);
  text-align: center;
}

.league-header[data-expanded="true"] .league-header__chevron {
  transform: translate(-50%, -50%) rotate(180deg);
}

.league-header__panel {
  border-top: 1px solid var(--border);
}

html[data-theme="dark"] .league-header__panel {
  border-top-color: rgba(255, 255, 255, 0.1);
}

.league-header__panel[hidden] {
  display: none;
}
