/* MECHAROGUE — chapter motion and persistent navigation. */
.masthead {
  position: fixed;
  z-index: 70;
  background: rgba(5, 14, 55, .91);
  border-bottom-color: rgba(255, 255, 255, .28);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 32px rgba(0, 8, 55, .12);
}

.header-tools .motion {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 59px;
  padding: 0 6px;
  border: 1px solid rgba(255, 255, 255, .28);
}
.motion .motion-state {
  font: 700 9px/1 var(--body);
  letter-spacing: .04em;
  white-space: nowrap;
}
.header-tools .motion:hover,
.header-tools .motion:focus-visible {
  background: white;
  color: var(--royal);
}
.desktop-nav a.active::after,
.desktop-nav a[aria-current="location"]::after { right: 0; }
.desktop-nav a.active,
.desktop-nav a[aria-current="location"] { color: white; }
.chapter-rail a.active i { box-shadow: 0 0 0 4px rgba(255, 255, 255, .12); }

/* These surfaces are driven together by the navigation controller. */
.chapter-transition {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 110;
  pointer-events: none;
  overflow: hidden;
  isolation: isolate;
}
.chapter-transition.is-active { display: block; }
.chapter-transition[hidden] { display: none !important; }
.frame-stage[aria-busy="true"]::after,
.combat-layout[aria-busy="true"]::after {
  content: '↻'; position: absolute; right: 12px; top: 12px; z-index: 4;
  width: 38px; height: 38px; display: grid; place-items: center;
  background: var(--ink); color: white; font-size: 26px; line-height: 1;
  animation: mecha-loading .75s linear infinite;
}
.combat-layout { position: relative; }
@keyframes mecha-loading { to { rotate: 360deg; } }
.chapter-transition .transition-slab {
  position: absolute;
  top: -25%;
  bottom: -25%;
  left: -20%;
  width: 140%;
  transform: translateX(-120%) skewX(-15deg);
  transform-origin: center;
  background: var(--blue);
  will-change: transform;
}
.chapter-transition .transition-slab:nth-child(2) { background: white; }
.chapter-transition .transition-slab:nth-child(3) { background: var(--ink); }
.chapter-transition .transition-label {
  position: absolute;
  z-index: 2;
  left: var(--gutter);
  right: var(--gutter);
  top: 50%;
  transform: translateY(-50%);
  color: white;
  opacity: 0;
}
.transition-label small {
  display: block;
  margin: 0 0 22px 5px;
  font: 700 10px/1.5 var(--body);
  text-transform: uppercase;
  letter-spacing: .26em;
  color: #becbef;
}
.transition-label b {
  display: block;
  width: fit-content;
  max-width: 100%;
  border-bottom: 8px solid white;
  padding: 0 20px 12px 0;
  font: italic 800 clamp(70px, 12.8vw, 220px)/.88 var(--display);
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
}

