/* =====================================================================
   IsoMythric · Dusk: shared tokens, base, shell and components.
   Source of truth: direction A "Dusk". A retheme only changes the Tokens block.
   Sections: Fonts · Tokens · Base · Layout · Signage labels · Shared · Buttons ·
   Forms · Header and navigation · Footer · Image viewer · Page change ·
   Scroll reveal · Responsive · Reduced motion
   ===================================================================== */

/* =====================================================================
   Fonts (self-hosted, OFL; licences in /fonts/licenses)
   ===================================================================== */
@font-face { font-family: 'Barlow Condensed'; src: url('../fonts/BarlowCondensed-Medium.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url('../fonts/BarlowCondensed-SemiBold.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Barlow Condensed'; src: url('../fonts/BarlowCondensed-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../fonts/InterVariable.woff2') format('woff2'); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('../fonts/JetBrainsMono-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('../fonts/JetBrainsMono-Medium.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }

/* =====================================================================
   Tokens: night bay, sodium amber, studio green on the logo only
   ===================================================================== */
:root {
    color-scheme: dark;

    /* Night-bay base: deep blue-green */
    --c-bg: #0b1518;
    --c-deep: #071013;          /* nav, footer */
    --c-panel: #0f1d21;
    --c-raised: #142529;
    --c-line: #22343a;          /* 1px rules */
    --c-line-2: #30474d;        /* stronger rules */
    --c-line-3: #5b7377;        /* field and control borders, 3.4:1 or more */
    --c-line-soft: rgba(34, 52, 58, 0.6);

    /* Text: every pair is AA or better on bg, panel and raised */
    --c-text: #e3eae8;          /* 15.2:1 on bg */
    --c-body: #b7c4c2;          /* 10.3:1 */
    --c-muted: #9babaa;         /*  7.7:1 */
    --c-prose: #c6d1cf;         /* long reading */
    --c-ink: #0b1518;           /* text on the mist button */
    --c-white: #ffffff;

    /* Accents */
    --c-amber: #f09a35;         /* now, newest, active phase, warm light: 8.3:1 */
    --c-amber-a: rgba(240, 154, 53, 0.55);
    --c-amber-soft: rgba(240, 154, 53, 0.14);
    --c-amber-halo: rgba(240, 154, 53, 0.2);
    --c-green: #27ca3f;         /* studio green: done and live (roadmap). Never on the logo cube */
    --c-teal: #55c2b1;          /* tags and in-text links, as text or outline only */
    --c-teal-a: rgba(85, 194, 177, 0.5);
    --c-teal-soft: rgba(85, 194, 177, 0.3);
    --c-warn: #e6bf5f;          /* forms only */
    --focus: #f6b968;

    /* Interface fills, overlays and shadows */
    --c-hover: rgba(227, 234, 232, 0.06);
    --c-hover-soft: rgba(227, 234, 232, 0.04);
    --c-press: rgba(227, 234, 232, 0.05);
    --c-disabled: rgba(227, 234, 232, 0.45);
    --c-placeholder: #8b9b99;
    --c-field-hover: #7a9195;
    --c-selection: rgba(240, 154, 53, 0.35);
    --c-scrim: rgba(3, 8, 9, 0.6);
    --c-scrim-strong: rgba(3, 8, 9, 0.94);
    --shadow-menu: 0 24px 48px -20px rgba(0, 0, 0, 0.85);

    /* Type */
    --f-display: 'Barlow Condensed', 'Arial Narrow', 'Roboto Condensed', system-ui, sans-serif;
    --f-text: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --f-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
    --fs-display: clamp(3rem, 1.7rem + 4.6vw, 6rem);
    --fs-h1: clamp(2.75rem, 1.8rem + 3.4vw, 4.75rem);
    --fs-h2: clamp(2.25rem, 1.7rem + 2vw, 3.5rem);
    --fs-h3: clamp(1.5rem, 1.3rem + 0.6vw, 1.875rem);
    --fs-lead: clamp(1.0625rem, 0.98rem + 0.4vw, 1.25rem);
    --track-caps: 0.08em;

    /* Space and layout */
    --sp-section: clamp(64px, 8vw, 112px);
    --sp-page-top: clamp(40px, 6vw, 88px);   /* first block under the header on inner pages */
    --gutter: clamp(16px, 4vw, 40px);
    --wrap: 1240px;
    --header-h: 72px;                        /* sticky header height; 64px on phones */
    --header-offset: calc(var(--header-h) + 16px);   /* scroll-padding and sticky offsets */

    /* Shape and motion */
    --r-sm: 6px;
    --r-md: 10px;
    --r-chip: 4px;              /* every chip, tag, badge and pill: signage corners */
    --r-pill: 999px;
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --t-ui: 200ms;

    /* Layers */
    --z-header: 50;
    --z-modal: 300;
    --z-intro: 400;
    --z-skip: 500;
}

/* =====================================================================
   Base
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html {
    background: var(--c-bg);
    scroll-behavior: smooth;
    scroll-padding-top: var(--header-offset);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--c-bg);
    color: var(--c-body);
    font: 400 1rem/1.65 var(--f-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

[hidden] { display: none !important; }

img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, h4 { text-wrap: balance; }
p { text-wrap: pretty; }
::selection { background: var(--c-selection); color: var(--c-white); }

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 3px;
    border-radius: 4px;
}
/* Programmatic focus targets (the page heading after a route change, the main region) show no ring */
#mainContent:focus, [tabindex="-1"]:focus:not(:focus-visible), h1[tabindex="-1"]:focus { outline: none; }

main { display: block; }
/* Main holds at least the viewport under the header, so the footer never paints in the first
   screen while the page is still empty (before the router runs, or while a page fetches) and
   then jumps away: that jump was the largest layout shift on a fresh load. */
#mainContent { min-height: calc(100vh - var(--header-h)); min-height: calc(100svh - var(--header-h)); }
main, .site-footer { position: relative; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    left: 16px;
    top: -80px;
    z-index: var(--z-skip);
    padding: 10px 16px;
    border-radius: var(--r-sm);
    background: var(--c-text);
    color: var(--c-ink);
    font-weight: 600;
    text-decoration: none;
    transition: top var(--t-ui) var(--ease-out);
}
.skip-link:focus { top: 12px; }

/* The icon sprite lives at the top of the body; it is never shown itself */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Line icons: <svg class="i"><use href="#i-arrow"/></svg> (symbols in index.html) */
.i {
    width: 1em;
    height: 1em;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Mono is for real values only: ISO dates, versions, phase numbers, counts */
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: 0; text-transform: none; }

/* 2:1 street grid, static, about 6 %: the hero and the footer only */
.grid-21 {
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='32'%3E%3Cpath d='M0 16L32 0L64 16L32 32Z' fill='none' stroke='%23e3eae8' stroke-opacity='.06'/%3E%3C/svg%3E");
    background-size: 64px 32px;
}

/* =====================================================================
   Layout utilities
   ===================================================================== */
.wrap, .container {
    width: 100%;
    max-width: calc(var(--wrap) + 2 * var(--gutter));
    margin: 0 auto;
    padding: 0 var(--gutter);
}

/* Inner pages: the first block under the header */
.page-head { padding-top: var(--sp-page-top); }
.page-head + .section { padding-top: clamp(48px, 6vw, 80px); }

.section { position: relative; padding: var(--sp-section) 0 0; }
main > .section:last-child, .page > .section:last-child { padding-bottom: var(--sp-section); }

.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 36px; }

/* =====================================================================
   Signage labels: uppercase condensed, +0.08em. Mono is kept for real values.
   ===================================================================== */
.kicker, .mini-label, .f-col h3, .crumbs {
    font-family: var(--f-display);
    font-weight: 600;
    letter-spacing: var(--track-caps);
    text-transform: uppercase;
}

.kicker {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.2;
    color: var(--c-body);
}
/* the marker is one 2:1 street tile */
.tile-mark {
    width: 14px;
    height: 7px;
    flex: none;
    background: var(--c-amber);
    clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.mini-label { display: flex; align-items: center; gap: 14px; margin: 0 0 16px; font-size: 0.8125rem; line-height: 1.2; color: var(--c-muted); }
.mini-label::after { content: ""; flex: 1; height: 1px; background: var(--c-line); }

/* =====================================================================
   Shared: headings, section heads, links, chips
   ===================================================================== */
.display {
    margin: 22px 0 0;
    font: 600 var(--fs-display)/0.95 var(--f-display);
    letter-spacing: -0.005em;
    color: var(--c-text);
}
.display .line { display: block; }

/* Page titles on inner pages */
.h1 {
    margin: 14px 0 0;
    font: 600 var(--fs-h1)/0.98 var(--f-display);
    color: var(--c-text);
}
.h2 {
    margin: 14px 0 0;
    font: 600 var(--fs-h2)/1 var(--f-display);
    letter-spacing: 0;
    color: var(--c-text);
}
.h3 {
    margin: 0;
    font: 600 var(--fs-h3)/1.1 var(--f-display);
    color: var(--c-text);
}

.lede {
    margin: 26px 0 0;
    max-width: 30em;
    font-size: var(--fs-lead);
    line-height: 1.6;
    color: var(--c-body);
}
.lede strong { color: var(--c-text); font-weight: 600; }

.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px 40px;
    flex-wrap: wrap;
    margin-bottom: 48px;
}
.section-sub {
    margin: 16px 0 0;
    max-width: 36em;
    color: var(--c-body);
    font-size: 1.0625rem;
}

/* In-text links: bay teal, underlined */
.link {
    color: var(--c-teal);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
    border-radius: 2px;
}
.link:hover { text-decoration-thickness: 2px; }

.link-arrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--c-teal);
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: 5px;
    text-decoration-thickness: 1px;
    border-radius: 4px;
    transition: text-decoration-color var(--t-ui) var(--ease-out);
}
.link-arrow .i { width: 16px; height: 16px; transition: transform var(--t-ui) var(--ease-out); }
.link-arrow:hover { text-decoration-color: currentColor; }
.link-arrow:hover .i { transform: translateX(3px); }

