/* 1600 Study Hall · gamify.css
   Styles for gamify.js: the XP chip, daily goal, toasts, XP pop and player card.
   Uses the Lobby theme tokens. Motion is skipped when the visitor asks for reduced motion. */

/* ---------- XP chip in the header ---------- */
.game-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-left: var(--s3);
  padding: 4px 12px 4px 4px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--well);
  color: var(--ink);
  font: 700 var(--fs-13)/1 var(--font-ui);
  cursor: pointer;
  box-shadow: 0 3px 0 rgb(0 0 0 / .35);
  transition: border-color .15s ease, transform .15s ease;
}
.game-chip[hidden] { display: none !important; }   /* hidden while progress loads or the learner changes */
.game-chip:hover { background: var(--well); color: var(--ink); filter: none; border-color: var(--accent-line); }
.game-chip:active { transform: translateY(2px); box-shadow: none; }
.game-chip-level {
  display: grid;
  place-items: center;
  min-width: 52px;
  height: 34px;
  padding: 3px 8px 0;
  box-sizing: border-box;
  border-radius: 8px;
  background: var(--gold);
  color: var(--on-gold);
  font: 400 15px/1 var(--font-pixel);
  box-shadow: inset 0 -4px 0 var(--gold-lip);
}
.game-chip-meter { display: grid; gap: 5px; min-width: 96px; }
.game-chip-bar { display: block; height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.game-chip-fill { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--go); box-shadow: inset 0 2px 0 var(--go-hi); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.game-chip-text { color: var(--ink-2); font: 400 13px/1 var(--font-pixel); letter-spacing: .02em; white-space: nowrap; }
.game-chip.is-off .game-chip-level { background: var(--surface-3); color: var(--ink-2); box-shadow: inset 0 -4px 0 var(--line); }
.game-chip.is-off .game-chip-meter { display: none; }
.game-chip.is-off { padding-right: 4px; gap: 0; }
.game-chip.is-off .game-chip-bar { display: none; }
.game-chip.is-gain .game-chip-fill { animation: game-flash .9s ease; }
.game-chip.is-levelup { animation: game-levelup 1.3s ease; }

/* ---------- XP pop ---------- */
.game-pop {
  position: fixed;
  z-index: 60;
  transform: translateX(-50%);
  padding: 4px 10px 2px;
  border-radius: 8px;
  background: var(--go);
  color: var(--on-go);
  font: 400 15px/1.2 var(--font-pixel);
  white-space: nowrap;
  box-shadow: 0 6px 18px rgb(0 0 0 / .45), inset 0 -3px 0 var(--go-lip);
  pointer-events: none;
  animation: game-rise 1.3s ease forwards;
}

/* ---------- Daily goal on the study plan ---------- */
.game-goal {
  display: grid;
  gap: var(--s3);
  margin: var(--s5) 0 0;
  padding: var(--s5);
  border: 2px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface);
  box-shadow: 0 5px 0 var(--well);
}
.game-goal-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); }
.game-goal-head .eyebrow { margin: 0; }
.game-streak {
  margin: 0;
  padding: 6px 12px 4px;
  border-radius: 8px;
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  color: var(--gold);
  font: 400 14px/1.2 var(--font-pixel);
}
.game-goal-count { margin: 0; color: var(--ink-2); font: 400 18px/1.2 var(--font-pixel); }
.game-goal-count strong { color: var(--gold); font-size: 30px; font-weight: 400; }
.game-goal-bar { height: 14px; border-radius: 7px; background: var(--well); border: 1px solid var(--line); overflow: hidden; }
.game-goal-bar span { display: block; height: 100%; border-radius: 7px; background: var(--go); box-shadow: inset 0 3px 0 var(--go-hi); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.game-goal-note { margin: 0; color: var(--ink-2); font-size: var(--fs-15); }

/* ---------- Toasts ---------- */
.game-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.game-toasts {
  position: fixed;
  z-index: 70;
  right: var(--s5);
  top: 84px;
  display: grid;
  gap: var(--s3);
  width: min(360px, calc(100vw - 2 * var(--s4)));
  pointer-events: none;
}
.game-toast {
  display: grid;
  gap: 4px;
  padding: var(--s4) var(--s4) var(--s4) 56px;
  border: 2px solid var(--line);
  border-radius: var(--r2);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--fs-15);
  line-height: 1.4;
  box-shadow: var(--shadow-float);
  pointer-events: auto;
  position: relative;
  animation: game-in .25s ease;
}
.game-toast::before {
  content: "+";
  position: absolute;
  left: 14px;
  top: 14px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding-top: 3px;
  box-sizing: border-box;
  border-radius: 8px;
  background: var(--go);
  color: var(--on-go);
  font: 400 16px/1 var(--font-pixel);
}
.game-toast strong { color: var(--ink); font: 400 17px/1.2 var(--font-display); letter-spacing: .03em; text-transform: uppercase; }
.game-toast-level { border-color: var(--gold-lip); }
.game-toast-level::before { content: "\2191"; background: var(--gold); color: var(--on-gold); }
.game-toast-badge { border-color: var(--accent-line); }
.game-toast-badge::before { content: "\2605"; background: var(--accent); color: var(--on-accent); font-family: var(--font-ui); }
.game-toast-goal::before { content: "\2713"; font-family: var(--font-ui); }
.game-toast.is-leaving { opacity: 0; transform: translateY(-6px); transition: opacity .35s ease, transform .35s ease; }

