/* ─────────────────────────────────────────────────────────────────────────
   Football Intelligence — Team detail page styles
   Faza 5.1, redesign v2.

   Layout: hero + tabs nav + tab panels (Overview default).
   Reuse z match-detail.css gdzie zasadne (.md-form-cards form cards style),
   prefix `td-` dla team-specific komponentów.
   ───────────────────────────────────────────────────────────────────────── */


.team-detail {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  margin: calc(-1 * var(--space-4)) calc(-1 * var(--space-3)) 0;
}
@media (max-width: 767px) {
  .team-detail {
    margin: calc(-1 * var(--space-3)) calc(-1 * var(--space-2)) 0;
  }
}


/* === Hero ================================================================= */

.td-hero {
  position: relative;
  background-color: var(--surface-2);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  padding: var(--space-4) var(--space-3);
  min-height: 320px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--divider);
}
@media (max-width: 767px) {
  .td-hero {
    min-height: 220px;
    padding: var(--space-3) var(--space-2) 24px;
    margin-bottom: 16px;
  }
}

.td-hero--has-bg {
  background-image:
    linear-gradient(to top, rgba(6, 10, 15, 0.96) 0%, rgba(6, 10, 15, 0.65) 60%, rgba(6, 10, 15, 0.4) 100%),
    var(--td-hero-bg-mobile);
}
@media (min-width: 768px) {
  .td-hero--has-bg {
    background-image:
      linear-gradient(to top, rgba(6, 10, 15, 0.96) 0%, rgba(6, 10, 15, 0.6) 55%, rgba(6, 10, 15, 0.35) 100%),
      var(--td-hero-bg-desktop);
  }
}

.td-hero__inner {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: center;
}

.td-hero__league-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.95rem;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: var(--weight-bold);
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--border);
  border-radius: 9999px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  text-decoration: none;
  transition: background-color var(--duration-fast), color var(--duration-fast), transform var(--duration-fast);
}
.td-hero__league-chip:hover {
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.7);
  transform: translateY(-1px);
}
@media (max-width: 767px) {
  .td-hero__league-chip {
    font-size: 0.7rem;
    padding: 0.3rem 0.7rem;
    max-width: 70vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.td-hero__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.td-hero__name {
  margin: 0;
  font-size: 2rem;
  letter-spacing: -0.01em;
  color: var(--white);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7);
}
@media (max-width: 767px) {
  .td-hero__name { font-size: 1.5rem; }
}

.td-hero__meta {
  color: var(--text-secondary);
}
.td-hero__venue {
  color: var(--text-tertiary);
}
/* F5.3: clickable stadium subtitle → #venue/<id> */
.td-hero__venue--linkable {
  text-decoration: none;
  color: var(--text-secondary);
  transition: color var(--duration-fast);
}
.td-hero__venue--linkable:hover {
  color: var(--accent);
  text-decoration: underline;
}

.td-team-badge {
  width: 96px;
  height: 96px;
  object-fit: contain;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.6));
}
.td-team-badge--placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-3);
  color: var(--text-primary);
  font-weight: var(--weight-extrabold);
  letter-spacing: 0.02em;
}
@media (max-width: 767px) {
  .td-team-badge { width: 72px; height: 72px; }
}


/* === Tabs nav ============================================================ */

.td-tabs {
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  align-self: flex-start;
  margin: 0 var(--space-3);
  scrollbar-width: none;
}
@media (max-width: 767px) {
  .td-tabs { margin: 0 var(--space-2); }
}
.td-tabs::-webkit-scrollbar { display: none; }

.td-tabs__btn {
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-md) - 4px);
  color: var(--text-tertiary);
  font-family: inherit;
  font-size: var(--text-body);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--duration-fast), color var(--duration-fast);
}
.td-tabs__btn:hover:not(.td-tabs__btn--active) { color: var(--text-primary); }
.td-tabs__btn--active {
  background: var(--surface-3);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}


/* === Tab panel host ====================================================== */

.td-tabpanel-host {
  padding: 0 var(--space-3) var(--space-4);
}
@media (max-width: 767px) {
  .td-tabpanel-host { padding: 0 var(--space-2) var(--space-3); }
}

.td-tabpanel {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.td-overview {
  display: grid;
  gap: var(--space-2);
}


/* === Section card wrapper ================================================ */

.td-section {
  /* card variant — uses .card from components.css */
}

.td-section__title {
  margin: 0 0 var(--space-2);
  letter-spacing: -0.01em;
}

.td-section__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

.td-section__header .td-section__title {
  margin: 0;
}

.td-section__link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}
.td-section__link:hover { text-decoration: underline; }


/* === Mini match grid (Latest result + Next match side-by-side) ========== */

.td-mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}
@media (max-width: 767px) {
  .td-mini-grid { grid-template-columns: 1fr; }
}

