/* ============================================================================
   CS2STAT — shell.css
   Application shell: left sidebar (desktop), in-content topbar, main content
   area, and the mobile bottom navigation. Also the minimal auth-shell used for
   anonymous pages (login / register).

   Breakpoint: 768px (mobile < 768), matching base.html + replay_player.js.
   The 2D viewer (viewer_2d.html) does NOT use this shell.
   ========================================================================== */

/* ============================ APP SHELL ==================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---- Sidebar (desktop) ---------------------------------------------------- */
.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  background:
    linear-gradient(180deg, rgba(18, 28, 40, 0.96) 0%, rgba(10, 16, 24, 0.98) 100%);
  border-right: 1px solid var(--color-border-soft);
  backdrop-filter: blur(8px);
}

.app-sidebar__brand {
  display: flex;
  align-items: center;
  height: var(--topbar-height);
  padding: 0 14px;
  border-bottom: 1px solid var(--color-border-soft);
}
.app-sidebar__brand a {
  display: flex;
  align-items: center;
  min-width: 0;
}
.app-sidebar__brand img {
  display: block;
  width: auto;
  height: 30px;
  max-width: 100%;
}

.app-sidebar__profile {
  padding: 10px 8px 4px;
}

.app-sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 8px 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.app-sidebar__section-label {
  padding: 10px 10px 6px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.app-sidebar__section-label--tools { margin-top: 6px; }

.app-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: var(--text-base);
  font-weight: var(--font-weight-semibold);
  transition: background 0.16s ease, color 0.16s ease;
}
.app-nav-item:hover { background: var(--color-surface-hover); color: var(--color-text); }
.app-nav-item svg,
.app-nav-item > .icon-asset { width: 18px; height: 18px; flex: none; }
/* Active: quiet — thin left accent line + faint COOL fill (no orange/brown
   wash) + brighter text and an orange icon. */
.app-nav-item[aria-current="page"] {
  color: var(--color-text);
  background: var(--color-surface-hover);
}
.app-nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 2px;
  border-radius: var(--radius-pill);
  background: var(--color-primary);
}
.app-nav-item[aria-current="page"] svg,
.app-nav-item[aria-current="page"] > .icon-asset { color: var(--color-primary); }

/* Upload: a quiet outlined CTA (orange text + icon), not a big filled block. */
.app-nav-item--upload {
  margin-top: 8px;
  min-height: 34px;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(255, 85, 0, 0.30);
  color: var(--color-primary);
}
.app-nav-item--upload svg,
.app-nav-item--upload > .icon-asset { color: var(--color-primary); }
.app-nav-item--upload:hover { background: var(--color-surface-hover); color: #ffb383; }
.app-nav-item--upload[aria-current="page"] { background: transparent; }
.app-nav-item--upload[aria-current="page"]::before { content: none; }

.app-nav-item--disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---- Sidebar footer: user profile ---------------------------------------- */
.app-sidebar__footer {
  border-top: 1px solid var(--color-border-soft);
  padding: 8px;
}
.app-user {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 5px 6px;
  border-radius: var(--radius-sm);
}
.app-user__avatar {
  width: 30px; height: 30px;
  flex: none;
  border-radius: var(--radius-pill);
  object-fit: cover;
  background: var(--color-surface-raised);
  display: grid; place-items: center;
  color: var(--color-text-secondary);
  font-size: 12px; font-weight: var(--font-weight-bold);
}
.app-user__meta { min-width: 0; flex: 1; }
.app-user__name {
  display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--color-text);
  font-size: var(--text-base);
  font-weight: var(--font-weight-bold);
}
.app-user__status {
  display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--color-text-muted);
  font-size: 12px;
}
.app-user__logout {
  flex: none;
  color: var(--color-text-muted);
  cursor: pointer;
  background: none;
  border: none;
  padding: 6px;
  border-radius: var(--radius-sm);
}
.app-user__logout:hover { color: var(--color-danger); }
.app-user__logout svg,
.app-user__logout .icon-asset { width: 16px; height: 16px; display: block; }
.app-user--primary {
  border: 1px solid transparent;
  color: inherit;
}
.app-user--primary:hover {
  border-color: var(--color-border-soft);
  background: var(--color-surface-raised);
}
.app-steam-status {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 6px 9px;
}
.app-steam-status__dot {
  width: 8px;
  height: 8px;
  flex: none;
  margin-top: 3px;
  border-radius: 50%;
  background: var(--color-success);
  box-shadow: 0 0 0 3px rgba(83, 190, 96, .1);
}
.app-steam-status__icon {
  flex: none;
  margin-top: 1px;
  width: 14px;
  height: 14px;
  font-size: 14px;
  color: #9fcdf6;
}
.app-steam-status strong,
.app-steam-status small { display: block; }
.app-steam-status strong { color: var(--color-text-secondary); font-size: 11px; }
.app-steam-status small { margin-top: 2px; color: var(--color-text-muted); font-size: 10px; }
.app-sidebar__logout-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
  padding: 0 2px 0 7px;
  border-top: 1px solid var(--color-border-soft);
  color: var(--color-text-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
}

