/* css/pages/achievements.css — TinkyTown SDR Achievements (full collection view)
 *
 * Companion to /js/views/achievements.js. Renders the trophy-case view
 * (stat row + 2-col grid of unlocked / locked cards) with the brand chrome
 * inherited from mission-engine.css + xp-dashboard.css.
 *
 * Brand tokens (canonical, per platform spec):
 *   --surface-deep #0d0b10 · --amber #e8a33d
 *   --green #22c55e · --green-soft #4ade80
 * Fonts: Fraunces (titles) · General Sans (body).
 *
 * Hard rules:
 *   - 44×44 min tap target on buttons (WCAG 2.5.5).
 *   - prefers-reduced-motion strips every animation / transition.
 *   - All colours via var(); raw hex only as token fallback (mirrors the
 *     pattern used in mission-card.css / xp-dashboard.css).
 *   - Color-blind safe: amber accent + 🏆 icon for unlocked cards;
 *     dimmed icon + 🔒 + crisp label for locked. Not colour-only.
 */

/* ── Root ────────────────────────────────────────────────────────────── */
.achievements-view {
  display: block;
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 18px;
  color: var(--text-primary, #f4f1ea);
  font-family: 'General Sans', system-ui, sans-serif;
}

/* ── Top toolbar (Back) ──────────────────────────────────────────────── */
.ach-toolbar {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.ach-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0.4rem 0.9rem;
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--text-muted, #ffffff) 22%, transparent);
  border-radius: 10px;
  color: var(--text-primary, #fff);
  font: 600 0.92rem/1 'General Sans', system-ui, sans-serif;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.ach-back:hover {
  border-color: color-mix(in srgb, var(--amber, #e8a33d) 45%, transparent);
  background: color-mix(in srgb, var(--amber, #e8a33d) 8%, transparent);
}

.ach-back:focus-visible {
  outline: 2px solid var(--amber, #e8a33d);
  outline-offset: 2px;
}

/* ── Header ──────────────────────────────────────────────────────────── */
.ach-header { margin: 0 0 18px; }

.ach-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 1.8rem;
  line-height: 1.15;
  margin: 0 0 4px;
  color: var(--text-primary, #fff);
}

.ach-subtitle {
  margin: 0;
  color: var(--text-muted, rgba(255, 255, 255, 0.7));
  font-size: 0.95rem;
  line-height: 1.45;
}

/* ── Stat row ────────────────────────────────────────────────────────── */
.ach-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 0 0 18px;
}

.ach-stat-card {
  padding: 14px 16px;
  background: color-mix(in srgb, var(--surface-deep, #0d0b10) 70%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber, #e8a33d) 22%, transparent);
  border-radius: 12px;
}

.ach-stat-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-muted, rgba(255, 255, 255, 0.6));
  margin-bottom: 4px;
}

.ach-stat-value {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 1.4rem;
  line-height: 1.2;
  color: var(--text-primary, #fff);
}

.ach-stat-sub {
  margin-top: 2px;
  font-size: 0.82rem;
  color: var(--text-muted, rgba(255, 255, 255, 0.6));
}

.ach-stat-bar {
  margin-top: 10px;
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-deep, #0d0b10) 55%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber, #e8a33d) 22%, transparent);
  overflow: hidden;
}

.ach-stat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg,
    var(--amber, #e8a33d),
    var(--green-soft, #4ade80));
  transition: width 320ms ease;
}

/* ── 2-column grid ───────────────────────────────────────────────────── */
.ach-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.ach-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: color-mix(in srgb, var(--surface-deep, #0d0b10) 60%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber, #e8a33d) 18%, transparent);
  border-radius: 14px;
}

.ach-col-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0 0 4px;
  color: var(--text-primary, #fff);
}

.ach-col-empty {
  margin: 0;
  padding: 12px 4px;
  color: var(--text-muted, rgba(255, 255, 255, 0.55));
  font-size: 0.9rem;
  line-height: 1.4;
}

/* ── Card (shared) ───────────────────────────────────────────────────── */
.ach-card {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--surface-deep, #0d0b10) 72%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber, #e8a33d) 20%, transparent);
  border-radius: 12px;
  transition: border-color 140ms ease, transform 140ms ease;
}

.ach-card:focus-visible {
  outline: 2px solid var(--amber, #e8a33d);
  outline-offset: 2px;
}

.ach-card:hover {
  border-color: color-mix(in srgb, var(--amber, #e8a33d) 45%, transparent);
}

.ach-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.35rem;
  line-height: 1;
  background: color-mix(in srgb, var(--amber, #e8a33d) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber, #e8a33d) 40%, transparent);
}

.ach-card-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ach-card-label {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
  margin: 0;
  color: var(--text-primary, #fff);
}

.ach-card-desc {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--text-muted, rgba(255, 255, 255, 0.72));
}

.ach-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.ach-card-xp {
  display: inline-block;
  padding: 0.14rem 0.6rem;
  background: color-mix(in srgb, var(--green-soft, #4ade80) 16%, transparent);
  color: var(--green-soft, #4ade80);
  border: 1px solid color-mix(in srgb, var(--green, #22c55e) 50%, transparent);
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

.ach-card-when {
  font-size: 0.82rem;
  color: var(--text-muted, rgba(255, 255, 255, 0.6));
}

/* ── Unlocked variant — amber accent + green-soft glow ───────────────── */
.ach-card-unlocked {
  border-color: color-mix(in srgb, var(--amber, #e8a33d) 50%, transparent);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--green-soft, #4ade80) 14%, transparent) inset;
}

/* ── Locked variant — grayed icon, hint copy ────────────────────────── */
.ach-card-locked {
  opacity: 0.78;
}

.ach-card-icon-locked {
  background: color-mix(in srgb, var(--surface-deep, #0d0b10) 60%, transparent);
  border-color: color-mix(in srgb, var(--text-muted, #ffffff) 22%, transparent);
  filter: grayscale(0.4);
}

.ach-card-hint {
  font-size: 0.86rem;
  color: var(--amber, #e8a33d);
  font-weight: 600;
}

.ach-card-xp-pending {
  background: color-mix(in srgb, var(--surface-deep, #0d0b10) 60%, transparent);
  color: var(--text-muted, rgba(255, 255, 255, 0.65));
  border-color: color-mix(in srgb, var(--text-muted, #ffffff) 22%, transparent);
}

/* ── Empty state (full-collection level) ─────────────────────────────── */
.ach-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 20px;
  text-align: center;
  background: color-mix(in srgb, var(--surface-deep, #0d0b10) 70%, transparent);
  border: 1px dashed color-mix(in srgb, var(--amber, #e8a33d) 35%, transparent);
  border-radius: 16px;
}

.ach-empty-icon { font-size: 2rem; line-height: 1; }

.ach-empty-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 1.25rem;
  margin: 0;
  color: var(--text-primary, #fff);
}

.ach-empty-text {
  max-width: 44ch;
  margin: 0;
  color: var(--text-muted, rgba(255, 255, 255, 0.72));
  font-size: 0.95rem;
  line-height: 1.5;
}

.ach-empty-cta {
  margin-top: 6px;
  min-height: 44px;
  padding: 0.55rem 1.1rem;
  background: var(--amber, #e8a33d);
  color: var(--surface-deep, #0d0b10);
  border: 1px solid var(--amber, #e8a33d);
  border-radius: 10px;
  font: 600 0.92rem/1 'General Sans', system-ui, sans-serif;
  cursor: pointer;
  transition: filter 120ms ease;
}
.ach-empty-cta:hover { filter: brightness(1.06); }
.ach-empty-cta:focus-visible {
  outline: 2px solid var(--amber, #e8a33d);
  outline-offset: 2px;
}

/* ── Error state ─────────────────────────────────────────────────────── */
.ach-error {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--amber, #e8a33d) 10%, transparent);
  border: 1px dashed color-mix(in srgb, var(--amber, #e8a33d) 40%, transparent);
  border-radius: 12px;
  color: var(--text-primary, #fff);
  font-size: 0.92rem;
}

.ach-error-icon {
  font-size: 1.1rem;
  color: var(--amber, #e8a33d);
}

.ach-error-retry {
  min-height: 44px;
  padding: 0.4rem 0.95rem;
  background: var(--amber, #e8a33d);
  color: var(--surface-deep, #0d0b10);
  border: 1px solid var(--amber, #e8a33d);
  border-radius: 10px;
  font: 600 0.9rem/1 'General Sans', system-ui, sans-serif;
  cursor: pointer;
}
.ach-error-retry:focus-visible {
  outline: 2px solid var(--green, #22c55e);
  outline-offset: 2px;
}

/* ── Skeleton (loading) ──────────────────────────────────────────────── */
.ach-skel-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ach-skel-loading {
  margin: 0;
  padding: 12px 0;
  color: var(--text-muted, rgba(255, 255, 255, 0.55));
  font-size: 0.92rem;
}

.ach-skel {
  background: color-mix(in srgb, var(--surface-deep, #0d0b10) 50%, transparent);
  border-color: color-mix(in srgb, var(--text-muted, #ffffff) 12%, transparent);
}

.ach-skel-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
}

.ach-skel-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 6px;
}

.ach-skel-row {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg,
    rgba(255, 255, 255, 0.06),
    rgba(255, 255, 255, 0.12),
    rgba(255, 255, 255, 0.06));
  background-size: 200% 100%;
  animation: ach-shimmer 1.8s ease-in-out infinite;
}

.ach-skel-line.wide  { width: 78%; }
.ach-skel-line.short { width: 46%; }

@keyframes ach-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Belt-and-braces: kill shimmer when the host hides itself. */
.ach-skel-row[hidden],
.ach-skel-row[aria-hidden="true"],
.ach-skel[hidden] .ach-skel-row,
.ach-skel[aria-hidden="true"] .ach-skel-row {
  animation: none !important;
}

/* ── prefers-reduced-motion: no shimmer, no transitions ──────────────── */
@media (prefers-reduced-motion: reduce) {
  .ach-skel-row { animation: none !important; }
  .ach-stat-bar-fill { transition: none !important; }
  .ach-card,
  .ach-back,
  .ach-empty-cta,
  .ach-error-retry { transition: none !important; }
}

/* ── Mobile: single column ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .ach-stats { grid-template-columns: 1fr; }
  .ach-grid { grid-template-columns: 1fr; }
  .ach-title { font-size: 1.5rem; }
  .achievements-view { margin: 16px auto; padding: 0 12px; }
}
