/* PopDex UI — drop-in primitives. Framework-agnostic; pairs with popdex-ui.tokens.json.
   Load Manrope 400–800 and JetBrains Mono 400–700 before this file. */

:root {
  --bg: #0b0b0d;
  --panel: #141518;
  --panel-2: #1b1c20;
  --line: #26272c;
  --line-2: #34363c;
  --text: #f4f4f6;
  --muted: #a0a3a7;
  --dim: #6c6f75;
  --brand: #4d42fc;
  --brand-hover: #645aff;
  --brand-soft: #8077ff;
  --brand-tint: #bdb9ff;
  --brand-deep: #201c5c;
  --success: #17a781;
  --success-light: #5fd1b3;
  --error: #f03277;
  --warning: #f5c46b;
  --ring: 0 0 0 3px rgba(128, 119, 255, 0.28);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-sans: 'Manrope', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; }

/* ---------- backdrop ---------- */
.pd-backdrop {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 48px 48px;
}
.pd-backdrop::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(40% 45% at 38% 42%, rgba(77, 66, 252, 0.22), transparent 70%),
    radial-gradient(30% 35% at 66% 60%, rgba(100, 90, 255, 0.16), transparent 70%),
    radial-gradient(22% 25% at 58% 30%, rgba(240, 50, 119, 0.07), transparent 70%),
    radial-gradient(35% 35% at 100% 100%, rgba(100, 90, 255, 0.10), transparent 70%),
    linear-gradient(180deg, rgba(11,11,13,0.1), rgba(11,11,13,0.85));
}

/* ---------- glass card + bokeh ---------- */
.pd-card {
  position: relative; overflow: hidden;
  border-radius: 22px;
  background: rgba(20, 21, 26, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 30px 90px -30px rgba(77, 66, 252, 0.35),
    0 24px 48px -24px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  padding: 28px 28px 26px;
}
.pd-card > *:not(.pd-bokeh) { position: relative; z-index: 1; }
.pd-card--success { border-color: rgba(23, 167, 129, 0.40); box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 30px 90px -30px rgba(23,167,129,0.35), 0 24px 48px -24px rgba(0,0,0,0.7); }
.pd-card--error { border-color: rgba(240, 50, 119, 0.35); box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 30px 90px -30px rgba(240,50,119,0.30), 0 24px 48px -24px rgba(0,0,0,0.7); }
.pd-card--rule { border-color: rgba(23, 167, 129, 0.42); background: linear-gradient(180deg, rgba(23,167,129,0.10), rgba(20,21,26,0.55) 60%); }

.pd-bokeh { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: inherit; z-index: 0; }
.pd-bokeh span {
  position: absolute; border-radius: 50%;
  filter: blur(var(--blur, 18px));
  background: radial-gradient(circle, var(--c1) 0%, var(--c2) 55%, transparent 72%);
  animation: pd-bokeh var(--t, 12s) ease-in-out infinite alternate;
  animation-delay: var(--delay, 0s);
  will-change: transform;
}
.pd-bokeh span:nth-child(1) { --c1: rgba(128,119,255,0.32); --c2: rgba(77,66,252,0.10); --blur: 34px; --t: 14s; width: 260px; height: 260px; left: -70px; top: -110px; }
.pd-bokeh span:nth-child(2) { --c1: rgba(189,185,255,0.22); --c2: rgba(128,119,255,0.06); --blur: 18px; --t: 11s; --delay: -4s; width: 120px; height: 120px; left: 60%; top: -70px; }
.pd-bokeh span:nth-child(3) { --c1: rgba(100,90,255,0.28); --c2: rgba(77,66,252,0.08); --blur: 30px; --t: 16s; --delay: -7s; width: 220px; height: 220px; right: -80px; bottom: -100px; }
.pd-bokeh span:nth-child(4) { --c1: rgba(240,50,119,0.14); --c2: rgba(240,50,119,0.03); --blur: 26px; --t: 13s; --delay: -2s; width: 140px; height: 140px; right: -40px; top: 40%; }
.pd-bokeh span:nth-child(5) { --c1: rgba(189,185,255,0.20); --c2: rgba(128,119,255,0.05); --blur: 14px; --t: 9s; --delay: -5s; width: 70px; height: 70px; left: -20px; bottom: 6%; }
.pd-card--success .pd-bokeh span:nth-child(1), .pd-card--rule .pd-bokeh span:nth-child(1) { --c1: rgba(23,167,129,0.34); --c2: rgba(23,167,129,0.08); }
.pd-card--success .pd-bokeh span:nth-child(3), .pd-card--rule .pd-bokeh span:nth-child(3) { --c1: rgba(95,209,179,0.26); --c2: rgba(23,167,129,0.06); }
.pd-card--success .pd-bokeh span:nth-child(4), .pd-card--rule .pd-bokeh span:nth-child(4) { --c1: rgba(23,167,129,0.16); --c2: rgba(23,167,129,0.03); }
@keyframes pd-bokeh {
  0% { transform: translate(0, 0) scale(1); opacity: 0.85; }
  50% { opacity: 1; }
  100% { transform: translate(28px, 20px) scale(1.1); opacity: 0.8; }
}

/* ---------- typography ---------- */
.pd-display { font-size: clamp(28px, 4vw, 44px); font-weight: 700; line-height: 1.15; letter-spacing: -0.015em; }
.pd-display em { font-style: normal; color: var(--brand-soft); }
.pd-title { font-size: clamp(22px, 2.4vw, 25px); font-weight: 700; line-height: 1.25; letter-spacing: -0.015em; }
.pd-subtitle { font-size: 19px; font-weight: 700; letter-spacing: -0.015em; }
.pd-body { font-size: 15px; line-height: 1.55; color: var(--muted); }
.pd-caption { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); }
.pd-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.pd-stat { font-family: var(--font-mono); font-size: 24px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.pd-kbd { font: inherit; font-size: 12px; border: 1px solid var(--line-2); border-radius: 5px; padding: 2px 6px; background: var(--panel-2); }

/* ---------- pills & chips ---------- */
.pd-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--brand-tint);
  background: rgba(128, 119, 255, 0.14);
  border: 1px solid rgba(128, 119, 255, 0.28);
  border-radius: 6px; padding: 3px 7px; line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.pd-pill--muted { color: var(--dim); background: transparent; border-color: var(--line-2); }
