/* ============================================================
   v0.4.17: Steam-style user profile modal (ProfileModal.razor)
   Avatar + streak + pet + artifact showcase. Hero banner, avatar
   ring and card glow tint to the user's rarest artifact tier via
   the --accent custom property set on .profile-card.tier-frame-*.
   Per-artifact tiles colour by their own tier (ADR §8.1 palette).
   ============================================================ */

.profile-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 6, 18, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: profile-fade 0.2s ease-out;
}
@keyframes profile-fade { from { opacity: 0; } to { opacity: 1; } }

/* Hide the OS scrollbar on the dark modal cards (wheel / trackpad scroll still works).
   The default gray scrollbar looked out of place on the modals. */
.profile-card,
.profile-card-scroll,
.theme-modal-card,
.inventory-card,
.inv-grid-wrap {
  scrollbar-width: none;          /* Firefox */
  -ms-overflow-style: none;       /* legacy Edge */
}
.profile-card::-webkit-scrollbar,
.profile-card-scroll::-webkit-scrollbar,
.theme-modal-card::-webkit-scrollbar,
.inventory-card::-webkit-scrollbar,
.inv-grid-wrap::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;                  /* Chromium / WebKit */
}

/* Inner scroll region of the profile modal (see .profile-card overflow note).
   max-height: inherit picks up the card's 92vh cap, so this is a plain
   block-in-block scroll - no flex sizing involved. */
.profile-card-scroll {
  max-height: inherit;
  overflow-y: auto;
  overflow-x: hidden;
  /* v0.4.68: keep touch scroll inside the modal - without this, hitting the top/
     bottom of the card chains the gesture to the page behind the overlay. */
  overscroll-behavior: contain;
}

.profile-card {
  /* Theme token set (defaults = the classic look). A .theme-<id> class on the same
     element re-skins the WHOLE card coherently by overriding these variables; every
     sub-element below reads them instead of hardcoding its colours. */
  --accent: #b8c0cc;
  --profile-card-bg: linear-gradient(180deg, #181228 0%, #0d0a18 100%);
  --profile-frame: rgba(255, 255, 255, 0.08);
  --profile-ring: var(--accent);
  --profile-tile-bg: rgba(124, 58, 237, 0.1);
  --profile-tile-border: rgba(255, 255, 255, 0.06);
  --profile-hero-overlay: transparent;
  --profile-tab-accent: var(--accent);
  position: relative;
  width: 720px;
  max-width: 100%;
  max-height: 92vh;
  /* v0.4.68: dvh where supported - 92vh overshoots the VISIBLE viewport under the
     mobile browser chrome (address bar), clipping the card bottom on first paint. */
  max-height: 92dvh;
  /* The card itself never scrolls - .profile-card-scroll inside does. Scrolling here
     dragged the theme frames' absolute decor (columns, corner scrolls, rails) along
     with the content; hidden keeps the ornaments pinned to the card box. */
  overflow: hidden;
  background: var(--profile-card-bg);
  border: 1px solid var(--profile-frame);
  border-radius: 16px;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.7),
    0 0 0 1px var(--accent),
    0 0 50px color-mix(in srgb, var(--accent) 35%, transparent);
  color: #e8e4f5;
  font-family: var(--chronos-font-sans);
}

