/* ==========================================================================
   achievements.php — tokens from DESIGN.md
   ========================================================================== */
.ach-page,
.ach-drawer {
  --primary: oklch(0.46 0.19 270);
  --primary-deep: oklch(0.36 0.17 270);
  --ink: oklch(0.18 0.01 270);
  --ink-body: oklch(0.40 0.015 270);
  --muted: oklch(0.52 0.015 270);
  --bg: oklch(1 0 0);
  --surface: oklch(0.96 0.006 270);
  --border: oklch(0.88 0.008 270);
  --danger-text: oklch(0.4 0.2 25);

  font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--ink);
}

.ach-page *,
.ach-drawer * { box-sizing: border-box; }

.ach-page h1,
.ach-page h2,
.ach-drawer h2,
.ach-drawer h3 { margin: 0; color: var(--ink); }

/* ---- Header ---- */
.ach-head { margin-bottom: 24px; }

.ach-head h1 {
  font-size: clamp(1.75rem, 3.5vw, 2.75rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.ach-summary { margin: 8px 0 0; color: var(--muted); font-size: 0.8125rem; }
.ach-summary a { color: var(--primary); }

/* ---- Profile showcase ---- */
.ach-showcase {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  margin-bottom: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.ach-showcase h2 { font-size: 1rem; font-weight: 600; }
.ach-showcase p { margin: 2px 0 0; color: var(--ink-body); font-size: 0.8125rem; }

.ach-slots { display: flex; gap: 8px; }

.ach-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  font: inherit;
  cursor: pointer;
}

.ach-slot.is-empty { border-style: dashed; cursor: default; background: transparent; }
.ach-slot:hover:not(.is-empty) { border-color: var(--primary); }
.ach-slot-img { width: 100%; height: 100%; object-fit: contain; }

.ach-title-pick {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
}

.ach-title-pick select {
  min-width: 0;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font: 400 0.9375rem/1.3 Inter, -apple-system, BlinkMacSystemFont, sans-serif;
}

.ach-title-pick select:focus-visible { outline: none; border-color: var(--primary); }

.ach-error { flex-basis: 100%; margin: 0; color: var(--danger-text); font-size: 0.8125rem; }

/* ---- Category filter ---- */
.ach-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

.ach-filter {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  font: 600 0.8125rem/1.3 Inter, -apple-system, BlinkMacSystemFont, sans-serif;
  cursor: pointer;
}

.ach-filter[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---- Grid ---- */
.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.ach-empty { color: var(--ink-body); }

.ach-card {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.ach-card[hidden] { display: none; }
.ach-card:hover { border-color: var(--primary); }
.ach-card:focus-visible,
.ach-filter:focus-visible,
.ach-pin:focus-visible,
.ach-slot:focus-visible,
.ach-drawer-close:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.ach-card-img { flex: none; width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; }
.ach-card-img img { width: 100%; height: 100%; object-fit: contain; }
.ach-card.is-locked .ach-card-img { opacity: 0.35; }

.ach-card-body { flex: 1; min-width: 0; padding-right: 24px; }
.ach-card-name { font-size: 0.9375rem; font-weight: 600; line-height: 1.25; }
.ach-card-tier { margin: 2px 0 6px; color: var(--muted); font-size: 0.8125rem; }
.ach-card-progress { margin: 4px 0 0; color: var(--ink-body); font-size: 0.8125rem; }

/* Placeholder when a tier's image hasn't been uploaded yet */
.ach-blank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80%;
  height: 80%;
  border-radius: 50%;
  background: var(--border);
  color: var(--muted);
  font-weight: 700;
}

.ach-bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.ach-bar span { display: block; height: 100%; background: var(--primary); }

.ach-pin {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  padding: 5px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.ach-pin svg { width: 100%; height: 100%; fill: currentColor; }
.ach-pin:hover:not(:disabled) { background: var(--border); color: var(--ink); }
.ach-pin[aria-pressed="true"] { background: var(--primary); color: #fff; }
.ach-pin:disabled { opacity: 0.3; cursor: not-allowed; }

/* ---- Detail slider ---- */
.ach-no-scroll { overflow: hidden; }

.ach-scrim {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(20, 16, 40, 0.35);
}

.ach-scrim[hidden] { display: none; }

.ach-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 10001;
  box-sizing: border-box;
  width: min(420px, 100%);
  overflow-y: auto;
  padding: 24px;
  background: var(--bg);
  box-shadow: 0 12px 32px rgba(20, 16, 40, 0.18);
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform 0.25s ease, visibility 0s linear 0.25s;
}

.ach-drawer.is-open {
  transform: none;
  visibility: visible;
  transition: transform 0.25s ease;
}

@media (prefers-reduced-motion: reduce) {
  .ach-drawer, .ach-drawer.is-open { transition: none; }
}

.ach-drawer-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  padding: 6px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.ach-drawer-close svg { width: 100%; height: 100%; fill: currentColor; }
.ach-drawer-close:hover { background: var(--surface); color: var(--ink); }

.ach-loading { color: var(--ink-body); }

.ach-detail-head { display: flex; gap: 16px; align-items: center; padding-right: 32px; }
.ach-detail-img { flex: none; width: 96px; height: 96px; object-fit: contain; }
.ach-detail-img.is-locked { opacity: 0.35; }
.ach-detail-cat { margin: 0; color: var(--muted); font-size: 0.8125rem; font-weight: 600; }
.ach-drawer h2 { font-size: 1.25rem; font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; }
.ach-detail-desc { margin: 4px 0 0; color: var(--ink-body); }

.ach-detail-progress { margin: 20px 0 16px; }
.ach-detail-progress p { margin: 6px 0 0; color: var(--ink-body); font-size: 0.8125rem; }

.ach-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 24px; }
.ach-stats div { padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.ach-stats dt { color: var(--muted); font-size: 0.8125rem; }
.ach-stats dd { margin: 2px 0 0; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.ach-drawer h3 { margin: 0 0 8px; font-size: 1rem; font-weight: 600; }

.ach-tiers,
.ach-lb { list-style: none; margin: 0 0 24px; padding: 0; }

.ach-tier {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.ach-tier:last-child { border-bottom: none; }
.ach-tier-img { flex: none; width: 64px; height: 64px; object-fit: contain; }
.ach-tier.is-locked .ach-tier-img { opacity: 0.35; }
.ach-tier-text { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 0.8125rem; }
.ach-tier-text strong { font-size: 0.9375rem; font-weight: 600; }
.ach-tier-text > span { color: var(--muted); }
.ach-tier-title { color: var(--ink-body); font-style: italic; }
.ach-tier-own {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  color: var(--ink-body);
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ach-tier-own small { color: var(--muted); font-size: 0.75rem; font-weight: 400; }

.ach-lb-row {
  display: grid;
  grid-template-columns: 24px 32px 1fr 28px auto;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
}

.ach-lb-row.is-you { background: var(--surface); outline: 1px solid var(--border); }
.ach-lb-rank { color: var(--muted); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

.ach-lb-ava {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--surface);
  background-size: 150%;
  background-position: top;
}

.ach-lb-name { color: var(--ink); font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ach-lb-name:hover { color: var(--primary); }
.ach-lb-tier { width: 28px; height: 28px; object-fit: contain; font-size: 0.75rem; }
.ach-lb-progress { font-weight: 600; font-variant-numeric: tabular-nums; }
.ach-lb-empty { color: var(--ink-body); }

@media (max-width: 480px) {
  .ach-drawer { padding: 20px 16px; }
  .ach-showcase { flex-direction: column; align-items: flex-start; }
  .ach-grid { grid-template-columns: 1fr; }
}
