/* ============================================================
   layout.css — Structural composition
   THE PRIMARCH ARCHIVE

   Governs position, size, and arrangement of every region of the
   page. No color, no motion — those live in style.css (tokens)
   and animations.css (Stage 3). Breakpoints live in responsive.css
   (Stage 13); this file assumes a desktop/laptop viewport.
   ------------------------------------------------------------ */

/* ============================================================
   0. FULL-BLEED OVERLAYS
   ============================================================ */
.crt-overlay,
.vignette-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  pointer-events: none;
}

/* ============================================================
   1. PRELOADER
   ============================================================ */
.preloader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none; /* opt-in via [data-state="active"], wired in Stage 4's app.js */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  background: var(--c-void);
}
.preloader[data-state="active"] { display: flex; }

.preloader__glyph { width: 4.5rem; height: 4.5rem; }
.preloader__aquila { width: 100%; height: 100%; fill: var(--c-gold); }
.preloader__text {
  font-family: var(--font-data);
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  color: var(--c-gold-dim);
}
.preloader__bar {
  width: 14rem;
  height: 2px;
  background: var(--c-void-raised);
  overflow: hidden;
}
.preloader__bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--c-gold);
}

/* ============================================================
   2. HERO
   ============================================================ */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  isolation: isolate;
}

.hero__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.hero__fog,
.hero__light-rays {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.hero__content {
  position: relative;
  z-index: 3;
  max-width: 50rem;
  padding: 0 var(--space-4);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.hero__eyebrow { order: 1; }

.hero__title {
  order: 2;
  margin-top: var(--space-3);
  line-height: 1.05;
}

.hero__subtitle { order: 3; margin-top: var(--space-3); }

.btn-enter {
  order: 4;
  position: relative;
  margin-top: var(--space-5);
  padding: var(--space-2) var(--space-5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-enter__ring {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.hero__hint {
  order: 5;
  margin-top: var(--space-3);
  font-family: var(--font-data);
  font-size: 0.7rem;
}

.music-toggle {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem;
}

/* ============================================================
   3. ARCHIVE-OPENING TRANSITION
   ============================================================ */
.archive-transition {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: none; /* revealed via [data-state="active"] once navigation.js exists */
  pointer-events: none;
}
.archive-transition[data-state="active"] {
  display: block;
  pointer-events: all;
}

.archive-transition__door {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  background: var(--c-void);
}
.archive-transition__door--left { left: 0; }
.archive-transition__door--right { right: 0; }

.archive-transition__text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-data);
  letter-spacing: 0.3em;
  z-index: 1;
}

/* ============================================================
   4. PRIMARY NAVIGATION
   ============================================================ */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 700;
  transform: translateY(-100%);
}
.site-nav[data-state="visible"] { transform: translateY(0); }

.site-nav__inner {
  max-width: 90rem;
  margin: 0 auto;
  padding: var(--space-2) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.site-nav__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.site-nav__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: center;
  flex: 1;
}

.site-nav__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.site-nav__menu-btn {
  display: none; /* shown on narrow viewports in responsive.css */
  flex-direction: column;
  gap: 4px;
  width: 1.5rem;
}
.site-nav__menu-btn span { display: block; width: 100%; height: 2px; }

/* ============================================================
   5. SEARCH OVERLAY
   ============================================================ */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 750;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  visibility: hidden;
}
.search-overlay[data-state="open"] { visibility: visible; }

.search-overlay__panel {
  width: min(40rem, 90vw);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.search-overlay__input-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
}

.search-overlay__input { flex: 1; background: none; border: none; color: var(--c-parchment); font-size: 1.1rem; }
.search-overlay__input:focus { outline: none; }

.search-overlay__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.search-filter {
  padding: 0.35rem 0.8rem;
  font-family: var(--font-data);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
}

.search-overlay__results {
  max-height: 50vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ============================================================
   6. MAIN CONTENT / ARCHIVE SECTIONS
   ============================================================ */
#main-content { position: relative; z-index: 1; }

.archive-section {
  max-width: 78rem;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4);
}

.archive-section__header {
  max-width: 46rem;
  margin: 0 auto var(--space-5);
  text-align: center;
}

.archive-section__title { margin-top: var(--space-1); font-size: clamp(1.75rem, 3.5vw, 2.75rem); }
.archive-section__intro { margin-top: var(--space-2); }

.archive-section__body {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: var(--space-5);
  align-items: start;
}

.emperor-portrait figcaption {
  text-align: center;
  margin-top: var(--space-1);
  font-family: var(--font-data);
  font-size: 0.75rem;
}

.archive-section__placeholder { max-width: 60rem; }

/* Toolbar above the Primarch grid */
.archive-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--space-3);
}
.archive-toolbar__sort {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-data);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}
.archive-toolbar__sort select {
  background: var(--c-void-raised);
  color: var(--c-parchment);
  border: 1px solid var(--c-gold-dim);
  padding: 0.4rem 0.6rem;
  font-family: inherit;
}

/* Primarch card grid — card visuals themselves live in cards.css */
.primarch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-3);
}

/* Timeline track container — event styling lives in timeline.css */
.timeline-track {
  position: relative;
  min-height: 12rem;
  overflow-x: auto;
}

/* Galaxy map container — star/planet styling lives in galaxy.js output */
.galaxy-map {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 24rem;
}

/* Gallery grid — image/lightbox visuals live in gallery.css */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-2);
}

/* ============================================================
   7. FOOTER
   ============================================================ */
.site-footer {
  max-width: 78rem;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4);
  text-align: center;
}
.site-footer__seal { letter-spacing: 0.3em; }
.site-footer__text { margin-top: var(--space-1); }

/* ============================================================
   8. LIGHTBOX
   ============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 850;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
}
.lightbox[data-state="open"] { visibility: visible; }

.lightbox__image { max-width: 85vw; max-height: 80vh; margin: 0 auto; }

.lightbox__caption {
  position: absolute;
  bottom: var(--space-3);
  left: 0;
  right: 0;
  text-align: center;
}

.lightbox__close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
}

.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2rem;
  padding: 0.5rem 1rem;
}
.lightbox__nav--prev { left: var(--space-3); }
.lightbox__nav--next { right: var(--space-3); }
