/* === Section Header === */
.section-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.section-header__subtitle {
  color: var(--color-secondary);
  font-family: var(--font-headline);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.section-header__title {
  font-family: var(--font-headline);
  font-size: clamp(2rem, 8vw, var(--text-4xl));
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--color-primary-emphasis);
  overflow-wrap: break-word;
  word-break: break-word;
}

/* === Main Content === */
.main {
  max-width: var(--max-width-container, 1280px);
  margin: 0 auto;
  padding: var(--space-xl);
  padding-top: calc(var(--layout-header-height) + var(--space-md));
  padding-bottom: calc(var(--layout-nav-height) + var(--space-xl));
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.level-selector-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

/* === Map Section === */
.map {
  position: relative;
  width: 100%;
  aspect-ratio: 21/9;
  min-height: 16rem;
  background-color: var(--color-surface-container);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-outline-variant);
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.1));
  overflow-x: hidden;
  overflow-y: hidden;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.map__scroll {
  cursor: grab;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--color-secondary) 35%, transparent) transparent;
  overflow-x: auto;
  overflow-y: hidden;
  display: flex;
  align-items: center;
  flex: 1;
  touch-action: pan-y;
  padding: 0 var(--space-md);
}

.map__scroll::-webkit-scrollbar {
  height: 0.5rem;
}

.map__scroll::-webkit-scrollbar-track {
  background: transparent;
}

.map__scroll::-webkit-scrollbar-thumb {
  background-color: color-mix(in srgb, var(--color-secondary) 35%, transparent);
  border-radius: 9999px;
}

.map--dragging .map__scroll {
  cursor: grabbing;
}

.map__track {
  position: relative;
  width: max-content;
  height: 20rem;
  flex: 0 0 auto;
}

.map__svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.map__line {
  stroke: var(--color-outline-variant);
  stroke-dasharray: 8, 8;
  stroke-width: 3;
}

.map__nodes {
  position: relative;
  width: 100%;
  height: 100%;
}

/* === Phase Node (BEM) === */
.node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  transform: translate(-50%, -50%);
}

.node__circle {
  width: clamp(3.5rem, 12vw, 5rem);
  height: clamp(3.5rem, 12vw, 5rem);
  border-radius: var(--radius-full, 9999px);
  border: 1px solid var(--color-surface-container);
  box-shadow: var(--shadow-lg, 0 10px 15px rgba(0, 0, 0, 0.2));
  display: flex;
  align-items: center;
  justify-content: center;
}

.node__label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Light mode: node labels use dark navy */
[data-theme="light"] .node__label {
  color: var(--color-dark);
}

[data-theme="light"] .node--completed .node__label {
  color: var(--color-dark);
}

[data-theme="light"] .node--active .node__label {
  color: var(--color-dark);
}

[data-theme="light"] .node--locked .node__label {
  color: var(--color-dark);
}

[data-theme="light"] .node--unlocked .node__label {
  color: var(--color-dark);
}

[data-theme="light"] .node--unlocked .text-on-secondary {
  color: var(--color-on-primary-container);
}

.node__badge {
  margin-top: calc(var(--space-2xs) * -0.25);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full, 9999px);
  background-color: var(--color-surface-container-highest);
  color: var(--color-secondary);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Node Variants */
.node--completed .node__circle {
  background-color: var(--color-secondary);
}

.node:not(.node--locked) .node__circle {
  cursor: pointer;
  transition: transform 200ms ease;
}

.node:not(.node--locked) .node__circle:hover {
  transform: scale(1.1);
}

.node--completed .node__label {
  color: var(--color-secondary);
}

.node--active .node__circle {
  background-color: var(--color-secondary);
  animation: pulse-ring 2s infinite;
  z-index: 10;
}

.node--active .node__label {
  color: var(--color-secondary);
}

.node--unlocked .node__circle {
  background-color: var(--color-primary-container);
  border: 2px solid var(--color-outline);
}

.node--unlocked .node__label {
  color: var(--color-text-muted);
}

.node--locked .node__circle {
  background-color: var(--color-surface-container-highest);
}

.node--locked .node__label {
  color: var(--color-outline);
}

/* === Toggle (segmented control) === */
.map__toggle {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-lg);
  background-color: var(--color-surface-container);
  border-bottom: 1px solid var(--color-outline-variant);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 20;
}

.map__toggle-btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full, 9999px);
  border: 1px solid var(--color-outline);
  background-color: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-headline);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease;
}

.map__toggle-btn:hover {
  background-color: var(--color-surface-container-highest);
}

.map__toggle-btn--active {
  background-color: var(--color-secondary);
  color: var(--color-on-secondary);
  border-color: var(--color-secondary);
}

.map__toggle-btn--active:hover {
  background-color: var(--color-secondary);
}

