/* ==========================================================================
   SH Shooting: primary menu (shs-menu.css)
   ==========================================================================

   WHAT THIS FILE DOES
   The site keeps its existing interaction: a round red MENU button, fixed
   top right, that opens a full-screen overlay at every screen width. This
   file turns that overlay into a properly laid-out, responsive menu and fixes
   the bugs in the old setup:

   1. Logged-in visitors (admin bar) at 482px and wider saw a blank white
      panel: the parent rule `.admin-bar .primary-navigation{top:initial}`
      left the fixed nav at its static position, so the links rendered far
      above the top of the screen. The overlay is now positioned against the
      viewport on its own, independent of the <nav> box.
   2. On desktop the open menu was one thin row of small links across an
      empty white screen. It is now a balanced multi-column list of large
      links, vertically centred.
   3. The page behind the menu could still scroll above 1279px, and at or
      below 1279px Twentig "locked" it with `.site{position:fixed}`, which
      threw the visitor back to the top of the page whenever the menu was
      opened. Scrolling is now locked with `overflow:hidden` instead.
   4. On the transparent-header pages the white logo sat on the white overlay
      (invisible), and on phones Twentig hid the logo while the menu was
      open. The logo now stays visible, in colour, above the overlay.
   5. The menu button was scaled to 0.8 on phones and could sit underneath
      the admin bar for logged-in users. It is now never smaller than 48px
      and always clears the admin bar.

   HOW IT IS WIRED (markup is stock Twenty Twenty-One, nothing added)
     header#masthead
       .site-branding                 logo (kept above the overlay)
       nav#site-navigation.primary-navigation
         .menu-button-container > button#primary-mobile-menu
         .primary-menu-container      <- the overlay panel (scroll container)
           ul#primary-menu-list.menu-wrapper > li.menu-item > a
   The parent theme's primary-navigation.js toggles these classes on <body>:
     .primary-navigation-open   menu is open
     .lock-scrolling            page should not scroll
   and handles Escape, focus return and the Tab trap. No extra JS is needed.

   CASCADE
   This file loads BEFORE the Customizer "Additional CSS", which cannot be
   edited and contains old menu rules (some with !important). Every rule
   here is therefore scoped under `#masthead #site-navigation` (two IDs) or
   similar, which outranks everything in the parent theme, Twentig and the
   Additional CSS. `!important` is used only to override declarations that
   the Additional CSS itself marks !important; each such case is commented.

   ADDING OR REMOVING MENU ITEMS
   Nothing here refers to individual menu items. The layout uses CSS
   multi-column, so any number of links balances itself across the columns.
   Sub-menus (if ever added) are shown indented under their parent.

   BREAKPOINTS (match the parent theme / Twentig)
     <= 651px            phone: one column
     652px - 1023px      tablet: two columns
     >= 1024px           desktop: up to four columns
     height <= 520px     short landscape screens: compact, more columns
   ========================================================================== */


/* --------------------------------------------------------------------------
   0. Design tokens
   Defined on <body> so they can read --global--admin-bar--height, which the
   parent theme sets on body.admin-bar (32px, or 46px at 782px and below).
   -------------------------------------------------------------------------- */
body {
	--shs-menu-red: #cc0000;          /* the button red */
	--shs-menu-red-bright: #e91e28;   /* the site's link red */
	--shs-menu-ink: #18181a;          /* site text colour */
	--shs-menu-muted: #6b6b70;
	--shs-menu-rule: rgba(24, 24, 26, 0.12);
	--shs-menu-bg: #ffffff;

	/* Top edge of the overlay: just below the admin bar, if there is one. */
	--shs-menu-top: var(--global--admin-bar--height, 0px);

	/* Height of the band at the top of the overlay that is kept clear for
	   the logo and the close button. The header has no vertical padding
	   (Additional CSS), so this is simply the logo height set by Twentig. */
	--shs-menu-head: var(--logo--height, 126px);

	/* Side padding of the overlay: the site gutter, or the notch / rounded
	   corner inset on landscape phones if that is larger. */
	--shs-menu-pad-x: max(var(--site--padding, 20px), env(safe-area-inset-left), env(safe-area-inset-right));

	/* Link type size; overridden per breakpoint below. */
	--shs-menu-size: 1.3125rem;
	--shs-menu-gap: 0;

	/* Open / close timing. */
	--shs-menu-speed: 0.24s;
}

