/* ==========================================================================
   friends.css — Friends & Leagues pane polish layer
   Loaded after styles.css; overrides/extends the baseline for this pane only.
   Uses app tokens exclusively (one pink accent, glassy dark surfaces).
   Medal colors on rank badges are semantic (gold/silver/bronze), not accents.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Grid + cards
   -------------------------------------------------------------------------- */

.friends-grid {
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 18px;
  margin-top: 14px;
}

.fr-card {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045) 0%, rgba(255, 255, 255, 0.015) 55%, rgba(255, 255, 255, 0.02) 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
  box-shadow: var(--edge-hi), var(--shadow-2);
  overflow: hidden; /* clip ambient glows to the card */
}

/* soft ambient accent bloom in the profile card's top-left, behind the avatar */
.fr-profile::before {
  content: "";
  position: absolute;
  top: -70px;
  left: -60px;
  width: 240px;
  height: 200px;
  background: radial-gradient(closest-side, rgba(var(--accent-rgb), 0.14), transparent 72%);
  pointer-events: none;
}

/* faint hairline sheen across the leagues card top */
.fr-leagues::before {
  content: "";
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.35), transparent);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   2. Profile: hero head
   -------------------------------------------------------------------------- */

.fr-prof-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.fr-avatar {
  width: 62px;
  height: 62px;
  font-size: 28px;
  box-shadow:
    0 0 0 2px var(--bg-2),
    0 0 0 3.5px rgba(var(--accent-rgb), 0.55),
    0 10px 28px -8px rgba(var(--accent-rgb), 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.fr-prof-id {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* display name reads as a title, reveals itself as a field on interaction */
.fr-name-input,
#frName {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 5px 9px;
  margin-left: -9px; /* optical: align text with the sub label */
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  transition:
    border-color var(--dur-2) var(--ease),
    background var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease);
}

.fr-name-input::placeholder { color: var(--faint); font-weight: 600; }

.fr-name-input:hover {
  border-color: var(--border);
  background: var(--card);
}

.fr-name-input:focus {
  border-color: rgba(var(--accent-rgb), 0.6);
  background: var(--bg-2);
  box-shadow: var(--focus-ring);
  outline: none;
}

.fr-prof-sub { margin-left: 0; letter-spacing: 0.01em; }

/* --------------------------------------------------------------------------
   3. Profile: scoreboard stat tiles (2 x 2)
   -------------------------------------------------------------------------- */

.fr-stat-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 18px;
}

.fr-stat {
  position: relative;
  background: linear-gradient(180deg, var(--bg-3) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 13px 14px 12px;
  box-shadow: var(--edge-hi);
  transition:
    transform var(--dur-2) var(--spring-soft),
    border-color var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease);
}

.fr-stat:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--edge-hi), 0 10px 26px -12px rgba(3, 3, 6, 0.7);
}

.fr-stat-ic {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 15px;
  color: var(--pink-4);
  background: rgba(var(--accent-rgb), 0.12);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.22);
  margin-bottom: 9px;
  transition: background var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}

.fr-stat:hover .fr-stat-ic {
  background: rgba(var(--accent-rgb), 0.18);
  box-shadow:
    inset 0 0 0 1px rgba(var(--accent-rgb), 0.35),
    0 0 14px -4px rgba(var(--accent-rgb), 0.5);
}

.fr-stat-n {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 23px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text);
}

.fr-stat-l {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
  margin-top: 4px;
}

/* --------------------------------------------------------------------------
   4. Privacy segmented control
   -------------------------------------------------------------------------- */

.fr-privacy {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.fr-priv-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
}

.seg,
#frPrivacy {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
}

.seg-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 8px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition:
    background var(--dur-2) var(--ease),
    color var(--dur-2) var(--ease),
    box-shadow var(--dur-2) var(--ease),
    transform var(--dur-1) var(--ease);
}

.seg-btn i { font-size: 14px; }

.seg-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.seg-btn:active { transform: scale(0.97); }

