/* ============================================================================
   px-base.css — Piplix base layer: typography, resets, core components.
   Canonical source: PIPLIX_DESIGN_GUIDELINE.md §3 (Typography), §6 (Core
   Components), §15 (Naming Conventions).
   REQUIRES px-tokens.css to be loaded first (it provides every --px-* value).
   Rules below reference tokens only — no hardcoded value that a token covers.
   Mobile-first; the only breakpoints are §2.9 (480 / 768 / 1024 / 1280).
   ============================================================================ */

/* ---- §3 Type families + type scale tokens ---------------------------- */
:root {
  --px-font-sans: 'BR Hendrix', system-ui, -apple-system, sans-serif;
  --px-font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace; /* numbers, prices */

  /* Type scale (rem @ 16px root) as `font` shorthand tokens: weight size/line family.
     Mirrors the §3 table exactly. */
  --px-text-display: 800 2rem/2.5rem      var(--px-font-sans);  /* 32 / 40 */
  --px-text-h1:      700 1.75rem/2.25rem  var(--px-font-sans);  /* 28 / 36 */
  --px-text-h2:      700 1.375rem/1.875rem var(--px-font-sans); /* 22 / 30 */
  --px-text-h3:      600 1.125rem/1.625rem var(--px-font-sans); /* 18 / 26 */
  --px-text-body:    400 1rem/1.5rem      var(--px-font-sans);  /* 16 / 24 */
  --px-text-body-sm: 400 0.875rem/1.25rem var(--px-font-sans);  /* 14 / 20 */
  --px-text-caption: 500 0.75rem/1rem     var(--px-font-sans);  /* 12 / 16 */
}

/* ---- Base resets (for the new component layer) ----------------------- */
*, *::before, *::after { box-sizing: border-box; }

/* Alpine: hide x-cloak elements until Alpine initializes (prevents the streak
   modal / other x-show overlays from flashing on load). */
[x-cloak] { display: none !important; }

/* Opt-in base: applies wherever this stylesheet is loaded. Page background +
   default body type. Existing pages do not load this bundle, so they are
   unaffected (parallel build). */
.px-ui,
body.px-ui {
  font: var(--px-text-body);
  color: var(--px-ink-700);
  background: var(--px-surface-50);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- §3 Type scale utility classes ----------------------------------- */
/* §3 rules: headings → ink-900, body → ink-700, secondary → ink-500. */
.px-text-display { font: var(--px-text-display); color: var(--px-ink-900); letter-spacing: -0.01em; }
.px-text-h1      { font: var(--px-text-h1);      color: var(--px-ink-900); letter-spacing: -0.01em; }
.px-text-h2      { font: var(--px-text-h2);      color: var(--px-ink-900); }
.px-text-h3      { font: var(--px-text-h3);      color: var(--px-ink-900); }
.px-text-body    { font: var(--px-text-body);    color: var(--px-ink-700); }
.px-text-body-sm { font: var(--px-text-body-sm); color: var(--px-ink-500); }
.px-text-caption { font: var(--px-text-caption); color: var(--px-ink-500); }

/* Optional numeric/price treatment (§3: mono is allowed for numbers/prices). */
.px-text-mono { font-family: var(--px-font-mono); font-variant-numeric: tabular-nums; }

/* Shared visible focus ring (§14: --px-info, 2px, never outline:none-without-replacement). */
.px-btn:focus-visible,
.px-input:focus-visible,
.px-chip:focus-visible {
  outline: 2px solid var(--px-info);
  outline-offset: 1px;
}

/* ============================================================================
   §6.1 BUTTONS — fully implemented.
   Shape: pill. Height 52px (mobile touch) → 48px (desktop). One primary/screen.
   ============================================================================ */
.px-btn {
  /* structure */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--px-space-2);
  min-height: 52px;                       /* mobile touch target (§6.1) */
  padding: 0 var(--px-space-6);           /* min horizontal padding (§6.1) */
  border: 1px solid transparent;
  border-radius: var(--px-radius-pill);   /* signature pill (§2.5/§6.1) */
  /* type */
  font: var(--px-text-body);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  /* motion (§10) — color only; never changes shape/size on hover */
  transition: background-color var(--px-dur-fast) var(--px-ease-out),
              border-color var(--px-dur-fast) var(--px-ease-out),
              color var(--px-dur-fast) var(--px-ease-out),
              box-shadow var(--px-dur-fast) var(--px-ease-out);
}
@media (min-width: 1024px) {              /* --px-bp-lg : desktop */
  .px-btn { min-height: 48px; }
}

