/* ==========================================================================
   Site header (nav.css · src/partials/header.html · js/nav.js)

   Desktop (>= 1280): the mark + tagline on the page's left edge, five primary links on the page's centre line
   (a 1fr | auto | 1fr grid, so the gaps either side of the links are equal), Register + the one accent CTA on the
   right edge. "Services" is a link plus a caret that opens a mega panel: a photo card and three groups
   (Care · Tests & medicines · Network) holding every old services anchor; the page dims under it.
   Tablet and phone (<= 1279): a floating frosted capsule on the page gutters (mark, a light CTA pill, a hairline
   menu icon). The menu is a full-screen sheet on phones (it unfolds out of the capsule) and a right-hand panel
   over a dimmed page on tablets: image-led rows for the pages, then the services anchors as two ruled columns,
   and a booking bar docked to the bottom. Focus is trapped, the page behind is inert and cannot scroll.

   States (one set of variables, switched by the selectors below; colours ease over 250ms):
   - paper (default): warm paper glass, hairline, ink mark with a teal dot. Also: no hero, no JS, past the hero.
   - on a dark photo hero, at rest: transparent; a soft scrim of the header's own guarantees the white words;
     the mark is white with a luminous teal dot; the row sits a little lower and settles up as the paper arrives.
     Below 1280 the capsule is dark frosted glass and the CTA a cream pill with teal words.
   - on a light photo hero (<section class="hero-bleed" data-nav-tone="light">): transparent, ink words over a
     paper fade (below 1280: a pale frosted capsule).
   motion.js adds html.past-hero before the hero copy can reach the header (see DESIGN.md).
   ========================================================================== */

/* ---- the mark: one <symbol id="mdc-mark">, drawn with <use>. Letters take currentColor, the dot --mark-dot ---- */
.nav-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.mark-letters { fill: currentColor; }
.mark-dot { fill: var(--mark-dot, var(--accent-em)); }