.td-mini-match {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.td-mini-match--empty {
  align-items: flex-start;
}

.td-mini-match__label {
  font-weight: var(--weight-semibold);
  letter-spacing: 0.06em;
}

.td-mini-match__row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.td-mini-match__team {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.td-mini-match__team--away {
  flex-direction: row-reverse;
}
.td-mini-match__name {
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.9rem;
}

.td-mini-match__badge {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}
.td-mini-match__badge--placeholder {
  display: inline-block;
  background: var(--surface-3);
  border-radius: 50%;
}

.td-mini-match__center {
  display: flex;
  align-items: center;
  justify-content: center;
}
.td-mini-match__score {
  font-size: 1.3rem;
  font-weight: var(--weight-extrabold);
  letter-spacing: 0;
}
.td-mini-match__sep {
  color: var(--text-tertiary);
  margin: 0 4px;
  font-weight: var(--weight-semibold);
}
.td-mini-match__time {
  font-size: 1.1rem;
  font-weight: var(--weight-bold);
  color: var(--accent);
}

.td-mini-match__meta {
  text-align: center;
}


/* === Standings table ===================================================== */

.td-standings {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.td-standings thead th {
  color: var(--text-tertiary);
  font-weight: var(--weight-semibold);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: right;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
}
.td-standings thead th.td-standings__pos,
.td-standings thead th.td-standings__team {
  text-align: left;
}
.td-standings tbody td {
  padding: 8px 4px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.td-standings tbody td.td-standings__pos,
.td-standings tbody td.td-standings__team {
  text-align: left;
}
.td-standings__team {
  display: flex;
  align-items: center;
  gap: 8px;
}
.td-standings__badge {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
}
.td-standings__pos {
  color: var(--text-secondary);
  font-weight: var(--weight-semibold);
  width: 32px;
}
.td-standings__pts {
  color: var(--text-primary);
  font-weight: var(--weight-extrabold);
}
.td-standings__row--target {
  background: rgba(29, 187, 121, 0.08);
}
.td-standings__row--target td {
  border-bottom-color: rgba(29, 187, 121, 0.3);
}
.td-standings__row--target .td-standings__pos {
  color: var(--system-green);
  font-weight: var(--weight-extrabold);
  position: relative;
}
.td-standings__row--target .td-standings__pos::before {
  content: '';
  position: absolute;
  left: -4px;
  top: 25%;
  bottom: 25%;
  width: 3px;
  background: var(--system-green);
  border-radius: 2px;
}

/* P5.1.1 Bug 2: mobile standings overflow fix.
   Desktop pokazuje 10 kolumn (Pos/Team/P/W/D/L/GF/GA/GD/Pts) → 360px+ na 375px viewport.
   Mobile <768px hide GF/GA/GD, zostaje 7 columns (Pos/Team/P/W/D/L/Pts) — mieści się
   z paddingiem. Plus tighter padding 8→6px + smaller team badge (20→16px) + ellipsis
   na team name dla długich nazw (Wolverhampton Wanderers, Borussia Mönchengladbach). */
@media (max-width: 767px) {
  .td-standings thead th:nth-child(7),  /* GF */
  .td-standings tbody td:nth-child(7),
  .td-standings thead th:nth-child(8),  /* GA */
  .td-standings tbody td:nth-child(8),
  .td-standings thead th:nth-child(9),  /* GD */
  .td-standings tbody td:nth-child(9) {
    display: none;
  }
  .td-standings thead th,
  .td-standings tbody td {
    padding: 6px 4px;
    font-size: 0.8rem;
  }
  .td-standings__badge {
    width: 16px;
    height: 16px;
  }
  .td-standings__team {
    gap: 6px;
    max-width: 130px;
  }
  .td-standings__team span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }
  .td-standings__pos {
    width: 24px;
  }
}


/* === Squad preview grid ================================================== */

.td-squad-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.td-squad-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: center;
  min-width: 0;
  overflow: hidden;
  transition: transform var(--duration-fast), box-shadow var(--duration-fast), border-color var(--duration-fast);
}
.td-squad-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(255, 255, 255, 0.18);
}
.td-squad-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.td-squad-card__avatar {
  width: 80px;
  height: 80px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}
.td-squad-card__avatar--render {
  object-position: center top;
}
.td-squad-card__avatar--silhouette {
  filter: none;
}

.td-squad-card__info {
  width: 100%;
  min-width: 0;
}
.td-squad-card__name {
  font-size: 0.85rem;
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  max-width: 100%;
}
.td-squad-card__pos {
  font-size: 0.65rem;
  margin-top: 2px;
}

@media (max-width: 767px) {
  .td-squad-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .td-squad-card {
    padding: 8px 4px;
  }
  .td-squad-card__avatar {
    width: 56px;
    height: 56px;
  }
  .td-squad-card__name {
    font-size: 0.7rem;
  }
}


/* === Skeleton state ====================================================== */

.td-hero--skeleton .td-hero__inner > * { opacity: 0.5; }


/* === Error state ========================================================= */

.td-error {
  text-align: center;
  padding: var(--space-4);
  margin: var(--space-3);
}
.td-error p:first-child { margin-bottom: 0.5rem; }
