/**
 * Menu Page — Warm & Earthen bento grid
 * Layout preserved; palette + type retuned to the v2 design language.
 */

:root {
  --menu-bg: #f4ecdc;
  --menu-surface: #fbf6ea;
  --menu-text: #2d2114;
  --menu-text-secondary: #6b5a45;
  --menu-border: #e2d5bd;
  --menu-primary: #bf5e1a;
  --menu-primary-dark: #9c4a13;
  --menu-gold: #b8862f;
  --menu-gold-bg: #f7edcf;
  --menu-gold-border: #ddc081;
  --menu-sage: #6c7a4f;
  --menu-sage-deep: #4f5c38;
  --menu-radius: 16px;
  --menu-shadow:
    0 1px 2px rgba(74, 52, 28, 0.06), 0 8px 20px -14px rgba(74, 52, 28, 0.3);
  --menu-display: "Fraunces", Georgia, serif;
  --menu-body: "Hanken Grotesk", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  font-family: var(--menu-body);
  background: var(--menu-bg);
  background-image: radial-gradient(
    rgba(120, 90, 50, 0.035) 1px,
    transparent 1px
  );
  background-size: 4px 4px;
  color: var(--menu-text);
  -webkit-font-smoothing: antialiased;
}

/* Page - centered vertically and horizontally */
.menu-page {
  min-height: 100vh;
  padding: calc(env(safe-area-inset-top, 16px) + 20px) 16px
    calc(env(safe-area-inset-bottom, 16px) + 16px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

/* Back nav - fixed top left */
.menu-nav {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top, 0px));
  left: 16px;
  z-index: 10;
}

.back-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px 9px 11px;
  border-radius: 100px;
  color: var(--menu-text);
  background: var(--menu-surface);
  border: 1px solid var(--menu-border);
  box-shadow: var(--menu-shadow);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
}

.back-link:hover {
  background: #f3ead6;
}

.back-link svg {
  flex-shrink: 0;
}

/* Bento Grid - 2 columns */
.menu-bento {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 500px;
  width: 100%;
}

.menu-bento__footer {
  grid-column: 1 / -1;
}

/* ============================================
   Updates Available Banner (full width row)
   ============================================ */
.updates-banner {
  grid-column: 1 / -1;
}

.updates-banner.hidden {
  display: none;
}

.updates-banner__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  background: #eef0e2;
  border: 1.5px solid #b8c08f;
  border-radius: var(--menu-radius);
  color: var(--menu-sage-deep);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.updates-banner__btn:hover {
  background: #e6e9d6;
}

.updates-banner__btn:active {
  transform: scale(0.99);
}

.updates-banner__btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.updates-banner__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.updates-banner__title {
  font-size: 14px;
  font-weight: 600;
}

.updates-banner__desc {
  font-size: 11px;
  opacity: 0.8;
}

/* ============================================
   Brand Cell (left of row 1)
   ============================================ */
.menu-bento__brand {
  background: var(--menu-surface);
  border-radius: var(--menu-radius);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--menu-shadow);
  border: 1px solid var(--menu-border);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  width: 44px;
  height: 44px;
}

.brand-title {
  font-family: var(--menu-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--menu-text);
}

/* ============================================
   Half Tiles (1-col each, side by side)
   ============================================ */
.half-tile {
  border-radius: var(--menu-radius);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-decoration: none;
  box-shadow: var(--menu-shadow);
  transition: transform 0.1s;
}

.half-tile:hover {
  transform: scale(1.01);
}

.half-tile:active {
  transform: scale(0.99);
}

.half-tile__icon,
.half-tile svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.half-tile__title {
  font-family: var(--menu-display);
  font-size: 15px;
  font-weight: 600;
}

.half-tile__desc {
  font-size: 10.5px;
  text-align: center;
  line-height: 1.3;
}

.half-tile--leaderboard {
  background: var(--menu-gold-bg);
  border: 1.5px solid var(--menu-gold-border);
  color: var(--menu-text);
}

.half-tile--leaderboard svg {
  color: var(--menu-gold);
}

.half-tile--leaderboard .half-tile__desc {
  color: var(--menu-text-secondary);
}