.text-btn {
    padding: 4px 0;
    border: 0;
    background: none;
    color: var(--c-teal);
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: 4px;
    transition: text-decoration-color var(--t-ui) var(--ease-out);
}
.text-btn:hover { text-decoration-color: currentColor; }

/* Breadcrumbs */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; padding: 0; list-style: none; font-size: 0.875rem; color: var(--c-muted); }
.crumbs a { display: inline-flex; align-items: center; gap: 7px; color: var(--c-body); text-decoration: none; border-radius: 4px; }
.crumbs a .i { width: 14px; height: 14px; transition: transform var(--t-ui) var(--ease-out); }
.crumbs a:hover { color: var(--c-text); }
.crumbs li:first-child a:hover .i { transform: translateX(-3px); }
.crumbs li + li::before { content: "/"; margin-right: 8px; color: var(--c-line-3); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }

/* tags: bay teal, outline only */
.tag {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 2px 10px;
    border-radius: var(--r-chip);
    border: 1px solid var(--c-teal-a);
    color: var(--c-teal);
    font: 600 0.8125rem/1.2 var(--f-display);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}
.tag-more { border-color: var(--c-teal-soft); font-family: var(--f-mono); font-weight: 500; font-size: 0.75rem; letter-spacing: 0; }

/* chapter marker: a monochrome line icon and the chapter name */
.chapter {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--c-body);
    font: 600 0.8125rem/1.2 var(--f-display);
    letter-spacing: var(--track-caps);
    text-transform: uppercase;
    white-space: nowrap;
}
.chapter .i { width: 15px; height: 15px; color: var(--c-muted); }

