/* ═══════════════════════════════════════════════
   MENU — Sidebar + Center layout
════════════════════════════════════════════════ */
.menu-layout {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  overflow: hidden;
}

/* Top bar */
.menu-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 36px;
  height: 64px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.menu-logo {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 24px;
  color: var(--text);
  letter-spacing: .12em;
  user-select: none;
}
.menu-logo span { color: var(--accent); }
.menu-topbar-right {
  display: flex;
  align-items: center;
  gap: 24px;
}
.menu-topbar-center {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.menu-topbar-username {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 20px;
  color: var(--text);
  letter-spacing: .1em;
}
.menu-topbar-elo {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .08em;
}
.menu-topbar-streak {
  font-size: 14px;
  color: var(--accent2);
  letter-spacing: .05em;
}
.menu-logout {
  background: none; border: none;
  font-size: 10px; color: var(--muted);
  letter-spacing: .15em; cursor: pointer;
  transition: color .2s;
}
.menu-logout:hover { color: var(--text); }

/* Body below topbar: sidebar + main */
.menu-body {
  display: grid;
  grid-template-columns: 220px 1fr;
  flex: 1;
  min-height: calc(100vh - 64px);
}

/* Sidebar */
.menu-sidebar {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  gap: 2px;
  position: relative;
  min-height: calc(100vh - 64px);
}
#nav-home-btn {
  position: fixed;
  bottom: 40px;
  left: 0;
  width: 220px;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 14px 24px;
  background: none;
  border: none;
  border-left: 2px solid transparent;
  cursor: pointer;
  text-align: left;
  transition: background .15s, border-color .15s;
  width: 100%;
}
.nav-item:hover {
  background: rgba(255,255,255,.03);
}
.nav-item--green { border-left-color: var(--accent); }
.nav-item--amber { border-left-color: var(--accent2); }
.nav-item--dim   { border-left-color: var(--border); }
.nav-item--green:hover { border-left-color: var(--accent); background: rgba(0,255,136,.04); }
.nav-item--amber:hover { border-left-color: var(--accent2); background: rgba(255,180,0,.04); }

.nav-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 17px;
  letter-spacing: .08em;
  line-height: 1;
}
.nav-item--green .nav-title { color: var(--accent); }
.nav-item--amber .nav-title { color: var(--accent2); }
.nav-item--dim   .nav-title { color: var(--text); }

.nav-sub {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: .04em;
  line-height: 1.5;
}
.nav-sub.solved { color: var(--accent); }

.nav-rank {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  color: var(--accent2);
  margin-top: 2px;
  letter-spacing: .05em;
}

.nav-spacer {
  flex: 1;
}

/* Main content area */
.menu-main {
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.menu-greeting {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .2em;
  margin-bottom: 8px;
}
.menu-username-big {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 64px;
  color: var(--accent);
  line-height: 1;
  letter-spacing: .04em;
}
.menu-divider {
  width: 48px; height: 1px;
  background: var(--border);
  margin: 20px 0;
}
.menu-streak-line {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: .04em;
}

/* ── PUZZLE layout inside menu-main ── */
#menu-puzzle {
  display: none;
  flex-direction: column;
  flex: 1;
  position: relative;
  animation: fadeIn .3s ease;
  overflow: hidden;
}
#menu-puzzle.active { display: flex; }

/* Puzzle sub-topbar inside menu-main */
.puzzle-subbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
  flex-shrink: 0;
}

.tab-btn {
  padding: 6px 18px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 15px;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: all .15s;
}
.tab-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}
.tab-btn:hover:not(.active) { color: var(--text); }

.back-btn {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all .15s;
}
.back-btn:hover { border-color: var(--muted); color: var(--text); }

/* Tab content */
.tab-content { display: none; flex: 1; }
.tab-content.active { display: flex; }

/* session-done is inside #menu-puzzle — position absolute */
#session-done {
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  animation: fadeIn .4s ease;
}
#session-done.show { display: flex; }

/* ── Progress dashboard grids ───────────────────────────────────────────────── */

.progress-stat-strip {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.progress-card-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 16px;
}

/* Large screens — scale up font sizes proportionally */
@media (min-width: 1440px) {
  .menu-main         { padding: 56px 72px; }
  .menu-username-big { font-size: 80px; }
  .menu-greeting     { font-size: 11px; letter-spacing: .25em; }
  .menu-streak-line  { font-size: 15px; }
  .menu-divider      { margin: 28px 0; }
  .nav-title         { font-size: 19px; }
  .nav-sub           { font-size: 11px; }
  .nav-item          { padding: 16px 28px; }
}

/* Medium screens — 2×2 layout */
@media (max-width: 1100px) {
  .menu-main { padding: 36px 32px; }
  .progress-stat-strip { grid-template-columns: 1fr 1fr; }
  .progress-card-grid  { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  /* Topbar */
  .menu-topbar { padding: 0 16px; }
  .menu-topbar-center { display: none; }
  .menu-topbar-right { gap: 10px; }

  /* Sidebar → horizontal tab row */
  .menu-body { grid-template-columns: 1fr; }
  .menu-sidebar { border-right: none; border-bottom: 1px solid var(--border); padding: 8px 0; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; min-height: unset; }
  .nav-item { width: auto; min-width: 120px; border-left: none; border-bottom: 2px solid transparent; padding: 10px 16px; flex-shrink: 0; }
  .nav-item--green { border-bottom-color: var(--accent); }
  .nav-item--amber { border-bottom-color: var(--accent2); }
  .nav-title { font-size: 15px; }
  .nav-sub { font-size: 9px; }

  /* HOME button: was position:fixed in desktop sidebar, must be static on mobile */
  #nav-home-btn { position: static; width: auto; }

  /* Main content */
  .menu-main { padding: 16px; }
  .menu-username-big { font-size: 40px; }
  .menu-divider { margin: 12px 0; }

  /* Progress dashboard */
  .progress-stat-strip { grid-template-columns: 1fr 1fr; }
  .progress-card-grid  { grid-template-columns: 1fr; }
}

/* Home panels fade/slide in as their data resolves, so the async cascade reads
   as an intentional reveal instead of hard pop-ins. */
@keyframes homeFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
.home-fade-in { animation: homeFadeIn 0.28s ease both; }
