/* ==========================================================
   PAGE-SPECIFIC STYLES
   ========================================================== */

/* --- Hero Section --- */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hero__map {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.35;
  filter: saturate(0.6) brightness(0.5);
}

.hero__overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    180deg,
    rgba(10, 10, 15, 0.4) 0%,
    rgba(10, 10, 15, 0.6) 50%,
    rgba(10, 10, 15, 0.95) 100%
  );
}

.hero__content {
  position: relative;
  z-index: 5;
  text-align: center;
  padding: var(--space-2xl);
  max-width: 800px;
}

.hero__label {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--color-violet-glow);
  text-transform: uppercase;
  letter-spacing: 0.4em;
  margin-bottom: var(--space-lg);
}

.hero__title {
  font-size: var(--text-hero);
  color: var(--text-primary);
  margin-bottom: var(--space-md);
  line-height: 1.1;
}

.hero__subtitle {
  font-family: var(--font-body);
  font-size: var(--text-xl);
  color: var(--text-secondary);
  margin-bottom: var(--space-2xl);
  font-style: italic;
}

.hero__cta-group {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
}

/* --- Book Spotlight Section --- */
.spotlight {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: var(--space-3xl);
  align-items: center;
}

.spotlight__cover {
  position: relative;
}

.spotlight__cover img {
  width: 100%;
  height: auto;
  border: 1px solid var(--border-color);
  box-shadow: var(--glow-violet);
  transition: box-shadow var(--transition-base);
}

.spotlight__cover:hover img {
  box-shadow: 0 0 30px rgba(168, 85, 247, 0.4),
              0 0 60px rgba(168, 85, 247, 0.2);
}

.spotlight__info {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.spotlight__series {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--color-violet-glow);
  text-transform: uppercase;
  letter-spacing: 0.3em;
}

.spotlight__title {
  font-size: var(--text-4xl);
}

.spotlight__subtitle {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--color-gold);
  letter-spacing: 0.1em;
}

.spotlight__blurb {
  color: var(--text-secondary);
  font-size: var(--text-lg);
  line-height: var(--leading-loose);
  font-style: italic;
  border-left: 2px solid var(--color-violet);
  padding-left: var(--space-lg);
}

.spotlight__meta {
  display: flex;
  gap: var(--space-lg);
  flex-wrap: wrap;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.spotlight__actions {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.spotlight__tagline {
  color: var(--text-secondary);
  font-size: var(--text-lg);
  font-style: italic;
  line-height: var(--leading-loose);
}

/* --- Nav Tiles (homepage directory) --- */
.nav-tile {
  display: block;
  padding: var(--space-xl);
  border: 1px solid var(--border-color);
  background: rgba(18, 14, 28, 0.6);
  text-align: center;
  transition: all var(--transition-base);
  text-decoration: none;
}

.nav-tile:hover {
  border-color: rgba(123, 45, 142, 0.4);
  box-shadow: 0 0 25px rgba(123, 45, 142, 0.08);
  transform: translateY(-2px);
}

.nav-tile__icon {
  font-size: var(--text-3xl);
  color: var(--color-violet-glow);
  margin-bottom: var(--space-md);
  opacity: 0.7;
  transition: opacity var(--transition-base);
}

.nav-tile:hover .nav-tile__icon {
  opacity: 1;
}

.nav-tile__label {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.nav-tile__desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-loose);
}

/* --- Newsletter Section --- */
.newsletter {
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* --- About Page Grid --- */
.about-grid {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: var(--space-2xl);
  align-items: start;
}

.newsletter__privileges {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  max-width: 700px;
  margin: var(--space-2xl) auto;
  text-align: left;
}

.newsletter__privilege {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  padding-left: var(--space-lg);
  position: relative;
}

.newsletter__privilege::before {
  content: '>';
  position: absolute;
  left: 0;
  color: var(--color-violet-glow);
}

/* --- Lore Page Header Underline --- */
.lore-layout ~ .section-header,
.section-header:has(+ .lore-layout) {
  padding-bottom: var(--space-2xl);
  position: relative;
}
.section-header:has(+ .lore-layout)::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(168, 85, 247, 0.25) 30%, rgba(168, 85, 247, 0.25) 70%, transparent);
}

/* --- Lore Page Layout (sidebar + content) --- */
.lore-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--space-2xl);
  align-items: start;
}

.lore-sidebar {
  position: sticky;
  top: calc(var(--nav-height) + var(--space-xl));
  padding: var(--space-lg) 0;
  border-right: 1px solid var(--border-color);
}

