/* =====================================================
   IEEE RAS SMU — Immersive Game-World Intro
   ===================================================== */

/* ── Base overlay ── */
#intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #020008;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-family: 'Outfit', sans-serif;
  cursor: crosshair;
}

#intro-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* ── Atmospheric fog layers ── */
.intro-fog {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 50% 100%, rgba(95,1,128,0.35) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 20% 60%, rgba(153,51,255,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 40%, rgba(217,126,255,0.08) 0%, transparent 60%);
  animation: fog-breathe 8s ease-in-out infinite;
}
@keyframes fog-breathe {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50%       { opacity: 1;   transform: scale(1.04); }
}

/* ── Scanline overlay ── */
#intro-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 3px,
    rgba(0,0,0,0.04) 3px,
    rgba(0,0,0,0.04) 6px
  );
  pointer-events: none;
  z-index: 2;
}

/* ── Vignette ── */
#intro-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.75) 100%);
  pointer-events: none;
  z-index: 2;
}

/* ── Corner HUD brackets ── */
.intro-corner {
  position: absolute;
  width: 40px;
  height: 40px;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  animation: corner-appear 1s ease forwards;
}
.intro-corner.tl { top: 28px; left: 28px; animation-delay: 0.2s; }
.intro-corner.tr { top: 28px; right: 28px; animation-delay: 0.4s; transform: scaleX(-1); }
.intro-corner.bl { bottom: 28px; left: 28px; animation-delay: 0.6s; transform: scaleY(-1); }
.intro-corner.br { bottom: 28px; right: 28px; animation-delay: 0.8s; transform: scale(-1); }
@keyframes corner-appear {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.intro-corner::before,
.intro-corner::after {
  content: '';
  position: absolute;
  background: #D97EFF;
  box-shadow: 0 0 8px rgba(217,126,255,0.8);
}
.intro-corner::before { width: 100%; height: 2px; top: 0; left: 0; }
.intro-corner::after  { width: 2px; height: 100%; top: 0; left: 0; }

/* ── Sweep lines ── */
.intro-sweep-line {
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(217,126,255,0.6), rgba(255,110,255,0.8), rgba(217,126,255,0.6), transparent);
  z-index: 3;
  opacity: 0;
  pointer-events: none;
}
.intro-sweep-line.s1 { animation: sweep-down 4s ease-in-out 0.5s infinite; }
.intro-sweep-line.s2 { animation: sweep-down 6.5s ease-in-out 2.5s infinite; }
@keyframes sweep-down {
  0%   { top: -2px; opacity: 0; }
  5%   { opacity: 0.8; }
  95%  { opacity: 0.4; }
  100% { top: 100%; opacity: 0; }
}

/* ── Badge ── */
.intro-badge {
  position: absolute;
  top: 36px;
  left: 44px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  opacity: 0;
  animation: fade-in-left 0.8s ease 1s forwards;
}
@keyframes fade-in-left {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}
.intro-badge-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #FF6EFF;
  box-shadow: 0 0 12px #FF6EFF, 0 0 24px rgba(255,110,255,0.5);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(0.75); }
}
.intro-badge-text {
  font-family: 'Syne', sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(217,126,255,0.8);
}

/* ── Skip button ── */
#intro-skip {
  position: absolute;
  top: 36px; right: 44px;
  z-index: 10;
  background: none;
  border: 1px solid rgba(217,126,255,0.2);
  color: rgba(217,126,255,0.5);
  font-family: 'Syne', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.45rem 1.1rem;
  border-radius: 3px;
  cursor: pointer;
  transition: border-color 0.3s, color 0.3s, box-shadow 0.3s;
  opacity: 0;
  animation: fade-in-right 0.8s ease 1.2s forwards;
}
@keyframes fade-in-right {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}
#intro-skip:hover {
  border-color: rgba(217,126,255,0.7);
  color: #D97EFF;
  box-shadow: 0 0 20px rgba(217,126,255,0.15);
}

/* ─────────────────────────────────────────────
   MAIN CONTENT
───────────────────────────────────────────── */
.intro-content {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 680px;
  padding: 2rem;
  pointer-events: none;
  margin-top: 54vh;
}

/* ── Boot Phase ── */
#intro-boot-phase {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 420px;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

#intro-status-line {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}
.intro-status-cursor {
  width: 7px; height: 15px;
  background: #D97EFF;
  box-shadow: 0 0 10px #D97EFF;
  animation: blink-cursor 0.8s step-end infinite;
}
@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}
#intro-status {
  font-size: 0.75rem;
  color: rgba(217,126,255,0.85);
  font-family: 'Outfit', monospace;
  letter-spacing: 0.06em;
  font-weight: 300;
}

