ferst-core 0.16.0 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1356 +1,1391 @@
1
- ---
2
- /**
3
- * Site-wide header: brand logo, primary nav (data-driven), About Us mega
4
- * panel (declarative), Contact CTA, hamburger drawer, theme toggle.
5
- *
6
- * Lifted out of `Base.astro` so the layout file is no longer 1700 lines
7
- * and so a future "edit navbar entries" feature only has to render a
8
- * different `primaryNav` array. The About Us mega menu stays declarative
9
- * because it carries icons and a custom panel — easy to extend, hard to
10
- * shoe-horn into a flat JSON entry until it earns its keep.
11
- */
12
- import Button from './Button.astro';
13
- import type { NavLink, NavGroup, LogoHeader } from '../content/schemas';
14
-
15
- import { navWithoutCta } from '../lib/nav';
16
- import { logoHeaderLayout } from '../lib/logo-header';
17
- import { imageSizeOf } from '../lib/image-sizes';
18
- interface Props {
19
- path: string;
20
- headerClass?: string;
21
- primaryLogoLight?: string;
22
- primaryLogoDark?: string;
23
- /** The logo's size and placement (logoSettings.header). Omitted: a standard logo in the bar. */
24
- logoHeader?: Partial<LogoHeader>;
25
- brandAlt: string;
26
- primaryNav: NavLink[];
27
- /** Optional dropdown / mega-menu group. Client-configured — the core ships none. */
28
- dropdown?: NavGroup;
29
- /** The call-to-action button (navbarSettings.cta); null hides it. */
30
- cta?: { label: string; href: string } | null;
31
- }
32
-
33
- const { path, headerClass, primaryLogoLight, primaryLogoDark, logoHeader = {}, brandAlt, primaryNav, dropdown, cta = { label: 'Contact', href: '/contact/' } } = Astro.props;
34
- // The logo's own size (read from the site's files at build), so its box keeps the image's
35
- // shape before it loads; and the header's attributes for the logo's size and placement.
36
- const logoSize = imageSizeOf(primaryLogoLight);
37
- const logoLayout = logoHeaderLayout({ header: logoHeader, hasLogo: !!primaryLogoLight, size: logoSize });
38
- // A menu link to the same place as the button would show it twice: the button wins.
39
- const navLinks = navWithoutCta(primaryNav, cta);
40
- const ctaActive = !!cta && cta.href.startsWith('/') && path.startsWith(cta.href.replace(/\/$/, '') || '/#');
41
-
42
- /**
43
- * Longest-prefix-wins active-nav matching. A plain independent `startsWith`
44
- * per link (the previous approach) breaks once one link's href is a subpath
45
- * of another's — e.g. "Newsletters" → /posts/tag/newsletter/ sits under
46
- * "Posts" → /posts/, so both would light up on a newsletter-tag page.
47
- * Computing every link's match length up front and keeping only the
48
- * longest means only the most specific matching link is ever active,
49
- * however nav hrefs happen to nest.
50
- */
51
- const primaryNavMatchLengths = navLinks.map((link) => {
52
- const trimmed = link.href.replace(/\/$/, '');
53
- return trimmed.length > 0 && path.startsWith(trimmed) ? trimmed.length : -1;
54
- });
55
- const primaryNavLongestMatch = Math.max(-1, ...primaryNavMatchLengths);
56
- ---
57
-
58
- <!--
59
- transition:persist — on pages using Astro's <ClientRouter /> (currently
60
- /posts/), this keeps the exact same header DOM node across a filter
61
- click instead of tearing it down and re-inserting a fresh copy. Without
62
- it: the logo's <script is:inline> and the theme-toggle's <script> (which
63
- attaches its click listener and calls applyThemeFromStorageOrSystem()) are
64
- identical on every /posts/ page, so Astro's script-dedup logic skips
65
- re-running them on the swapped-in copy — the new toggle button ends up
66
- with no click listener at all, and the logo can flash to a stale value
67
- before this page's own remaining scripts settle. The "POSTS" nav-link's
68
- active state (path.startsWith below) is identical across every page in
69
- this family, so nothing here goes stale by persisting it.
70
- -->
71
- <header
72
- class:list={['site-header', headerClass]}
73
- {...logoLayout.attributes}
74
- style={logoLayout.ratio ? `--logo-ratio: ${logoLayout.ratio}` : undefined}
75
- transition:persist transition:name="site-header" transition:animate="none">
76
- <a href="/" class="brand">
77
- {primaryLogoLight ? (
78
- <img
79
- id="primary-logo"
80
- src={primaryLogoLight}
81
- data-src-light={primaryLogoLight}
82
- data-src-dark={primaryLogoDark ?? primaryLogoLight}
83
- alt={brandAlt}
84
- class="primary-logo"
85
- width={logoSize?.width}
86
- height={logoSize?.height}
87
- loading="eager"
88
- fetchpriority="high"
89
- decoding="sync"
90
- />
91
- ) : (
92
- <span class="brand-wordmark">{brandAlt}</span>
93
- )}
94
- </a>
95
- {primaryLogoLight && (
96
- <script is:inline define:vars={{ primaryLogoDark, primaryLogoLight }}>
97
- (function () {
98
- var img = document.getElementById('primary-logo');
99
- if (!img) return;
100
- var t = document.documentElement.dataset.theme;
101
- img.src = t === 'dark' ? (primaryLogoDark || primaryLogoLight) : primaryLogoLight;
102
- })();
103
- </script>
104
- )}
105
-
106
- <nav class="site-nav" id="site-nav" aria-label="Main navigation">
107
- {dropdown && (
108
- <div class="nav-item nav-has-dropdown" data-panel="about">
109
- <a
110
- href={dropdown.href}
111
- class:list={['nav-link', { active: path.startsWith(dropdown.href.replace(/\/$/, '')) }]}
112
- aria-haspopup="true"
113
- aria-expanded="false"
114
- aria-controls="about-submenu"
115
- >
116
- {dropdown.label}
117
- <svg class="nav-chevron" width="10" height="6" viewBox="0 0 10 6" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
118
- <path d="M1 1L5 5L9 1" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
119
- </svg>
120
- </a>
121
- <ul class="nav-dropdown" id="about-submenu">
122
- {dropdown.items.map((item) => (
123
- <li>
124
- <a href={item.href} class:list={[{ active: path === item.href }]}>
125
- <span class="drop-text">
126
- <span class="drop-title">{item.title}</span>
127
- {item.desc && <span class="drop-desc">{item.desc}</span>}
128
- </span>
129
- </a>
130
- </li>
131
- ))}
132
- </ul>
133
- </div>
134
- )}
135
- {/* Primary nav links — data-driven so editing siteSettings.navigation.primary
136
- adds, reorders, or removes entries without touching the layout.
137
- Active-state matching uses startsWith on the href to keep policy-style
138
- subpages highlighting their parent (e.g. /posts/tag/event/), but only
139
- the longest/most-specific match wins — see primaryNavLongestMatch
140
- above — so a link whose href is a subpath of another's (Newsletters
141
- under Posts) doesn't light up both at once. */}
142
- {navLinks.map((link, i) => {
143
- const isActive =
144
- primaryNavMatchLengths[i] >= 0 && primaryNavMatchLengths[i] === primaryNavLongestMatch;
145
- return (
146
- <a href={link.href} class:list={['nav-link', { active: isActive }]}>
147
- {link.label}
148
- </a>
149
- );
150
- })}
151
- <div class="nav-mobile-theme">
152
- {cta && (
153
- <Button
154
- href={cta.href}
155
- variant="cta"
156
- class:list={['nav-cta', 'nav-cta--drawer', { active: ctaActive }]}
157
- >
158
- {cta.label}
159
- </Button>
160
- )}
161
- <button type="button" class="theme-toggle-mobile" id="theme-toggle-mobile" role="switch" aria-checked="false" aria-label="Toggle dark mode">
162
- <span class="theme-toggle__highlight" aria-hidden="true"></span>
163
- <svg class="theme-icon theme-icon--sun" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="4"/><line x1="12" y1="2" x2="12" y2="4"/><line x1="12" y1="20" x2="12" y2="22"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="2" y1="12" x2="4" y2="12"/><line x1="20" y1="12" x2="22" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg>
164
- <svg class="theme-icon theme-icon--moon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg>
165
- </button>
166
- </div>
167
- </nav>
168
-
169
- <div class="nav-right">
170
- <button type="button" class="theme-toggle" id="theme-toggle" role="switch" aria-checked="false" aria-label="Toggle dark mode">
171
- <span class="theme-toggle__highlight" aria-hidden="true"></span>
172
- <svg class="theme-icon theme-icon--sun" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="4"/><line x1="12" y1="2" x2="12" y2="4"/><line x1="12" y1="20" x2="12" y2="22"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="2" y1="12" x2="4" y2="12"/><line x1="20" y1="12" x2="22" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg>
173
- <svg class="theme-icon theme-icon--moon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg>
174
- </button>
175
- {cta && (
176
- <span class="nav-cta-header-wrap">
177
- <Button
178
- href={cta.href}
179
- variant="cta"
180
- class:list={['nav-cta', 'nav-cta--header', { active: ctaActive }]}
181
- >
182
- {cta.label}
183
- </Button>
184
- </span>
185
- )}
186
- <button class="nav-toggle" aria-label="Toggle navigation" aria-expanded="false" aria-controls="site-nav">
187
- <span></span><span></span><span></span>
188
- </button>
189
- </div>
190
- </header>
191
-
192
- <div class="mobile-overlay" id="mobile-overlay"></div>
193
-
194
- <!-- Optional dropdown mega panel (desktop only) — client-configured, core ships none -->
195
- {dropdown && (
196
- <div class="mega-nav" id="mega-nav" aria-hidden="true">
197
- <div class="mega-nav__backdrop" id="mega-backdrop"></div>
198
-
199
- <div class="mega-panel mega-panel--about" data-panel="about">
200
- <div class="mega-panel__inner">
201
- <div class="mega-section-header">
202
- <h2>{dropdown.label}</h2>
203
- </div>
204
- <div class="mega-about-grid">
205
- {dropdown.items.map((item) => (
206
- <a href={item.href} class:list={['mega-about-card', { active: path === item.href }]}>
207
- <span class="mega-about-title">{item.title}</span>
208
- {item.desc && <span class="mega-about-desc">{item.desc}</span>}
209
- </a>
210
- ))}
211
- </div>
212
- </div>
213
- </div>
214
- </div>
215
- )}
216
-
217
- <style is:global>
218
- /* Header chrome — every selector here used to live in Base.astro's giant
219
- <style is:global> block. Kept global because dark-mode rules cross the
220
- boundary between header markup and html[data-theme="dark"]. */
221
-
222
- .primary-logo {
223
- height: var(--header-logo-h, 44px);
224
- width: auto;
225
- }
226
-
227
- /* Text wordmark fallback — shown when a client has configured no logo image
228
- (var(--fg) auto-switches for dark mode via theme.css). */
229
- .brand-wordmark {
230
- font-family: var(--font-heading);
231
- font-weight: 700;
232
- font-size: 1.25rem;
233
- line-height: 1;
234
- color: var(--fg);
235
- letter-spacing: 0.01em;
236
- white-space: nowrap;
237
- }
238
- @media (min-width: 64em) {
239
- .brand-wordmark { font-size: 1.5rem; }
240
- }
241
-
242
- /* ── Header ── */
243
- /* Logo + header: mobile-first — compact until desktop ≥64em scales up (matches button/theme sizing). */
244
- .site-header {
245
- display: flex;
246
- align-items: center;
247
- justify-content: space-between;
248
- height: 56px;
249
- padding: 0 1.25rem;
250
- background: var(--bg-tag);
251
- position: sticky;
252
- top: 0;
253
- z-index: 100;
254
- isolation: isolate;
255
- overflow: visible;
256
- }
257
- @media (min-width: 64em) {
258
- .site-header {
259
- height: 64px;
260
- padding: 0 28px;
261
- }
262
- }
263
- [data-theme="dark"] .site-header { background: var(--dark-bg); }
264
-
265
- /* Sticky "shrink on scroll": the header condenses and gains a shadow once the
266
- page is scrolled, then expands again at the top. Purely additive; safe with
267
- the sticky positioning. Motion honoured. */
268
- .site-header {
269
- transition: height 0.25s ease, min-height 0.25s ease, box-shadow 0.25s ease;
270
- }
271
- .site-header.is-compact {
272
- box-shadow: 0 2px 14px rgba(15, 23, 42, 0.10);
273
- height: 50px;
274
- }
275
- @media (min-width: 64em) {
276
- .site-header.is-compact { height: 54px; }
277
- }
278
- .site-header .primary-logo,
279
- .site-header .brand-wordmark {
280
- transition: height 0.25s ease, font-size 0.25s ease;
281
- }
282
- .site-header.is-compact .primary-logo { height: 38px; }
283
- .site-header.is-compact .brand-wordmark { font-size: 1.15rem; }
284
- @media (prefers-reduced-motion: reduce) {
285
- .site-header,
286
- .site-header .primary-logo,
287
- .site-header .brand-wordmark { transition: none; }
288
- }
289
- .brand {
290
- text-decoration: none;
291
- display: flex;
292
- align-items: center;
293
- gap: 12px;
294
- min-width: 0;
295
- flex-shrink: 1;
296
- }
297
- .brand:focus-visible {
298
- outline: 2px solid var(--gold);
299
- outline-offset: 3px;
300
- border-radius: 4px;
301
- }
302
- @media (min-width: 64em) {
303
- .brand { gap: 16px; }
304
- }
305
- .primary-logo {
306
- flex-shrink: 0;
307
- display: block;
308
- height: 44px;
309
- width: auto;
310
- max-width: 100%;
311
- object-fit: contain;
312
- }
313
-
314
- /* ── The logo's size and placement (logoSettings.header) ──
315
- --header-logo-h: the logo's height at the top of the page, by size and screen width.
316
- --header-bar-h: the bar's own height (the bar never grows for an overhanging logo).
317
- A larger logo set `inline` grows the bar on desktops only; phones and tablets keep the
318
- standard logo. Set `overhang`, it grows on every screen, in smaller steps on small ones. */
319
- :root { --header-logo-h: 44px; --header-bar-h: 60px; --header-logo-inset: 6px; }
320
- @media (min-width: 48em) { :root { --header-logo-h: 48px; --header-bar-h: 56px; } }
321
- @media (min-width: 64em) { :root { --header-logo-h: 56px; --header-bar-h: 64px; --header-logo-inset: 8px; } }
322
- :root:has(.site-header[data-logo-size='large'][data-logo-placement='overhang']) { --header-logo-h: 64px; }
323
- :root:has(.site-header[data-logo-size='xl'][data-logo-placement='overhang']) { --header-logo-h: 88px; }
324
- @media (min-width: 48em) {
325
- :root:has(.site-header[data-logo-size='large'][data-logo-placement='overhang']) { --header-logo-h: 88px; }
326
- :root:has(.site-header[data-logo-size='xl'][data-logo-placement='overhang']) { --header-logo-h: 152px; }
327
- }
328
- @media (min-width: 64em) {
329
- :root:has(.site-header[data-logo-size='large']),
330
- :root:has(.site-header[data-logo-size='large'][data-logo-placement='overhang']) { --header-logo-h: 112px; }
331
- :root:has(.site-header[data-logo-size='xl']),
332
- :root:has(.site-header[data-logo-size='xl'][data-logo-placement='overhang']) { --header-logo-h: 216px; }
333
- .site-header[data-logo-size]:not([data-logo-placement]):not(.is-compact) {
334
- min-height: calc(var(--header-logo-h) + 16px);
335
- }
336
- }
337
- /* How far the logo hangs below the bar at the top of the page: the page's first words
338
- keep clear of it (Base, Hero). */
339
- :root:has(.site-header[data-logo-placement='overhang']) {
340
- --logo-overhang: max(0px, calc(var(--header-logo-h) + var(--header-logo-inset) - var(--header-bar-h)));
341
- }
342
-
343
- /* Overhang: pinned to the top of the bar with a small inset, hanging below it over the
344
- opener. The brand keeps the logo's width in the bar, so the menu and buttons keep their
345
- space. Above the page, under the open menus (the drawer and the dropdown panel). */
346
- .site-header[data-logo-placement='overhang'] { --logo-now: var(--header-logo-h); }
347
- .site-header[data-logo-placement='overhang'] .brand {
348
- position: relative;
349
- z-index: 1;
350
- align-self: stretch;
351
- flex-shrink: 0;
352
- width: calc(var(--logo-now) * var(--logo-ratio, 1));
353
- transition: width 0.25s ease;
354
- }
355
- .site-header[data-logo-placement='overhang'] .primary-logo {
356
- position: absolute;
357
- left: 0;
358
- top: var(--header-logo-inset);
359
- height: var(--logo-now);
360
- width: auto;
361
- max-width: none;
362
- transition: height 0.25s ease, top 0.25s ease;
363
- }
364
- /* Scrolled down (unless the site keeps it hanging), or a menu open: back inside the bar,
365
- at the small size, so it never covers what the visitor is reading. */
366
- .site-header[data-logo-placement='overhang'].is-compact:not([data-logo-hang]),
367
- .site-header[data-logo-placement='overhang'].is-menu-open { --logo-now: 38px; }
368
- .site-header[data-logo-placement='overhang'].is-compact:not([data-logo-hang]) .primary-logo,
369
- .site-header[data-logo-placement='overhang'].is-menu-open .primary-logo {
370
- top: calc(50% - var(--logo-now) / 2);
371
- }
372
- /* A soft shadow, so a dark round badge stands apart from a dark header. */
373
- .site-header[data-logo-shadow] .primary-logo {
374
- filter: drop-shadow(var(--shadow-logo));
375
- }
376
- @media (prefers-reduced-motion: reduce) {
377
- .site-header[data-logo-placement='overhang'] .brand,
378
- .site-header[data-logo-placement='overhang'] .primary-logo { transition: none; }
379
- }
380
-
381
- /* ── Center nav ── */
382
- .site-nav {
383
- display: flex;
384
- align-items: center;
385
- gap: 28px;
386
- position: absolute;
387
- left: 50%;
388
- transform: translateX(-50%);
389
- }
390
- .nav-link {
391
- position: relative;
392
- display: inline-flex;
393
- align-items: center;
394
- padding: 14px 0;
395
- color: var(--accent);
396
- text-decoration: none;
397
- font-family: var(--font-body);
398
- font-size: 0.875rem;
399
- font-weight: 500;
400
- letter-spacing: 0.1em;
401
- text-transform: uppercase;
402
- transition: color 0.25s ease;
403
- }
404
- .nav-link::after {
405
- content: '';
406
- position: absolute;
407
- bottom: 4px;
408
- left: 0;
409
- right: 0;
410
- height: 2px;
411
- background: var(--gold);
412
- transform: scaleX(0);
413
- transition: transform 0.2s ease;
414
- border-radius: 1px;
415
- }
416
- .nav-link:hover { color: var(--gold); }
417
- .nav-link:focus-visible {
418
- outline: 2px solid var(--gold);
419
- outline-offset: 3px;
420
- border-radius: 2px;
421
- }
422
- .nav-link.active {
423
- color: var(--gold);
424
- font-weight: 500;
425
- }
426
- .nav-link.active::after { display: none; }
427
- .nav-item.panel-active > .nav-link::after { display: none; }
428
- [data-theme="dark"] .nav-link { color: var(--text-light); }
429
- [data-theme="dark"] .nav-link:hover { color: var(--gold); }
430
- [data-theme="dark"] .nav-link.active { color: var(--gold); }
431
- [data-theme="dark"] .nav-toggle span { background: var(--text-light); }
432
-
433
- /* ── Right side ── */
434
- .nav-right {
435
- display: flex;
436
- align-items: center;
437
- gap: 12px;
438
- flex-shrink: 0;
439
- position: relative;
440
- z-index: 101; /* always above the mobile full-screen nav (z-index: 99) */
441
- }
442
-
443
- /* Crowded (#11, set by measuring): the centred menu would collide with the site name or
444
- the buttons, so it takes its own row under them and wraps if it must. Desktop only;
445
- below 64em the drawer applies as usual. */
446
- @media (min-width: 64em) {
447
- .site-header.is-crowded,
448
- .site-header.is-crowded.is-compact {
449
- height: auto;
450
- flex-wrap: wrap;
451
- row-gap: 0;
452
- padding-block: 6px;
453
- }
454
- .site-header.is-crowded .site-nav {
455
- position: static;
456
- transform: none;
457
- order: 3;
458
- flex-basis: 100%;
459
- justify-content: center;
460
- flex-wrap: wrap;
461
- column-gap: 24px;
462
- row-gap: 0;
463
- }
464
- .site-header.is-crowded .site-nav .nav-link {
465
- padding-block: 8px;
466
- }
467
- /* A hanging logo reaches down past the first row: the menu's own row starts beside it. */
468
- .site-header.is-crowded[data-logo-placement='overhang'] .site-nav {
469
- padding-inline-start: calc(var(--logo-now) * var(--logo-ratio, 1) + 16px);
470
- }
471
- }
472
-
473
- /* ── Contact CTA ── */
474
- .nav-cta {
475
- white-space: nowrap;
476
- }
477
- .nav-cta:hover,
478
- .nav-cta.active { background: color-mix(in srgb, var(--gold) 85%, #000); color: var(--on-brand); border: none; }
479
- [data-theme="dark"] .nav-cta { background: var(--gold); color: var(--dark-bg); border: none; }
480
- [data-theme="dark"] .nav-cta:hover,
481
- [data-theme="dark"] .nav-cta.active { background: color-mix(in srgb, var(--gold) 85%, #fff); color: var(--dark-bg); border: none; }
482
-
483
- .nav-mobile-theme .nav-cta--drawer {
484
- display: none;
485
- }
486
- @media (min-width: 64em) {
487
- .nav-mobile-theme .btn.nav-cta--drawer,
488
- .nav-mobile-theme a.nav-cta--drawer {
489
- display: none !important;
490
- }
491
- }
492
-
493
- /* ── Theme toggle: segmented sun/moon switch, shared by the desktop
494
- button and the mobile drawer button. Both icons stay in the DOM at all
495
- times, pinned to either side; a gold highlight slides behind whichever
496
- one is active. --overlay-accent-08/-18 already resolve to the dark-mode
497
- white-tinted values via the [data-theme="dark"] root override in
498
- theme.css, so no manual dark-mode override is needed for the track
499
- itself. */
500
- .theme-toggle,
501
- .theme-toggle-mobile {
502
- position: relative;
503
- display: inline-flex;
504
- align-items: center;
505
- justify-content: space-around;
506
- width: 64px;
507
- height: 30px;
508
- padding: 3px;
509
- background: var(--overlay-accent-08);
510
- border: 1px solid var(--overlay-accent-18);
511
- border-radius: 999px;
512
- cursor: pointer;
513
- flex-shrink: 0;
514
- transition:
515
- background-color 0.35s cubic-bezier(0.4, 0, 0.2, 1),
516
- border-color 0.35s cubic-bezier(0.4, 0, 0.2, 1);
517
- }
518
- .theme-toggle:hover,
519
- .theme-toggle-mobile:hover {
520
- border-color: var(--gold);
521
- }
522
- .theme-toggle:focus-visible,
523
- .theme-toggle-mobile:focus-visible {
524
- outline: 2px solid var(--gold);
525
- outline-offset: 2px;
526
- }
527
-
528
- .theme-toggle__highlight {
529
- position: absolute;
530
- top: 3px;
531
- left: 3px;
532
- width: calc(50% - 3px);
533
- height: calc(100% - 6px);
534
- border-radius: 999px;
535
- background: var(--gold);
536
- transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
537
- }
538
- [data-theme="dark"] .theme-toggle__highlight { transform: translateX(100%); }
539
-
540
- .theme-icon {
541
- position: relative;
542
- z-index: 1;
543
- width: 14px;
544
- height: 14px;
545
- color: var(--fg);
546
- opacity: 0.5;
547
- transition: opacity 0.3s ease, color 0.3s ease;
548
- }
549
- .theme-icon--sun { opacity: 1; }
550
- [data-theme="dark"] .theme-icon--sun { opacity: 0.5; }
551
- [data-theme="dark"] .theme-icon--moon { opacity: 1; color: var(--dark-bg); }
552
-
553
- /* Mobile theme toggle row — hidden on desktop */
554
- .nav-mobile-theme { display: none; }
555
-
556
- /* ── Hamburger ── */
557
- .nav-toggle {
558
- display: none;
559
- flex-direction: column;
560
- justify-content: center;
561
- align-items: center;
562
- width: 44px;
563
- height: 44px;
564
- padding: 0;
565
- background: none;
566
- border: none;
567
- cursor: pointer;
568
- border-radius: 8px;
569
- transition: background 0.15s;
570
- position: relative;
571
- }
572
- .nav-toggle:hover { background: var(--overlay-white-08); }
573
- .nav-toggle span {
574
- display: block;
575
- position: absolute;
576
- width: 22px;
577
- height: 2px;
578
- background: var(--fg);
579
- border-radius: 2px;
580
- transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, top 0.3s cubic-bezier(0.4, 0, 0.2, 1);
581
- transform-origin: center;
582
- }
583
- .nav-toggle span:nth-child(1) { top: 13px; }
584
- .nav-toggle span:nth-child(2) { top: 19px; }
585
- .nav-toggle span:nth-child(3) { top: 25px; }
586
- .nav-toggle.open span:nth-child(1) { top: 19px; transform: rotate(45deg); }
587
- .nav-toggle.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
588
- .nav-toggle.open span:nth-child(3) { top: 19px; transform: rotate(-45deg); }
589
-
590
- /* ── Mega nav system (tablet/desktop, not phone overlay) ── */
591
- .mega-nav {
592
- display: none;
593
- position: fixed;
594
- top: 56px;
595
- left: 0;
596
- right: 0;
597
- z-index: 98;
598
- pointer-events: none;
599
- }
600
- .mega-nav.is-open {
601
- display: block;
602
- pointer-events: auto;
603
- }
604
- .mega-nav__backdrop {
605
- position: fixed;
606
- inset: 0;
607
- top: 56px;
608
- background: rgba(0,0,0,0.45);
609
- z-index: -1;
610
- animation: backdropIn 0.2s ease forwards;
611
- }
612
- @media (min-width: 64em) {
613
- .mega-nav,
614
- .mega-nav__backdrop {
615
- top: var(--mega-top, 64px);
616
- }
617
- }
618
- @media (max-width: 47.9375em) {
619
- .mega-nav,
620
- .mega-nav__backdrop {
621
- top: 60px;
622
- }
623
- }
624
- @keyframes backdropIn {
625
- from { opacity: 0; }
626
- to { opacity: 1; }
627
- }
628
-
629
- .mega-panel {
630
- display: none;
631
- }
632
- .mega-nav.is-open .mega-panel {
633
- display: block;
634
- animation: panelIn 0.18s ease forwards;
635
- }
636
- .mega-panel--about {
637
- background: var(--bg);
638
- box-shadow: 0 16px 48px rgba(0,0,0,0.4);
639
- }
640
-
641
- @keyframes panelIn {
642
- from { opacity: 0; transform: translateY(-6px); }
643
- to { opacity: 1; transform: translateY(0); }
644
- }
645
-
646
- .mega-panel__inner {
647
- max-width: 1100px;
648
- margin: 0 auto;
649
- padding: 2rem 2.5rem;
650
- }
651
-
652
- .mega-section-header {
653
- display: flex;
654
- align-items: baseline;
655
- justify-content: space-between;
656
- margin-bottom: 1.25rem;
657
- padding-bottom: 0.75rem;
658
- }
659
- .mega-section-header h2 {
660
- margin: 0;
661
- font-size: 1rem;
662
- color: var(--accent);
663
- font-family: var(--font-heading);
664
- font-weight: 600;
665
- letter-spacing: 0.04em;
666
- }
667
- [data-theme="dark"] .mega-section-header h2 { color: var(--text-light); }
668
- .mega-about-grid {
669
- display: grid;
670
- grid-template-columns: repeat(5, 1fr);
671
- gap: 0.85rem;
672
- }
673
- .mega-about-card {
674
- display: flex;
675
- flex-direction: column;
676
- align-items: flex-start;
677
- gap: 6px;
678
- padding: 1rem 1.1rem;
679
- background: rgba(200,151,58,0.1);
680
- border: 1px solid rgba(200,151,58,0.35);
681
- border-radius: 10px;
682
- text-decoration: none;
683
- transition: background 0.15s, border-color 0.15s, transform 0.15s;
684
- }
685
- .mega-about-card:hover {
686
- background: rgba(200,151,58,0.1);
687
- border-color: rgba(200,151,58,0.35);
688
- transform: translateY(-2px);
689
- }
690
- .mega-about-card:focus-visible {
691
- outline: 2px solid var(--gold);
692
- outline-offset: 2px;
693
- }
694
- .mega-about-card:hover .mega-about-title { color: var(--gold); }
695
- [data-theme="dark"] .mega-about-card { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.07); }
696
- [data-theme="dark"] .mega-about-card:hover { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.07); transform: translateY(-2px); }
697
- .mega-about-card.active,
698
- .mega-about-card.active:hover {
699
- background: rgba(200,151,58,0.12);
700
- border-color: rgba(200,151,58,0.45);
701
- }
702
- /* [data-theme="dark"] .mega-about-card:hover above has higher specificity
703
- (attribute selector + class + pseudo-class) than .mega-about-card.active
704
- (two classes), so without this it would win and flatten the active card
705
- back to the plain hover look. Matching specificity + declared after it
706
- keeps the active highlight showing through hover in dark mode too. */
707
- [data-theme="dark"] .mega-about-card.active,
708
- [data-theme="dark"] .mega-about-card.active:hover {
709
- background: rgba(200,151,58,0.12);
710
- border-color: rgba(200,151,58,0.45);
711
- }
712
- .mega-about-card.active .mega-about-title { color: var(--gold); }
713
- .mega-about-card.active .mega-about-icon { background: rgba(200,151,58,0.25); }
714
- .mega-about-icon {
715
- width: 42px;
716
- height: 42px;
717
- background: rgba(200,151,58,0.12);
718
- border-radius: 8px;
719
- display: flex;
720
- align-items: center;
721
- justify-content: center;
722
- color: var(--gold);
723
- margin-bottom: 2px;
724
- }
725
- .mega-about-title {
726
- font-size: 0.875rem;
727
- font-weight: 600;
728
- color: var(--accent);
729
- font-family: var(--font-body);
730
- line-height: 1.3;
731
- transition: color 0.15s;
732
- }
733
- [data-theme="dark"] .mega-about-title { color: var(--text-light); }
734
- .mega-about-desc {
735
- font-size: 0.75rem;
736
- color: var(--accent);
737
- font-weight: 500;
738
- font-family: var(--font-body);
739
- line-height: 1.4;
740
- }
741
- .mega-about-sub {
742
- font-size: 0.8rem;
743
- color: var(--accent);
744
- font-weight: 500;
745
- font-family: var(--font-body);
746
- }
747
- [data-theme="dark"] .mega-about-desc,
748
- [data-theme="dark"] .mega-about-sub {
749
- color: var(--muted);
750
- font-weight: 400;
751
- }
752
-
753
- .mega-empty {
754
- color: var(--text-subtle);
755
- font-size: 0.9rem;
756
- font-style: italic;
757
- }
758
-
759
- /* Hide mega nav whenever hamburger / drawer nav is used (≤1023px) */
760
- @media (max-width: 63.9375em) {
761
- .mega-nav { display: none !important; }
762
- }
763
-
764
- /* Desktop only: hide flyout dropdown (replaced by mega panel) */
765
- @media (min-width: 64em) {
766
- .nav-dropdown { display: none; }
767
- }
768
-
769
- /* ── About dropdown (mega-menu style, mobile only) ── */
770
- .nav-item { position: relative; display: flex; align-items: center; }
771
- .nav-chevron {
772
- display: inline-block;
773
- vertical-align: middle;
774
- margin-left: 3px;
775
- transform: rotate(0deg);
776
- transition: transform 0.2s ease;
777
- }
778
- .nav-item.open .nav-chevron,
779
- .nav-item.panel-active .nav-chevron { transform: rotate(180deg); }
780
-
781
- .nav-dropdown {
782
- display: none;
783
- position: absolute;
784
- top: calc(100% + 12px);
785
- left: 50%;
786
- transform: translateX(-50%);
787
- min-width: 280px;
788
- background: var(--bg-surface);
789
- border: 1px solid var(--border);
790
- border-top: 2px solid var(--gold);
791
- border-radius: 0 0 10px 10px;
792
- box-shadow: 0 12px 32px rgba(0,0,0,0.35);
793
- list-style: none;
794
- padding: 0.35rem 0;
795
- margin: 0;
796
- z-index: 200;
797
- }
798
- .nav-item.open .nav-dropdown { display: block; }
799
-
800
- .nav-dropdown li a {
801
- display: flex;
802
- align-items: center;
803
- gap: 12px;
804
- padding: 0.65rem 1.1rem;
805
- color: var(--muted);
806
- text-decoration: none;
807
- transition: background 0.12s, color 0.12s;
808
- border-radius: 0;
809
- }
810
- .nav-dropdown li a:hover {
811
- background: rgba(200,151,58,0.1);
812
- color: var(--fg);
813
- }
814
- .nav-dropdown li a:focus-visible {
815
- outline: 2px solid var(--gold);
816
- outline-offset: -2px;
817
- }
818
- .nav-dropdown li a:hover .drop-title { color: var(--gold); }
819
- .nav-dropdown li a.active { color: var(--fg); }
820
- .nav-dropdown li a.active .drop-title { color: var(--gold); }
821
- .nav-dropdown li a.active .drop-icon { background: rgba(200,151,58,0.25); }
822
- .nav-dropdown li + li {
823
- border-top: 1px solid rgba(255,255,255,0.05);
824
- }
825
-
826
- .drop-icon {
827
- flex-shrink: 0;
828
- width: 32px;
829
- height: 32px;
830
- display: flex;
831
- align-items: center;
832
- justify-content: center;
833
- background: rgba(200,151,58,0.12);
834
- border-radius: 6px;
835
- color: var(--gold);
836
- }
837
-
838
- .drop-text {
839
- display: flex;
840
- flex-direction: column;
841
- gap: 1px;
842
- }
843
-
844
- .drop-title {
845
- font-family: var(--font-body);
846
- font-size: 0.8125rem;
847
- font-weight: 600;
848
- color: var(--text-light);
849
- line-height: 1.3;
850
- transition: color 0.12s;
851
- }
852
-
853
- .drop-desc {
854
- font-family: var(--font-body);
855
- font-size: 0.6875rem;
856
- color: var(--text-subtle);
857
- line-height: 1.3;
858
- }
859
-
860
- /* ── Tablet md: 768px+ ── */
861
- @media (min-width: 48em) {
862
- .site-header { padding: 0 2.5rem; }
863
- }
864
-
865
- /* ── Mobile overlay backdrop ── */
866
- .mobile-overlay {
867
- position: fixed;
868
- inset: 0;
869
- background: rgba(0,0,0,0.5);
870
- z-index: 98;
871
- opacity: 0;
872
- visibility: hidden;
873
- transition: opacity 0.22s ease, visibility 0.22s ease;
874
- pointer-events: none;
875
- }
876
- .mobile-overlay.visible {
877
- opacity: 1;
878
- visibility: visible;
879
- pointer-events: auto;
880
- }
881
-
882
- /* ── Hamburger + slide-out nav (≤1023px) ── */
883
- @media (max-width: 63.9375em) {
884
- .nav-toggle { display: flex; }
885
- .nav-cta-header-wrap { display: none; }
886
- .nav-right .theme-toggle { display: none; }
887
-
888
- .site-nav {
889
- display: flex;
890
- flex-direction: column;
891
- align-items: stretch;
892
- position: fixed;
893
- top: 56px;
894
- left: 0;
895
- right: 0;
896
- bottom: 0;
897
- width: 100%;
898
- transform: none;
899
- background: var(--bg-tag);
900
- border-top: 1px solid rgba(44,59,42,0.10);
901
- padding: 2rem 0 2rem;
902
- gap: 0;
903
- overflow-y: auto;
904
- overflow-x: hidden;
905
- pointer-events: none;
906
- opacity: 0;
907
- visibility: hidden;
908
- transition: opacity 0.22s ease, visibility 0.22s ease;
909
- z-index: 99;
910
- justify-content: flex-start;
911
- }
912
- [data-theme="dark"] .site-nav { background: var(--dark-bg); border-top-color: rgba(255,255,255,0.10); }
913
- .site-nav.open {
914
- opacity: 1;
915
- visibility: visible;
916
- pointer-events: auto;
917
- }
918
-
919
- .nav-link {
920
- display: flex;
921
- align-items: center;
922
- justify-content: flex-start;
923
- position: relative;
924
- gap: 0;
925
- padding: 1rem 3rem;
926
- font-size: 0.9375rem;
927
- font-weight: 300;
928
- font-family: var(--font-heading);
929
- border-radius: 0;
930
- text-align: left;
931
- width: 100%;
932
- color: var(--fg);
933
- transition: color 0.18s ease;
934
- }
935
- .nav-link::before {
936
- content: '';
937
- position: absolute;
938
- bottom: 0;
939
- left: 3rem;
940
- right: 0;
941
- height: 1px;
942
- background: rgba(255,255,255,0.08);
943
- }
944
- /* Last link (Calendar) sits directly above .nav-mobile-theme's own
945
- border-top — drop its trailing divider so the two don't double up. */
946
- .site-nav > .nav-link:last-of-type::before { display: none; }
947
- .nav-link:hover { color: var(--gold); background: none; }
948
- .nav-link::after { display: none; }
949
- .nav-link.active { color: var(--gold); font-weight: 400; }
950
-
951
- .nav-mobile-theme {
952
- display: flex;
953
- justify-content: flex-end;
954
- align-items: center;
955
- padding: 1rem 1.5rem;
956
- border-top: 1px solid var(--border);
957
- margin-top: 0.5rem;
958
- }
959
-
960
- .nav-item { width: 100%; flex-direction: column; align-items: stretch; }
961
- .nav-item .nav-link {
962
- width: 100%;
963
- display: flex;
964
- justify-content: flex-start;
965
- align-items: center;
966
- }
967
- .nav-item .nav-chevron { margin-left: auto; }
968
- .nav-dropdown {
969
- position: static;
970
- transform: none;
971
- display: block;
972
- width: 100%;
973
- background: transparent;
974
- border: none;
975
- border-radius: 0;
976
- box-shadow: none;
977
- min-width: 0;
978
- max-height: 0;
979
- overflow: hidden;
980
- padding: 0;
981
- transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease;
982
- }
983
- .nav-item.open .nav-dropdown {
984
- max-height: min(70vh, 560px);
985
- max-height: min(70dvh, 560px);
986
- padding: 0.35rem 0;
987
- }
988
- .nav-dropdown li a {
989
- padding: 0.6rem 1.5rem 0.6rem 3rem;
990
- gap: 10px;
991
- justify-content: flex-start;
992
- font-size: 0.8rem;
993
- color: var(--fg);
994
- transition: color 0.18s ease;
995
- }
996
- .nav-dropdown li a:hover { color: var(--gold); background: none; }
997
- .drop-icon { width: 24px; height: 24px; flex-shrink: 0; transition: color 0.18s ease; }
998
- .drop-title { font-size: 0.75rem; color: var(--fg); transition: color 0.18s ease; }
999
- [data-theme="dark"] .nav-dropdown li a { color: rgba(250,246,239,0.75); }
1000
- [data-theme="dark"] .nav-dropdown li a:hover,
1001
- [data-theme="dark"] .nav-dropdown li a:active { color: var(--gold); }
1002
- [data-theme="dark"] .nav-dropdown li a:hover .drop-title,
1003
- [data-theme="dark"] .nav-dropdown li a:active .drop-title { color: var(--gold); }
1004
- [data-theme="dark"] .nav-dropdown li a:hover .drop-icon,
1005
- [data-theme="dark"] .nav-dropdown li a:active .drop-icon { color: var(--gold); }
1006
- [data-theme="dark"] .drop-title { color: rgba(250,246,239,0.9); }
1007
- .drop-desc { display: none; }
1008
- .nav-dropdown li + li { border-top: 1px solid rgba(255,255,255,0.04); }
1009
-
1010
- .site-nav .nav-mobile-theme .btn.nav-cta--drawer,
1011
- .site-nav .nav-mobile-theme a.nav-cta--drawer {
1012
- display: inline-flex !important;
1013
- }
1014
- .site-nav .nav-mobile-theme {
1015
- justify-content: space-between;
1016
- align-items: center;
1017
- gap: 0.75rem;
1018
- }
1019
- .site-nav .nav-mobile-theme .nav-cta--drawer {
1020
- flex: 1 1 auto;
1021
- min-width: 0;
1022
- max-width: calc(100% - 3.25rem);
1023
- justify-content: center;
1024
- }
1025
- }
1026
-
1027
- /* ── Phone only: shorter header (≤767px) ── */
1028
- @media (max-width: 47.9375em) {
1029
- .site-nav { top: 60px; }
1030
- .site-header { padding: 0 1.25rem; height: 60px; }
1031
- .brand { gap: 10px; }
1032
- }
1033
- </style>
1034
-
1035
- <script>
1036
- // ── Hamburger (mobile) ──
1037
- const toggle = document.querySelector('.nav-toggle') as HTMLButtonElement;
1038
- const nav = document.querySelector('#site-nav') as HTMLElement;
1039
- const megaNav = document.getElementById('mega-nav') as HTMLElement;
1040
- const aboutTrigger = document.querySelector('.nav-has-dropdown') as HTMLElement;
1041
- const aboutLink = aboutTrigger?.querySelector('.nav-link') as HTMLAnchorElement;
1042
- const mobileOverlay = document.getElementById('mobile-overlay') as HTMLElement;
1043
-
1044
- let scrollY = 0;
1045
-
1046
- function openNav() {
1047
- scrollY = window.scrollY;
1048
- document.body.style.position = 'fixed';
1049
- document.body.style.top = `-${scrollY}px`;
1050
- document.body.style.width = '100%';
1051
- nav.classList.add('open');
1052
- toggle.classList.add('open');
1053
- siteHeader?.classList.add('is-menu-open');
1054
- mobileOverlay.classList.add('visible');
1055
- toggle.setAttribute('aria-expanded', 'true');
1056
- }
1057
-
1058
- function closeNav() {
1059
- const wasFixed = document.body.style.position === 'fixed';
1060
- document.body.style.position = '';
1061
- document.body.style.top = '';
1062
- document.body.style.width = '';
1063
- if (wasFixed) window.scrollTo(0, scrollY);
1064
- nav.classList.remove('open');
1065
- toggle.classList.remove('open');
1066
- siteHeader?.classList.remove('is-menu-open');
1067
- mobileOverlay.classList.remove('visible');
1068
- toggle.setAttribute('aria-expanded', 'false');
1069
- aboutTrigger?.classList.remove('open');
1070
- aboutLink?.setAttribute('aria-expanded', 'false');
1071
- }
1072
-
1073
- toggle.addEventListener('click', () => {
1074
- nav.classList.contains('open') ? closeNav() : openNav();
1075
- });
1076
-
1077
- mobileOverlay?.addEventListener('click', closeNav);
1078
-
1079
- document.addEventListener('click', e => {
1080
- const target = e.target as HTMLElement;
1081
- if (!target.closest('.site-header') && !target.closest('#mobile-overlay')) {
1082
- closeNav();
1083
- }
1084
- });
1085
-
1086
- // Close the drawer when a real link inside it is clicked. This used to be
1087
- // an accidental side effect of navigation always hard-reloading the page
1088
- // (nav starts closed on a fresh load) — now that the header persists
1089
- // across Astro's <ClientRouter /> transitions (see /posts/), that DOM
1090
- // node's "open" state carries over untouched too, so it needs an explicit
1091
- // close here. Skip the "About Us" trigger: on mobile that link expands the
1092
- // submenu in place (preventDefault below) instead of navigating away.
1093
- nav.addEventListener('click', e => {
1094
- const link = (e.target as HTMLElement).closest('a[href]');
1095
- if (!link || link.getAttribute('aria-haspopup') === 'true') return;
1096
- closeNav();
1097
- });
1098
-
1099
- const siteHeader = document.querySelector('.site-header') as HTMLElement | null;
1100
-
1101
- // Shrink-on-scroll: condense the header once the page is scrolled.
1102
- if (siteHeader) {
1103
- const onScrollCompact = () => siteHeader.classList.toggle('is-compact', window.scrollY > 40);
1104
- onScrollCompact();
1105
- window.addEventListener('scroll', onScrollCompact, { passive: true });
1106
- }
1107
-
1108
- // The header's full height, published as --header-h on <html> so a full-screen opener
1109
- // fills the screen BELOW the sticky header (Hero size "screen"). Only the full-size header
1110
- // counts: while it's condensed on scroll, or animating between sizes, the last full value
1111
- // stays, so the opener never resizes as the page scrolls.
1112
- let headerAnimating = false;
1113
- function syncHeaderHeight() {
1114
- if (!siteHeader || headerAnimating || siteHeader.classList.contains('is-compact')) return;
1115
- document.documentElement.style.setProperty('--header-h', `${siteHeader.getBoundingClientRect().height}px`);
1116
- }
1117
- if (siteHeader) {
1118
- siteHeader.addEventListener('transitionrun', (e) => {
1119
- if (e.target === siteHeader && (e.propertyName === 'height' || e.propertyName === 'min-height')) headerAnimating = true;
1120
- });
1121
- const settled = (e: TransitionEvent) => {
1122
- if (e.target !== siteHeader || (e.propertyName !== 'height' && e.propertyName !== 'min-height')) return;
1123
- headerAnimating = false;
1124
- syncHeaderHeight();
1125
- };
1126
- siteHeader.addEventListener('transitionend', settled);
1127
- siteHeader.addEventListener('transitioncancel', settled);
1128
- // The first value is published below, once the crowding check has settled the layout.
1129
- }
1130
-
1131
- // Crowding (#11): on desktop the menu is centred on the header. When the site name (or
1132
- // the right-hand buttons) would run into it, give the menu its own row instead. Decided
1133
- // by measuring the real layout, so it adapts to any name and any number of links.
1134
- if (siteHeader) {
1135
- const desktop = window.matchMedia('(min-width: 64em)');
1136
- const brand = siteHeader.querySelector<HTMLElement>('.brand');
1137
- const nav = siteHeader.querySelector<HTMLElement>('.site-nav');
1138
- const right = siteHeader.querySelector<HTMLElement>('.nav-right');
1139
- const GAP = 16;
1140
- const fitCheck = () => {
1141
- if (!brand || !nav || !right) return;
1142
- siteHeader.classList.remove('is-crowded');
1143
- if (!desktop.matches) return;
1144
- const b = brand.getBoundingClientRect();
1145
- const n = nav.getBoundingClientRect();
1146
- const r = right.getBoundingClientRect();
1147
- if (b.right + GAP > n.left || n.right + GAP > r.left) siteHeader.classList.add('is-crowded');
1148
- };
1149
- let queued = false;
1150
- const queue = () => { if (!queued) { queued = true; requestAnimationFrame(() => { queued = false; fitCheck(); }); } };
1151
- if (brand) new ResizeObserver(queue).observe(brand);
1152
- new ResizeObserver(queue).observe(siteHeader);
1153
- new ResizeObserver(syncHeaderHeight).observe(siteHeader);
1154
- desktop.addEventListener('change', queue);
1155
- document.fonts?.ready.then(queue);
1156
- fitCheck();
1157
- // Only now that the menu has its row (or not) is the header its real height: publishing
1158
- // it before the check told the opener the one-row height until the next frame.
1159
- syncHeaderHeight();
1160
- }
1161
-
1162
- function openMega() {
1163
- if (!megaNav || !aboutTrigger) return;
1164
- const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
1165
- const scrollY = window.scrollY;
1166
- // The panel opens right under the header, whatever its height (a taller bar for a large logo).
1167
- if (siteHeader) megaNav.style.setProperty('--mega-top', `${Math.round(siteHeader.getBoundingClientRect().bottom)}px`);
1168
- megaNav.classList.add('is-open');
1169
- megaNav.removeAttribute('aria-hidden');
1170
- siteHeader?.classList.add('is-menu-open');
1171
- aboutTrigger.classList.add('panel-active');
1172
- aboutLink?.setAttribute('aria-expanded', 'true');
1173
- siteHeader?.classList.add('header--scrolled');
1174
-
1175
- document.body.style.position = 'fixed';
1176
- document.body.style.top = `-${scrollY}px`;
1177
- document.body.style.left = '0';
1178
- document.body.style.right = '0';
1179
- document.body.style.paddingRight = scrollbarWidth + 'px';
1180
- document.body.dataset.scrollY = String(scrollY);
1181
- }
1182
-
1183
- function closeMega() {
1184
- if (!megaNav || !aboutTrigger) return;
1185
- megaNav.classList.remove('is-open');
1186
- megaNav.setAttribute('aria-hidden', 'true');
1187
- siteHeader?.classList.remove('is-menu-open');
1188
- aboutTrigger.classList.remove('panel-active');
1189
- aboutLink?.setAttribute('aria-expanded', 'false');
1190
-
1191
- const scrollY = parseInt(document.body.dataset.scrollY || '0', 10);
1192
- document.body.style.position = '';
1193
- document.body.style.top = '';
1194
- document.body.style.left = '';
1195
- document.body.style.right = '';
1196
- document.body.style.paddingRight = '';
1197
- delete document.body.dataset.scrollY;
1198
- window.scrollTo(0, scrollY);
1199
-
1200
- if (scrollY < 1) siteHeader?.classList.remove('header--scrolled');
1201
- }
1202
-
1203
- aboutLink?.addEventListener('click', e => {
1204
- if (window.matchMedia('(min-width: 64em)').matches) {
1205
- e.preventDefault();
1206
- if (megaNav.classList.contains('is-open')) {
1207
- closeMega();
1208
- } else {
1209
- openMega();
1210
- }
1211
- } else {
1212
- e.preventDefault();
1213
- aboutTrigger.classList.toggle('open');
1214
- aboutLink?.setAttribute('aria-expanded', aboutTrigger.classList.contains('open') ? 'true' : 'false');
1215
- }
1216
- });
1217
-
1218
- document.addEventListener('click', e => {
1219
- if (
1220
- window.matchMedia('(min-width: 64em)').matches &&
1221
- megaNav?.classList.contains('is-open') &&
1222
- !(e.target as HTMLElement).closest('.nav-has-dropdown') &&
1223
- !(e.target as HTMLElement).closest('#mega-nav')
1224
- ) {
1225
- closeMega();
1226
- }
1227
- });
1228
-
1229
- document.getElementById('mega-backdrop')?.addEventListener('click', closeMega);
1230
- document.addEventListener('keydown', e => {
1231
- if (e.key !== 'Escape') return;
1232
- closeMega();
1233
- if (nav.classList.contains('open')) closeNav();
1234
- });
1235
-
1236
- // ── Theme toggle ──
1237
- const html = document.documentElement;
1238
- const themeToggle = document.getElementById('theme-toggle') as HTMLButtonElement | null;
1239
- const themeToggleMobile = document.getElementById('theme-toggle-mobile') as HTMLButtonElement | null;
1240
-
1241
- const THEME_STORAGE_KEY = 'theme';
1242
- /** Set only when the user clicks the toggle — that's when localStorage takes
1243
- priority over the system preference. */
1244
- const THEME_SOURCE_KEY = 'theme-source';
1245
-
1246
- function syncPrimaryLogo() {
1247
- const img = document.getElementById('primary-logo') as HTMLImageElement | null;
1248
- if (!img) return;
1249
- const src = html.dataset.theme === 'dark'
1250
- ? (img.dataset.srcDark ?? img.dataset.srcLight)
1251
- : img.dataset.srcLight;
1252
- if (src) img.src = src;
1253
- }
1254
-
1255
- function syncThemedRasterLogos() {
1256
- syncPrimaryLogo();
1257
- }
1258
-
1259
- /** Keeps the switch's accessible state (role="switch" aria-checked) in
1260
- sync with the rendered theme — called everywhere html.dataset.theme
1261
- is set. */
1262
- function syncToggleAria() {
1263
- const checked = html.dataset.theme === 'dark' ? 'true' : 'false';
1264
- themeToggle?.setAttribute('aria-checked', checked);
1265
- themeToggleMobile?.setAttribute('aria-checked', checked);
1266
- }
1267
-
1268
- function systemTheme(): 'dark' | 'light' {
1269
- return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
1270
- }
1271
-
1272
- function userThemeOverride(): 'dark' | 'light' | null {
1273
- if (localStorage.getItem(THEME_SOURCE_KEY) !== 'user') return null;
1274
- const v = localStorage.getItem(THEME_STORAGE_KEY);
1275
- return v === 'light' || v === 'dark' ? v : null;
1276
- }
1277
-
1278
- function applyThemeFromStorageOrSystem() {
1279
- const override = userThemeOverride();
1280
- html.dataset.theme = override ?? systemTheme();
1281
- syncThemedRasterLogos();
1282
- syncToggleAria();
1283
- }
1284
-
1285
- function onSystemThemeChange() {
1286
- if (userThemeOverride() !== null) return;
1287
- html.dataset.theme = systemTheme();
1288
- syncThemedRasterLogos();
1289
- syncToggleAria();
1290
- }
1291
-
1292
- function setUserThemeChoice(theme: 'dark' | 'light') {
1293
- localStorage.setItem(THEME_SOURCE_KEY, 'user');
1294
- localStorage.setItem(THEME_STORAGE_KEY, theme);
1295
- html.dataset.theme = theme;
1296
- syncThemedRasterLogos();
1297
- syncToggleAria();
1298
- }
1299
-
1300
- applyThemeFromStorageOrSystem();
1301
- const colorSchemeMq = window.matchMedia('(prefers-color-scheme: dark)');
1302
- colorSchemeMq.addEventListener('change', onSystemThemeChange);
1303
-
1304
- function toggleTheme() {
1305
- const next = html.dataset.theme === 'dark' ? 'light' : 'dark';
1306
- setUserThemeChoice(next);
1307
- }
1308
-
1309
- themeToggle?.addEventListener('click', (e) => {
1310
- e.preventDefault();
1311
- e.stopPropagation();
1312
- toggleTheme();
1313
- });
1314
-
1315
- themeToggleMobile?.addEventListener('click', (e) => {
1316
- e.preventDefault();
1317
- e.stopPropagation();
1318
- toggleTheme();
1319
- });
1320
-
1321
- // ── Primary nav active-state re-sync ──
1322
- // The header is `transition:persist` (see the comment above <header>), so
1323
- // on a soft navigation within a ClientRouter-enabled page family
1324
- // (/posts/*), this DOM node survives untouched — the freshly-computed
1325
- // active state on the destination page's own server-rendered header never
1326
- // reaches the screen, since that header copy is discarded, not this one.
1327
- // `astro:page-load` fires after every navigation, initial load and every
1328
- // soft transition alike, so re-deriving the active link from the current
1329
- // URL here keeps the persisted header in sync regardless of how it got
1330
- // stale. Same longest-match rule as the server-side computation above
1331
- // (SiteHeader's frontmatter) — ported to run client-side since this is
1332
- // the only copy guaranteed to run on every navigation, including ones the
1333
- // server-rendered version never gets a chance to apply.
1334
- document.addEventListener('astro:page-load', () => {
1335
- const navLinks = Array.from(
1336
- document.querySelectorAll<HTMLAnchorElement>('#site-nav > a.nav-link'),
1337
- );
1338
- if (!navLinks.length) return;
1339
-
1340
- const path = window.location.pathname;
1341
- let bestLink: HTMLAnchorElement | null = null;
1342
- let bestLength = -1;
1343
-
1344
- for (const link of navLinks) {
1345
- const trimmed = (link.getAttribute('href') ?? '').replace(/\/$/, '');
1346
- if (trimmed.length > bestLength && path.startsWith(trimmed)) {
1347
- bestLink = link;
1348
- bestLength = trimmed.length;
1349
- }
1350
- }
1351
-
1352
- for (const link of navLinks) {
1353
- link.classList.toggle('active', link === bestLink);
1354
- }
1355
- });
1356
- </script>
1
+ ---
2
+ /**
3
+ * Site-wide header: brand logo, primary nav (data-driven), About Us mega
4
+ * panel (declarative), Contact CTA, hamburger drawer, theme toggle.
5
+ *
6
+ * Lifted out of `Base.astro` so the layout file is no longer 1700 lines
7
+ * and so a future "edit navbar entries" feature only has to render a
8
+ * different `primaryNav` array. The About Us mega menu stays declarative
9
+ * because it carries icons and a custom panel — easy to extend, hard to
10
+ * shoe-horn into a flat JSON entry until it earns its keep.
11
+ */
12
+ import Button from './Button.astro';
13
+ import type { NavLink, NavGroup, LogoHeader } from '../content/schemas';
14
+
15
+ import { navWithoutCta } from '../lib/nav';
16
+ import { logoHeaderLayout } from '../lib/logo-header';
17
+ import { imageSizeOf } from '../lib/image-sizes';
18
+ interface Props {
19
+ path: string;
20
+ headerClass?: string;
21
+ primaryLogoLight?: string;
22
+ primaryLogoDark?: string;
23
+ /** The logo's size and placement (logoSettings.header). Omitted: a standard logo in the bar. */
24
+ logoHeader?: Partial<LogoHeader>;
25
+ brandAlt: string;
26
+ primaryNav: NavLink[];
27
+ /** Optional dropdown / mega-menu group. Client-configured — the core ships none. */
28
+ dropdown?: NavGroup;
29
+ /** The call-to-action button (navbarSettings.cta); null hides it. */
30
+ cta?: { label: string; href: string } | null;
31
+ /** The members' account link (the site has the Ferst Members module): "Account" in the build,
32
+ * then "Sign in" or the member's first name, from a small script (lib/members). */
33
+ account?: boolean;
34
+ }
35
+
36
+ const { path, headerClass, primaryLogoLight, primaryLogoDark, logoHeader = {}, brandAlt, primaryNav, dropdown, cta = { label: 'Contact', href: '/contact/' }, account = false } = Astro.props;
37
+ // The logo's own size (read from the site's files at build), so its box keeps the image's
38
+ // shape before it loads; and the header's attributes for the logo's size and placement.
39
+ const logoSize = imageSizeOf(primaryLogoLight);
40
+ const logoLayout = logoHeaderLayout({ header: logoHeader, hasLogo: !!primaryLogoLight, size: logoSize });
41
+ // A menu link to the same place as the button would show it twice: the button wins.
42
+ const navLinks = navWithoutCta(primaryNav, cta);
43
+ const ctaActive = !!cta && cta.href.startsWith('/') && path.startsWith(cta.href.replace(/\/$/, '') || '/#');
44
+
45
+ /**
46
+ * Longest-prefix-wins active-nav matching. A plain independent `startsWith`
47
+ * per link (the previous approach) breaks once one link's href is a subpath
48
+ * of another's — e.g. "Newsletters" → /posts/tag/newsletter/ sits under
49
+ * "Posts" → /posts/, so both would light up on a newsletter-tag page.
50
+ * Computing every link's match length up front and keeping only the
51
+ * longest means only the most specific matching link is ever active,
52
+ * however nav hrefs happen to nest.
53
+ */
54
+ const primaryNavMatchLengths = navLinks.map((link) => {
55
+ const trimmed = link.href.replace(/\/$/, '');
56
+ return trimmed.length > 0 && path.startsWith(trimmed) ? trimmed.length : -1;
57
+ });
58
+ const primaryNavLongestMatch = Math.max(-1, ...primaryNavMatchLengths);
59
+ ---
60
+
61
+ <!--
62
+ transition:persist — on pages using Astro's <ClientRouter /> (currently
63
+ /posts/), this keeps the exact same header DOM node across a filter
64
+ click instead of tearing it down and re-inserting a fresh copy. Without
65
+ it: the logo's <script is:inline> and the theme-toggle's <script> (which
66
+ attaches its click listener and calls applyThemeFromStorageOrSystem()) are
67
+ identical on every /posts/ page, so Astro's script-dedup logic skips
68
+ re-running them on the swapped-in copy — the new toggle button ends up
69
+ with no click listener at all, and the logo can flash to a stale value
70
+ before this page's own remaining scripts settle. The "POSTS" nav-link's
71
+ active state (path.startsWith below) is identical across every page in
72
+ this family, so nothing here goes stale by persisting it.
73
+ -->
74
+ <header
75
+ class:list={['site-header', headerClass]}
76
+ {...logoLayout.attributes}
77
+ style={logoLayout.ratio ? `--logo-ratio: ${logoLayout.ratio}` : undefined}
78
+ transition:persist transition:name="site-header" transition:animate="none">
79
+ <a href="/" class="brand">
80
+ {primaryLogoLight ? (
81
+ <img
82
+ id="primary-logo"
83
+ src={primaryLogoLight}
84
+ data-src-light={primaryLogoLight}
85
+ data-src-dark={primaryLogoDark ?? primaryLogoLight}
86
+ alt={brandAlt}
87
+ class="primary-logo"
88
+ width={logoSize?.width}
89
+ height={logoSize?.height}
90
+ loading="eager"
91
+ fetchpriority="high"
92
+ decoding="sync"
93
+ />
94
+ ) : (
95
+ <span class="brand-wordmark">{brandAlt}</span>
96
+ )}
97
+ </a>
98
+ {primaryLogoLight && (
99
+ <script is:inline define:vars={{ primaryLogoDark, primaryLogoLight }}>
100
+ (function () {
101
+ var img = document.getElementById('primary-logo');
102
+ if (!img) return;
103
+ var t = document.documentElement.dataset.theme;
104
+ img.src = t === 'dark' ? (primaryLogoDark || primaryLogoLight) : primaryLogoLight;
105
+ })();
106
+ </script>
107
+ )}
108
+
109
+ <nav class="site-nav" id="site-nav" aria-label="Main navigation">
110
+ {dropdown && (
111
+ <div class="nav-item nav-has-dropdown" data-panel="about">
112
+ <a
113
+ href={dropdown.href}
114
+ class:list={['nav-link', { active: path.startsWith(dropdown.href.replace(/\/$/, '')) }]}
115
+ aria-haspopup="true"
116
+ aria-expanded="false"
117
+ aria-controls="about-submenu"
118
+ >
119
+ {dropdown.label}
120
+ <svg class="nav-chevron" width="10" height="6" viewBox="0 0 10 6" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
121
+ <path d="M1 1L5 5L9 1" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
122
+ </svg>
123
+ </a>
124
+ <ul class="nav-dropdown" id="about-submenu">
125
+ {dropdown.items.map((item) => (
126
+ <li>
127
+ <a href={item.href} class:list={[{ active: path === item.href }]}>
128
+ <span class="drop-text">
129
+ <span class="drop-title">{item.title}</span>
130
+ {item.desc && <span class="drop-desc">{item.desc}</span>}
131
+ </span>
132
+ </a>
133
+ </li>
134
+ ))}
135
+ </ul>
136
+ </div>
137
+ )}
138
+ {/* Primary nav links — data-driven so editing siteSettings.navigation.primary
139
+ adds, reorders, or removes entries without touching the layout.
140
+ Active-state matching uses startsWith on the href to keep policy-style
141
+ subpages highlighting their parent (e.g. /posts/tag/event/), but only
142
+ the longest/most-specific match wins — see primaryNavLongestMatch
143
+ above — so a link whose href is a subpath of another's (Newsletters
144
+ under Posts) doesn't light up both at once. */}
145
+ {navLinks.map((link, i) => {
146
+ const isActive =
147
+ primaryNavMatchLengths[i] >= 0 && primaryNavMatchLengths[i] === primaryNavLongestMatch;
148
+ return (
149
+ <a href={link.href} class:list={['nav-link', { active: isActive }]}>
150
+ {link.label}
151
+ </a>
152
+ );
153
+ })}
154
+ {/* Before paint, the inline script puts back the label this browser last saw (lib/members
155
+ ACCOUNT_LABEL_KEY, rememberedLabel), so the link doesn't flicker. */}
156
+ {account && (<>
157
+ <a href="/account" class:list={['nav-link', 'nav-account', { active: path.startsWith('/account') }]} data-members-account>Sign in</a>
158
+ <script is:inline>
159
+ (function () {
160
+ try {
161
+ var t = localStorage.getItem('ferst:account-label');
162
+ var a = document.currentScript && document.currentScript.previousElementSibling;
163
+ if (a && t && t.trim() && t.length <= 40 && !/[\n\r<>]/.test(t)) a.textContent = t.trim();
164
+ } catch (e) { /* storage off: the build's "Sign in" stands */ }
165
+ })();
166
+ </script>
167
+ </>)}
168
+ <div class="nav-mobile-theme">
169
+ {cta && (
170
+ <Button
171
+ href={cta.href}
172
+ variant="cta"
173
+ class:list={['nav-cta', 'nav-cta--drawer', { active: ctaActive }]}
174
+ >
175
+ {cta.label}
176
+ </Button>
177
+ )}
178
+ <button type="button" class="theme-toggle-mobile" id="theme-toggle-mobile" role="switch" aria-checked="false" aria-label="Toggle dark mode">
179
+ <span class="theme-toggle__highlight" aria-hidden="true"></span>
180
+ <svg class="theme-icon theme-icon--sun" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="4"/><line x1="12" y1="2" x2="12" y2="4"/><line x1="12" y1="20" x2="12" y2="22"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="2" y1="12" x2="4" y2="12"/><line x1="20" y1="12" x2="22" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg>
181
+ <svg class="theme-icon theme-icon--moon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg>
182
+ </button>
183
+ </div>
184
+ </nav>
185
+
186
+ <div class="nav-right">
187
+ <button type="button" class="theme-toggle" id="theme-toggle" role="switch" aria-checked="false" aria-label="Toggle dark mode">
188
+ <span class="theme-toggle__highlight" aria-hidden="true"></span>
189
+ <svg class="theme-icon theme-icon--sun" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="4"/><line x1="12" y1="2" x2="12" y2="4"/><line x1="12" y1="20" x2="12" y2="22"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="2" y1="12" x2="4" y2="12"/><line x1="20" y1="12" x2="22" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg>
190
+ <svg class="theme-icon theme-icon--moon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></svg>
191
+ </button>
192
+ {cta && (
193
+ <span class="nav-cta-header-wrap">
194
+ <Button
195
+ href={cta.href}
196
+ variant="cta"
197
+ class:list={['nav-cta', 'nav-cta--header', { active: ctaActive }]}
198
+ >
199
+ {cta.label}
200
+ </Button>
201
+ </span>
202
+ )}
203
+ <button class="nav-toggle" aria-label="Toggle navigation" aria-expanded="false" aria-controls="site-nav">
204
+ <span></span><span></span><span></span>
205
+ </button>
206
+ </div>
207
+ </header>
208
+
209
+ <div class="mobile-overlay" id="mobile-overlay"></div>
210
+
211
+ <!-- Optional dropdown mega panel (desktop only) — client-configured, core ships none -->
212
+ {dropdown && (
213
+ <div class="mega-nav" id="mega-nav" aria-hidden="true">
214
+ <div class="mega-nav__backdrop" id="mega-backdrop"></div>
215
+
216
+ <div class="mega-panel mega-panel--about" data-panel="about">
217
+ <div class="mega-panel__inner">
218
+ <div class="mega-section-header">
219
+ <h2>{dropdown.label}</h2>
220
+ </div>
221
+ <div class="mega-about-grid">
222
+ {dropdown.items.map((item) => (
223
+ <a href={item.href} class:list={['mega-about-card', { active: path === item.href }]}>
224
+ <span class="mega-about-title">{item.title}</span>
225
+ {item.desc && <span class="mega-about-desc">{item.desc}</span>}
226
+ </a>
227
+ ))}
228
+ </div>
229
+ </div>
230
+ </div>
231
+ </div>
232
+ )}
233
+
234
+ <style is:global>
235
+ /* Header chrome — every selector here used to live in Base.astro's giant
236
+ <style is:global> block. Kept global because dark-mode rules cross the
237
+ boundary between header markup and html[data-theme="dark"]. */
238
+
239
+ .primary-logo {
240
+ height: var(--header-logo-h, 44px);
241
+ width: auto;
242
+ }
243
+
244
+ /* Text wordmark fallback — shown when a client has configured no logo image
245
+ (var(--fg) auto-switches for dark mode via theme.css). */
246
+ .brand-wordmark {
247
+ font-family: var(--font-heading);
248
+ font-weight: 700;
249
+ font-size: 1.25rem;
250
+ line-height: 1;
251
+ color: var(--fg);
252
+ letter-spacing: 0.01em;
253
+ white-space: nowrap;
254
+ }
255
+ @media (min-width: 64em) {
256
+ .brand-wordmark { font-size: 1.5rem; }
257
+ }
258
+
259
+ /* ── Header ── */
260
+ /* Logo + header: mobile-first — compact until desktop ≥64em scales up (matches button/theme sizing). */
261
+ .site-header {
262
+ display: flex;
263
+ align-items: center;
264
+ justify-content: space-between;
265
+ height: 56px;
266
+ padding: 0 1.25rem;
267
+ background: var(--bg-tag);
268
+ position: sticky;
269
+ top: 0;
270
+ z-index: 100;
271
+ isolation: isolate;
272
+ overflow: visible;
273
+ }
274
+ @media (min-width: 64em) {
275
+ .site-header {
276
+ height: 64px;
277
+ padding: 0 28px;
278
+ }
279
+ }
280
+ [data-theme="dark"] .site-header { background: var(--dark-bg); }
281
+
282
+ /* Sticky "shrink on scroll": the header condenses and gains a shadow once the
283
+ page is scrolled, then expands again at the top. Purely additive; safe with
284
+ the sticky positioning. Motion honoured. */
285
+ .site-header {
286
+ transition: height 0.25s ease, min-height 0.25s ease, box-shadow 0.25s ease;
287
+ }
288
+ .site-header.is-compact {
289
+ box-shadow: 0 2px 14px rgba(15, 23, 42, 0.10);
290
+ height: 50px;
291
+ }
292
+ @media (min-width: 64em) {
293
+ .site-header.is-compact { height: 54px; }
294
+ }
295
+ .site-header .primary-logo,
296
+ .site-header .brand-wordmark {
297
+ transition: height 0.25s ease, font-size 0.25s ease;
298
+ }
299
+ .site-header.is-compact .primary-logo { height: 38px; }
300
+ .site-header.is-compact .brand-wordmark { font-size: 1.15rem; }
301
+ @media (prefers-reduced-motion: reduce) {
302
+ .site-header,
303
+ .site-header .primary-logo,
304
+ .site-header .brand-wordmark { transition: none; }
305
+ }
306
+ .brand {
307
+ text-decoration: none;
308
+ display: flex;
309
+ align-items: center;
310
+ gap: 12px;
311
+ min-width: 0;
312
+ flex-shrink: 1;
313
+ }
314
+ .brand:focus-visible {
315
+ outline: 2px solid var(--gold);
316
+ outline-offset: 3px;
317
+ border-radius: 4px;
318
+ }
319
+ @media (min-width: 64em) {
320
+ .brand { gap: 16px; }
321
+ }
322
+ .primary-logo {
323
+ flex-shrink: 0;
324
+ display: block;
325
+ height: 44px;
326
+ width: auto;
327
+ max-width: 100%;
328
+ object-fit: contain;
329
+ }
330
+
331
+ /* ── The logo's size and placement (logoSettings.header) ──
332
+ --header-logo-h: the logo's height at the top of the page, by size and screen width.
333
+ --header-bar-h: the bar's own height (the bar never grows for an overhanging logo).
334
+ A larger logo set `inline` grows the bar on desktops only; phones and tablets keep the
335
+ standard logo. Set `overhang`, it grows on every screen, in smaller steps on small ones. */
336
+ :root { --header-logo-h: 44px; --header-bar-h: 60px; --header-logo-inset: 6px; }
337
+ @media (min-width: 48em) { :root { --header-logo-h: 48px; --header-bar-h: 56px; } }
338
+ @media (min-width: 64em) { :root { --header-logo-h: 56px; --header-bar-h: 64px; --header-logo-inset: 8px; } }
339
+ :root:has(.site-header[data-logo-size='large'][data-logo-placement='overhang']) { --header-logo-h: 64px; }
340
+ :root:has(.site-header[data-logo-size='xl'][data-logo-placement='overhang']) { --header-logo-h: 88px; }
341
+ @media (min-width: 48em) {
342
+ :root:has(.site-header[data-logo-size='large'][data-logo-placement='overhang']) { --header-logo-h: 88px; }
343
+ :root:has(.site-header[data-logo-size='xl'][data-logo-placement='overhang']) { --header-logo-h: 152px; }
344
+ }
345
+ @media (min-width: 64em) {
346
+ :root:has(.site-header[data-logo-size='large']),
347
+ :root:has(.site-header[data-logo-size='large'][data-logo-placement='overhang']) { --header-logo-h: 112px; }
348
+ :root:has(.site-header[data-logo-size='xl']),
349
+ :root:has(.site-header[data-logo-size='xl'][data-logo-placement='overhang']) { --header-logo-h: 216px; }
350
+ .site-header[data-logo-size]:not([data-logo-placement]):not(.is-compact) {
351
+ min-height: calc(var(--header-logo-h) + 16px);
352
+ }
353
+ }
354
+ /* How far the logo hangs below the bar at the top of the page: the page's first words
355
+ keep clear of it (Base, Hero). */
356
+ :root:has(.site-header[data-logo-placement='overhang']) {
357
+ --logo-overhang: max(0px, calc(var(--header-logo-h) + var(--header-logo-inset) - var(--header-bar-h)));
358
+ }
359
+
360
+ /* Overhang: pinned to the top of the bar with a small inset, hanging below it over the
361
+ opener. The brand keeps the logo's width in the bar, so the menu and buttons keep their
362
+ space. Above the page, under the open menus (the drawer and the dropdown panel). */
363
+ .site-header[data-logo-placement='overhang'] { --logo-now: var(--header-logo-h); }
364
+ .site-header[data-logo-placement='overhang'] .brand {
365
+ position: relative;
366
+ z-index: 1;
367
+ align-self: stretch;
368
+ flex-shrink: 0;
369
+ width: calc(var(--logo-now) * var(--logo-ratio, 1));
370
+ transition: width 0.25s ease;
371
+ }
372
+ .site-header[data-logo-placement='overhang'] .primary-logo {
373
+ position: absolute;
374
+ left: 0;
375
+ top: var(--header-logo-inset);
376
+ height: var(--logo-now);
377
+ width: auto;
378
+ max-width: none;
379
+ transition: height 0.25s ease, top 0.25s ease;
380
+ }
381
+ /* Scrolled down (unless the site keeps it hanging), or a menu open: back inside the bar,
382
+ at the small size, so it never covers what the visitor is reading. */
383
+ .site-header[data-logo-placement='overhang'].is-compact:not([data-logo-hang]),
384
+ .site-header[data-logo-placement='overhang'].is-menu-open { --logo-now: 38px; }
385
+ .site-header[data-logo-placement='overhang'].is-compact:not([data-logo-hang]) .primary-logo,
386
+ .site-header[data-logo-placement='overhang'].is-menu-open .primary-logo {
387
+ top: calc(50% - var(--logo-now) / 2);
388
+ }
389
+ /* A soft shadow, so a dark round badge stands apart from a dark header. */
390
+ .site-header[data-logo-shadow] .primary-logo {
391
+ filter: drop-shadow(var(--shadow-logo));
392
+ }
393
+ @media (prefers-reduced-motion: reduce) {
394
+ .site-header[data-logo-placement='overhang'] .brand,
395
+ .site-header[data-logo-placement='overhang'] .primary-logo { transition: none; }
396
+ }
397
+
398
+ /* ── Center nav ── */
399
+ .site-nav {
400
+ display: flex;
401
+ align-items: center;
402
+ gap: 28px;
403
+ position: absolute;
404
+ left: 50%;
405
+ transform: translateX(-50%);
406
+ }
407
+ .nav-link {
408
+ position: relative;
409
+ display: inline-flex;
410
+ align-items: center;
411
+ padding: 14px 0;
412
+ color: var(--accent);
413
+ text-decoration: none;
414
+ font-family: var(--font-body);
415
+ font-size: 0.875rem;
416
+ font-weight: 500;
417
+ letter-spacing: 0.1em;
418
+ text-transform: uppercase;
419
+ transition: color 0.25s ease;
420
+ }
421
+ .nav-link::after {
422
+ content: '';
423
+ position: absolute;
424
+ bottom: 4px;
425
+ left: 0;
426
+ right: 0;
427
+ height: 2px;
428
+ background: var(--gold);
429
+ transform: scaleX(0);
430
+ transition: transform 0.2s ease;
431
+ border-radius: 1px;
432
+ }
433
+ .nav-link:hover { color: var(--gold); }
434
+ .nav-link:focus-visible {
435
+ outline: 2px solid var(--gold);
436
+ outline-offset: 3px;
437
+ border-radius: 2px;
438
+ }
439
+ .nav-link.active {
440
+ color: var(--gold);
441
+ font-weight: 500;
442
+ }
443
+ .nav-link.active::after { display: none; }
444
+ .nav-item.panel-active > .nav-link::after { display: none; }
445
+ [data-theme="dark"] .nav-link { color: var(--text-light); }
446
+ [data-theme="dark"] .nav-link:hover { color: var(--gold); }
447
+ [data-theme="dark"] .nav-link.active { color: var(--gold); }
448
+ [data-theme="dark"] .nav-toggle span { background: var(--text-light); }
449
+
450
+ /* ── Right side ── */
451
+ .nav-right {
452
+ display: flex;
453
+ align-items: center;
454
+ gap: 12px;
455
+ flex-shrink: 0;
456
+ position: relative;
457
+ z-index: 101; /* always above the mobile full-screen nav (z-index: 99) */
458
+ }
459
+
460
+ /* Crowded (#11, set by measuring): the centred menu would collide with the site name or
461
+ the buttons, so it takes its own row under them and wraps if it must. Desktop only;
462
+ below 64em the drawer applies as usual. */
463
+ @media (min-width: 64em) {
464
+ .site-header.is-crowded,
465
+ .site-header.is-crowded.is-compact {
466
+ height: auto;
467
+ flex-wrap: wrap;
468
+ row-gap: 0;
469
+ padding-block: 6px;
470
+ }
471
+ .site-header.is-crowded .site-nav {
472
+ position: static;
473
+ transform: none;
474
+ order: 3;
475
+ flex-basis: 100%;
476
+ justify-content: center;
477
+ flex-wrap: wrap;
478
+ column-gap: 24px;
479
+ row-gap: 0;
480
+ }
481
+ .site-header.is-crowded .site-nav .nav-link {
482
+ padding-block: 8px;
483
+ }
484
+ /* A hanging logo reaches down past the first row: the menu's own row starts beside it. */
485
+ .site-header.is-crowded[data-logo-placement='overhang'] .site-nav {
486
+ padding-inline-start: calc(var(--logo-now) * var(--logo-ratio, 1) + 16px);
487
+ }
488
+ }
489
+
490
+ /* ── Contact CTA ── */
491
+ .nav-cta {
492
+ white-space: nowrap;
493
+ }
494
+ .nav-cta:hover,
495
+ .nav-cta.active { background: color-mix(in srgb, var(--gold) 85%, #000); color: var(--on-brand); border: none; }
496
+ [data-theme="dark"] .nav-cta { background: var(--gold); color: var(--dark-bg); border: none; }
497
+ [data-theme="dark"] .nav-cta:hover,
498
+ [data-theme="dark"] .nav-cta.active { background: color-mix(in srgb, var(--gold) 85%, #fff); color: var(--dark-bg); border: none; }
499
+
500
+ .nav-mobile-theme .nav-cta--drawer {
501
+ display: none;
502
+ }
503
+ @media (min-width: 64em) {
504
+ .nav-mobile-theme .btn.nav-cta--drawer,
505
+ .nav-mobile-theme a.nav-cta--drawer {
506
+ display: none !important;
507
+ }
508
+ }
509
+
510
+ /* ── Theme toggle: segmented sun/moon switch, shared by the desktop
511
+ button and the mobile drawer button. Both icons stay in the DOM at all
512
+ times, pinned to either side; a gold highlight slides behind whichever
513
+ one is active. --overlay-accent-08/-18 already resolve to the dark-mode
514
+ white-tinted values via the [data-theme="dark"] root override in
515
+ theme.css, so no manual dark-mode override is needed for the track
516
+ itself. */
517
+ .theme-toggle,
518
+ .theme-toggle-mobile {
519
+ position: relative;
520
+ display: inline-flex;
521
+ align-items: center;
522
+ justify-content: space-around;
523
+ width: 64px;
524
+ height: 30px;
525
+ padding: 3px;
526
+ background: var(--overlay-accent-08);
527
+ border: 1px solid var(--overlay-accent-18);
528
+ border-radius: 999px;
529
+ cursor: pointer;
530
+ flex-shrink: 0;
531
+ transition:
532
+ background-color 0.35s cubic-bezier(0.4, 0, 0.2, 1),
533
+ border-color 0.35s cubic-bezier(0.4, 0, 0.2, 1);
534
+ }
535
+ .theme-toggle:hover,
536
+ .theme-toggle-mobile:hover {
537
+ border-color: var(--gold);
538
+ }
539
+ .theme-toggle:focus-visible,
540
+ .theme-toggle-mobile:focus-visible {
541
+ outline: 2px solid var(--gold);
542
+ outline-offset: 2px;
543
+ }
544
+
545
+ .theme-toggle__highlight {
546
+ position: absolute;
547
+ top: 3px;
548
+ left: 3px;
549
+ width: calc(50% - 3px);
550
+ height: calc(100% - 6px);
551
+ border-radius: 999px;
552
+ background: var(--gold);
553
+ transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
554
+ }
555
+ [data-theme="dark"] .theme-toggle__highlight { transform: translateX(100%); }
556
+
557
+ .theme-icon {
558
+ position: relative;
559
+ z-index: 1;
560
+ width: 14px;
561
+ height: 14px;
562
+ color: var(--fg);
563
+ opacity: 0.5;
564
+ transition: opacity 0.3s ease, color 0.3s ease;
565
+ }
566
+ .theme-icon--sun { opacity: 1; }
567
+ [data-theme="dark"] .theme-icon--sun { opacity: 0.5; }
568
+ [data-theme="dark"] .theme-icon--moon { opacity: 1; color: var(--dark-bg); }
569
+
570
+ /* Mobile theme toggle row — hidden on desktop */
571
+ .nav-mobile-theme { display: none; }
572
+
573
+ /* ── Hamburger ── */
574
+ .nav-toggle {
575
+ display: none;
576
+ flex-direction: column;
577
+ justify-content: center;
578
+ align-items: center;
579
+ width: 44px;
580
+ height: 44px;
581
+ padding: 0;
582
+ background: none;
583
+ border: none;
584
+ cursor: pointer;
585
+ border-radius: 8px;
586
+ transition: background 0.15s;
587
+ position: relative;
588
+ }
589
+ .nav-toggle:hover { background: var(--overlay-white-08); }
590
+ .nav-toggle span {
591
+ display: block;
592
+ position: absolute;
593
+ width: 22px;
594
+ height: 2px;
595
+ background: var(--fg);
596
+ border-radius: 2px;
597
+ transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, top 0.3s cubic-bezier(0.4, 0, 0.2, 1);
598
+ transform-origin: center;
599
+ }
600
+ .nav-toggle span:nth-child(1) { top: 13px; }
601
+ .nav-toggle span:nth-child(2) { top: 19px; }
602
+ .nav-toggle span:nth-child(3) { top: 25px; }
603
+ .nav-toggle.open span:nth-child(1) { top: 19px; transform: rotate(45deg); }
604
+ .nav-toggle.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
605
+ .nav-toggle.open span:nth-child(3) { top: 19px; transform: rotate(-45deg); }
606
+
607
+ /* ── Mega nav system (tablet/desktop, not phone overlay) ── */
608
+ .mega-nav {
609
+ display: none;
610
+ position: fixed;
611
+ top: 56px;
612
+ left: 0;
613
+ right: 0;
614
+ z-index: 98;
615
+ pointer-events: none;
616
+ }
617
+ .mega-nav.is-open {
618
+ display: block;
619
+ pointer-events: auto;
620
+ }
621
+ .mega-nav__backdrop {
622
+ position: fixed;
623
+ inset: 0;
624
+ top: 56px;
625
+ background: rgba(0,0,0,0.45);
626
+ z-index: -1;
627
+ animation: backdropIn 0.2s ease forwards;
628
+ }
629
+ @media (min-width: 64em) {
630
+ .mega-nav,
631
+ .mega-nav__backdrop {
632
+ top: var(--mega-top, 64px);
633
+ }
634
+ }
635
+ @media (max-width: 47.9375em) {
636
+ .mega-nav,
637
+ .mega-nav__backdrop {
638
+ top: 60px;
639
+ }
640
+ }
641
+ @keyframes backdropIn {
642
+ from { opacity: 0; }
643
+ to { opacity: 1; }
644
+ }
645
+
646
+ .mega-panel {
647
+ display: none;
648
+ }
649
+ .mega-nav.is-open .mega-panel {
650
+ display: block;
651
+ animation: panelIn 0.18s ease forwards;
652
+ }
653
+ .mega-panel--about {
654
+ background: var(--bg);
655
+ box-shadow: 0 16px 48px rgba(0,0,0,0.4);
656
+ }
657
+
658
+ @keyframes panelIn {
659
+ from { opacity: 0; transform: translateY(-6px); }
660
+ to { opacity: 1; transform: translateY(0); }
661
+ }
662
+
663
+ .mega-panel__inner {
664
+ max-width: 1100px;
665
+ margin: 0 auto;
666
+ padding: 2rem 2.5rem;
667
+ }
668
+
669
+ .mega-section-header {
670
+ display: flex;
671
+ align-items: baseline;
672
+ justify-content: space-between;
673
+ margin-bottom: 1.25rem;
674
+ padding-bottom: 0.75rem;
675
+ }
676
+ .mega-section-header h2 {
677
+ margin: 0;
678
+ font-size: 1rem;
679
+ color: var(--accent);
680
+ font-family: var(--font-heading);
681
+ font-weight: 600;
682
+ letter-spacing: 0.04em;
683
+ }
684
+ [data-theme="dark"] .mega-section-header h2 { color: var(--text-light); }
685
+ .mega-about-grid {
686
+ display: grid;
687
+ grid-template-columns: repeat(5, 1fr);
688
+ gap: 0.85rem;
689
+ }
690
+ .mega-about-card {
691
+ display: flex;
692
+ flex-direction: column;
693
+ align-items: flex-start;
694
+ gap: 6px;
695
+ padding: 1rem 1.1rem;
696
+ background: rgba(200,151,58,0.1);
697
+ border: 1px solid rgba(200,151,58,0.35);
698
+ border-radius: 10px;
699
+ text-decoration: none;
700
+ transition: background 0.15s, border-color 0.15s, transform 0.15s;
701
+ }
702
+ .mega-about-card:hover {
703
+ background: rgba(200,151,58,0.1);
704
+ border-color: rgba(200,151,58,0.35);
705
+ transform: translateY(-2px);
706
+ }
707
+ .mega-about-card:focus-visible {
708
+ outline: 2px solid var(--gold);
709
+ outline-offset: 2px;
710
+ }
711
+ .mega-about-card:hover .mega-about-title { color: var(--gold); }
712
+ [data-theme="dark"] .mega-about-card { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.07); }
713
+ [data-theme="dark"] .mega-about-card:hover { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.07); transform: translateY(-2px); }
714
+ .mega-about-card.active,
715
+ .mega-about-card.active:hover {
716
+ background: rgba(200,151,58,0.12);
717
+ border-color: rgba(200,151,58,0.45);
718
+ }
719
+ /* [data-theme="dark"] .mega-about-card:hover above has higher specificity
720
+ (attribute selector + class + pseudo-class) than .mega-about-card.active
721
+ (two classes), so without this it would win and flatten the active card
722
+ back to the plain hover look. Matching specificity + declared after it
723
+ keeps the active highlight showing through hover in dark mode too. */
724
+ [data-theme="dark"] .mega-about-card.active,
725
+ [data-theme="dark"] .mega-about-card.active:hover {
726
+ background: rgba(200,151,58,0.12);
727
+ border-color: rgba(200,151,58,0.45);
728
+ }
729
+ .mega-about-card.active .mega-about-title { color: var(--gold); }
730
+ .mega-about-card.active .mega-about-icon { background: rgba(200,151,58,0.25); }
731
+ .mega-about-icon {
732
+ width: 42px;
733
+ height: 42px;
734
+ background: rgba(200,151,58,0.12);
735
+ border-radius: 8px;
736
+ display: flex;
737
+ align-items: center;
738
+ justify-content: center;
739
+ color: var(--gold);
740
+ margin-bottom: 2px;
741
+ }
742
+ .mega-about-title {
743
+ font-size: 0.875rem;
744
+ font-weight: 600;
745
+ color: var(--accent);
746
+ font-family: var(--font-body);
747
+ line-height: 1.3;
748
+ transition: color 0.15s;
749
+ }
750
+ [data-theme="dark"] .mega-about-title { color: var(--text-light); }
751
+ .mega-about-desc {
752
+ font-size: 0.75rem;
753
+ color: var(--accent);
754
+ font-weight: 500;
755
+ font-family: var(--font-body);
756
+ line-height: 1.4;
757
+ }
758
+ .mega-about-sub {
759
+ font-size: 0.8rem;
760
+ color: var(--accent);
761
+ font-weight: 500;
762
+ font-family: var(--font-body);
763
+ }
764
+ [data-theme="dark"] .mega-about-desc,
765
+ [data-theme="dark"] .mega-about-sub {
766
+ color: var(--muted);
767
+ font-weight: 400;
768
+ }
769
+
770
+ .mega-empty {
771
+ color: var(--text-subtle);
772
+ font-size: 0.9rem;
773
+ font-style: italic;
774
+ }
775
+
776
+ /* Hide mega nav whenever hamburger / drawer nav is used (≤1023px) */
777
+ @media (max-width: 63.9375em) {
778
+ .mega-nav { display: none !important; }
779
+ }
780
+
781
+ /* Desktop only: hide flyout dropdown (replaced by mega panel) */
782
+ @media (min-width: 64em) {
783
+ .nav-dropdown { display: none; }
784
+ }
785
+
786
+ /* ── About dropdown (mega-menu style, mobile only) ── */
787
+ .nav-item { position: relative; display: flex; align-items: center; }
788
+ .nav-chevron {
789
+ display: inline-block;
790
+ vertical-align: middle;
791
+ margin-left: 3px;
792
+ transform: rotate(0deg);
793
+ transition: transform 0.2s ease;
794
+ }
795
+ .nav-item.open .nav-chevron,
796
+ .nav-item.panel-active .nav-chevron { transform: rotate(180deg); }
797
+
798
+ .nav-dropdown {
799
+ display: none;
800
+ position: absolute;
801
+ top: calc(100% + 12px);
802
+ left: 50%;
803
+ transform: translateX(-50%);
804
+ min-width: 280px;
805
+ background: var(--bg-surface);
806
+ border: 1px solid var(--border);
807
+ border-top: 2px solid var(--gold);
808
+ border-radius: 0 0 10px 10px;
809
+ box-shadow: 0 12px 32px rgba(0,0,0,0.35);
810
+ list-style: none;
811
+ padding: 0.35rem 0;
812
+ margin: 0;
813
+ z-index: 200;
814
+ }
815
+ .nav-item.open .nav-dropdown { display: block; }
816
+
817
+ .nav-dropdown li a {
818
+ display: flex;
819
+ align-items: center;
820
+ gap: 12px;
821
+ padding: 0.65rem 1.1rem;
822
+ color: var(--muted);
823
+ text-decoration: none;
824
+ transition: background 0.12s, color 0.12s;
825
+ border-radius: 0;
826
+ }
827
+ .nav-dropdown li a:hover {
828
+ background: rgba(200,151,58,0.1);
829
+ color: var(--fg);
830
+ }
831
+ .nav-dropdown li a:focus-visible {
832
+ outline: 2px solid var(--gold);
833
+ outline-offset: -2px;
834
+ }
835
+ .nav-dropdown li a:hover .drop-title { color: var(--gold); }
836
+ .nav-dropdown li a.active { color: var(--fg); }
837
+ .nav-dropdown li a.active .drop-title { color: var(--gold); }
838
+ .nav-dropdown li a.active .drop-icon { background: rgba(200,151,58,0.25); }
839
+ .nav-dropdown li + li {
840
+ border-top: 1px solid rgba(255,255,255,0.05);
841
+ }
842
+
843
+ .drop-icon {
844
+ flex-shrink: 0;
845
+ width: 32px;
846
+ height: 32px;
847
+ display: flex;
848
+ align-items: center;
849
+ justify-content: center;
850
+ background: rgba(200,151,58,0.12);
851
+ border-radius: 6px;
852
+ color: var(--gold);
853
+ }
854
+
855
+ .drop-text {
856
+ display: flex;
857
+ flex-direction: column;
858
+ gap: 1px;
859
+ }
860
+
861
+ .drop-title {
862
+ font-family: var(--font-body);
863
+ font-size: 0.8125rem;
864
+ font-weight: 600;
865
+ color: var(--text-light);
866
+ line-height: 1.3;
867
+ transition: color 0.12s;
868
+ }
869
+
870
+ .drop-desc {
871
+ font-family: var(--font-body);
872
+ font-size: 0.6875rem;
873
+ color: var(--text-subtle);
874
+ line-height: 1.3;
875
+ }
876
+
877
+ /* ── Tablet md: 768px+ ── */
878
+ @media (min-width: 48em) {
879
+ .site-header { padding: 0 2.5rem; }
880
+ }
881
+
882
+ /* ── Mobile overlay backdrop ── */
883
+ .mobile-overlay {
884
+ position: fixed;
885
+ inset: 0;
886
+ background: rgba(0,0,0,0.5);
887
+ z-index: 98;
888
+ opacity: 0;
889
+ visibility: hidden;
890
+ transition: opacity 0.22s ease, visibility 0.22s ease;
891
+ pointer-events: none;
892
+ }
893
+ .mobile-overlay.visible {
894
+ opacity: 1;
895
+ visibility: visible;
896
+ pointer-events: auto;
897
+ }
898
+
899
+ /* ── Hamburger + slide-out nav (≤1023px) ── */
900
+ @media (max-width: 63.9375em) {
901
+ .nav-toggle { display: flex; }
902
+ .nav-cta-header-wrap { display: none; }
903
+ .nav-right .theme-toggle { display: none; }
904
+
905
+ .site-nav {
906
+ display: flex;
907
+ flex-direction: column;
908
+ align-items: stretch;
909
+ position: fixed;
910
+ top: 56px;
911
+ left: 0;
912
+ right: 0;
913
+ bottom: 0;
914
+ width: 100%;
915
+ transform: none;
916
+ background: var(--bg-tag);
917
+ border-top: 1px solid rgba(44,59,42,0.10);
918
+ padding: 2rem 0 2rem;
919
+ gap: 0;
920
+ overflow-y: auto;
921
+ overflow-x: hidden;
922
+ pointer-events: none;
923
+ opacity: 0;
924
+ visibility: hidden;
925
+ transition: opacity 0.22s ease, visibility 0.22s ease;
926
+ z-index: 99;
927
+ justify-content: flex-start;
928
+ }
929
+ [data-theme="dark"] .site-nav { background: var(--dark-bg); border-top-color: rgba(255,255,255,0.10); }
930
+ .site-nav.open {
931
+ opacity: 1;
932
+ visibility: visible;
933
+ pointer-events: auto;
934
+ }
935
+
936
+ .nav-link {
937
+ display: flex;
938
+ align-items: center;
939
+ justify-content: flex-start;
940
+ position: relative;
941
+ gap: 0;
942
+ padding: 1rem 3rem;
943
+ font-size: 0.9375rem;
944
+ font-weight: 300;
945
+ font-family: var(--font-heading);
946
+ border-radius: 0;
947
+ text-align: left;
948
+ width: 100%;
949
+ color: var(--fg);
950
+ transition: color 0.18s ease;
951
+ }
952
+ .nav-link::before {
953
+ content: '';
954
+ position: absolute;
955
+ bottom: 0;
956
+ left: 3rem;
957
+ right: 0;
958
+ height: 1px;
959
+ background: rgba(255,255,255,0.08);
960
+ }
961
+ /* Last link (Calendar) sits directly above .nav-mobile-theme's own
962
+ border-top — drop its trailing divider so the two don't double up. */
963
+ .site-nav > .nav-link:last-of-type::before { display: none; }
964
+ .nav-link:hover { color: var(--gold); background: none; }
965
+ .nav-link::after { display: none; }
966
+ .nav-link.active { color: var(--gold); font-weight: 400; }
967
+
968
+ .nav-mobile-theme {
969
+ display: flex;
970
+ justify-content: flex-end;
971
+ align-items: center;
972
+ padding: 1rem 1.5rem;
973
+ border-top: 1px solid var(--border);
974
+ margin-top: 0.5rem;
975
+ }
976
+
977
+ .nav-item { width: 100%; flex-direction: column; align-items: stretch; }
978
+ .nav-item .nav-link {
979
+ width: 100%;
980
+ display: flex;
981
+ justify-content: flex-start;
982
+ align-items: center;
983
+ }
984
+ .nav-item .nav-chevron { margin-left: auto; }
985
+ .nav-dropdown {
986
+ position: static;
987
+ transform: none;
988
+ display: block;
989
+ width: 100%;
990
+ background: transparent;
991
+ border: none;
992
+ border-radius: 0;
993
+ box-shadow: none;
994
+ min-width: 0;
995
+ max-height: 0;
996
+ overflow: hidden;
997
+ padding: 0;
998
+ transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease;
999
+ }
1000
+ .nav-item.open .nav-dropdown {
1001
+ max-height: min(70vh, 560px);
1002
+ max-height: min(70dvh, 560px);
1003
+ padding: 0.35rem 0;
1004
+ }
1005
+ .nav-dropdown li a {
1006
+ padding: 0.6rem 1.5rem 0.6rem 3rem;
1007
+ gap: 10px;
1008
+ justify-content: flex-start;
1009
+ font-size: 0.8rem;
1010
+ color: var(--fg);
1011
+ transition: color 0.18s ease;
1012
+ }
1013
+ .nav-dropdown li a:hover { color: var(--gold); background: none; }
1014
+ .drop-icon { width: 24px; height: 24px; flex-shrink: 0; transition: color 0.18s ease; }
1015
+ .drop-title { font-size: 0.75rem; color: var(--fg); transition: color 0.18s ease; }
1016
+ [data-theme="dark"] .nav-dropdown li a { color: rgba(250,246,239,0.75); }
1017
+ [data-theme="dark"] .nav-dropdown li a:hover,
1018
+ [data-theme="dark"] .nav-dropdown li a:active { color: var(--gold); }
1019
+ [data-theme="dark"] .nav-dropdown li a:hover .drop-title,
1020
+ [data-theme="dark"] .nav-dropdown li a:active .drop-title { color: var(--gold); }
1021
+ [data-theme="dark"] .nav-dropdown li a:hover .drop-icon,
1022
+ [data-theme="dark"] .nav-dropdown li a:active .drop-icon { color: var(--gold); }
1023
+ [data-theme="dark"] .drop-title { color: rgba(250,246,239,0.9); }
1024
+ .drop-desc { display: none; }
1025
+ .nav-dropdown li + li { border-top: 1px solid rgba(255,255,255,0.04); }
1026
+
1027
+ .site-nav .nav-mobile-theme .btn.nav-cta--drawer,
1028
+ .site-nav .nav-mobile-theme a.nav-cta--drawer {
1029
+ display: inline-flex !important;
1030
+ }
1031
+ .site-nav .nav-mobile-theme {
1032
+ justify-content: space-between;
1033
+ align-items: center;
1034
+ gap: 0.75rem;
1035
+ }
1036
+ .site-nav .nav-mobile-theme .nav-cta--drawer {
1037
+ flex: 1 1 auto;
1038
+ min-width: 0;
1039
+ max-width: calc(100% - 3.25rem);
1040
+ justify-content: center;
1041
+ }
1042
+ }
1043
+
1044
+ /* ── Phone only: shorter header (≤767px) ── */
1045
+ @media (max-width: 47.9375em) {
1046
+ .site-nav { top: 60px; }
1047
+ .site-header { padding: 0 1.25rem; height: 60px; }
1048
+ .brand { gap: 10px; }
1049
+ }
1050
+ </style>
1051
+
1052
+ <script>
1053
+ // The members' account link, on a site with Members: "Sign in", or the member's first name
1054
+ // (lib/members), remembered for the next page so it doesn't flicker. Without the link it does nothing.
1055
+ import { MEMBERS_ME, accountLinkText, readMembersAnswer, rememberAccountLabel } from '../lib/members';
1056
+ const accountLink = document.querySelector<HTMLAnchorElement>('[data-members-account]');
1057
+ if (accountLink) {
1058
+ fetch(MEMBERS_ME, { credentials: 'same-origin', headers: { Accept: 'application/json' } })
1059
+ .then(readMembersAnswer)
1060
+ .then((answer) => {
1061
+ const text = accountLinkText(answer);
1062
+ if (!text) return;
1063
+ if (accountLink.textContent !== text) accountLink.textContent = text;
1064
+ rememberAccountLabel(text);
1065
+ })
1066
+ .catch(() => { /* what's shown stands */ });
1067
+ }
1068
+ </script>
1069
+
1070
+ <script>
1071
+ // ── Hamburger (mobile) ──
1072
+ const toggle = document.querySelector('.nav-toggle') as HTMLButtonElement;
1073
+ const nav = document.querySelector('#site-nav') as HTMLElement;
1074
+ const megaNav = document.getElementById('mega-nav') as HTMLElement;
1075
+ const aboutTrigger = document.querySelector('.nav-has-dropdown') as HTMLElement;
1076
+ const aboutLink = aboutTrigger?.querySelector('.nav-link') as HTMLAnchorElement;
1077
+ const mobileOverlay = document.getElementById('mobile-overlay') as HTMLElement;
1078
+
1079
+ let scrollY = 0;
1080
+
1081
+ function openNav() {
1082
+ scrollY = window.scrollY;
1083
+ document.body.style.position = 'fixed';
1084
+ document.body.style.top = `-${scrollY}px`;
1085
+ document.body.style.width = '100%';
1086
+ nav.classList.add('open');
1087
+ toggle.classList.add('open');
1088
+ siteHeader?.classList.add('is-menu-open');
1089
+ mobileOverlay.classList.add('visible');
1090
+ toggle.setAttribute('aria-expanded', 'true');
1091
+ }
1092
+
1093
+ function closeNav() {
1094
+ const wasFixed = document.body.style.position === 'fixed';
1095
+ document.body.style.position = '';
1096
+ document.body.style.top = '';
1097
+ document.body.style.width = '';
1098
+ if (wasFixed) window.scrollTo(0, scrollY);
1099
+ nav.classList.remove('open');
1100
+ toggle.classList.remove('open');
1101
+ siteHeader?.classList.remove('is-menu-open');
1102
+ mobileOverlay.classList.remove('visible');
1103
+ toggle.setAttribute('aria-expanded', 'false');
1104
+ aboutTrigger?.classList.remove('open');
1105
+ aboutLink?.setAttribute('aria-expanded', 'false');
1106
+ }
1107
+
1108
+ toggle.addEventListener('click', () => {
1109
+ nav.classList.contains('open') ? closeNav() : openNav();
1110
+ });
1111
+
1112
+ mobileOverlay?.addEventListener('click', closeNav);
1113
+
1114
+ document.addEventListener('click', e => {
1115
+ const target = e.target as HTMLElement;
1116
+ if (!target.closest('.site-header') && !target.closest('#mobile-overlay')) {
1117
+ closeNav();
1118
+ }
1119
+ });
1120
+
1121
+ // Close the drawer when a real link inside it is clicked. This used to be
1122
+ // an accidental side effect of navigation always hard-reloading the page
1123
+ // (nav starts closed on a fresh load) — now that the header persists
1124
+ // across Astro's <ClientRouter /> transitions (see /posts/), that DOM
1125
+ // node's "open" state carries over untouched too, so it needs an explicit
1126
+ // close here. Skip the "About Us" trigger: on mobile that link expands the
1127
+ // submenu in place (preventDefault below) instead of navigating away.
1128
+ nav.addEventListener('click', e => {
1129
+ const link = (e.target as HTMLElement).closest('a[href]');
1130
+ if (!link || link.getAttribute('aria-haspopup') === 'true') return;
1131
+ closeNav();
1132
+ });
1133
+
1134
+ const siteHeader = document.querySelector('.site-header') as HTMLElement | null;
1135
+
1136
+ // Shrink-on-scroll: condense the header once the page is scrolled.
1137
+ if (siteHeader) {
1138
+ const onScrollCompact = () => siteHeader.classList.toggle('is-compact', window.scrollY > 40);
1139
+ onScrollCompact();
1140
+ window.addEventListener('scroll', onScrollCompact, { passive: true });
1141
+ }
1142
+
1143
+ // The header's full height, published as --header-h on <html> so a full-screen opener
1144
+ // fills the screen BELOW the sticky header (Hero size "screen"). Only the full-size header
1145
+ // counts: while it's condensed on scroll, or animating between sizes, the last full value
1146
+ // stays, so the opener never resizes as the page scrolls.
1147
+ let headerAnimating = false;
1148
+ function syncHeaderHeight() {
1149
+ if (!siteHeader || headerAnimating || siteHeader.classList.contains('is-compact')) return;
1150
+ document.documentElement.style.setProperty('--header-h', `${siteHeader.getBoundingClientRect().height}px`);
1151
+ }
1152
+ if (siteHeader) {
1153
+ siteHeader.addEventListener('transitionrun', (e) => {
1154
+ if (e.target === siteHeader && (e.propertyName === 'height' || e.propertyName === 'min-height')) headerAnimating = true;
1155
+ });
1156
+ const settled = (e: TransitionEvent) => {
1157
+ if (e.target !== siteHeader || (e.propertyName !== 'height' && e.propertyName !== 'min-height')) return;
1158
+ headerAnimating = false;
1159
+ syncHeaderHeight();
1160
+ };
1161
+ siteHeader.addEventListener('transitionend', settled);
1162
+ siteHeader.addEventListener('transitioncancel', settled);
1163
+ // The first value is published below, once the crowding check has settled the layout.
1164
+ }
1165
+
1166
+ // Crowding (#11): on desktop the menu is centred on the header. When the site name (or
1167
+ // the right-hand buttons) would run into it, give the menu its own row instead. Decided
1168
+ // by measuring the real layout, so it adapts to any name and any number of links.
1169
+ if (siteHeader) {
1170
+ const desktop = window.matchMedia('(min-width: 64em)');
1171
+ const brand = siteHeader.querySelector<HTMLElement>('.brand');
1172
+ const nav = siteHeader.querySelector<HTMLElement>('.site-nav');
1173
+ const right = siteHeader.querySelector<HTMLElement>('.nav-right');
1174
+ const GAP = 16;
1175
+ const fitCheck = () => {
1176
+ if (!brand || !nav || !right) return;
1177
+ siteHeader.classList.remove('is-crowded');
1178
+ if (!desktop.matches) return;
1179
+ const b = brand.getBoundingClientRect();
1180
+ const n = nav.getBoundingClientRect();
1181
+ const r = right.getBoundingClientRect();
1182
+ if (b.right + GAP > n.left || n.right + GAP > r.left) siteHeader.classList.add('is-crowded');
1183
+ };
1184
+ let queued = false;
1185
+ const queue = () => { if (!queued) { queued = true; requestAnimationFrame(() => { queued = false; fitCheck(); }); } };
1186
+ if (brand) new ResizeObserver(queue).observe(brand);
1187
+ new ResizeObserver(queue).observe(siteHeader);
1188
+ new ResizeObserver(syncHeaderHeight).observe(siteHeader);
1189
+ desktop.addEventListener('change', queue);
1190
+ document.fonts?.ready.then(queue);
1191
+ fitCheck();
1192
+ // Only now that the menu has its row (or not) is the header its real height: publishing
1193
+ // it before the check told the opener the one-row height until the next frame.
1194
+ syncHeaderHeight();
1195
+ }
1196
+
1197
+ function openMega() {
1198
+ if (!megaNav || !aboutTrigger) return;
1199
+ const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
1200
+ const scrollY = window.scrollY;
1201
+ // The panel opens right under the header, whatever its height (a taller bar for a large logo).
1202
+ if (siteHeader) megaNav.style.setProperty('--mega-top', `${Math.round(siteHeader.getBoundingClientRect().bottom)}px`);
1203
+ megaNav.classList.add('is-open');
1204
+ megaNav.removeAttribute('aria-hidden');
1205
+ siteHeader?.classList.add('is-menu-open');
1206
+ aboutTrigger.classList.add('panel-active');
1207
+ aboutLink?.setAttribute('aria-expanded', 'true');
1208
+ siteHeader?.classList.add('header--scrolled');
1209
+
1210
+ document.body.style.position = 'fixed';
1211
+ document.body.style.top = `-${scrollY}px`;
1212
+ document.body.style.left = '0';
1213
+ document.body.style.right = '0';
1214
+ document.body.style.paddingRight = scrollbarWidth + 'px';
1215
+ document.body.dataset.scrollY = String(scrollY);
1216
+ }
1217
+
1218
+ function closeMega() {
1219
+ if (!megaNav || !aboutTrigger) return;
1220
+ megaNav.classList.remove('is-open');
1221
+ megaNav.setAttribute('aria-hidden', 'true');
1222
+ siteHeader?.classList.remove('is-menu-open');
1223
+ aboutTrigger.classList.remove('panel-active');
1224
+ aboutLink?.setAttribute('aria-expanded', 'false');
1225
+
1226
+ const scrollY = parseInt(document.body.dataset.scrollY || '0', 10);
1227
+ document.body.style.position = '';
1228
+ document.body.style.top = '';
1229
+ document.body.style.left = '';
1230
+ document.body.style.right = '';
1231
+ document.body.style.paddingRight = '';
1232
+ delete document.body.dataset.scrollY;
1233
+ window.scrollTo(0, scrollY);
1234
+
1235
+ if (scrollY < 1) siteHeader?.classList.remove('header--scrolled');
1236
+ }
1237
+
1238
+ aboutLink?.addEventListener('click', e => {
1239
+ if (window.matchMedia('(min-width: 64em)').matches) {
1240
+ e.preventDefault();
1241
+ if (megaNav.classList.contains('is-open')) {
1242
+ closeMega();
1243
+ } else {
1244
+ openMega();
1245
+ }
1246
+ } else {
1247
+ e.preventDefault();
1248
+ aboutTrigger.classList.toggle('open');
1249
+ aboutLink?.setAttribute('aria-expanded', aboutTrigger.classList.contains('open') ? 'true' : 'false');
1250
+ }
1251
+ });
1252
+
1253
+ document.addEventListener('click', e => {
1254
+ if (
1255
+ window.matchMedia('(min-width: 64em)').matches &&
1256
+ megaNav?.classList.contains('is-open') &&
1257
+ !(e.target as HTMLElement).closest('.nav-has-dropdown') &&
1258
+ !(e.target as HTMLElement).closest('#mega-nav')
1259
+ ) {
1260
+ closeMega();
1261
+ }
1262
+ });
1263
+
1264
+ document.getElementById('mega-backdrop')?.addEventListener('click', closeMega);
1265
+ document.addEventListener('keydown', e => {
1266
+ if (e.key !== 'Escape') return;
1267
+ closeMega();
1268
+ if (nav.classList.contains('open')) closeNav();
1269
+ });
1270
+
1271
+ // ── Theme toggle ──
1272
+ const html = document.documentElement;
1273
+ const themeToggle = document.getElementById('theme-toggle') as HTMLButtonElement | null;
1274
+ const themeToggleMobile = document.getElementById('theme-toggle-mobile') as HTMLButtonElement | null;
1275
+
1276
+ const THEME_STORAGE_KEY = 'theme';
1277
+ /** Set only when the user clicks the toggle — that's when localStorage takes
1278
+ priority over the system preference. */
1279
+ const THEME_SOURCE_KEY = 'theme-source';
1280
+
1281
+ function syncPrimaryLogo() {
1282
+ const img = document.getElementById('primary-logo') as HTMLImageElement | null;
1283
+ if (!img) return;
1284
+ const src = html.dataset.theme === 'dark'
1285
+ ? (img.dataset.srcDark ?? img.dataset.srcLight)
1286
+ : img.dataset.srcLight;
1287
+ if (src) img.src = src;
1288
+ }
1289
+
1290
+ function syncThemedRasterLogos() {
1291
+ syncPrimaryLogo();
1292
+ }
1293
+
1294
+ /** Keeps the switch's accessible state (role="switch" aria-checked) in
1295
+ sync with the rendered theme — called everywhere html.dataset.theme
1296
+ is set. */
1297
+ function syncToggleAria() {
1298
+ const checked = html.dataset.theme === 'dark' ? 'true' : 'false';
1299
+ themeToggle?.setAttribute('aria-checked', checked);
1300
+ themeToggleMobile?.setAttribute('aria-checked', checked);
1301
+ }
1302
+
1303
+ function systemTheme(): 'dark' | 'light' {
1304
+ return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
1305
+ }
1306
+
1307
+ function userThemeOverride(): 'dark' | 'light' | null {
1308
+ if (localStorage.getItem(THEME_SOURCE_KEY) !== 'user') return null;
1309
+ const v = localStorage.getItem(THEME_STORAGE_KEY);
1310
+ return v === 'light' || v === 'dark' ? v : null;
1311
+ }
1312
+
1313
+ function applyThemeFromStorageOrSystem() {
1314
+ const override = userThemeOverride();
1315
+ html.dataset.theme = override ?? systemTheme();
1316
+ syncThemedRasterLogos();
1317
+ syncToggleAria();
1318
+ }
1319
+
1320
+ function onSystemThemeChange() {
1321
+ if (userThemeOverride() !== null) return;
1322
+ html.dataset.theme = systemTheme();
1323
+ syncThemedRasterLogos();
1324
+ syncToggleAria();
1325
+ }
1326
+
1327
+ function setUserThemeChoice(theme: 'dark' | 'light') {
1328
+ localStorage.setItem(THEME_SOURCE_KEY, 'user');
1329
+ localStorage.setItem(THEME_STORAGE_KEY, theme);
1330
+ html.dataset.theme = theme;
1331
+ syncThemedRasterLogos();
1332
+ syncToggleAria();
1333
+ }
1334
+
1335
+ applyThemeFromStorageOrSystem();
1336
+ const colorSchemeMq = window.matchMedia('(prefers-color-scheme: dark)');
1337
+ colorSchemeMq.addEventListener('change', onSystemThemeChange);
1338
+
1339
+ function toggleTheme() {
1340
+ const next = html.dataset.theme === 'dark' ? 'light' : 'dark';
1341
+ setUserThemeChoice(next);
1342
+ }
1343
+
1344
+ themeToggle?.addEventListener('click', (e) => {
1345
+ e.preventDefault();
1346
+ e.stopPropagation();
1347
+ toggleTheme();
1348
+ });
1349
+
1350
+ themeToggleMobile?.addEventListener('click', (e) => {
1351
+ e.preventDefault();
1352
+ e.stopPropagation();
1353
+ toggleTheme();
1354
+ });
1355
+
1356
+ // ── Primary nav active-state re-sync ──
1357
+ // The header is `transition:persist` (see the comment above <header>), so
1358
+ // on a soft navigation within a ClientRouter-enabled page family
1359
+ // (/posts/*), this DOM node survives untouched — the freshly-computed
1360
+ // active state on the destination page's own server-rendered header never
1361
+ // reaches the screen, since that header copy is discarded, not this one.
1362
+ // `astro:page-load` fires after every navigation, initial load and every
1363
+ // soft transition alike, so re-deriving the active link from the current
1364
+ // URL here keeps the persisted header in sync regardless of how it got
1365
+ // stale. Same longest-match rule as the server-side computation above
1366
+ // (SiteHeader's frontmatter) — ported to run client-side since this is
1367
+ // the only copy guaranteed to run on every navigation, including ones the
1368
+ // server-rendered version never gets a chance to apply.
1369
+ document.addEventListener('astro:page-load', () => {
1370
+ const navLinks = Array.from(
1371
+ document.querySelectorAll<HTMLAnchorElement>('#site-nav > a.nav-link'),
1372
+ );
1373
+ if (!navLinks.length) return;
1374
+
1375
+ const path = window.location.pathname;
1376
+ let bestLink: HTMLAnchorElement | null = null;
1377
+ let bestLength = -1;
1378
+
1379
+ for (const link of navLinks) {
1380
+ const trimmed = (link.getAttribute('href') ?? '').replace(/\/$/, '');
1381
+ if (trimmed.length > bestLength && path.startsWith(trimmed)) {
1382
+ bestLink = link;
1383
+ bestLength = trimmed.length;
1384
+ }
1385
+ }
1386
+
1387
+ for (const link of navLinks) {
1388
+ link.classList.toggle('active', link === bestLink);
1389
+ }
1390
+ });
1391
+ </script>