/* ============================================================
   HS Mega Menu — ported from prototype (prototypes/mega-menu.html).
   Owns: hamburger button (Ophiuchus sigil), full-screen mega overlay,
   matrix-rain transitions, per-button hover matrix, flux-gradient
   borders. Reuses the theme's existing --hs-cyan / --hs-pink / --hs-ease
   tokens from style.css; only adds tokens the mega menu needs on top.
   ============================================================ */

@property --hs-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: true;
}

:root {
  --hs-cyan-soft:  rgba(0, 234, 255, .18);
  --hs-pink-soft:  rgba(255, 47, 211, .16);
  --hs-hot:        #eafcff;
  --hs-soft:       rgba(217, 252, 255, .78);
  --hs-mm-mute:    rgba(217, 252, 255, .55);
  --hs-spd:        .45s;
  --hs-angle:      0deg;
  animation: hs-hueorbit 2.6s linear infinite;
}

@keyframes hs-hueorbit { to { --hs-angle: 360deg; } }
@keyframes hs-caret    { 50% { opacity: 0; } }

/* ---------- hamburger (menu button in site header) ---------- */
.hamburger {
  position: relative;
  width: 56px; height: 56px;
  border: 1px solid rgba(255, 255, 255, .5); border-radius: 14px;
  background: rgba(10, 2, 20, .72); cursor: pointer;
  display: grid; place-items: center; padding: 0;
  overflow: hidden;
  isolation: isolate;
  transition: box-shadow .25s ease, border-color .25s ease;
}
.hamburger.hover-matrix { border-color: transparent; box-shadow: 0 0 32px rgba(0, 234, 255, .4); }
.hamburger > .hb-sigil {
  position: relative;
  z-index: 3;
  width: 34px; height: 34px;
  display: block;
  color: #fff;
  transition: opacity .08s ease-out;
}
.hamburger.hover-matrix > .hb-sigil { opacity: 0; }

/* ============================================================
   Overlay — drop-from-above, covers the sticky site header (z: 110 > header z:100)
   ============================================================ */