/* ---- the header and its states ---- */
.nav {
  --nav-ink: var(--ink);               /* mark letters, hovered and current links */
  --nav-ink-2: var(--ink-2);           /* resting links, tagline */
  --mark-dot: var(--accent-em);
  --nav-dot: var(--teal-600);          /* the current page's dot under its link */
  --nav-rule: var(--line-2);           /* hairline between the mark and the tagline */
  --nav-text-shadow: none;
  --nav-scrim-o: 0;                    /* the header's own scrim (photo states only) */
  --nav-scrim: linear-gradient(180deg, rgba(var(--photo-ink), 0.44) 0, rgba(var(--photo-ink), 0.2) 55%, rgba(var(--photo-ink), 0) 100%);
  --nav-drop: 0px;                     /* the row sits a little lower on a photo at rest */
  --toggle-fg: var(--ink);
  --mark-h: 26px;
  position: sticky; top: 0; z-index: var(--z-sticky);
  padding: 0 var(--gutter);
  background: var(--header-solid);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  backdrop-filter: blur(16px) saturate(1.5);
  box-shadow: var(--shadow-header);
  transition: background-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out);
}
.nav::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; z-index: -1;
  height: calc(100% + var(--space-12));
  background: var(--nav-scrim);
  opacity: var(--nav-scrim-o);
  pointer-events: none;
  transition: opacity var(--dur-3) var(--ease-out);
}
/* on a dark photo hero (the default for .hero-bleed), at rest */
html.js:not(.past-hero) body:has(.hero-bleed:not([data-nav-tone="light"])) .nav {
  --nav-ink: var(--on-photo);
  --nav-ink-2: var(--on-photo);
  --mark-dot: var(--teal-400);
  --nav-dot: var(--teal-400);
  --nav-rule: var(--on-photo-line);
  --nav-text-shadow: var(--text-shadow-photo);
  --nav-scrim-o: 1;
  --toggle-fg: var(--on-photo);
  background: transparent; box-shadow: none;
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
/* on a light photo hero, at rest: ink words over a paper fade */
html.js:not(.past-hero) body:has(.hero-bleed[data-nav-tone="light"]) .nav {
  --nav-scrim: linear-gradient(180deg, color-mix(in srgb, var(--canvas) 78%, transparent) 0, color-mix(in srgb, var(--canvas) 40%, transparent) 55%, transparent 100%);
  --nav-scrim-o: 1;
  background: transparent; box-shadow: none;
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
@media (min-width: 641px) {
  html.js:not(.past-hero) body:has(.hero-bleed) .nav { --nav-drop: 8px; }
}
@media (min-width: 1280px) {
  html.js:not(.past-hero) body:has(.hero-bleed) .nav { --nav-drop: 12px; }
}

.nav-chrome {
  width: min(var(--max), 100%);
  margin: 0 auto;
  min-height: var(--nav-h);
  display: flex; align-items: center; gap: var(--space-4);
  position: relative;
  transform: translateY(var(--nav-drop));
  transition: transform var(--dur-3) var(--ease-out);
}

/* ---- logo: the mark, a hairline, the tagline as real text ---- */
.logo {
  display: inline-flex; align-items: center; gap: 14px;
  flex: 0 0 auto;
  min-height: 44px;
  color: var(--nav-ink);
  border-radius: var(--r-xs);
  transition: color var(--dur-2) var(--ease-out);
}
.logo-mark { display: block; height: var(--mark-h); width: calc(var(--mark-h) * 2.4654); overflow: visible; }
.logo-tag {
  padding-left: 14px;
  border-left: 1px solid var(--nav-rule);
  font-size: var(--fs-eyebrow); line-height: 1.2; font-weight: var(--fw-ui); letter-spacing: 0;
  color: var(--nav-ink-2);
  text-shadow: var(--nav-text-shadow);
  white-space: nowrap;
  transition: color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out);
}

/* ---- primary links (desktop) ---- */
.nav-primary { display: none; }
.nav-links { display: flex; align-items: center; gap: 2px; }
.nav-link {
  position: relative;
  display: inline-flex; align-items: center;
  min-height: 44px;
  padding: 0 14px;
  font-size: var(--fs-body); font-weight: var(--fw-ui); letter-spacing: -0.01em; line-height: 1;
  color: var(--nav-ink-2);
  text-shadow: var(--nav-text-shadow);
  white-space: nowrap;
  border-radius: var(--r-pill);
  transition: color var(--dur-2) var(--ease-out);
}
/* the MDC dot: marks the current page, previews on hover */
.nav-link::after {
  content: ""; position: absolute; left: 50%; bottom: 5px;
  width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%;
  background: var(--nav-dot);
  opacity: 0; transform: scale(0);
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-3) var(--ease-spring), background-color var(--dur-2) var(--ease-out);
}
.nav-link[aria-current="page"] { color: var(--nav-ink); }
.nav-link[aria-current="page"]::after { opacity: 1; transform: none; }
@media (hover: hover) {
  .nav-link:hover { color: var(--nav-ink); }
  .nav-link:not([aria-current="page"]):hover::after { opacity: 0.55; transform: scale(0.8); }
}
.nav-link:focus-visible { outline-offset: 0; border-radius: var(--r-pill); }

/* Services: a real link plus a caret that opens the mega panel */
.nav-split { display: inline-flex; align-items: center; }
.nav-caret {
  position: relative;
  display: inline-grid; place-items: center;
  width: 26px; height: 44px; margin-left: -12px; margin-right: 2px;
  color: var(--nav-ink-2);
  border-radius: var(--r-pill);
  transition: color var(--dur-2) var(--ease-out);
}
.nav-caret svg { width: 14px; height: 14px; transition: transform var(--dur-3) var(--ease-out); }
/* keyboard ring: a 26px circle round the chevron, not a tall stadium round the whole 44px target */
.nav-caret:focus-visible { outline: none; }
.nav-caret:focus-visible::before { content: ""; position: absolute; inset: 9px 0; border-radius: 50%; outline: 2px solid var(--ring-color); outline-offset: 1px; }
.nav-split .nav-link { padding-right: 18px; }
.nav-split .nav-link::after { margin-left: -4.5px; }
.has-mega.is-open .nav-caret svg { transform: rotate(180deg); }
.has-mega.is-open .nav-caret, .has-mega.is-open .nav-link { color: var(--nav-ink); }
@media (hover: hover) { .nav-caret:hover { color: var(--nav-ink); } }