/* accent palette per top-tier (ADR §8.1: White/Blue/Yellow/Orange/Red) */
.profile-card.tier-frame-common    { --accent: #b8c0cc; }
.profile-card.tier-frame-uncommon  { --accent: #4a90d9; }
.profile-card.tier-frame-rare      { --accent: #f0c419; }
.profile-card.tier-frame-epic      { --accent: #e8833a; }
.profile-card.tier-frame-legendary { --accent: #e0405a; }

.profile-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.35);
  color: #c8bfe0;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.profile-close:hover { background: rgba(0,0,0,0.6); color: #fff; }

.profile-hero {
  position: relative;
  height: 96px; /* v0.4.20.6: trimmed from 120 - the streak headline now fills it */
  border-radius: 16px 16px 0 0;
  background:
    radial-gradient(ellipse 70% 130% at 30% 0%, color-mix(in srgb, var(--accent) 55%, transparent), transparent 70%),
    linear-gradient(120deg, color-mix(in srgb, var(--accent) 40%, #1a1230) 0%, #140e24 60%);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}
/* Theme hero tint - paints over both the tier gradient and a custom background so a
   theme reads coherently on any hero. Default is transparent (no visual change). */
.profile-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 16px 16px 0 0;
  background: var(--profile-hero-overlay);
  pointer-events: none;
}

/* v0.4.20.6: streak headline in the hero (Pit ADR §7.1 - the most prominent number).
   Inset 56px from the right so it clears the 32px close button in the corner. */
/* v0.4.34: centered + dropped a little; the number and its caption share one
   vertical axis so the count reads as centered over the flame + word. */
.hero-streak {
  position: absolute;
  top: 24px;
  right: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}
.hero-streak-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  color: #fff;
  /* dark contour so the white number stays legible on a light hero (common tier
     accent is light grey) as well as on dark/custom backgrounds. */
  text-shadow: 0 1px 2px rgba(0,0,0,0.75), 0 0 6px rgba(0,0,0,0.5);
}
.hero-streak-fire { font-size: 24px; }
.hero-streak-word {
  margin-top: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
}

.profile-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  padding: 0 24px;
  margin-top: -44px;
  /* The hero is position:relative (it anchors the streak), so without an explicit
     stacking position it would paint OVER this head and hide the avatar/username.
     Lift the head above the hero; the close button stays on top at z-index 3. */
  position: relative;
  z-index: 1;
}

.profile-avatar {
  width: 88px;
  height: 88px;
  flex-shrink: 0;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #2a2347, #1a1230);
  border: 3px solid var(--profile-ring);
  box-shadow: 0 0 24px color-mix(in srgb, var(--profile-ring) 50%, transparent),
              0 6px 18px rgba(0,0,0,0.5);
}
.profile-avatar-initial {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 40px;
  font-weight: 800;
  /* line-height:1 + flex centering on the parent makes the glyph sit dead-center
     vertically instead of riding the text baseline (the "floating high" look). */
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--accent);
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.profile-identity { padding-bottom: 6px; }
.profile-name { font-size: 22px; font-weight: 800; color: #fff; line-height: 1.1; }
/* v0.4.20.5: subscription badge next to the username (Pricing tiers ADR). */
.tier-badge {
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 1.4;
  text-transform: uppercase;
}
.tier-badge-free {
  background: rgba(148, 163, 184, 0.18);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.35);
}
.tier-badge-plus {
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
  box-shadow: 0 1px 6px rgba(124, 58, 237, 0.5);
}
.tier-badge-pro {
  background: linear-gradient(135deg, #f59e0b, #fcd34d);
  color: #3b2a00;
  box-shadow: 0 1px 8px rgba(245, 158, 11, 0.55);
}
.profile-rank {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-top: 2px;
}
.profile-since { font-size: 11px; color: #8c84a8; margin-top: 3px; }

.profile-stats {
  display: grid;
  /* v0.4.34: 4 - Record / Freeze / Milestone / Tokens. */
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 16px 24px 6px;
}
.profile-inventory {
  padding: 10px 24px 6px;
}
.profile-inventory-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #a79ec6;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.profile-stats-inventory {
  padding: 0;
}
.profile-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  /* Let the 4 grid tracks shrink to fit. Without this, a wide value like the Pet XP
     "22200" keeps its min-content width (min-width:auto on grid items) and pushes the
     4-up row past the card, which is what put a stat tile off to the right + a scrollbar. */
  min-width: 0;
  padding: 12px 6px;
  background: var(--profile-tile-bg);
  border: 1px solid var(--profile-tile-border);
  border-radius: 10px;
}
.profile-stat-value {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.55);
  /* center-align so number tiles and emoji tiles sit on a common line, and reserve a
     fixed height so the row stays even whether a tile shows "1", "❄️", or "-". */
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.profile-stat-suffix { font-size: 13px; }
.profile-pet { font-size: 24px; }
.profile-stat-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: #a79ec6; /* v0.4.20.6: lifted from #8c84a8 for AA contrast on the dark card */
  font-weight: 700;
}

/* StatTile size modifiers - .stat-tile--md is the base (.profile-stat above, unchanged);
   sm/lg scale font-size and padding roughly 0.85x / 1.2x off the base 22px / 12px 6px. */
.stat-tile--sm { padding: 10px 5px; }
.stat-tile--sm .profile-stat-value { font-size: 19px; }
.stat-tile--lg { padding: 14px 7px; }
.stat-tile--lg .profile-stat-value { font-size: 26px; }

/* v0.4.20.6: pet tile states (Pit ADR §11). Unlocked tile gets a warm tint and the
   companion bobs gently so the Plus/Pro perk feels alive; locked shows a padlocked egg. */
.profile-stat-pet.is-unlocked {
  background: rgba(245, 158, 11, 0.10);
  border-color: rgba(245, 158, 11, 0.28);
}
.profile-stat-pet.is-unlocked .profile-pet {
  animation: pet-bob 3s ease-in-out infinite;
}
@keyframes pet-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}
@media (prefers-reduced-motion: reduce) {
  .profile-stat-pet.is-unlocked .profile-pet { animation: none; }
}
.profile-pet-locked { position: relative; }
.profile-pet-dim { opacity: 0.45; filter: grayscale(0.35); }
.profile-pet-lock {
  position: absolute;
  left: 50%;
  top: 54%;
  transform: translate(-50%, -50%);
  font-size: 13px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.profile-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 18px 24px 10px;
}
.profile-section-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: #c8bfe0;
}
.profile-section-count { font-size: 11px; color: #8c84a8; }

.profile-empty {
  margin: 0 24px 24px;
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: #a59cc0;
  background: rgba(124, 58, 237, 0.08);
  border: 1px dashed rgba(124, 58, 237, 0.3);
  border-radius: 12px;
}
.profile-empty strong { color: #FFD700; }

.profile-artifacts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
  padding: 0 24px 12px;
}
/* Showcase strip: exactly one row of four - the profile stays fixed-height. */
.profile-showcase {
  grid-template-columns: repeat(4, 1fr);
  padding-bottom: 20px;
}
.profile-showcase-hint {
  padding: 0 24px 20px;
  font-size: 12px;
  color: #8c84a8;
}
.artifact-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(0,0,0,0.2));
  border: 1px solid;
  border-radius: 10px;
  transition: transform 0.12s ease-out, box-shadow 0.2s ease-out;
}
.artifact-tile:hover { transform: translateY(-2px); }
.artifact-glyph { font-size: 32px; line-height: 1; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5)); }
.artifact-name {
  font-size: 10px;
  text-align: center;
  color: #c8bfe0;
  line-height: 1.2;
}
.artifact-count {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  background: rgba(0,0,0,0.5);
  border-radius: 6px;
  padding: 1px 5px;
}

