/* ============================================================
   title.css — Shattered Nexus
   Title screen, cinematic backdrop, nebula, hero silhouettes,
   menu buttons, and title responsive overrides.
   ============================================================ */
/* ═══════════════════════════════════════════════════════════
   TITLE SCREEN  —  Cinematic redesign (matches map aesthetic)
   ═══════════════════════════════════════════════════════════ */
#title-screen {
  flex: 1;
  min-height: 0;
  align-items: center;
  justify-content: center;
  background: #020108;
  padding: 36px 24px 28px;
  gap: 0;
  position: relative;
  overflow: hidden;
}

/* ── Advanced Visual Context (Nebula & Parallax) ────────── */
.title-visual-context {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ── Final Boss Backdrop (Shadow Emperor) ───────────────── */
.bg-boss-sil {
  position: absolute;
  width: 120vw;
  height: 120vh;
  background-image: url('../images/enemies/shadow_emperor.webp');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center 20%;
  opacity: 0.04;
  filter: brightness(0) blur(4px);
  z-index: -2;
  animation: bossLoom 20s ease-in-out infinite alternate;
}

@keyframes bossLoom {
  from {
    transform: scale(1) translateY(0);
    opacity: 0.03;
  }

  to {
    transform: scale(1.1) translateY(-20px);
    opacity: 0.05;
  }
}

.stars-layer {
  position: absolute;
  inset: -100px;
  background-image:
    radial-gradient(1px 1px at 25px 35px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 100px 150px, #fff, transparent),
    radial-gradient(1px 1px at 200px 50px, #fff, transparent);
  background-size: 300px 300px;
}

#stars-l1 {
  animation: drift 60s linear infinite;
  opacity: 0.3;
}

#stars-l2 {
  animation: drift 30s linear infinite reverse;
  opacity: 0.5;
  background-size: 200px 200px;
}

.nebula-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 30%, rgba(96, 40, 184, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(20, 40, 120, 0.18) 0%, transparent 50%);
  filter: blur(40px);
  animation: nebulaPulse 10s ease-in-out infinite alternate;
}

/* ── Environmental Debris ──────────────────────────────── */
.title-env-debris {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

.debris-shard {
  position: absolute;
  background: rgba(144, 128, 255, 0.2);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  box-shadow: 0 0 10px rgba(78, 207, 255, 0.3);
  pointer-events: none;
}

/* ── Hero Silhouettes ───────────────────────────────────── */
.hero-silhouettes {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  padding-bottom: 0;
  opacity: 0.18;
  z-index: 0;
  pointer-events: none;
}

.hero-sil {
  height: 55vh;
  width: auto;
  min-width: 280px;
  background-repeat: no-repeat;
  transition: transform 6s ease-in-out, filter 0.5s ease;
  transform-origin: bottom center;
  filter: brightness(0.4) saturate(0) contrast(1.2) blur(0.3px);
}

/* ── Nexus Crystal ──────────────────────────────────────── */
.nexus-crystal {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 400px;
  height: 400px;
  background:
    radial-gradient(circle, rgba(144, 200, 255, 0.25) 0%, transparent 40%),
    radial-gradient(circle, rgba(96, 60, 255, 0.15) 20%, transparent 60%),
    radial-gradient(circle, rgba(255, 255, 255, 0.08) 0%, transparent 20%);
  z-index: -1;
  pointer-events: none;
  animation: crystalGlow 6s ease-in-out infinite alternate;
  mix-blend-mode: screen;
}

@keyframes crystalGlow {
  0% {
    opacity: 0.3;
    transform: translate(-50%, -50%) scale(0.9) rotate(0deg);
  }

  50% {
    opacity: 0.8;
  }

  100% {
    opacity: 0.5;
    transform: translate(-50%, -50%) scale(1.1) rotate(5deg);
  }
}

/* Elemental Rim-Lighting (Spectral Bloom) */
.hero-sil[data-hero="aya"] {
  filter: brightness(0.4) saturate(0) contrast(1.2) drop-shadow(0 0 12px rgba(96, 204, 255, 0.5));
}

.hero-sil[data-hero="tao"] {
  filter: brightness(0.4) saturate(0) contrast(1.2) drop-shadow(0 0 12px rgba(255, 80, 80, 0.5));
}

.hero-sil[data-hero="lulu"] {
  filter: brightness(0.4) saturate(0) contrast(1.2) drop-shadow(0 0 12px rgba(80, 160, 255, 0.5));
}

.hero-sil[data-hero="rei"] {
  filter: brightness(0.4) saturate(0) contrast(1.2) drop-shadow(0 0 12px rgba(80, 255, 160, 0.5));
}

@keyframes spectralBreathing {

  0%,
  100% {
    opacity: 0.15;
    transform: scale(1.0);
  }

  50% {
    opacity: 0.22;
    transform: scale(1.02);
  }
}

/* The HomeEngine handles applying these animations dynamically */

@keyframes drift {
  from {
    transform: translate(0, 0);
  }

  to {
    transform: translate(50px, 50px);
  }
}

@keyframes nebulaPulse {
  from {
    opacity: 0.6;
    transform: scale(1);
  }

  to {
    opacity: 1;
    transform: scale(1.1);
  }
}

/* ── Cinematic top accent bar ───────────────────────────── */
.title-top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg,
      transparent 0%,
      #6040c0 20%,
      var(--gold) 50%,
      #6040c0 80%,
      transparent 100%);
  box-shadow: 0 0 24px #9060ff60;
  z-index: 2;
}

