ferst-core 0.14.0 → 0.16.0

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