/* ============================================
   IMMERSIVE SIDEBAR - Cinematic Entrance Effect
   ============================================ */

/* ---------------------------------------------------------
   1. SCROLL LOCK - Prevent body scrolling during immersive mode
   --------------------------------------------------------- */

/* Lock body scroll during immersive mode */
body[data-immersive-state="true"] {
  overflow: hidden !important;
  height: 100vh !important;
  height: 100dvh !important;
}

body[data-immersive-state="true"] html {
  overflow: hidden !important;
}

/* ---------------------------------------------------------
   2. DEFAULT STATE - Fixed sidebar
   --------------------------------------------------------- */

@media screen and (min-width: 60rem) {
  .left-panel {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 20rem !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 100 !important;
    overflow-y: auto !important;
  }
  
  #main-content {
    margin-left: 20rem !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ---------------------------------------------------------
   3. INITIAL FULL-VIEWPORT OVERLAY STATE
   --------------------------------------------------------- */

@media screen and (min-width: 60rem) {
  .left-panel[data-immersive="true"] {
    width: 100vw !important;
    width: 100dvw !important;
    z-index: 1000 !important;
    
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    
    transition: width 750ms cubic-bezier(0.4, 0, 0.2, 1) !important;
    
    overflow: hidden !important;
    padding: 2rem !important;
  }
  
  .left-panel[data-immersive="true"] .left-panel__content {
    transform: scale(1.2);
    transition: transform 750ms cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .left-panel[data-immersive="true"] .left-panel__avatar {
    width: 150px;
    height: 150px;
    transition: all 750ms cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .left-panel[data-immersive="true"] .left-panel__title {
    font-size: 2.5rem;
    transition: font-size 750ms cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  /* Hide main content initially */
  body[data-immersive-state="true"] #main-content {
    opacity: 0;
    margin-left: 0 !important;
    pointer-events: none !important;
    transition: opacity 500ms ease, margin-left 750ms cubic-bezier(0.4, 0, 0.2, 1);
  }
}

/* ---------------------------------------------------------
   4. MORPHED STATE
   --------------------------------------------------------- */

@media screen and (min-width: 60rem) {
  .left-panel[data-immersive="morphed"] {
    width: 20rem !important;
    z-index: 100 !important;
    transition: width 750ms cubic-bezier(0.4, 0, 0.2, 1) !important;
    padding: 1.5rem !important;
  }
  
  .left-panel[data-immersive="morphed"] .left-panel__content {
    transform: scale(1);
    transition: transform 750ms cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  .left-panel[data-immersive="morphed"] .left-panel__avatar {
    width: 100px;
    height: 100px;
  }
  
  .left-panel[data-immersive="morphed"] .left-panel__title {
    font-size: 2rem;
  }
  
  /* Reveal main content and restore pointer events */
  body[data-immersive-state="morphed"] #main-content,
  body[data-immersive-state="complete"] #main-content {
    opacity: 1;
    margin-left: 20rem !important;
    pointer-events: auto !important;
  }
}

/* ---------------------------------------------------------
   5. SCROLL INDICATOR
   --------------------------------------------------------- */

@media screen and (min-width: 60rem) {
  .scroll-indicator {
    position: absolute;
    bottom: 3rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    opacity: 1;
    transition: opacity 400ms ease, transform 400ms ease;
    pointer-events: none;
  }
  
  .left-panel[data-immersive="morphed"] .scroll-indicator,
  .left-panel[data-immersive="complete"] .scroll-indicator,
  body[data-immersive-state="complete"] .scroll-indicator {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  
  .scroll-indicator__chevron {
    width: 30px;
    height: 40px;
    position: relative;
  }
  
  .scroll-indicator__chevron::before,
  .scroll-indicator__chevron::after {
    content: '';
    position: absolute;
    left: 50%;
    width: 12px;
    height: 12px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateX(-50%) rotate(45deg);
    animation: bounce-chevron 2s ease-in-out infinite;
  }
  
  .scroll-indicator__chevron::before { top: 0; animation-delay: 0s; }
  .scroll-indicator__chevron::after { top: 10px; animation-delay: 0.2s; opacity: 0.6; }
  
  @keyframes bounce-chevron {
    0%, 20%, 50%, 80%, 100% { transform: translateX(-50%) rotate(45deg) translateY(0); }
    40% { transform: translateX(-50%) rotate(45deg) translateY(10px); }
    60% { transform: translateX(-50%) rotate(45deg) translateY(5px); }
  }
}

/* ---------------------------------------------------------
   6. DARK MODE SUPPORT
   --------------------------------------------------------- */

[data-theme="dark"] .left-panel,
.dark-mode .left-panel {
  background-color: var(--color-bg);
  border-color: var(--color-border);
}

[data-theme="dark"] .left-panel__title,
.dark-mode .left-panel__title {
  color: var(--color-text);
}

[data-theme="dark"] .left-panel__description,
.dark-mode .left-panel__description {
  color: var(--color-text-secondary);
}

[data-theme="dark"] .nav-menu a,
.dark-mode .nav-menu a {
  color: var(--color-text);
  border-color: var(--color-border);
}

[data-theme="dark"] .nav-menu a:hover,
[data-theme="dark"] .nav-menu a:focus-visible,
.dark-mode .nav-menu a:hover,
.dark-mode .nav-menu a:focus-visible {
  background-color: var(--color-bg-secondary);
  border-color: var(--color-primary);
}

[data-theme="dark"] .left-panel__footer,
.dark-mode .left-panel__footer {
  color: var(--color-text-muted);
}

[data-theme="dark"] .scroll-indicator__text,
.dark-mode .scroll-indicator__text {
  color: var(--color-text-secondary);
}

/* ---------------------------------------------------------
   7. MOBILE & REDUCED MOTION
   --------------------------------------------------------- */

@media screen and (max-width: 60rem) {
  .scroll-indicator { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .left-panel, .left-panel *, #main-content {
    transition: none !important;
  }
  .scroll-indicator__chevron::before,
  .scroll-indicator__chevron::after {
    animation: none !important;
  }
}
