/* Profile menu and language styles from AcademiaGames. */
.topbar__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: var(--pmenu-w, 258px);
  max-width: calc(100vw - 24px);
  display: grid;
  gap: 2px;
  background: var(--ink-700);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-pop);
  padding: 8px;
  z-index: 20;
  /* A phone held sideways is ~570px tall: the menu (card, XP, prefs, log out)
     is taller than that, and a sticky header's child can't be scrolled into
     view — so the menu scrolls itself. */
  max-height: calc(100dvh - var(--topbar-h) - 20px);
  overflow-y: auto;
}

/* ── Player card: the menu's signature header ── */
.pmenu__card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 14px;
}

.pmenu__avatar {
  position: relative;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--gold), var(--gold-hot));
  color: var(--on-gold);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 20px;
  box-shadow: var(--gold-glow);
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}

.pmenu__lvl {
  position: absolute;
  right: -4px;
  bottom: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--ink-900);
  border: 1px solid var(--gold);
  color: var(--gold);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 11px;
  line-height: 1;
}

.pmenu__who {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.pmenu__name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pmenu__role {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ── XP progress ── */
.pmenu__xp {
  display: grid;
  gap: 7px;
  padding: 0 12px 14px;
  border-bottom: 1px solid var(--line);
}

.pmenu__xp-track {
  height: 7px;
  border-radius: var(--radius-pill);
  background: var(--ink-900);
  overflow: hidden;
}

.pmenu__xp-track span {
  display: block;
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--gold), var(--gold-hot));
  transition: width var(--t-slow) var(--ease-out);
}

.pmenu__xp-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
}

.pmenu__xp-meta b {
  color: var(--text-dim);
}

.topbar__streak {
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: rgba(255, 107, 94, 0.15);
  color: var(--cat-arcade);
  font-weight: 700;
  font-size: 14px;
}

.topbar__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.topbar__badge {
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--ink-800);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  text-transform: capitalize;
}

.topbar__badge.is-gold {
  border-color: var(--gold);
  color: var(--gold);
}

.topbar__badge.is-silver {
  border-color: rgba(200, 210, 230, 0.6);
  color: #c8d2e6;
}

.topbar__badge.is-bronze {
  border-color: rgba(222, 148, 90, 0.6);
  color: #de945a;
}

/* ── Nav rows (Profile / Family / Log out) ── */
.pmenu__nav {
  display: grid;
  gap: 2px;
  padding: 4px 0;
}

.pmenu__item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  text-align: left;
  transition: background var(--t-fast), color var(--t-fast);
}

.pmenu__item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-faint);
  transition: color var(--t-fast);
}

.pmenu__item:hover {
  background: var(--ink-600);
  color: var(--gold);
}

.pmenu__item:hover svg {
  color: var(--gold);
}

.pmenu__item--logout {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  border-radius: 0;
}

.pmenu__item--logout:hover {
  background: transparent;
  color: var(--wrong);
}

.pmenu__item--logout:hover svg {
  color: var(--wrong);
}

/* ── Preferences block (language + theme) ── */
.pmenu__prefs {
  display: grid;
  gap: 14px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.pmenu__pref {
  display: grid;
  gap: 7px;
}

.pmenu__pref-label {
  color: var(--text-faint);
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Light/dark switch — two equal halves with a gold thumb that slides between
   them; the one micro-interaction the menu allows itself. */
.pmenu__theme {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
}

.pmenu__theme-thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, var(--gold), var(--gold-hot));
  box-shadow: var(--gold-glow);
  transition: transform var(--t-med) var(--ease-snap);
}

.pmenu__theme.is-dark .pmenu__theme-thumb {
  transform: translateX(100%);
}

.pmenu__theme-opt {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 6px;
  background: transparent;
  color: var(--text-dim);
  font-weight: 700;
  font-size: 13px;
  transition: color var(--t-fast);
}

.pmenu__theme-opt svg {
  width: 15px;
  height: 15px;
}

.pmenu__theme-opt[aria-pressed='true'] {
  color: var(--on-gold);
}

