/* ================================================================
   nav.css — shared site navigation
   Loaded by every page. Fixed height: 60px always.
   ================================================================ */

#site-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  height: calc(60px + env(safe-area-inset-top, 0px));
  padding: 0 32px;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--surface);
  border-bottom: 1px solid var(--toolbar-border);
  flex-shrink: 0;
}

/* Logo — matches the same muted currentColor the nav icon links/buttons
   resolve to, so the wordmark reads as the same lighter tone as the rest
   of the nav bar's icons. */
#site-nav .nav-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-right: 20px;
  text-decoration: none;
  color: var(--text-muted);
}
#site-nav .nav-logo img,
#site-nav .nav-logo svg {
  height: 40px;
  display: block;
  width: auto;
}

/* Standalone logo mark used outside #site-nav (board/wall toolbars) —
   same muted currentColor as the main nav's wordmark, for consistency. */
#logo-slot {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
}

/* Left links (About etc.) */
#site-nav .nav-left {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

/* Right links (Join, Teacher, CTA) */
#site-nav .nav-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

/* Base link style */
#site-nav a,
#site-nav button.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 11px;
  border-radius: 7px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  transition: background .12s, color .12s;
  white-space: nowrap;
  line-height: 1;
}
#site-nav a:hover,
#site-nav button.nav-link:hover {
  background: none;
  color: var(--text-muted);
}

/* Active page indicator */
#site-nav a.nav-active {
  color: var(--purple);
  font-weight: 600;
  background: var(--purple-light);
}

/* Separator */
#site-nav .nav-sep {
  width: 1px;
  height: 20px;
  background: var(--toolbar-border);
  margin: 0 6px;
  flex-shrink: 0;
}

/* Signed-in user name pill */
#site-nav .nav-user {
  font-size: 13px;
  font-weight: 600;
  color: var(--btn-text);
  padding: 6px 10px;
  border-radius: 7px;
  white-space: nowrap;
}

/* CTA button */
#site-nav .nav-cta {
  font-size: 13px;
  font-weight: 600;
  color: #fff !important;
  background: var(--purple) !important;
  padding: 7px 16px;
  border-radius: 8px;
  border: none;
  text-decoration: none;
  transition: background .12s !important;
}
#site-nav .nav-cta:hover {
  background: var(--purple-dark) !important;
}

/* More dropdown */
#site-nav .nav-dropdown {
  position: relative;
}
#site-nav .nav-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 4px;
}
#site-nav .nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--toolbar-border);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  padding: 6px;
  z-index: 600;
}
#site-nav .nav-dropdown.open .nav-dropdown-menu {
  display: block;
}
#site-nav .nav-dropdown-menu a {
  display: block;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}
#site-nav .nav-dropdown-menu a:hover {
  background: var(--btn-hover);
  color: var(--btn-text);
}
#site-nav .nav-dropdown-menu a.nav-dd-active {
  color: var(--purple);
  font-weight: 600;
  background: var(--purple-light);
}
#site-nav .nav-dropdown-menu.nav-dd-right {
  left: auto;
  right: 0;
}
.nav-dd-sep {
  height: 1px;
  background: var(--toolbar-border);
  margin: 4px 6px;
}
.nav-dd-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 12px 2px;
  opacity: 0.6;
}

/* Global Challenge status pill — follows the challenged game's own palette. */
#site-nav .nav-challenge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--challenge-color,var(--purple)) !important;
  background: color-mix(in srgb,var(--challenge-color,var(--purple)) 14%,var(--surface));
  border:1px solid color-mix(in srgb,var(--challenge-color,var(--purple)) 24%,var(--btn-border));
  border-radius: 7px;
  height:25px;
  padding:0 11px;
}
#site-nav .nav-challenge:hover {
  background: var(--challenge-color,var(--purple)) !important;
  color: #fff !important;
}
#site-nav .nav-challenge > span,
#site-nav .nav-scheduled-game > span { display:inline-flex; align-items:center; gap:6px; }
#site-nav .nav-challenge svg,
#site-nav .nav-scheduled-game svg { width:13px; height:13px; flex:none; }
#site-nav .nav-scheduled-game {
  display:inline-flex;
  align-items:center;
  gap:6px;
  height:25px;
  padding:0 11px;
  border-radius:7px;
  background:color-mix(in srgb,var(--scheduled-bg) 76%,var(--surface));
  color:var(--scheduled-color) !important;
  font-size:13px;
  font-weight:600;
  text-decoration:none;
}
#site-nav .nav-scheduled-game:hover { background:var(--scheduled-color) !important; color:#fff !important; }

