/* ============================================================
   Landing Page — "The War Room"
   Cinematic entry for the Pacific War interactive atlas.
   Nautical chart aesthetic with vertical timeline narrative.
   ============================================================ */

:root {
  --bg-primary: #0a0e17;
  --bg-panel: #111827;
  --bg-surface: #1a2332;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-dim: #475569;
  --accent-gold: #d4a847;
  --accent-blue: #3b82f6;
  --accent-red: #dc2626;
  --accent-green: #10b981;
  --border-color: #1e293b;
  --border-subtle: #151d2e;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Bebas Neue', 'Arial Narrow', sans-serif;
}

/* Reset */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   HERO — Full viewport, atmospheric
   ============================================================ */
.hero {
  position: relative;
  height: 100vh;
  min-height: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}

/* Coordinate grid — nautical chart feel */
.hero-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(212, 168, 71, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(212, 168, 71, 0.04) 1px, transparent 1px);
  background-size: 80px 80px;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 20%, transparent 70%);
}

/* Animated atmospheric glow */
.hero-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(212, 168, 71, 0.06) 0%, transparent 100%),
    radial-gradient(circle 400px at 25% 70%, rgba(59, 130, 246, 0.04) 0%, transparent 100%),
    radial-gradient(circle 400px at 75% 70%, rgba(220, 38, 38, 0.03) 0%, transparent 100%);
  animation: glowPulse 8s ease-in-out infinite alternate;
}

@keyframes glowPulse {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

/* Giant background year text */
.hero-year-bg {
  position: absolute;
  font-family: var(--font-display);
  font-size: clamp(120px, 22vw, 280px);
  letter-spacing: 12px;
  color: rgba(212, 168, 71, 0.10);
  white-space: nowrap;
  user-select: none;
  pointer-events: none;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Hero content */
.hero-content {
  position: relative;
  z-index: 1;
  max-width: 680px;
  padding: 0 24px;
}

.hero-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 5px;
  text-transform: uppercase;
  color: var(--accent-gold);
  margin-bottom: 20px;
  opacity: 0;
  animation: fadeInUp 1s ease forwards 0.3s;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(56px, 12vw, 110px);
  line-height: 0.9;
  letter-spacing: 6px;
  color: var(--text-primary);
  margin-bottom: 24px;
  opacity: 0;
  animation: fadeInUp 1s ease forwards 0.5s;
}

.hero-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 520px;
  margin: 0 auto 40px;
  opacity: 0;
  animation: fadeInUp 1s ease forwards 0.7s;
}

/* Stats bar */
.hero-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  opacity: 0;
  animation: fadeInUp 1s ease forwards 0.9s;
}

.hero-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.hero-stat-number {
  font-family: var(--font-display);
  font-size: 32px;
  letter-spacing: 2px;
  color: var(--text-primary);
}

.hero-stat-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.hero-stat-divider {
  width: 1px;
  height: 40px;
  background: var(--border-color);
}

/* Scroll hint */
/* Centered by layout, NOT by transform. Two other rules write `transform` on
   this element -- the fadeInUp keyframes (which set translateY, and hold it
   via `forwards`) and the reduced-motion block (`transform: none !important`)
   -- and either one silently drops a `translateX(-50%)`, dumping the hint
   half its own width right of the title. Spanning the hero and letting
   `align-items: center` do the centering puts it out of their reach. */
.scroll-hint {
  position: absolute;
  bottom: 32px;
  left: 0;
  right: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  opacity: 0;
  animation: fadeInUp 1s ease forwards 1.3s;
  /* The box now spans the hero; only the text and chevron should take a click */
  pointer-events: none;
}

.scroll-hint > * {
  pointer-events: auto;
  cursor: pointer;
}

.scroll-text {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--accent-gold);
  opacity: 0.7;
}

.scroll-chevron {
  display: block;
  width: 20px;
  height: 20px;
  border-right: 2px solid var(--accent-gold);
  border-bottom: 2px solid var(--accent-gold);
  transform: rotate(45deg);
  opacity: 0.7;
  animation: scrollBounce 2.5s ease-in-out infinite;
}