/* status chips: shape and colour together */
.st {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 28px;
    padding: 0 12px 0 10px;
    border-radius: var(--r-chip);
    border: 1px solid var(--c-line-2);
    color: var(--c-text);
    font: 600 0.8125rem/1 var(--f-display);
    letter-spacing: var(--track-caps);
    text-transform: uppercase;
    white-space: nowrap;
}
.st::before {
    content: "";
    width: 10px;
    height: 10px;
    flex: none;
    border-radius: 50%;
}
.st--now { color: var(--c-amber); border-color: var(--c-amber-a); }
.st--now::before { background: var(--c-amber); box-shadow: 0 0 0 4px var(--c-amber-halo); }
.st--next::before { border: 1.5px solid var(--c-text); background: linear-gradient(90deg, var(--c-text) 50%, transparent 50%); }
.st--later { color: var(--c-body); }
.st--later::before { border: 1.5px solid var(--c-body); }
.st--someday { color: var(--c-muted); border-style: dashed; }
.st--someday::before { border: 1.5px dashed var(--c-muted); }

/* "New" badge: the newest item only */
.badge-new {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 24px;
    padding: 0 9px;
    border-radius: var(--r-chip);
    border: 1px solid var(--c-amber-a);
    color: var(--c-amber);
    font: 700 0.8125rem/1 var(--f-display);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.badge-new::before { content: ""; width: 10px; height: 5px; background: var(--c-amber); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }

/* =====================================================================
   Buttons
   ===================================================================== */
.btn {
    --h: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: var(--h);
    padding: 0 22px;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    font: 600 1.0625rem/1 var(--f-display);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--t-ui) var(--ease-out), border-color var(--t-ui) var(--ease-out), color var(--t-ui) var(--ease-out);
}
.btn .i { width: 18px; height: 18px; transition: transform var(--t-ui) var(--ease-out); }
.btn:hover .i-arrow { transform: translateX(3px); }
.btn-lg { --h: 56px; padding: 0 28px; font-size: 1.125rem; }
.btn-sm { --h: 36px; padding: 0 14px; gap: 7px; font-size: 0.9375rem; }
.btn-sm .i { width: 16px; height: 16px; }

