/* =========================================================================
   Flopiq Stats Mockups — shared design system
   Tokens extracted verbatim from fc-app BlurpleColors.kt + BlurpleTypography.kt
   (chess.com-inspired warm dark palette: green + gold).
   All variant pages link this file so they look native + consistent.
   ========================================================================= */

:root {
  /* Backgrounds */
  --bg-page:      #262522;
  --bg-default:   #302E2B;
  --bg-elevated:  #3C3A37;
  --bg-card:      #3C3A37;
  --bg-highlight: rgba(255,255,255,0.06);

  /* Text */
  --text-primary:   #FFFFFF;
  --text-secondary: #BABABA;
  --text-muted:     #989898;
  --text-faint:     #757575;

  /* Border */
  --border: #484644;

  /* Accents */
  --accent:        #81B64C; /* chess.com green */
  --accent-gold:   #E8AC0A; /* chess.com gold  */
  --accent-warning:#F0D03E;
  --accent-subtle: rgba(129,182,76,0.22);
  --gold-subtle:   rgba(232,172,10,0.15);

  /* Profit / Loss */
  --profit-green:        #81B64C;
  --profit-green-subtle: rgba(129,182,76,0.15);
  --profit-red:          #E5533D;
  --profit-red-subtle:   rgba(229,83,61,0.15);

  /* Tier accent colors (from TierBadge.tierColor) */
  --tier-amateur: #989898;
  --tier-warrior: #CD7F32;
  --tier-grinder: #C0C0C0;
  --tier-crusher: #E8AC0A;
  --tier-legend:  #A259D9;

  /* Card suit colors (4-color deck) */
  --suit-h: #EF4444;
  --suit-d: #3B82F6;
  --suit-c: #22C55E;
  --suit-s: #FFFFFF;

  /* Shape */
  --r-card: 16px;
  --r-tile: 14px;
  --r-pill: 12px;
  --r-btn:  14px;

  --font: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { background: var(--bg-page); }

body {
  font-family: var(--font);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- phone frame (mobile-first: home screen maxWidth is 400dp) ---------- */
.screen {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg-page);
  padding: 16px 16px 96px;
  position: relative;
}

/* When embedded in the gallery iframe, no outer chrome needed */
.screen--framed { box-shadow: 0 24px 60px rgba(0,0,0,0.5); }

/* ---- generic surfaces -------------------------------------------------- */
.card {
  background: var(--bg-elevated);
  border-radius: var(--r-card);
  padding: 16px;
  border: 1px solid transparent;
}
.card--bordered { border-color: var(--border); }
.card--page { background: var(--bg-default); }

.section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 22px 4px 10px;
}
.section-label:first-child { margin-top: 4px; }

/* ---- app bar ----------------------------------------------------------- */
.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  margin-bottom: 8px;
}
.appbar h1 { font-size: 20px; font-weight: 800; letter-spacing: -0.3px; }
.appbar .appbar-sub { font-size: 11px; color: var(--text-faint); }
.icon-btn {
  width: 36px; height: 36px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--bg-elevated); color: var(--text-secondary);
  border: 1px solid var(--border); cursor: pointer; font-size: 16px;
}

/* ---- typography helpers ----------------------------------------------- */
.display-hero { font-size: 44px; font-weight: 700; line-height: 1.1; letter-spacing: -1px; }
.display-lg   { font-size: 32px; font-weight: 800; line-height: 1.15; letter-spacing: -0.5px; }
.display-md   { font-size: 24px; font-weight: 800; line-height: 1.2; }
.display-sm   { font-size: 20px; font-weight: 800; line-height: 1.3; }
.h-lg { font-size: 17px; font-weight: 600; }
.h-md { font-size: 16px; font-weight: 600; }
.body { font-size: 13px; font-weight: 400; color: var(--text-secondary); }
.body-sm { font-size: 11px; color: var(--text-muted); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.tabular { font-variant-numeric: tabular-nums; }

.pos { color: var(--profit-green); }
.neg { color: var(--profit-red); }
.profit { font-size: 18px; font-weight: 800; letter-spacing: -0.3px; font-variant-numeric: tabular-nums; }

/* ---- avatar ------------------------------------------------------------ */
.avatar {
  border-radius: 50%;
  background: var(--bg-default);
  object-fit: cover;
  flex: none;
  border: 2px solid var(--border);
}
.avatar--ring { border-color: var(--accent); }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -10px; border: 2px solid var(--bg-elevated); }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---- tier badge (real app rank emblems, drawable PNGs) ------------------ */
/* Uses the exact tier_*.png assets shipped in fc-app (composeResources/drawable).
   Rendered as a contained background in a square box (matches the app's
   Image + ContentScale.Fit). Any inner fallback letter is hidden. */
.tier {
  display: inline-block;
  width: 28px; height: 28px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  flex: none;
  vertical-align: middle;
  font-size: 0;          /* hide any inner letter fallback */
  color: transparent;
  line-height: 0;
}
.tier[data-tier="amateur"] { background-image: url(assets/tier_amateur.png); }
.tier[data-tier="warrior"] { background-image: url(assets/tier_warrior.png); }
.tier[data-tier="grinder"] { background-image: url(assets/tier_grinder.png); }
.tier[data-tier="crusher"] { background-image: url(assets/tier_crusher.png); }
.tier[data-tier="legend"]  { background-image: url(assets/tier_legend.png); }
.tier--lg { width: 48px; height: 48px; }
.tier--sm { width: 24px; height: 24px; }

.tier-name { font-size: 11px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; }
.tier-name[data-tier="amateur"] { color: var(--tier-amateur); }
.tier-name[data-tier="warrior"] { color: var(--tier-warrior); }
.tier-name[data-tier="grinder"] { color: var(--tier-grinder); }
.tier-name[data-tier="crusher"] { color: var(--tier-crusher); }
.tier-name[data-tier="legend"]  { color: var(--tier-legend); }