.lore-sidebar__heading {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--color-violet-glow);
  margin-bottom: var(--space-lg);
  padding-right: var(--space-lg);
}

.lore-sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg) var(--space-sm) 0;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 2px solid transparent;
  padding-left: var(--space-md);
  margin-left: -1px;
  transition: all var(--transition-fast);
}

.lore-sidebar__link:hover {
  color: var(--text-primary);
  border-left-color: rgba(168, 85, 247, 0.3);
}

.lore-sidebar__link--active {
  color: var(--text-primary);
  border-left-color: var(--color-violet-glow);
}

.lore-sidebar__count {
  font-size: var(--text-xs);
  color: var(--color-violet-glow);
  background: rgba(168, 85, 247, 0.1);
  padding: 1px 6px;
  border-radius: 2px;
  min-width: 20px;
  text-align: center;
}

.lore-content {
  min-width: 0;
}

.lore-category {
  scroll-margin-top: calc(var(--nav-height) + var(--space-xl));
}

.lore-category__title {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-xl);
}

.lore-category__label {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--color-violet-glow);
  letter-spacing: 0.3em;
  display: block;
  margin-bottom: var(--space-xs);
}

/* --- Sidebar View Toggle --- */
.lore-sidebar__toggle {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-xs);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.lore-sidebar__toggle:hover {
  color: var(--text-primary);
  border-left-color: rgba(168, 85, 247, 0.3);
}

.lore-sidebar__toggle--active {
  color: var(--text-primary);
  border-left-color: var(--color-violet-glow);
  background: rgba(168, 85, 247, 0.06);
}

.lore-sidebar__toggle-icon {
  font-size: var(--text-sm);
  color: var(--color-violet-glow);
  width: 20px;
  text-align: center;
}

/* --- Interactive Map View --- */
.lore-map {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.lore-map__container {
  position: relative;
  border: none;
  border-radius: 0;
  overflow: hidden;
  background: transparent;
}

.lore-map__image {
  display: block;
  width: 100%;
  height: auto;
  filter: saturate(0.5) brightness(0.65);
  transition: filter var(--transition-base);
  mask-image: linear-gradient(to right, transparent 0%, black 7%, black 93%, transparent 100%),
    linear-gradient(to bottom, transparent 0%, black 7%, black 93%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 7%, black 93%, transparent 100%),
    linear-gradient(to bottom, transparent 0%, black 7%, black 93%, transparent 100%);
  mask-composite: intersect;
  -webkit-mask-composite: source-in;
}

.lore-map__hotspots {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* --- Map Hotspots --- */
.map-hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  z-index: 5;
}

.map-hotspot__dot {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-violet-glow);
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.6), 0 0 20px rgba(168, 85, 247, 0.3);
  transition: all var(--transition-fast);
}

.map-hotspot--public .map-hotspot__dot { background: var(--clearance-green); box-shadow: 0 0 8px rgba(34, 197, 94, 0.6); }
.map-hotspot--restricted .map-hotspot__dot { background: var(--color-violet-glow); }
.map-hotspot--top-secret .map-hotspot__dot { background: var(--clearance-redacted); box-shadow: 0 0 8px rgba(239, 68, 68, 0.6); }
.map-hotspot--gold .map-hotspot__dot { background: var(--color-gold); box-shadow: 0 0 8px rgba(200, 150, 46, 0.6); }

.map-hotspot__pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--color-violet-glow);
  animation: mapPulse 3s ease-in-out infinite;
}

@keyframes mapPulse {
  0%, 100% { width: 30px; height: 30px; opacity: 0.5; }
  50% { width: 45px; height: 45px; opacity: 0.15; }
}

.map-hotspot__label {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-primary);
  background: rgba(10, 10, 15, 0.9);
  border: 1px solid rgba(168, 85, 247, 0.3);
  padding: 4px 10px;
  border-radius: 2px;
  letter-spacing: 0.08em;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  z-index: 10;
}

.map-hotspot:hover .map-hotspot__label,
.map-hotspot:focus .map-hotspot__label {
  opacity: 1;
}

.map-hotspot:hover .map-hotspot__dot,
.map-hotspot:focus .map-hotspot__dot {
  width: 16px;
  height: 16px;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.8), 0 0 30px rgba(168, 85, 247, 0.4);
}

/* Spotlight state — when navigated from a card */
.map-hotspot--spotlight .map-hotspot__dot {
  width: 18px;
  height: 18px;
  box-shadow: 0 0 16px rgba(168, 85, 247, 1), 0 0 40px rgba(168, 85, 247, 0.6), 0 0 60px rgba(168, 85, 247, 0.3);
}