/* one primary per view: a mist sign with night ink. Amber never fills a button. */
.btn-primary { background: var(--c-text); color: var(--c-ink); }
.btn-primary:hover { background: var(--c-white); }
.btn-secondary { background: transparent; color: var(--c-text); border-color: var(--c-line-3); }
.btn-secondary:hover { border-color: var(--c-text); background: var(--c-press); }
.btn-ghost { background: transparent; color: var(--c-body); }
.btn-ghost:hover { color: var(--c-text); background: var(--c-hover); }
.btn-portal { background: transparent; color: var(--c-text); border-color: var(--c-line-2); }
.btn-portal .i { color: var(--c-muted); }
.btn-portal:hover { border-color: var(--c-line-3); }

.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: var(--r-sm); }
.btn:disabled, .btn[aria-disabled="true"] {
    cursor: not-allowed;
    color: var(--c-disabled);
    background: transparent;
    border-color: var(--c-line);
}

/* =====================================================================
   Forms
   ===================================================================== */
.field-label { display: block; margin: 0 0 7px; font: 600 0.875rem/1.2 var(--f-display); letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--c-body); }
.field {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 11px 14px;
    border-radius: var(--r-sm);
    border: 1px solid var(--c-line-3);
    background: var(--c-deep);
    color: var(--c-text);
    font-size: 0.9375rem;
    line-height: 1.5;
    transition: border-color var(--t-ui) var(--ease-out);
}
.field::placeholder { color: var(--c-placeholder); }
.field:hover { border-color: var(--c-field-hover); }
.field:focus { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--c-text); }
textarea.field { resize: vertical; min-height: 104px; }
select.field { appearance: none; padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, var(--c-body) 50%), linear-gradient(-45deg, transparent 50%, var(--c-body) 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.field-hint { margin: 6px 0 0; font-size: 0.8125rem; line-height: 1.45; color: var(--c-muted); }
/* errors carry a shape as well as a colour */
.field[aria-invalid="true"] { border-color: var(--c-warn); }
.field-error { display: flex; align-items: baseline; gap: 8px; margin: 6px 0 0; font-size: 0.875rem; line-height: 1.45; color: var(--c-warn); }
.field-error::before { content: "!"; display: inline-grid; place-items: center; flex: none; width: 16px; height: 16px; border: 1.5px solid currentColor; border-radius: 50%; font: 700 0.6875rem/1 var(--f-text); transform: translateY(2px); }
.form-row { display: grid; gap: 14px; }
.form-status { margin: 12px 0 0; font-size: 0.9375rem; color: var(--c-body); }

/* =====================================================================
   Header and navigation
   ===================================================================== */
.site-header {
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    background: var(--c-deep);
    border-bottom: 1px solid var(--c-line);
}

.nav-row { display: flex; align-items: center; gap: 24px; height: var(--header-h); }
.site-header .nav-row { position: relative; z-index: 2; }

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    flex: none;
    color: var(--c-text);
    text-decoration: none;
    font: 700 1.5rem/1 var(--f-display);
    letter-spacing: 0.01em;
    border-radius: 6px;
}
.brand-cube { display: block; width: 34px; height: 34px; flex: none; }
.brand-cube svg { width: 100%; height: auto; }

