/* ==========================================================================
   AXL — app pages (profile, search).
   Layered on top of style.css: reuses tokens, glass, nav, buttons, toast.
   ========================================================================== */

body.app-page {
  /* app pages fade in almost immediately */
  --intro: 0.1s;
}

.app-main {
  padding: 6.25rem 1.5rem 2.2rem;
  min-height: calc(100vh - 240px);
}

.app-main > section {
  padding: 0 0 1.8rem;
}

/* На телефоне плавающий верхний хедер скрыт (навигация — в нижнем таббаре),
   так что верхний отступ карточки под него больше не нужен. */
@media (max-width: 760px) {
  .app-main {
    padding-top: 1.75rem;
  }
}

/* ---------- Logged-out gate ---------- */

.app-gate {
  display: flex;
  justify-content: center;
  padding: 2.4rem 0;
}

/* Гейт и Steam-блоки показываются после ответа сервера — тоже мягко. */
.app-gate:not([hidden]),
#steamLinked:not([hidden]),
#steamUnlinked:not([hidden]) {
  animation: authFade 0.45s var(--ease) both;
}

.gate-card {
  max-width: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.8rem;
  padding: 2.4rem 1.8rem 2.2rem;
}

.gate-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  color: var(--violet);
  background: rgba(91, 140, 255, 0.1);
  border: 1px solid rgba(91, 140, 255, 0.25);
  margin-bottom: 0.2rem;
}

.gate-icon svg {
  width: 23px;
  height: 23px;
}

.gate-card h2 {
  font-size: 1.35rem;
}

.gate-card p {
  margin: 0 0 0.8rem;
  color: var(--text-dim);
  font-size: 0.93rem;
}

/* ---------- Role accents (standalone tags outside .role cards) ---------- */

[data-role="combat"] {
  --accent: 255, 92, 87;
}

[data-role="support"] {
  --accent: 255, 180, 84;
}

[data-role="lead"] {
  --accent: 77, 214, 255;
}

[data-role="recruiter"] {
  --accent: 244, 114, 182;
}

/* ---------- Profile ---------- */

/* Хиро-карточка: обложка-градиент в акцент роли (через [data-role] на
   #profileHero), аватар с подсветкой поверх неё и полоса ключевых цифр. */

.profile-hero {
  overflow: hidden;
  margin-bottom: 1.1rem;
}

