/* ══════════════════════════════════════════════════════
   TSSR QCM · Components (JS-injected)
   auth menu · toasts · bug report · leaderboard · profil · achievements
   ══════════════════════════════════════════════════════ */

/* ─── Nav quick links (auth.js injecte) ─── */
.nav-quick-links {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.nav-quick-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--line);
  background: var(--surf-3);
  color: var(--ink-2);
  transition: all var(--t-sm) var(--ease-out);
  white-space: nowrap;
}
.nav-quick-link:hover {
  background: var(--surf-2);
  border-color: var(--line-2);
  color: var(--ink);
  opacity: 1;
}
.nav-quick-link--bits {
  background: rgba(34, 211, 238, .06);
  border-color: rgba(34, 211, 238, .2);
  color: #22d3ee;
}
.nav-quick-link--bits:hover {
  background: rgba(34, 211, 238, .12);
  border-color: rgba(34, 211, 238, .4);
  color: #22d3ee;
}

/* ─── Auth widget menu ─── */
.auth-widget--menu {
  position: relative;
  padding: 0;
  background: none;
  border: 0;
}
.auth-widget--menu[open] { z-index: 200; }

.auth-widget-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 11px;
  border-radius: 999px;
  background: var(--surf-3);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  transition: all var(--t-sm) var(--ease-out);
}
.auth-widget-button::-webkit-details-marker { display: none; }
.auth-widget-button:hover {
  background: var(--surf-2);
  border-color: var(--line-2);
  color: var(--ink);
}
.auth-widget-button svg { width: 15px; height: 15px; flex-shrink: 0; }
.auth-pseudo { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.auth-bits-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: .72rem;
  font-family: 'JetBrains Mono', monospace;
}
.auth-chevron { width: 12px !important; height: 12px !important; opacity: .6; transition: transform var(--t-sm) ease; }
.auth-widget--menu[open] .auth-chevron { transform: rotate(180deg); }

.auth-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px;
  border-radius: var(--r-md);
  background: var(--surf-grad);
  border: 1px solid var(--line-2);
  box-shadow: var(--sh-lg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  animation: fadeUp 180ms var(--ease-spring) both;
  z-index: 300;
}
[data-theme="dark"] .auth-menu { background: linear-gradient(160deg, #1c1330, #160f26); }
[data-theme="light"] .auth-menu { background: #fff; }

.auth-menu a,
.auth-menu button {
  display: block;
  text-align: left;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: .86rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--t-xs) ease;
  width: 100%;
}
.auth-menu a:hover,
.auth-menu button:hover {
  background: var(--accent-soft);
  color: var(--accent);
  opacity: 1;
}
.auth-menu button[data-auth-logout] {
  margin-top: 4px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  color: var(--muted);
}
.auth-menu button[data-auth-logout]:hover { background: var(--fb-err); color: var(--danger); }

/* Lien admin discret au-dessus du logout */
.auth-menu a.auth-menu-admin {
  margin-top: 4px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-style: italic;
  font-size: .82rem;
}
.auth-menu a.auth-menu-admin:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ─── Toasts achievement ─── */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast-achievement {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--r-lg);
  background: var(--surf-grad);
  border: 1px solid var(--accent);
  box-shadow: var(--sh-lg), 0 0 0 1px var(--accent-soft);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  min-width: 280px;
  max-width: 340px;
  animation: toastIn 400ms var(--ease-spring) both, toastOut 400ms ease 3.6s forwards;
}
[data-theme="dark"] .toast-achievement { background: linear-gradient(160deg, #221636, #1a1129); }
[data-theme="light"] .toast-achievement { background: #fff; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(120%) scale(.9); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(120%) scale(.9); }
}

.toast-icon {
  width: 44px; height: 44px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 1.6rem;
}
.toast-icon svg { width: 28px; height: 28px; }
.toast-title { font-size: .92rem; font-weight: 700; color: var(--ink); margin-bottom: 2px; }
.toast-desc { font-size: .78rem; color: var(--muted); line-height: 1.4; }

/* ─── Bug report ─── */
#bug-report-btn {
  position: fixed;
  bottom: 20px; right: 20px;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: var(--surf-grad);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  font-size: 1.3rem;
  cursor: pointer;
  z-index: 900;
  box-shadow: var(--sh);
  transition: all var(--t-sm) var(--ease-spring);
}
[data-theme="dark"] #bug-report-btn { background: #1a1228; }
[data-theme="light"] #bug-report-btn { background: #fff; }
#bug-report-btn:hover { transform: translateY(-3px) scale(1.08) rotate(-8deg); box-shadow: var(--sh-lg); }

#bug-report-overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(13, 8, 18, .6);
  backdrop-filter: blur(6px);
}
#bug-report-overlay.open { display: flex; animation: fadeUp 200ms ease both; }

#bug-report-panel {
  width: min(460px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  border-radius: var(--r-xl);
  background: var(--surf-grad);
  border: 1px solid var(--line-2);
  box-shadow: var(--sh-lg);
  padding: 24px;
  backdrop-filter: blur(24px);
}
[data-theme="dark"] #bug-report-panel { background: linear-gradient(160deg, #1a1228, #140e20); }
[data-theme="light"] #bug-report-panel { background: #fff; }

.br-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.br-title { font-size: 1.05rem; font-weight: 700; }
.br-close {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surf-3);
  color: var(--muted); cursor: pointer; font-size: .9rem;
  transition: all var(--t-sm) ease;
}
.br-close:hover { background: var(--fb-err); color: var(--danger); border-color: rgba(248,113,113,.3); }