.half-tile--guide {
  background: linear-gradient(135deg, #8a3f1d 0%, #a8492c 100%);
  color: #fbf6ea;
}

.half-tile--guide svg {
  opacity: 0.92;
}

.half-tile--guide .half-tile__desc {
  color: rgba(251, 246, 234, 0.78);
}

/* ============================================
   Action Rows (full width, bigger for mobile)
   ============================================ */
.action-row {
  grid-column: 1 / -1;
  border-radius: var(--menu-radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--menu-shadow);
}

.action-row--route {
  background: linear-gradient(135deg, #6c7a4f 0%, #56683f 100%);
  color: #fbf6ea;
}

.action-row--route .action-row__label {
  color: #fbf6ea;
}

.action-row--route .action-row__icon {
  color: rgba(251, 246, 234, 0.9);
}

.action-row--route .action-row__select {
  background: rgba(251, 246, 234, 0.96);
  color: var(--menu-sage-deep);
  border: none;
}

.action-row--route .action-row__select:focus {
  outline: 2px solid rgba(251, 246, 234, 0.5);
}

.action-row--leafshell {
  background: linear-gradient(135deg, #5b8a3c 0%, #46702f 100%);
}

.action-row--leafshell .action-row__label {
  color: #fbf6ea;
}

.action-row__header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.action-row__icon {
  width: 28px;
  height: 28px;
}

.action-row__img {
  width: 32px;
  height: 32px;
}

.action-row__label {
  font-family: var(--menu-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.action-row__select {
  flex: 1;
  max-width: 200px;
  padding: 10px 14px;
  border-radius: 8px;
  font-family: var(--menu-body);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.action-row__buttons {
  display: flex;
  gap: 8px;
}

.action-row__btn {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
  text-decoration: none;
  color: #3a5524;
  background: rgba(251, 246, 234, 0.92);
  transition: background 0.15s;
}

.action-row__btn:active {
  background: #fbf6ea;
}

.action-row__btn--alt {
  background: rgba(251, 246, 234, 0.6);
}

/* ============================================
   Nav Stack (left of row 2)
   ============================================ */
.nav-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-tile {
  background: var(--menu-surface);
  border: 1px solid var(--menu-border);
  border-radius: var(--menu-radius);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--menu-text);
  box-shadow: var(--menu-shadow);
  transition:
    transform 0.1s,
    box-shadow 0.15s;
}

.nav-tile:hover {
  box-shadow: 0 6px 16px -8px rgba(74, 52, 28, 0.4);
}

.nav-tile:active {
  transform: scale(0.98);
}

.nav-tile__icon {
  width: 24px;
  height: 24px;
  color: var(--menu-primary-dark);
}

.nav-tile span {
  font-size: 13px;
  font-weight: 600;
}

/* ============================================
   Help Out Tile (right of row 1, next to brand)
   ============================================ */
.help-tile {
  background: var(--menu-gold-bg);
  border: 1.5px solid var(--menu-gold-border);
  border-radius: var(--menu-radius);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-decoration: none;
  color: var(--menu-text);
  box-shadow: var(--menu-shadow);
  transition: transform 0.1s;
}

.help-tile:hover {
  transform: scale(1.01);
}

.help-tile:active {
  transform: scale(0.99);
}

.help-tile__icon {
  width: 24px;
  height: 24px;
  color: #b04a2f;
}

.help-tile__title {
  font-family: var(--menu-display);
  font-size: 15px;
  font-weight: 600;
}

.help-tile__desc {
  font-size: 10.5px;
  color: var(--menu-text-secondary);
  text-align: center;
  line-height: 1.3;
}

/* ============================================
   Coffee Tile (left of row 3)
   ============================================ */
.coffee-tile {
  background: var(--menu-primary);
  border-radius: var(--menu-radius);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  color: #fff;
  font-family: var(--menu-display);
  font-size: 15px;
  font-weight: 600;
  box-shadow: var(--menu-shadow);
  transition: background 0.15s;
}

.coffee-tile:hover {
  background: var(--menu-primary-dark);
}

.coffee-tile svg {
  width: 20px;
  height: 20px;
}

/* ============================================
   Controls Row (full width)
   ============================================ */
.controls-stack {
  grid-column: 1 / -1;
  display: flex;
  gap: 12px;
}

.control-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 16px;
  background: var(--menu-surface);
  border: 1px solid var(--menu-border);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--menu-text);
  cursor: pointer;
  box-shadow: var(--menu-shadow);
  transition: all 0.15s;
}

.control-btn svg {
  width: 16px;
  height: 16px;
}

.control-btn:hover {
  border-color: var(--menu-text-secondary);
}

.control-btn:active {
  transform: scale(0.98);
}

.control-btn--danger {
  color: #b04a2f;
}

.control-btn--danger:hover {
  border-color: #b04a2f;
  background: #fbeae1;
}

/* App update glow on Restart App button */
@keyframes pulse-glow {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(191, 94, 26, 0.55);
  }
  50% {
    box-shadow: 0 0 12px 4px rgba(191, 94, 26, 0.38);
  }
}

.control-btn.has-app-update {
  animation: pulse-glow 2s ease-in-out infinite;
  border-color: var(--menu-primary);
}

.app-update-hint {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--menu-primary);
  margin: -4px 0 0;
}

/* ============================================
   Footer
   ============================================ */
.menu-bento__footer {
  text-align: center;
  padding: 12px 0 4px;
}

.footer-copyright {
  font-size: 11px;
  color: var(--menu-text-secondary);
}

.footer-copyright a {
  color: inherit;
}

.footer-version {
  font-size: 11px;
  color: var(--menu-text-secondary);
  margin-top: 2px;
}

.footer-version a {
  color: var(--menu-primary);
  text-decoration: none;
}

.footer-version a:hover {
  text-decoration: underline;
}

/* ============================================
   Prefetch Tile (download next stage)
   ============================================ */
.action-row--prefetch {
  background: linear-gradient(135deg, #5a7185 0%, #47596e 100%);
  color: #fff;
  flex-direction: column;
  gap: 0;
}

.action-row--prefetch .action-row__icon {
  color: rgba(255, 255, 255, 0.9);
}

.action-row--prefetch .action-row__label {
  color: #fff;
}

.prefetch-tile__default {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 16px;
}

.action-row__btn--prefetch {
  background: rgba(255, 255, 255, 0.95);
  color: #47596e;
  font-weight: 700;
  border: none;
  cursor: pointer;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  transition: background 0.15s;
}

.action-row__btn--prefetch:active {
  background: white;
}

.prefetch-tile__progress {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.prefetch-tile__info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.prefetch-tile__label {
  font-size: 13px;
  font-weight: 600;
}

.prefetch-tile__stats {
  font-size: 12px;
  opacity: 0.8;
}

.prefetch-tile__bar-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  overflow: hidden;
}

.prefetch-tile__bar-fill {
  height: 100%;
  background: white;
  border-radius: 3px;
  width: 0;
  transition: width 0.3s ease;
}

.prefetch-tile__cancel {
  align-self: flex-end;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.prefetch-tile__cancel:hover {
  background: rgba(255, 255, 255, 0.25);
}