.intro-progress-track {
  width: 100%;
  height: 3px;
  background: rgba(217,126,255,0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.7rem;
  position: relative;
}
#intro-progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5F0180, #9933ff, #D97EFF, #FF6EFF);
  border-radius: 3px;
  box-shadow: 0 0 16px rgba(217,126,255,0.8), 0 0 4px rgba(255,110,255,1);
  position: relative;
  transition: width 0.08s linear;
}
#intro-progress::after {
  content: '';
  position: absolute;
  right: 0; top: -3px;
  width: 3px; height: 9px;
  background: white;
  border-radius: 2px;
  box-shadow: 0 0 10px white;
}

#intro-counter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}
#intro-counter {
  font-family: 'Syne', sans-serif;
  font-size: 0.72rem;
  font-weight: 800;
  color: #D97EFF;
  letter-spacing: 0.05em;
}
#intro-pct-label {
  font-family: 'Outfit', monospace;
  font-size: 0.65rem;
  color: rgba(217,126,255,0.4);
  letter-spacing: 0.08em;
}

#intro-log {
  width: 100%;
  max-width: 420px;
  margin-top: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: 80px;
  overflow: hidden;
}
.intro-log-entry {
  font-family: 'Outfit', monospace;
  font-size: 0.65rem;
  color: rgba(217,126,255,0.3);
  letter-spacing: 0.04em;
  opacity: 0;
  animation: log-appear 0.3s ease forwards;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.intro-log-entry.active { color: rgba(217,126,255,0.75); }
@keyframes log-appear {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Reveal Phase ── */
#intro-reveal-phase {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 780px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem;
  opacity: 0;
  pointer-events: none;
  top: 50%;
  margin-top: -220px;
}

.intro-world-tag {
  font-family: 'Syne', sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: rgba(217,126,255,0.55);
  margin-bottom: 1.8rem;
  opacity: 0;
  transform: translateY(10px);
}
.intro-world-tag::before,
.intro-world-tag::after {
  content: '─';
  margin: 0 0.9rem;
  opacity: 0.4;
}

#intro-title {
  font-family: 'Syne', sans-serif;
  font-size: clamp(3rem, 9vw, 6rem);
  font-weight: 800;
  text-align: center;
  line-height: 0.92;
  margin-bottom: 1.6rem;
  letter-spacing: -0.02em;
  opacity: 0;
}
.intro-title-line {
  display: block;
  overflow: hidden;
  line-height: 1.05;
}
.intro-title-word {
  display: inline-block;
  transform: translateY(110%);
  opacity: 0;
  background: linear-gradient(160deg, #ffffff 0%, #e8d5ff 30%, #D97EFF 65%, #FF6EFF 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 40px rgba(217,126,255,0.4));
  transition: transform 0.9s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.7s ease;
}

#intro-subtitle {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(0.78rem, 1.5vw, 0.92rem);
  color: rgba(200,170,230,0.5);
  text-align: center;
  letter-spacing: 0.08em;
  margin-bottom: 3.2rem;
  opacity: 0;
  transform: translateY(14px);
  max-width: 480px;
  line-height: 1.8;
  text-transform: uppercase;
  transition: opacity 0.8s ease, transform 0.8s ease;
}

/* ── Launch button ── */
#intro-launch {
  pointer-events: all;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1.1rem 3rem;
  background: transparent;
  border: 1px solid rgba(217,126,255,0.45);
  border-radius: 2px;
  color: #fff;
  font-family: 'Syne', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease,
              box-shadow 0.4s, border-color 0.4s, color 0.3s;
  box-shadow: 0 0 30px rgba(95,1,128,0.3), inset 0 0 30px rgba(95,1,128,0.08);
  overflow: hidden;
}
#intro-launch::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(217,126,255,0.12), transparent);
  transform: skewX(-20deg);
  animation: launch-shimmer 3.5s ease infinite 3s;
}
@keyframes launch-shimmer {
  0%   { left: -100%; opacity: 0; }
  15%  { opacity: 1; }
  100% { left: 150%; opacity: 0; }
}
.intro-launch-ring {
  position: absolute;
  inset: -1px;
  border-radius: 2px;
  border: 1px solid rgba(217,126,255,0.4);
  animation: ring-pulse 2.5s ease-out infinite 3.5s;
}
@keyframes ring-pulse {
  0%   { opacity: 0.8; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.12); }
}
#intro-launch:hover {
  border-color: rgba(217,126,255,0.9);
  box-shadow: 0 0 70px rgba(153,51,255,0.5), 0 0 140px rgba(95,1,128,0.3), inset 0 0 50px rgba(95,1,128,0.2);
  color: #F0CFFF;
}
#intro-launch:hover .intro-launch-icon { transform: rotate(360deg); }
#intro-launch:active { transform: scale(0.97); }
.intro-launch-icon {
  font-size: 1rem;
  transition: transform 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}

