/* ─────────────────────────────────────────────
   AMPACITIES · site chrome
   Topbar + megamenu + mobile drawer + footer
   Extracted from index.html for re-use on
   library / platform / standards pages.
   ───────────────────────────────────────────── */

/* ─────  Layout container  ───── */
.frame { max-width: 1480px; margin: 0 auto; padding: 0 56px; position: relative; z-index: 2; }
.rule  { height: 1px; background: var(--rule); width: 100%; }

/* ─────  Top bar  ───── */
.topbar {
  position: sticky; top: 0;
  z-index: 60;
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--rule);
  transition: background 0.9s;
  display: block;
  padding: 0;
}
.topbar-inner { position: relative; z-index: 2; }
.topbar-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 16px 56px;
  gap: 24px;
}
.brand {
  display: flex; align-items: center; gap: 14px;
  font-family: 'Antonio', sans-serif;
  font-weight: 500;
  font-size: 20px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  color: inherit;
  text-decoration: none;
}
.brand:hover .brand-mark { transform: rotate(45deg); border-color: var(--accent); }
.brand:hover .brand-mark::before, .brand:hover .brand-mark::after { background: var(--accent); }
.brand-mark {
  position: relative;
  width: 28px; height: 28px;
  border: 1px solid currentColor;
  transition: transform 0.65s cubic-bezier(.7,.05,.18,1), border-color 0.5s;
}
.brand-mark::before, .brand-mark::after {
  content: ''; position: absolute;
  background: currentColor;
  transition: background 0.5s;
}
.brand-mark::before { left: 50%; top: 4px; bottom: 4px; width: 1px; transform: translateX(-50%); }
.brand-mark::after  { top: 50%; left: 4px; right: 4px; height: 1px; transform: translateY(-50%); }
.brand-sub {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-size: 14px;
  letter-spacing: 0;
  color: var(--ink-mute);
  text-transform: none;
  margin-left: 2px;
}

.nav {
  display: flex; gap: 0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}
.nav-item { position: relative; padding: 0 18px; }
.nav-item + .nav-item::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  width: 2px; height: 2px;
  background: var(--ink-mute);
  transform: translateY(-50%);
  border-radius: 50%;
}
.nav-item > a, .nav-item > button {
  color: var(--ink-soft);
  text-decoration: none;
  position: relative;
  padding: 8px 0;
  display: inline-flex; align-items: center; gap: 8px;
  background: none; border: none;
  font: inherit;
  cursor: pointer;
  letter-spacing: inherit;
  text-transform: inherit;
  transition: color 0.4s;
}
.nav-item > a:hover, .nav-item > button:hover,
.nav-item.is-open > a, .nav-item.is-open > button { color: var(--ink); }
.nav-item > a::after, .nav-item > button::after {
  content: ''; position: absolute; bottom: 2px; left: 0;
  width: 0; height: 1px; background: var(--accent);
  transition: width 0.5s cubic-bezier(.7,.05,.18,1);
}
.nav-item > a:hover::after, .nav-item > button:hover::after,
.nav-item.is-open > a::after, .nav-item.is-open > button::after { width: 100%; }
.nav-item .chev {
  display: inline-block;
  width: 8px; height: 8px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 0.5s cubic-bezier(.7,.05,.18,1);
  opacity: 0.7;
}
.nav-item.is-open .chev { transform: rotate(-135deg) translate(-2px, -2px); }

/* ─────  Mega menu  ───── */
.megamenu {
  position: absolute;
  left: 0; right: 0; top: 100%;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--rule);
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.55s cubic-bezier(.7,.05,.18,1), border-color 0.4s;
  z-index: 70;
}
.megamenu.is-open { max-height: 540px; border-bottom-color: var(--rule); }
.megamenu-inner { padding: 0 56px; position: relative; }
.megamenu-panel {
  display: none;
  grid-template-columns: 1.1fr 3fr;
  gap: 64px;
  padding: 44px 0 48px;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.5s cubic-bezier(.7,.05,.18,1), transform 0.5s cubic-bezier(.7,.05,.18,1);
}
.megamenu-panel.is-active { display: grid; opacity: 1; transform: translateY(0); }
.mm-intro { display: flex; flex-direction: column; gap: 18px; border-right: 1px solid var(--rule); padding-right: 48px; }
.mm-intro .eyebrow { color: var(--ink-mute); font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; letter-spacing: 0.3em; text-transform: uppercase; }
.mm-intro h3 {
  font-family: 'Antonio', sans-serif;
  font-weight: 300;
  font-size: 64px;
  line-height: 0.9;
  letter-spacing: -0.018em;
  text-transform: uppercase;
}
.mm-intro h3 .strong { font-weight: 600; }
.mm-intro h3 .it {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
  text-transform: none;
  letter-spacing: 0;
}
.mm-intro p { font-size: 13.5px; color: var(--ink-soft); line-height: 1.6; max-width: 32ch; }
.mm-intro .mm-cta {
  margin-top: 6px;
  display: inline-flex; align-items: center; gap: 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  align-self: flex-start;
  position: relative;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--ink);
  transition: color 0.4s, border-color 0.4s;
}
.mm-intro .mm-cta:hover { color: var(--accent); border-color: var(--accent); }
.mm-intro .mm-cta .arr { font-family: 'Instrument Serif', serif; font-style: italic; font-size: 14px; }