/* ---- Main column ---------------------------------------------------------- */
.app-main-col {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---- Topbar (in-content) -------------------------------------------------- */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-height);
  padding: 0 20px;
  background: color-mix(in srgb, var(--color-bg) 82%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border-soft);
}
.app-topbar__menu {
  display: none; /* mobile only */
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  color: var(--color-text);
  cursor: pointer;
}
.app-topbar__menu svg { width: 20px; height: 20px; }
.app-topbar__title {
  font-size: var(--text-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.app-topbar__spacer { flex: 1; }
.app-topbar__actions { display: flex; align-items: center; gap: 8px; }
.app-topbar__brand-mobile { display: none; }
.app-topbar__brand-mobile img { height: 24px; }

@media (min-width: 768px) {
  .app-topbar--empty { display: none; }
}

/* ---- Content area --------------------------------------------------------- */
.app-main {
  flex: 1;
  min-width: 0;
}
.app-content {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 16px 18px;
}

/* ============================ MOBILE BOTTOM NAV ============================ */
.app-mobile-nav { display: none; }

/* ============================ AUTH SHELL ================================== */
.auth-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}
.auth-shell__header {
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(var(--topbar-height) + 12px);
  border-bottom: 0;
  padding-top: 8px;
}
.auth-shell__header img { height: 30px; }
.auth-shell__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* ---- Site/legal footer --------------------------------------------------- */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 14px 20px 18px;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.03em;
}
.site-footer__links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 18px;
  min-height: 0;
  padding: 0 !important;
  background: transparent !important;
}
.site-footer a { color: var(--color-text-secondary); }
.site-footer a:hover { color: var(--color-primary); }