/* ---- mega panel (desktop) ---- */
.mega {
  position: absolute; left: 50%; top: calc(100% + var(--space-3));
  width: min(1000px, 100%);
  display: none;
  grid-template-columns: minmax(0, 1.08fr) repeat(3, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr) auto;
  gap: var(--space-2);
  padding: var(--space-2);
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--line);
  text-shadow: none;
  visibility: hidden; opacity: 0;
  translate: -50% 0;
  transform: translateY(-8px) scale(0.985);
  transform-origin: 50% 0;
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-3) var(--ease-out), visibility 0s linear var(--dur-3);
}
/* a bridge over the gap, so the pointer can travel from the caret to the panel */
.mega::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: var(--space-4); }
.mega.is-primed { display: grid; }
.has-mega.is-open .mega {
  visibility: visible; opacity: 1; transform: none;
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-3) var(--ease-out), visibility 0s;
}
.mega-feature {
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; align-items: flex-end;
  grid-row: 1 / span 2;
  min-height: 300px;
  padding: var(--space-6);
  border-radius: var(--r-sm);
  color: var(--on-photo);
  background: var(--night);
}
.mega-feature img { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; object-position: 62% 30%; transform: scale(1.04); transition: transform var(--dur-5) var(--ease-out); }
.mega-feature::after { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--scrim-card); }
.mega-feature-text { display: grid; gap: var(--space-3); }
.mega-feature-title { font-family: var(--font-display); font-weight: var(--fw-title); font-size: var(--fs-title); line-height: 1.12; letter-spacing: var(--tracking-heading); }
.mega-feature-title em { font-style: italic; }
.mega-feature-link { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--fs-small); font-weight: var(--fw-ui); color: var(--on-photo-2); }
.mega-feature-link .icon-arrow { transition: transform var(--dur-3) var(--ease-spring); }
@media (hover: hover) {
  .mega-feature:hover img { transform: scale(1.09); }
  .mega-feature:hover .icon-arrow { transform: translateX(3px); }
}
.mega-group { padding: var(--space-5) var(--space-2) var(--space-3); }
.mega-label {
  margin: 0 var(--space-3) var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-eyebrow); font-weight: var(--fw-ui); letter-spacing: var(--tracking-eyebrow); text-transform: uppercase;
  color: var(--ink-3);
}
.mega-group ul { display: grid; gap: 2px; }
.mega-link {
  display: grid; gap: 3px;
  padding: 10px var(--space-3);
  border-radius: var(--r-sm);
  transition: background-color var(--dur-2) var(--ease-out);
}
.mega-link b { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-body); font-weight: var(--fw-ui); color: var(--ink); line-height: 1.25; }
.mega-link span { font-size: var(--fs-small); color: var(--ink-3); line-height: 1.35; }
.mega-link b::after {
  content: ""; width: 14px; height: 14px; flex: 0 0 auto;
  background: currentColor; -webkit-mask: var(--icon-arrow) center / contain no-repeat; mask: var(--icon-arrow) center / contain no-repeat;
  opacity: 0; transform: translateX(-4px);
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-3) var(--ease-spring);
}
.mega-link[aria-current="location"] { background: var(--teal-50); }
.mega-link[aria-current="location"] b { color: var(--teal-800); }
@media (hover: hover) {
  .mega-link:hover { background: var(--canvas); }
  .mega-link:hover b::after { opacity: 1; transform: none; }
}
.mega-link:focus-visible { outline-offset: -2px; }
.mega-foot {
  grid-column: 2 / -1;
  display: flex; align-items: center; flex-wrap: wrap; column-gap: var(--space-3);
  margin: 0 0 0 var(--space-2);
  padding: var(--space-1) var(--space-5);
  background: var(--canvas);
  border-radius: var(--r-sm);
  font-size: var(--fs-small); color: var(--ink-2);
}
.mega-foot-link { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 44px; font-weight: var(--fw-ui); color: var(--teal-700); }
.mega-foot-link .icon-arrow { transition: transform var(--dur-3) var(--ease-spring); }
@media (hover: hover) { .mega-foot-link:hover .icon-arrow { transform: translateX(3px); } }
/* the panel's contents arrive in turn */
.mega > * { opacity: 0; transform: translateY(6px); transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-3) var(--ease-out); }
.has-mega.is-open .mega > * { opacity: 1; transform: none; }
.has-mega.is-open .mega > :nth-child(2) { transition-delay: 40ms; }
.has-mega.is-open .mega > :nth-child(3) { transition-delay: 80ms; }
.has-mega.is-open .mega > :nth-child(4) { transition-delay: 120ms; }
.has-mega.is-open .mega > :nth-child(5) { transition-delay: 160ms; }
/* no JS: the panel still opens on hover and keyboard focus */
html:not(.js) .has-mega:is(:hover, :focus-within) .mega { display: grid; visibility: visible; opacity: 1; transform: none; }
html:not(.js) .has-mega:is(:hover, :focus-within) .mega > * { opacity: 1; transform: none; }