@media only screen and (max-width: 651px) {
	body {
		--shs-menu-head: var(--logo--height-mobile, 105px);
	}
}

/* On phones the WordPress admin bar is position:absolute (it scrolls away
   with the page), so the overlay starts at the very top and the admin bar,
   when it is in view, simply covers the top of it. The head band is made
   taller by the admin-bar height so nothing important hides underneath. */
@media screen and (max-width: 600px) {
	body.admin-bar {
		--shs-menu-top: 0px;
		--shs-menu-head: calc(var(--logo--height-mobile, 105px) + var(--global--admin-bar--height, 46px));
	}
}


/* --------------------------------------------------------------------------
   1. Scroll lock while the menu is open
   Replaces Twentig's `.lock-scrolling .site{position:fixed}` (which jumped
   the page back to the top) with a plain overflow lock that keeps the
   visitor's place. Applies at every width (the old lock stopped at 1279px).
   -------------------------------------------------------------------------- */
/* Lock on <html> only. (If <body> also got overflow:hidden it would become
   its own scroll container, which moves the sticky header down by the
   admin-bar height while the menu is open.) */
html:has(> body.lock-scrolling) {
	overflow: hidden;
	/* Keep the space of a classic (Windows / Linux) scrollbar while it is
	   hidden, so the page and the fixed MENU button do not jump ~15px
	   sideways on open and back on close. No effect with overlay
	   scrollbars (macOS, phones), which take no space. */
	scrollbar-gutter: stable;
}

/* Older browsers without :has(): lock on <body>, which then propagates to
   the viewport because <html> keeps overflow:visible. */
@supports not selector(:has(*)) {
	body.lock-scrolling {
		overflow: hidden;
	}
}

body.lock-scrolling #page.site {
	position: static;
}


/* --------------------------------------------------------------------------
   1b. Header clears the admin bar (logged-in visitors only)
   The header is position:fixed (transparent-header pages, body.tw-header-light)
   or position:sticky (solid-header pages), both with top:0, so for logged-in
   visitors the logo slid underneath the admin bar. Nothing changes for
   logged-out visitors.
   -------------------------------------------------------------------------- */
body.admin-bar #masthead.site-header {
	top: var(--global--admin-bar--height, 32px);
}

/* At 600px and below the admin bar scrolls away with the page. A sticky
   header then belongs at top:0; a fixed header still has to start below
   the bar (it would otherwise be hidden under it at the top of the page). */
@media screen and (max-width: 600px) {
	body.admin-bar #masthead.site-header {
		top: 0;
	}

	body.admin-bar.tw-header-light #masthead.site-header {
		top: var(--global--admin-bar--height, 46px);
	}
}


/* --------------------------------------------------------------------------
   2. The menu button (round red MENU / CLOSE)
   Look is unchanged; size, position and focus are made robust.
   -------------------------------------------------------------------------- */

/* The container is position:fixed top right (Additional CSS, !important).
   Keep that, but push it below the admin bar for logged-in visitors, and
   drop the full-width white bar the parent theme gives it when open. */
#masthead.has-logo .menu-button-container {
	top: calc(var(--shs-menu-top) + 10px) !important;  /* beats Additional CSS !important */
	right: max(10px, env(safe-area-inset-right)) !important; /* beats Additional CSS !important */
	width: auto;
	/* Twentig pads this container so the button lands at y = 75px on tablets
	   (below the logo's centre line) and 25px on desktop. Use one value so
	   the button sits level with the middle of the logo at every width. */
	padding: 15px 0 0;
	background: transparent;
	z-index: 3;
}

@media only screen and (max-width: 600px) {
	#masthead.has-logo .menu-button-container {
		padding-top: 12px !important;   /* beats Additional CSS padding-top:10px!important */
	}
}

/* On phones with the admin bar (absolute, 46px) keep the button below it
   while the page is at the top. */
@media screen and (max-width: 600px) {
	body.admin-bar #masthead.has-logo .menu-button-container {
		top: calc(var(--global--admin-bar--height, 46px) + 10px) !important; /* beats Additional CSS !important */
	}
}

