/* ==========================================================================
   StudySkewl — global gamification layer (topbar chip, XP fly-ups, celebration
   toasts + overlay) and shared gamify bits used by practice pages.
   Prefix: gm-  (adaptive.css owns the older g-* classes — don't collide).
   ========================================================================== */

.gm-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- topbar chip ---------- */
.gm-chip-wrap { position: relative; display: flex; align-items: center; margin-right: 4px; }
.gm-chip {
  display: inline-flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px 0 4px;
  border-radius: 999px; text-decoration: none; color: #e7e9f5;
  background: linear-gradient(145deg, rgba(255,255,255,.06), rgba(255,255,255,.025));
  border: 1px solid rgba(148,163,184,.2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
  transition: border-color .2s, background .2s, box-shadow .25s, transform .2s var(--ease, ease);
}
.gm-chip:hover, .gm-chip:focus-visible { border-color: rgb(var(--accent) / .5); background: rgba(255,255,255,.07); box-shadow: 0 0 0 3px rgb(var(--accent) / .12), 0 10px 26px -14px rgb(var(--accent) / .7); outline: none; }
.gm-chip.gm-bump { animation: gmBump .55s var(--ease, ease); }
.gm-ring-svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.gm-ring-bg { fill: none; stroke: rgba(255,255,255,.1); }
.gm-ring-fg { fill: none; stroke-linecap: round; transition: stroke-dashoffset .8s var(--ease, ease); }

.gm-chip-lvl { position: relative; width: 32px; height: 32px; display: grid; place-items: center; flex: none; }
.gm-chip-lvl .gm-ring-bg, .gm-chip-lvl .gm-ring-fg { stroke-width: 3.2; }
.gm-chip-lvl .gm-ring-fg { stroke: rgb(var(--accent)); filter: drop-shadow(0 0 3px rgb(var(--accent) / .7)); }
.gm-chip-lvl::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: radial-gradient(circle at 30% 25%, rgb(var(--accent) / .55), rgb(var(--accent-2) / .25) 70%); box-shadow: inset 0 1px 0 rgba(255,255,255,.25); }
.gm-chip-lvl b { position: relative; font: 700 .74rem/1 "Space Grotesk", Inter, sans-serif; color: #fff; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

.gm-chip-streak { display: inline-flex; align-items: center; gap: 3px; font: 700 .82rem/1 Inter, sans-serif; color: #fdba74; font-variant-numeric: tabular-nums; }
.gm-chip-streak svg { color: #fb923c; filter: drop-shadow(0 0 5px rgba(251,146,60,.65)); }
.gm-chip-streak.cold { color: #8792ab; }
.gm-chip-streak.cold svg { color: #64748b; filter: none; }

.gm-chip-goal { position: relative; width: 18px; height: 18px; display: grid; place-items: center; flex: none; }
.gm-chip-goal .gm-ring-bg, .gm-chip-goal .gm-ring-fg { stroke-width: 2.6; }
.gm-chip-goal .gm-ring-fg { stroke: #22d3ee; }
.gm-chip-goal .gm-goal-check { position: relative; width: 10px; height: 10px; color: #0b0d19; opacity: 0; transform: scale(.4); transition: all .3s var(--ease, ease); stroke-width: 3.5; }
.gm-chip-goal.met .gm-ring-fg { stroke: #4ade80; }
.gm-chip-goal.met::before { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 8px rgba(74,222,128,.7); }
.gm-chip-goal.met .gm-goal-check { opacity: 1; transform: none; }

/* tooltip */
.gm-tip {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 95; width: 250px; padding: 12px 14px;
  border-radius: 14px; background: rgba(16,19,40,.97); border: 1px solid rgba(203,213,225,.2);
  box-shadow: 0 24px 50px -18px rgba(0,0,0,.9); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  font-size: .76rem; color: #c6cee0; pointer-events: none; opacity: 0; transform: translateY(-4px); transition: opacity .18s, transform .18s var(--ease, ease);
}
.gm-tip:empty { display: none; }
body.gm-tip-open .gm-tip { z-index: 217; }
body.gm-tip-open .gm-toasts { transform: translateY(var(--gm-tip-h, 190px)); }
.gm-tip.show { opacity: 1; transform: none; }
.gm-tip-xp { font: 700 1.05rem/1.1 "Space Grotesk", Inter, sans-serif; color: #fcd34d; }
.gm-tip-parts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.gm-tip-parts span, .gm-bd span { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 99px; font-size: .68rem; font-weight: 650; color: #fde68a; background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.25); white-space: nowrap; }
.gm-tip-parts span.mult, .gm-bd span.mult { color: #fdba74; background: rgba(249,115,22,.12); border-color: rgba(249,115,22,.35); }
.gm-tip-sep { height: 1px; margin: 10px 0; background: rgba(148,163,184,.15); }
.gm-tip-row { display: flex; justify-content: space-between; gap: 10px; }
.gm-tip-row.mt { margin-top: 8px; }
.gm-tip-row b { color: #f1f5f9; font-variant-numeric: tabular-nums; }
.gm-tip-bar { height: 5px; margin-top: 6px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.gm-tip-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, rgb(var(--accent)), rgb(var(--accent-2))); }

/* ---------- XP fly-up ---------- */
.gm-fly {
  position: fixed; z-index: 230; pointer-events: none; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 99px;
  font: 700 .82rem/1 "Space Grotesk", Inter, sans-serif; color: #1a1205; white-space: nowrap;
  background: linear-gradient(135deg, #fde68a, #f59e0b); box-shadow: 0 8px 22px -6px rgba(245,158,11,.75);
  animation: gmFly 1.8s cubic-bezier(.2,.8,.2,1) forwards;
}
.gm-fly svg { width: 13px; height: 13px; }

/* ---------- celebration toasts ---------- */
.gm-toasts { transition: transform .3s var(--ease, ease); position: fixed; top: calc(var(--topbar-h, 68px) + 12px); right: 20px; z-index: 215; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.gm-toast {
  --gm-c: #a78bfa; position: relative; overflow: hidden; pointer-events: auto;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 13px; align-items: start; padding: 14px 14px 16px;
  border-radius: 18px; color: #eef2ff;
  background: linear-gradient(140deg, color-mix(in srgb, var(--gm-c) 16%, rgba(18,21,42,.97)), rgba(14,16,34,.97) 60%);
  border: 1px solid color-mix(in srgb, var(--gm-c) 45%, transparent);
  box-shadow: 0 26px 60px -22px rgba(0,0,0,.95), 0 0 0 1px rgba(255,255,255,.03) inset, 0 0 40px -18px var(--gm-c);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  animation: gmToastIn .5s cubic-bezier(.2,.9,.25,1.15) both;
}
.gm-toast::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.12) 50%, transparent 65%); transform: translateX(-100%); animation: gmSheen 1.4s .25s ease-out both; pointer-events: none; }
.gm-toast.leaving { animation: gmToastOut .28s ease both; }
.gm-toast-medal {
  position: relative; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: var(--gm-c);
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--gm-c) 40%, transparent), color-mix(in srgb, var(--gm-c) 10%, transparent) 75%);
  border: 1px solid color-mix(in srgb, var(--gm-c) 60%, transparent); box-shadow: 0 0 22px -6px var(--gm-c), inset 0 1px 0 rgba(255,255,255,.2);
  animation: gmMedal .7s .1s cubic-bezier(.2,.9,.25,1.3) both;
}
.gm-toast-medal svg { width: 22px; height: 22px; filter: drop-shadow(0 0 6px var(--gm-c)); }
.gm-toast-medal b { position: absolute; bottom: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px; background: var(--gm-c); color: #140b02; font-size: .66rem; display: grid; place-items: center; }
.gm-toast.gm-t4 .gm-toast-medal, .gm-toast.gm-t5 .gm-toast-medal { border-radius: 50%; }
.gm-toast-body { min-width: 0; }
.gm-toast-kicker { font-size: .63rem; font-weight: 750; letter-spacing: .11em; text-transform: uppercase; color: color-mix(in srgb, var(--gm-c) 75%, #fff); }
.gm-tier-name { color: var(--gm-c); }
.gm-toast-title { margin-top: 3px; font: 700 .98rem/1.25 "Space Grotesk", Inter, sans-serif; color: #fff; letter-spacing: -.01em; overflow-wrap: anywhere; }
.gm-toast-sub { margin-top: 2px; font-size: .78rem; color: #aab4c8; line-height: 1.4; overflow-wrap: anywhere; }
.gm-toast-foot { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.gm-toast-foot:empty { display: none; }
.gm-toast-link { display: inline-flex; align-items: center; gap: 3px; font-size: .74rem; font-weight: 650; color: color-mix(in srgb, var(--gm-c) 70%, #fff); text-decoration: none; }
.gm-toast-link:hover { text-decoration: underline; }
.gm-toast-link svg { width: 12px; height: 12px; }
.gm-toast-x { display: grid; place-items: center; width: 26px; height: 26px; margin: -4px -4px 0 0; border: 0; border-radius: 8px; background: transparent; color: #8792ab; cursor: pointer; }
.gm-toast-x:hover { background: rgba(255,255,255,.08); color: #fff; }
.gm-toast-x svg { width: 14px; height: 14px; }
.gm-toast-timer { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: var(--gm-c); opacity: .65; transform-origin: left; animation: gmTimer var(--gm-ms, 5000ms) linear forwards; }
.gm-toast.paused .gm-toast-timer { animation-play-state: paused; }

.gm-xp-pill { display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: .72rem; font-weight: 750; color: #fde68a; background: rgba(245,158,11,.14); border: 1px solid rgba(245,158,11,.35); font-variant-numeric: tabular-nums; }
.gm-xp-pill svg { width: 12px; height: 12px; }
.gm-xp-pill.lg { height: 30px; padding: 0 13px; font-size: .9rem; margin-top: 14px; }
.gm-xp-pill.lg svg { width: 15px; height: 15px; }

.gm-burst { position: fixed; z-index: 216; width: 0; height: 0; pointer-events: none; }
.gm-burst i { position: absolute; width: 6px; height: 6px; border-radius: 2px; animation: gmBurst .95s cubic-bezier(.15,.7,.3,1) forwards; }

/* ---------- full-screen overlay ---------- */
body.gm-overlay-open { overflow: hidden; }
.gm-overlay {
  --gm-c: #a78bfa; position: fixed; inset: 0; z-index: 220; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(ellipse at 50% 42%, color-mix(in srgb, var(--gm-c) 22%, rgba(4,6,14,.82)), rgba(4,6,14,.9) 65%);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); opacity: 0; transition: opacity .26s ease;
}
.gm-overlay.in { opacity: 1; }
.gm-overlay.leaving { opacity: 0; }
.gm-confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.gm-ov-card {
  position: relative; width: min(420px, 100%); padding: 38px 32px 28px; text-align: center; border-radius: 26px; overflow: hidden;
  background: linear-gradient(160deg, rgba(26,30,60,.96), rgba(12,14,30,.97));
  border: 1px solid color-mix(in srgb, var(--gm-c) 45%, rgba(255,255,255,.12));
  box-shadow: 0 40px 100px -30px rgba(0,0,0,.95), 0 0 80px -30px var(--gm-c), inset 0 1px 0 rgba(255,255,255,.08);
  transform: scale(.86) translateY(14px); transition: transform .5s cubic-bezier(.2,.9,.25,1.25);
}
.gm-overlay.in .gm-ov-card { transform: none; }
.gm-ov-glow { position: absolute; left: 50%; top: -120px; width: 360px; height: 260px; transform: translateX(-50%); background: radial-gradient(closest-side, color-mix(in srgb, var(--gm-c) 45%, transparent), transparent); pointer-events: none; }
.gm-ov-medal {
  position: relative; width: 104px; height: 104px; margin: 0 auto 18px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: radial-gradient(circle at 32% 26%, color-mix(in srgb, var(--gm-c) 85%, #fff), color-mix(in srgb, var(--gm-c) 55%, #0b0d19) 75%);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--gm-c) 18%, transparent), 0 0 0 1px rgba(255,255,255,.25) inset, 0 18px 50px -10px var(--gm-c);
  animation: gmMedalBig .9s .08s cubic-bezier(.2,.9,.25,1.3) both;
}
.gm-ov-medal::after { content: ""; position: absolute; inset: -14px; border-radius: 50%; border: 2px dashed color-mix(in srgb, var(--gm-c) 55%, transparent); animation: gmSpin 14s linear infinite; }
.gm-ov-medal svg { width: 46px; height: 46px; filter: drop-shadow(0 2px 8px rgba(0,0,0,.35)); }
.gm-ov-level { font: 700 2.7rem/1 "Space Grotesk", Inter, sans-serif; letter-spacing: -.04em; text-shadow: 0 3px 14px rgba(0,0,0,.35); }
.gm-ov-kicker { position: relative; font-size: .7rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; color: color-mix(in srgb, var(--gm-c) 70%, #fff); }
.gm-ov-title { position: relative; margin: 6px 0 0; font: 700 1.75rem/1.15 "Space Grotesk", Inter, sans-serif; letter-spacing: -.03em; color: #fff; overflow-wrap: anywhere; }
.gm-ov-sub { position: relative; margin: 8px auto 0; max-width: 32ch; font-size: .9rem; color: #aab4c8; line-height: 1.5; }
.gm-ov-actions { position: relative; display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 22px; }

/* ---------- shared bits for practice / report / languages ---------- */
.gm-bd { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-top: 10px; }
.gm-bd .gm-xp-pill { margin-right: 2px; }
.gm-mrec { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; padding: 9px 11px; border-radius: 12px; font-size: .78rem; color: #c6cee0; background: rgba(255,255,255,.035); border: 1px solid rgba(148,163,184,.14); }
.gm-mrec b { color: #fff; font-weight: 650; }
.gm-state { display: inline-flex; align-items: center; gap: 4px; height: 21px; padding: 0 8px; border-radius: 99px; font-size: .68rem; font-weight: 700; letter-spacing: .01em; color: var(--sc, #94a3b8); background: color-mix(in srgb, var(--sc, #94a3b8) 13%, transparent); border: 1px solid color-mix(in srgb, var(--sc, #94a3b8) 40%, transparent); white-space: nowrap; }
.gm-state.up { animation: gmPop .5s var(--ease, ease); }
.gm-arrow { color: #64748b; }
.gm-conf { display: inline-flex; align-items: center; gap: 5px; color: #8792ab; }
.gm-conf i { display: inline-block; width: 38px; height: 4px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.gm-conf i > span { display: block; height: 100%; background: #22d3ee; border-radius: inherit; }
.gm-item-xp { font-size: .7rem; font-weight: 750; color: #fcd34d; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gm-sum-xp { display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; font-size: .78rem; color: #fde68a; }

/* ---------- keyframes ---------- */
@keyframes gmBump { 0% { transform: scale(1); } 30% { transform: scale(1.08); box-shadow: 0 0 0 4px rgba(245,158,11,.25), 0 0 26px -6px rgba(245,158,11,.8); } 100% { transform: scale(1); } }
@keyframes gmFly { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.7); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.08); } 30% { transform: translate(-50%, 0) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, 34px) scale(.96); } }
@keyframes gmToastIn { from { opacity: 0; transform: translateX(40px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes gmToastOut { to { opacity: 0; transform: translateX(30px) scale(.97); } }
@keyframes gmSheen { to { transform: translateX(100%); } }
@keyframes gmMedal { from { transform: scale(.3) rotate(-25deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes gmMedalBig { from { transform: scale(.2) rotate(-40deg); opacity: 0; } 60% { transform: scale(1.1) rotate(4deg); opacity: 1; } to { transform: none; } }
@keyframes gmSpin { to { transform: rotate(360deg); } }
@keyframes gmTimer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes gmBurst { 0% { transform: translate(0,0) scale(1); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }
@keyframes gmPop { 0% { transform: scale(.7); } 60% { transform: scale(1.12); } 100% { transform: none; } }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .gm-chip { gap: 7px; padding-right: 9px; }
  .gm-chip-goal { display: none; }
  .gm-tip { display: none; }
  body.gm-tip-open .gm-toasts { transform: none; }
  .gm-toasts { left: 16px; right: 16px; width: auto; top: calc(var(--topbar-h, 68px) + 8px); }
}
@media (max-width: 480px) {
  .gm-chip-streak { display: none; }
  .gm-chip { padding-right: 4px; }
  .gm-ov-card { padding: 30px 20px 22px; }
  .gm-ov-title { font-size: 1.45rem; }
}
@media (prefers-reduced-motion: reduce) {
  .gm-chip, .gm-chip.gm-bump, .gm-toast, .gm-toast::after, .gm-toast.leaving, .gm-toast-medal, .gm-ov-medal, .gm-ov-medal::after, .gm-state.up, .gm-burst i { animation: none !important; }
  .gm-fly { animation: gmFlyCalm 1.6s linear forwards; }
  .gm-ov-card, .gm-overlay, .gm-ring-fg, .gm-tip { transition: none !important; }
  .gm-ov-card { transform: none; }
  .gm-toast-timer { animation: none; display: none; }
}
@keyframes gmFlyCalm { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
@media (forced-colors: active) {
  .gm-chip, .gm-toast, .gm-ov-card { border: 1px solid CanvasText; }
}