@keyframes scrollBounce {
  0%, 100% { transform: rotate(45deg) translateY(0); opacity: 0.3; }
  50% { transform: rotate(45deg) translateY(5px); opacity: 0.7; }
}

/* ============================================================
   FEATURED BATTLE — Full-width cinematic card
   ============================================================ */
.featured-section {
  position: relative;
  padding: 0 24px;
  max-width: 1000px;
  margin: -40px auto 0;
  z-index: 2;
}

.featured-card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.4s ease, box-shadow 0.4s ease, transform 0.4s ease;
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s ease, transform 0.8s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

.featured-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.featured-card:hover {
  border-color: var(--accent-gold);
  box-shadow:
    0 0 0 1px rgba(212, 168, 71, 0.1),
    0 16px 48px rgba(212, 168, 71, 0.08),
    0 4px 16px rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
}

/* Gold accent bar on top — above the thumbnail and its scrim */
.featured-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent-gold), transparent);
  z-index: 3;
}

/* The chart itself, behind the words. Sits under .featured-inner (which gets
   its own stacking context below) and is scrimmed left-to-right so the body
   text keeps a near-solid backing while the open Pacific stays visible out
   past the stats column. */
.featured-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* The featured card is wider than the photographs' 2.2:1 crop (~3.1:1 at
     full width), so ~29% is cropped here no matter what. Bias the surviving
     band low rather than dead centre: on these photographs the recognizable
     structure — a ship's masts, a shoreline, a horizon — sits below the
     midline, while the top is usually sky or smoke that reads as nothing
     under the scrim. */
  object-position: center 62%;
  opacity: 0.8;
  z-index: 0;
}

.featured-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    var(--bg-surface) 16%,
    rgba(26, 35, 50, 0.82) 45%,
    rgba(26, 35, 50, 0.3) 100%
  );
  z-index: 1;
}

/* No image, no scrim — an un-photographed battle keeps the flat surface it
   has always had rather than a gradient over nothing. */
.featured-card:not(:has(.featured-thumb))::after { display: none; }

/* Required by the one photo (Iwo Jima, CC BY 2.0) that isn't public domain —
   present only when battles.json sets photoCredit. Sits above the scrim,
   tucked in the corner where it reads as a caption, not a watermark. */
.featured-credit,
.tl-credit {
  position: absolute;
  z-index: 2;
  font-size: 10px;
  letter-spacing: 0.3px;
  color: rgba(226, 232, 240, 0.65);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}

.featured-credit { bottom: 8px; right: 12px; }

.featured-inner {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 320px;
  min-height: 280px;
}

.featured-body {
  padding: 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.featured-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--accent-gold);
  margin-bottom: 12px;
}

.featured-title {
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 48px);
  letter-spacing: 2px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.featured-date {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.featured-description {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 24px;
  max-width: 480px;
}

.featured-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent-gold);
  text-decoration: none;
  transition: gap 0.3s ease;
}

.featured-card:hover .featured-cta {
  gap: 14px;
}

.featured-cta-arrow {
  font-size: 18px;
  transition: transform 0.3s ease;
}

.featured-card:hover .featured-cta-arrow {
  transform: translateX(4px);
}

/* Right side — stats panel */
.featured-stats {
  background: rgba(0, 0, 0, 0.2);
  border-left: 1px solid var(--border-color);
  padding: 40px 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
}

/* The scrim is at its thinnest under the stats column — deliberately, so the
   open Pacific stays visible out to the card's edge. That is also where the
   type is smallest and dimmest, so the panel carries its own backing. */
.featured-card:has(.featured-thumb) .featured-stats {
  background: rgba(0, 0, 0, 0.42);
}

.featured-stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.featured-stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.featured-stat-value {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.4;
}

.featured-stat-value.gold { color: var(--accent-gold); }
.featured-stat-value.red { color: var(--accent-red); }

/* ============================================================
   TIMELINE — Vertical chronological spine
   ============================================================ */
.timeline-section {
  padding: 48px 24px 80px;
  max-width: 1000px;
  margin: 0 auto;
}

.timeline-spine {
  position: relative;
  /* The vertical line */
}