/* ── Footer ───────────────────────────────────────────────── */
#site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: 48px;
  background: var(--surface);
  border-top: 1px solid var(--toolbar-border);
  flex-shrink: 0;
}
#site-footer .footer-copy {
  font-size: 12px;
  color: var(--text-muted);
}
#site-footer .footer-links {
  display: flex;
  align-items: center;
  gap: 2px;
}
#site-footer a {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 6px;
}
#site-footer a:hover {
  color: var(--btn-text);
}

/* Mobile — collapse left links, keep right */
@media (max-width: 700px) {
  #site-nav { padding: 0 16px; }
  #site-nav .nav-left { display: none; }
  #site-nav .nav-logo { margin-right: 0; }
}
@media (max-width: 480px) {
  #site-nav .nav-sep { display: none; }
  #site-nav .nav-right a:not(.nav-cta) { display: none; }
}

/* ── Other Projects side drawer ───────────────────────────── */
.proj-tab {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  background: var(--purple);
  color: #fff;
  padding: 18px 10px;
  border-radius: 0 10px 10px 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
  z-index: 920;
  border: none;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: background .15s, padding-left .15s;
  box-shadow: 2px 0 12px rgba(83,74,183,.2);
}
.proj-tab:hover { background: var(--purple-dark); padding-left: 14px; }


.proj-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1005;
  display: none;
}
.proj-backdrop.show { display: block; }

.proj-drawer {
  position: fixed;
  left: -300px;
  top: 0;
  height: 100%;
  width: 272px;
  background: var(--surface);
  border-right: 1px solid var(--toolbar-border);
  box-shadow: 8px 0 32px rgba(0,0,0,.12);
  z-index: 1010;
  transition: left .25s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
  padding: 0;
}
.proj-drawer.open { left: 0; }

.proj-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
}

.proj-drawer .proj-panel { padding: 16px 20px 20px; }
.proj-drawer-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--purple);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.proj-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--btn-border);
  background: none;
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s;
  padding: 0;
}
.proj-close:hover { background: var(--btn-hover); color: var(--btn-text); }

.proj-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--toolbar-border);
  background: var(--bg);
  text-decoration: none;
  color: var(--btn-text);
  margin-bottom: 10px;
  transition: border-color .12s, background .12s, transform .12s;
}
.proj-item:hover {
  border-color: var(--purple);
  background: var(--purple-light);
  transform: translateX(2px);
}
.proj-item-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--dgc-bg, var(--purple-light));
  color: var(--dgc-color, var(--purple));
  border: 1px solid color-mix(in srgb, var(--dgc-color, var(--btn-text)) 55%, transparent);
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.proj-item-icon svg { width: 22px; height: 22px; }
.proj-item-name { font-size: 14px; font-weight: 700; margin-bottom: 3px; }
.proj-item-desc { font-size: 12px; color: var(--text-muted); }

