/* ============================================================================
   Shared chrome — header and navigation
   ----------------------------------------------------------------------------
   On every screen, so it has to be the most disciplined thing in the game.
   The commander with experience drawn as a ring around their portrait, the
   purse in a fixed order, and a navigation bar where the selected tab rises
   out of it.

   Depends on tokens.css and kit.css.
   ========================================================================== */

.topbar {
  gap: var(--s2);
  background: linear-gradient(180deg, #1b2234 0%, #11161f 100%);
  border-bottom: 0;
  box-shadow: 0 2px 0 #090c13, 0 6px 14px rgba(0, 0, 0, 0.45);
}

/* --- the commander ----------------------------------------------------------- */

.cm {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  --xp: 0deg;
}
/* 46px visual, 48dp hit area. */
.cm::after { content: ''; position: absolute; inset: -1px; }

/* Experience is the ring. It reads at a glance and costs no row of its own. */
.cm-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 180deg,
    var(--gold-300) 0deg, var(--gold-200) var(--xp), rgba(255, 255, 255, 0.12) var(--xp));
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* The painted medallion sits over the XP ring: the ornament is a bezel, the
   ring is the gauge, and the player needs to read the gauge. A sliver of ring
   stays visible in the gap between the two.

   The image is set from JS, not from a custom property here. A url() inside
   a custom property resolves against the stylesheet rather than the document
   — the mistake that 404'd the victory banner once already. */
.cm-bezel {
  position: absolute;
  inset: -5px;
  z-index: 2;
  background-position: center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  pointer-events: none;
}
.cm.is-medallion .cm-face { inset: 6px; }

.cm-face {
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--ink-700);
  box-shadow: inset 0 0 0 2px rgba(8, 11, 18, 0.9);
}
.cm-face img { width: 100%; height: 100%; object-fit: cover; }
.cm-face-blank { display: grid; place-items: center; width: 100%; height: 100%; color: var(--text-dim); }

.cm-lv {
  position: absolute;
  right: -3px;
  bottom: -3px;
  min-width: 19px;
  padding: 0 4px;
  border-radius: var(--rad-pill);
  border: 2px solid var(--gold-800);
  background: linear-gradient(180deg, var(--gold-200), var(--gold-400));
  color: var(--text-ink);
  font-size: 0.6rem;
  line-height: 15px;
  text-align: center;
}

/* --- the purse ----------------------------------------------------------------- */

.cur-strip { display: flex; gap: 6px; margin-left: auto; align-items: center; }

.cur-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 34px;
  padding: 0 3px 0 2px;
  border-radius: var(--rad-pill);
  background: var(--panel-sunken);
  box-shadow: var(--carve), inset 0 -1px 0 rgba(255, 255, 255, 0.07);
}
/* The chip itself is not tappable; the + inside it is. The chip still grows
   to the floor so a stray thumb lands somewhere harmless rather than between
   two controls. */
.cur-chip::after { content: ''; position: absolute; inset: -7px 0; pointer-events: none; }

.cur-icon { flex: none; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.6)); }

.cur-amt {
  font-size: var(--fz-small);
  color: var(--text-cream);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.7);
  min-width: 2ch;
}

.cur-plus {
  position: relative;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--gold-800);
  background: linear-gradient(180deg, var(--gold-200), var(--gold-400));
  color: var(--text-ink);
  font-weight: 800;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--bevel), 0 2px 0 var(--gold-800);
}
.cur-plus::after { content: ''; position: absolute; inset: calc((48px - 22px) / -2); }
.cur-plus:active { transform: translateY(1px); box-shadow: var(--bevel); }

.cur-chip.is-credited .cur-amt { animation: kit-credit 420ms var(--ease-spring); }

/* --- navigation ------------------------------------------------------------------
   Five painted marks on a dark band. The selected tab is lifted onto its own
   plaque that breaks the top edge of the bar, so the current place is
   obvious from the silhouette alone — you can find Home without reading. */

.navbar {
  position: relative;
  align-items: flex-end;
  padding-top: 14px;
  background: linear-gradient(180deg, #1c2439 0%, #0b1018 100%);
  border-top: 0;
  box-shadow: 0 -2px 0 #070a10, 0 -8px 18px rgba(0, 0, 0, 0.5);
}

/* A hairline of worn gold along the top of the bar, which is what stops it
   reading as a browser toolbar. */
.navbar::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent, rgba(240, 192, 112, 0.5) 18%, rgba(240, 192, 112, 0.5) 82%, transparent);
}

.nav-btn {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: end;
  gap: 1px;
  min-height: 62px;
  padding: 2px 2px 7px;
  border: 0;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
}

.nav-ico {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  filter: saturate(0.9) brightness(0.9) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6));
  transition:
    transform var(--t-quick) var(--ease-back),
    filter var(--t-quick) var(--ease-out);
}

.nav-label {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.01em;
  transition: color var(--t-quick) var(--ease-out);
}

/* The selected tab: full colour, lifted, standing on a plaque that breaks
   the bar's top edge. */
.nav-btn.is-on { color: var(--gold-200); }
.nav-btn.is-on .nav-ico {
  transform: translateY(-14px) scale(1.12);
  filter: saturate(1.06) brightness(1.06) drop-shadow(0 4px 6px rgba(0, 0, 0, 0.7));
}
.nav-btn.is-on .nav-label { transform: translateY(-6px); }

.nav-btn.is-on::before {
  content: '';
  position: absolute;
  top: -16px;
  left: 50%;
  translate: -50% 0;
  width: 62px;
  height: 66px;
  z-index: -1;
  /* A shield: square shoulders, a point at the foot. */
  clip-path: polygon(0 0, 100% 0, 100% 64%, 50% 100%, 0 64%);
  background: linear-gradient(180deg, #4a5a8e 0%, #27314e 62%, #1a2132 100%);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.55);
}
.nav-btn.is-on::after {
  content: '';
  position: absolute;
  top: -18px;
  left: 50%;
  translate: -50% 0;
  width: 66px;
  height: 70px;
  z-index: -2;
  clip-path: polygon(0 0, 100% 0, 100% 64%, 50% 100%, 0 64%);
  background: linear-gradient(180deg, var(--gold-200), var(--gold-500) 60%, var(--gold-800));
}

/* Home is the landmark the thumb finds without looking. */
.nav-btn.is-home .nav-ico { width: 48px; height: 48px; }
.nav-btn.is-home.is-on .nav-ico { transform: translateY(-16px) scale(1.1); }
.nav-btn.is-home.is-on::before { width: 70px; height: 74px; top: -19px; }
.nav-btn.is-home.is-on::after { width: 74px; height: 78px; top: -21px; }

.nav-btn .kit-badge { position: absolute; top: 2px; right: 20%; z-index: 2; }

@media (prefers-reduced-motion: reduce) {
  .nav-ico, .nav-label { transition: none; }
}

/* --- team power ------------------------------------------------------------
   Sits next to the commander rather than out with the purse, because it is a
   fact about the player, not a balance they can spend. The genre puts it in
   the header for a reason: it is the number that answers "am I strong enough
   for the next thing", and it gets checked far more often than the player's
   own level. */

.cm-power {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 7px 0 4px;
  height: 26px;
  border-radius: var(--rad-pill);
  background: var(--panel-sunken);
  box-shadow: var(--carve);
}

.cm-power-ico { flex: none; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6)); }

.cm-power-n {
  font-size: var(--fz-small);
  color: var(--gold-200);
  text-shadow: var(--stroke-dark);
}
