/* ==========================================================================
   IRONITT v2 — user profile window
   --------------------------------------------------------------------------
   The card another member's name opens (js/profile-modal.js). It floats, so
   it carries the shadow; its top edge wears the member's banner colour.
   Inside it is flat: stats and standings are one row each, split by
   hairlines, not a row of boxes; status, activity and bio are lines of
   text, not little cards. On phones it is a bottom sheet whose actions stay
   reachable.
   ========================================================================== */

/* Sits on the dialogs' layer (.modal-overlay), above the assistant launcher. */

.user-profile-modal {
  position: relative;
  width: min(480px, 92vw);
  max-width: 92vw;
  max-height: min(760px, 92dvh);
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--radius-xl);
  border-top: 4px solid var(--up-banner-color, var(--accent-color));
  background: var(--bg-secondary);
  box-shadow: var(--shadow-lg);
}
.user-profile-modal .up-banner { display: none; }

.user-profile-modal .up-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--radius-round);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}
.user-profile-modal .up-close-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.user-profile-modal .up-close-btn:focus { outline: 0; }
.user-profile-modal .up-close-btn:focus-visible { box-shadow: var(--focus-ring); }

.user-profile-modal .up-content { padding: var(--space-lg) var(--space-lg) var(--space-lg); }

/* ---- Who ---------------------------------------------------------------- */
.user-profile-modal .up-avatar-wrap { display: flex; margin: 0 0 12px; }
.user-profile-modal .up-avatar {
  position: relative;
  width: 72px;
  height: 72px;
  overflow: visible;
  border-radius: var(--radius-round);
  background: var(--bg-tertiary);
  color: var(--accent-color);
  font-size: 30px;
  font-weight: var(--font-weight-bold);
}
.user-profile-modal .up-avatar > img { border-radius: var(--radius-round); }
.user-profile-modal .up-avatar .status-dot {
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  border: 3px solid var(--bg-secondary);
}

.user-profile-modal .up-name-row { display: flex; align-items: baseline; gap: var(--space-sm); padding-right: 42px; margin-bottom: 4px; }
.user-profile-modal .up-name { margin: 0; font-family: var(--font-display); font-size: var(--font-size-lg); font-weight: var(--font-weight-bold); overflow-wrap: anywhere; }
.user-profile-modal .up-tag { color: var(--text-muted); font-size: var(--font-size-sm); font-variant-numeric: tabular-nums; }

.user-profile-modal .up-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 var(--space-sm); }
.user-profile-modal .up-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-2xs);
  font-weight: var(--font-weight-bold);
  line-height: 1.2;
  white-space: nowrap;
}
.user-profile-modal .up-badge i { font-size: 10px; }

/* ---- Status, activity, bio: lines, not cards ---------------------------- */
.user-profile-modal .up-status-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}
.user-profile-modal .up-status-row .status-dot { position: static; width: 9px; height: 9px; border: 0; }

.user-profile-modal .up-status-line { display: none; align-items: center; gap: 6px; margin-bottom: 6px; color: var(--text-primary); font-size: var(--font-size-sm); }
.user-profile-modal .up-status-line.has-emoji,
.user-profile-modal .up-status-line.has-text { display: flex; }
.user-profile-modal .up-status-line .status-emoji { font-size: 16px; line-height: 1; }
.user-profile-modal .up-status-line .status-emoji:empty,
.user-profile-modal .up-status-line .status-text:empty { display: none; }

.user-profile-modal .up-activity { display: flex; align-items: center; gap: var(--space-sm); margin-bottom: 6px; color: var(--text-secondary); font-size: var(--font-size-sm); }
.user-profile-modal .up-activity[hidden] { display: none; }
.user-profile-modal .up-activity-emoji { color: var(--accent-color); font-size: 14px; }

.user-profile-modal .up-bio { margin: var(--space-sm) 0 0; max-height: 120px; overflow-y: auto; color: var(--text-primary); font-size: var(--font-size-sm); line-height: 1.5; }
.user-profile-modal .up-bio p { margin: 0; white-space: pre-wrap; }