.proj-item--featured {
  border-color: var(--purple);
  background: var(--purple-light);
}
.proj-item--featured:hover { filter: brightness(0.95); transform: translateX(2px); }
.proj-item--featured .proj-item-icon { background: var(--purple); color: #fff; }
.proj-item--scheduled { margin-top:8px; cursor:pointer; border-color:color-mix(in srgb,var(--scheduled-color) 35%,var(--btn-border)); background:color-mix(in srgb,var(--scheduled-color) 13%,var(--surface)); }
.proj-item--scheduled:hover { transform:translateX(2px); filter:brightness(.96); }
.proj-item--scheduled .proj-item-icon { color:var(--scheduled-color); background:var(--scheduled-bg); }
.proj-item--scheduled .proj-item-desc { color:var(--scheduled-color); font-weight:700; }

/* Scheduled solo-game unavailable view: navigation stays usable above it. */
#mb-game-access-pending { position:fixed; z-index:900; top:calc(60px + env(safe-area-inset-top,0px)); right:0; bottom:0; left:0; display:grid; place-items:center; background:var(--bg); color:var(--purple); }
.mb-access-spinner { width:34px; height:34px; border:4px solid var(--purple-light); border-top-color:var(--purple); border-radius:50%; animation:mb-access-spin .7s linear infinite; }
@keyframes mb-access-spin { to { transform:rotate(360deg); } }
#mb-game-unavailable { position:fixed; z-index:900; top:calc(60px + env(safe-area-inset-top,0px)); right:0; bottom:0; left:0; display:flex; align-items:center; justify-content:center; padding:24px; overflow:auto; background:var(--bg); color:var(--btn-text); text-align:center; }
.mb-unavailable-card { position:relative; isolation:isolate; overflow:hidden; width:min(100%,620px); min-height:340px; display:flex; flex-direction:column; align-items:center; justify-content:center; padding:42px 36px; border:1.5px solid color-mix(in srgb,var(--unavailable-game-color) 35%,var(--btn-border)); border-radius:24px; background:color-mix(in srgb,var(--unavailable-game-color) 13%,var(--surface)); box-shadow:0 18px 55px color-mix(in srgb,var(--btn-text) 14%,transparent); }
.mb-unavailable-watermark { position:absolute; z-index:-1; left:-48px; bottom:-55px; width:230px; height:230px; color:var(--unavailable-game-color); opacity:.1; transform:rotate(-9deg); }
.mb-unavailable-watermark svg { width:100%; height:100%; }
.mb-unavailable-icon { display:grid; place-items:center; width:62px; height:62px; margin-bottom:20px; border-radius:17px; color:var(--unavailable-game-color); background:var(--unavailable-game-bg); box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--unavailable-game-color) 14%,transparent); }
.mb-unavailable-icon svg { width:34px; height:34px; }
.mb-unavailable-card h1 { margin:0 0 12px; color:var(--btn-text); font-size:clamp(23px,4vw,31px); line-height:1.2; }
.mb-unavailable-card p { margin:0 0 27px; color:var(--text-muted); font-size:16px; line-height:1.55; }
.mb-unavailable-card > a { display:inline-flex; align-items:center; justify-content:center; padding:12px 22px; border-radius:12px; background:var(--purple); color:var(--surface); font-size:15px; font-weight:800; text-decoration:none; }
.mb-unavailable-card > a:hover { background:var(--purple-dark); color:var(--surface); }
body.proj-sidebar #mb-game-unavailable,body.proj-sidebar #mb-game-access-pending { left:272px; }
@media(max-width:700px){body.proj-sidebar #mb-game-unavailable,body.proj-sidebar #mb-game-access-pending{left:0}.mb-unavailable-card{min-height:300px;padding:34px 22px}.mb-unavailable-watermark{width:180px;height:180px}}
@media(prefers-reduced-motion:reduce){.mb-access-spinner{animation:none}}

.proj-item-divider {
  border: none;
  border-top: 1px solid var(--toolbar-border);
  margin: 4px 0 12px;
}

/* ── Game Menu — categorized icon grid ──────────────────────── */
:root {
  --cat-maths:    #2d7dd2;
  --cat-words:    #D97706;
  --cat-logic:    #3e9a4a;
  --cat-creative: #D946A0;
}
.proj-cat { margin-bottom: 18px; }
.proj-cat:last-child { margin-bottom: 0; }
.proj-cat-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 9px;
  padding: 0 2px;
}
.proj-cat-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.proj-cat-name {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.proj-tile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.proj-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.proj-tile-icon {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid color-mix(in srgb, var(--dgc-color, var(--btn-text)) 55%, transparent);
  box-shadow: var(--shadow);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--dgc-bg, var(--surface-2));
  color: var(--dgc-color, var(--btn-text));
  transition: transform .12s, background .12s;
}
.proj-tile-icon svg { width: 46%; height: 46%; }
.proj-tile:hover .proj-tile-icon { transform: translateY(-1px); }
.proj-tile:active .proj-tile-icon { transform: scale(.94); }
.proj-tile-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: none;
  color: var(--btn-text);
  text-align: center;
  line-height: 1.25;
}

/* ── Sidebar mode (home page) ─────────────────────────────── */
/* Shifts page content right so the drawer is a real column,  */
/* not an overlay. Nav bar sits in the right column above it. */
body.proj-sidebar {
  margin-left: 272px;
}
body.proj-sidebar .proj-drawer {
  z-index: 900;        /* below site-nav (1000) so nav overlaps at top */
  transition: none;    /* no slide animation — always open */
  box-shadow: 1px 0 0 var(--toolbar-border);
}
body.proj-sidebar .proj-tab      { display: none !important; }
body.proj-sidebar .proj-backdrop { display: none !important; }

@media (max-width: 700px) {
  /* On mobile, revert to normal drawer behaviour */
  body.proj-sidebar { margin-left: 0; }
  body.proj-sidebar .proj-drawer { z-index: 1010; transition: left .25s cubic-bezier(.4,0,.2,1); }
  body.proj-sidebar .proj-tab    { display: flex !important; }
}