.profile-cover {
  position: relative;
  height: 104px;
  overflow: hidden;
  background:
    radial-gradient(120% 160% at 15% 0%, rgba(var(--accent, 91, 140, 255), 0.32), transparent 55%),
    radial-gradient(110% 150% at 85% 20%, rgba(255, 180, 84, 0.14), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  border-bottom: 1px solid var(--border);
}

/* диагональная фактура, проявляющаяся к правому краю — чтобы широкая
   обложка на ПК не выглядела пустой */
.profile-cover::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 20px);
  -webkit-mask: linear-gradient(90deg, transparent 25%, #000 85%);
  mask: linear-gradient(90deg, transparent 25%, #000 85%);
  pointer-events: none;
}

/* водяной знак клана в правой части обложки */
.profile-cover::after {
  content: "AXL";
  position: absolute;
  right: 1.4rem;
  top: 50%;
  transform: translateY(-46%);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 3.6rem;
  letter-spacing: 0.14em;
  line-height: 1;
  color: rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

.profile-head {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  padding: 0 1.8rem;
  margin-top: -44px;
  position: relative;
}

.profile-avatar-wrap {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 3px solid rgba(var(--accent, 91, 140, 255), 0.55);
  background: var(--bg);
  box-shadow: 0 0 32px rgba(var(--accent, 91, 140, 255), 0.28);
}

.profile-avatar-wrap .avatar {
  width: 100%;
  height: 100%;
  font-size: 2.2rem;
}

.profile-id {
  padding-bottom: 0.2rem;
  min-width: 0;
}

.profile-id h3 {
  font-size: 1.45rem;
  margin: 0;
  overflow-wrap: anywhere;
}

.profile-tag {
  margin: 0.1rem 0 0;
  color: var(--text-faint);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

/* Роль — отдельная таблетка поверх обложки, в правом верхнем углу. */
.profile-role-wrap {
  --accent: 255, 255, 255;
  position: absolute;
  top: 1.1rem;
  right: 1.2rem;
  z-index: 2;
  margin: 0;
  padding: 0;
}

.profile-role-wrap .role-tag {
  font-size: 0.74rem;
  padding: 0.5rem 1.1rem;
  background: rgba(var(--accent), 0.13);
  border-color: rgba(var(--accent), 0.34);
  box-shadow: 0 0 22px rgba(var(--accent), 0.22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 1px;
  margin: 1.3rem 0 0;
  background: var(--border);
  border-top: 1px solid var(--border);
}

.profile-stats > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 1rem 0.9rem;
  text-align: center;
  background: rgba(13, 10, 11, 0.55);
}

.profile-stats dt {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.profile-stats dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

/* главная цифра шапки — акцент в цвет роли, как «часы в Rust» у Steam */
#statDays {
  font-size: 1.2rem;
  background: linear-gradient(90deg, rgb(var(--accent, 255, 92, 87)), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.1rem;
}

.info-card {
  padding: 1.5rem;
}

/* Клан-карточка короче Steam-карточки — не тянем её на всю высоту строки,
   пусть высота идёт по содержимому. Лёгкий акцент в фирменных цветах —
   чтобы карточка не выглядела пустой рядом со Steam-баннером. */
#clanCard {
  align-self: start;
  background:
    radial-gradient(65% 60% at 100% 0%, rgba(255, 92, 87, 0.1), transparent 70%),
    radial-gradient(55% 50% at 0% 100%, rgba(255, 180, 84, 0.06), transparent 70%),
    var(--glass);
}

.info-card h4 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.3rem;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.info-card h4 svg {
  width: 14px;
  height: 14px;
  color: var(--text-faint);
}

.info-note {
  margin: 0 0 0.9rem;
  font-size: 0.8rem;
  color: var(--text-faint);
}

.info-note a {
  color: var(--violet);
}

.info-rows {
  margin: 0;
  display: flex;
  flex-direction: column;
}

.info-rows > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--border);
}

.info-rows dt {
  color: var(--text-dim);
  font-size: 0.87rem;
}

.info-rows dd {
  margin: 0;
  font-weight: 700;
  font-size: 0.87rem;
  text-align: right;
  overflow-wrap: anywhere;
}

/* ---------- Steam card ----------
   Фон — размытая аватарка Steam как «баннер» (--steam-bg ставит скрипт),
   поверх — затемнение в фирменный сине-графитовый Steam. Карточка тянется
   на всю высоту колонки, кнопки прижаты к низу — пустоты не остаётся. */

.steam-card {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.steam-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--steam-bg, linear-gradient(135deg, #1b2838, #2a475e)) center / cover no-repeat;
  filter: blur(30px) saturate(1.25);
  transform: scale(1.4);
  opacity: 0.4;
  pointer-events: none;
}

.steam-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(27, 40, 56, 0.25), rgba(10, 7, 9, 0.78) 75%);
  pointer-events: none;
}

.steam-card > * {
  position: relative;
  z-index: 1;
}

#steamLinked:not([hidden]) {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.steam-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0 1rem;
}

.steam-row .avatar {
  width: 72px;
  height: 72px;
  font-size: 1.7rem;
  border: 2px solid rgba(102, 192, 244, 0.45);
  box-shadow: 0 0 24px rgba(102, 192, 244, 0.2);
}

.steam-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.steam-name {
  font-weight: 800;
  font-size: 1.1rem;
  overflow-wrap: anywhere;
}

.steam-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