.chapter-hud {
  position: fixed;
  z-index: 35;
  left: 25px;
  bottom: 22px;
  display: grid;
  gap: 3px;
  min-width: 145px;
  max-width: min(300px, calc(100vw - 50px));
  padding: 12px 28px 13px 16px;
  border-left: 3px solid white;
  color: white;
  background: rgba(5, 14, 55, .95);
  box-shadow: 7px 7px 0 rgba(0, 20, 171, .28);
  text-decoration: none;
  transition: translate .2s, background .2s, opacity .2s;
}
.chapter-hud::after {
  content: '\2198';
  position: absolute;
  right: 10px;
  bottom: 14px;
  font-size: 19px;
  line-height: 1;
}
.chapter-hud small {
  font: 700 7px/1.5 var(--body);
  letter-spacing: .17em;
  text-transform: uppercase;
  color: #becbef;
}
.chapter-hud b {
  font: italic 800 23px/1 var(--display);
  letter-spacing: .01em;
}
.chapter-hud:hover { background: var(--royal); translate: 3px -3px; }
.chapter-hud[hidden] { display: none; }
/* Leave the first screen's own footer and scroll cue unobstructed. */
body:has(.chapter-rail a[href="#top"].active) .chapter-hud {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Moving architecture stays behind the real mech and readable copy. */
.hero-blue::before,
.hero-blue::after {
  content: '';
  position: absolute;
  pointer-events: none;
}
.hero-blue::before {
  inset: -25%;
  background: repeating-linear-gradient(116deg, transparent 0 110px, rgba(255,255,255,.055) 110px 112px, transparent 112px 220px);
  animation: mecha-blue-drift 22s ease-in-out infinite alternate;
}
.hero-blue::after {
  left: -25%;
  right: -25%;
  top: -15%;
  height: 1px;
  background: rgba(255, 255, 255, .32);
  box-shadow: 0 -25px 0 rgba(255,255,255,.05), 0 25px 0 rgba(255,255,255,.05);
  animation: mecha-stage-scan 13s linear infinite;
}
.frames::before {
  content: '';
  position: absolute;
  inset: -10% -20%;
  pointer-events: none;
  background: linear-gradient(116deg, transparent 41%, rgba(255,255,255,.045) 41% 49%, transparent 49% 73%, rgba(255,255,255,.035) 73% 74%, transparent 74%);
  animation: mecha-blue-drift 26s ease-in-out infinite alternate-reverse;
}
.frames > .section-top,
.frames > .frame-controls { position: relative; }

.cut-button:hover { translate: 0 -3px; }
.cut-button:active { translate: 0 1px; }
.frame-arrows button,
.lightbox-controls button,
.film-link,
.combat-tabs button,
.frame-tabs button {
  transition: background .2s, color .2s, translate .2s;
}
.frame-arrows button:hover,
.lightbox-controls button:hover { translate: 0 -3px; }
.frame-arrows button:active,
.lightbox-controls button:active { translate: 0 1px; }
.film-link:hover .play-small { background: white; color: var(--royal); }
.combat-tabs button:hover,
.frame-tabs button:hover { translate: 0 -3px; }
.combat-tabs button[aria-selected="true"],
.frame-tabs button[aria-selected="true"] { translate: 0 -2px; }
.gallery-grid button:focus-visible,
.route-scenes button:focus-visible { outline-offset: -5px; }

@keyframes mecha-blue-drift {
  from { transform: translate(-2.5%, -1%); }
  to { transform: translate(2.5%, 1%); }
}
@keyframes mecha-stage-scan {
  from { transform: translateY(0) rotate(-8deg); opacity: 0; }
  8%, 80% { opacity: .8; }
  to { transform: translateY(130vh) rotate(-8deg); opacity: 0; }
}

@media (max-width: 760px) {
  .masthead { padding: 0 18px; }
  .chapter-transition .transition-slab { left: -50%; width: 200%; }
  .header-tools { gap: 8px; }
  .header-tools .motion { gap: 4px; min-width: 47px; height: 38px; padding: 0 4px; font-size: 18px; }
  .motion .motion-state { font-size: 8px; }
  .chapter-hud { display: none; }
  .chapter-hud b { font-size: 21px; }
  .chapter-hud small { font-size: 6px; }
  .transition-label small { margin: 0 0 17px 2px; font-size: 8px; letter-spacing: .17em; }
  .transition-label b { font-size: clamp(52px, 12vw, 90px); border-bottom-width: 5px; padding-bottom: 12px; }
  .hero-blue::before { background-size: 70% 100%; }
}
@media (max-width: 420px) {
  .brand { gap: 7px; font-size: 23px; }
  .brand-project { font-size: 16px; }
  .header-tools { gap: 6px; }
  .header-tools .language { min-width: 28px; padding: 0 2px; }
  .header-tools .motion { min-width: 43px; }
  .menu-toggle { width: 25px; }
}
@media (prefers-reduced-motion: reduce) {
  html:not(.allow-motion) .hero-blue::before,
  html:not(.allow-motion) .hero-blue::after,
  html:not(.allow-motion) .frames::before { animation: none; }
}
html.reduce-motion .hero-blue::before,
html.reduce-motion .hero-blue::after,
html.reduce-motion .frames::before { animation: none; }
html.reduce-motion .hero-blue::after { display: none; }
html.reduce-motion .cut-button,
html.reduce-motion .frame-arrows button,
html.reduce-motion .lightbox-controls button,
html.reduce-motion .combat-tabs button,
html.reduce-motion .frame-tabs button,
html.reduce-motion .chapter-hud { transition: none; translate: none; }