.seg-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.seg-btn.active {
  background: var(--pink-grad);
  color: #fff;
  box-shadow:
    0 2px 10px -2px rgba(var(--accent-rgb), 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.seg-btn.active:hover { color: #fff; }

#frPrivacyHint { margin: 8px 0 0; min-height: 0; }
#frPrivacyHint:empty { display: none; }

#frResetSeason {
  margin-top: 14px;
  color: var(--faint);
  transition: color var(--dur-2) var(--ease);
}
#frResetSeason:hover { color: var(--muted); }

/* --------------------------------------------------------------------------
   5. Leagues: create / join rows
   -------------------------------------------------------------------------- */

.fr-create,
.fr-join {
  display: grid;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.fr-create { grid-template-columns: minmax(0, 1fr) auto auto; }
.fr-join   { grid-template-columns: minmax(0, 1fr) auto; }

.fr-create input,
.fr-create select,
.fr-join input {
  height: 34px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0 11px;
  font-size: 12.5px;
  color: var(--text);
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}

.fr-create input::placeholder,
.fr-join input::placeholder { color: var(--faint); }

.fr-create input:hover,
.fr-create select:hover,
.fr-join input:hover { border-color: var(--border-strong); }

/* invite code: mono, uppercase, spaced like a ticket stub */
.fr-join input[type="text"] {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
}
.fr-join input[type="text"]::placeholder { letter-spacing: 0.06em; text-transform: none; }

#frLeagueMsg { margin: 4px 0 2px; }
#frLeagueMsg:empty { display: none; }

#leagueSyncNote { letter-spacing: 0.02em; }

/* --------------------------------------------------------------------------
   6. League cards
   -------------------------------------------------------------------------- */

.fr-league-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.fr-league {
  background: linear-gradient(180deg, var(--bg-3) 0%, var(--bg-2) 70%);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--edge-hi), 0 2px 10px -6px rgba(3, 3, 6, 0.6);
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
  animation: sf-fr-rise var(--dur-3) var(--spring-soft) backwards;
}

.fr-league:hover {
  border-color: var(--border-strong);
  box-shadow: var(--edge-hi), 0 10px 30px -14px rgba(3, 3, 6, 0.75);
}

/* staggered entrance */
.fr-league:nth-child(1) { animation-delay: 0ms; }
.fr-league:nth-child(2) { animation-delay: 60ms; }
.fr-league:nth-child(3) { animation-delay: 120ms; }
.fr-league:nth-child(4) { animation-delay: 180ms; }
.fr-league:nth-child(n + 5) { animation-delay: 240ms; }

.fr-league-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  background: rgba(255, 255, 255, 0.025);
  border-bottom: 1px solid var(--border);
}

.fr-league-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.fr-league-meta { margin-top: 2px; letter-spacing: 0.01em; }

.fr-league-code { display: flex; align-items: center; gap: 6px; flex: none; }

.fr-league-code code {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--pink-4);
  background: rgba(var(--accent-rgb), 0.1);
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  padding: 3px 9px;
  border-radius: 7px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* --------------------------------------------------------------------------
   7. Standings: the ladder
   -------------------------------------------------------------------------- */

.fr-standings {
  list-style: none;
  margin: 0;
  padding: 7px;
  display: flex;
  flex-direction: column;
}

.fr-row {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 42px;
  padding: 7px 11px;
  border-radius: var(--r-sm);
  transition: background var(--dur-2) var(--ease);
  animation: sf-fr-rise var(--dur-3) var(--ease) backwards;
}

/* stagger rows so the ladder builds top-down */
.fr-row:nth-child(1) { animation-delay: 40ms; }
.fr-row:nth-child(2) { animation-delay: 80ms; }
.fr-row:nth-child(3) { animation-delay: 120ms; }
.fr-row:nth-child(4) { animation-delay: 160ms; }
.fr-row:nth-child(5) { animation-delay: 200ms; }
.fr-row:nth-child(n + 6) { animation-delay: 240ms; }

/* hairline separators between rows */
.fr-row + .fr-row { border-top: 1px solid rgba(255, 255, 255, 0.04); }

.fr-row:hover { background: rgba(255, 255, 255, 0.04); }

/* ---- rank badge ---- */

.fr-rank {
  flex: none;
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
}

/* ---- podium: gold / silver / bronze medals (color + shape, no glyphs) ---- */

.fr-standings .fr-row:nth-child(1) .fr-rank {
  background: linear-gradient(160deg, #ffe3a0 0%, #f2b83f 100%);
  border-color: rgba(255, 209, 102, 0.7);
  color: #3a2a06;
  box-shadow:
    0 0 14px -3px rgba(255, 209, 102, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.fr-standings .fr-row:nth-child(2) .fr-rank {
  background: linear-gradient(160deg, #eef1f6 0%, #a9b0bd 100%);
  border-color: rgba(214, 219, 228, 0.55);
  color: #23262d;
  box-shadow:
    0 0 10px -3px rgba(214, 219, 228, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.fr-standings .fr-row:nth-child(3) .fr-rank {
  background: linear-gradient(160deg, #e5aa78 0%, #ad6d3c 100%);
  border-color: rgba(211, 141, 84, 0.55);
  color: #2e1808;
  box-shadow:
    0 0 10px -3px rgba(211, 141, 84, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* rank 1 row: gently elevated with a warm wash fading right */
.fr-standings .fr-row:nth-child(1) {
  background-image: linear-gradient(90deg, rgba(255, 209, 102, 0.07), rgba(255, 209, 102, 0) 65%);
}
.fr-standings .fr-row:nth-child(1):hover {
  background-image: linear-gradient(90deg, rgba(255, 209, 102, 0.1), rgba(255, 255, 255, 0.03) 65%);
}
.fr-standings .fr-row:nth-child(1) .fr-mname { color: var(--text); }

/* ---- you: unmistakable accent marker ---- */

.fr-row.me {
  background-color: rgba(var(--accent-rgb), 0.08);
  box-shadow:
    inset 3px 0 0 rgba(var(--accent-rgb), 0.65), /* left accent bar, not color-only */
    inset 0 0 0 1px rgba(var(--accent-rgb), 0.16);
}

.fr-row.me:hover { background-color: rgba(var(--accent-rgb), 0.12); }

.fr-row.me + .fr-row,
.fr-row.me { border-top-color: transparent; }

/* ---- member avatar: img and glyph fallback, identical shape ---- */

.fr-mav,
img.fr-mav,
.fr-mav.ph-glyph {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-3);
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border-strong);
}

/* ---- name, you-chip, score ---- */

.fr-mname {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.fr-row.me .fr-mname { color: var(--text); }

.fr-you {
  flex: none;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1;
  color: var(--pink-4);
  background: rgba(var(--accent-rgb), 0.14);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  padding: 3px 6px;
  border-radius: 999px;
}

.fr-mval {
  flex: none;
  margin-left: auto;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* podium scores read a touch brighter */
.fr-standings .fr-row:nth-child(1) .fr-mval { text-shadow: 0 0 14px rgba(255, 209, 102, 0.25); }

/* the muted "Private" placeholder inside a score cell stays quiet */
.fr-mval .muted,
.fr-row .fr-mval:empty { color: var(--faint); }
.fr-mval .muted {
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.03em;
}

/* --------------------------------------------------------------------------
   8. Motion + responsive
   -------------------------------------------------------------------------- */

@keyframes sf-fr-rise {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  .friends-grid { grid-template-columns: 1fr; gap: 14px; }
  .fr-card { padding: 18px; }
  .fr-create { grid-template-columns: minmax(0, 1fr) auto; }
  .fr-create input { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  .fr-league,
  .fr-row { animation: none; }
  .fr-card,
  .fr-stat,
  .fr-stat-ic,
  .fr-league,
  .fr-row,
  .fr-name-input,
  .seg-btn,
  .fr-create input,
  .fr-create select,
  .fr-join input,
  #frResetSeason { transition: none; }
  .fr-stat:hover { transform: none; }
  .seg-btn:active { transform: none; }
}

/* ---- friends list (add by code) ---- */
.fr-friends .fr-mycode { display: flex; align-items: center; gap: 8px; margin: 8px 0 10px; }
.fr-friends .fr-mycode code { font-size: 15px; font-weight: 700; letter-spacing: 2px; color: var(--text);
  background: var(--card-2); border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; }
.fr-add { display: flex; gap: 8px; margin-bottom: 8px; }
.fr-add input { flex: 1; min-width: 0; }
.fr-friend-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.fr-friend-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px;
  background: var(--card-2); border: 1px solid var(--border); }
.fr-friend-av { flex: none; width: 32px; height: 32px; border-radius: 50%; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.85), rgba(var(--accent-rgb), 0.45)); }
.fr-friend-av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.fr-friend-meta { display: flex; flex-direction: column; min-width: 0; margin-right: auto; }
.fr-friend-meta b { font-size: 13.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fr-friend-meta span { font-size: 11px; }
.fr-friend-msg.ok, #frFriendMsg.ok { color: #34d399; }
.fr-friend-msg.bad, #frFriendMsg.bad { color: #f87171; }