/* ---- right cluster: Register, the one accent CTA, the menu button ---- */
.nav-cta { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }
.nav-quiet { display: none; }
.nav .nav-book { --btn-h: 44px; --btn-px: 20px; }   /* .nav raises it over .btn (components.css loads after) */

/* menu button and the sheet's close button: a hairline icon on a 44px target (no disc). Two lines; on the menu
   button the lower one is shorter and grows on hover; on the close button they fold into a cross. */
.menu-toggle, .menu-close {
  position: relative;
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; flex: 0 0 auto;
  border-radius: 50%;
  color: var(--toggle-fg, var(--ink));
  transition: background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out), transform var(--dur-3) var(--ease-spring);
}
.menu-toggle:active, .menu-close:active { transform: scale(0.92); }
.burger { position: relative; display: block; width: 22px; height: 9px; }
.burger i {
  position: absolute; left: 0; right: 0; height: 1.5px; border-radius: 2px;
  background: currentColor;
  transform-origin: 100% 50%;
  transition: transform var(--dur-3) var(--ease-out);
}
.burger i:first-child { top: 0; }
.burger i:last-child { bottom: 0; }
.menu-toggle .burger i:last-child { transform: scaleX(0.62); }
.menu-close .burger i { transform-origin: 50% 50%; }
@media (hover: hover) {
  .menu-toggle:hover, .menu-close:hover { background: var(--toggle-hover, var(--hover-fill)); }
  .menu-toggle:hover .burger i:last-child { transform: none; }
}
.menu-toggle:focus-visible, .menu-close:focus-visible { outline-offset: 0; }

/* the menu sheet and the page scrim exist only where they are used (below) */
.menu-sheet { display: none; }
.nav-scrim { display: none; }

/* ==========================================================================
   Desktop: three tracks, the links on the page's centre line
   ========================================================================== */