.map-hotspot--spotlight .map-hotspot__label {
  opacity: 1;
  border-color: var(--color-violet-glow);
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.3);
}

/* --- Map Info Panel --- */
.lore-map__info {
  padding: var(--space-lg);
  border: 1px solid var(--border-color);
  background: rgba(18, 14, 28, 0.8);
  min-height: 100px;
}

.lore-map__info-empty {
  text-align: center;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  padding: var(--space-xl) 0;
  letter-spacing: 0.05em;
}

.lore-map__info-content {
  animation: fadeInQuick 0.3s ease;
}

@keyframes fadeInQuick {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.lore-map__info-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-md);
}

.lore-map__info-ref {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: var(--space-xs);
}

.lore-map__info-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  color: var(--text-primary);
}

.lore-map__info-body {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: var(--leading-loose);
}

.lore-map__info-body p + p {
  margin-top: var(--space-sm);
}

/* --- "View on Map" link in lore cards --- */
.lore-entry__map-link {
  display: inline-block;
  margin-top: var(--space-sm);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--color-violet-glow);
  background: none;
  border: none;
  cursor: pointer;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: var(--space-xs) 0;
  border-bottom: 1px dashed rgba(168, 85, 247, 0.3);
  transition: all var(--transition-fast);
}

.lore-entry__map-link:hover {
  color: var(--text-primary);
  border-bottom-color: var(--color-violet-glow);
  text-shadow: 0 0 8px rgba(168, 85, 247, 0.4);
}

/* --- Responsive: Tablet --- */
@media (max-width: 1024px) {
  .spotlight {
    grid-template-columns: 220px 1fr;
    gap: var(--space-xl);
  }

  .lore-layout {
    grid-template-columns: 160px 1fr;
    gap: var(--space-lg);
  }
}