.timeline-spine::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(to bottom, var(--border-color), var(--border-subtle));
  transform: translateX(-50%);
}

/* Year markers on the spine */
.timeline-year {
  position: relative;
  text-align: center;
  margin-bottom: 48px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.timeline-year.visible {
  opacity: 1;
  transform: translateY(0);
}

.timeline-year-label {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 36px;
  letter-spacing: 4px;
  color: var(--accent-gold);
  background: var(--bg-primary);
  padding: 0 20px;
  position: relative;
  z-index: 1;
}

/* Phase label under year */
.timeline-phase {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Battle entries — alternating left/right */
.timeline-entry {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  margin-bottom: 40px;
  align-items: center;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.timeline-entry.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Dot on the spine */
.timeline-entry::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  background: var(--bg-primary);
  border: 2px solid var(--border-color);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  transition: border-color 0.3s, background 0.3s;
}

.timeline-entry:hover::before {
  border-color: var(--accent-gold);
  background: var(--accent-gold);
}

/* Left-aligned card (odd) */
.timeline-entry .tl-card {
  grid-column: 1;
  text-align: right;
}

.timeline-entry .tl-spacer {
  grid-column: 2;
}

/* Right-aligned card (even) */
.timeline-entry.right .tl-card {
  grid-column: 2;
  text-align: left;
  order: 2;
}

.timeline-entry.right .tl-spacer {
  grid-column: 1;
  order: 1;
}

/* Timeline card styling */
.tl-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px 28px;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
  position: relative;
}

.tl-card.available {
  cursor: pointer;
  border-color: rgba(212, 168, 71, 0.3);
  box-shadow: 0 0 0 1px rgba(212, 168, 71, 0.06) inset;
}

.tl-card.available:hover {
  border-color: var(--accent-gold);
  box-shadow: 0 8px 32px rgba(212, 168, 71, 0.12), 0 0 0 1px rgba(212, 168, 71, 0.08) inset;
  transform: translateY(-2px);
}

.tl-card.coming-soon {
  opacity: 0.5;
}

.tl-card.coming-soon:hover {
  opacity: 0.65;
}

/* Connector line from card to spine dot */
.timeline-entry .tl-card::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 24px;
  height: 1px;
  background: var(--border-color);
}

/* Left card — connector goes right */
.timeline-entry:not(.right) .tl-card::after {
  right: -24px;
}

/* Right card — connector goes left */
.timeline-entry.right .tl-card::after {
  left: -24px;
}

/* Full-bleed photo band across the top of the card. The negative margins
   cancel .tl-card's padding rather than clipping with overflow:hidden —
   .tl-card::after is the connector line reaching OUT to the spine dot, and
   clipping the card would cut it off. Hence the hand-matched corner radii. */
.tl-thumb-wrap {
  position: relative;
  width: calc(100% + 56px);
  margin: -24px -28px 18px;
}

/* The photographs are cut to 2.2:1, and the band is declared at 2.2:1 — so
   `cover` has nothing left to crop and every card shows its whole picture at
   any card width. A fixed pixel height here is what used to hide 41% of each
   photo, and it would start hiding a different amount the moment the column
   width changed. Keep these two numbers equal to the crop in
   assets/thumbnails/CREDITS.md. */
.tl-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 2.2;
  object-fit: cover;
  border-radius: 11px 11px 0 0;
  opacity: 0.9;
  transition: opacity 0.3s ease;
}

.tl-card.available:hover .tl-thumb { opacity: 1; }

/* Anchored to the band, not to a hard-coded offset from the card's top. */
.tl-credit { bottom: 6px; right: 8px; }

.tl-date {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 1px;
  color: var(--accent-gold);
  margin-bottom: 4px;
}

.tl-title {
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 1px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.tl-description {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 12px;
}

.tl-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: inherit; /* inherits text-align direction */
}

/* Right-aligned cards: meta should flow left */
.timeline-entry:not(.right) .tl-meta {
  justify-content: flex-end;
}

.timeline-entry.right .tl-meta {
  justify-content: flex-start;
}

.tl-pill {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  border-radius: 100px;
  background: rgba(212, 168, 71, 0.08);
  color: var(--accent-gold);
  border: 1px solid rgba(212, 168, 71, 0.15);
  white-space: nowrap;
}