/* ─────────────────────────────────────────────
   PORTAL RINGS
───────────────────────────────────────────── */
.intro-portal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  pointer-events: none;
}
.intro-portal-ring {
  position: absolute;
  top: 50%; left: 50%;
  border-radius: 50%;
  border: 1px solid rgba(217,126,255,0.12);
  transform: translate(-50%, -50%);
  animation: portal-rotate linear infinite;
}
.intro-portal-ring:nth-child(1) { width: 240px; height: 240px; border-color: rgba(217,126,255,0.2);  animation-duration: 18s; border-style: dashed; }
.intro-portal-ring:nth-child(2) { width: 370px; height: 370px; border-color: rgba(153,51,255,0.14); animation-duration: 28s; animation-direction: reverse; }
.intro-portal-ring:nth-child(3) { width: 520px; height: 520px; border-color: rgba(95,1,128,0.09);  animation-duration: 42s; border-style: dashed; }
.intro-portal-ring:nth-child(4) { width: 720px; height: 720px; border-color: rgba(217,126,255,0.05); animation-duration: 65s; animation-direction: reverse; }
@keyframes portal-rotate {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to   { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ── Ground glow ── */
.intro-ground-glow {
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 60vw; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(153,51,255,0.4), rgba(217,126,255,0.7), rgba(255,110,255,0.4), transparent);
  z-index: 3;
  filter: blur(2px);
  animation: ground-pulse 3.5s ease-in-out infinite;
}
@keyframes ground-pulse {
  0%, 100% { opacity: 0.4; width: 40vw; }
  50%       { opacity: 1;   width: 70vw; }
}

/* ── Floating runes ── */
.intro-rune {
  position: absolute;
  font-family: 'Syne', monospace;
  font-size: 0.65rem;
  color: rgba(217,126,255,0.18);
  z-index: 3;
  pointer-events: none;
  letter-spacing: 0.1em;
  animation: rune-drift linear infinite;
}
@keyframes rune-drift {
  0%   { opacity: 0; transform: translateY(0) rotate(0deg); }
  10%  { opacity: 1; }
  90%  { opacity: 0.3; }
  100% { opacity: 0; transform: translateY(-130px) rotate(20deg); }
}

/* ─────────────────────────────────────────────
   FLASH EXIT
───────────────────────────────────────────── */
#intro-overlay.intro-flash { background: #f0e6ff; }

/* ── Hide scrollbar completely while intro is active ── */
body.intro-playing {
  overflow: hidden;
}
body.intro-playing::-webkit-scrollbar { display: none; }
body.intro-playing { scrollbar-width: none; -ms-overflow-style: none; }

/* ── Page entrance (after intro exits) ── */
body.intro-playing #hero,
body.intro-playing nav {
  opacity: 0;
}
body.intro-done #hero,
body.intro-done nav {
  animation: page-entrance 1s ease forwards;
}
@keyframes page-entrance {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Drag hint tooltip ── */
#intro-drag-hint {
  position: absolute;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  font-family: 'Syne', sans-serif;
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(217,126,255,0.4);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0;
  animation: fade-up 0.8s ease 3s forwards, hint-fade 1s ease 8s forwards;
}
@keyframes hint-fade {
  to { opacity: 0; }
}
#intro-drag-hint::before,
#intro-drag-hint::after {
  content: '↔';
  opacity: 0.5;
}

/* ── HUD bar ── */
.intro-hud {
  position: absolute;
  bottom: 36px; left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 3rem;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  animation: fade-up 0.8s ease 2s forwards;
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.intro-hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}
.intro-hud-val {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  color: #D97EFF;
  text-shadow: 0 0 20px rgba(217,126,255,0.6);
}
.intro-hud-label {
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(217,126,255,0.4);
}
.intro-hud-divider {
  width: 1px; height: 32px;
  background: rgba(217,126,255,0.15);
  align-self: center;
}

@media (max-width: 640px) {
  .intro-content { margin-top: 58vh; }
  #intro-reveal-phase { margin-top: -160px; }
  #intro-title { font-size: 2.4rem !important; }
  .intro-hud { gap: 1.5rem; bottom: 24px; }
  .intro-hud-divider { display: none; }
  #intro-launch { padding: 0.9rem 2rem; font-size: 0.78rem; }
  .intro-portal-ring:nth-child(3),
  .intro-portal-ring:nth-child(4) { display: none; }
}