.mm-cols { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; }
.mm-col { padding: 0 24px; border-right: 1px solid var(--rule); position: relative; }
.mm-col:first-child { padding-left: 0; }
.mm-col:last-child { border-right: none; padding-right: 0; }
.mm-col h5 {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 400;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 14px;
}
.mm-col h5 .n {
  color: var(--accent);
  font-style: italic;
  font-family: 'Instrument Serif', serif;
  font-size: 14px;
  letter-spacing: 0;
  margin-right: 4px;
}
.mm-col ul { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.mm-col a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-family: 'Antonio', sans-serif;
  font-weight: 400;
  font-size: 16px;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  padding: 4px 0;
  border-bottom: 1px dashed transparent;
  transition: color 0.35s, border-color 0.35s, transform 0.35s cubic-bezier(.7,.05,.18,1);
}
.mm-col a .ref {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9.5px;
  color: var(--ink-mute);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: color 0.35s;
}
.mm-col a:hover { color: var(--accent); transform: translateX(4px); border-bottom-color: var(--rule); }
.mm-col a:hover .ref { color: var(--accent); }
.mm-col a.feat {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  padding: 10px 12px;
  margin: -4px -12px;
}
.mm-col a.feat:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); transform: translateX(0); }
.mm-col .tag {
  display: inline-block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--accent);
  text-transform: uppercase;
  padding-top: 4px;
}

/* ─────  Utility cluster (right side of topbar)  ───── */
.utility {
  justify-self: end;
  display: flex; align-items: center; gap: 22px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.24em;
  color: var(--ink-mute);
  text-transform: uppercase;
}
.utility .live {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 6px 10px;
  border: 1px solid var(--rule);
  transition: border-color 0.5s, color 0.5s;
}
.utility .live:hover { border-color: var(--accent); color: var(--ink); }
.utility .live .ct { color: var(--ink); }
.live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--voltage);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--voltage) 18%, transparent);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.45; transform: scale(0.85); } }

/* ─────  Theme toggle  ───── */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 10px;
  cursor: pointer;
  background: none; border: none;
  color: inherit;
  font: inherit;
  user-select: none;
  padding: 4px;
}
.theme-track {
  position: relative;
  width: 60px; height: 26px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  transition: border-color 0.7s;
}
.theme-thumb {
  position: absolute; top: 1px; left: 1px;
  width: 22px; height: 22px;
  background: var(--ink);
  display: grid; place-items: center;
  transition: transform 0.7s cubic-bezier(.7,.05,.18,1), background 0.7s;
}
.theme-thumb svg { width: 12px; height: 12px; color: var(--bg); }
[data-theme="night"] .theme-thumb { transform: translateX(34px); background: var(--accent-bright); }
.theme-toggle .lbl {
  display: inline-flex; gap: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px; letter-spacing: 0.26em;
}
.theme-toggle .lbl span { transition: color 0.7s; }
.theme-toggle .lbl .on { color: var(--ink); }
.theme-toggle .lbl .off { color: var(--ink-mute); opacity: 0.5; }

/* ─────  Mobile toggle / drawer  ───── */
.mobile-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink);
  cursor: pointer;
  width: 44px; height: 44px;
  padding: 0;
  align-items: center; justify-content: center;
  transition: border-color 0.5s, color 0.5s;
}
.mobile-toggle:hover { border-color: var(--accent); color: var(--accent); }
.mt-bars { display: flex; flex-direction: column; gap: 5px; width: 18px; }
.mt-bars span {
  display: block; height: 1.5px; width: 100%;
  background: currentColor;
  transition: transform 0.4s cubic-bezier(.7,.05,.18,1), opacity 0.3s;
  transform-origin: center;
}
.mobile-toggle.is-active .mt-bars span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.mobile-toggle.is-active .mt-bars span:nth-child(2) { opacity: 0; }
.mobile-toggle.is-active .mt-bars span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

