/* ══════════════════════════════════════════════════════════════════
   GLOBAL PORTFOLIO LOADER & VISITOR EXPERIENCE PROMPT
   Aesthetic: Cyberpunk Aurora Night, Luxury Dark Glass, Neon Accents
══════════════════════════════════════════════════════════════════ */

/* Prevent scroll while loader is visible */
body.loader-active {
  overflow: hidden !important;
}

.app-loader {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: #020612;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transition: opacity 0.55s cubic-bezier(0.2, 0, 0, 1), transform 0.55s cubic-bezier(0.2, 0, 0, 1);
}

.app-loader.loader-dismissed {
  opacity: 0;
  transform: scale(1.025);
  pointer-events: none;
}

.app-loader.loader-instant-hidden {
  display: none !important;
}

/* ── Atmospheric Nebula Backdrop ── */
.loader-backdrop {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 55% at 50% 28%, rgba(56, 189, 248, 0.14) 0%, transparent 70%),
    radial-gradient(ellipse 65% 50% at 50% 75%, rgba(245, 158, 11, 0.09) 0%, transparent 65%),
    linear-gradient(180deg, #020612 0%, #030a1c 50%, #01040d 100%);
  z-index: 1;
}

/* Subtle cybernetic scanline grid */
.loader-backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(56, 189, 248, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.035) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.85;
}

/* ── Loader Content Stage ── */
.loader-content {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 580px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: auto;
}

/* ── Brand Hex Core & Orbit Rings ── */
.loader-brand-stage {
  position: relative;
  width: 108px;
  height: 108px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 22px;
}

.loader-orbit-ring {
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 1px dashed rgba(56, 189, 248, 0.35);
  animation: loaderOrbit 16s linear infinite;
  pointer-events: none;
}

.loader-ring-2 {
  inset: -24px;
  border-style: dotted;
  border-color: rgba(245, 158, 11, 0.28);
  animation: loaderOrbitRev 22s linear infinite;
}

@keyframes loaderOrbit {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes loaderOrbitRev {
  from { transform: rotate(360deg); }
  to   { transform: rotate(0deg); }
}

.loader-hex-core {
  position: relative;
  width: 78px;
  height: 78px;
  background: linear-gradient(145deg, rgba(8, 24, 56, 0.95), rgba(4, 12, 30, 0.98));
  border: 1.5px solid rgba(56, 189, 248, 0.65);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace, monospace;
  font-size: 1.35rem;
  font-weight: 800;
  color: #ffffff;
  box-shadow: 
    0 0 30px rgba(56, 189, 248, 0.35),
    0 0 15px rgba(245, 158, 11, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  animation: corePulse 3.5s ease-in-out infinite alternate;
}

@keyframes corePulse {
  0%   { transform: scale(1.0); box-shadow: 0 0 25px rgba(56, 189, 248, 0.35), 0 0 12px rgba(245, 158, 11, 0.2); }
  100% { transform: scale(1.04); box-shadow: 0 0 40px rgba(56, 189, 248, 0.6), 0 0 22px rgba(245, 158, 11, 0.45); }
}

.loader-bracket {
  color: #f59e0b;
}

/* ── Typography Group ── */
.loader-text-group {
  margin-bottom: 22px;
}

.loader-kicker {
  font-family: 'JetBrains Mono', monospace, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #38bdf8;
  margin-bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 12px;
  border-radius: 9999px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.loader-title {
  font-family: 'Syne', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: clamp(2rem, 5.5vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  line-height: 1.15;
  background: linear-gradient(135deg, #ffffff 0%, #e0f2fe 35%, #38bdf8 65%, #fbbf24 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 18px rgba(56, 189, 248, 0.3));
}

.loader-subtitle {
  font-size: clamp(0.85rem, 2.2vw, 0.98rem);
  color: #94a3b8;
  margin: 0 0 16px;
  line-height: 1.5;
  max-width: 440px;
}

/* Terminal typing line */
.loader-terminal-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace, monospace;
  font-size: 0.78rem;
  color: #e2e8f0;
  background: rgba(4, 12, 32, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 6px 14px;
  border-radius: 8px;
  min-height: 34px;
  max-width: 100%;
}

.terminal-prompt {
  color: #10b981;
  font-weight: 700;
}

.terminal-text {
  color: #bae6fd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.terminal-cursor {
  color: #f59e0b;
  font-weight: 700;
  animation: termBlink 0.9s infinite;
}

@keyframes termBlink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

/* ── Progress Bar ── */
.loader-progress-wrap {
  width: 100%;
  max-width: 380px;
  margin-bottom: 24px;
  transition: opacity 0.3s ease;
}

.loader-progress-bar {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
}

.loader-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #38bdf8 0%, #0ea5e9 40%, #fbbf24 80%, #f59e0b 100%);
  border-radius: 9999px;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.8), 0 0 6px rgba(245, 158, 11, 0.6);
  transition: width 0.12s linear;
}

.loader-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  font-family: 'JetBrains Mono', monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: #64748b;
}

.loader-mono-num {
  color: #f59e0b;
  font-weight: 700;
}

/* ── Experience Choice Card (Mobile & Choice Interface) ── */
.loader-choice-card {
  width: 100%;
  background: rgba(6, 14, 34, 0.94);
  border: 1.5px solid rgba(56, 189, 248, 0.35);
  border-radius: 20px;
  padding: 20px 18px 18px;
  box-shadow: 
    0 16px 45px rgba(0, 0, 0, 0.85),
    0 0 30px rgba(56, 189, 248, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  display: none; /* revealed when progress reaches 100% or on mobile */
  animation: choiceFadeIn 0.45s cubic-bezier(0.2, 0, 0, 1) forwards;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

@keyframes choiceFadeIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1.0); }
}

.choice-card-header {
  margin-bottom: 14px;
}

.choice-badge {
  font-family: 'JetBrains Mono', monospace, monospace;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 6px;
  padding: 3px 8px;
  display: inline-block;
  margin-bottom: 6px;
  line-height: 1;
}

.choice-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.22rem;
  font-weight: 800;
  color: #ffffff;
  margin: 0 0 4px;
  line-height: 1.25;
}

