/* ============================================================
   HISTORY OF ARMS — Premium Tactical Animations
   Military-grade, medium intensity, scroll-triggered reveals
   Zero external dependencies — pure CSS + IntersectionObserver
   ============================================================ */

/* -------------------------------------------------------
   1. BASE REVEAL SYSTEM
   Elements start hidden and animate in when .in-view is added
   ------------------------------------------------------- */

/* Fade-up: the primary reveal — smooth upward slide + fade */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* Fade-left: slide in from the left — used for section headings */
.reveal-left {
  opacity: 0;
  transform: translateX(-32px);
  transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal-left.in-view {
  opacity: 1;
  transform: translateX(0);
}

/* Fade-right: slide in from the right — used for descriptions */
.reveal-right {
  opacity: 0;
  transform: translateX(32px);
  transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal-right.in-view {
  opacity: 1;
  transform: translateX(0);
}

/* Scale-up: subtle scale entrance — used for individual cards */
.reveal-scale {
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.45s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal-scale.in-view {
  opacity: 1;
  transform: scale(1);
}


/* -------------------------------------------------------
   2. STAGGER DELAYS — cards animate one after another
   ------------------------------------------------------- */
.stagger-1 { transition-delay: 0.08s; }
.stagger-2 { transition-delay: 0.16s; }
.stagger-3 { transition-delay: 0.24s; }
.stagger-4 { transition-delay: 0.32s; }
.stagger-5 { transition-delay: 0.40s; }
.stagger-6 { transition-delay: 0.48s; }


/* -------------------------------------------------------
   3. PAGE LOAD ANIMATION — header, nav, first section
   Plays once on page load via CSS animation
   ------------------------------------------------------- */

/* Header entrance — instant paint for green Core Web Vitals FCP/LCP */
header .eyebrow {
  animation: tacticalSlideDown 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.05s both;
}
header h1 {
  animation: tacticalSlideDown 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
}
header p {
  animation: tacticalSlideDown 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.15s both;
}

@keyframes tacticalSlideDown {
  from {
    transform: translateY(-12px);
  }
  to {
    transform: translateY(0);
  }
}

/* Nav bar entrance */
.nav {
  animation: navSlideIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both;
}

@keyframes navSlideIn {
  from {
    transform: translateY(-6px);
  }
  to {
    transform: translateY(0);
  }
}


/* -------------------------------------------------------
   4. ENHANCED NAV ACTIVE LINK
   Smooth glow transition on active state
   ------------------------------------------------------- */
.nav a {
  transition: color 0.3s ease,
              border-bottom-color 0.3s ease,
              text-shadow 0.3s ease;
}
.nav a.active {
  text-shadow: 0 0 12px rgba(108, 129, 152, 0.4);
}


/* -------------------------------------------------------
   5. NEON GLOW HOVER — per-category colored border glow
   Each category gets its own distinct neon aura & tactical indicator
   ------------------------------------------------------- */

/* Category neon colors (RGB triplets for rgba() usage) */
#g-weapons .card        { --neon: 59, 130, 246; }    /* Electric Blue (Assault Rifles)    */
#g-rejected .card       { --neon: 239, 68, 68; }      /* Crimson Hazard (Unsuccessful)     */
#g-handguns .card       { --neon: 245, 158, 11; }     /* Amber Gold (Handguns)             */
#g-machine-guns .card   { --neon: 16, 185, 129; }     /* Emerald Green (Machine Guns)      */
#g-sniper-rifles .card  { --neon: 6, 182, 212; }      /* Ice Cyan (Sniper Rifles)          */
#g-british .card        { --neon: 234, 179, 8; }      /* Royal Gold (British Armor)        */
#g-american .card       { --neon: 132, 204, 22; }     /* Tactical Olive (U.S. Armor)       */
#g-german .card         { --neon: 168, 85, 247; }     /* Steel Ultraviolet (German Armor)  */

/* Section header category accent borders */
#arms-comparison .sec-head h2,
#small-arms .sec-head h2    { border-left: 4px solid rgba(59, 130, 246, 0.85); padding-left: 12px; margin-top: 8px; }
#rejected .sec-head h2      { border-left: 4px solid rgba(239, 68, 68, 0.85); padding-left: 12px; }
#handguns .sec-head h2      { border-left: 4px solid rgba(245, 158, 11, 0.85); padding-left: 12px; }
#machine-guns .sec-head h2  { border-left: 4px solid rgba(16, 185, 129, 0.85); padding-left: 12px; }
#sniper-rifles .sec-head h2 { border-left: 4px solid rgba(6, 182, 212, 0.85); padding-left: 12px; }
#british .sec-head h2       { border-left: 4px solid rgba(234, 179, 8, 0.85); padding-left: 12px; }
#american .sec-head h2      { border-left: 4px solid rgba(132, 204, 22, 0.85); padding-left: 12px; }
#german .sec-head h2        { border-left: 4px solid rgba(168, 85, 247, 0.85); padding-left: 12px; }

/* Base card: crisp dark border with subtle category tint */
.card {
  --neon: 108, 129, 152;  /* fallback: neutral steel */
  border: 1.5px solid rgba(var(--neon), 0.22) !important;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.35s cubic-bezier(0.22, 1, 0.36, 1),
              border-color 0.35s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

/* Neon glow on hover / focus — high-intensity tactical outline */
.card:hover,
.card:focus-visible {
  transform: translateY(-6px) !important;
  border-color: rgba(var(--neon), 0.95) !important;
  box-shadow:
    0 0 12px rgba(var(--neon), 0.55),
    0 0 28px rgba(var(--neon), 0.32),
    0 0 55px rgba(var(--neon), 0.16),
    inset 0 0 16px rgba(var(--neon), 0.12),
    0 20px 40px rgba(10, 16, 23, 0.45) !important;
}

.card:focus-visible {
  outline: none !important;
  border-color: rgba(var(--neon), 1) !important;
}

/* Tactical neon square dot before weapon/vehicle title (matching reference UI) */
.card .info h3 {
  display: flex;
  align-items: center;
  gap: 8px;
}
.card .info h3::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background-color: rgb(var(--neon));
  box-shadow: 0 0 6px rgb(var(--neon));
  flex-shrink: 0;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.card:hover .info h3::before {
  transform: scale(1.4);
  box-shadow: 0 0 12px rgb(var(--neon)), 0 0 22px rgb(var(--neon));
}

/* Image zoom on hover */
.card img {
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.card:hover img {
  transform: scale(1.08);
}

/* Card info text slides up slightly on hover */
.card .info {
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.card:hover .info {
  transform: translateY(-4px);
}

.card:hover .sub {
  color: #fff;
}

/* Tag glow on rejected cards */
.card .tag {
  color: rgb(var(--neon));
  font-weight: 600;
  letter-spacing: 0.15em;
  transition: color 0.3s ease, text-shadow 0.3s ease;
}
.card:hover .tag {
  text-shadow: 0 0 8px rgba(var(--neon), 0.8);
}

#g-rejected .card .badge {
  background: rgba(var(--neon), 0.9);
  box-shadow: 0 0 10px rgba(var(--neon), 0.6);
}


/* -------------------------------------------------------
   6. SECTION DIVIDER — tactical line pulse
   GPU-accelerated horizontal line that animates on scroll
   ------------------------------------------------------- */
section {
  position: relative;
}
section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(108, 129, 152, 0.35),
    transparent
  );
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
section:first-child::before {
  display: none;
}
section.in-view::before {
  transform: scaleX(1);
}


/* -------------------------------------------------------
   7. ARTICLE PAGE ANIMATIONS
   Hero image + content reveals
   ------------------------------------------------------- */

/* Smooth, high-performance article hero image entrance */
.article-hero img {
  transform: scale(1);
  transition: transform 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.article-hero:hover img {
  transform: scale(1.03);
}

/* Article hero title entrance */
.article-hero-title {
  animation: heroTitleIn 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.3s both;
}
@keyframes heroTitleIn {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Article content sections (exclude .blog which contains long-form content) */
.article-section:not(.blog) {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.article-section:not(.blog).in-view {
  opacity: 1;
  transform: translateY(0);
}

/* Specs bar — slides down */
.article-content .specs {
  opacity: 0;
  transform: translateY(-15px);
  transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.15s,
              transform 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.15s;
}
.article-content .specs.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* Blog section: heading animates, body content is always visible */
.article-section.blog {
  opacity: 1;
  transform: none;
}
.article-section.blog > h2 {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.article-section.blog > h2.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* Blog body — always visible so readers never miss content */
.blog-body {
  opacity: 1;
  transform: none;
}

/* Breadcrumbs fade-in */
.breadcrumbs {
  animation: fadeIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.15s both;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Pros/Cons list items stagger in */
.pc .pros li,
.pc .cons li {
  opacity: 0;
  transform: translateX(-12px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.pc.in-view .pros li,
.pc.in-view .cons li {
  opacity: 1;
  transform: translateX(0);
}
.pc.in-view li:nth-child(1) { transition-delay: 0.05s; }
.pc.in-view li:nth-child(2) { transition-delay: 0.10s; }
.pc.in-view li:nth-child(3) { transition-delay: 0.12s; }
.pc.in-view li:nth-child(4) { transition-delay: 0.16s; }
.pc.in-view li:nth-child(5) { transition-delay: 0.20s; }
.pc.in-view li:nth-child(6) { transition-delay: 0.24s; }
.pc.in-view li:nth-child(7) { transition-delay: 0.28s; }
.pc.in-view li:nth-child(8) { transition-delay: 0.32s; }
.pc.in-view li:nth-child(9) { transition-delay: 0.36s; }


/* -------------------------------------------------------
   8. SIMPLE PAGES (About, Privacy, Contact)
   ------------------------------------------------------- */
.simple-page,
.policy-page,
.contact-page {
  animation: contentFadeUp 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both;
}
@keyframes contentFadeUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* -------------------------------------------------------
   9. FOOTER ENTRANCE
   ------------------------------------------------------- */
footer {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
footer.in-view {
  opacity: 1;
  transform: translateY(0);
}


/* -------------------------------------------------------
   10. RESPECT REDUCED MOTION PREFERENCES
   Users who prefer reduced motion get instant display
   ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal, .reveal-left, .reveal-right, .reveal-scale,
  .article-section:not(.blog), .article-content .specs,
  .article-section.blog > h2,
  footer {
    opacity: 1 !important;
    transform: none !important;
  }
  section::before {
    width: 100% !important;
    left: 0 !important;
  }
}

/* -------------------------------------------------------
   11. MOBILE & TOUCHSCREEN ENHANCEMENTS
   Optimized animations, tap ergonomics, and layout stability
   ------------------------------------------------------- */
@media (max-width: 640px) {
  /* Tamer translation distances to prevent horizontal layout shift / scroll flutter */
  .reveal {
    transform: translateY(20px);
  }
  .reveal-left {
    transform: translateX(-16px);
  }
  .reveal-right {
    transform: translateX(16px);
  }
  .article-section:not(.blog) {
    transform: translateY(20px);
  }

  /* Cards on mobile: show distinct neon border at rest so category colors shine */
  .card {
    border: 1.5px solid rgba(var(--neon), 0.4) !important;
    box-shadow: 0 4px 16px rgba(10, 16, 23, 0.3), 0 0 10px rgba(var(--neon), 0.12) !important;
  }
  .card .info h3::before {
    box-shadow: 0 0 8px rgb(var(--neon));
  }

  /* Gentler Ken Burns animation to save mobile battery and avoid stutter */
  .article-hero img {
    animation-duration: 35s;
  }
}

/* Touch devices (phones / tablets without mouse pointer) */
@media (hover: none) and (pointer: coarse) {
  .card:active {
    transform: scale(0.98) !important;
    border-color: rgba(var(--neon), 1) !important;
    box-shadow:
      0 0 16px rgba(var(--neon), 0.6),
      0 0 35px rgba(var(--neon), 0.3),
      inset 0 0 12px rgba(var(--neon), 0.15) !important;
  }
  .card:hover {
    transform: none;
  }
}
