/* ALLBRAD game layer, sprint 0.
   Sits on the v4 tokens (--bg --s1 --s2 --s3 --text --muted --muted2 --border
   --voice --good --watch --earned --measured --attention --on-accent).
   Every var() carries a fallback so this file also renders on a page that has
   not loaded the v4 tokens yet. Nothing here redefines a v4 token.
   Glass is used in exactly three places: the profile header, the tab bar and
   the XP toast. Never on cards. */

:root {
  --gm-gold: var(--watch, #E8B96B);
  --gm-glass: color-mix(in srgb, var(--s1, #1D1815) 72%, transparent);
  --gm-glass-line: color-mix(in srgb, var(--text, #F5EDE4) 12%, transparent);
  --gm-r-sm: 12px; --gm-r-md: 18px; --gm-r-lg: 24px;
  --gm-font: var(--font, 'Hanken Grotesk', system-ui, sans-serif);
  --gm-voice: var(--font-voice, 'Newsreader', Georgia, serif);
}

/* Mount wrapper. 20px matches the .app sections on Work, Learn, Money and Rules;
   boxing.html and index.html set their own. Hidden until game.js fills it. */
.gm-wrap { padding: 6px 20px 0; }
.gm-wrap:empty { display: none; }

/* ---------- Profile header ---------- */
.gm-header {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border-radius: var(--gm-r-lg);
  background: var(--gm-glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid var(--gm-glass-line);
  font-family: var(--gm-font);
  color: var(--text, #F5EDE4);
}
.gm-ring { position: relative; width: 56px; height: 56px; flex: none; display: block; text-decoration: none; color: inherit; border-radius: 999px; }
.gm-ring:focus-visible { outline: 2px solid var(--gm-gold); outline-offset: 3px; }
/* Ray's line, Newsreader, under the header on Home. Figures only, no praise. */
.gm-ray { font-family: var(--gm-voice); font-weight: 300; font-size: 19px; line-height: 1.35; letter-spacing: -.005em; color: var(--text, #F5EDE4); margin: 10px 4px 0; text-wrap: balance; }
.gm-ray:empty { display: none; }
.gm-ring svg { width: 56px; height: 56px; transform: rotate(-90deg); display: block; }
.gm-ring .track { fill: none; stroke: var(--border, rgba(255,238,226,.10)); stroke-width: 4; }
.gm-ring .fill  { fill: none; stroke: var(--gm-gold); stroke-width: 4; stroke-linecap: round;
                  transition: stroke-dashoffset .6s cubic-bezier(.2,.8,.2,1); }
.gm-ring .num { position: absolute; inset: 0; display: grid; place-items: center;
                font-weight: 700; font-size: 20px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.gm-who { min-width: 0; }
.gm-title { font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
            color: var(--gm-gold); }
.gm-level { font-size: 17px; font-weight: 600; margin-top: 2px; }
.gm-xp { text-align: right; font-variant-numeric: tabular-nums; }
.gm-xp .total { font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.gm-xp .next  { font-size: 12px; color: var(--muted, #B0A398); margin-top: 2px; }
.gm-streaks { grid-column: 1 / -1; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
              margin: 2px -16px -4px; padding: 0 16px 4px; }
.gm-streaks::-webkit-scrollbar { display: none; }
.gm-streaks:empty { display: none; }
.gm-chip { flex: none; display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 10px;
           border-radius: 999px; background: var(--s2, #272019); font-size: 12px; color: var(--muted, #B0A398);
           border: 1px solid var(--border, rgba(255,238,226,.10)); }
.gm-chip b { color: var(--text, #F5EDE4); font-variant-numeric: tabular-nums; font-weight: 600; }

/* Active challenges, under the streaks. Gold bar: it is XP in waiting. */
.gm-chals { grid-column: 1 / -1; display: grid; gap: 8px; margin-top: 4px; --gm-accent: var(--gm-gold); }
.gm-chal { display: grid; gap: 6px; }
.gm-chal-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 12.5px; }
.gm-chal-title { font-weight: 600; min-width: 0; }
.gm-chal-n { color: var(--muted, #B0A398); white-space: nowrap; font-variant-numeric: tabular-nums; }
.gm-chal-n b { color: var(--text, #F5EDE4); }

/* ---------- Module card ---------- */
.gm-card {
  display: grid; gap: 10px;
  padding: 16px;
  border-radius: var(--gm-r-md);
  background: var(--s1, #1D1815);
  border: 1px solid var(--border, rgba(255,238,226,.10));
  font-family: var(--gm-font);
  color: var(--text, #F5EDE4);
  text-decoration: none;
  min-width: 0;
}
.gm-card .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.gm-card .name { font-size: 15px; font-weight: 600; }
.gm-card .phase { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted, #B0A398); white-space: nowrap; }
.gm-card .next { font-size: 13px; color: var(--muted, #B0A398); line-height: 1.35; }
.gm-card .next b { color: var(--text, #F5EDE4); font-weight: 600; }
.gm-card[data-accent="boxing"]   { --gm-accent: var(--voice, #F2704F); }
.gm-card[data-accent="learning"] { --gm-accent: var(--measured, #CDBFAF); }
.gm-card[data-accent="work"]     { --gm-accent: var(--earned, #EE9A5E); }
.gm-card[data-accent="money"]    { --gm-accent: var(--good, #9DBE72); }

/* ---------- Progress bar ---------- */
.gm-bar { height: 6px; border-radius: 999px; background: var(--s3, #2E2620); overflow: hidden; }
.gm-bar > i { display: block; height: 100%; width: 0; border-radius: inherit;
              background: var(--gm-accent, var(--gm-gold));
              transition: width .6s cubic-bezier(.2,.8,.2,1); }
.gm-bar-meta { display: flex; justify-content: space-between; font-size: 12px;
               color: var(--muted, #B0A398); font-variant-numeric: tabular-nums; }

/* ---------- The site nav and the boxing tab bar become the floating glass pill ----------
   allbrad.css draws .nav as a full-width bar on the bottom edge; boxing.html draws its
   own .tabbar the same way. Both get the mockup treatment here: inset, pill, glass,
   the active item on a raised surface, and (via game.js) the light in the middle. */
.nav, .tabbar {
  bottom: calc(10px + env(safe-area-inset-bottom, 0px)) !important;
  left: 50% !important; right: auto !important; transform: translateX(-50%) !important;
  width: calc(100% - 32px) !important; max-width: 520px;
  padding: 6px !important; gap: 2px; align-items: center;
  border: 1px solid var(--gm-glass-line) !important;
  border-radius: 999px;
  background: var(--gm-glass) !important;
  -webkit-backdrop-filter: blur(22px) saturate(1.3) !important; backdrop-filter: blur(22px) saturate(1.3) !important;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.nav-item, .tabbar button {
  border-radius: 999px !important; padding: 8px 4px 7px !important; min-height: 50px;
  font-family: var(--gm-font) !important; font-weight: 600 !important; font-size: 10.5px !important;
  letter-spacing: .06em !important; text-transform: uppercase; transition: background .15s, color .15s;
}
.nav-item .nl { font-family: var(--gm-font) !important; font-size: 10.5px !important; font-weight: 600; letter-spacing: .06em; }
.nav-item.active, .tabbar button.on { background: var(--s2, #272019) !important; color: var(--text, #F5EDE4) !important; }
.nav-item:focus-visible, .tabbar button:focus-visible, .nav-light:focus-visible { outline: 2px solid var(--gm-gold); outline-offset: 2px; }
/* The light, centre of the bar. One tap opens Ray. It breathes because presence is a state. */
.nav-light { flex: 0 0 52px; display: grid; place-items: center; border: 0; background: none; cursor: pointer; padding: 0; min-height: 50px; }
.nav-light i {
  display: block; width: 34px; height: 34px; border-radius: 999px;
  background: radial-gradient(circle at 50% 40%, var(--voice, #F2704F) 0%, color-mix(in srgb, var(--voice, #F2704F) 50%, transparent) 55%, transparent 72%);
  animation: gm-breathe 7s ease-in-out infinite;
}

/* ---------- The quiet line (every page that is not the camp) ---------- */
.gm-slim {
  display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 6px;
  font-family: var(--gm-font); font-size: 12px; font-weight: 500; letter-spacing: .02em;
  color: var(--muted, #B0A398); text-decoration: none; padding: 2px 0;
  font-variant-numeric: tabular-nums;
}
.gm-slim .xp { color: var(--text, #F5EDE4); font-weight: 600; }
.gm-slim .dot { color: var(--muted2, #9A8F84); }
.gm-slim:focus-visible { outline: 2px solid var(--gm-gold); outline-offset: 3px; border-radius: 6px; }

/* ---------- Module cards (Home) ---------- */
.gm-modules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.gm-modules:empty { display: none; }
@media (min-width: 640px) { .gm-modules { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.gm-card .wk { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--gm-gold); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Floating tab bar (glass) ---------- */
.gm-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: center;
  padding: 0 max(16px, env(safe-area-inset-left, 0px)) calc(10px + env(safe-area-inset-bottom, 0px))
          max(16px, env(safe-area-inset-right, 0px));
  pointer-events: none;
}
.gm-tabbar > nav {
  pointer-events: auto;
  display: flex; align-items: center; gap: 2px;
  padding: 6px;
  border-radius: 999px;
  background: var(--gm-glass);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  backdrop-filter: blur(22px) saturate(1.3);
  border: 1px solid var(--gm-glass-line);
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  max-width: 100%;
}
.gm-tab {
  display: grid; place-items: center; gap: 2px;
  min-width: 58px; padding: 8px 10px;
  border-radius: 999px; border: 0; background: transparent;
  color: var(--muted, #B0A398); font: 600 10.5px/1 var(--gm-font); letter-spacing: .06em; text-transform: uppercase;
  cursor: pointer;
}
.gm-tab svg { width: 20px; height: 20px; }
.gm-tab[aria-current="page"] { color: var(--text, #F5EDE4); background: var(--s2, #272019); }
.gm-tab:focus-visible { outline: 2px solid var(--gm-gold); outline-offset: 2px; }
/* The centre item is the light, not a sparkle. One tap opens Ray. */
.gm-tab.light { min-width: 48px; padding: 6px; }
.gm-tab.light i {
  display: block; width: 32px; height: 32px; border-radius: 999px;
  background: radial-gradient(circle at 50% 40%, var(--voice, #F2704F) 0%, color-mix(in srgb, var(--voice, #F2704F) 50%, transparent) 55%, transparent 72%);
  animation: gm-breathe 7s ease-in-out infinite;
}

/* ---------- XP toast (glass) ---------- */
.gm-toasts {
  position: fixed; left: 0; right: 0; top: calc(10px + env(safe-area-inset-top, 0px)); z-index: 50;
  display: grid; justify-items: center; gap: 8px; pointer-events: none;
  padding: 0 max(16px, env(safe-area-inset-left, 0px)) 0 max(16px, env(safe-area-inset-right, 0px));
}
.gm-toast {
  display: flex; align-items: baseline; gap: 10px;
  padding: 10px 16px; border-radius: 999px;
  background: var(--gm-glass);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border: 1px solid var(--gm-glass-line);
  font-family: var(--gm-font); color: var(--text, #F5EDE4); font-size: 14px;
  animation: gm-in .35s cubic-bezier(.2,.8,.2,1) both;
}
.gm-toast .amt { color: var(--gm-gold); font-weight: 700; font-variant-numeric: tabular-nums; }
.gm-toast.capped .amt { color: var(--muted, #B0A398); }
.gm-toast.levelup { padding: 14px 20px; border-color: var(--gm-gold); font-size: 15px; }
.gm-toast.levelup .amt { font-size: 18px; }
.gm-toast.out { animation: gm-out .3s ease-in both; }

@keyframes gm-in  { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes gm-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes gm-breathe { 0%,100% { opacity: .55; } 50% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .gm-ring .fill, .gm-bar > i { transition: none; }
  .gm-toast { animation-duration: .01s; }
  .gm-tab.light i { animation: none; opacity: .85; }
}
