/* Shared header, command palette and footer. One markup (build/sitelib.py), one stylesheet, every page.
   Tokens come from tokens.css (loaded after the legacy sheets); fallbacks keep it working on its own. */
:root { --am-header: 64px; }

.am-skip {
  position: absolute; left: 12px; top: -60px; z-index: 200;
  background: var(--navy, #1A2332); color: #fff; padding: 10px 14px; border-radius: 8px;
  font: 600 0.9rem "DM Sans", system-ui, sans-serif; text-decoration: none;
}
.am-skip:focus { top: 10px; }

.am-header {
  position: sticky; top: 0; z-index: 60; height: var(--am-header);
  background: rgba(255, 255, 255, 0.96); -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line, #E4EBF2);
  font-family: "DM Sans", system-ui, sans-serif;
}
.am-header *, .am-footer * { box-sizing: border-box; }
.am-header-inner { width: min(1240px, calc(100% - 32px)); height: 100%; margin: 0 auto; display: flex; align-items: center; gap: 16px; }
.am-brand { display: flex; align-items: center; gap: 8px; flex: none; text-decoration: none; color: var(--navy, #1A2332); }
.am-brand img { width: 32px; height: 32px; display: block; }
.am-brand-name { font-family: "Sora", system-ui, sans-serif; font-size: 1.15rem; font-weight: 700; letter-spacing: -0.03em; color: var(--navy, #1A2332); }
.am-brand-name span { color: var(--accent-ink, #066E6B); }

.am-drawer { display: flex; flex: 1; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.am-list { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 0; }
.am-item { position: relative; margin: 0; }

.am-nav a, .am-trigger, .am-cta a { font-family: "DM Sans", system-ui, sans-serif; text-decoration: none; }
.am-nav .am-item > a, .am-trigger {
  display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 6px 10px; border: 0; border-radius: 8px; background: none;
  font-size: 0.94rem; font-weight: 600; color: var(--navy, #1A2332); cursor: pointer; white-space: nowrap;
  transition: background var(--d-fast, 120ms) ease, color var(--d-fast, 120ms) ease;
}
.am-nav .am-item > a:hover, .am-trigger:hover, .am-trigger[aria-expanded="true"] { background: var(--surface-2, #F6F9FB); }
.am-nav .am-item > a.is-current, .am-trigger.is-section { color: var(--accent-ink, #066E6B); box-shadow: inset 0 -2px 0 var(--accent, #0ABFBC); border-radius: 8px 8px 0 0; }
.am-chev { transition: transform var(--d-fast, 120ms) ease; }
.am-trigger[aria-expanded="true"] .am-chev { transform: rotate(180deg); }
.am-header a:focus-visible, .am-header button:focus-visible, .am-footer a:focus-visible, .am-pal button:focus-visible, .am-pal input:focus-visible {
  outline: 2px solid var(--accent-ink, #066E6B); outline-offset: 2px;
}

/* Dropdowns: a compact list, one line each. Absolutely positioned: opening never moves the page. */
.am-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 70; min-width: 288px; padding: 6px;
  background: #fff; border: 1px solid var(--line, #E4EBF2); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(26, 35, 50, 0.12), 0 2px 6px rgba(26, 35, 50, 0.06);
  visibility: hidden; opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease, visibility 0s linear 120ms;
}
.am-panel.is-open, html:not(.am-js) .am-has-menu:hover > .am-panel, html:not(.am-js) .am-has-menu:focus-within > .am-panel {
  visibility: visible; opacity: 1; transform: none; pointer-events: auto; transition: opacity 120ms ease, transform 120ms ease;
}
.am-panel ul { list-style: none; margin: 0; padding: 0; }
.am-panel a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--navy, #1A2332); text-decoration: none; }
.am-panel a:hover { background: var(--surface-2, #F6F9FB); }
.am-panel a.is-current { background: var(--accent-soft, #E7F8F8); }
.am-link-title { display: block; font-weight: 600; font-size: 0.93rem; line-height: 1.3; }
.am-link-sub { display: block; margin-top: 1px; font-size: 0.82rem; line-height: 1.35; color: var(--ink-2, #4A586B); font-weight: 400; }

.am-cta { display: flex; align-items: center; gap: 8px; flex: none; }
.am-search {
  display: none; align-items: center; gap: 8px; min-height: 40px; padding: 0 8px 0 12px; border-radius: 8px;
  border: 1px solid var(--line-strong, #8795A8); background: #fff; color: var(--ink-2, #4A586B); cursor: pointer;
  font: 400 0.9rem "DM Sans", system-ui, sans-serif; transition: border-color var(--d-fast, 120ms) ease, background var(--d-fast, 120ms) ease;
}
html.am-js .am-search { display: inline-flex; }
.am-search:hover { border-color: var(--accent-ink, #066E6B); background: var(--surface-2, #F6F9FB); color: var(--navy, #1A2332); }
.am-kbd { font: 600 0.74rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; padding: 2px 6px; border-radius: 6px; background: var(--surface-2, #F6F9FB); border: 1px solid var(--line, #E4EBF2); color: var(--ink-2, #4A586B); white-space: nowrap; }
.am-search-mini { display: none !important; }
.am-login, .am-cta .logout {
  display: inline-flex; align-items: center; min-height: 40px; padding: 6px 10px; border-radius: 8px;
  font-weight: 600; font-size: 0.94rem; color: var(--navy, #1A2332);
}
.am-login:hover { color: var(--accent-ink, #066E6B); background: var(--surface-2, #F6F9FB); }
.am-login.is-current { background: var(--accent-soft, #E7F8F8); color: var(--accent-ink, #066E6B); }
.am-btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 16px;
  background: var(--accent, #0ABFBC); color: var(--navy, #1A2332); border-radius: 8px;
  font-family: "Sora", system-ui, sans-serif; font-weight: 700; font-size: 0.86rem; white-space: nowrap;
  transition: background var(--d-fast, 120ms) ease;
}
.am-btn:hover { background: #25d9d6; }
.am-btn.is-current { box-shadow: inset 0 0 0 2px var(--navy, #1A2332); }
.am-cta .logout { border: 1px solid var(--line-strong, #8795A8); background: #fff; cursor: pointer; font-family: inherit; }

.am-burger {
  display: none; width: 44px; height: 44px; border: 1px solid var(--line-strong, #8795A8);
  border-radius: 8px; background: #fff; cursor: pointer; padding: 0; align-items: center; justify-content: center;
}
.am-burger-bars { display: block; width: 18px; }
.am-burger-bars i { display: block; height: 2px; margin: 4px 0; background: var(--navy, #1A2332); transition: transform var(--d-base, 200ms) ease, opacity var(--d-base, 200ms) ease; }
.am-burger[aria-expanded="true"] i:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.am-burger[aria-expanded="true"] i:nth-child(2) { opacity: 0; }
.am-burger[aria-expanded="true"] i:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Tight desktops: keep the search as icon + shortcut only. */
@media (max-width: 1280px) {
  .am-search-label { display: none; }
  .am-nav .am-item > a, .am-trigger { padding: 6px 8px; }
}

/* Full-screen drawer */
@media (max-width: 1100px) {
  .am-brand { margin-right: auto; }
  .am-burger { display: inline-flex; }
  html.am-js .am-search-mini { display: inline-flex !important; width: 44px; height: 44px; justify-content: center; padding: 0; }
  .am-cta .am-search { display: none !important; }
  .am-drawer {
    position: fixed; left: 0; right: 0; top: var(--am-header); bottom: 0; z-index: 55;
    display: block; flex: none; padding: 8px 16px 32px; background: #fff; overflow-y: auto; overscroll-behavior: contain;
    visibility: hidden; opacity: 0; transform: translateY(-8px);
    transition: opacity 200ms ease, transform 200ms ease, visibility 0s linear 200ms;
  }
  .am-drawer.is-open { visibility: visible; opacity: 1; transform: none; transition: opacity 200ms ease, transform 200ms ease; }
  html.am-lock { overflow: hidden; }
  .am-list { display: block; }
  .am-item { border-bottom: 1px solid var(--line, #E4EBF2); }
  .am-nav .am-item > a, .am-trigger { width: 100%; min-height: 52px; padding: 10px 6px; font-size: 1.1rem; justify-content: space-between; border-radius: 0; box-shadow: none; }
  .am-nav .am-item > a.is-current, .am-trigger.is-section { background: var(--accent-soft, #E7F8F8); box-shadow: none; border-radius: 0; }
  .am-panel {
    position: static; border: 0; box-shadow: none; border-radius: 0; background: transparent; min-width: 0; padding: 0 0 10px 8px;
    visibility: visible; opacity: 1; transform: none; pointer-events: auto; transition: none; display: none;
  }
  .am-panel.is-open { display: block; }
  .am-panel a { padding: 11px 10px; }
  .am-cta { flex-direction: column; align-items: stretch; gap: 10px; margin-top: 18px; }
  .am-login { justify-content: center; border: 1px solid var(--line-strong, #8795A8); min-height: 48px; }
  .am-btn { min-height: 52px; }
  /* No JavaScript: show everything stacked under the header instead of a drawer. */
  html:not(.am-js) .am-header { height: auto; position: static; }
  html:not(.am-js) .am-burger { display: none; }
  html:not(.am-js) .am-header-inner { flex-wrap: wrap; padding: 10px 0; }
  html:not(.am-js) .am-drawer { position: static; visibility: visible; opacity: 1; transform: none; flex: 1 0 100%; padding: 0; }
  html:not(.am-js) .am-panel { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  .am-panel, .am-drawer, .am-chev, .am-burger-bars i, .am-pal, .am-pal-box { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------------------- Command palette */
.am-pal { position: fixed; inset: 0; z-index: 120; display: none; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; background: rgba(11, 15, 20, 0.52); }
.am-pal.is-open { display: flex; }
.am-pal-box {
  width: min(640px, 100%); max-height: min(560px, 76vh); display: flex; flex-direction: column; overflow: hidden;
  background: #fff; border-radius: 20px; box-shadow: 0 24px 56px rgba(26, 35, 50, 0.3);
  font-family: "DM Sans", system-ui, sans-serif; color: var(--navy, #1A2332);
}
.am-pal.is-open .am-pal-box { animation: am-pal-in 200ms var(--ease, cubic-bezier(0.2, 0.7, 0.2, 1)); }
@keyframes am-pal-in { from { opacity: 0; transform: translateY(8px) scale(0.985); } to { opacity: 1; transform: none; } }
.am-pal-top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line, #E4EBF2); color: var(--ink-2, #4A586B); }
.am-pal-input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: 400 1.05rem "DM Sans", system-ui, sans-serif; color: var(--navy, #1A2332); padding: 6px 0; min-height: 44px; }
.am-pal-input::placeholder { color: var(--ink-3, #5B6B80); }
.am-pal-close { border: 1px solid var(--line, #E4EBF2); background: var(--surface-2, #F6F9FB); border-radius: 6px; padding: 2px 8px; font: 600 0.74rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--ink-2, #4A586B); cursor: pointer; min-height: 28px; }
.am-pal-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.am-pal-grp { padding: 10px 10px 4px; font: 600 0.72rem "DM Sans", system-ui, sans-serif; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3, #5B6B80); }
.am-pal-item a { display: flex; align-items: center; gap: 12px; padding: 10px 10px; min-height: 44px; border-radius: 8px; text-decoration: none; color: inherit; }
.am-pal-item.is-active a, .am-pal-item a:hover { background: var(--accent-soft, #E7F8F8); }
.am-pal-item.is-active a { box-shadow: inset 3px 0 0 var(--accent-ink, #066E6B); }
.am-pal-t { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.am-pal-d { color: var(--ink-2, #4A586B); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.am-pal-t mark { background: none; color: var(--accent-ink, #066E6B); text-decoration: underline; text-underline-offset: 3px; }
.am-pal-type { flex: none; font: 600 0.72rem "DM Sans", system-ui, sans-serif; color: var(--ink-2, #4A586B); border: 1px solid var(--line, #E4EBF2); border-radius: 6px; padding: 1px 7px; white-space: nowrap; }
.am-pal-empty { padding: 28px 16px; text-align: center; color: var(--ink-2, #4A586B); }
.am-pal-foot { display: flex; gap: 16px; padding: 8px 16px; border-top: 1px solid var(--line, #E4EBF2); color: var(--ink-3, #5B6B80); font-size: 0.8rem; background: var(--surface-2, #F6F9FB); }
.am-pal-foot kbd { font: 600 0.72rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; border: 1px solid var(--line, #E4EBF2); border-radius: 4px; padding: 0 5px; background: #fff; }
@media (max-width: 640px) { .am-pal { padding-top: 8px; } .am-pal-d { display: none; } .am-pal-foot { display: none; } }

/* ---------------------------------------------------------------- Footer */
.am-footer { background: var(--navy, #1A2332); color: rgba(255, 255, 255, 0.86); padding: 28px 0 12px; font-family: "DM Sans", system-ui, sans-serif; font-size: 0.88rem; line-height: 1.4; }
.am-wrap { width: min(1240px, calc(100% - 32px)); margin: 0 auto; }
.am-foot-grid { display: grid; grid-template-columns: 1.3fr 1fr 2.2fr 0.9fr 0.9fr; gap: 20px 28px; }
.am-footer h2 { margin: 0 0 6px; font: 700 0.74rem "Sora", system-ui, sans-serif; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(255, 255, 255, 0.72); }
.am-footer h2.am-foot-gap { margin-top: 22px; }
.am-footer a { display: block; padding: 1px 0; color: rgba(255, 255, 255, 0.92); text-decoration: none; }
.am-footer a:hover { color: var(--accent, #0ABFBC); text-decoration: underline; }
.am-footer a.am-foot-more { margin-top: 0; color: var(--accent, #0ABFBC); font-weight: 600; }
.am-footer p { margin: 0; color: rgba(255, 255, 255, 0.8); }
.am-footer address { font-style: normal; margin-top: 8px; }
.am-foot-cols { columns: 2; column-gap: 20px; } .am-foot-cols a { break-inside: avoid; }
.am-foot-brand { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: #fff; font-family: "Sora", system-ui, sans-serif; font-weight: 700; }
.am-foot-brand img { width: 24px; height: 24px; }
.am-foot-about > p { max-width: 34ch; }
.am-legal-line { margin-top: 16px !important; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, 0.14); color: rgba(255, 255, 255, 0.74) !important; font-size: 0.88rem; }
@media (max-width: 1100px) { .am-foot-grid { grid-template-columns: 1fr 1fr 1fr; } .am-foot-about, .am-foot-bp { grid-column: 1 / -1; } }
@media (max-width: 640px) { .am-foot-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 400px) { .am-foot-grid { grid-template-columns: 1fr; } }