.choice-desc {
  font-size: 0.82rem;
  color: #94a3b8;
  margin: 0;
  line-height: 1.42;
}

.choice-options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

@media (min-width: 520px) {
  .choice-options-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.choice-option-btn {
  background: rgba(10, 22, 48, 0.75);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 13px 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.2, 0, 0, 1);
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.choice-option-btn:hover {
  background: rgba(14, 30, 64, 0.9);
  border-color: rgba(56, 189, 248, 0.45);
}

/* Static Choice Specific (Emerald / Performance Theme) */
.choice-option-btn.choice-static-btn.selected {
  background: linear-gradient(145deg, rgba(6, 32, 26, 0.92), rgba(4, 18, 38, 0.96));
  border-color: #10b981;
  box-shadow: 
    0 8px 24px rgba(0, 0, 0, 0.6),
    0 0 20px rgba(16, 185, 129, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 0 16px rgba(16, 185, 129, 0.08);
}

.choice-option-btn.choice-static-btn .choice-option-icon {
  color: #34d399;
  filter: drop-shadow(0 0 6px rgba(52, 211, 153, 0.35));
}

.choice-option-btn.choice-static-btn.selected .choice-radio-indicator {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.2);
}

.choice-option-btn.choice-static-btn.selected .choice-radio-indicator span {
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

/* Video Choice Specific (Cyan / Cinematic Theme) */
.choice-option-btn.choice-video-btn.selected {
  background: linear-gradient(145deg, rgba(8, 28, 56, 0.92), rgba(4, 14, 34, 0.96));
  border-color: #38bdf8;
  box-shadow: 
    0 8px 24px rgba(0, 0, 0, 0.6),
    0 0 20px rgba(56, 189, 248, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 0 16px rgba(56, 189, 248, 0.1);
}

.choice-option-btn.choice-video-btn .choice-option-icon {
  color: #38bdf8;
  filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.4));
}

.choice-option-btn.choice-video-btn.selected .choice-radio-indicator {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.2);
}

.choice-option-btn.choice-video-btn.selected .choice-radio-indicator span {
  background: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
}

.choice-option-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.choice-option-tag {
  font-family: 'JetBrains Mono', monospace, monospace;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 5px;
  line-height: 1.2;
}

.choice-option-tag.recommended {
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #34d399;
}

.choice-option-tag.high-def {
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #7dd3fc;
}

.choice-radio-indicator {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.choice-radio-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.2s ease;
}

.choice-option-btn.selected .choice-radio-indicator span {
  opacity: 1;
  transform: scale(1);
}

.choice-option-name {
  font-family: 'Syne', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.choice-option-info {
  font-size: 0.75rem;
  color: #94a3b8;
  line-height: 1.40;
  letter-spacing: 0.01em;
}

/* ── Enter Buttons ── */
.loader-enter-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 26px;
  font-size: 0.96rem;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #030712;
  border: none;
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.45);
  transition: all 0.25s cubic-bezier(0.2, 0, 0, 1);
}