/* IsoCube light sweep (js/app.js, LogoSweep): a soft band of warm-white light passes once across the
   tiles along the isometric diagonal, and they settle back. Each tile has a light copy of its face laid
   over it (.ic-glint, --sd = its place along the band, 0 to 1); only the copies' opacity changes.
   --ic-spread is how long the band takes to cross, --ic-glow how long one tile stays bright. */
[data-logo] { --ic-spread: 440ms; --ic-glow: 340ms; }
[data-logo][data-anim="sweep"] { --ic-spread: 900ms; --ic-glow: 640ms; }
.ic-sweep { pointer-events: none; }
.ic-glint { opacity: 0; --ic-peak: 0.36; }
.ic-glint[data-face="left"] { --ic-peak: 0.3; }
.ic-glint[data-face="right"] { --ic-peak: 0.24; }
.is-sweeping .ic-glint {
    animation: ic-glint var(--ic-glow) cubic-bezier(0.37, 0, 0.3, 1) both;
    animation-delay: calc(var(--sd, 0) * var(--ic-spread));
}
@keyframes ic-glint {
    0% { opacity: 0; }
    40% { opacity: var(--ic-peak); }
    100% { opacity: 0; }
}

.nav { flex: 1; display: flex; justify-content: center; }
.nav-list { display: flex; align-items: center; gap: 2px; margin: 0; padding: 0; list-style: none; }
.nav-list > li { position: relative; }

.nav-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 40px;
    padding: 0 14px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--c-body);
    font: 600 1rem/1 var(--f-display);
    letter-spacing: var(--track-caps);
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: color var(--t-ui) var(--ease-out), background-color var(--t-ui) var(--ease-out);
}
.nav-link:hover { color: var(--c-text); background: var(--c-hover); }
.nav-link[aria-current="page"], .has-menu.is-section .nav-split .nav-link { color: var(--c-text); }
.nav-link[aria-current="page"]::after, .has-menu.is-section .nav-split .nav-link::after {
    content: "";
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 4px;
    height: 2px;
    background: var(--c-amber);
}

