/**
 * FRIENDS — non-asset commercial polish layer (post route-integrity).
 * Ownership: visual tokens / hierarchy / calm surfaces only.
 * Loads after V2 shell + home + platform CSS. No new features, no asset intake.
 */

html.friends-ui-v2 {
  /* Shared commercial rhythm (8px base) */
  --polish-space-1: 0.5rem;
  --polish-space-2: 1rem;
  --polish-space-3: 1.5rem;
  --polish-space-4: 2.5rem;
  --polish-radius-control: 12px;
  --polish-radius-card: 16px;
  --polish-radius-panel: 18px;
  --polish-border: rgba(212, 160, 23, 0.2);
  --polish-border-soft: rgba(255, 255, 255, 0.07);
  --polish-surface: rgba(14, 16, 24, 0.78);
  --polish-surface-raised: rgba(18, 20, 30, 0.88);
  --polish-text: #f3efe6;
  --polish-muted: rgba(232, 228, 220, 0.58);
  --polish-glow: 0 10px 28px rgba(0, 0, 0, 0.28);
  --polish-title: clamp(1.65rem, 2.6vw, 2.2rem);
  --polish-section: 1.05rem;
}

/* ── Topbar: calmer chrome ── */
html.friends-ui-v2 .friends-topbar {
  padding: 0.55rem 1.15rem;
  background: linear-gradient(180deg, rgba(12, 14, 22, 0.96), rgba(11, 14, 24, 0.9));
  border-bottom-color: var(--polish-border);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03);
}

html.friends-ui-v2 .friends-topbar-title {
  font-size: 1.05rem;
  letter-spacing: 0.06em;
}

html.friends-ui-v2 .friends-topbar-subtitle {
  opacity: 0.85;
  max-width: 13rem;
}

html.friends-ui-v2 .friends-topbar-section {
  border-radius: var(--polish-radius-control);
  border-color: var(--polish-border);
  background: rgba(212, 160, 23, 0.06);
  padding: 0.4rem 0.7rem;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: none;
}

html.friends-ui-v2 .friends-topbar-balance {
  border-radius: var(--polish-radius-control);
  border-color: var(--polish-border-soft);
  background: rgba(0, 0, 0, 0.32);
  padding: 0.4rem 0.65rem;
  gap: 0.4rem;
}