/* Disabled (§6.1): surface-200 fill, ink-400 text, no shadow. */
.px-btn:disabled,
.px-btn[aria-disabled="true"],
.px-btn.is-disabled {
  background: var(--px-surface-200);
  color: var(--px-ink-400);
  border-color: transparent;
  box-shadow: none;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary — the single main action on a screen. */
.px-btn--primary {
  background: var(--px-brand);
  color: var(--px-brand-on);
  border-color: var(--px-brand);
}
.px-btn--primary:hover  { background: var(--px-brand-hover);  border-color: var(--px-brand-hover); color:var(--px-surface-0);}   /* lifts one step (§6.1) */
.px-btn--primary:active  { background: var(--px-brand-active); border-color: var(--px-brand-active);color:var(--px-surface-0); }

/* Secondary — alternative action. */
.px-btn--secondary {
  background: var(--px-surface-0);
  color: var(--px-ink-700);
  border-color: var(--px-ink-300);
}
.px-btn--secondary:hover  { background: var(--px-surface-100); }

/* Success — "Correct → Continue" state only. */
.px-btn--success {
  background: var(--px-success);
  color: var(--px-brand-on);
  border-color: var(--px-success);
}

/* Danger — "Incorrect → Continue" state only. */
.px-btn--danger {
  background: var(--px-error);
  color: var(--px-brand-on);
  border-color: var(--px-error);
}

/* Ghost — tertiary/text actions. */
.px-btn--ghost {
  background: transparent;
  color: var(--px-brand);
  border-color: transparent;
}
.px-btn--ghost:hover  { background: var(--px-brand-subtle); }

/* Full-width helper (mobile reward/onboarding bottom CTA, §6.1). */
.px-btn--block { width: 100%; }

/* ============================================================================
   §6.2 CARDS — fully implemented (base + --level + --row).
   ============================================================================ */
.px-card {
  background: var(--px-surface-0);
  border-radius: var(--px-radius-lg);
  box-shadow: var(--px-shadow-card);      /* resting (§2.6) */
  padding: var(--px-space-6);
}

/* Level card (Learn home): larger radius, hero treatment. */
.px-card--level {
  border-radius: var(--px-radius-xl);
  padding: var(--px-space-6);
}
/* Illustration panel inside a level card (§6.2: brand-subtle / info-subtle). */
.px-card--level .px-card__media {
  border-radius: var(--px-radius-lg);
  background: var(--px-brand-subtle);
  padding: var(--px-space-6);
}

/* List row (inner level page, leaderboard, news list). */
.px-card--row {
  border-radius: var(--px-radius-md);
  padding: var(--px-space-4);
  transition: box-shadow var(--px-dur-fast) var(--px-ease-out);
}
.px-card--row:hover { box-shadow: var(--px-shadow-md); }   /* lift on hover (§6.2) */

/* ============================================================================
   §6.4 INPUTS & FORMS — fully implemented.
   ============================================================================ */
.px-field { display: block; }
.px-label {
  display: block;
  margin-bottom: var(--px-space-1);
  font: var(--px-text-body-sm);
  color: var(--px-ink-500);               /* label above field (§6.4) */
}
.px-input {
  display: block;
  width: 100%;
  min-height: 48px;                       /* 44–48px (§6.4) */
  padding: var(--px-space-2) var(--px-space-3);
  font: var(--px-text-body);
  color: var(--px-ink-900);
  background: var(--px-surface-0);
  border: 1px solid var(--px-surface-200);
  border-radius: var(--px-radius-sm);
  transition: border-color var(--px-dur-fast) var(--px-ease-out),
              box-shadow var(--px-dur-fast) var(--px-ease-out);
}
.px-input::placeholder { color: var(--px-ink-400); }
.px-input:focus {
  border-color: var(--px-info);
  box-shadow: 0 0 0 2px var(--px-info-subtle);   /* focus ring --px-info @ 2px (§6.4) */
  outline: none;
}
/* Error state (§6.4): error border + caption message below. */
.px-input.is-error,
.px-input[aria-invalid="true"] { border-color: var(--px-error); }
.px-input.is-error:focus { box-shadow: 0 0 0 2px var(--px-error-subtle); }
.px-field__error {
  margin-top: var(--px-space-1);
  font: var(--px-text-caption);
  color: var(--px-error);
}

/* ============================================================================
   §6.5 PROGRESS BARS — fully implemented.
   Track surface-200, fill brand (player) / bamboo (level) / info (achievement),
   height 8px, fully rounded.
   ============================================================================ */
.px-progress {
  width: 100%;
  height: 8px;
  background: var(--px-info-brand-subtle);
  border-radius: var(--px-radius-pill);
  overflow: hidden;
}
.px-progress__fill {
  height: 100%;
  width: 0%;                              /* set inline / via JS */
  background: var(--px-brand);            /* default = player progress (§6.5) */
  border-radius: var(--px-radius-pill);
  transition: width var(--px-dur-base) var(--px-ease-out);
}
.px-progress--level .px-progress__fill { background: var(--px-info-brand); }  /* level / mastery */
.px-progress--info  .px-progress__fill { background: var(--px-info); }    /* achievement */

/* ============================================================================
   §6.3 CHIPS / TAGS / COUNTERS — documented stub (scaffold only).
   TODO(rebuild): pill, --px-text-caption, padding space-1 × space-3; asset-class
   chips use a muted palette (NOT feedback colors); HUD counters = icon + number.
   ============================================================================ */
.px-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--px-space-1);
  padding: var(--px-space-1) var(--px-space-3);
  font: var(--px-text-caption);
  color: var(--px-ink-700);
  background: var(--px-surface-100);
  border-radius: var(--px-radius-pill);
  /* variants (asset-class muted palette, HUD counter) — pending build */
}