#masthead #site-navigation #primary-mobile-menu {
	box-sizing: border-box;
	min-width: 48px;
	min-height: 48px;
	align-items: center;
	justify-content: center;
	/* Wide enough for "CLOSE" + icon as well as "MENU" + icon, so the label
	   never spills out of the red shape (white text on white was invisible)
	   and the button does not change size when toggled. */
	min-width: 108px;
	padding-inline: 16px;
	white-space: nowrap;
	font-family: var(--global--font-secondary);
	font-weight: 700;
	letter-spacing: 0.06em;
	line-height: 1;
	-webkit-tap-highlight-color: transparent;
}

/* Phones: the Additional CSS shrinks the button with transform:scale(0.8),
   which made it visually smaller than its 48px hit area promised. Use real
   (smaller) padding instead and no scaling. */
@media only screen and (max-width: 600px) {
	#masthead #site-navigation #primary-mobile-menu {
		transform: none;
		min-width: 96px;
		padding: 18px 12px;
	}
}

/* Keyboard focus: white gap plus red ring, visible on both the dark hero
   images and the white overlay. */
#masthead #site-navigation #primary-mobile-menu:focus {
	outline: none;
}

#masthead #site-navigation #primary-mobile-menu:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--shs-menu-red);
}

/* While open the button reads CLOSE on the same red, so it is obvious. */
.primary-navigation-open #masthead #site-navigation #primary-mobile-menu {
	color: #fff;
	background: var(--shs-menu-red);
}


/* --------------------------------------------------------------------------
   3. Logo stays visible above the overlay
   -------------------------------------------------------------------------- */
.primary-navigation-open #masthead .site-branding {
	position: relative;
	z-index: 3;   /* above the <nav> (z-index 2), which holds the overlay */
}

/* Twentig hides the logo on phones while the menu is open; undo that. */
.primary-navigation-open #masthead.has-logo .site-logo {
	display: block;
	visibility: visible;
}

/* Transparent-header pages print a colour logo (.logo-primary, hidden) and
   a white one (.logo-transparent). On the white overlay show the colour one. */
.primary-navigation-open #masthead .custom-logo.logo-primary {
	visibility: visible;
}

.primary-navigation-open #masthead .logo-primary + .logo-transparent {
	visibility: hidden;
	opacity: 0;
}


/* --------------------------------------------------------------------------
   4. The overlay panel
   Positioned against the viewport on its own (fixes the blank panel for
   logged-in visitors), full height with dynamic-viewport units, scrolls
   inside itself when the links do not fit.
   -------------------------------------------------------------------------- */

/* The <nav> itself is just a holder; keep it out of the way. */
#masthead #site-navigation.primary-navigation {
	z-index: 2;
}

#masthead #site-navigation > .primary-menu-container {
	/* geometry: always fixed to the viewport, open or closed */
	position: fixed;
	top: var(--shs-menu-top);
	right: 0;
	bottom: auto;
	left: 0;
	z-index: 1;
	box-sizing: border-box;
	width: auto;
	height: calc(100vh - var(--shs-menu-top));   /* fallback */
	height: calc(100dvh - var(--shs-menu-top));
	max-width: none;
	margin: 0;

	/* layout: a column so the list can be centred vertically with auto
	   margins (auto margins never push content off the top when the list
	   is taller than the panel, unlike justify-content:center). */
	display: flex;
	flex-direction: column;
	padding: var(--shs-menu-head) var(--shs-menu-pad-x) max(32px, env(safe-area-inset-bottom));
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;

	background: var(--shs-menu-bg);
	border: 0;

	/* closed state */
	visibility: hidden;
	opacity: 0;
	transform: translateY(-12px);
	transition:
		opacity var(--shs-menu-speed) ease,
		transform var(--shs-menu-speed) ease,
		visibility 0s linear var(--shs-menu-speed);
}

.primary-navigation-open #masthead #site-navigation > .primary-menu-container {
	visibility: visible;
	opacity: 1;
	transform: none;
	transition:
		opacity var(--shs-menu-speed) ease,
		transform var(--shs-menu-speed) ease,
		visibility 0s linear 0s;
}

/* A white band pinned to the top of the scrolling panel, so links that
   scroll up pass underneath the logo / close-button area instead of
   showing through behind the logo. */