html.friends-ui-v2 .friends-topbar-balance-label {
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

html.friends-ui-v2 .friends-topbar-balance-value {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

html.friends-ui-v2 .friends-topbar-avatar-cluster {
  border-color: var(--polish-border-soft);
  background: rgba(255, 255, 255, 0.025);
  transition: border-color 160ms ease, background 160ms ease;
}

html.friends-ui-v2 .friends-topbar-avatar-cluster:hover,
html.friends-ui-v2 .friends-topbar-avatar-cluster:focus-visible {
  border-color: var(--polish-border);
  background: rgba(212, 160, 23, 0.06);
}

html.friends-ui-v2 .friends-topbar-avatar {
  background: linear-gradient(145deg, rgba(212, 160, 23, 0.28), rgba(80, 60, 20, 0.35));
  font-size: 0.78rem;
}

html.friends-ui-v2 .shell-btn--primary {
  border-radius: var(--polish-radius-control);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 8px 18px rgba(212, 160, 23, 0.16);
}

html.friends-ui-v2 .shell-btn--secondary {
  border-radius: var(--polish-radius-control);
  border-color: var(--polish-border);
  background: rgba(255, 255, 255, 0.035);
}

html.friends-ui-v2 .shell-btn--ghost {
  border-radius: var(--polish-radius-control);
}

html.friends-ui-v2 .account-status {
  font-size: 0.78rem;
  color: var(--polish-muted);
  max-width: 14rem;
  line-height: 1.3;
}

html.friends-ui-v2 .account-status.account-status--auth {
  color: rgba(243, 239, 230, 0.72);
}

/* ── Companion rail: cleaner expanded / intentional collapsed ── */
html.friends-ui-v2 .friends-ui-v2-shell aside.companion-rail {
  background: linear-gradient(180deg, rgba(12, 14, 22, 0.98), rgba(10, 12, 18, 0.94));
  border-right-color: var(--polish-border);
}

html.friends-ui-v2 .companion-rail--collapsed .companion-rail-expanded,
html.friends-ui-v2 .companion-rail--collapsed [data-rail-expanded-body] {
  display: none !important;
  visibility: hidden !important;
}

html.friends-ui-v2 .companion-rail-expanded {
  padding: 2.55rem 0.85rem 1rem;
  gap: var(--polish-space-2);
}

html.friends-ui-v2 .companion-rail-room {
  border-radius: var(--polish-radius-card);
  border-color: var(--polish-border-soft);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

html.friends-ui-v2 .companion-rail-identity {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--polish-text);
}

html.friends-ui-v2 .companion-rail-dialogue {
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--polish-muted);
  max-height: 3.2em;
}

html.friends-ui-v2 .companion-rail-stats {
  gap: 0.45rem;
  padding: 0.55rem 0.6rem;
  border-radius: 12px;
  border: 1px solid var(--polish-border-soft);
  background: rgba(255, 255, 255, 0.02);
}

html.friends-ui-v2 .companion-rail-stats > div {
  font-size: 0.76rem;
}

html.friends-ui-v2 .companion-rail-quest {
  border-radius: 12px;
  border-color: var(--polish-border-soft);
  background: rgba(255, 255, 255, 0.025);
  padding: 0.6rem 0.65rem;
}

html.friends-ui-v2 .companion-rail-actions .shell-btn {
  width: 100%;
  justify-content: center;
}

html.friends-ui-v2 .companion-rail-collapsed.companion-mini-dock {
  padding: 0.4rem 0.35rem 0.45rem;
  gap: 0.35rem;
}

html.friends-ui-v2 .companion-rail-avatar-btn {
  width: 2.9rem;
  height: 2.9rem;
  min-width: 44px;
  min-height: 44px;
  border-radius: 14px;
  border-color: var(--polish-border);
  background: linear-gradient(160deg, rgba(212, 160, 23, 0.18), rgba(255, 255, 255, 0.04));
  box-shadow: var(--polish-glow);
}

html.friends-ui-v2 .companion-rail-dot,
html.friends-ui-v2 .companion-rail-badge {
  opacity: 0.95;
}

/* Play routes: lighter, quieter rail */
html.friends-ui-v2 .showcase-shell.playground--slot-active aside.companion-rail,
html.friends-ui-v2 .showcase-shell.playground--embed-active aside.companion-rail {
  background: rgba(10, 12, 18, 0.72);
  border-right-color: rgba(255, 255, 255, 0.05);
  box-shadow: none;
}

html.friends-ui-v2 .showcase-shell.playground--slot-active .companion-rail-avatar-btn,
html.friends-ui-v2 .showcase-shell.playground--embed-active .companion-rail-avatar-btn {
  box-shadow: none;
  opacity: 0.92;
}

/* ── Main content gutter rhythm ── */
html.friends-ui-v2 .friends-ui-v2-shell .showcase-center--player {
  padding-left: var(--friends-content-gutter);
  padding-right: var(--friends-content-gutter);
}

html.friends-ui-v2 .showcase-shell.playground--slot-active .showcase-center--player,
html.friends-ui-v2 .showcase-shell.playground--embed-active .showcase-center--player {
  padding-left: 0;
  padding-right: 0;
}

/* ── Home hierarchy + portal calmness ── */
html.friends-ui-v2 .friends-home {
  gap: var(--polish-space-3);
  padding-top: 0.5rem;
  padding-bottom: var(--polish-space-4);
}

html.friends-ui-v2 .friends-home-welcome {
  padding: 1.25rem 1.35rem 1.4rem;
  border-radius: var(--polish-radius-panel);
  border-color: var(--polish-border);
  background:
    radial-gradient(90% 70% at 0% 0%, rgba(212, 160, 23, 0.12), transparent 55%),
    var(--polish-surface);
  box-shadow: var(--polish-glow);
}

html.friends-ui-v2 .friends-home-kicker {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: rgba(212, 160, 23, 0.75);
}

html.friends-ui-v2 .friends-home-title {
  font-size: var(--polish-title);
  font-weight: 750;
  letter-spacing: -0.01em;
  line-height: 1.12;
}

html.friends-ui-v2 .friends-home-sentence {
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--polish-muted);
  max-width: 38rem;
}