/* ============================================================================
   §6.6 MODALS & SHEETS — documented stubs (scaffold only).
   TODO(rebuild): desktop modal = centered, radius-lg, shadow-lg, scrim
   --px-overlay, max-width 480px; mobile sheet = bottom, rounded-top radius-lg,
   drag handle, slides up. Close: top-left in player, top-right standalone (§7).
   ============================================================================ */
.px-modal {
  background: var(--px-surface-0);
  border-radius: var(--px-radius-lg);
  box-shadow: var(--px-shadow-lg);
  z-index: var(--px-z-modal);
  /* layout/scrim/sizing — pending build */
}
.px-sheet {
  background: var(--px-surface-0);
  border-top-left-radius: var(--px-radius-lg);
  border-top-right-radius: var(--px-radius-lg);
  box-shadow: var(--px-shadow-lg);
  z-index: var(--px-z-modal);
  /* drag handle, slide-up transition — pending build */
}

/* ---- Plus paywall (player deep-link gate) -------------------------------- */
.px-paywall { max-width: 560px; margin: 40px auto 80px; padding: 0 18px; }
.px-paywall__back {
  display: inline-block;
  margin-bottom: var(--px-space-4, 16px);
  color: var(--px-text-muted, #8A8A85);
  font-size: 0.8125rem;
  text-decoration: none;
}
.px-paywall__back:hover { color: var(--px-brand, #F26B1D); }
.px-paywall__hero { text-align: center; }
.px-paywall__chip { margin-bottom: var(--px-space-3, 12px); }
.px-paywall__hero .px-btn--block { margin-top: var(--px-space-4, 16px); }
.px-paywall__price { margin-top: var(--px-space-2, 8px); }
.px-paywall__bullets { margin-top: var(--px-space-4, 16px); }
.px-paywall__bullets ul { list-style: none; padding: 0; margin: var(--px-space-3, 12px) 0 0; }
.px-paywall__bullets li {
  display: flex; gap: 10px; padding: var(--px-space-2, 8px) 0;
  font-size: 0.875rem;
}
.px-paywall__bullets li::before { content: "✓"; color: var(--px-bamboo, #5DBB30); font-weight: 800; }

/* ---- Dashboard: Streak Saver pill (§8.3) -------------------------------- */
.px-saverpill {
  padding: var(--px-space-2, 8px) var(--px-space-3, 12px);
  background: var(--px-bamboo-subtle, #EAF6E3);
  border: 1px solid var(--px-bamboo, #5DBB30);
  border-radius: var(--px-radius-md, 10px);
}
.px-saverpill__count { color: var(--px-bamboo-hover, #4FA528); }
.px-saverpill__hint  { color: var(--px-text-muted, #6B7280); opacity: .8; font-size: 11px; }

/* ---- Dashboard: Trader Battles coming-soon card (§9.4) ------------------ */
.px-battles {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: var(--px-space-6, 24px);
  margin-bottom: var(--px-space-5, 20px);
  border-radius: var(--px-radius-lg, 12px);
  background: var(--px-ink-900, #0D1B3E);
  color: var(--px-brand-on, #FFFFFF);
}
.px-battles__glyph { position: absolute; top: -20px; right: -20px; font-size: 100px; opacity: .06; }
.px-battles__badge {
  display: inline-block;
  padding: 2px 12px;
  margin-bottom: var(--px-space-2, 8px);
  border-radius: var(--px-radius-pill, 999px);
  background: var(--px-brand-subtle, rgba(242,107,29,.18));
  color: var(--px-brand, #F26B1D);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
}
.px-battles__title { color: var(--px-brand-on, #FFF); font-weight: 800; margin-bottom: 4px; }
.px-battles__sub { color: var(--px-ink-300, #9CA3AF); font-size: .875rem; line-height: 1.5; margin-bottom: var(--px-space-4, 16px); }
.px-battles__stats { display: flex; gap: var(--px-space-6, 24px); justify-content: center; margin-bottom: var(--px-space-4, 16px); }
.px-battles__num { display: block; color: var(--px-brand-on, #FFF); font-weight: 800; font-size: 1.25rem; }
.px-battles__lbl { font-size: 10px; color: var(--px-ink-300, #9CA3AF); }
.px-battles__foot { font-size: 11px; color: var(--px-ink-300, #9CA3AF); margin: 0; }

/* Honor reduced motion (§10 / §14). */
@media (prefers-reduced-motion: reduce) {
  .px-btn, .px-card--row, .px-input, .px-progress__fill { transition: none; }
}

.page-wrapper.learn-v2 .pxl-glossary {
    max-width: 1080px;
    margin: 0 auto;
    padding-block: 3rem;
    padding-inline: 1rem;
}