/* ---- Public legal documents --------------------------------------------- */
.legal-page {
  width: min(100%, 820px);
  margin: 8px auto 36px;
  padding: clamp(20px, 4vw, 40px);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  background: rgba(10, 16, 24, 0.86);
  box-shadow: var(--shadow-card);
}
.legal-page__header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--color-border-soft);
}
.legal-page h1 {
  margin: 4px 0 8px;
  font-family: var(--font-display);
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.legal-page h2 {
  margin: 26px 0 8px;
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0.02em;
}
.legal-page p,
.legal-page li {
  color: var(--color-text-secondary);
  line-height: 1.7;
}
.legal-page p { margin: 0 0 12px; }
.legal-page ul { margin: 8px 0 0; padding-left: 22px; }
.legal-page li + li { margin-top: 8px; }
.legal-page strong { color: var(--color-text); }
.legal-page a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ============================ RESPONSIVE ================================== */
@media (max-width: 767px) {
  .app-sidebar { display: none; }
  .app-main-col { margin-left: 0; }

  /* legacy.css has `main { padding:16px 16px 88px !important }` written for the
     old single <main>. Neutralise it for the shell mains (class > element, so
     these win) and let .app-content / the login card own mobile padding. */
  .app-main, .auth-shell__main { width: 100%; max-width: none; padding: 0 !important; overflow-x: hidden; }

  .app-topbar { padding: 0 14px; }
  .app-topbar__menu { display: inline-flex; }
  .app-topbar__title { display: none; }
  .app-topbar__brand-mobile { display: inline-flex; }

  /* content gets bottom padding so the fixed bottom nav never covers it.
     (The legacy mobile `main{padding-bottom:88px}` rule already helps; this
     keeps it correct if that rule is ever scoped away.) */
  .app-content { padding: 16px 16px calc(var(--bottomnav-height) + env(safe-area-inset-bottom, 0px) + 20px); }

  .app-main-col > .site-footer {
    padding-bottom: calc(var(--bottomnav-height) + env(safe-area-inset-bottom, 0px) + 14px);
  }
  .site-footer { padding-inline: 16px; text-align: center; }
  .site-footer__links { gap: 8px 14px; }
  .legal-page { margin: 0; border-radius: 0; border-inline: 0; }

  /* ---- Bottom navigation ---- */
  .app-mobile-nav {
    position: fixed;
    inset: auto 0 0 0;
    z-index: var(--z-drawer);
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    align-items: stretch;
    height: calc(var(--bottomnav-height) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--color-surface);
    border-top: 1px solid var(--color-border-soft);
  }
  .app-mobile-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 44px;
    color: var(--color-text-secondary);
    font-size: 10px;
    font-weight: 800;
  }
  .app-mobile-nav__item svg,
  .app-mobile-nav__item > .icon-asset { width: 20px; height: 20px; }
  .app-mobile-nav__item[aria-current="page"] { color: var(--color-primary); }
  .app-mobile-nav__item[aria-current="page"] svg { color: var(--color-primary); }

  /* central upload action: raised orange pill */
  .app-mobile-nav__item--upload { color: #fff; position: relative; }
  .app-mobile-nav__item--upload .app-mobile-nav__badge {
    display: grid;
    place-items: center;
    width: 44px; height: 44px;
    margin-top: -18px;
    border-radius: var(--radius-pill);
    background: var(--color-primary);
    border: 3px solid var(--color-bg);
    color: #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, .28);
  }
  .app-mobile-nav__item--upload .app-mobile-nav__badge svg,
  .app-mobile-nav__item--upload .app-mobile-nav__badge .icon-asset { width: 22px; height: 22px; }

  /* ---- Drawer (hamburger): profile + secondary actions ---- */
  .app-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--z-overlay);
    background: rgba(3, 6, 10, 0.6);
  }
  .app-drawer {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: var(--z-drawer);
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: min(82vw, 300px);
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px));
    background: var(--color-surface);
    border-right: 1px solid var(--color-border-soft);
    transition: transform 0.2s ease;
  }
  .app-drawer.app-drawer--closed { transform: translateX(-100%); }
  .app-drawer__head { display: flex; align-items: center; justify-content: space-between; }
  .app-drawer__user {
    display: flex; align-items: center; gap: 10px;
    padding: 10px; border-radius: var(--radius-md);
    background: var(--color-surface-raised);
  }
  .app-drawer__nav { display: flex; flex-direction: column; gap: 2px; }
  .app-drawer__logout { margin-top: auto; }
}

/* Desktop: the mobile drawer/backdrop are never shown. */
@media (min-width: 768px) {
  .app-drawer, .app-drawer-backdrop { display: none !important; }
}

/* On very wide screens keep the content from stretching into unreadable line
   lengths, but never squeeze the wide stat tables (they scroll inside their own
   containers). */
@media (min-width: 1921px) {
  .app-content { max-width: 1720px; }
}
/* Shared locale switcher: visible focus, non-colour active state and a
   comfortable touch target on compact layouts. */
.language-switcher {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted, #8290a6);
  font: 700 12px/1 var(--font-mono, monospace);
  letter-spacing: .08em;
}
.language-switcher a {
  display: inline-flex;
  min-width: 34px;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
}
.language-switcher a[aria-current="true"] {
  border-color: currentColor;
  color: var(--accent, #ff7043);
  background: rgba(255,112,67,.08);
  text-decoration: none;
}
.language-switcher a:focus-visible {
  outline: 3px solid var(--accent, #ff7043);
  outline-offset: 2px;
}
.auth-shell__header { position: relative; }
.auth-shell__header > .language-switcher { position: absolute; top: 12px; right: 16px; }
.app-topbar__locale { display: none; }
.app-drawer > .language-switcher { align-self: stretch; margin: 4px 16px; }
.app-sidebar__footer .language-switcher { z-index: 60; }
.app-sidebar__footer .language-switcher__menu {
  top: auto;
  right: auto;
  bottom: calc(100% + 8px);
  left: 0;
}
.app-sidebar__footer .language-switcher > summary::after { content: none; }
@media (max-width: 767px) {
  .language-switcher a { min-width: 44px; min-height: 44px; }
  .app-topbar__locale { display: block; }
}