/* ---- XP progress bar --------------------------------------------------- */
.xpbar { height: 6px; border-radius: 3px; background: var(--bg-page); overflow: hidden; }
.xpbar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* ---- pills ------------------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 700;
  background: var(--bg-page); color: var(--text-secondary);
}
.pill--win  { background: var(--profit-green-subtle); color: var(--profit-green); }
.pill--loss { background: var(--profit-red-subtle); color: var(--profit-red); }
.pill--gold { background: var(--gold-subtle); color: var(--accent-gold); }
.pill--accent { background: var(--accent-subtle); color: var(--accent); }
.pill--ghost { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }

/* ---- buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--r-btn);
  font-size: 14px; font-weight: 700;
  background: var(--bg-elevated); color: var(--text-primary);
  border: 1px solid var(--border); cursor: pointer; transition: filter .12s, transform .08s;
}
.btn:active { transform: scale(0.98); }
.btn:hover { filter: brightness(1.08); }
.btn--primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn--gold { background: var(--accent-gold); color: #1c1b19; border-color: transparent; }
.btn--block { width: 100%; }
.btn--sm { padding: 7px 12px; font-size: 12px; border-radius: 10px; }

/* ---- segmented control (tabs) ----------------------------------------- */
.segmented {
  display: flex; gap: 4px; padding: 4px;
  background: var(--bg-default); border-radius: 12px;
  border: 1px solid var(--border);
}
.segmented .seg {
  flex: 1; text-align: center; padding: 8px 6px; border-radius: 9px;
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  cursor: pointer; user-select: none; transition: background .15s, color .15s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.segmented .seg[aria-selected="true"] { background: var(--bg-elevated); color: var(--text-primary); box-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.seg .seg-ico { font-size: 13px; }

/* tab content visibility */
[data-tab-panel] { display: none; }
[data-tab-panel].is-active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---- stat tiles -------------------------------------------------------- */
.tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile-grid--3 { grid-template-columns: 1fr 1fr 1fr; }
.tile {
  background: var(--bg-elevated); border-radius: var(--r-tile);
  padding: 12px 14px; border: 1px solid transparent;
}
.tile-label { font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); white-space: nowrap; }
.tile .tile-value { font-size: 22px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile .tile-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* aligned multi-column stat header: labels top-align, values share a baseline */
.statline { display: flex; gap: 14px; align-items: flex-start; }
.statline .stat { flex: 1 1 0; min-width: 0; }
.statline .stat-label { font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); white-space: nowrap; }
.statline .stat-val { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 3px; line-height: 1.15; }
.statline .stat-val.lg { font-size: 24px; }
.statline .stat-val.sm { font-size: 17px; }
.statline.right-vals { text-align: right; }

/* ---- rows / list ------------------------------------------------------- */
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: none; }
.row .grow { flex: 1; min-width: 0; }
.row .row-title { font-size: 14px; font-weight: 600; }
.row .row-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.row-rank { width: 22px; text-align: center; font-weight: 800; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.row--me { background: var(--accent-subtle); border-radius: 10px; border-bottom-color: transparent; padding-left: 8px; padding-right: 8px; }
/* the "You" row shows a full rank like #142 — let it size to content so the
   trailing digit isn't clipped by the avatar (the fixed-width 22px column is
   only meant for single-digit leaderboard ranks). */
.row--me .row-rank { width: auto; white-space: nowrap; padding-right: 2px; }

.divider { height: 1px; background: var(--border); margin: 12px 0; }

/* ---- progress (cracked-bot meter etc) --------------------------------- */
.meter { height: 7px; border-radius: 4px; background: var(--bg-page); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.meter--gold > span { background: var(--accent-gold); }

/* ---- mini cards (playing cards) --------------------------------------- */
.cards { display: inline-flex; gap: 3px; }
.pcard {
  width: 22px; height: 30px; border-radius: 4px; background: #fff; color: #111;
  display: grid; place-items: center; font-weight: 800; font-size: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.pcard[data-s="h"] { color: var(--suit-h); }
.pcard[data-s="d"] { color: var(--suit-d); }
.pcard[data-s="c"] { color: var(--suit-c); }
.pcard[data-s="s"] { color: #111; }

/* ---- sparkline / chart container -------------------------------------- */
.chart { width: 100%; height: 64px; display: block; }
.chart-lg { height: 120px; }

/* ---- modal (compare) --------------------------------------------------- */
.modal-scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: none; align-items: flex-end; justify-content: center; z-index: 50;
  padding: 0;
}
.modal-scrim.is-open { display: flex; }
.modal {
  width: 100%; max-width: 420px; background: var(--bg-default);
  border-radius: 20px 20px 0 0; padding: 20px 16px 28px;
  border-top: 1px solid var(--border);
  animation: sheet .22s cubic-bezier(.2,.8,.2,1);
  max-height: 86vh; overflow-y: auto;
}
@keyframes sheet { from { transform: translateY(100%); } to { transform: none; } }
.modal-grab { width: 36px; height: 4px; border-radius: 2px; background: var(--border); margin: -6px auto 14px; }

/* ---- compare table ----------------------------------------------------- */
.cmp { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.cmp .cmp-stat { padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cmp .cmp-mid { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); text-align: center; border-bottom: 1px solid var(--border); padding: 9px 6px; }
.cmp .cmp-l { text-align: right; }
.cmp .cmp-r { text-align: left; }
.cmp .win { color: var(--accent); }

/* ---- utility ----------------------------------------------------------- */
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mb-4 { margin-bottom: 4px; } .mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.mt-10 { margin-top: 10px; } .mt-20 { margin-top: 20px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
