/**
 * Shared flyout menu (top-right ☰) — uniform 2-column tiles, scrollable panel.
 * Open state: .menu-panel.is-open (wired in pwa-menu.js)
 */
:root {
  --menu-accent: #1d6ea4;
  --menu-accent-mid: #156a9e;
  --menu-surface: rgba(14, 20, 30, 0.96);
  --menu-border: rgba(255, 255, 255, 0.1);
  --menu-item-bg: rgba(255, 255, 255, 0.07);
  --menu-item-border: rgba(255, 255, 255, 0.11);
  --menu-text: rgba(255, 255, 255, 0.94);
  --menu-tile-h: 46px;
}

.top-nav {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  z-index: 30;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  pointer-events: none;
}

.top-nav--with-back {
  justify-content: space-between;
}

.back-wrap {
  position: relative;
  pointer-events: auto;
}

.back-btn {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 16, 24, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #fff;
  padding: 0;
  margin: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  transition: transform 0.14s ease, background 0.14s ease, border-color 0.14s ease,
    box-shadow 0.14s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.back-btn__icon {
  font-size: 30px;
  line-height: 1;
  font-weight: 300;
  transform: translateY(-1px);
}

.back-btn:hover {
  background: rgba(20, 30, 44, 0.9);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.48);
}

.back-btn:active {
  transform: scale(0.96);
}

.menu-wrap {
  position: relative;
  pointer-events: auto;
}

.menu-btn {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 16, 24, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  transition: transform 0.14s ease, background 0.14s ease, border-color 0.14s ease,
    box-shadow 0.14s ease;
}

.menu-btn:hover {
  background: rgba(20, 30, 44, 0.9);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.48);
}

.menu-btn:active {
  transform: scale(0.96);
}

.menu-panel {
  position: absolute;
  top: calc(48px + 10px);
  right: 0;
  width: min(328px, calc(100vw - 24px));
  padding: 10px;
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
  border-radius: 18px;
  border: 1px solid var(--menu-border);
  background: var(--menu-surface);
  backdrop-filter: blur(20px) saturate(1.25);
  -webkit-backdrop-filter: blur(20px) saturate(1.25);
  box-shadow:
    0 28px 56px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  max-height: min(72dvh, calc(100dvh - env(safe-area-inset-top) - 76px));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}

.menu-panel.is-open {
  display: grid;
}

.menu-panel::-webkit-scrollbar {
  width: 6px;
}

.menu-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.24);
  border-radius: 999px;
}

/* Uniform tile — every menu link uses the same design */
.menu-panel a[href],
.menu-panel .menu-tile,
.menu-panel .nav-item {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--menu-tile-h);
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--menu-item-border);
  background: var(--menu-item-bg);
  color: var(--menu-text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.01em;
  text-align: center;
  text-decoration: none;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease,
    color 0.12s ease, box-shadow 0.12s ease;
}

.menu-panel a[href]:hover,
.menu-panel .menu-tile:hover,
.menu-panel .nav-item:hover {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.18);
}

.menu-panel a[href]:active,
.menu-panel .menu-tile:active,
.menu-panel .nav-item:active {
  transform: scale(0.98);
}

.menu-panel a[href].active,
.menu-panel .menu-tile.active,
.menu-panel .nav-item.active {
  color: #fff;
  background: linear-gradient(165deg, rgba(42, 143, 212, 0.95), var(--menu-accent) 55%, var(--menu-accent-mid));
  border-color: rgba(42, 143, 212, 0.55);
  box-shadow: 0 6px 18px rgba(29, 110, 164, 0.32);
}

.menu-panel-divider {
  grid-column: 1 / -1;
  border: none;
  height: 1px;
  margin: 2px 0;
  width: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.14) 20%,
    rgba(255, 255, 255, 0.14) 80%,
    transparent
  );
}

.revision-tap-pulse {
  transform: scale(0.97);
  opacity: 0.92;
  transition: transform 0.08s ease, opacity 0.08s ease;
}
