/**
 * Nebo CTF Design System
 * Cross-cutting UI primitives (Dreams POS migration).
 * Design tokens live in tokens.css — do not redefine colors here.
 */

/* ─── Base ──────────────────────────────────────────────────── */

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

html {
  scroll-behavior: smooth;
  scrollbar-gutter: stable both-edges;
  overflow-x: hidden;
}

/* ─── Layout width ──────────────────────────────────────────── */

.constrain-width {
  width: 100%;
  max-width: var(--nebo-page-max-width-wide);
  margin-left: auto;
  margin-right: auto;
  padding-left: clamp(1rem, 4vw, 2.5rem);
  padding-right: clamp(1rem, 4vw, 2.5rem);
}

.constrain-width--narrow {
  max-width: 900px;
}

/* ─── Chips / filters ───────────────────────────────────────── */

.nebo-chip,
.filter-btn,
.filter-tab,
.leaderboard-tab {
  padding: 0.5rem 1rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid #334155;
  border-radius: var(--nebo-radius-sm);
  color: var(--nebo-text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.nebo-chip:hover,
.filter-btn:hover,
.filter-tab:hover,
.leaderboard-tab:hover {
  border-color: var(--nebo-brand);
  color: var(--nebo-brand);
  background: var(--nebo-brand-muted);
}

.nebo-chip.active,
.filter-btn.active,
.filter-tab.active,
.leaderboard-tab.active {
  background: var(--nebo-brand-hover);
  border-color: var(--nebo-brand);
  color: var(--nebo-text);
}

/* ─── Stat values (leaderboard) — typography: nebo-typography.css tabular-nums ─ */

.stat-card-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--nebo-text);
  margin-bottom: 0.25rem;
  font-variant-numeric: tabular-nums;
}

/* ─── Toasts (Dreams POS / Bootstrap) ───────────────────────── */

.nebo-toast-container {
  top: var(--nebo-toast-top);
  z-index: 1090;
  max-width: min(100%, 26rem);
}

body.nebo-app .nebo-toast-container {
  top: var(--nebo-toast-top);
}

@media (max-width: 768px) {
  .nebo-toast-container {
    top: max(var(--nebo-toast-top), 0.75rem) !important;
    left: 0.75rem;
    right: 0.75rem;
    max-width: none;
  }

  .nebo-toast-container .toast {
    width: 100%;
  }
}

/* ─── Modals ────────────────────────────────────────────────── */

.app-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.app-modal-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.app-modal {
  width: min(100%, 420px);
  background: var(--nebo-bg-card);
  border: 1px solid var(--nebo-brand-border);
  border-radius: var(--nebo-radius-lg);
  box-shadow: var(--nebo-shadow-lg);
  overflow: hidden;
}

.app-modal-header,
.app-modal-footer {
  padding: 1rem 1.25rem;
}

.app-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--nebo-border);
}

.app-modal-title {
  color: var(--nebo-text);
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}

.app-modal-close {
  background: transparent;
  border: none;
  color: var(--nebo-text-muted);
  font-size: 1.1rem;
  border-radius: var(--nebo-radius-sm);
  padding: 0.35rem;
  cursor: pointer;
}

.app-modal-close:hover {
  color: var(--nebo-text);
  background: rgba(255, 255, 255, 0.08);
}

.app-modal-body {
  padding: 1.25rem;
  color: var(--nebo-text-secondary);
  line-height: 1.7;
}

.app-modal-input {
  width: 100%;
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: var(--nebo-radius-sm);
  border: 1px solid #334155;
  background: #1e293b;
  color: var(--nebo-text);
}

.app-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  border-top: 1px solid var(--nebo-border);
}

.app-modal-btn {
  border: none;
  border-radius: var(--nebo-radius-sm);
  padding: 0.7rem 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--nebo-font-sans);
}

.app-modal-btn.secondary {
  background: rgba(51, 65, 85, 0.95);
  color: #e2e8f0;
}

.app-modal-btn.primary {
  background: var(--nebo-brand-hover);
  color: var(--nebo-text);
}

.app-modal-btn.danger {
  background: #dc2626;
  color: var(--nebo-text);
}

/* ─── App page layout ───────────────────────────────────────── */

.nebo-app-page {
  width: 100%;
  max-width: var(--nebo-page-max-width);
  margin: 0 auto;
}

.nebo-app-page--wide {
  max-width: var(--nebo-page-max-width-wide);
}

.nebo-app-page--narrow {
  max-width: 40rem;
}

/* ─── Page headers ──────────────────────────────────────────── */

.nebo-page-header__row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.nebo-page-header__main {
  flex: 1;
  min-width: min(100%, 16rem);
}

.nebo-page-header__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.teams-page-title,
.leaderboard-page-title {
  font-size: clamp(1.75rem, 3vw, 2rem);
  font-weight: 700;
  color: var(--nebo-text);
  margin: 0 0 0.5rem;
  line-height: 1.2;
}

.teams-page-subtitle,
.leaderboard-page-subtitle {
  color: var(--nebo-text-muted);
  font-size: 1rem;
  line-height: 1.6;
  margin: 0;
  max-width: 56rem;
}

/* ─── Breadcrumbs & tables ──────────────────────────────────── */

.nebo-breadcrumb,
.team-breadcrumb,
.challenge-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  color: var(--nebo-text-muted);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.nebo-breadcrumb a,
.team-breadcrumb a,
.challenge-breadcrumb a {
  color: var(--nebo-brand);
  text-decoration: none;
}

.nebo-breadcrumb a:hover,
.team-breadcrumb a:hover,
.challenge-breadcrumb a:hover {
  color: var(--nebo-brand-light);
}

/* ─── Responsive tables ─────────────────────────────────────── */

.nebo-table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ─── Learning subnav ───────────────────────────────────────── */

.nebo-learning-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.nebo-learning-subnav__link {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--nebo-text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.nebo-learning-subnav__link:hover {
  color: var(--nebo-text);
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.08);
  text-decoration: none;
}

.nebo-learning-subnav__link.active {
  color: var(--nebo-brand-light);
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.14);
}

/* ─── Focus states ──────────────────────────────────────────── */

.filter-btn:focus-visible,
.app-modal-close:focus-visible,
.app-modal-btn:focus-visible {
  outline: 2px solid var(--nebo-brand);
  outline-offset: 2px;
}