@media (min-width: 1280px) {
  .nav { --mark-h: 36px; }
  .nav .nav-book { --btn-h: 52px; --btn-px: 26px; --btn-fs: 1rem; gap: 12px; }
  /* on paper (scrolled, or a page without a photo hero) the actions compact into the 64px bar; on the photo at
     rest they stand at full size. scale composes with the button's own hover transform */
  .nav-cta { transform-origin: 100% 50%; scale: 0.88; }
  html.js:not(.past-hero) body:has(.hero-bleed) .nav-cta { scale: 1; }
  .nav-chrome { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); column-gap: var(--space-6); }
  /* the open links need a little more shade than the capsule does (bright ceilings on services and patients):
     white links >= 5:1 against the brightest 10% behind them on all six heroes at 1280 and 1920 */
  html.js:not(.past-hero) body:has(.hero-bleed:not([data-nav-tone="light"])) .nav {
    --nav-scrim: linear-gradient(180deg, rgba(var(--photo-ink), 0.54) 0, rgba(var(--photo-ink), 0.28) 55%, rgba(var(--photo-ink), 0) 100%);
  }
  .logo { justify-self: start; }
  .nav-primary { display: block; }
  .nav-cta { justify-self: end; margin-left: 0; gap: var(--space-3); }
  .nav-quiet { display: inline-flex; }
  .menu-toggle { display: none; }

  /* while the mega panel is open the page under the header dims and softens, so nothing reads through the gap
     between the header and the panel (purely visual: clicks pass through, a click outside closes the panel) */
  .nav-scrim {
    display: block;
    position: fixed; inset: 0; z-index: calc(var(--z-sticky) - 1);
    background: var(--scrim-menu);
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity var(--dur-3) var(--ease-out), visibility 0s linear var(--dur-3);
  }
  body.mega-open .nav-scrim { opacity: 0.7; visibility: visible; transition: opacity var(--dur-3) var(--ease-out), visibility 0s; }
  /* on paper the page frosts over instead of dimming (a dark veil turns the butter field olive) */
  html.past-hero .nav-scrim { background: color-mix(in srgb, var(--canvas) 72%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
  html.past-hero body.mega-open .nav-scrim { opacity: 1; }
}
/* very wide screens: the container stays 1440 (one edge for the whole page), so the header's own furniture grows */
@media (min-width: 1700px) {
  .nav { --mark-h: 42px; }
  .nav-links { gap: var(--space-2); }
  .nav-link { font-size: calc(var(--fs-body) * 1.06); padding: 0 16px; }
  .nav-split .nav-link { padding-right: 20px; }
  .logo { gap: 16px; }
  .logo-tag { padding-left: 16px; font-size: var(--fs-small); }
  .nav .nav-book { --btn-h: 56px; --btn-px: 30px; --btn-fs: var(--fs-body); }
}

/* ==========================================================================
   Tablet and phone: a floating frosted capsule, then the menu sheet
   ========================================================================== */
@media (max-width: 1279px) {
  /* The header box stays --nav-h (64) tall: 8px of air, then a 56px capsule on the page gutters. The page scrolls
     past in the air around it. Paper by default; dark frosted glass on a dark photo hero at rest. */
  .nav {
    --mark-h: 32px;
    --cap-top: var(--space-2);
    --cap-bg: var(--header-solid);
    --cap-line: var(--line);
    --cap-shadow: 0 14px 34px -22px rgba(var(--photo-ink), 0.42);
    --cap-filter: blur(20px) saturate(1.6);
    --toggle-hover: var(--hover-fill);
    --book-bg: var(--accent); --book-fg: var(--on-accent);
    --book-bg-h: var(--accent-hover); --book-fg-h: var(--on-accent);
    --book-sh-h: var(--shadow-btn-accent);
    padding: var(--cap-top) var(--gutter) 0;
    background: transparent; box-shadow: none;
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  /* frosted glass: the photo behind is blurred and dimmed by a fifth, then a 12% white veil lifts the capsule off
     the photo. Measured on all six heroes at 390 and 768: white >= 5:1 against the brightest 10% inside it */
  html.js:not(.past-hero) body:has(.hero-bleed:not([data-nav-tone="light"])) .nav {
    --nav-scrim-o: 0.6;
    --cap-bg: color-mix(in srgb, var(--on-photo) 12%, transparent);
    --cap-line: var(--on-photo-line);
    --cap-shadow: 0 16px 36px -22px rgba(var(--photo-ink), 0.6);
    --cap-filter: blur(24px) saturate(1.4) brightness(0.8);
    --toggle-hover: var(--glass);
    /* the action steps back on the photo: a cream pill with teal words, not a second saturated block */
    --book-bg: var(--canvas); --book-fg: var(--teal-700);
    --book-bg-h: var(--surface); --book-fg-h: var(--teal-800);
    --book-sh-h: var(--shadow-btn-photo);
  }
  html.js:not(.past-hero) body:has(.hero-bleed[data-nav-tone="light"]) .nav {
    --cap-bg: color-mix(in srgb, var(--canvas) 64%, transparent);
    --cap-line: var(--line);
    --cap-shadow: none;
  }
  .nav-chrome {
    min-height: calc(var(--nav-h) - var(--cap-top));
    gap: var(--space-2);
    padding: 0 6px 0 var(--space-4);
    border-radius: var(--r-pill);
    background: var(--cap-bg);
    box-shadow: inset 0 0 0 1px var(--cap-line), var(--cap-shadow);
    -webkit-backdrop-filter: var(--cap-filter); backdrop-filter: var(--cap-filter);
    transition: transform var(--dur-3) var(--ease-out), background-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out);
  }
  .nav-cta { gap: var(--space-1); }
  .nav .nav-book {
    --btn-h: 40px; --btn-px: 18px; --btn-fs: 0.9375rem;
    --btn-bg: var(--book-bg); --btn-fg: var(--book-fg);
    --btn-bg-h: var(--book-bg-h); --btn-fg-h: var(--book-fg-h); --btn-sh-h: var(--book-sh-h);
    gap: 8px;
  }
  /* 40px to the eye, 44px to the thumb */
  .nav .nav-book::before { content: ""; position: absolute; inset: -2px 0; }

  /* the page behind the open menu */
  .nav-scrim {
    display: block;
    position: fixed; inset: 0; z-index: calc(var(--z-menu) - 1);
    background: var(--scrim-menu);
    -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity var(--dur-3) var(--ease-out), visibility 0s linear var(--dur-3);
  }
  body.menu-open .nav-scrim { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity var(--dur-3) var(--ease-out), visibility 0s; }
  body.menu-open { overflow: hidden; padding-right: var(--scrollbar-w, 0px); }

  /* ---- the sheet ---- */
  .menu-sheet {
    --mark-h: 32px;
    position: fixed; top: 0; right: 0; bottom: 0; z-index: var(--z-menu);
    width: 100%;
    flex-direction: column;
    overflow: hidden;
    background: color-mix(in srgb, var(--tint) 60%, var(--canvas));
    visibility: hidden;
  }
  .menu-sheet.is-primed { display: flex; }

  .menu-top {
    flex: 0 0 auto;
    display: flex; align-items: center; gap: var(--space-4);
    min-height: var(--nav-h);
  }
  .menu-logo { color: var(--ink); --mark-dot: var(--accent-em); }
  .menu-kicker { display: none; }
  .menu-close { --toggle-fg: var(--ink); --toggle-hover: var(--hover-fill); margin-left: auto; }
  .menu-sheet.is-open .menu-close .burger i { transition-delay: 140ms; }
  .menu-sheet.is-open .menu-close .burger i:first-child { transform: translateY(3.75px) rotate(45deg); }
  .menu-sheet.is-open .menu-close .burger i:last-child { transform: translateY(-3.75px) rotate(-45deg); }

  .menu-body {
    flex: 1 1 auto; min-height: 0;
    overflow-y: auto; overscroll-behavior: contain;
    padding: var(--space-2) var(--gutter) var(--space-10);
    /* the list softens under the top row and into the booking bar, so it reads as scrollable */
    -webkit-mask-image: linear-gradient(to bottom, transparent, black var(--space-4), black calc(100% - var(--space-7)), transparent);
    mask-image: linear-gradient(to bottom, transparent, black var(--space-4), black calc(100% - var(--space-7)), transparent);
  }
  .menu-title {
    font-family: var(--font-display); font-weight: var(--fw-display);
    font-size: clamp(2.375rem, 2rem + 1.4vw, 2.75rem); line-height: 1.04; letter-spacing: var(--tracking-display-2);
    color: var(--ink);
    margin: var(--space-4) 0 var(--space-7);
    text-wrap: balance;
  }
  .menu-title em { font-style: italic; color: var(--accent-em); }

  /* image-led rows: the pages */
  .menu-rows { display: grid; gap: var(--space-2); }
  .menu-row {
    display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; column-gap: var(--space-4);
    min-height: 76px;
    padding: 6px var(--space-5) 6px 6px;
    background: var(--surface);
    border-radius: var(--r-sm);
    color: var(--ink);
    transition: background-color var(--dur-2) var(--ease-out), transform var(--dur-3) var(--ease-out);
  }
  .menu-row:active { transform: scale(0.985); }
  .menu-thumb {
    position: relative; overflow: hidden;
    width: 64px; height: 64px;
    border-radius: calc(var(--r-sm) - 4px);
    background: var(--canvas-2);
  }
  .menu-thumb img { width: 100%; height: 100%; object-fit: cover; }
  .menu-thumb .t-scan { object-position: 50% 30%; }
  .menu-thumb .t-services { object-position: 76% 36%; }
  .menu-thumb .t-products { object-position: 44% 60%; }
  .menu-thumb .t-patients { object-position: 62% 40%; }
  .menu-thumb .t-wellness { object-position: 42% 40%; }
  .menu-thumb-mark { display: grid; place-items: center; background: var(--mist); color: var(--ink); --mark-dot: var(--accent-em); }
  .menu-thumb-mark svg { width: 40px; height: auto; aspect-ratio: 78.4 / 31.8; }
  .menu-row[aria-current="page"] .menu-thumb-mark { background: var(--surface); }
  .menu-text { display: grid; gap: 3px; min-width: 0; }
  .menu-text b { font-family: var(--font-display); font-weight: var(--fw-title); font-size: var(--fs-row); line-height: 1.15; letter-spacing: -0.01em; }
  .menu-text span { font-size: var(--fs-small); color: var(--ink-3); line-height: 1.3; }
  .menu-row .icon-arrow { color: var(--ink-3); transition: transform var(--dur-3) var(--ease-spring), color var(--dur-2) var(--ease-out); }
  .menu-row[aria-current="page"] { background: var(--teal-50); }
  .menu-row[aria-current="page"] .menu-text b,
  .menu-row[aria-current="page"] .menu-text span,
  .menu-row[aria-current="page"] .icon-arrow { color: var(--teal-800); }
  .menu-row:focus-visible { outline-offset: 2px; border-radius: var(--r-sm); }
  @media (hover: hover) {
    .menu-row:hover { background: var(--surface-2); }
    .menu-row:hover .icon-arrow { transform: translateX(3px); color: var(--ink); }
  }

  /* every services anchor: two ruled columns of plain links (below the first screen on phones) */
  .menu-groups { display: grid; gap: var(--space-8); margin-top: var(--space-10); }
  .menu-label {
    display: flex; align-items: center; gap: var(--space-3);
    margin-bottom: var(--space-1);
    font-size: var(--fs-eyebrow); font-weight: var(--fw-ui); letter-spacing: var(--tracking-eyebrow); text-transform: uppercase;
    color: var(--ink-3);
  }
  .menu-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--space-5); }
  .menu-link {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
    min-height: 52px;
    border-bottom: 1px solid var(--line-2);
    font-size: var(--fs-body); line-height: 1.2; color: var(--ink);
    transition: color var(--dur-2) var(--ease-out);
  }
  .menu-link::after {
    content: ""; width: 14px; height: 14px; flex: 0 0 auto;
    background: currentColor; -webkit-mask: var(--icon-arrow) center / contain no-repeat; mask: var(--icon-arrow) center / contain no-repeat;
    opacity: 0.4;
    transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-3) var(--ease-spring);
  }
  .menu-link[aria-current="location"] { color: var(--teal-700); }
  .menu-link[aria-current="location"]::after { opacity: 1; }
  .menu-link:focus-visible { outline-offset: 2px; }
  @media (hover: hover) {
    .menu-link:hover { color: var(--teal-700); }
    .menu-link:hover::after { opacity: 1; transform: translateX(3px); }
  }

  /* the booking bar, docked to the bottom of the sheet */
  .menu-foot { flex: 0 0 auto; }
  .menu-card {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
    padding: var(--space-4) var(--gutter) calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    box-shadow: 0 -1px 0 var(--line), 0 -18px 40px -30px rgba(var(--photo-ink), 0.45);
  }
  .menu-card-text { display: grid; gap: 2px; min-width: 0; }
  .menu-card-text b { font-size: var(--fs-body); font-weight: var(--fw-ui); color: var(--ink); }
  .menu-card-text span { font-size: var(--fs-small); color: var(--ink-3); line-height: 1.3; }
  .menu-card .btn { --btn-h: 48px; --btn-px: 22px; flex: 0 0 auto; }

  /* the sheet's contents arrive in turn */
  .menu-title, .menu-rows > li, .menu-group, .menu-card {
    opacity: 0; transform: translateY(14px);
    transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-3) var(--ease-out);
  }
  .menu-sheet.is-open :is(.menu-title, .menu-rows > li, .menu-group, .menu-card) {
    opacity: 1; transform: none;
    transition: opacity var(--dur-3) var(--ease-out), transform var(--dur-4) var(--ease-out);
  }
  .menu-sheet.is-open .menu-title { transition-delay: 60ms; }
  .menu-sheet.is-open .menu-rows > li:nth-child(1) { transition-delay: 100ms; }
  .menu-sheet.is-open .menu-rows > li:nth-child(2) { transition-delay: 135ms; }
  .menu-sheet.is-open .menu-rows > li:nth-child(3) { transition-delay: 170ms; }
  .menu-sheet.is-open .menu-rows > li:nth-child(4) { transition-delay: 205ms; }
  .menu-sheet.is-open .menu-rows > li:nth-child(5) { transition-delay: 240ms; }
  .menu-sheet.is-open .menu-rows > li:nth-child(6) { transition-delay: 275ms; }
  .menu-sheet.is-open .menu-group:nth-child(1) { transition-delay: 300ms; }
  .menu-sheet.is-open .menu-group:nth-child(2) { transition-delay: 330ms; }
  .menu-sheet.is-open .menu-card { transition-delay: 200ms; }
}