/* Per-tier rarity colours - borders, glows, legend dots */
.tier-common    { border-color: #b8c0cc; }
.tier-uncommon  { border-color: #4a90d9; }
.tier-rare      { border-color: #f0c419; }
.tier-epic      { border-color: #e8833a; }
.tier-legendary { border-color: #e0405a; }
.artifact-tile.tier-uncommon  { box-shadow: 0 0 14px rgba(74,144,217,0.3); }
.artifact-tile.tier-rare      { box-shadow: 0 0 16px rgba(240,196,25,0.35); }
.artifact-tile.tier-epic      { box-shadow: 0 0 18px rgba(232,131,58,0.4); }
.artifact-tile.tier-legendary { box-shadow: 0 0 22px rgba(224,64,90,0.5); }
.artifact-tile.artifact-tile-pinned { outline: 2px solid rgba(168,85,247,0.7); }

.profile-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 4px 24px 24px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: #8c84a8;
  letter-spacing: 0.04em;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid;
  background: transparent;
}
.legend-dot.tier-common    { background: #b8c0cc; }
.legend-dot.tier-uncommon  { background: #4a90d9; }
.legend-dot.tier-rare      { background: #f0c419; }
.legend-dot.tier-epic      { background: #e8833a; }
.legend-dot.tier-legendary { background: #e0405a; }

/* ============================================================
   v0.4.68: phone fit (80% of users are mobile). The card used to
   keep desktop paddings and the 4-up showcase at 375px - tiles
   squeezed to ~62px with truncated names, and 48px of overlay
   padding was pure waste. Reclaim width, relax the grids.
   ============================================================ */
@media (max-width: 480px) {
  .profile-overlay { padding: 12px; }
  .profile-card { max-height: calc(100dvh - 24px); }
  /* 44px hero count reads oversized on a ~350px card. */
  .hero-streak-count { font-size: 32px; }
  .profile-head { padding: 0 16px; gap: 12px; }
  .profile-stats { padding: 12px 16px; gap: 6px; }
  /* 4-up artifact showcase -> 2-up: full names, comfortable tap targets. */
  .profile-showcase { grid-template-columns: repeat(2, 1fr); }
}

