/* ── Phone nav (shared by every page; nav.js toggles .is-open) ──
   Phones get the logo on the left and a "menu" button on the right. The button opens a
   full-screen panel with the links stacked large. The panel takes the page's own colours:
   set --menu-bg / --menu-fg on .topnav (the home page switches them for its dark header). */
.topnav { --menu-bg: #D6F1FF; --menu-fg: #4D1722; }

.topnav-toggle { display: none; }

@media (max-width: 700px) {
  .topnav .topnav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 72px;
    padding: 0 20px;
  }
  .topnav .topnav-logo { order: -1; padding: 0; }
  .topnav .topnav-logo img { width: 168px; }
  .topnav .topnav-link { display: none; }

  .topnav-toggle {
    display: block;
    appearance: none;
    background: none;
    border: 0;
    margin: 0 -8px 0 0;
    padding: 10px 8px;
    font-family: 'Fustat', system-ui, sans-serif;
    font-size: 17px;
    font-weight: 600;
    color: var(--ink, #4D1722);
    cursor: pointer;
  }

  /* ── open: the whole nav becomes a full-screen panel ── */
  .topnav.is-open .topnav-inner {
    position: fixed;
    inset: 0;
    z-index: 1000;
    height: auto;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 6px;
    padding: 0 20px 40px;
    background: var(--menu-bg);
    overflow-y: auto;
  }
  /* keep the logo + close button in the same spot as the closed header */
  .topnav.is-open .topnav-logo { height: 72px; display: flex; align-items: center; margin-bottom: 40px; }
  .topnav.is-open .topnav-toggle {
    position: absolute;
    top: 14px;
    right: 20px;
    color: var(--menu-fg);
  }
  .topnav.is-open .topnav-link {
    display: block;
    font-size: clamp(40px, 12vw, 56px);
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1.15;
    color: var(--menu-fg);
    animation: menu-rise 560ms cubic-bezier(.16,1,.3,1) both;
  }
  .topnav.is-open .topnav-link::after { background: var(--menu-fg); height: 3px; }
  /* links rise in one after another (the logo sits between them in the markup) */
  .topnav.is-open .topnav-link:nth-child(1) { animation-delay: 40ms; }
  .topnav.is-open .topnav-link:nth-child(2) { animation-delay: 100ms; }
  .topnav.is-open .topnav-link:nth-child(4) { animation-delay: 160ms; }
  .topnav.is-open .topnav-link:nth-child(5) { animation-delay: 220ms; }
  .topnav.is-open .topnav-inner { animation: menu-fade 220ms ease both; }

  @keyframes menu-rise {
    from { opacity: 0; transform: translateY(32px); }
    to   { opacity: 1; transform: none; }
  }
  @keyframes menu-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
  @media (prefers-reduced-motion: reduce) {
    .topnav.is-open .topnav-link,
    .topnav.is-open .topnav-inner { animation: none; }
  }
}

/* stop the page scrolling behind the open menu */
.menu-open { overflow: hidden; }