.pd-pill--success { color: var(--success); background: rgba(23,167,129,0.12); border-color: rgba(23,167,129,0.35); }
.pd-pill--error { color: var(--error); background: rgba(240,50,119,0.12); border-color: rgba(240,50,119,0.35); }
.pd-code {
  font-family: var(--font-mono); font-size: 0.9em;
  color: var(--brand-tint); background: rgba(128,119,255,0.14);
  border: 1px solid rgba(128,119,255,0.3); border-radius: 6px; padding: 1px 6px;
}
.pd-code--green { color: var(--success-light); background: rgba(23,167,129,0.14); border-color: rgba(23,167,129,0.4); }

/* ---------- buttons ---------- */
.pd-btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 0; border-radius: 12px;
  background: var(--brand); color: #fff;
  font-weight: 700; font-size: 15px; padding: 12px 22px;
  cursor: pointer; text-decoration: none;
  box-shadow: 0 8px 24px -10px rgba(77, 66, 252, 0.8);
  transition: background 160ms ease, transform 120ms ease, opacity 160ms ease, box-shadow 160ms ease;
}
.pd-btn:hover { background: var(--brand-hover); box-shadow: 0 10px 28px -10px rgba(100, 90, 255, 0.9); }
.pd-btn:active { transform: translateY(1px); }
.pd-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.pd-btn:disabled { opacity: 0.6; cursor: default; }
.pd-btn--sm { padding: 9px 16px; font-size: 14px; }
.pd-btn--ghost { background: transparent; color: var(--muted); box-shadow: none; border: 1px solid var(--line-2); }
.pd-btn--ghost:hover { color: #fff; border-color: var(--brand-soft); background: rgba(77, 66, 252, 0.08); }

/* ---------- inputs ---------- */
.pd-input {
  width: 100%;
  background: rgba(14, 14, 18, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 12px; padding: 14px 16px;
  font-size: 17px; font-weight: 500; line-height: 1.4; color: var(--text);
  outline: none; resize: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.pd-input::placeholder { color: var(--dim); font-weight: 400; }
.pd-input:hover { border-color: #45474e; }
.pd-input:focus { border-color: var(--brand-soft); box-shadow: var(--ring); background: rgba(14, 14, 18, 0.75); }
.pd-input--mono { font-family: var(--font-mono); font-size: 16px; letter-spacing: 0.01em; }
.pd-error { margin-top: 12px; color: var(--error); font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 8px; }

/* ---------- choice / option row ---------- */
.pd-choice {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.10); background: rgba(14, 14, 18, 0.45);
  cursor: pointer; text-align: left; font-size: 16px; font-weight: 600;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}
.pd-choice:hover { border-color: var(--brand-soft); }
.pd-choice.is-selected { border-color: var(--brand-soft); background: rgba(77, 66, 252, 0.16); }
.pd-key { width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid var(--line-2); border-radius: 6px; font-size: 11px; font-weight: 700; color: var(--muted); }
.pd-choice.is-selected .pd-key { border-color: var(--brand-soft); color: #fff; background: var(--brand); }

/* ---------- segmented switch ---------- */
.pd-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(14,14,18,0.55); border: 1px solid rgba(255,255,255,0.08); }
.pd-seg button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 9px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); text-align: left; cursor: pointer; transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease; }
.pd-seg button.is-active { background: rgba(77,66,252,0.18); color: #fff; box-shadow: inset 0 0 0 1px rgba(128,119,255,0.45); }
.pd-seg .label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.pd-seg .value { font-family: var(--font-mono); font-size: 15px; font-weight: 700; }
.pd-seg button.is-active .value { color: var(--brand-tint); }

/* ---------- hairline progress ---------- */
.pd-track { height: 4px; border-radius: 999px; background: rgba(255,255,255,0.08); overflow: hidden; }
.pd-fill { position: relative; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-soft)); box-shadow: 0 0 12px rgba(128,119,255,0.7); transition: width 800ms var(--ease); }
.pd-fill--green { background: linear-gradient(90deg, #128a6a, #17a781 60%, #5fd1b3); box-shadow: 0 0 12px rgba(23,167,129,0.7); }
.pd-fill--shimmer::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.45), transparent); background-size: 60px 100%; background-repeat: no-repeat; animation: pd-shimmer 2.6s ease-in-out infinite; }
@keyframes pd-shimmer { 0% { background-position: -60px 0; } 100% { background-position: calc(100% + 60px) 0; } }