.steam-stats {
  display: grid;
  /* всегда 2×2 — при auto-fit четвёртый стат мог уезжать один на вторую
     строку, оставляя пустоту справа */
  grid-template-columns: repeat(2, 1fr);
  gap: 0.9rem;
  margin: 0 0 1.2rem;
  padding: 0.95rem 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.steam-stats > div {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.steam-stats dt {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.steam-stats dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
}

/* часы в Rust — главная цифра карточки */
#steamHours {
  background: linear-gradient(90deg, #66c0f4, var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* прогресс часов против нормы клана */
.steam-progress {
  margin: 0 0 1.2rem;
}

.sp-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.sp-head span:first-child {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

#spLabel {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.sp-bar {
  height: 8px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}

.sp-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #66c0f4, var(--violet));
  transition: width 0.9s var(--ease) 0.3s;
}

.steam-progress.is-done .sp-bar i {
  background: linear-gradient(90deg, #4ade80, #66c0f4);
}

.steam-progress.is-done #spLabel {
  color: var(--ok);
}

.steam-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: auto;
}

/* На ПК карточка выше — масштабируем содержимое, чтобы не было пустот. */
@media (min-width: 950px) {
  .steam-row {
    gap: 1.2rem;
    padding: 0.7rem 0 1.3rem;
  }
  .steam-row .avatar {
    width: 88px;
    height: 88px;
    font-size: 2rem;
  }
  .steam-name {
    font-size: 1.3rem;
  }
  .steam-meta {
    font-size: 0.85rem;
  }
  .steam-stats {
    gap: 1.15rem;
    padding-top: 1.15rem;
    margin-bottom: 1.5rem;
  }
  .steam-stats dt {
    font-size: 0.72rem;
  }
  .steam-stats dd {
    font-size: 1.95rem;
  }
  .steam-progress {
    margin-bottom: 1.5rem;
  }
  .sp-head span:first-child {
    font-size: 0.72rem;
  }
  #spLabel {
    font-size: 0.9rem;
  }
  .sp-bar {
    height: 10px;
  }
}

/* непривязанный Steam: заметка растягивается, кнопка у нижнего края */
#steamUnlinked:not([hidden]) {
  display: flex;
  flex-direction: column;
  flex: 1;
}

#steamUnlinked .info-note {
  flex: 1;
}

#steamUnlinked .cta {
  align-self: flex-start;
}

.btn-small {
  padding: 0.55rem 1.2rem;
  font-size: 0.83rem;
}

.btn-small svg {
  width: 15px;
  height: 15px;
}

/* ---------- Quick links (клан) ---------- */

.quick-links {
  display: flex;
  flex-direction: column;
}

.quick-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0;
  border-top: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.87rem;
  transition: color 0.2s ease;
}

.quick-link svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: var(--text-faint);
  transition: color 0.2s ease, transform 0.25s var(--ease);
}

.quick-link:hover {
  color: var(--violet);
}

.quick-link:hover svg {
  color: var(--violet);
  transform: translateX(3px);
}

.logout-row {
  display: flex;
  justify-content: center;
  margin-top: 1.4rem;
}

.cta-danger {
  border-color: rgba(255, 107, 107, 0.25);
  background: rgba(255, 80, 80, 0.07);
  color: #ff9d9d;
}

.cta-danger:hover {
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(255, 80, 80, 0.13);
}

.cta-danger .cta-spinner {
  border-color: rgba(255, 157, 157, 0.3);
  border-top-color: #ff9d9d;
}

@media (max-width: 560px) {
  .profile-head {
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-top: -48px;
  }
  .profile-id {
    padding-bottom: 0;
  }
  .profile-cover::after {
    font-size: 2.4rem;
  }
}

/* ---------- Search ---------- */

.search-bar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  max-width: 520px;
  margin: 0 auto 1rem;
  padding: 0.3rem 0.7rem 0.3rem 1.2rem;
  border-radius: var(--r-full);
}

.search-bar svg {
  width: 18px;
  height: 18px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  padding: 0.6rem 0;
}

.search-bar input::placeholder {
  color: var(--text-faint);
}

.chip-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.8rem;
}

.chip {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.42rem 1.05rem;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease;
  appearance: none;
  -webkit-appearance: none;
}

.chip:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.chip.is-active {
  background: #fff;
  border-color: #fff;
  color: #0a0a10;
}

.members-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.member-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.3rem 1.1rem 1.2rem;
  color: inherit;
  text-decoration: none;
  /* карточки приезжают с сервера — появляются каскадом, а не разом */
  animation: cardIn 0.5s var(--ease) both;
  animation-delay: calc(var(--ci, 0) * 0.045s);
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.member-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
}

.member-card .avatar {
  width: 56px;
  height: 56px;
  font-size: 1.35rem;
  margin-bottom: 0.7rem;
}