/* ── Title hero block ───────────────────────────────────── */
.title-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  z-index: 1;
  margin-bottom: 24px;
}

/* Eyebrow label above title */
.title-eyebrow {
  font-family: var(--px);
  font-size: var(--fs-xxs);
  color: #6050a0;
  letter-spacing: 3px;
  margin-bottom: 14px;
  text-shadow: 0 0 14px #6040c040;
}

/* ── Main game title — Cinzel, large, gold ──────────────── */
.game-title {
  font-family: 'Cinzel', serif;
  font-size: var(--fs-h1);
  font-weight: 700;
  text-align: center;
  letter-spacing: 8px;
  line-height: 1.15;
  background: linear-gradient(135deg, #ffcf5c 0%, #a6852d 45%, #ffcf5c 55%, #a6852d 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmerGold 6s linear infinite;
  text-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 1;
  position: relative;
}

@keyframes shimmerGold {
  to {
    background-position: 200% center;
  }
}

/* ── Ornament divider ✦ ─── ✦ ─── ✦ ────────────────────── */
.title-ornament {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 280px;
  margin: 14px auto 10px;
}

.title-ornament span:not(.orn-gem) {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, #5040a0, transparent);
}

.orn-gem {
  font-size: var(--fs-sm);
  color: var(--gold);
  text-shadow: 0 0 12px var(--gold-glow), 0 0 28px #c0800060;
  animation: float 3s ease-in-out infinite;
}

/* ── Subtitle — Cinzel, spaced, muted ──────────────────── */
.subtitle {
  font-family: 'Cinzel', serif;
  font-size: var(--fs-sm);
  font-weight: 400;
  color: #8070b8;
  letter-spacing: 10px;
  text-shadow: 0 0 20px #6050a040;
  margin-bottom: 10px;
}

/* ── Tagline ────────────────────────────────────────────── */
.title-tagline {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: var(--fs-base);
  font-style: italic;
  color: #504878;
  text-align: center;
  letter-spacing: 0.5px;
  line-height: 1.6;
  margin-top: 2px;
}

/* ── CONTINUE button (full-width, above grid) ───────────── */
.title-continue-btn {
  font-family: 'Cinzel', serif !important;
  font-size: var(--fs-sm) !important;
  letter-spacing: 3px !important;
  width: 100%;
  max-width: 440px;
  z-index: 1;
  margin: 0 0 14px;
  background: linear-gradient(180deg, #0d1a30, #081220) !important;
  border: 1px solid #4a80b0 !important;
  color: #80c0f0 !important;
  padding: 16px 20px !important;
  box-shadow: 0 0 20px #3a608030, inset 0 1px 0 #ffffff10 !important;
}

.title-continue-btn:hover {
  border-color: #70b8e8 !important;
  box-shadow: 0 0 30px #4a90c060 !important;
  color: #b0d8f8 !important;
}

/* ── Action container: helps with landscape row layout ── */
.title-actions-row {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  align-items: center;
  gap: 16px;
  z-index: 2;
}

/* ── Menu button grid ───────────────────────────────────── */
.menu-btns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 600px;
  z-index: 1;
}

/* ── New cinematic title buttons ────────────────────────── */
.title-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 24px 12px;
  background: rgba(13, 10, 32, 0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(144, 128, 255, 0.15);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

/* subtle inner top-highlight */
.title-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
}

.tbtn-icon {
  font-size: 1.75rem;
  line-height: 1;
  filter: drop-shadow(0 0 10px currentColor);
  transition: transform 0.3s ease;
}

.title-btn:hover .tbtn-icon {
  transform: translateY(-4px) scale(1.1);
}

.tbtn-label {
  font-family: 'Cinzel', serif;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Secondary — purple/violet (BOSS MODE) */
.title-btn-secondary {
  color: #b080ff;
}

.title-btn-secondary:hover {
  background: rgba(30, 10, 50, 0.6);
  border-color: #9060e0;
  box-shadow: 0 10px 40px rgba(144, 96, 224, 0.2);
  color: #d0a0ff;
}

/* Primary — gold/amber (NEW STORY) */
.title-btn-primary {
  color: #c0a040;
}

.title-btn-primary:hover {
  background: rgba(40, 30, 10, 0.6);
  border-color: var(--gold);
  box-shadow: 0 10px 40px rgba(255, 207, 92, 0.15);
  color: var(--gold);
}

/* Tertiary — teal/green (EXPLORE) */
.title-btn-tertiary {
  color: #40a880;
}

.title-btn-tertiary:hover {
  background: rgba(10, 40, 30, 0.6);
  border-color: #40c090;
  box-shadow: 0 10px 40px rgba(64, 192, 144, 0.15);
  color: #70d8a8;
}

/* Highlight — Cyan (INSTALL) */
.title-btn-highlight {
  color: var(--cyan);
  background: rgba(0, 242, 255, 0.05);
  border: 1px solid rgba(0, 242, 255, 0.25);
  animation: pwaPulse 2s ease-in-out infinite alternate;
}

.title-btn-highlight:hover {
  background: rgba(0, 242, 255, 0.15);
  border-color: var(--cyan);
  box-shadow: 0 10px 40px rgba(0, 242, 255, 0.2);
  color: #fff;
}

@keyframes pwaPulse {
  from { box-shadow: 0 0 10px rgba(0, 242, 255, 0.1); border-color: rgba(0, 242, 255, 0.25); }
  to { box-shadow: 0 0 25px rgba(0, 242, 255, 0.3); border-color: var(--cyan); }
}

/* System — gray/slate (REINSTALL) */
.title-btn-system {
  color: #64748b;
  border-color: rgba(100, 116, 139, 0.2);
}

.title-btn-system:hover {
  background: rgba(100, 116, 139, 0.1);
  border-color: #94a3b8;
  color: #f43f5e;
}

.ver-tag {
  position: absolute;
  bottom: 0.8rem;
  right: 1rem;
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: var(--fs-xs);
  color: #2a2050;
  letter-spacing: 1px;
  z-index: 1;
}

.reinstall-link {
  cursor: pointer;
  color: #4a4070;
  margin-left: 10px;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s ease;
}

.reinstall-link:hover {
  color: #fb7185;
}

/* ── Title responsive — tablet (≤ 920px) ────────────────── */
@media (max-width: 920px) {
  .game-title {
    font-size: 2.75rem;
    letter-spacing: 6px;
  }

  .menu-btns {
    max-width: 500px;
  }

  .title-continue-btn {
    max-width: 400px;
  }
}

/* ── Title responsive — mobile (≤ 768px) ────────────────── */
@media (max-width: 768px) {
  #title-screen {
    padding-top: 20px;
    justify-content: flex-start;
  }

  .title-hero {
    transform: scale(0.85);
    margin-bottom: 16px;
  }

  .game-title {
    font-size: 3rem;
    letter-spacing: 4px;
  }

  .title-tagline {
    font-size: 0.8rem;
    max-width: 280px;
    margin: 10px auto;
  }

  /* Hide side heroes on narrow screens */
  .hero-sil[data-hero="tao"],
  .hero-sil[data-hero="rei"],
  .hero-sil[data-hero="lulu"] {
    display: none;
  }

  .hero-sil[data-hero="aya"] {
    height: 40vh;
    min-width: 220px;
  }

  /* Fix: grid-template is the correct property for a grid container */
  .menu-btns {
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    width: 100%;
    max-width: 440px;
    gap: 10px;
  }

  .title-btn {
    padding: 14px 8px;
    gap: 5px;
  }

  .tbtn-label {
    font-size: var(--fs-xxs);
    letter-spacing: 1px;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
  }

  .title-continue-btn {
    padding: 12px 20px !important;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .hero-sil[data-hero="tao"],
  .hero-sil[data-hero="rei"] {
    display: none;
  }

  .hero-sil {
    height: 45vh;
  }
}

/* ── Title responsive — mobile portrait (≤ 600px) ────────── */
@media (max-width: 600px) {
  #title-screen {
    padding: 24px 16px 16px;
    gap: 0;
  }

  .game-title {
    font-size: 2.125rem;
    letter-spacing: 5px;
  }

  .subtitle {
    font-size: var(--fs-xs);
    letter-spacing: 8px;
  }

  .title-tagline {
    font-size: var(--fs-sm);
  }

  .title-hero {
    margin-bottom: 16px;
  }

  /* 2-column grid on medium mobile */
  .menu-btns {
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    max-width: 100%;
    gap: 8px;
  }

  .title-btn {
    padding: 14px 8px;
    gap: 5px;
  }

  .tbtn-label {
    font-size: var(--fs-xxs);
    letter-spacing: 1px;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
  }

  .tbtn-icon {
    font-size: 1.2rem;
  }

  .title-continue-btn {
    max-width: 380px;
    padding: 11px 20px !important;
  }
}

/* ── Title responsive — iPhone SE and small mobile (≤ 400px) ── */
@media (max-width: 400px) {
  #title-screen {
    padding: 16px 12px 16px;
    justify-content: center;
  }

  /* Hide decorative extras to compress the block */
  .title-eyebrow,
  .title-tagline,
  .title-ornament {
    display: none;
  }

  .game-title {
    font-size: 1.75rem;
    letter-spacing: 3px;
  }

  .subtitle {
    font-size: var(--fs-xxs);
    letter-spacing: 5px;
    margin-bottom: 6px;
  }

  .title-hero {
    margin-bottom: 16px;
    transform: none;
  }

  /* iPhone SE: compact 3-column grid */
  .menu-btns {
    grid-template-columns: repeat(auto-fit, minmax(75px, 1fr));
    width: 100%;
    max-width: 100%;
    gap: 6px;
    margin-top: 0;
  }

  .title-btn {
    padding: 14px 6px;
    gap: 5px;
    border-radius: 6px;
  }

  .tbtn-icon {
    font-size: 1.4rem;
  }

  .tbtn-label {
    font-size: 0.6rem;
    letter-spacing: 1px;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
  }

  .title-continue-btn {
    max-width: 100%;
    padding: 12px 16px !important;
    font-size: var(--fs-xxs) !important;
    letter-spacing: 2px !important;
    margin-bottom: 12px;
  }
}

