/* ============================================
   ARKSPAN — SITE CHROME
   Single-row Tesla header, banded global footer.
   ============================================ */

/* ============================================
   HEADER
   ============================================ */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition-base), border-color var(--transition-base),
    box-shadow var(--transition-base);
}

/* Over a media panel the bar floats and the ink flips to white */
.site-header.is-transparent {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

.nav-bar {
  height: var(--header-height);
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: 0 clamp(1rem, 2.5vw, 2rem);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-4);
}

/* ---------- Wordmark: A R K S P A N (glyph retired pending final logo) ---------- */
.nav-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  justify-self: start;
  min-width: 0;
}
.menu-btn {
  display: none; /* desktop nav is always visible — no hamburger */
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-4);
  margin-left: -4px;
  background: var(--bg-tertiary);
  border: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  transition: background var(--transition-fast);
}
.site-header.is-transparent .menu-btn {
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.menu-btn:active {
  background: var(--border-light);
}

.brand {
  display: inline-flex;
  align-items: center;
  color: var(--text-primary);
  flex-shrink: 0;
}
.brand__text {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-primary);
  white-space: nowrap;
}

/* ---------- Primary nav ---------- */
.header-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  justify-self: center;
}
.nav-link {
  padding: 7px var(--space-4);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-full);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.nav-link:hover {
  background: var(--bg-tertiary);
}
.nav-link.active,
.nav-dropdown:hover > .nav-link {
  background: var(--bg-tertiary);
  font-weight: 600;
}
.nav-link.active {
  color: var(--accent);
}

/* ---------- Mega menu ---------- */
.nav-dropdown {
  position: relative;
  display: flex;
  align-items: center;
}
.mega {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  width: min(980px, 88vw);
  background: var(--bg-primary);
  border-top: 1px solid var(--border-light);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.12);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-fast), transform var(--transition-fast), visibility var(--transition-fast);
  z-index: 30;
}
.nav-dropdown:hover .mega,
.nav-dropdown:focus-within .mega {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
.mega__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
}
.mega--slim .mega__inner {
  grid-template-columns: 1fr;
}
.mega__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(170px, 100%), 1fr));
  gap: var(--space-5);
  padding: var(--space-8) var(--space-6);
  min-height: 120px;
}
.mega__loading {
  grid-column: 1 / -1;
  color: var(--text-muted);
  font-size: var(--text-sm);
}
.mega__tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-primary);
  padding: var(--space-3);
  margin: calc(var(--space-3) * -1);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}
.mega__tile:hover {
  background: var(--bg-tertiary);
}
.mega__visual {
  height: 92px;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}
.mega__visual--abstract {
  background: linear-gradient(135deg, var(--bg-tertiary), var(--accent-muted));
}
.mega__name {
  font-size: var(--text-base);
  font-weight: 600;
  text-align: center;
}
.mega__tile--bare {
  padding: var(--space-4) 0;
}
.mega__links {
  display: flex;
  justify-content: center;
  gap: var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.mega__links em {
  font-style: normal;
  border-bottom: 1px solid var(--border-dark);
  padding-bottom: 1px;
}
.mega__tile:hover .mega__links em {
  border-bottom-color: var(--text-primary);
}

/* Right rail, separated by a vertical rule — Tesla's secondary column */
.mega__rail {
  border-left: 1px solid var(--border-light);
  padding: var(--space-6) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.mega__rail a {
  font-size: var(--text-sm);
  color: var(--text-primary);
  padding: 7px 0;
}
.mega__rail a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.mega__rail--wide {
  border-left: none;
}

/* ---------- Utilities ---------- */
.header-utilities {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  justify-self: end;
}
.nav-utility {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: var(--tracking-nav);
  text-transform: uppercase;
  color: var(--text-secondary);
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: var(--radius-full);
}
.nav-utility:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition-fast);
}
.icon-btn:hover {
  color: var(--text-primary);
}

.mobile-toggle {
  display: none;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  flex-shrink: 0;
}
.mobile-toggle svg {
  pointer-events: none;
}

/* ============================================
   MENU SHEET — rounded panel, drill-down views
   ============================================ */
