/* ==========================================================================
   pages/profile.css: the Profile (/me). Concept: design/eli/Concepts/profile.png.
   Owner: the profile page builder. Everything is scoped under .pg-profile except
   the one header rule at the bottom (the chosen face in the header avatar).
   ========================================================================== */

.pg-profile .pf { padding-top: var(--s-6); padding-bottom: var(--s-9); }
.pg-profile .pf-sec { margin-top: var(--s-7); }
.pg-profile .pf-sh { margin-bottom: 14px; }
.pg-profile .pf-sh .section-title { font-size: 24px; }
.pg-profile .pf-meta {
  display: block; margin: 0; font: 500 var(--fs-xs)/1.3 var(--font-label); letter-spacing: .16em;
  text-transform: uppercase; color: var(--text-2);
}

/* ---- head: avatar, handle, tagline, joined, Edit Profile ----------------- */
.pg-profile .pf-head { display: flex; align-items: center; gap: 30px; }
.pg-profile .pf-avatar {
  position: relative; flex: 0 0 124px; width: 124px; height: 124px; border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, hsl(var(--av) 45% 34%), hsl(var(--av) 40% 16%));
  box-shadow: 0 0 0 3px var(--mode-primary), 0 0 36px -8px rgba(var(--mode-rgb), .75);
}
.pg-profile .pf-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.pg-profile .pf-initial {
  display: grid; place-items: center; width: 100%; height: 100%;
  font: 800 52px/1 var(--font-ui); color: var(--text);
}
.pg-profile .pf-avatar-edit {
  position: absolute; right: -2px; bottom: -2px; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; color: var(--text);
  background: #121317; border: 2px solid var(--text); box-shadow: 0 2px 8px rgba(0, 0, 0, .5);
}
.pg-profile .pf-avatar-edit .i { width: 17px; height: 17px; }
.pg-profile .pf-avatar-edit:hover { border-color: var(--mode-highlight); color: var(--mode-highlight); }
.pg-profile .pf-id { flex: 1; min-width: 0; }
.pg-profile .pf-name {
  margin: 0; font: 800 40px/1.05 var(--font-ui); letter-spacing: -.02em; color: var(--text);
  overflow-wrap: anywhere;
}
.pg-profile .pf-tagline { margin: 8px 0 0; font-size: var(--fs-lg); color: #C9C9CF; }
.pg-profile .pf-add-tag {
  padding: 0; border: 0; background: none; font: inherit; color: var(--text-2); cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 4px;
}
.pg-profile .pf-add-tag:hover { color: var(--mode-highlight); }
.pg-profile .pf-joined { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; color: var(--text-2); font-size: var(--fs-sm); }
.pg-profile .pf-joined .i { width: 15px; height: 15px; }
.pg-profile .pf-edit { align-self: center; flex: 0 0 auto; min-height: 44px; padding: 0 22px; border-color: #C9C9CF; color: var(--text); }
.pg-profile .pf-edit .btn-icon .i { width: 18px; height: 18px; }

/* ---- stat tiles ---------------------------------------------------------- */
.pg-profile .pf-stats { list-style: none; margin: var(--s-6) 0 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.pg-profile .pf-stat {
  position: relative; display: flex; flex-direction: column; gap: 12px; padding: 18px 16px 16px;
  border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface);
}
.pg-profile .pf-stat-n { font: 700 34px/1 var(--font-display); color: var(--text); letter-spacing: .01em; }
.pg-profile .pf-stat-k { font: 500 var(--fs-xs)/1.2 var(--font-label); letter-spacing: .16em; text-transform: uppercase; color: #C9C9CF; }
.pg-profile .pf-stat-ic { position: absolute; top: 16px; right: 16px; color: #5E606A; }
.pg-profile .pf-stat-ic .i { width: 24px; height: 24px; }
.pg-profile .pf-stat.is-gold-ic .pf-stat-ic { color: var(--gold); }
.pg-profile .pf-stat.is-gold .pf-stat-n { color: var(--gold); }
.pg-profile .pf-stat.is-hot .pf-stat-n { color: var(--mode-primary); }
.pg-profile .pf-stat.is-flame .pf-stat-ic { color: #FF5A1F; }

/* ---- best ever board ------------------------------------------------------ */
.pg-profile .pf-best {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 26px; align-items: start;
  min-height: 148px; padding: 12px 14px; overflow: hidden;
  border-radius: var(--r-md); border: 1px solid rgba(var(--mode-rgb), .6); background: #16110C;
  box-shadow: 0 0 40px -18px rgba(var(--mode-rgb), .6);
}
.pg-profile .pf-best[data-tone="reruns"] { background: #0F1020; }
.pg-profile .pf-best-score {
  position: relative; z-index: 1; display: grid; place-items: center; align-content: center; width: 80px; height: 80px;
  border-radius: 6px; border: 2px solid var(--gold); background: linear-gradient(180deg, #F2C263, #E0A53B);
  color: #1A1206; box-shadow: 0 0 22px -6px rgba(244, 199, 122, .7);
}
.pg-profile .pf-best-score b { font: 700 38px/1 var(--font-display); }
.pg-profile .pf-best-score span { font: 500 11px/1 var(--font-label); letter-spacing: .1em; margin-top: 2px; }
.pg-profile .pf-best-main { position: relative; z-index: 1; min-width: 0; padding-top: 4px; }
.pg-profile .pf-best-title { margin: 0 0 6px; font: 700 var(--fs-lg)/1.2 var(--font-ui); }
.pg-profile .pf-best-crew { margin-top: 16px; gap: 7px; }
.pg-profile .pf-best-crew .portrait-chip { width: 58px; height: 64px; border-radius: 4px; flex-basis: 58px; font-size: 16px; }
.pg-profile .pf-best-art {
  position: absolute; inset: 0 0 0 42%; display: grid; place-items: center; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 90% at 62% 55%, rgba(var(--mode-rgb), .34), transparent 70%),
    linear-gradient(90deg, #16110C 0%, transparent 38%);
}
.pg-profile .pf-best[data-tone="reruns"] .pf-best-art { background: radial-gradient(ellipse 60% 90% at 62% 55%, rgba(var(--mode-rgb), .34), transparent 70%), linear-gradient(90deg, #0F1020 0%, transparent 38%); }
.pg-profile .pf-art-ic { color: rgba(var(--mode-rgb), .9); transform: translateX(10%); filter: drop-shadow(0 0 22px rgba(var(--mode-rgb), .65)); }
.pg-profile .pf-art-ic .i { width: 108px; height: 108px; }
.pg-profile .pf-best-go {
  position: absolute; z-index: 2; right: 14px; bottom: 18px; display: inline-flex; align-items: center; gap: 10px;
  min-height: 42px; padding: 0 20px; border-radius: 6px; border: 1px solid #C9C9CF; background: rgba(10, 10, 12, .72);
  color: var(--text); text-decoration: none; font: 600 var(--fs-xs)/1 var(--font-label); letter-spacing: .16em; text-transform: uppercase;
}
.pg-profile .pf-best-go .i { width: 16px; height: 16px; }
.pg-profile .pf-best-go:hover { border-color: var(--mode-highlight); color: var(--mode-highlight); }

/* ---- first discoveries --------------------------------------------------- */
.pg-profile .pf-finds { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.pg-profile .pf-find {
  position: relative; overflow: hidden; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface);
}
.pg-profile .pf-find::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--seat); z-index: 2; }
.pg-profile .pf-find-pic { position: relative; height: 92px; background: #0C0D10; }
.pg-profile .pf-find-pic img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 22%; display: block; filter: grayscale(1) contrast(1.08); }
.pg-profile .pf-find-mono {
  display: grid; place-items: center; width: 100%; height: 100%;
  font: 700 30px/1 var(--font-ui); color: rgba(255, 255, 255, .78);
  background: radial-gradient(circle at 50% 40%, hsl(var(--h) 26% 26%), hsl(var(--h) 22% 11%));
}
.pg-profile .pf-find-trophy { position: absolute; left: 14px; bottom: -2px; color: var(--gold); filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .7)); }
.pg-profile .pf-find-trophy .i { width: 22px; height: 22px; }
.pg-profile .pf-find-body { display: flex; flex-direction: column; gap: 3px; padding: 12px 12px 12px 14px; }
.pg-profile .pf-find-name { font: 700 var(--fs-md)/1.2 var(--font-ui); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-profile .pf-find-seat { font-size: var(--fs-sm); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-profile .pf-find-date { margin-top: 5px; font: 500 11px/1 var(--font-label); letter-spacing: .14em; color: var(--text-2); }

/* ---- achievements (tiles themselves: achievements.css) -------------------- */
.pg-profile .pf-count { font: 600 var(--fs-sm)/1 var(--font-ui); color: var(--mode-primary); }
.pg-profile .pf-wide {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 46px; margin-top: 14px;
  border-radius: var(--r-sm); border: 1px solid #3A3B43; background: transparent;
  color: var(--text); text-decoration: none; font: 600 var(--fs-md)/1 var(--font-ui);
}
.pg-profile .pf-wide .i { width: 18px; height: 18px; }
.pg-profile .pf-wide:hover { border-color: var(--mode-primary); color: var(--mode-highlight); }

/* ---- recent boards ------------------------------------------------------- */
.pg-profile .pf-recent { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pg-profile .pf-row {
  display: flex; align-items: center; gap: 16px; min-height: 56px; padding-right: 14px; overflow: hidden;
  border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface);
  color: inherit; text-decoration: none;
}
.pg-profile .pf-row:hover { border-color: var(--hover); background: #1D1E23; }
.pg-profile .pf-row-art {
  flex: 0 0 168px; align-self: stretch; display: grid; place-items: center; color: var(--mode-primary);
  background: radial-gradient(ellipse 70% 120% at 50% 60%, rgba(var(--mode-rgb), .26), transparent 70%), var(--mode-card);
  border-right: 1px solid var(--border);
}
.pg-profile .pf-row-art .i { width: 30px; height: 30px; filter: drop-shadow(0 0 10px rgba(var(--mode-rgb), .6)); }
.pg-profile .pf-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.pg-profile .pf-row-title { font: 600 var(--fs-md)/1.2 var(--font-ui); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-profile .pf-row-crew { gap: 5px; }
.pg-profile .pf-row-crew .portrait-chip { width: 30px; height: 38px; flex-basis: 30px; border-radius: 3px; font-size: 11px; }
.pg-profile .pf-row-score { flex: 0 0 52px; text-align: right; font: 700 26px/1 var(--font-display); }
.pg-profile .pf-row-chev { color: var(--text-2); display: grid; }
.pg-profile .pf-row-chev .i { width: 18px; height: 18px; }

/* ---- friends & leaderboard ----------------------------------------------- */
.pg-profile .pf-lb-head { align-items: center; flex-wrap: wrap; }
.pg-profile .pf-range .seg { background: transparent; border: 0; padding: 0; gap: 8px; }
.pg-profile .pf-range .seg button {
  min-width: 104px; min-height: 32px; border-radius: 4px; border: 1px solid var(--border); background: var(--surface);
  font: 500 var(--fs-sm)/1 var(--font-ui); color: var(--text-2);
}
.pg-profile .pf-range .seg button[aria-pressed="true"] {
  border-color: var(--mode-primary); color: var(--mode-highlight); background: rgba(var(--mode-rgb), .12);
  box-shadow: 0 0 14px -4px rgba(var(--mode-rgb), .6);
}
.pg-profile .pf-lb { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.pg-profile .pf-lb-card { display: grid; grid-template-columns: 1fr 1fr; align-items: start; padding: 28px 28px 26px; min-height: 164px; }
.pg-profile .pf-lb-score { border-left: 1px solid var(--border); padding-left: 28px; display: flex; flex-direction: column; }
.pg-profile .pf-lb-rank { display: flex; flex-direction: column; }
.pg-profile .pf-lb-k { font: 500 var(--fs-xs)/1.2 var(--font-label); letter-spacing: .16em; text-transform: uppercase; color: #C9C9CF; }
.pg-profile .pf-lb-k.is-top { margin-top: 18px; }
.pg-profile .pf-lb-big { margin-top: 10px; font: 700 64px/1 var(--font-display); color: var(--text); }
.pg-profile .pf-lb-big.is-none { color: var(--text-muted); }
.pg-profile .pf-lb-mid { margin-top: 10px; font: 700 30px/1 var(--font-display); color: var(--text); }
.pg-profile .pf-lb-of { margin-top: 6px; font-size: var(--fs-md); color: var(--text-2); }
.pg-profile .pf-lb-list { padding: 8px; }
.pg-profile .pf-lb-table { list-style: none; margin: 0; padding: 0; }
.pg-profile .pf-lb-row {
  display: flex; align-items: center; gap: 14px; min-height: 36px; padding: 2px 12px; border-radius: 6px; border: 1px solid transparent;
  font-size: var(--fs-sm);
}
.pg-profile .pf-lb-row + .pf-lb-row { margin-top: 1px; }
.pg-profile .pf-lb-row.is-me {
  border-color: var(--mode-primary); background: rgba(var(--mode-rgb), .12); box-shadow: 0 0 16px -6px rgba(var(--mode-rgb), .6);
  font-weight: 700;
}
.pg-profile .pf-lb-n { flex: 0 0 34px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pg-profile .pf-lb-row.is-me .pf-lb-n { color: var(--mode-primary); }
.pg-profile .pf-lb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-profile .pf-lb-pts { font: 700 var(--fs-md)/1 var(--font-ui); font-variant-numeric: tabular-nums; }
.pg-profile .avatar.is-face { overflow: hidden; padding: 0; }
.pg-profile .pf-lb .skel { border-radius: var(--r-md); }
.pg-profile .pf-foot { margin: var(--s-6) 0 0; font-size: var(--fs-sm); color: var(--text-2); text-align: center; }

/* ---- Edit Profile sheet (the sheet sits outside <main>, so it is not under .pg-profile) ---- */
.pf-sheet .sheet-title { margin: 0 0 var(--s-4); font: 800 var(--fs-xl)/1.1 var(--font-ui); }
.pf-form { display: grid; gap: var(--s-5); }
.pf-field { display: grid; gap: 6px; border: 0; margin: 0; padding: 0; min-width: 0; }
.pf-lbl { font: 500 var(--fs-xs)/1.2 var(--font-label); letter-spacing: .16em; text-transform: uppercase; color: #C9C9CF; padding: 0; }
.pf-hint { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--text-2); }
.pf-pic-now { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.pf-pic-prev {
  flex: 0 0 56px; width: 56px; height: 56px; border-radius: 50%; overflow: hidden; display: grid; place-items: center;
  font: 800 22px/1 var(--font-ui); background: hsl(var(--av) 40% 24%); box-shadow: 0 0 0 2px var(--mode-primary);
}
.pf-pic-prev img { width: 100%; height: 100%; object-fit: cover; }
.pf-pic-what { flex: 1; min-width: 0; font-weight: 600; }
.pf-faces { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.pf-face {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 4px; cursor: pointer;
  border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  font: 500 11px/1.2 var(--font-ui);
}
.pf-face img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; background: #0C0D10; }
.pf-face span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-face:hover { border-color: var(--hover); color: var(--text); }
.pf-face.is-on { border-color: var(--mode-primary); color: var(--text); box-shadow: 0 0 14px -4px rgba(var(--mode-rgb), .6); }
.pf-search { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pf-search .input { flex: 1 1 180px; min-width: 0; }
.pf-err { margin: 0; min-height: 1em; color: var(--red); font-size: var(--fs-sm); }
.pf-err:empty { display: none; }
.pf-sheet-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ---- tablet --------------------------------------------------------------- */
@media (max-width: 1000px) {
  .pg-profile .pf-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .pg-profile .pf-stat { grid-column: span 2; }
  .pg-profile .pf-stat:nth-child(n+4) { grid-column: span 3; }
  .pg-profile .pf-finds {
    grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 30%;
    overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; overscroll-behavior-x: contain;
  }
  .pg-profile .pf-finds.is-all { grid-auto-flow: row; grid-auto-columns: auto; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: visible; }
  .pg-profile .pf-find { scroll-snap-align: start; }
  .pg-profile .pf-row-art { flex-basis: 96px; }
  .pg-profile .pf-lb { grid-template-columns: 1fr; }
}

/* ---- phone ---------------------------------------------------------------- */
@media (max-width: 640px) {
  .pg-profile .pf { padding-top: var(--s-5); }
  .pg-profile .pf-sec { margin-top: var(--s-6); }
  .pg-profile .pf-head { flex-wrap: wrap; gap: 16px 18px; }
  .pg-profile .pf-avatar { flex-basis: 88px; width: 88px; height: 88px; }
  .pg-profile .pf-initial { font-size: 38px; }
  .pg-profile .pf-avatar-edit { width: 32px; height: 32px; }
  .pg-profile .pf-name { font-size: 30px; }
  .pg-profile .pf-tagline { font-size: var(--fs-md); }
  .pg-profile .pf-edit { flex: 1 0 100%; justify-content: center; }
  .pg-profile .pf-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .pg-profile .pf-stat, .pg-profile .pf-stat:nth-child(n+4) { grid-column: auto; }
  .pg-profile .pf-stat:last-child { grid-column: 1 / -1; }
  .pg-profile .pf-stat { padding: 14px; gap: 8px; }
  .pg-profile .pf-stat-n { font-size: 30px; }
  .pg-profile .pf-stat-k { font-size: 11px; letter-spacing: .12em; }
  .pg-profile .pf-stat-ic { top: 12px; right: 12px; }
  .pg-profile .pf-stat-ic .i { width: 20px; height: 20px; }
  .pg-profile .pf-sh .section-title { font-size: 20px; }
  .pg-profile .pf-best { grid-template-columns: auto minmax(0, 1fr); gap: 14px; padding: 12px 12px 68px; }
  .pg-profile .pf-best-score { width: 64px; height: 64px; }
  .pg-profile .pf-best-score b { font-size: 30px; }
  .pg-profile .pf-best-crew { gap: 5px; }
  .pg-profile .pf-best-crew .portrait-chip { width: 40px; height: 46px; flex-basis: 40px; }
  .pg-profile .pf-best-art { inset: 0 0 0 45%; }
  .pg-profile .pf-art-ic { display: none; }
  .pg-profile .pf-best-go { left: 12px; right: 12px; bottom: 12px; justify-content: center; }
  .pg-profile .pf-finds {
    grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 42%;
    overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; overscroll-behavior-x: contain;
  }
  .pg-profile .pf-finds.is-all { grid-auto-flow: row; grid-auto-columns: auto; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
  .pg-profile .pf-find { scroll-snap-align: start; }
  .pg-profile .pf-row { gap: 10px; padding-right: 8px; min-height: 64px; }
  .pg-profile .pf-row-art { flex-basis: 52px; }
  .pg-profile .pf-row-art .i { width: 24px; height: 24px; }
  .pg-profile .pf-row-crew { display: none; }
  .pg-profile .pf-row-score { flex-basis: 40px; font-size: 24px; }
  .pg-profile .pf-range { width: 100%; }
  .pg-profile .pf-range .seg { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; }
  .pg-profile .pf-range .seg button { min-width: 0; }
  .pg-profile .pf-lb-card { padding: 20px; gap: 0; }
  .pg-profile .pf-lb-score { padding-left: 20px; }
  .pg-profile .pf-lb-big { font-size: 52px; }
}

/* The chosen face in the site header's avatar (painted by pages/profile.js on every
   page). Global on purpose: the header is on every route, not only on /me. */
#site-header .hd-avatar.has-face .i, #site-header .hd-avatar.has-face .hd-initial { display: none; }
#site-header .hd-avatar .hd-face { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; padding: 3px; }