/* ── Theme picker ──────────────────────────────────────────── */
.nav-theme-wrap {
  position: relative;
  flex-shrink: 0;
}
.nav-theme-menu {
  display: none;
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--toolbar-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 9100;
  min-width: 130px;
}
.nav-theme-menu.open { display: block; }
.nav-theme-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background .12s, color .12s;
}
.theme-swatches {
  display: flex;
  gap: 3px;
  align-items: center;
  flex-shrink: 0;
  background: var(--sw1);
  border-radius: 20px;
  padding: 3px 6px;
  border: 1px solid rgba(0,0,0,.15);
}
.theme-swatches span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.15);
  flex-shrink: 0;
}

/* Swatch colors — update these when a theme's palette changes */
.nav-theme-opt[data-theme="light"]  { --sw1: #f0eee8; --sw2: #534AB7; }
.nav-theme-opt[data-theme="dark"]   { --sw1: #111318; --sw2: #7B74D8; }
.nav-theme-opt[data-theme="ocean"]  { --sw1: #0b1e35; --sw2: #4BAED6; }
.nav-theme-opt[data-theme="forest"] { --sw1: #141f14; --sw2: #5EC05E; }
.nav-theme-opt[data-theme="rose"]   { --sw1: #fdf2f5; --sw2: #D946A0; }
.nav-theme-opt[data-theme="sand"]   { --sw1: #faf5ec; --sw2: #D97706; }
.nav-theme-opt[data-theme="sky"]    { --sw1: #eff6ff; --sw2: #2d7dd2; }
.nav-theme-opt[data-theme="slate"]  { --sw1: #1e2433; --sw2: #8899dd; }
.nav-theme-opt[data-theme="dusk"]   { --sw1: #12101e; --sw2: #C084FC; }
.nav-theme-opt[data-theme="high-contrast"] { --sw1: #ffffff; --sw2: #000000; }
.theme-swatches span { background: var(--sw2); }
.nav-theme-opt:hover {
  background: var(--btn-hover);
  color: var(--btn-text);
}
.nav-theme-opt.active {
  color: var(--purple);
  font-weight: 600;
}
.nav-theme-divider {
  height: 1px;
  margin: 5px 6px;
  background: var(--toolbar-border);
}
.nav-theme-section-label {
  padding: 3px 12px 2px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.nav-pattern-preview {
  width: 28px;
  height: 20px;
  flex-shrink: 0;
  border: 1px solid var(--toolbar-border);
  border-radius: 5px;
  background-color: var(--surface-2);
}
.nav-pattern-preview.mb-pattern-none {
  background-image: none;
}

/* ── Info dropdown ─────────────────────────────────────────── */
.nav-info-wrap {
  position: relative;
  flex-shrink: 0;
}
.nav-info-menu {
  display: none;
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--toolbar-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 9100;
  min-width: 150px;
}
.nav-info-menu.open { display: block; }
.nav-info-opt {
  display: block;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: background .12s, color .12s;
  white-space: nowrap;
}
.nav-info-opt:hover {
  background: var(--btn-hover);
  color: var(--btn-text);
}


/* ── Site QR modal ──────────────────────────────────────────── */
#nav-qr-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 9500;
}
#nav-qr-modal {
  background: var(--surface); border-radius: 18px; padding: 36px 40px;
  text-align: center; width: 320px; max-width: 92vw;
  box-shadow: 0 24px 60px rgba(0,0,0,.2); position: relative;
}
#nav-qr-close {
  position: absolute; top: 14px; right: 16px;
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--btn-border); background: var(--surface);
  font-size: 16px; font-weight: 700; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  color: var(--btn-text);
}
#nav-qr-close:hover { background: #FCEBEB; border-color: #E24B4A; color: #A32D2D; }
#nav-qr-modal h2 { font-size: 17px; font-weight: 700; color: var(--btn-text); margin-bottom: 4px; }
.nav-qr-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
#nav-qr-canvas { display: flex; justify-content: center; margin-bottom: 16px; }
#nav-qr-canvas img, #nav-qr-canvas canvas { border-radius: 8px; border: 4px solid var(--surface); box-shadow: 0 2px 12px rgba(0,0,0,.1); }
.nav-qr-url { font-size: 11px; color: var(--text-muted); word-break: break-all; margin-bottom: 18px; line-height: 1.5; }
.nav-qr-copy-btn {
  width: 100%; padding: 10px; background: var(--purple); color: #fff;
  border: none; border-radius: 9px; font-size: 13px; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: background .12s;
}
.nav-qr-copy-btn:hover { background: var(--purple-dark); }