.nav-sheet {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: var(--bg-primary);
  border-radius: 22px 22px 0 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateY(100%);
  visibility: hidden;
  transition: transform 0.36s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.36s;
  padding-bottom: calc(var(--space-12) + env(safe-area-inset-bottom, 0px));
}
.nav-sheet.open {
  transform: translateY(0);
  visibility: visible;
}
.nav-sheet__panel {
  padding: 0 clamp(1.25rem, 5vw, 2.5rem);
  max-width: 720px;
  margin: 0 auto;
}
.nav-sheet__head {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) 0 var(--space-4);
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 2;
}
.nav-sheet__title {
  font-size: var(--text-lg);
  font-weight: 600;
  text-align: center;
  color: var(--text-primary);
}
.sheet-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: var(--radius-full);
}
.sheet-btn:hover {
  background: var(--bg-tertiary);
}
.nav-sheet__close {
  justify-self: end;
}

/* Root list — oversized rows with a right chevron */
.sheet-list {
  list-style: none;
  margin: 0;
  padding: var(--space-2) 0 0;
}
.sheet-list > li {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sheet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  width: 100%;
  padding: var(--space-4) 0;
  font-family: var(--font-sans);
  font-size: clamp(1.4rem, 5.4vw, 1.85rem);
  font-weight: 500;
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  text-align: left;
}
.sheet-row:hover {
  color: var(--accent);
}
.sheet-row svg {
  flex-shrink: 0;
  opacity: 0.5;
}

/* Section view — image left, name + underlined links right */
.sheet-product {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) 0;
}
.sheet-product__visual {
  aspect-ratio: 4 / 3;
  background-size: cover;
  background-position: center;
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}
.sheet-product__visual--abstract {
  background: linear-gradient(135deg, var(--bg-tertiary), var(--accent-muted));
}
.sheet-product__name {
  font-size: var(--text-xl);
  font-weight: 600;
  margin-bottom: var(--space-3);
  color: var(--text-primary);
}
.sheet-product__links {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: var(--text-base);
}
.sheet-product__links a {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.sheet-product__links a:hover {
  color: var(--accent);
}
.sheet-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-8) 0 0;
}
.sheet-link {
  display: block;
  width: 100%;
  padding: var(--space-4) 0;
  font-family: var(--font-sans);
  font-size: clamp(1.4rem, 5.4vw, 1.85rem);
  font-weight: 500;
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  text-align: left;
}
.sheet-link:hover {
  color: var(--accent);
}
body.sheet-open {
  overflow: hidden;
}

/* The bar must outrank the overlay so the brand + close stay reachable */
.nav-bar {
  position: relative;
  z-index: 20;
}

/* ============================================
   FOOTER — banded global footer
   ============================================ */
.site-footer {
  background: var(--bg-primary);
  color: var(--text-secondary);
  border-top: 1px solid var(--border-light);
}

/* --- Reveal control: the footer is obviously collapsible --- */
.footer-reveal {
  border-top: 1px solid var(--border-light);
}
.footer-reveal__bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: var(--space-5);
  padding-bottom: var(--space-5);
}
.footer-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--bg-primary);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.footer-toggle:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-primary);
}
.footer-toggle__label {
  font-weight: 600;
}
.footer-toggle__hint {
  color: var(--text-muted);
  border-left: 1px solid var(--border);
  padding-left: var(--space-3);
}
.footer-toggle svg {
  transition: transform var(--transition-base);
}
.site-footer.is-open .footer-toggle svg {
  transform: rotate(180deg);
}

/* Collapse without measuring: 0fr -> 1fr animates cleanly */
.footer-body-wrap {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows var(--transition-base);
}
.site-footer:not(.is-open) .footer-body-wrap {
  grid-template-rows: 0fr;
}
.footer-body-wrap > .footer-body {
  overflow: hidden;
  min-height: 0;
}

/* --- Main band --- */
.footer-main {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) repeat(4, minmax(0, 1fr));
  gap: clamp(1.5rem, 4vw, 4rem);
  /* longhand only — this element also carries .container's side gutters */
  padding-top: clamp(3rem, 6vw, 5rem);
  padding-bottom: clamp(2rem, 4vw, 3rem);
}

.footer-brand .brand {
  margin-bottom: var(--space-4);
}
.footer-brand__about {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 34ch;
  margin-bottom: var(--space-5);
}
.footer-social {
  display: flex;
  gap: var(--space-4);
}
.footer-social a {
  color: var(--text-muted);
  display: inline-flex;
  transition: color var(--transition-fast);
}
.footer-social a:hover {
  color: var(--text-primary);
}