.loader-enter-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(245, 158, 11, 0.65);
}

.loader-enter-btn:active {
  transform: translateY(0);
}

/* ── Desktop Direct Entry Action ── */
.loader-desktop-action {
  display: none;
  width: 100%;
  max-width: 380px;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: choiceFadeIn 0.4s ease forwards;
}

.desktop-mode-pill {
  font-family: 'JetBrains Mono', monospace, monospace;
  font-size: 0.75rem;
  color: #a7f3d0;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 9999px;
  padding: 5px 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.desktop-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: dotBlink 1.5s infinite;
}

@keyframes dotBlink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.8); }
}

/* ── Quick Navbar Mode Toggle Pill ── */
.bg-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  background: rgba(6, 16, 38, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 9999px;
  color: #ffffff;
  font-family: 'JetBrains Mono', monospace, monospace;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.bg-mode-toggle:hover {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.18);
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.3);
  transform: translateY(-1px);
}

.bg-mode-icon {
  font-size: 0.88rem;
  line-height: 1;
}

/* Hide toggle text on very small screens to keep navbar compact */
@media (max-width: 480px) {
  .bg-mode-toggle {
    padding: 6px 10px;
  }
}

/* Safe area padding for mobile notches and dynamic islands */
.app-loader {
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

/* Compact layout for mobile screens to guarantee complete modal fits without scrolling */
@media (max-width: 600px), ((max-width: 900px) and (max-height: 840px)) {
  .app-loader {
    padding: 16px 14px;
    align-items: center;
  }
  .loader-brand-stage {
    width: 68px;
    height: 68px;
    margin-bottom: 12px;
  }
  .loader-hex-core {
    width: 52px;
    height: 52px;
    font-size: 1.05rem;
    border-radius: 14px;
  }
  .loader-orbit-ring { inset: -9px; }
  .loader-ring-2 { inset: -16px; }
  .loader-text-group {
    margin-bottom: 12px;
  }
  .loader-kicker {
    font-size: 0.65rem;
    padding: 2px 10px;
    margin-bottom: 4px;
  }
  .loader-title {
    font-size: 1.65rem;
    margin-bottom: 4px;
    line-height: 1.18;
  }
  .loader-subtitle {
    font-size: 0.82rem;
    line-height: 1.35;
    margin-bottom: 8px;
  }
  .loader-terminal-line {
    font-size: 0.72rem;
    padding: 4px 10px;
    min-height: 28px;
  }
  .loader-choice-card {
    padding: 16px 14px 14px;
    border-radius: 16px;
  }
  .choice-card-header {
    margin-bottom: 10px;
  }
  .choice-badge {
    font-size: 0.62rem;
    padding: 2px 6px;
    margin-bottom: 4px;
  }
  .choice-title {
    font-size: 1.10rem;
    margin-bottom: 3px;
  }
  .choice-desc {
    font-size: 0.78rem;
    line-height: 1.35;
  }
  .choice-options-grid {
    gap: 8px;
    margin-bottom: 12px;
  }
  .choice-option-btn {
    padding: 10px 12px;
    gap: 4px;
  }
  .choice-option-name {
    font-size: 0.88rem;
  }
  .choice-option-info {
    font-size: 0.72rem;
    line-height: 1.32;
  }
  .loader-enter-btn {
    padding: 11px 20px;
    font-size: 0.90rem;
  }
}

/* Compact layout for landscape phones (height <= 520px) */
@media (max-height: 520px) {
  .app-loader {
    align-items: flex-start;
    padding: 12px 16px;
  }
  .loader-brand-stage {
    width: 60px;
    height: 60px;
    margin-bottom: 8px;
  }
  .loader-hex-core {
    width: 48px;
    height: 48px;
    font-size: 0.95rem;
    border-radius: 12px;
  }
  .loader-orbit-ring { inset: -8px; }
  .loader-ring-2 { inset: -14px; }
  .loader-term-card {
    padding: 6px 12px;
    margin-bottom: 8px;
  }
  .choice-card-header {
    margin-bottom: 8px;
  }
  .choice-title {
    font-size: 1.05rem;
    margin-bottom: 2px;
  }
  .choice-desc {
    display: none;
  }
  .choice-options-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
  }
  .choice-option-btn {
    padding: 8px 10px;
    gap: 3px;
  }
  .choice-option-info {
    font-size: 0.70rem;
    line-height: 1.3;
  }
  .loader-enter-btn {
    padding: 8px 16px;
    font-size: 0.88rem;
  }
}