#masthead #site-navigation > .primary-menu-container::before {
	content: "";
	position: sticky;
	top: 0;                                  /* sticks to the top edge of the panel */
	z-index: 5;                              /* above the links (Additional CSS gives every <a> z-index 4) */
	display: block;
	flex: none;
	height: var(--shs-menu-head);
	margin: calc(0px - var(--shs-menu-head)) calc(0px - var(--shs-menu-pad-x)) 0;
	background: var(--shs-menu-bg);
	/* pointer-events stay on: links scrolled under the band are hidden, so
	   they should not be clickable through it either. */
}


/* --------------------------------------------------------------------------
   5. The list
   -------------------------------------------------------------------------- */
#masthead #site-navigation > .primary-menu-container > .menu-wrapper {
	display: block;              /* not flex: columns do the layout */
	box-sizing: border-box;
	width: 100%;
	max-width: 1440px;
	margin: auto 0;              /* centred vertically, left-aligned with the logo */
	padding: 0;
	list-style: none;
	counter-reset: shs-menu;
	column-gap: clamp(24px, 4vw, 64px);
	column-fill: balance;
}

#masthead #site-navigation .menu-wrapper li {
	display: block !important;   /* Twentig sets display:block!important; kept */
	width: auto;
	margin: 0 !important;        /* beats Twentig margin-inline-start:0!important */
	break-inside: avoid;
	-webkit-column-break-inside: avoid;
	counter-increment: shs-menu;
}

/* Every link: a full-width row with a hairline above it. */
#masthead #site-navigation .menu-wrapper a {
	position: relative;
	z-index: auto !important;    /* beats Additional CSS `a{z-index:4!important}` so the head band covers scrolled links */
	display: flex;
	align-items: baseline;
	gap: 0.875rem;
	box-sizing: border-box;
	width: 100%;
	min-height: 48px;
	padding: 0.6em 0.25em 0.6em 0;
	border-top: 1px solid var(--shs-menu-rule);
	font-family: var(--global--font-primary);   /* Source Serif Pro */
	font-size: var(--shs-menu-size);
	font-weight: 900;
	line-height: 1.15;
	letter-spacing: 0;
	text-transform: none;
	text-decoration: none;
	color: var(--shs-menu-ink);
	opacity: 1;                                  /* Twentig dims links to .87 on transparent headers */
	text-wrap: balance;                          /* if a long name must wrap, wrap it evenly */
	transition: color 0.15s ease;
}

/* Small running number before each link (01, 02 ...), generated, so it
   follows whatever order the owner sets in Appearance > Menus. */
#masthead #site-navigation .menu-wrapper > li > a::before {
	content: counter(shs-menu, decimal-leading-zero);
	flex: none;
	min-width: 1.25rem;
	font-family: var(--global--font-secondary); /* Source Sans Pro */
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	color: var(--shs-menu-muted);
	transition: color 0.15s ease;
}

/* Arrow that slides in on hover / focus. */
#masthead #site-navigation .menu-wrapper a::after {
	content: "\2192";   /* → */
	margin-inline-start: auto;
	padding-inline-start: 0.5em;
	font-family: var(--global--font-secondary);
	font-weight: 400;
	color: var(--shs-menu-red);
	opacity: 0;
	transform: translateX(-6px);
	transition: opacity 0.15s ease, transform 0.15s ease;
}

/* Hover and keyboard focus. The Additional CSS forces an underline on every
   a:hover with !important; the colour change and arrow replace it here. */
#masthead #site-navigation .menu-wrapper a:hover,
#masthead #site-navigation .menu-wrapper a:focus-visible {
	color: var(--shs-menu-red);
	text-decoration: none !important;   /* beats Additional CSS a:hover underline !important */
}

#masthead #site-navigation .menu-wrapper a:hover::before,
#masthead #site-navigation .menu-wrapper a:focus-visible::before {
	color: var(--shs-menu-red);
}

#masthead #site-navigation .menu-wrapper a:hover::after,
#masthead #site-navigation .menu-wrapper a:focus-visible::after {
	opacity: 1;
	transform: none;
}

/* Twentig styles header-link focus as `.tw-header-bg .site .site-header
   a:focus{outline:1px auto ...!important}` (a thin blue system ring), so
   !important is needed here to replace it with the red ring. */
#masthead #site-navigation .menu-wrapper a:focus {
	outline: none !important;
}