/* ---------- Player card ---------- */
.game-card {
  width: min(680px, calc(100vw - 2 * var(--s4)));
  max-height: min(86vh, 900px);
  padding: 0;
  border: 2px solid var(--line);
  border-radius: var(--r3);
  background: var(--paper);
  color: var(--ink-2);
  box-shadow: var(--shadow-float);
  overflow: auto;
}
.game-card::backdrop { background: rgb(5 9 15 / .72); }
.game-card > * { margin-left: var(--s5); margin-right: var(--s5); }
.game-card-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-top: var(--s4); }
.game-card h2 { margin: 0; font: 400 var(--fs-28)/1.1 var(--font-display); letter-spacing: .03em; text-transform: uppercase; }
.game-card h3 { margin-top: var(--s5); margin-bottom: var(--s3); font: 400 var(--fs-19)/1.1 var(--font-display); letter-spacing: .04em; text-transform: uppercase; }
.game-card-close {
  min-width: 44px;
  min-height: 44px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: 700 24px/1 var(--font-ui);
  cursor: pointer;
}
/* The theme's generic button look (green fill on hover, brighter filter, green lip shadow, press offset) must
   not reach the game's own controls, so each one sets its rest, hover and press states itself. */
.game-card-close, .game-switch { box-shadow: none; filter: none; transform: none; }
.game-card-close:hover, .game-switch:hover { background: var(--surface-2); color: var(--ink); filter: none; border-color: var(--accent-line); }
.game-card-close:active, .game-switch:active { transform: translateY(1px); box-shadow: none; }
.game-card-level { display: grid; grid-template-columns: auto 1fr; gap: var(--s4); align-items: center; margin-top: var(--s4); padding: var(--s4); border-radius: var(--r2); background: var(--surface); border: 2px solid var(--line); }
.game-card-badge { display: grid; place-items: center; width: 64px; height: 64px; padding-top: 5px; box-sizing: border-box; border-radius: 14px; background: var(--gold); color: var(--on-gold); font: 400 28px/1 var(--font-pixel); box-shadow: inset 0 -6px 0 var(--gold-lip); }
.game-card-levelname { margin: 0 0 var(--s2); color: var(--ink); font: 800 var(--fs-19)/1.2 var(--font-ui); }
.game-card-bar { height: 12px; border-radius: 6px; background: var(--well); border: 1px solid var(--line); overflow: hidden; }
.game-card-bar span { display: block; height: 100%; background: var(--go); box-shadow: inset 0 3px 0 var(--go-hi); }
.game-card-sub { margin: var(--s2) 0 0; font-size: var(--fs-15); }
.game-card-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); margin-top: var(--s4); margin-bottom: 0; }
.game-card-stats div { padding: var(--s3); border-radius: var(--r1); background: var(--surface); border: 1px solid var(--line); }
.game-card-stats dt { color: var(--ink-3); font-size: var(--fs-13); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.game-card-stats dd { margin: 4px 0 0; color: var(--ink); font: 400 17px/1.2 var(--font-pixel); }
.game-badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s3); padding: 0; list-style: none; }
.game-badges li { display: grid; grid-template-columns: auto 1fr; gap: var(--s3); align-items: start; padding: var(--s3); border-radius: var(--r1); border: 1px solid var(--line); background: var(--surface); }
.game-badges .is-earned { border-color: var(--accent-line); background: var(--accent-soft); }
.game-badge-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: var(--surface-3); color: var(--ink-2); font: 700 18px/1 var(--font-ui); }
.is-earned .game-badge-icon { background: var(--gold); color: var(--on-gold); box-shadow: inset 0 -4px 0 var(--gold-lip); }
.game-badge-text { display: grid; gap: 2px; font-size: var(--fs-15); line-height: 1.4; }
.game-badge-text strong { color: var(--ink); }
.game-badge-state { color: var(--ink-3); font-size: var(--fs-13); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.is-earned .game-badge-state { color: var(--good); }
.game-rules { margin-top: var(--s5); padding: var(--s3) var(--s4); border-radius: var(--r1); border: 1px solid var(--line); background: var(--surface); }
.game-rules summary { min-height: 44px; display: flex; align-items: center; color: var(--ink); font-weight: 750; cursor: pointer; }
.game-rules ul { margin: var(--s2) 0; padding-left: 1.2em; }
.game-rules li, .game-rules p { font-size: var(--fs-15); line-height: 1.5; }
.game-setting { margin-bottom: var(--s3); }
.game-setting:last-child { margin-bottom: var(--s5); }
.game-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  width: 100%;
  min-height: 52px;
  padding: var(--s2) var(--s4);
  border: 2px solid var(--line);
  border-radius: var(--r1);
  background: var(--surface);
  color: var(--ink);
  font: 750 var(--fs-17)/1.2 var(--font-ui);
  text-align: left;
  cursor: pointer;
}
.game-switch-state { min-width: 56px; padding: 6px 10px 4px; border-radius: 8px; background: var(--surface-3); color: var(--ink-2); font: 400 14px/1 var(--font-pixel); text-align: center; }
.game-switch[aria-checked="true"] .game-switch-state { background: var(--go); color: var(--on-go); }
.game-setting-note { margin: var(--s2) 0 0; color: var(--ink-3); font-size: var(--fs-15); line-height: 1.4; }