/* ---------- header / footer ---------- */
.pd-header { display: flex; align-items: center; justify-content: space-between; padding: 26px 36px 0; }
.pd-brand { display: flex; align-items: center; gap: 10px; }
.pd-brand img { height: 24px; width: auto; display: block; }
.pd-brand .section { font-size: 15px; font-weight: 600; color: var(--brand-soft); letter-spacing: 0.01em; padding-top: 2px; }
.pd-counter { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--dim); letter-spacing: 0.06em; font-variant-numeric: tabular-nums; }
.pd-counter b { color: var(--text); font-weight: 700; }
.pd-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 28px 36px; }

/* ---------- toast ---------- */
.pd-toast {
  display: inline-flex; align-items: center; gap: 14px;
  padding: 10px 12px 10px 16px; border-radius: 999px; font-size: 13px; color: var(--text);
  background: rgba(22, 23, 28, 0.7); border: 1px solid rgba(128, 119, 255, 0.35);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px -10px rgba(77, 66, 252, 0.5);
  animation: pd-rise 400ms var(--ease) both; white-space: nowrap;
}
.pd-toast button { border: 0; border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 700; background: rgba(128,119,255,0.18); color: var(--brand-tint); cursor: pointer; }
.pd-toast button:hover { background: var(--brand); color: #fff; }

/* ---------- motion ---------- */
.pd-rise { animation: pd-rise 600ms var(--ease) both; }
@keyframes pd-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

@media (max-width: 640px) {
  .pd-card { padding: 20px 18px 18px; }
  .pd-header { padding: 20px 20px 0; }
  .pd-brand img { height: 20px; }
  .pd-brand .section { font-size: 13px; }
  .pd-footer { padding: 24px 20px; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  .pd-bokeh span, .pd-rise, .pd-toast, .pd-fill--shimmer::after { animation: none; }
  .pd-fill { transition: none; }
}
