/* ============================================================
   Ligas DrawPhase · estilos base (site público + Backstage)
   Minimalista: fundo claro quente, tipografia grande e apertada,
   cartões arredondados, cor de cada liga só como acento.
   ============================================================ */

:root {
  /* Cores da marca DrawPhase */
  --brand-dark: #1f063e;
  --brand: #915ff2;
  --brand-mid: #5a2aa8;
  --brand-gradient: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand-mid) 58%, var(--brand) 100%);
  --brand-soft: #f1ebfe;

  --bg: #f6f5f9;
  --surface: #ffffff;
  --surface-2: #faf9fc;
  --text: #140a24;
  --muted: #645f70;
  --faint: #9a95a6;
  --line: #e8e4ef;
  --line-strong: #d4cee0;
  --danger: #c2412d;
  --ok: #2f8a4c;

  --accent: #0f0f10;

  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(15, 15, 16, 0.04), 0 12px 32px -18px rgba(15, 15, 16, 0.18);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Inter Tight", "Inter", system-ui, sans-serif;
  --wrap: 1080px;
  --gutter: 20px;
}

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

/* Tons derivados da cor da liga. Recalculados onde --accent muda (body e cartões). */
:root,
body,
.league-card {
  --accent-soft: color-mix(in srgb, var(--accent) 13%, var(--surface));
  --accent-line: color-mix(in srgb, var(--accent) 45%, var(--surface));
  --accent-ink: color-mix(in srgb, var(--accent) 55%, #000);
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

::selection {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.num {
  font-variant-numeric: tabular-nums;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.display {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.02;
}

.section-title {
  margin: 0 0 18px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* ---------- Logótipo ---------- */

.logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.logo-img {
  display: block;
  width: 100%;
  height: auto;
}

/* ---------- Logótipos dos jogos ---------- */

.league-title {
  display: flex;
  align-items: center;
  gap: 0.35em;
  flex-wrap: wrap;
}

.league-title-logo {
  width: 4em;
  height: auto;
  max-width: 100%;
  flex-shrink: 0;
}

.league-card-logo {
  display: block;
  width: 170px;
  height: auto;
  max-width: 100%;
}

/* ---------- Cor de cada liga ---------- */

.league-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--pill, var(--text));
}

/* ---------- Botões ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: 1px solid var(--brand-dark);
  border-radius: 999px;
  background: var(--brand-dark);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}

.btn:hover {
  background: var(--brand-mid);
  border-color: var(--brand-mid);
}

.btn:disabled {
  opacity: 0.45;
  cursor: progress;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line-strong);
}

.btn-ghost:hover {
  background: var(--surface);
  border-color: var(--brand);
  color: var(--brand-dark);
}

.btn-small {
  padding: 7px 14px;
  font-size: 14px;
}

.btn-block {
  width: 100%;
}

/* ---------- Estado da liga ---------- */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-em_curso {
  color: var(--ok);
  background: #eef7f0;
  border-color: #d3eadb;
}

.status-inscricoes_abertas {
  color: #2d63c2;
  background: #eef3fc;
  border-color: #d5e1f6;
}

/* ---------- Cartões e estados ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.state-card {
  max-width: 520px;
  margin: 48px auto;
  padding: 36px 28px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.state-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.state-text {
  margin: 0 0 22px;
  color: var(--muted);
}

.state-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.skeleton {
  background: linear-gradient(90deg, var(--line) 0%, var(--surface-2) 50%, var(--line) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius);
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

/* ---------- Página inicial ---------- */

.league-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.league-card {
  --accent: var(--text);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 260px;
  padding: 28px;
  overflow: hidden;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, border-color 0.2s, box-shadow 0.2s;
}

.league-card::before {
  content: "";
  position: absolute;
  inset: auto -20% -55% auto;
  width: 70%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 34%, transparent), transparent);
  pointer-events: none;
  transition: transform 0.4s ease;
}

.league-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-line);
  box-shadow: 0 1px 2px rgba(15, 15, 16, 0.04), 0 22px 44px -22px rgba(15, 15, 16, 0.28);
}

.league-card:hover::before {
  transform: scale(1.12);
}

.league-card-top {
  display: flex;
  align-items: center;
  min-height: 88px; /* altura fixa para o resto do cartão ficar alinhado, seja qual for o logo */
  justify-content: space-between;
  gap: 12px;
}

.league-swatch {
  width: 14px;
  height: 14px;
  border-radius: 5px;
  background: var(--accent);
}