.footer-col h5 {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-nav);
  text-transform: uppercase;
  color: var(--text-primary);
  margin-bottom: var(--space-4);
}
.footer-col a {
  display: block;
  font-size: var(--text-sm);
  color: var(--text-muted);
  padding: 5px 0;
  transition: color var(--transition-fast);
}
/* Long labels must wrap, never widen the track */
.footer-col a,
.footer-legal__links a,
.footer-legal__row,
.nav-link,
.nav-utility,
.footer-brand__about {
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
}

.footer-col a:hover {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* --- Legal band --- */
.footer-legal {
  border-top: 1px solid var(--border-light);
  padding: var(--space-6) 0 calc(var(--space-8) + env(safe-area-inset-bottom, 0px));
}
.footer-legal__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-align: center;
}
.footer-legal__links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
}
.footer-legal a:hover {
  color: var(--text-primary);
}

.staff-portal-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-nav);
  text-transform: uppercase;
  color: var(--text-primary);
  margin-top: var(--space-5);
}
.staff-portal-cta:hover {
  color: var(--accent);
}

/* ============================================
   BACK TO TOP
   ============================================ */
.back-to-top {
  position: fixed;
  bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
  right: var(--space-6);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: all var(--transition-base);
  z-index: 50;
}
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.back-to-top:hover {
  background: var(--accent);
}
/* Fades away once the reader stops scrolling */
.back-to-top.is-idle {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);
}

/* ============================================
   SEARCH OVERLAY
   ============================================ */
.search-overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 18vh;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}
.search-overlay.active {
  opacity: 1;
  visibility: visible;
}
.search-box {
  background: var(--bg-primary);
  width: 92%;
  max-width: 600px;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
}
.search-box input {
  width: 100%;
  padding: var(--space-6);
  font-size: var(--text-xl);
  font-family: var(--font-sans);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
}
.search-box input:focus {
  outline: none;
}
.search-results {
  max-height: 340px;
  overflow-y: auto;
  padding: var(--space-2) 0;
}
.search-results a {
  display: block;
  padding: var(--space-3) var(--space-6);
  color: var(--text-primary);
  font-size: var(--text-base);
}
.search-results a:hover {
  background: var(--bg-tertiary);
}
.search-results .empty {
  padding: var(--space-8);
  text-align: center;
  color: var(--text-muted);
}

/* ============================================
   RESPONSIVE FOOTER
   ============================================ */
@media (max-width: 1024px) {
  .footer-main {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-8);
  }
  .footer-brand {
    grid-column: 1 / -1;
  }
}

/* Mobile: wordmark left, "Menu" pill right, utility icons tucked into the sheet */
@media (max-width: 1080px) {
  .nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
  }
  .header-nav {
    display: none;
  }
  .nav-left {
    flex: 1;
  }
  .header-utilities {
    gap: var(--space-1);
  }
  .header-utilities .icon-btn {
    display: none;
  }
  .menu-btn {
    display: inline-flex;
  }
  /* Never trap the fixed sheet inside a backdrop-filter containing block */
  .site-header.is-transparent {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

@media (max-width: 768px) {
  /* Mobile: the whole legal strip centres as one block */
  .footer-legal__row {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: var(--space-3);
    padding-bottom: var(--space-2);
  }
  .footer-legal__row > span {
    text-align: center;
    max-width: 34ch;
  }
  .footer-legal__links {
    justify-content: center;
    gap: var(--space-2) var(--space-5);
    row-gap: var(--space-2);
  }
  .footer-reveal__bar {
    padding-top: var(--space-4);
    padding-bottom: var(--space-4);
  }
  .footer-toggle {
    width: 100%;
    justify-content: center;
  }
  /* Two columns of links keeps the collapsed footer from being a tall stack */
  .site-footer.is-open .footer-main {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-6) var(--space-4);
    /* longhand — this element also carries .container's side gutters */
    padding-top: var(--space-6);
    padding-bottom: var(--space-6);
  }
  .site-footer.is-open .footer-brand {
    grid-column: 1 / -1;
  }
}

@media (max-width: 480px) {
  .footer-main {
    grid-template-columns: 1fr;
  }
}