/* === Empty State (no custom levels) === */
.map__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 12rem;
  gap: var(--space-md);
  color: var(--color-text-muted);
  text-align: center;
  padding: var(--space-xl);
}

.level-selector-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.map__empty-text {
  font-family: var(--font-headline);
  font-size: var(--text-lg);
  font-weight: 700;
}

.map__empty-action {
  color: var(--color-secondary);
  text-decoration: underline;
  cursor: pointer;
}

/* === Ranking Section === */
.ranking {
  background-color: var(--color-surface-container);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-outline-variant);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.1));
}

.ranking__header {
  padding: var(--space-lg) var(--space-xl);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--color-outline-variant);
}

.ranking__title-container {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.ranking__icon {
  color: var(--color-primary);
}

[data-theme="light"] .ranking__icon {
  color: var(--color-dark);
}

.ranking__title {
  font-family: var(--font-headline);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-primary);
}

[data-theme="light"] .ranking__title {
  color: var(--color-dark);
}

/* === Table === */
.table-container {
  overflow-x: auto;
}

.table {
  width: 100%;
  text-align: left;
  border-collapse: collapse;
}

.table__header {
  color: var(--color-text-muted);
  font-weight: 700;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--color-outline-variant);
}

.table__header-cell {
  padding: var(--space-lg);
  text-align: center;
}

.table__body {
  font-size: var(--text-md);
  line-height: 1.5;
}

.table__row {
  border-bottom: 1px solid var(--color-outline-variant);
  transition: background-color 200ms ease;
}

.table__row:hover {
  background-color: var(--color-surface-container-highest);
}

.table__cell {
  padding: var(--space-md);
  text-align: center;
}

.table__cell--bold {
  font-weight: 700;
  color: var(--color-secondary);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-xs);
}

/* === Table User Info === */
.table__user {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-md);
}

.table__user-name {
  font-weight: 700;
  color: var(--color-text);
}

/* === Position Badge === */
.position-badge {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-md);
}

.position-badge__circle {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius-full, 9999px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.position-badge__circle--first {
  border: 1px solid var(--color-secondary);
  color: var(--color-secondary);
}

.position-badge__circle--other {
  border: 1px solid var(--color-text-muted);
  color: var(--color-text-muted);
}

/* === Utility Classes === */
.text-on-surface-variant { color: var(--color-text-muted); }
.text-outline { color: var(--color-outline); }
.text-on-secondary { color: var(--color-on-secondary); }
.text-on-primary-container { color: var(--color-on-primary-container); }

.bg-background { background-color: var(--color-bg); }
.min-h-screen { min-height: 100vh; }
.antialiased {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.font-label-caps {
  font-family: var(--font-headline);
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1.0;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.font-h1 {
  font-family: var(--font-headline);
  font-size: var(--text-3xl);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.font-h3 {
  font-family: var(--font-headline);
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 1.2;
}

.font-bold {
  font-weight: 700;
}

/* === Animations === */
@keyframes pulse-ring {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(71, 242, 225, 0.4);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 15px rgba(71, 242, 225, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(71, 242, 225, 0);
  }
}

/* === Material Icons Size Helpers === */
.icon-sm { font-size: 1.25rem; }
.icon-md { font-size: 1.5rem; }
.icon-lg { font-size: 2rem; }
.icon-xl { font-size: 3rem; }

/* === Empty State === */
.table__cell--empty {
  text-align: center;
  padding: var(--space-xl);
  color: var(--color-text-muted);
  font-style: italic;
}

/* === Responsive: tablet+ overrides === */
@media (min-width: 768px) {
  .map {
    min-height: 20rem;
  }

  .table__cell {
    padding: var(--space-lg);
  }
}

/* === Mobile: ranking card layout === */
@media (max-width: 47.9375rem) {
  .table__header {
    display: none;
  }

  .table,
  .table__body {
    display: block;
  }

  .table__row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "pos  user  score"
      "date date  date";
    align-items: center;
    gap: var(--space-2xs) var(--space-md);
    padding: var(--space-md);
    margin-bottom: var(--space-sm);
    border: 1px solid var(--color-outline-variant);
    border-radius: var(--radius-default);
    background-color: var(--color-bg);
  }

  .table__cell {
    padding: 0;
    border: none;
    text-align: left;
  }

  .table__cell::before {
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  [data-label="Posição"] {
    grid-area: pos;
  }

  [data-label="Usuário"] {
    grid-area: user;
  }

  [data-label="Pontuação"] {
    grid-area: score;
  }

  [data-label="Data"] {
    grid-area: date;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-2xs);
    font-size: var(--text-xs);
  }

  [data-label="Data"]::before {
    content: attr(data-label);
  }

  [data-label="Posição"]::before,
  [data-label="Usuário"]::before,
  [data-label="Pontuação"]::before {
    display: none;
  }

  .table__user {
    justify-content: flex-start;
  }

  .position-badge {
    justify-content: flex-start;
  }
}