.league-card-name {
  margin: 0;
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: clamp(28px, 3.4vw, 38px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.league-card-season {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.league-card-foot {
  position: relative;
  margin-top: auto;
  padding-top: 28px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.league-leader-label {
  margin: 0 0 2px;
  font-size: 12.5px;
  color: var(--muted);
}

.league-leader-name {
  margin: 0;
  font-weight: 600;
  font-size: 17px;
}

.league-leader-points {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.league-card-arrow {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.league-card:hover .league-card-arrow {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
}

.league-card.skeleton {
  border: 0;
  box-shadow: none;
  min-height: 260px;
}

/* ---------- Página de liga ---------- */

.league-head {
  padding: 32px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.league-head::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent);
}

.league-head-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 14px;
}

/* Troca de temporada (só com mais do que uma) */

.season-switcher {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.season-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}

.season-pill:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.season-pill.is-active {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
}

.season-pill-tag {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-mid);
  font-size: 11px;
  font-weight: 600;
}

.season-pill.is-active .season-pill-tag {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.league-head .display {
  font-size: clamp(36px, 6vw, 60px);
}

.league-head-dates {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.season-track {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px 28px;
  align-items: center;
  margin-top: 28px;
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.8s ease;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.countdown {
  display: flex;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.countdown-unit {
  min-width: 52px;
  padding: 8px 6px;
  text-align: center;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.countdown-value {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.countdown-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.countdown-done {
  font-weight: 600;
}

.league-section {
  margin-top: 20px;
  padding: 28px;
}

/* Pirâmide compacta */

.pyramid {
  display: grid;
  grid-template-columns: 1fr 1.3fr 2fr;
  gap: 12px;
}

.tier {
  padding: 18px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.tier-1 {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.tier-rank {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

.tier-title {
  margin: 2px 0 12px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.tier-names {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tier-names li {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 14px;
  font-weight: 500;
}

.tier-names li.is-empty {
  color: var(--faint);
  border-style: dashed;
  background: transparent;
  font-weight: 400;
}

.notice {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--warn, #b7791f) 9%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn, #b7791f) 35%, var(--surface));
  font-size: 14.5px;
}

.notice strong {
  display: block;
  margin-bottom: 2px;
}

.ranking-head + .notice {
  margin: 0 0 14px;
}

/* Títulos em jogo (separador Grande Final) */

.stake {
  margin-top: 22px;
  padding: 16px 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand-soft), var(--surface-2));
  border: 1px solid var(--line);
}

.stake-label {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.stake-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stake-list li {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-weight: 600;
  font-size: 14.5px;
}

.stake-list li span {
  font-weight: 400;
  font-size: 12.5px;
  color: var(--muted);
}

/* Galeria de jogadores */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gallery-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 12px 12px 14px;
  border-radius: 18px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.gallery-card.is-top8 {
  border-color: var(--accent-line);
}

.gallery-photo {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  margin-bottom: 12px;
  overflow: hidden;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 600;
}

.gallery-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-rank {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(10, 8, 16, 0.72);
  color: #fff;
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 600;
}

.gallery-card.is-top8 .gallery-rank {
  background: var(--accent);
  color: var(--on-accent, #fff);
}

.gallery-name {
  margin: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-points {
  margin: 2px 0 0;
  font-size: 14.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Classificação */

.ranking-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.ranking-head .section-title {
  margin: 0;
}

.search-input {
  width: min(280px, 100%);
  padding: 9px 14px 9px 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2366666c' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E")
    no-repeat 13px center;
  font-size: 14.5px;
}

.search-input:focus {
  outline: none;
  border-color: var(--line-strong);
  background-color: var(--surface);
}

.table-scroll {
  overflow-x: auto;
  margin: 0 -8px;
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.ranking-table th {
  padding: 8px;
  text-align: left;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.ranking-table td {
  padding: 11px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.ranking-table tr:last-child td {
  border-bottom: 0;
}

.ranking-table .col-pos {
  width: 56px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.ranking-table .col-points {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.ranking-table th.col-points {
  text-align: right;
}

.ranking-table .col-title {
  width: 1%;
  white-space: nowrap;
  padding-left: 20px;
}

.ranking-table tr.zone-top8 .col-pos {
  color: var(--text);
  font-weight: 600;
}

.ranking-table tr.zone-top8 td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

.ranking-table tr.zone-out td {
  color: var(--muted);
}

.player-cell {
  font-weight: 500;
}

.title-inline {
  display: none;
}

.zone-out .player-cell {
  font-weight: 400;
}

.title-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.title-tag.tag-1 {
  background: var(--accent);
  color: var(--on-accent, #111);
}

.title-tag.tag-contested {
  background: color-mix(in srgb, var(--warn, #b7791f) 16%, var(--surface));
  color: var(--warn, #b7791f);
}

.cut-row td {
  padding: 0 !important;
  border-bottom: 0 !important;
}

.cut-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-ink);
}

.cut-line::before,
.cut-line::after {
  content: "";
  flex: 1;
  border-top: 1.5px dashed var(--accent-line);
}

.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 28px 8px;
}

/* Como funciona */

.tab-text {
  margin: 0 0 12px;
  max-width: 640px;
  font-size: 16.5px;
}

.points-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.points-item {
  padding: 18px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.points-item-label {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
}

.points-item-value {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* ---------- Rodapé ---------- */

.site-footer {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 40px 36px;
  font-size: 13.5px;
  color: var(--faint);
}

.site-footer p {
  margin: 0;
}

/* ---------- Telemóvel ---------- */

@media (max-width: 820px) {
  .pyramid {
    grid-template-columns: 1fr 1fr;
  }

  .pyramid .tier-3 {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  :root {
    --gutter: 16px;
  }

  .league-grid {
    grid-template-columns: 1fr;
  }

  .league-card {
    min-height: 220px;
    padding: 22px;
  }

  .league-card-logo {
    width: 140px;
  }

  .league-head,
  .league-section {
    padding: 22px 18px;
  }

  .season-track {
    grid-template-columns: 1fr;
  }

  .countdown-unit {
    flex: 1;
    min-width: 0;
  }

  .pyramid {
    grid-template-columns: 1fr;
  }

  .points-grid {
    grid-template-columns: 1fr;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  /* No telemóvel o título passa para baixo do nome, para a tabela caber no ecrã. */
  .ranking-table .col-title {
    display: none;
  }

  .title-inline:not(:empty) {
    display: block;
    margin-top: 4px;
  }
}

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