.nav-split { display: flex; align-items: center; border-radius: var(--r-sm); transition: background-color var(--t-ui) var(--ease-out); }
.nav-split .nav-link { padding-right: 4px; }
.nav-split .nav-link[aria-current="page"]::after, .has-menu.is-section .nav-split .nav-link::after { right: 4px; }
.nav-split .nav-link:hover { background: transparent; }
.has-menu:hover .nav-split, .has-menu.is-open .nav-split { background: var(--c-hover); }
.has-menu:hover .nav-split .nav-link, .has-menu.is-open .nav-split .nav-link { color: var(--c-text); }
.nav-caret {
    display: grid;
    place-items: center;
    width: 30px;
    height: 40px;
    padding: 0 8px 0 0;
    border: 0;
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    background: transparent;
    color: var(--c-muted);
    cursor: pointer;
}
.nav-split .nav-link:focus-visible, .nav-caret:focus-visible { outline-offset: -2px; }
.nav-caret .i { width: 15px; height: 15px; transition: transform var(--t-ui) var(--ease-out); }
.has-menu:hover .nav-caret, .has-menu.is-open .nav-caret { color: var(--c-text); }
.has-menu.is-open .nav-caret .i { transform: rotate(180deg); }

.menu {
    position: absolute;
    top: calc(100% + 12px);
    left: 50%;
    z-index: 20;
    width: 330px;
    padding: 8px;
    border-radius: var(--r-md);
    background: var(--c-raised);
    border: 1px solid var(--c-line-2);
    box-shadow: var(--shadow-menu);
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -4px);
    transition: opacity var(--t-ui) var(--ease-out), transform var(--t-ui) var(--ease-out), visibility 0s linear var(--t-ui);
}
/* a bridge over the gap, so the pointer can travel from the label to the menu */
.menu::before { content: ""; position: absolute; left: 0; right: 0; top: -14px; height: 14px; }
.has-menu.is-open .menu, html:not(.js) .has-menu:hover .menu, html:not(.js) .has-menu:focus-within .menu {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
    transition-delay: 0s;
}

.menu-item {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--c-text);
    text-decoration: none;
    transition: background-color var(--t-ui) var(--ease-out);
}
.menu-item:hover { background: var(--c-hover); }
.menu-item:focus-visible { outline-offset: -2px; }
.menu-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: 1px solid var(--c-line-2);
    color: var(--c-body);
}
.menu-item:hover .menu-icon { border-color: var(--c-line-3); color: var(--c-text); }
.menu-item[aria-current="page"] .menu-icon { border-color: var(--c-amber-a); color: var(--c-amber); }
/* the current page in a menu also carries a shape: the 2:1 tile after its name (as in the mobile list) */
.menu-item[aria-current="page"] b { display: flex; align-items: center; gap: 10px; }
.menu-item[aria-current="page"] b::after,
.m-sub a[aria-current="page"]::after {
    content: "";
    width: 12px;
    height: 6px;
    flex: none;
    background: var(--c-amber);
    clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}
.menu-icon .i { width: 19px; height: 19px; }
.menu-item b { display: block; font: 600 1.0625rem/1.2 var(--f-display); letter-spacing: 0.04em; text-transform: uppercase; }
.menu-item small { display: block; margin-top: 3px; color: var(--c-muted); font-size: 0.8125rem; line-height: 1.35; }

.nav-portal { flex: none; }