.member-name {
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.member-tag {
  color: var(--text-faint);
  font-size: 0.8rem;
  margin: 0.1rem 0 0.55rem;
}

.member-card .role-tag {
  margin-bottom: 0.6rem;
}

.member-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.you-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--violet);
  background: rgba(91, 140, 255, 0.16);
  border: 1px solid rgba(91, 140, 255, 0.3);
  padding: 0.14rem 0.5rem;
  border-radius: var(--r-full);
}

.empty-note {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.85rem;
  margin: 1.6rem 0 0;
}

#loadingNote {
  animation: loadPulse 1.4s ease-in-out infinite;
}

@keyframes loadPulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

/* ---------- Tournaments ---------- */

.tourn-create {
  max-width: 640px;
  margin: 0 auto 1.6rem;
  padding: 1.4rem 1.4rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.tourn-create h4 {
  margin: 0;
  font-size: 1rem;
}

.tc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  width: 100%;
}

.tc-grid input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.25s ease, background 0.25s ease;
}

.tc-grid input::placeholder {
  color: var(--text-faint);
}

.tc-grid input:focus {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.06);
}

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

.tourn-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1rem;
  max-width: 900px;
  margin: 0 auto;
}

.tourn-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.85rem;
  padding: 1.4rem 1.3rem;
  animation: cardIn 0.5s var(--ease) both;
  animation-delay: calc(var(--ci, 0) * 0.05s);
}

.tourn-head {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tourn-head h3 {
  font-size: 1.1rem;
  margin: 0;
  overflow-wrap: anywhere;
}

.tourn-owner-actions {
  position: absolute;
  right: -0.2rem;
  top: -0.3rem;
  display: flex;
  gap: 0.35rem;
}

.tourn-icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  font: inherit;
  font-size: 0.72rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.tourn-icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.tourn-icon-finish {
  border-color: rgba(74, 222, 128, 0.28);
  background: rgba(74, 222, 128, 0.08);
}

.tourn-icon-finish:hover {
  background: rgba(74, 222, 128, 0.16);
  border-color: rgba(74, 222, 128, 0.45);
}

.tourn-icon-del {
  border-color: rgba(255, 107, 107, 0.25);
  background: rgba(255, 80, 80, 0.08);
  color: #ff9d9d;
}

.tourn-icon-del:hover {
  background: rgba(255, 80, 80, 0.16);
  border-color: rgba(255, 107, 107, 0.45);
}

.tourn-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
}

.t-chip {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 0.3rem 0.8rem;
  white-space: nowrap;
}

.t-chip-accent {
  color: var(--gold);
  background: rgba(255, 180, 84, 0.08);
  border-color: rgba(255, 180, 84, 0.28);
}

.tourn-players {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 10px;
  min-height: 38px;
}

.tourn-players .avatar {
  width: 34px;
  height: 34px;
  font-size: 0.9rem;
  margin-left: -10px;
  border: 2px solid var(--bg);
  animation: cardIn 0.4s var(--ease) both;
  animation-delay: calc(var(--ai, 0) * 0.04s);
}

.tourn-none {
  font-size: 0.8rem;
  color: var(--text-faint);
  margin-left: -10px;
}

.tourn-card .cta,
.tourn-card .cta-ghost {
  margin-top: auto;
}

.tourn-card.is-done {
  opacity: 0.8;
}

/* ---------- Владелец: подсказка о ненастроенной роли ---------- */

.owner-hint {
  max-width: 640px;
  margin: 0 auto 1.4rem;
  padding: 0.8rem 1.1rem;
  border-radius: var(--r-md);
  background: rgba(255, 180, 84, 0.08);
  border: 1px solid rgba(255, 180, 84, 0.28);
  color: var(--gold);
  font-size: 0.83rem;
  text-align: center;
}

/* ---------- Архив турниров ---------- */

.tourn-archive {
  margin-top: 2.2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.tourn-archive-head {
  text-align: center;
  margin-bottom: 1.2rem;
}

.tourn-archive-head h3 {
  font-size: 1.25rem;
  margin: 0.35rem 0 0;
  color: var(--text-dim);
}