.mobile-drawer {
  position: fixed; inset: 0;
  z-index: 1000;
  pointer-events: none;
  visibility: hidden;
  transition: visibility 0.5s;
}
.mobile-drawer.is-open { pointer-events: auto; visibility: visible; transition: visibility 0s; }
.mobile-drawer-scrim {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--bg-deep) 86%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.45s cubic-bezier(.7,.05,.18,1);
}
.mobile-drawer.is-open .mobile-drawer-scrim { opacity: 1; }
.mobile-drawer-inner {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(420px, 92vw);
  background: var(--bg);
  border-left: 1px solid var(--rule);
  display: flex; flex-direction: column;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.5s cubic-bezier(.7,.05,.18,1);
}
.mobile-drawer.is-open .mobile-drawer-inner { transform: translateX(0); }
.mobile-drawer-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}
.mobile-drawer-head .eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.mobile-close {
  width: 44px; height: 44px;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink);
  cursor: pointer;
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-size: 26px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.5s, color 0.5s;
}
.mobile-close::before { content: '×'; }
.mobile-close:hover { border-color: var(--accent); color: var(--accent); }
.mobile-nav { flex: 1 1 auto; display: flex; flex-direction: column; }
.mobile-section { border-bottom: 1px solid var(--rule); }
.mobile-section > summary {
  list-style: none;
  cursor: pointer;
  padding: 18px 24px;
  display: flex; align-items: center; gap: 14px;
  min-height: 60px;
  font-family: 'Antonio', sans-serif;
  font-weight: 400;
  font-size: 22px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink);
  user-select: none;
}
.mobile-section > summary::-webkit-details-marker { display: none; }
.mobile-section > summary::marker { content: ''; }
.mobile-section .ms-roman {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-size: 18px;
  color: var(--accent);
  letter-spacing: 0;
  text-transform: none;
  width: 28px;
}
.mobile-section .ms-name { flex: 1; }
.mobile-section .ms-arr {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-size: 24px;
  color: var(--accent);
  transition: transform 0.4s cubic-bezier(.7,.05,.18,1);
  line-height: 1;
}
.mobile-section[open] > summary .ms-arr { transform: rotate(45deg); }
.mobile-section ul {
  list-style: none;
  display: flex; flex-direction: column;
  padding: 4px 24px 16px 66px;
}
.mobile-section ul li a {
  display: flex; align-items: center;
  padding: 12px 0;
  min-height: 44px;
  font-family: 'Manrope', sans-serif;
  font-size: 14.5px;
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: color 0.4s;
}
.mobile-section ul li:last-child a { border-bottom: none; }
.mobile-section ul li a:hover,
.mobile-section ul li a:focus { color: var(--accent); }
.mobile-drawer-foot {
  padding: 18px 24px;
  border-top: 1px solid var(--rule);
  flex-shrink: 0;
}
.mobile-drawer-foot .btn { width: 100%; min-width: 0; }

/* ─────  Btn primitive (used in mobile drawer footer)  ───── */
.btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 16px 28px;
  border: 1px solid var(--ink);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  transition: color 0.5s, border-color 0.5s;
  min-width: 240px;
}
.btn .arr { font-family: 'Instrument Serif', serif; font-style: italic; font-size: 16px; }

/* ─────  Site footer  ───── */
.site-footer {
  padding: 80px 56px 32px;
  border-top: 1px solid var(--rule);
  max-width: 1480px;
  margin: 60px auto 0;
}
.site-footer .footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 56px;
  padding-bottom: 80px;
}
.site-footer .foot-brand {
  font-family: 'Antonio', sans-serif;
  font-weight: 300;
  font-size: clamp(72px, 8vw, 128px);
  line-height: 0.86;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  padding-bottom: 22px;
}
.site-footer .foot-brand .strong { font-weight: 600; }
.site-footer .foot-brand .it { font-family: 'Instrument Serif', serif; font-style: italic; font-weight: 400; color: var(--accent); text-transform: none; }
.site-footer .foot-tag {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-size: 18px;
  color: var(--ink-soft);
  max-width: 36ch;
}
.site-footer .foot-col h5 {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.3em;
  color: var(--ink-mute);
  text-transform: uppercase;
  font-weight: 400;
  padding-bottom: 18px;
}
.site-footer .foot-col ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.site-footer .foot-col a, .site-footer .foot-col li {
  color: var(--ink);
  text-decoration: none;
  font-size: 14.5px;
  transition: color 0.4s;
}
.site-footer .foot-col a:hover { color: var(--accent); }
.site-footer .foot-base {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 32px;
  border-top: 1px solid var(--rule);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.site-footer .foot-parent {
  padding-top: 28px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ink-mute);
  display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: baseline;
}
.site-footer .foot-parent a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--rule); padding-bottom: 1px; transition: color 0.2s, border-color 0.2s; }
.site-footer .foot-parent a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.site-footer .foot-parent .it { font-family: 'Instrument Serif', serif; font-style: italic; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink-soft); }

/* ─────  Responsive (tablet ≤1200px)  ───── */
@media (max-width: 1200px) {
  .topbar-inner { padding: 14px 36px; grid-template-columns: 1fr auto; }
  .nav { display: none; }
  .mobile-toggle { display: inline-flex; }
  .megamenu { display: none; }
  .site-footer { padding: 60px 36px 32px; }
  .site-footer .footer-grid { grid-template-columns: 1fr; gap: 36px; }
}
@media (max-width: 720px) {
  .topbar-inner { padding: 12px 20px; gap: 16px; }
  .brand-sub { display: none; }
  .brand { font-size: 16px; gap: 10px; }
  .utility { gap: 12px; }
  .utility .live { display: none; }
  .site-footer { padding: 48px 20px 28px; }
  .site-footer .footer-grid { padding-bottom: 48px; }
  .site-footer .foot-base { flex-direction: column; gap: 12px; text-align: center; }
  .site-footer .foot-brand { font-size: clamp(48px, 14vw, 88px); }
}