/* --- Responsive: Mobile --- */
@media (max-width: 768px) {
  .hero__content {
    padding: var(--space-md);
  }

  .spotlight {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .spotlight__cover {
    max-width: 250px;
    margin: 0 auto;
  }

  .spotlight__blurb {
    border-left: none;
    padding-left: 0;
    border-top: 2px solid var(--color-violet);
    padding-top: var(--space-md);
  }

  .spotlight__meta {
    justify-content: center;
  }

  .spotlight__actions {
    justify-content: center;
  }

  /* About page grid */
  .about-grid {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .about-grid > div:first-child {
    max-width: 200px;
    margin: 0 auto;
  }

  /* Dossier card header stacks on mobile */
  .dossier-card__header {
    flex-direction: column;
    gap: var(--space-sm);
  }

  /* Lore sidebar collapses to horizontal scroll on mobile */
  .lore-layout {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  .lore-sidebar {
    position: static;
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    padding: var(--space-md) 0;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .lore-sidebar__heading {
    margin-bottom: 0;
    padding-right: var(--space-md);
    white-space: nowrap;
  }

  .lore-sidebar__link {
    border-left: none;
    border-bottom: 2px solid transparent;
    padding: var(--space-xs) var(--space-md);
    margin-left: 0;
    white-space: nowrap;
    font-size: var(--text-xs);
  }

  .lore-sidebar__link:hover {
    border-left-color: transparent;
    border-bottom-color: rgba(168, 85, 247, 0.3);
  }

  .lore-sidebar__link--active {
    border-left-color: transparent;
    border-bottom-color: var(--color-violet-glow);
  }

  .lore-sidebar__toggle {
    border-left: none;
    border-bottom: 2px solid transparent;
    padding: var(--space-xs) var(--space-md);
    margin-bottom: 0;
    white-space: nowrap;
    font-size: var(--text-xs);
  }

  .lore-sidebar__toggle--active {
    border-left-color: transparent;
    border-bottom-color: var(--color-violet-glow);
  }

  .lore-sidebar__heading {
    display: none;
  }

  .lore-sidebar__heading + .lore-sidebar__toggle {
    display: flex;
  }

  .map-hotspot__label {
    font-size: 9px;
    padding: 3px 6px;
  }

  .map-hotspot__dot {
    width: 10px;
    height: 10px;
  }

  /* Lore map info panel stacks below map */
  .lore-map {
    gap: var(--space-md);
  }

  /* Newsletter privileges single column on mobile */
  .newsletter__privileges {
    grid-template-columns: 1fr;
  }

  /* Section headers tighten on mobile */
  .section-header__title {
    font-size: var(--text-3xl);
  }
}

/* ==========================================================
   404 ERROR PAGE
   ========================================================== */

.error-page {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* --- Floating background fragments --- */
.error-page__bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.error-page__fragment {
  position: absolute;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  opacity: 0;
  animation: fragmentDrift 12s ease-in-out infinite;
  white-space: nowrap;
}

.error-page__fragment:nth-child(odd)  { animation-duration: 10s; }
.error-page__fragment:nth-child(2)    { animation-delay: -2s; }
.error-page__fragment:nth-child(3)    { animation-delay: -4s; }
.error-page__fragment:nth-child(4)    { animation-delay: -1s; }
.error-page__fragment:nth-child(5)    { animation-delay: -6s; }
.error-page__fragment:nth-child(6)    { animation-delay: -3s; }
.error-page__fragment:nth-child(7)    { animation-delay: -8s; }
.error-page__fragment:nth-child(8)    { animation-delay: -5s; }
.error-page__fragment:nth-child(9)    { animation-delay: -7s; }
.error-page__fragment:nth-child(10)   { animation-delay: -9s; }

@keyframes fragmentDrift {
  0%, 100% { opacity: 0; transform: translateY(0); }
  15%      { opacity: 0.08; }
  50%      { opacity: 0.12; transform: translateY(-8px); }
  85%      { opacity: 0.08; }
}

/* --- Main content --- */
.error-page__content {
  position: relative;
  z-index: 1;
  text-align: center;
}

/* --- Error code with flicker --- */
.error-page__code {
  font-family: var(--font-ui);
  font-size: clamp(6rem, 15vw, 12rem);
  font-weight: 300;
  line-height: 1;
  margin-bottom: var(--space-md);
  color: rgba(239, 68, 68, 0.15);
  letter-spacing: 0.1em;
  user-select: none;
}

.error-page__code-flicker {
  animation: codeFlicker 4s ease-in-out infinite;
}

@keyframes codeFlicker {
  0%, 100%  { opacity: 1; }
  92%       { opacity: 1; }
  93%       { opacity: 0.3; }
  94%       { opacity: 0.8; }
  95%       { opacity: 0.2; }
  96%       { opacity: 1; }
  97%       { opacity: 0.4; }
  98%       { opacity: 1; }
}

/* --- Glitch title --- */
.error-page__title {
  font-size: var(--text-5xl);
  margin-bottom: var(--space-md);
  position: relative;
  animation: glitchShift 6s ease-in-out infinite;
}

.error-page__title::before,
.error-page__title::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
}

.error-page__title::before {
  color: var(--color-violet-glow);
  animation: glitchLeft 6s ease-in-out infinite;
}

.error-page__title::after {
  color: var(--clearance-redacted);
  animation: glitchRight 6s ease-in-out infinite;
}

@keyframes glitchShift {
  0%, 89%, 100% { transform: none; }
  90%           { transform: translateX(-2px); }
  91%           { transform: translateX(3px); }
  92%           { transform: translateX(-1px); }
  93%           { transform: none; }
}

@keyframes glitchLeft {
  0%, 89%, 94%, 100% { opacity: 0; transform: none; }
  90%                 { opacity: 0.8; transform: translateX(-4px) skewX(-2deg); }
  91%                 { opacity: 0; }
  92%                 { opacity: 0.5; transform: translateX(-2px); }
  93%                 { opacity: 0; }
}

@keyframes glitchRight {
  0%, 89%, 94%, 100% { opacity: 0; transform: none; }
  90.5%              { opacity: 0.8; transform: translateX(4px) skewX(2deg); }
  91.5%              { opacity: 0; }
  92.5%              { opacity: 0.5; transform: translateX(2px); }
  93.5%              { opacity: 0; }
}

/* --- Subtitle --- */
.error-page__subtitle {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--color-violet-glow);
  letter-spacing: 0.15em;
  margin-bottom: var(--space-2xl);
}

/* --- Body text --- */
.error-page__body {
  max-width: 480px;
  margin: 0 auto var(--space-2xl);
}

.error-page__body p {
  color: var(--text-secondary);
  line-height: var(--leading-loose);
}

.error-page__timestamp {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  opacity: 0.6;
  margin-top: var(--space-md);
  letter-spacing: 0.05em;
}

/* --- Action buttons --- */
.error-page__actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-2xl);
}

/* --- Footer directive --- */
.error-page__directive {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  opacity: 0.4;
  letter-spacing: 0.1em;
}

/* --- Mobile --- */
@media (max-width: 768px) {
  .error-page__bg {
    display: none;
  }

  .error-page__code {
    font-size: 5rem;
  }
}