#masthead #site-navigation .menu-wrapper a:focus-visible {
	outline: 3px solid var(--shs-menu-red) !important;
	outline-offset: 2px !important;     /* outside the row, so it never cuts through the number */
	border-radius: 2px;
	background: rgba(204, 0, 0, 0.05);
}

/* Current page: red, with a red bar on the left and a red hairline. */
#masthead #site-navigation .menu-wrapper .current-menu-item > a,
#masthead #site-navigation .menu-wrapper .current_page_item > a,
#masthead #site-navigation .menu-wrapper .current-menu-ancestor > a {
	color: var(--shs-menu-red);
	text-decoration: none;
	border-top-color: var(--shs-menu-red);
	box-shadow: inset 0 1px 0 var(--shs-menu-red);
}

#masthead #site-navigation .menu-wrapper .current-menu-item > a::before,
#masthead #site-navigation .menu-wrapper .current_page_item > a::before {
	color: var(--shs-menu-red);
}

/* Sub-menus, should any be added later: shown open, indented, smaller. */
#masthead #site-navigation .menu-wrapper .sub-menu {
	position: static;
	display: block !important;   /* Twentig uses !important here; kept */
	margin: 0 0 0.5em;
	padding: 0 0 0 2.35rem;
	border: 0;
	list-style: none;
	background: none;
}

#masthead #site-navigation .menu-wrapper .sub-menu a {
	min-height: 44px;
	padding-block: 0.45em;
	border-top: 0;
	font-family: var(--global--font-secondary);
	font-size: 1rem;
	font-weight: 600;
}

#masthead #site-navigation .menu-wrapper .sub-menu-toggle {
	display: none !important;    /* Twentig uses !important here; kept */
}


/* --------------------------------------------------------------------------
   6. Responsive layout
   -------------------------------------------------------------------------- */

/* Phone: one column, big comfortable rows. */
@media only screen and (max-width: 651px) {
	body {
		--shs-menu-size: 1.3125rem;   /* 21px */
	}

	#masthead #site-navigation > .primary-menu-container > .menu-wrapper {
		margin-top: 8px;              /* top-aligned under the logo on phones */
		margin-bottom: auto;
		border-bottom: 1px solid var(--shs-menu-rule);
	}

	#masthead #site-navigation .menu-wrapper a {
		min-height: 52px;
		align-items: center;
	}
}

/* Tablet: two balanced columns. */
@media only screen and (min-width: 652px) {
	body {
		--shs-menu-size: clamp(1.5rem, 1rem + 1.2vw, 1.875rem);
	}

	#masthead #site-navigation > .primary-menu-container > .menu-wrapper {
		columns: 2;
	}

	#masthead #site-navigation .menu-wrapper a {
		min-height: 56px;
	}
}

/* Desktop: as many ~19rem columns as fit, at most four (three at
   laptop widths, four on wide screens). */
@media only screen and (min-width: 1024px) {
	body {
		--shs-menu-size: clamp(1.625rem, 0.9rem + 1.15vw, 2.125rem);
	}

	#masthead #site-navigation > .primary-menu-container > .menu-wrapper {
		columns: 4 19rem;
	}
}

/* Short screens (landscape phones, small laptop windows): smaller head
   band and type, more columns, so most or all links fit without scrolling. */
@media only screen and (max-height: 520px) and (min-width: 560px) {
	body {
		--shs-menu-size: 1.125rem;
	}

	#masthead #site-navigation > .primary-menu-container > .menu-wrapper {
		columns: 3 12rem;
		margin-top: 0;
	}

	#masthead #site-navigation .menu-wrapper a {
		min-height: 48px;
		padding-block: 0.45em;
		align-items: center;
	}
}


/* --------------------------------------------------------------------------
   7. Reduced motion: no slide or fade, the menu simply appears.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
	#masthead #site-navigation > .primary-menu-container,
	.primary-navigation-open #masthead #site-navigation > .primary-menu-container {
		transform: none;
		transition: none;
	}

	#masthead #site-navigation .menu-wrapper a,
	#masthead #site-navigation .menu-wrapper a::before,
	#masthead #site-navigation .menu-wrapper a::after {
		transition: none;
	}

	#masthead #site-navigation .menu-wrapper a::after {
		transform: none;
	}
}
