/* ============================================================
   MENU CARD — the black card with the site's title, description,
   page links and social links (partials/menu.njk, menu-card.njk).
   Same padding, meta line, title and description sizes as the page columns. Links as soft tiles (the soft look).
   Desktop: the floating rail grows into it (one dark rounded shape); the page stays visible beside it.
   Phone: fills the screen under the header, fading in and out; only the page and social links;
   opened and closed with the header's menu button, which stays on top.
   ============================================================ */

.menu {
  --row-h: 48px;  /* height of a menu row */
  /* Short screens: gaps shrink so everything still fits without scrolling.
     1st the gaps above the links and Instagram shrink (--short, from 710px tall on
     phone / 800px on desktop), so the top still lines up with the columns;
     only on even shorter screens do the top gaps shrink too (--shorter, from 670 / 740px). */
  --short: max(0px, 710px - 100dvh);
  --shorter: max(0px, 670px - 100dvh);
  position: fixed; top: 0; bottom: 0; left: var(--rail); z-index: 55;
  width: calc(100vw - var(--rail));
  display: flex; flex-direction: column; overflow-y: auto;
  padding: max(16px, 40px - var(--shorter) * .35) max(24px, env(safe-area-inset-right)) calc(var(--col-pb) + env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background: var(--dark); color: var(--light);
  overscroll-behavior: contain;   /* scrolling inside the card never moves the page behind */
  transform: translateX(-100%); visibility: hidden;
  transition: transform .55s var(--ease), visibility 0s linear .55s;
}
.menu.is-open { transform: none; visibility: visible; transition: transform .55s var(--ease); }

/* Desktop: the rail grows into the menu. The menu is one dark rounded shape the rail's height, starting
   under the rail; closed, it is clipped back to the rail's own width, and opening slides its right edge
   out. Its contents fade in once it is open. The rail sits on top, so they read as one object. */
@media (min-width: 768px) and (min-height: 501px), (min-width: 768px) and (pointer: fine) {
  .menu {
    --short: max(0px, 800px - 100dvh);
    --shorter: max(0px, 740px - 100dvh);
    --menu-w: clamp(360px, 29vw, 440px); --rail-w: calc(var(--rail) - var(--float));
    top: var(--float); bottom: var(--float); left: var(--float);
    width: calc(var(--rail-w) + var(--menu-w));
    /* sides (9 Nov 2026): 24px after the rail and 64px on the right (were 44px each). The rail is part of the same dark shape,
       so equal sides left the words looking pushed right; the words keep their width and sit closer to the panel's middle. */
    padding: max(24px, 72px - var(--float) - var(--shorter) * .35) 64px calc(var(--col-pb) - var(--float) + env(safe-area-inset-bottom)) calc(var(--rail-w) + 24px);
    border-radius: var(--card-r); box-shadow: 0 16px 40px -16px rgba(38,38,38,.45);
    transform: none; clip-path: inset(0 var(--menu-w) 0 0 round var(--card-r));
    transition: clip-path .55s var(--ease), visibility 0s linear .55s;
  }
  .menu.is-open { transform: none; clip-path: inset(0 0 0 0 round var(--card-r)); transition: clip-path .55s var(--ease); }
  .menu > * { opacity: 0; transition: opacity .2s; }
  .menu.is-open > * { opacity: 1; transition: opacity .3s .25s; }
}

/* Wash: desktop only. A warm light veil with a slight blur over the page (under the rail and menu, z 55 / 60),
   fading in as the menu slides out. It catches clicks while shown, so a click beside the menu just closes it. */
.menu-wash { display: none; }
@media (min-width: 768px) and (min-height: 501px), (min-width: 768px) and (pointer: fine) {
  .menu-wash {
    display: block; position: fixed; inset: 0; z-index: 54; pointer-events: none; opacity: 0;
    background: rgba(227,223,215,.72); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
    transition: opacity .45s ease;
  }
  html.menu-open .menu-wash { opacity: 1; pointer-events: auto; }
}
@media (prefers-reduced-motion: reduce) { .menu-wash { transition: none; } }

/* Meta line (no rule under it: the soft look) */
.menu .meta { min-height: 48px; padding-bottom: 4px; color: var(--accent); }   /* "Cycling coach" in the orange, like "Coaching" in the rail */

/* Title and description: same sizes and spacing as the column title and summary */
.menu-title {
  margin: max(20px, 40px - var(--shorter) * .35) 0 0;
  font-family: var(--display); font-weight: var(--heavy); font-stretch: var(--stretch-card); text-transform: uppercase;
  font-size: var(--fs-menu-title); line-height: 1.02; letter-spacing: .005em;
}
/* the description sits close under the title, so the two read as one block below the meta line */
.menu-text { margin: max(12px, 18px - var(--shorter) * .3) 0 0; font-size: var(--fs-body); line-height: 1.6; }

@media (min-width: 768px) and (min-height: 501px), (min-width: 768px) and (pointer: fine) {
  .menu-title { margin-top: max(24px, 64px - var(--shorter) * .35); }
  .menu-text { margin-top: max(14px, 22px - var(--shorter) * .3); }
}

/* Page links as soft tiles, under the description — the soft cards of the pages, on the dark.
   The gap above them matches the gap above the title. */
.menu-foot { padding-top: max(16px, 40px - var(--short) * .6); }
@media (min-width: 768px) and (min-height: 501px), (min-width: 768px) and (pointer: fine) { .menu-foot { padding-top: max(20px, 64px - var(--short) * .75); } }

.menu { --tile: rgba(245,242,236,.055); --tile-hover: rgba(245,242,236,.10); }
.menu-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.menu-list a, .menu-soon {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: var(--row-h); padding: 0 18px; border-radius: 8px; background: var(--tile);
  color: var(--light); text-decoration: none;
  font-size: var(--fs-meta); letter-spacing: var(--track); text-transform: uppercase;
  transition: background .2s;
}
.menu-list svg { width: 9px; height: 10px; flex-shrink: 0; }
/* Pointed at: the tile lightens */
.menu-list a:hover { background: var(--tile-hover); }
/* Not open yet (Plans, until 2027): the same tile and colour, just not a link; the small label says when */
.menu-soon { cursor: default; }
.soon-label { font-size: var(--fs-micro); letter-spacing: .08em; color: var(--grey-on-dark); }

/* **Bold** words in the description (site.json → intro.text) show in orange */
.menu-text strong { font-weight: 700; color: var(--accent); }

.menu-title a { color: inherit; text-decoration: none; transition: color .2s; }
.menu-title a:hover { color: var(--accent); }

/* Social links at the bottom, side by side, as plain words (no tiles, 2 Nov 2026), so they sit below the page links in the hierarchy. The row is as tall as the big buttons
   and sits on the same bottom padding, so its centre lines up with the TL logo. */
.menu-social { display: flex; align-items: center; gap: 16px; min-height: var(--btn-h); margin-top: auto; padding-top: max(8px, 24px - var(--short) * .4); box-sizing: content-box; }
/* Phone: the card starts 40px below the header (where the pages' meta line sits); on short phones
   only the gaps below it shrink (and the rows a little), so everything still fits */
@media (max-width: 767px), (max-height: 500px) and (pointer: coarse) {
  .menu {
    --short: max(0px, 710px + var(--header-h) - 100dvh);     /* the header takes its share of the height */
    --shorter: max(0px, 670px + var(--header-h) - 100dvh);
    --row-h: clamp(44px, 48px - var(--short) * .05, 48px);   /* rows tighten a little on short phones */
    z-index: 65; padding-top: calc(var(--header-h) + 24px);   /* full screen under the header (--rail is 0, so it's full width) */
    padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right));   /* in line with the header logo and the pages */
    /* Phones: the card fades in and out rather than sliding (there's no rail for it to come from) */
    transform: none; opacity: 0;
    transition: opacity .25s ease, visibility 0s linear .25s;
  }
  .menu.is-open { opacity: 1; transition: opacity .25s ease; }
  /* Phones: just the page links and the social links. The header above already carries the
     logo and wordmark, so the meta line, title and description are left out here (desktop keeps them). */
  .menu .meta, .menu-title, .menu-text { display: none; }
  /* The links sit a third of the way down the space between the header and the social links
     (spare height split 1 : 2 above and below them), so they read as a group rather than hanging off the header */
  .menu::before { content: ""; flex: 1 1 0; }
  .menu-foot { flex: 2 1 auto; padding-top: 0; }
  .menu-social { justify-content: center; }   /* Terms · Privacy · Motion centred under the links (11 Nov 2026); desktop keeps them on the left */
}
@media (min-width: 768px) and (min-height: 501px), (min-width: 768px) and (pointer: fine) { .menu-social { padding-top: max(8px, 24px - var(--short) * .25); } }
.menu-social a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0;   /* 40px tall: still an easy tap */
  color: var(--grey-on-dark); text-decoration: none;
  font-size: var(--fs-label); letter-spacing: var(--track); text-transform: uppercase;
  transition: color .2s;
}
.menu-social a:hover, .menu-social a[aria-current="page"] { color: var(--light); }
.menu-social a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* ---- Leaving through the menu: the card slides away over the new page ----
   When a menu link loads another page, the browser keeps a picture of the open card
   and slides it out to the left while the new page appears underneath it.
   (Cross-document View Transitions: Safari 18.2+, Chrome/Edge 126+. Other browsers just load the page.) */
@view-transition { navigation: auto; }
.menu.is-open { view-transition-name: menu; }
.rail { view-transition-name: rail; }   /* desktop: the card slides away under the rail, as it does when closed */
.topbar { view-transition-name: topbar; }   /* phone: the header stays on top and its × turns back into the menu button */
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
::view-transition-old(menu) { animation: menu-out .55s var(--ease) both; }
@keyframes menu-out { to { clip-path: inset(0 100% 0 0); } }   /* desktop: the menu folds back into the rail */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
/* Phones: leaving through a menu link, the card fades away over the new page */
@keyframes menu-fade-out { to { opacity: 0; } }
@media (max-width: 767px), (max-height: 500px) and (pointer: coarse) { ::view-transition-old(menu) { animation: menu-fade-out .3s ease both; } }