.br-label { display: block; margin: 14px 0 6px; font-size: .82rem; font-weight: 700; color: var(--ink-2); }
.br-req { color: var(--accent); }
.br-opt { color: var(--muted); font-weight: 500; font-size: .75rem; }

#bug-form input[type="text"],
#bug-form textarea {
  width: 100%;
  padding: 10px 13px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--line);
  background: var(--surf-2);
  color: var(--ink);
  font: inherit;
  font-size: .9rem;
  outline: none;
  transition: all var(--t-sm) ease;
  resize: vertical;
}
#bug-form input:focus,
#bug-form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.br-screenshot-zone {
  border: 1.5px dashed var(--line-2);
  border-radius: var(--r-md);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--t-sm) ease;
  position: relative;
}
.br-screenshot-zone:hover { border-color: var(--accent); }
.br-ss-placeholder { color: var(--muted); font-size: .84rem; }
#br-ss-preview { max-width: 100%; max-height: 180px; border-radius: var(--r-sm); margin: 0 auto; }
.br-ss-clear {
  margin-top: 8px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surf-3);
  color: var(--muted); font-size: .78rem; cursor: pointer;
}
.br-auto-info { margin: 12px 0 0; font-size: .72rem; color: var(--muted); line-height: 1.4; word-break: break-all; }

.br-actions { display: flex; gap: 8px; margin-top: 18px; }
.br-submit {
  flex: 1;
  padding: 11px; border-radius: 999px; border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff; font-weight: 700; font-size: .9rem; cursor: pointer;
  transition: all var(--t-sm) var(--ease-spring);
}
.br-submit:hover { transform: translateY(-2px); box-shadow: 0 8px 20px var(--accent-soft); }
.br-submit:disabled { opacity: .6; cursor: default; transform: none; }
.br-cancel {
  padding: 11px 20px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surf-3);
  color: var(--ink-2); font-weight: 600; font-size: .9rem; cursor: pointer;
}
.br-cancel:hover { border-color: var(--line-2); color: var(--ink); }
.br-feedback { margin: 12px 0 0; padding: 10px 13px; border-radius: var(--r-md); font-size: .85rem; font-weight: 500; }
.br-feedback[data-tone="success"] { background: var(--fb-ok); color: var(--success); }
.br-feedback[data-tone="error"] { background: var(--fb-err); color: var(--danger); }