.mega {
  position: fixed; inset: 0; z-index: 110;
  opacity: 0;
  transform: translateY(-12%);
  filter: blur(4px);
  transition:
    transform .6s var(--hs-ease),
    opacity .3s ease,
    filter .4s ease;
  background:
    radial-gradient(ellipse 140% 100% at 50% 40%, rgba(0, 234, 255, .07), transparent 75%),
    linear-gradient(180deg, #060a13 0%, #020407 100%);
  overflow: hidden;
  pointer-events: none;
}

.mega-topbar {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 10;
  height: 76px;
  padding: 0 clamp(18px, 3vw, 32px);
  display: flex; align-items: center; justify-content: space-between;
  gap: clamp(12px, 2vw, 24px);
  background: transparent;
  pointer-events: none;
}
.mega-topbar > * { pointer-events: auto; }

.mega-topbar-left {
  display: flex; align-items: center;
  gap: clamp(10px, 1.4vw, 18px);
  min-width: 0;
  flex: 1 1 auto;
  opacity: 0;
  transform: translateX(-14px);
  filter: blur(3px);
  transition:
    opacity .42s var(--hs-ease),
    transform .42s var(--hs-ease),
    filter .42s ease;
}
.mega.open .mega-topbar-left {
  opacity: 1;
  transform: translateX(0);
  filter: blur(0);
  transition-delay: .36s;
}

.mega-griffin-icon {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  color: var(--hs-hot);
  filter: drop-shadow(0 0 6px var(--hs-cyan)) drop-shadow(0 0 14px rgba(0, 234, 255, .5));
  flex-shrink: 0;
}
.mega-griffin-icon svg { width: 100%; height: 100%; display: block; fill: currentColor; }

.mega-path {
  color: var(--hs-cyan);
  font-family: "Courier New", ui-monospace, monospace;
  font-size: clamp(20px, 2.2vw, 30px);
  line-height: 56px;
  letter-spacing: .14em;
  text-transform: lowercase;
  text-shadow: 0 0 8px var(--hs-cyan-soft), 0 0 14px rgba(0, 234, 255, .3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.mega-path::before { content: ">_ "; color: var(--hs-hot); margin-right: 2px; text-shadow: 0 0 6px var(--hs-cyan); }
.mega-path::after {
  content: "\25AE"; /* ▮ */
  margin-left: 4px;
  color: var(--hs-hot);
  animation: hs-caret 1s steps(2, end) infinite;
}

.mega-controls { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.back-button {
  position: relative;
  width: 56px; height: 56px;
  border: 1px solid rgba(255, 255, 255, .5); border-radius: 14px;
  background: rgba(10, 2, 20, .72);
  color: var(--hs-cyan);
  cursor: pointer;
  display: grid; place-items: center; padding: 0;
  box-shadow: 0 0 24px rgba(0, 234, 255, .22);
  opacity: 0;
  transform: translateX(14px) scale(.9);
  pointer-events: none;
  overflow: hidden;
  isolation: isolate;
  transition:
    opacity .32s var(--hs-ease),
    transform .32s var(--hs-ease),
    color .25s ease,
    border-color .25s ease,
    box-shadow .25s ease;
}
.back-button svg {
  position: relative;
  z-index: 3;
  width: 29px; height: 29px;
  display: block;
  color: var(--hs-cyan);
  filter: drop-shadow(0 0 4px var(--hs-cyan)) drop-shadow(0 0 10px rgba(0, 234, 255, .55));
  transition: opacity .08s ease-out;
}
.back-button.hover-matrix svg { opacity: 0; }
.back-button.is-visible { opacity: 1; transform: translateX(0) scale(1); pointer-events: auto; }
.back-button.hover-matrix {
  color: var(--hs-hot);
  border-color: transparent;
  box-shadow: 0 0 32px rgba(0, 234, 255, .4);
}

.close-x {
  position: relative;
  width: 56px; height: 56px;
  border: 1px solid rgba(255, 255, 255, .5); border-radius: 14px;
  background: rgba(10, 2, 20, .72);
  cursor: pointer;
  display: grid; place-items: center; padding: 0;
  box-shadow: 0 0 24px rgba(0, 234, 255, .22);
  overflow: hidden;
  isolation: isolate;
  opacity: 0;
  transition:
    box-shadow .25s ease,
    border-color .25s ease,
    opacity .25s ease;
}
.mega.open .close-x {
  opacity: 1;
  transition-delay: 0s, 0s, .15s;
}
.close-x.hover-matrix { border-color: transparent; box-shadow: 0 0 32px rgba(0, 234, 255, .4); }
.close-x svg {
  position: relative;
  z-index: 3;
  width: 29px; height: 29px;
  display: block;
  color: var(--hs-pink);
  filter:
    drop-shadow(0 0 4px var(--hs-pink))
    drop-shadow(0 0 10px rgba(255, 47, 211, .55));
  transition: opacity .08s ease-out;
}
.close-x.hover-matrix svg { opacity: 0; }

/* Shared flux-ring border for the matrix-portal family (hamburger, cart,
   close-x, back-button, the griffin brand button, the header pillar links,
   the footer service cards, and the Shadow Core signature — the signature
   uses :hover instead of the JS-driven .hover-matrix since it skips the
   matrix-rain effect) */
.hamburger::before,
.close-x::before,
.back-button::before,
.hs-cart-btn::before,
.hs-brand::before,
.hs-pillars-desktop .hs-pillars a::before,
.hs-synthwave .service::before,
.hs-synthwave .signature::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  padding: 3px;
  background: conic-gradient(from var(--hs-angle), var(--hs-cyan), var(--hs-pink), #a855f7, var(--hs-cyan));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  transition: opacity .2s ease;
}
.hamburger.hover-matrix::before,
.close-x.hover-matrix::before,
.back-button.hover-matrix::before,
.hs-cart-btn.hover-matrix::before,
.hs-brand.hover-matrix::before,
.hs-pillars-desktop .hs-pillars a.hover-matrix::before,
.hs-synthwave .service.hover-matrix::before,
.hs-synthwave .signature:hover::before { opacity: 1; }
.hs-cart-btn.hover-matrix { border-color: transparent; box-shadow: 0 0 32px rgba(0, 234, 255, .4); }

/* Brand button override — replace the rectangular padding-mask with a
   shield-shaped ring mask (#hs-shield-ring-mask in header.php) so the conic
   flux-ring traces the heater shield outline instead of a rectangle. */
.hs-brand::before {
  padding: 0;
  border-radius: 0;
  -webkit-mask: url(#hs-shield-ring-mask);
          mask: url(#hs-shield-ring-mask);
  -webkit-mask-composite: source-over;
          mask-composite: add;
}

/* Hover-matrix canvas inside each portal button */
.btn-matrix-canvas {
  position: absolute; inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  z-index: 1;
  transition: opacity .15s ease;
}
.hover-matrix .btn-matrix-canvas { opacity: 1; }

.mega.open {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
  pointer-events: auto;
}

/* soft scanlines over the mega bg */
.mega::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 8;
  opacity: .22;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,0) 0 2px, rgba(255,255,255,.018) 3px, rgba(255,255,255,0) 4px);
}

/* ============================================================
   SHELL — full-width grid.
   Main (home):  3 cols desktop/tablet, 1 col mobile.
   Sub-view:     2 cols everywhere.
   ============================================================ */
.shell {
  position: relative; z-index: 5;
  height: 100vh;
  padding: 84px clamp(18px, 3vw, 40px) clamp(20px, 2.5vw, 36px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: clamp(14px, 1.6vw, 24px);
  box-sizing: border-box;
}

/* Sub-view override: 2-col (pillars only, bot-row hidden) */
.mega.sub-view .shell { grid-template-columns: repeat(2, 1fr); }

/* top-row and bot-row are transparent grid wrappers — their children
   flatten into the shell's grid so all cards share one flow. */
.top-row, .bot-row { display: contents; }

.mega.sub-view .bot-row { display: none; }

.mega.exiting .mega-topbar-left,
.mega.exiting .back-button,
.mega.exiting .close-x {
  opacity: 0 !important;
  transition: opacity .08s ease-out !important;
  transition-delay: 0s !important;
}

/* ============================================================
   CARD — FX stack
   ============================================================ */
.nav-card {
  --r: 18px;
  --fillTop: color-mix(in srgb, var(--hs-cyan) 25%, #000);
  --fillBot: color-mix(in srgb, var(--hs-cyan) 15%, #000);

  position: relative;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  padding: clamp(22px, 2.6vw, 40px);
  gap: 16px;
  text-align: center;
  text-decoration: none;
  color: var(--hs-hot);
  background: #000;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: var(--r);
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  transform: translateY(14px);
  opacity: 0;
  transition:
    transform .08s ease-out,
    opacity .08s ease-out,
    border-color .22s ease,
    box-shadow .25s ease;
}

.nav-card::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  padding: 3px;
  background: conic-gradient(from var(--hs-angle), var(--hs-cyan), var(--hs-pink), #a855f7, var(--hs-cyan));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  transition: opacity .3s ease;
}

.card-fill {
  position: absolute; inset: 0;
  border-radius: inherit;
  z-index: 0;
  background: linear-gradient(180deg, var(--fillTop), var(--fillBot));
  transform-origin: left center;
  transform: scaleX(0);
  opacity: .55;
  pointer-events: none;
  transition: transform var(--hs-spd) var(--hs-ease), opacity var(--hs-spd) var(--hs-ease);
}

.nav-card > .card-title,
.nav-card > .card-hint { position: relative; z-index: 4; }

.nav-card.is-live {
  opacity: 1;
  transform: translateY(0);
  transition:
    transform .4s ease-out,
    opacity .4s ease-out,
    border-color .22s ease,
    box-shadow .25s ease;
}

.top-row .nav-card.is-live:nth-child(1) { transition-delay:   0ms; }
.top-row .nav-card.is-live:nth-child(2) { transition-delay:  40ms; }
.top-row .nav-card.is-live:nth-child(3) { transition-delay:  80ms; }
.bot-row .nav-card.is-live:nth-child(1) { transition-delay: 140ms; }
.bot-row .nav-card.is-live:nth-child(2) { transition-delay: 190ms; }
.bot-row .nav-card.is-live:nth-child(3) { transition-delay: 240ms; }

.nav-card:hover { border-color: transparent; text-decoration: none; }
.nav-card:hover::before { opacity: 1; }
.nav-card:focus-visible { outline: none; border-color: transparent; text-decoration: none; }
.nav-card:focus-visible::before { opacity: 1; }

.card-title {
  display: block;
  font-family: "Vonca", "Impact", "Bebas Neue", "Arial Black", sans-serif;
  font-size: clamp(30px, 3.6vw, 60px);
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--hs-hot);
  line-height: .95;
  text-shadow:
    0 0 6px var(--hs-cyan),
    0 0 20px var(--hs-cyan),
    0 0 44px rgba(0, 234, 255, .5);
  transition: text-shadow .3s ease;
}

/* Hints removed from the menu — titles only. */
.card-hint { display: none; }

.nav-card:hover .card-title {
  text-shadow:
    0 0 8px var(--hs-cyan),
    0 0 28px var(--hs-cyan),
    0 0 60px rgba(0, 234, 255, .75);
}

/* bot-row cards share all styling with top-row — same square, same heading weight. */

/* ============================================================
   Matrix rain transition layer (fixed full-screen canvas)
   ============================================================ */
.matrix-transition {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 120;
  display: none;
}
.matrix-transition.is-active { display: block; }
.matrix-transition canvas {
  position: absolute; inset: 0;
  opacity: 0;
  transition: opacity .3s ease;
  filter: drop-shadow(0 0 6px rgba(0, 234, 255, .45));
}
.matrix-transition .matrix-fade {
  position: absolute; inset: 0;
  background: #000;
  opacity: 0;
  transition: opacity .3s ease;
}

/* Body lock while mega is open (JS also sets overflow:hidden) */
body.hs-mega-open { overflow: hidden; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 767px) {
  .shell {
    padding: 88px 14px 18px;
    gap: 12px;
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    grid-auto-rows: auto;
    overflow-y: auto;
  }
  .mega.sub-view .shell {
    grid-template-columns: 1fr;
    grid-auto-rows: 1fr;
    height: 100vh;
    min-height: 0;
  }
  /* Desktop stretches cards via grid-auto-rows: 1fr. Mobile can't on the main
     view — 1-col wrap would either squish (1fr) or overflow awkwardly, so we
     lock 4:2 shape there. Sub-view (2 cards) DOES stretch — fills viewport. */
  .nav-card { aspect-ratio: 4 / 2; }
  .mega.sub-view .nav-card { aspect-ratio: auto; }
  .mega-topbar { height: 64px; padding: 0 14px; }
  .back-button, .hamburger, .close-x { width: 48px; height: 48px; border-radius: 12px; }
  .mega-griffin-icon { width: 48px; height: 48px; }
  .mega-path { line-height: 48px; }

  .nav-card { padding: 18px; }
  .card-title { font-size: clamp(26px, 7.5vw, 44px); }
}

@media (prefers-reduced-motion: reduce) {
  :root { animation: none !important; }
  .mega { transition: opacity .2s ease !important; filter: none !important; }
  .nav-card::before { animation: none !important; }
  .matrix-transition { display: none !important; }
}