html.friends-ui-v2 .friends-home-welcome-actions {
  gap: 0.65rem;
  margin-top: 0.75rem;
}

html.friends-ui-v2 .friends-home-btn {
  border-radius: var(--polish-radius-control);
  min-height: 2.55rem;
  padding: 0.55rem 1.15rem;
  font-weight: 650;
}

html.friends-ui-v2 .friends-home-btn--primary {
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 8px 18px rgba(212, 160, 23, 0.18);
}

html.friends-ui-v2 .friends-home-btn--secondary {
  border-color: var(--polish-border);
  background: rgba(255, 255, 255, 0.03);
}

html.friends-ui-v2 .friends-home-section-title {
  margin: 0 0 0.75rem;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(212, 160, 23, 0.7);
}

html.friends-ui-v2 .friends-portal-grid {
  gap: var(--polish-space-2);
}

html.friends-ui-v2 .friends-portal-card {
  border-radius: var(--polish-radius-card);
  border-color: var(--polish-border-soft);
  background: var(--polish-surface);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
  transition: border-color 160ms ease, transform 160ms ease;
}

html.friends-ui-v2 .friends-portal-card:hover {
  border-color: var(--polish-border);
  transform: translateY(-1px);
}

html.friends-ui-v2 .friends-portal-card-body {
  gap: 0.45rem;
  padding: 1rem 1.05rem 1.1rem;
}

html.friends-ui-v2 .friends-portal-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

html.friends-ui-v2 .friends-portal-card-lead,
html.friends-ui-v2 .friends-portal-card-meta,
html.friends-ui-v2 .friends-portal-card-status {
  font-size: 0.86rem;
  line-height: 1.4;
  color: var(--polish-muted);
}