/* tablets: a panel slides in from the right over the dimmed page; the page's capsule stays visible on the left */
@media (min-width: 641px) and (max-width: 1279px) {
  .menu-sheet {
    width: min(480px, 100%);
    border-radius: var(--r-lg) 0 0 var(--r-lg);
    box-shadow: var(--shadow-lg);
    opacity: 0; transform: translateX(48px);
    transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-3) var(--ease-out), visibility 0s linear var(--dur-3);
  }
  .menu-sheet.is-open {
    visibility: visible; opacity: 1; transform: none;
    transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-4) var(--ease-out), visibility 0s;
  }
  .menu-logo { display: none; }
  .menu-br { display: none; }
  .menu-kicker {
    display: block;
    font-size: var(--fs-eyebrow); font-weight: var(--fw-ui); letter-spacing: var(--tracking-eyebrow); text-transform: uppercase;
    color: var(--ink-3);
  }
  .menu-top { padding: var(--space-2) var(--space-6) 0 var(--space-7); }
  .menu-body { padding: var(--space-2) var(--space-7) var(--space-10); }
  .menu-groups { margin-top: var(--space-9); }
  .menu-card { padding: var(--space-5) var(--space-7) calc(var(--space-5) + env(safe-area-inset-bottom, 0px)); }
}

