/* The small rounded-rectangle buttons shared by the website's pages and
   Connect: the back arrow on About, Support, and Privacy, and the site menu,
   a ☰ button that opens a short list on every page:
   - About, Support, and Privacy, the current page in bold;
   - a Language row that unfolds in place to list the languages, the
     current one ticked;
   - the App Store badge.
   The menu and its Language row are <details> elements, so both open without
   a script, with a short animation. language.js closes the menu on a tap
   elsewhere or Escape, plays the closing and folding animations, folds the
   languages away again, and remembers a language choice. */
.site-menu {
  position: relative;
  font-family: ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  pointer-events: auto;
}

.site-menu[hidden],
.language-menu[hidden] {
  display: none;
}

.site-menu > summary,
.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--yomm-stone-wash, color-mix(in srgb, #6B6A6A 18%, transparent));
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: var(--yomm-charcoal, #34353B);
  list-style: none;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
  -webkit-tap-highlight-color: transparent;
  /* A tap is a tap: it never selects the glyph. */
  -webkit-user-select: none;
  user-select: none;
}

.site-menu > summary::-webkit-details-marker,
.language-menu > summary::-webkit-details-marker {
  display: none;
}

.site-menu > summary:hover,
.site-menu[open] > summary,
.back-button:hover {
  background: color-mix(in srgb, #FD681A 14%, transparent);
  color: var(--yomm-ember, #FD681A);
}

.site-menu > summary:focus-visible,
.back-button:focus-visible {
  outline: 3px solid color-mix(in srgb, #FD681A 36%, transparent);
  outline-offset: 3px;
}

/* The back arrow is a link; it sits in a top bar that lets taps through. */
.back-button {
  text-decoration: none;
  pointer-events: auto;
}

.site-menu-list {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  min-width: 168px;
  padding: 6px;
  border-radius: 14px;
  background: var(--yomm-porcelain, #F7F2E8);
  box-shadow:
    0 0 0 1px color-mix(in srgb, #6B6A6A 16%, transparent),
    0 12px 32px color-mix(in srgb, #34353B 18%, transparent);
}

/* Rows: the page links, the Language row, and the languages (links on the
   website's pages, buttons on Connect). */
.site-menu-list a,
.site-menu-list button,
.language-menu > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--yomm-charcoal, #34353B);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.2;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.site-menu-list a:hover,
.site-menu-list button:hover,
.language-menu > summary:hover {
  background: color-mix(in srgb, #6B6A6A 12%, transparent);
}

.site-menu-list a:focus-visible,
.site-menu-list button:focus-visible,
.language-menu > summary:focus-visible {
  outline: 3px solid color-mix(in srgb, #FD681A 36%, transparent);
  outline-offset: -3px;
}

.site-menu-list [aria-current="page"],
.site-menu-list [aria-pressed="true"] {
  font-weight: 800;
}

/* The Language row is a plain word like the rows above it: no glyph, no
   chevron. */
.language-menu > summary {
  list-style: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

/* On desktop the two buttons carry their names beside the glyph: Back and
   Menu. The words are the buttons' own labels (the back arrow's data-label,
   the menu's aria-label), so they follow the page's language. */
@media (min-width: 1024px) {
  .site-menu > summary,
  .back-button {
    gap: 8px;
    width: auto;
    padding: 0 14px 0 12px;
    font-family: ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
    font-size: 0.95rem;
    font-weight: 650;
    line-height: 1;
  }

  .site-menu > summary::after {
    content: attr(aria-label);
  }

  .back-button::after {
    content: attr(data-label);
  }
}

.language-menu-list {
  display: flex;
  flex-direction: column;
  /* Clips the rows while they unfold and fold. */
  overflow: hidden;
}

.language-menu-list > * {
  flex: none;
}

.language-menu-list [aria-current="page"]::after,
.language-menu-list [aria-pressed="true"]::after {
  content: "✓";
  margin-left: auto;
  color: var(--yomm-ember, #FD681A);
}

/* Line glyphs drawn alike: three lines for the site menu, an arrow for the
   back button. */
.menu-glyph {
  display: block;
  width: 20px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

/* The App Store badge closes the site menu's list. */
.site-menu-list .site-menu-store {
  margin-top: 4px;
  padding: 8px 12px 10px;
}

.site-menu-list .site-menu-store:hover {
  background: none;
}

/* Apple's badge differs in width by language, so it is sized by its height:
   40px, the smallest Apple allows on screen. */
.site-menu-store img {
  display: block;
  width: auto;
  height: 40px;
}

/* Opening and closing. The list fades and settles in from the button's side
   (--menu-shift: from above by default); the languages grow to their own
   height, which language.js measures into --unfolded (the fallback is three
   rows). Opening plays by itself. To close, language.js adds .is-closing or
   .is-folding and closes the <details> when the leaving animation ends. */
@media (prefers-reduced-motion: no-preference) {
  .site-menu-list {
    --menu-shift: -6px;
    transform-origin: top right;
  }

  .site-menu[open] > .site-menu-list {
    animation: menu-in 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  .site-menu.is-closing > .site-menu-list {
    animation: menu-out 130ms ease-in forwards;
  }

  .language-menu[open] > .language-menu-list {
    animation: languages-unfold 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  .language-menu.is-folding > .language-menu-list {
    animation: languages-fold 150ms ease-in forwards;
  }
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(var(--menu-shift)) scale(0.97);
  }
}

@keyframes menu-out {
  to {
    opacity: 0;
    transform: translateY(var(--menu-shift)) scale(0.97);
  }
}

@keyframes languages-unfold {
  from {
    max-height: 0;
    opacity: 0;
  }

  to {
    max-height: var(--unfolded, 117px);
    opacity: 1;
  }
}

@keyframes languages-fold {
  from {
    max-height: var(--unfolded, 117px);
    opacity: 1;
  }

  to {
    max-height: 0;
    opacity: 0;
  }
}

/* Where the menu sits: in a page's top bar, or, on pages without one, in the
   top corner. */
.menu-group,
.corner-menus {
  display: flex;
  gap: 8px;
}

.corner-menus {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 14px;
  z-index: 20;
}