html.friends-ui-v2 .friends-portal-badge {
  border-radius: 8px;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

html.friends-ui-v2 .friends-continue-card,
html.friends-ui-v2 .friends-today-card,
html.friends-ui-v2 .friends-home-context-card {
  border-radius: 14px;
  border-color: var(--polish-border-soft);
  background: rgba(22, 20, 18, 0.92);
  padding: 0.95rem 1.1rem;
  color: #f3efe6;
}

html.friends-ui-v2 button.friends-continue-card,
html.friends-ui-v2 button.friends-continue-card--inline {
  color: #f3efe6;
}

html.friends-ui-v2 .friends-continue-card-title,
html.friends-ui-v2 .friends-continue-card strong {
  color: #f3efe6;
}

html.friends-ui-v2 .friends-continue-card-cta {
  color: #1a1408;
  background: #d4a017;
}

html.friends-ui-v2 .friends-home-degraded,
html.friends-ui-v2 .friends-home-loading {
  padding: 0.75rem 0.95rem;
  border-radius: 12px;
  border: 1px solid var(--polish-border-soft);
  background: rgba(255, 255, 255, 0.03);
}

/* ── Games catalog scanability ── */
html.friends-ui-v2 .friends-catalog {
  gap: var(--polish-space-3);
  padding-top: 0.35rem;
}

html.friends-ui-v2 .friends-catalog-head h1 {
  font-size: var(--polish-title);
  font-weight: 750;
  letter-spacing: -0.01em;
  margin-bottom: 0.45rem;
}

html.friends-ui-v2 .friends-catalog-head p {
  color: var(--polish-muted);
  max-width: 36rem;
  line-height: 1.45;
}

html.friends-ui-v2 .friends-catalog-section h2 {
  margin: 0 0 0.75rem;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(212, 160, 23, 0.7);
}

html.friends-ui-v2 .friends-catalog-grid {
  gap: 0.9rem;
}

html.friends-ui-v2 .friends-catalog-card {
  border-radius: var(--polish-radius-card);
  border-color: var(--polish-border-soft);
  background: var(--polish-surface);
  transition: border-color 160ms ease, transform 160ms ease;
}

html.friends-ui-v2 .friends-catalog-card:hover:not(:disabled):not(.friends-catalog-card--soon) {
  border-color: var(--polish-border);
  transform: translateY(-1px);
}

html.friends-ui-v2 .friends-catalog-card-body {
  padding: 0.9rem 0.95rem 1rem;
}

html.friends-ui-v2 .friends-catalog-card-body h3 {
  margin: 0 0 0.35rem;
  font-size: 1.02rem;
  font-weight: 700;
}

/* ── Friends / profile surfaces ── */
html.friends-ui-v2 .friends-social-surface,
html.friends-ui-v2 .friends-profile-surface,
html.friends-ui-v2 .friends-rank-surface,
html.friends-ui-v2 .friends-stats-surface,
html.friends-ui-v2 .friends-achievements-surface,
html.friends-ui-v2 .friends-settings-surface,
html.friends-ui-v2 [data-friends-leaderboard] {
  padding-top: 0.35rem;
}

html.friends-ui-v2 .friends-social-title,
html.friends-ui-v2 .friends-profile-title {
  font-size: var(--polish-title);
  font-weight: 750;
  letter-spacing: -0.01em;
  line-height: 1.12;
}

html.friends-ui-v2 .friends-social-kicker,
html.friends-ui-v2 .friends-profile-kicker {
  letter-spacing: 0.1em;
  color: rgba(212, 160, 23, 0.75);
}

html.friends-ui-v2 .friends-social-lead,
html.friends-ui-v2 .friends-profile-lead {
  color: var(--polish-muted);
  max-width: 40rem;
}

html.friends-ui-v2 .friends-profile-hero,
html.friends-ui-v2 .friends-rank-current,
html.friends-ui-v2 .friends-stats-section,
html.friends-ui-v2 .friends-settings-block,
html.friends-ui-v2 .friends-social-card {
  border-color: var(--polish-border-soft);
  background: var(--polish-surface);
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
}

html.friends-ui-v2 .friends-social-empty,
html.friends-ui-v2 .friends-social-empty--guest,
html.friends-ui-v2 .friends-achievements-empty,
html.friends-ui-v2 .friends-social-loading {
  border-radius: 14px;
  border: 1px solid var(--polish-border-soft);
  background: rgba(255, 255, 255, 0.025);
  padding: 1.35rem 1.25rem;
}

html.friends-ui-v2 .friends-social-empty-title {
  font-size: 1.2rem;
  font-weight: 700;
}

html.friends-ui-v2 .friends-social-empty-actions {
  margin-top: 0.35rem;
}

html.friends-ui-v2 .friends-profile-nav-btn,
html.friends-ui-v2 .friends-social-filters .shell-btn {
  border-radius: var(--polish-radius-control);
}

/* Soften nested chrome in discovery lobby panels */
html.friends-ui-v2 .game-lobby--discovery-v2 {
  max-width: var(--friends-content-max-width, 1200px);
}

@media (max-width: 900px) {
  html.friends-ui-v2 .friends-home-welcome,
  html.friends-ui-v2 .friends-catalog-head h1,
  html.friends-ui-v2 .friends-social-title,
  html.friends-ui-v2 .friends-profile-title {
    letter-spacing: 0;
  }

  html.friends-ui-v2 .friends-ui-v2-shell .showcase-center--player {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.friends-ui-v2 .friends-portal-card,
  html.friends-ui-v2 .friends-catalog-card,
  html.friends-ui-v2 .friends-topbar-avatar-cluster {
    transition: none;
  }

  html.friends-ui-v2 .friends-portal-card:hover,
  html.friends-ui-v2 .friends-catalog-card:hover:not(:disabled):not(.friends-catalog-card--soon) {
    transform: none;
  }
}