/* ─── Leaderboard table ─── */
.lb-table-wrapper { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--line); }
.lb-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.lb-table thead th {
  text-align: left;
  padding: 13px 16px;
  font-size: .7rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
  background: var(--surf-3);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.lb-table tbody tr {
  border-bottom: 1px solid var(--line);
  transition: background var(--t-sm) ease;
}
.lb-table tbody tr:last-child { border-bottom: 0; }
.lb-table tbody tr:hover { background: var(--surf-3); }
.lb-table td { padding: 12px 16px; vertical-align: middle; }

.lb-rank {
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: var(--muted);
  font-size: 1rem;
}
.lb-top-1 .lb-rank { color: #fbbf24; }
.lb-top-2 .lb-rank { color: #cbd5e1; }
.lb-top-3 .lb-rank { color: #d97706; }
.lb-top-1 { background: linear-gradient(90deg, rgba(251,191,36,.08), transparent); }
.lb-top-2 { background: linear-gradient(90deg, rgba(203,213,225,.06), transparent); }
.lb-top-3 { background: linear-gradient(90deg, rgba(217,119,6,.06), transparent); }

.lb-pseudo { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--ink); }
.lb-avatar-wrap {
  width: 32px; height: 32px; border-radius: 50%;
  overflow: hidden; flex-shrink: 0;
  border: 1.5px solid var(--line-2);
  display: flex; align-items: center; justify-content: center;
  background: var(--surf);
}
.lb-avatar-img { width: 100%; height: 100%; object-fit: cover; }
.lb-avatar-fallback { width: 18px; height: 18px; color: var(--muted); }

.bits-col { text-align: right; }
.bits-value {
  font-weight: 700;
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
}
.badge-count {
  display: inline-flex;
  align-items: center; justify-content: center;
  min-width: 26px; padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700; font-size: .8rem;
}

#lb-activity-list {
  display: flex; flex-direction: column; gap: 6px; margin-top: 12px;
}

/* ─── Profile strip ─── */
.profile-strip {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 24px;
  margin-bottom: 18px;
  border-radius: var(--r-xl);
  background: var(--surf-grad);
  border: 1px solid var(--line);
  box-shadow: var(--sh);
  backdrop-filter: blur(20px);
  position: relative;
  overflow: hidden;
}
.profile-strip::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent 60%);
}

.avatar-wrap {
  position: relative;
  width: 76px; height: 76px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  flex-shrink: 0;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.avatar-img { width: 100%; height: 100%; object-fit: cover; }
.avatar-fallback {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surf-2); color: var(--muted);
}
.avatar-fallback svg { width: 38px; height: 38px; }
.avatar-hover-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(13,8,18,.55);
  color: #fff;
  opacity: 0;
  transition: opacity var(--t-sm) ease;
}
.avatar-hover-overlay svg { width: 24px; height: 24px; }
.avatar-wrap:hover .avatar-hover-overlay { opacity: 1; }

.profile-info { display: flex; flex-direction: column; gap: 3px; }
.profile-name { font-size: 1.4rem; font-weight: 800; letter-spacing: -.02em; }
.profile-sub { font-size: .82rem; color: var(--muted); font-weight: 600; letter-spacing: .04em; }
.profile-bits {
  margin-top: 4px;
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 700; color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
}
.bits-icon-lg { font-size: 1.1rem; }

.profil-form { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.profil-form .field input {
  width: 100%; padding: 11px 15px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--line);
  background: var(--surf-2); color: var(--ink);
  font-size: .95rem; outline: none;
  transition: all var(--t-sm) ease;
}
.profil-form .field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ─── Achievements grid (profil) ─── */
#achievements-grid.achievements-grid,
.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.achievement-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 14px;
  border-radius: var(--r-lg);
  background: var(--surf-3);
  border: 1px solid var(--line);
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: all var(--t-md) var(--ease-spring);
}
.achievement-card:hover { transform: translateY(-4px); border-color: var(--line-2); box-shadow: var(--sh); }
.achievement-card.locked { opacity: .55; }
.achievement-card.locked .ach-medallion { filter: grayscale(1); opacity: .4; }

.ach-medallion {
  width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--accent-soft), transparent 70%), var(--surf-2);
  border: 2px solid var(--accent-soft);
}
.ach-icon { font-size: 2rem; line-height: 1; }
.ach-icon svg { width: 34px; height: 34px; }
.ach-lock {
  position: absolute; top: 10px; right: 10px;
  color: var(--muted); opacity: .7;
}
.ach-lock svg { width: 16px; height: 16px; }
.ach-body { display: flex; flex-direction: column; gap: 4px; }
.ach-label { font-size: .88rem; font-weight: 700; color: var(--ink); }
.ach-desc { font-size: .74rem; color: var(--muted); line-height: 1.45; }
.ach-sep { height: 1px; background: var(--line); margin: 6px 0; }
.ach-riddle { font-size: .72rem; color: var(--ink-2); font-style: italic; line-height: 1.4; }
.ach-date { font-size: .68rem; color: var(--muted); margin-top: 4px; }

/* ─── Responsive ─── */
@media (max-width: 640px) {
  .auth-menu { right: auto; left: 0; }
  #toast-container { left: 12px; right: 12px; top: 12px; }
  .toast-achievement { min-width: 0; max-width: none; }
  .profile-strip { flex-direction: column; text-align: center; }
  .lb-table { font-size: .82rem; }
  .lb-table td, .lb-table th { padding: 10px 12px; }
}