/* ---- Stats: one row split by hairlines ---------------------------------- */
.user-profile-modal .up-stats {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  margin: var(--space-md) 0 0;
  padding: var(--space-md) 0;
  border-top: 1px solid var(--border-color);
}
.user-profile-modal .up-stat {
  --stat-tint: var(--text-primary);
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 0 var(--space-md);
  border-left: 1px solid var(--border-color);
}
.user-profile-modal .up-stat:first-child { padding-left: 0; border-left: 0; }
.user-profile-modal .up-stat[class*="streak-t"] { --stat-tint: var(--streak-tier, var(--iron-gold)); }
.user-profile-modal .up-stat--iron { --stat-tint: var(--iron-gold); }
.user-profile-modal .up-stat-icon { display: none; }
.user-profile-modal .up-stat-val {
  overflow: hidden;
  color: var(--stat-tint);
  font-family: var(--font-display);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-bold);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-profile-modal .up-stat-lbl {
  color: var(--text-muted);
  font-size: var(--font-size-2xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---- Iron identity: motto, pinned achievements, standings --------------- */
.up-iron-identity { display: grid; gap: var(--space-md); padding: var(--space-md) 0; border-top: 1px solid var(--border-color); }
.up-iron-motto {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  margin: 0;
  padding-left: 12px;
  border-left: 2px solid var(--accent-color);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  line-height: 1.5;
}
.up-iron-motto i { display: none; }
.up-iron-identity h3 {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin: 0 0 var(--space-sm);
  color: var(--text-muted);
  font-size: var(--font-size-2xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.up-pinned-achievements > div { display: flex; gap: var(--space-xs); overflow-x: auto; padding-bottom: 2px; }
.up-iron-token {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: var(--space-sm);
  min-width: 150px;
  padding: var(--space-sm) 12px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
}
.up-iron-token > i { grid-row: 1 / 3; align-self: center; color: var(--accent-color); }
.up-iron-token strong { overflow: hidden; color: var(--text-primary); font-size: var(--font-size-xs); text-overflow: ellipsis; white-space: nowrap; }
.up-iron-token small { color: var(--text-muted); font-size: var(--font-size-2xs); text-transform: capitalize; }
/* Standings read like the stats row above them. */
.up-iron-boards { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.up-iron-boards span { display: grid; gap: 4px; padding: 0 var(--space-md); border-left: 1px solid var(--border-color); }
.up-iron-boards span:first-child { padding-left: 0; border-left: 0; }
.up-iron-boards strong { color: var(--accent-color); font-family: var(--font-display); font-size: var(--font-size-md); }
.up-iron-boards small { color: var(--text-muted); font-size: var(--font-size-2xs); font-weight: var(--font-weight-semibold); letter-spacing: 0.06em; text-transform: uppercase; }

/* ---- Actions ------------------------------------------------------------ */
.user-profile-modal .up-actions { display: flex; gap: var(--space-sm); padding-top: var(--space-md); border-top: 1px solid var(--border-color); }
.user-profile-modal .up-action-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
}
/* Icon-only actions (Block, Report) carry an aria-label; the rest grow. */
.user-profile-modal .up-action-btn[aria-label] { flex: 0 0 40px; padding: 0; }
.user-profile-modal .up-action-btn:focus-visible { outline: 0; box-shadow: var(--focus-ring); }

/* ---- Loading / error ---------------------------------------------------- */
.user-profile-modal .up-loading,
.user-profile-modal .up-error { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 36px; color: var(--text-muted); }
.user-profile-modal .up-spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent-color);
  border-radius: var(--radius-round);
  animation: spin 0.7s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .user-profile-modal .up-spinner { animation-duration: 1.6s; }
}

/* ---- Phones: a bottom sheet with its actions pinned --------------------- */
@media (max-width: 600px) {
  .user-profile-overlay { align-items: flex-end; padding: 0; }
  .user-profile-modal { width: 100vw; max-width: none; max-height: calc(100dvh - 12px); border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
  .user-profile-modal .up-content { padding: var(--space-md) var(--space-md) 84px; }
  .user-profile-modal .up-actions {
    position: sticky;
    bottom: -84px;
    z-index: 3;
    margin: 12px calc(-1 * var(--space-md)) -84px;
    padding: 12px var(--space-md) calc(12px + env(safe-area-inset-bottom));
    background: var(--bg-secondary);
  }
  .user-profile-modal .up-pinned-achievements > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
  .user-profile-modal .up-stat, .up-iron-boards span { padding: 0 12px; }
}

@keyframes spin { to { transform: rotate(360deg); } }