/* ---------- Motion ---------- */
@keyframes game-rise { 0% { opacity: 0; transform: translate(-50%, 6px); } 15% { opacity: 1; transform: translate(-50%, 0); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -18px); } }
@keyframes game-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes game-flash { 0%, 100% { filter: none; } 40% { filter: brightness(1.5); } }
@keyframes game-levelup { 0% { box-shadow: 0 0 0 0 rgb(255 201 60 / .75); } 60% { box-shadow: 0 0 0 14px rgb(255 201 60 / 0); } 100% { box-shadow: 0 3px 0 rgb(0 0 0 / .35); } }

/* ---------- Phones and tablets ---------- */
@media (max-width: 900px) {
  .game-chip { margin-left: auto; }
  .game-toasts { top: 70px; right: var(--s3); left: var(--s3); width: auto; max-width: 420px; margin-left: auto; }
}
@media (max-width: 480px) {
  .game-chip { padding-right: 4px; gap: 0; }
  .game-chip-meter { display: none; }
  .game-chip-level { min-width: 58px; }
  .game-card > * { margin-left: var(--s4); margin-right: var(--s4); }
  .game-card-stats { grid-template-columns: minmax(0, 1fr); }
  .game-badges { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  .game-pop { animation: none; transform: translateX(-50%); }
  .game-toast, .game-chip.is-gain .game-chip-fill, .game-chip.is-levelup { animation: none; }
  .game-chip-fill, .game-goal-bar span { transition: none; }
  .game-toast.is-leaving { transition: none; }
}
@media (forced-colors: active) {
  .game-chip, .game-goal, .game-toast, .game-card, .game-switch, .game-badges li, .game-card-stats div { border: 1px solid CanvasText; }
  .game-chip-fill, .game-goal-bar span, .game-card-bar span { background: Highlight; }
}
@media print { .game-chip, .game-toasts, .game-pop, .game-goal { display: none !important; } }