/* ── Title — landscape phone override ───────────────────── */
@media (orientation: landscape) and (max-height: 500px) {
  #title-screen {
    padding: 12px 20px;
    gap: 0;
    min-height: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  /* Hide decorative extras to save vertical space */
  .title-eyebrow,
  .title-ornament,
  .title-tagline,
  .ver-tag {
    display: none;
  }

  .title-hero {
    margin-bottom: 12px;
    transform: none;
    text-align: center;
  }

  .game-title {
    font-size: 1.45rem;
    letter-spacing: 4px;
    line-height: 1.1;
  }

  .subtitle {
    font-size: 0.6rem;
    letter-spacing: 5px;
    margin-top: 8px;
    opacity: 0.85;
    text-transform: uppercase;
  }

  /* Container for ALL actions in one row */
  .title-actions-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: auto;
    max-width: 95%;
  }

  .title-continue-btn {
    flex: 2;
    min-width: 140px;
    padding: 12px 16px !important;
    font-size: 0.65rem !important;
    letter-spacing: 2px !important;
    margin-bottom: 0 !important;
    border-radius: 6px;
  }

  .menu-btns {
    flex: 3;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 8px;
    margin-top: 0;
    width: auto;
    max-width: 500px;
  }

  .title-btn {
    padding: 10px 8px;
    gap: 4px;
    min-width: 70px;
  }

  .tbtn-icon {
    font-size: 1rem;
  }

  .tbtn-label {
    font-size: 0.55rem;
    letter-spacing: 0.5px;
    line-height: 1.1;
  }
}


/* ── Home Engine Keyframes (extracted from JS injection) ───── */
@keyframes essenceFloat {
  0% { transform: translateY(0) translateX(0); opacity: 0; }
  10% { opacity: 0.5; }
  100% { transform: translateY(-110vh) translateX(30px); opacity: 0; }
}

@keyframes debrisFloat {
  0% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-40px) rotate(180deg); }
  100% { transform: translateY(0) rotate(360deg); }
}