/* phones: full screen. The sheet unfolds out of the capsule (a clip from the capsule's exact shape to the whole
   screen); its mark and close button sit exactly where the capsule's mark and menu button are. */
@media (max-width: 640px) {
  .nav { --mark-h: 31px; }
  .logo-tag { display: none; }
  .nav .nav-book { --btn-px: 18px; }
  .nav .nav-book .icon-arrow { display: none; }
  .menu-sheet {
    --mark-h: 31px;
    clip-path: inset(var(--space-2) var(--gutter) calc(100% - var(--nav-h)) var(--gutter) round 28px);
    transition: clip-path var(--dur-3) var(--ease-in-out), visibility 0s linear var(--dur-3);
  }
  .menu-sheet.is-open {
    visibility: visible;
    clip-path: inset(0 0 0 0 round 0px);
    transition: clip-path 560ms var(--ease-out), visibility 0s;
  }
  .menu-top { padding: var(--space-2) calc(var(--gutter) + 6px) 0 calc(var(--gutter) + var(--space-4)); }
  .menu-card .btn { --btn-px: 20px; }
}
@media (max-width: 359px) {
  .menu-text span, .menu-card-text span { display: none; }
}

/* ---- load-in: the capsule settles in at once; once the faces are in, the mark, the links and the actions follow ---- */
@media (prefers-reduced-motion: no-preference) {
  html.js:not(.fonts-wait) :is(.nav-chrome > .logo, .nav-links > li > :first-child, .nav-cta > *) {
    animation: nav-in var(--dur-4) var(--ease-out) backwards;
  }
  html.js .nav-links > li:nth-child(1) > :first-child { animation-delay: 70ms; }
  html.js .nav-links > li:nth-child(2) > :first-child { animation-delay: 110ms; }
  html.js .nav-links > li:nth-child(3) > :first-child { animation-delay: 150ms; }
  html.js .nav-links > li:nth-child(4) > :first-child { animation-delay: 190ms; }
  html.js .nav-links > li:nth-child(5) > :first-child { animation-delay: 230ms; }
  html.js .nav-cta > :nth-child(1) { animation-delay: 200ms; }
  html.js .nav-cta > :nth-child(2) { animation-delay: 250ms; }
  html.js .nav-cta > :nth-child(3) { animation-delay: 300ms; }
}
@media (prefers-reduced-motion: no-preference) and (max-width: 1279px) {
  html.js .nav-chrome { animation: cap-in var(--dur-4) var(--ease-out) backwards; }
}
@keyframes nav-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes cap-in { from { opacity: 0; scale: 0.96; } }

/* ---- first paint: the header's words wait for the web fonts (html.fonts-wait, at most 600ms), then fade in ---- */
.nav-links, .nav-cta, .logo-tag { transition: opacity var(--dur-3) var(--ease-out), color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out), scale var(--dur-3) var(--ease-out); }
html.fonts-wait :is(.nav-links, .nav-cta, .logo-tag) { opacity: 0; }

/* ---- reduced motion: states switch at once, nothing slides ---- */
@media (prefers-reduced-motion: reduce) {
  .nav, .nav::before, .nav-chrome, .nav-link, .nav-link::after, .logo, .mega, .mega > *, .menu-sheet, .nav-scrim,
  .menu-title, .menu-rows > li, .menu-group, .menu-card, .burger i, .mega-feature img { transition: none !important; }
  .nav-chrome { transform: none; animation: none; }
  .mega, .mega > *, .menu-sheet, .menu-title, .menu-rows > li, .menu-group, .menu-card { transform: none !important; }
}

/* ---- print: no header furniture ---- */
@media print {
  .menu-sheet, .nav-scrim, .mega, .nav-sprite { display: none !important; }
}