.pmenu__theme-opt:disabled {
  cursor: default;
}

/* A preference the e-ink display mode overrides: dimmed, with a one-line note. */
.pmenu__pref.is-overridden .pmenu__theme {
  opacity: 0.45;
}

.pmenu__pref-note {
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-faint);
}

/* Three-way variant (display mode): same thumb, a third of the track each.
   Labels are short but the row is narrow — stack the glyph over the text. */
.pmenu__theme--3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.pmenu__theme--3 .pmenu__theme-thumb {
  width: calc(33.333% - 2.667px);
}

.pmenu__theme--3.is-eink .pmenu__theme-thumb {
  transform: translateX(100%);
}

.pmenu__theme--3.is-eink-color .pmenu__theme-thumb {
  transform: translateX(200%);
}

.pmenu__theme--3 .pmenu__theme-opt {
  flex-direction: column;
  gap: 3px;
  padding: 6px 2px;
  font-size: 11px;
  line-height: 1.15;
  white-space: nowrap;
}


@media (prefers-reduced-motion: reduce) { .pmenu__theme-thumb, .pmenu__xp-track span { transition: none; } }
/* Themed language picker — shared by the landing hero and the profile menu.
   Native <select> option lists can't be styled, so the popup is custom markup
   that follows the AcademiaGames tokens (ink surfaces, gold active state). */
.langdd {
  position: relative;
}

.langdd__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--ink-700);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color var(--t-fast);
}

.langdd__btn:hover {
  border-color: var(--line-strong);
}

.langdd__btn[aria-expanded='true'] {
  border-color: var(--gold);
}

.langdd__globe {
  font-size: 16px;
}

.langdd__caret {
  color: var(--text-dim);
  font-size: 12px;
  margin-left: auto;
  transition: transform var(--t-fast) var(--ease-out);
}

.langdd__btn[aria-expanded='true'] .langdd__caret {
  transform: rotate(180deg);
}

.langdd__menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 100%;
  margin: 0;
  padding: 6px;
  list-style: none;
  display: grid;
  gap: 2px;
  background: var(--ink-700);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-pop);
  z-index: 30;
  animation: langdd-in var(--t-fast) var(--ease-out) both;
}

.langdd__menu button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  text-align: left;
  white-space: nowrap;
  background: transparent;
  border-radius: var(--radius-s);
  padding: 9px 12px;
  color: var(--text-dim);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}

/* Flag emoji beside each option (and the trigger's current language). Fixed
   width so the labels align into a column whether the glyph renders as a flag
   (mac/iOS/Android/Linux) or as a two-letter code (Windows ships no flags). */
.langdd__flag {
  flex: none;
  width: 1.5em;
  font-size: 15px;
  line-height: 1;
  text-align: center;
}

.langdd__menu button:hover {
  background: var(--ink-800);
  color: var(--text);
}

.langdd__menu button.is-active {
  background: var(--gold);
  color: var(--on-gold);
}

/* ── Block variant: fills its container (used inside the profile menu) ── */
.langdd--block,
.langdd--block .langdd__btn {
  width: 100%;
}

.langdd--block .langdd__btn {
  justify-content: flex-start;
  border-radius: var(--radius-s);
  background: var(--ink-800);
  border-color: var(--line-strong);
}

@keyframes langdd-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .langdd__caret,
  .langdd__menu {
    transition: none;
    animation: none;
  }
}

/* Guest-only adaptation: character selection and unavailable account routes. */
#profile-popover .pmenu__avatar { padding: 0; background: var(--ink-600); }
.pmenu__avatar canvas { display: block; width: 46px; height: 46px; border-radius: 50%; image-rendering: pixelated; }
.pmenu__item:disabled { opacity: .35; cursor: not-allowed; }
.pmenu__item:disabled:hover { background: transparent; color: var(--text); }
.pmenu__item:disabled:hover svg { color: var(--text-faint); }
.pmenu__rank { color: var(--gold); }
.pmenu__xp-meta { gap: 8px; }
