/* The site menu's button and phone layout. Loaded by scripts/nav.php (and games/index.php) with a ?v= version,
   so phones pick up changes at once; css-new.css is cached for a week. These rules also override the older
   menu rules a phone may still have in its cached css-new.css (hence the resets marked "old").
   The Christmas theme restyles the button colour and font in themes/christmas_vacation/theme.css. */

/* Menu button: hidden on desktop. On phones it's a "Menu" pill that turns into "Close". */
.hamburger {
  display: none;
  flex-direction: row; /* old: column */
  align-items: center;
  gap: 10px;
  margin: 0 auto;
  padding: 9px 18px 9px 16px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  color: var(--link-color, #444);
  background: rgba(127, 127, 127, 0.12);
  background: color-mix(in srgb, currentColor 11%, transparent);
  font: 600 13px/1 'Open Sans', sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  -webkit-tap-highlight-color: transparent;
}
.hamburger:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}
.hamburger-icon {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hamburger-line {
  display: block;
  width: 18px;
  height: 2px;
  background-color: currentColor;
  border-radius: 2px;
  transition: transform 0.25s, opacity 0.2s;
}
/* Older copies of the menu put the lines straight in the button: stack them, no label */
.hamburger:not(:has(.hamburger-icon)) {
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
}
.hamburger-text::after { content: 'Menu'; }
.hamburger.open .hamburger-text::after { content: 'Close'; }

/* Animate the three lines into an X when open */
.hamburger.open .hamburger-line:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger.open .hamburger-line:nth-child(2) { opacity: 0; }
.hamburger.open .hamburger-line:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Phones: the links fold out as a two-column grid of tiles */
@media screen and (max-width: 600px) {
  .hamburger {
    display: inline-flex;
  }

  #footer {
    flex-direction: column;
    padding: 8px 10px;
    gap: 0;
  }

  #footer .footer-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
    max-height: 0;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.2s ease, visibility 0s linear 0.3s;
  }

  #footer .footer-wrapper.open {
    display: grid; /* old: flex */
    max-height: 400px;
    padding: 12px 0 4px;
    opacity: 1;
    visibility: visible;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.2s ease 0.05s;
  }

  #footer .footer-wrapper a.footer {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
    border-top: 0; /* old: divider lines */
    background: rgba(127, 127, 127, 0.1);
    background: color-mix(in srgb, currentColor 9%, transparent);
  }

  /* An odd number of links: the last tile spans both columns */
  #footer .footer-wrapper a.footer:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    justify-content: center;
  }

  #footer .footer-wrapper a.footer:hover {
    background: rgba(127, 127, 127, 0.18);
    background: color-mix(in srgb, currentColor 16%, transparent);
  }

  #footer .footer-wrapper a.footer.active {
    text-decoration: none;
    background: rgba(127, 127, 127, 0.2);
    background: color-mix(in srgb, currentColor 18%, transparent);
    box-shadow: inset 0 0 0 1.5px var(--nav-accent, currentColor);
  }

  .nav-icon {
    display: inline-flex;
    justify-content: center;
    flex: none;
    width: 24px;
    font-size: 18px;
    line-height: 1;
    margin-right: 0; /* old: 8px */
  }
}

@media screen and (max-width: 360px) {
  #footer .footer-wrapper a.footer { gap: 8px; padding: 10px 9px; }
}

@media (prefers-reduced-motion: reduce) {
  #footer .footer-wrapper,
  #footer .footer-wrapper.open,
  .hamburger-line { transition: none; }
}