/* Logged in: the user, Dashboard and Log out take the portal button's place */
.nav-auth { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.nav-user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    max-width: 15rem;
    color: var(--c-text);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.site-header .role-badge {
    display: inline-flex;
    align-items: center;
    flex: none;
    height: 22px;
    margin: 0;
    padding: 0 7px;
    border-radius: var(--r-chip);
    border: 1px solid var(--c-line-2);
    background: none;
    color: var(--c-body);
    font: 600 0.75rem/1 var(--f-display);
    letter-spacing: var(--track-caps);
    text-transform: uppercase;
}

.menu-toggle {
    display: none;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-left: auto;
    border-radius: var(--r-sm);
    border: 1px solid var(--c-line-2);
    background: transparent;
    color: var(--c-text);
    cursor: pointer;
}
.menu-toggle .i { width: 22px; height: 22px; }
.menu-toggle .i-close { display: none; }
.menu-open .menu-toggle .i-menu { display: none; }
.menu-open .menu-toggle .i-close { display: block; }

.mobile-panel {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    top: var(--header-h);
    z-index: 1;
    max-height: calc(100vh - var(--header-h));
    max-height: calc(100dvh - var(--header-h));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px var(--gutter) 28px;
    background: var(--c-deep);
    border-bottom: 1px solid var(--c-line-2);
    box-shadow: 0 0 0 100vmax var(--c-scrim);
}
.menu-open .mobile-panel { display: block; animation: panel-in var(--t-ui) var(--ease-out); }
@keyframes panel-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.m-list { margin: 0; padding: 0; list-style: none; }
.m-list > li { border-bottom: 1px solid var(--c-line); }
.m-row { display: flex; align-items: center; }
.m-link {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    color: var(--c-text);
    font: 600 1.25rem/1.2 var(--f-display);
    letter-spacing: var(--track-caps);
    text-transform: uppercase;
    text-decoration: none;
}
.m-link[aria-current="page"]::before, .m-group.is-section .m-link::before { content: ""; width: 14px; height: 7px; flex: none; background: var(--c-amber); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.m-caret {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: var(--r-sm);
    border: 1px solid var(--c-line-2);
    background: transparent;
    color: var(--c-body);
    cursor: pointer;
}
.m-caret .i { width: 18px; height: 18px; transition: transform var(--t-ui) var(--ease-out); }
.m-group.is-open .m-caret .i { transform: rotate(180deg); }
.m-sub { display: none; margin: 0 0 12px; padding: 4px 0; list-style: none; border-left: 1px solid var(--c-line-2); }
.m-group.is-open .m-sub { display: block; }
.m-sub a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 0 14px;
    color: var(--c-body);
    font-weight: 500;
    text-decoration: none;
    border-radius: 4px;
}
.m-sub a:hover { color: var(--c-text); background: var(--c-press); }
.m-sub a[aria-current="page"] { color: var(--c-text); }
.m-sub .i { width: 18px; height: 18px; color: var(--c-muted); }
.m-sub a[aria-current="page"] .i { color: var(--c-amber); }
.m-portal { margin-top: 20px; width: 100%; }
.mob-auth { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--c-line); }
.mob-auth .nav-user { flex: 1 1 100%; max-width: none; font-size: 0.9375rem; }
.mob-auth .btn { flex: 1 1 0; }

/* =====================================================================
   Footer
   ===================================================================== */
.site-footer { isolation: isolate; overflow: clip; background: var(--c-deep); border-top: 1px solid var(--c-line); }
.site-footer .grid-21 {
    -webkit-mask-image: radial-gradient(ellipse 70% 90% at 50% 100%, #000 0%, transparent 75%);
    mask-image: radial-gradient(ellipse 70% 90% at 50% 100%, #000 0%, transparent 75%);
}
.footer-cta { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 32px; padding: var(--sp-section) 0 56px; border-bottom: 1px solid var(--c-line); }
.footer-cta h2 { margin: 14px 0 0; font: 600 var(--fs-h2)/1 var(--f-display); color: var(--c-text); }
.footer-cta .footer-sub { margin: 14px 0 0; max-width: 34em; color: var(--c-body); font-size: 1.0625rem; text-wrap: balance; }
.footer-cta .cta-row { margin-top: 0; }

.footer-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(0, 1fr)); gap: 40px; padding: 56px 0 48px; }
.f-brand .brand { font-size: 1.625rem; }
.f-brand .brand-cube { width: 40px; height: 40px; }
.f-tagline { margin: 18px 0 0; max-width: 26em; color: var(--c-body); font-size: 0.9375rem; }
.f-col h3 { margin: 6px 0 18px; font-size: 0.8125rem; line-height: 1; color: var(--c-muted); }
.f-col ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.f-col a { color: var(--c-body); text-decoration: none; font-size: 0.9375rem; border-radius: 4px; }
.f-col a:hover { color: var(--c-text); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }

.footer-bottom { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 24px; padding: 22px 0 32px; border-top: 1px solid var(--c-line); color: var(--c-muted); font-size: 0.875rem; }
.footer-bottom a { display: inline-flex; align-items: center; gap: 8px; color: var(--c-body); text-decoration: none; border-radius: 4px; }
.footer-bottom a:hover { color: var(--c-text); }
.fb-left { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0; }
.fb-left .sep { color: var(--c-line-3); }
.footer-bottom .i { width: 15px; height: 15px; color: var(--c-muted); }

/* =====================================================================
   Image viewer (opened from post images; markup in index.html, script in js/app.js)
   ===================================================================== */
.image-modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(16px, 4vw, 48px);
    background: var(--c-scrim-strong);
}
.image-modal img { max-width: 100%; max-height: calc(100vh - 2 * clamp(16px, 4vw, 48px)); width: auto; border-radius: var(--r-sm); border: 1px solid var(--c-line-2); }
.image-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: var(--r-sm);
    border: 1px solid var(--c-line-2);
    background: var(--c-deep);
    color: var(--c-text);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}
.image-modal-close:hover { border-color: var(--c-line-3); }
.image-modal-close .i { width: 20px; height: 20px; }
body.modal-open { overflow: hidden; }

/* =====================================================================
   Page change: a short fade when the route changes (not on first load)
   ===================================================================== */
.page-in { animation: page-in 0.2s var(--ease-out) both; }
@keyframes page-in { from { opacity: 0; } to { opacity: 1; } }

/* =====================================================================
   Scroll reveal (UI only, never world motion). Router.reveal() adds .is-in.
   ===================================================================== */
.js .reveal { opacity: 0; transform: translate3d(0, 16px, 0); transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out); transition-delay: var(--rd, 0ms); }
.js .reveal.is-in { opacity: 1; transform: none; }

/* =====================================================================
   Responsive (shell and shared parts; page layouts live in their own files)
   ===================================================================== */
@media (max-width: 1180px) {
    .nav-auth .nav-user { display: none; }
}

@media (max-width: 960px) {
    .site-header .nav, .site-header .nav-portal, .site-header .nav-auth { display: none; }
    .menu-toggle { display: grid; }
    .menu-open { overflow: hidden; }
    .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .f-brand { grid-column: 1 / -1; }
    .footer-cta { grid-template-columns: minmax(0, 1fr); align-items: start; }
}

@media (max-width: 680px) {
    .section-head { margin-bottom: 32px; }
}

@media (max-width: 560px) {
    :root { --header-h: 64px; }
    .brand { font-size: 1.375rem; }
    .cta-row .btn { flex: 1 1 100%; }
    .cta-row { margin-top: 28px; }
    .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px 24px; }
    .footer-cta .cta-row .btn { flex: 1 1 100%; }
    .footer-bottom, .fb-left { flex-direction: column; align-items: flex-start; gap: 0; }
    .fb-left .sep { display: none; }
}

/* Touch: small links and controls get a 44px target. Breadcrumbs grow their hit area only
   (padding offset by a negative margin), so the layout does not move. */
@media (pointer: coarse), (max-width: 560px) {
    .btn-sm { --h: 44px; }
    .brand { min-height: 44px; }
    .crumbs a { padding-block: 11px; margin-block: -11px; }
    .f-col ul { gap: 0; }
    .f-col a, .footer-bottom a { display: inline-flex; align-items: center; min-height: 44px; }
    .footer-bottom { padding-top: 12px; padding-bottom: 22px; }
}

/* =====================================================================
   Reduced motion: nothing moves, nothing is hidden
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        animation-delay: 0ms !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0ms !important;
    }
    .js .reveal { opacity: 1; transform: none; }
    .ic-sweep { display: none; }
}