.tl-pill.outcome-allied {
  background: rgba(59, 130, 246, 0.08);
  color: var(--accent-blue);
  border-color: rgba(59, 130, 246, 0.15);
}

.tl-pill.outcome-japan {
  background: rgba(220, 38, 38, 0.08);
  color: var(--accent-red);
  border-color: rgba(220, 38, 38, 0.15);
}

.tl-coming-soon {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-top: 4px;
}

.tl-explore {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent-gold);
  margin-top: 8px;
  opacity: 0.8;
  transition: opacity 0.2s, letter-spacing 0.2s;
}

.tl-card.available:hover .tl-explore {
  opacity: 1;
  letter-spacing: 3px;
}

/* ============================================================
   FOOTER
   ============================================================ */
.landing-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 48px 24px;
}

.footer-content {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
}

.footer-disclaimer {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 16px;
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.footer-links a {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 1px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
  padding: 14px 8px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.footer-links a:hover {
  color: var(--accent-gold);
}

.footer-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-dim);
}

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Responsive
   ============================================================ */

/* Tablet */
@media (max-width: 768px) {
  .featured-inner {
    grid-template-columns: 1fr;
  }

  /* Stacked, the body no longer occupies only the left — the scrim has to
     darken top-down instead of left-to-right or the headline sits on ocean. */
  .featured-card::after {
    background: linear-gradient(
      180deg,
      var(--bg-surface) 25%,
      rgba(26, 35, 50, 0.9) 60%,
      rgba(26, 35, 50, 0.75) 100%
    );
  }

  .featured-stats {
    border-left: none;
    border-top: 1px solid var(--border-color);
    flex-direction: row;
    flex-wrap: wrap;
    gap: 20px;
  }

  .featured-body {
    padding: 32px;
  }

  /* Timeline goes single-column with spine on left */
  .timeline-spine::before {
    left: 20px;
  }

  .timeline-year {
    text-align: left;
    padding-left: 44px;
  }

  .timeline-year-label {
    padding: 0 12px 0 0;
  }

  .timeline-entry {
    grid-template-columns: 1fr;
    gap: 0;
    padding-left: 44px;
  }

  .timeline-entry::before {
    left: 20px;
    top: 28px;
  }

  .timeline-entry .tl-card,
  .timeline-entry.right .tl-card {
    grid-column: 1;
    text-align: left;
    order: 1;
  }

  .timeline-entry .tl-spacer,
  .timeline-entry.right .tl-spacer {
    display: none;
  }

  .timeline-entry .tl-card::after,
  .timeline-entry.right .tl-card::after {
    display: none;
  }

  .timeline-entry:not(.right) .tl-meta,
  .timeline-entry.right .tl-meta {
    justify-content: flex-start;
  }
}

/* Mobile */
@media (max-width: 480px) {
  .hero { min-height: 500px; }
  .hero-stats { gap: 16px; }
  .hero-stat-number { font-size: 24px; }
  .hero-stat-divider { height: 28px; }

  .featured-section { padding: 0 16px; }
  .featured-body { padding: 24px; }
  .featured-stats { padding: 24px; }

  .timeline-section { padding: 60px 16px; }

  .tl-card { padding: 20px; }

  /* Card padding drops to 20px here — the band's bleed has to follow it.
     The height needs no restating: aspect-ratio derives it from the new
     width, so the crop stays identical to desktop. */
  .tl-thumb-wrap {
    width: calc(100% + 40px);
    margin: -20px -20px 14px;
  }
}

/* ============================================================
   Reduced motion — respect the OS-level preference.
   ============================================================ */
@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;
  }
  /* Entrance animations start at opacity 0 — land them instantly instead. */
  .hero-eyebrow, .hero-title, .hero-subtitle, .hero-stats, .scroll-hint,
  .featured-card, .timeline-year, .timeline-entry {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* Keyboard focus: battle cards are div-links; show where you are */
.featured-card:focus-visible,
.tl-card:focus-visible {
  outline: 2px solid var(--accent-gold, #d4a847);
  outline-offset: 3px;
}
