/* ======================================================
   FILE: mobile.css
   ROLE: Mobile overrides & interaction logic
   OWNS: display, position, z-index (mobile only)
   MUST NOT: redefine tokens, base typography
====================================================== */

/* ======================================================
   MOBILE-FIRST VISIBILITY RULE
   Desktop never hides mobile things — mobile does.
====================================================== */

.subpage-logo-container {
  display: none; /* Hide desktop logo on mobile */
}

/* ========== MOBILE HEADER ========== */
.mobile-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: none; /* Hidden by default, shown in media query */
  justify-content: space-between;
  align-items: center;
  padding: 0 1rem;
  background: rgba(28, 28, 30, 0.95);
  backdrop-filter: blur(10px);
  z-index: 2200;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  height: 60px;
  gap: 0.5rem;
}

.mobile-header-placeholder {
  display: none;
}

/* ========== SEARCH ICON - LEFT SIDE ========== */
.mobile-search-icon {
  flex: 0 0 44px; /* Fixed width */
  position: inherit;
  order: 1;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: white;
  margin: 0;
}

.mobile-search-icon svg {
  width: 24px;
  height: 24px;
  fill: var(--light);
  transition: fill var(--transition-fast);
}

.mobile-search-icon:hover svg {
  fill: var(--primary);
}

.mobile-logo {
  font-family: 'Playfair Display', serif;
  font-weight: bold;
  font-size: 1.5rem;
  color: var(--primary);
}

/* ========== HAMBURGER - FIXED VERSION ========== */
.hamburger {
  /* POSITIONING - ABSOLUTELY FIXED */
  position: fixed !important;
  top: 8px !important;
  right: 1rem !important;
  width: 44px !important;
  height: 44px !important;
  
  /* VISIBILITY */
  display: flex !important;
  opacity: 1 !important;
  visibility: visible !important;
  
  /* STACKING - ULTRA HIGH */
  z-index: 999999 !important;
  
  /* BASIC STYLING */
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  cursor: pointer !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Hamburger lines */
.hamburger-inner {
  width: 30px;
  height: 3px;
  background-color: white !important;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  transition: transform 0.3s ease;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
  border-radius: 4px;
}

.hamburger-inner::before,
.hamburger-inner::after {
  content: '';
  width: 30px;
  height: 3px;
  background-color: var(--light);
  position: absolute;
  left: 0;
  transition: transform 0.3s ease;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
  border-radius: 4px;
}

.hamburger-inner::before {
  top: -10px;
}

.hamburger-inner::after {
  bottom: -10px;
}

/* X TRANSFORMATION - SIMPLE */
.hamburger.active .hamburger-inner {
  transform: rotate(45deg) translateY(-50%) !important;
}

.hamburger.active .hamburger-inner::before {
  transform: rotate(90deg) !important;
  top: 0 !important;
}

.hamburger.active .hamburger-inner::after {
  transform: rotate(90deg) !important;
  bottom: 0 !important;
}

/* ========== CRITICAL: OVERLAY FIX ========== */
/* Force overlay to be BELOW hamburger */
.fullscreen-overlay {
  z-index: 2400 !important; /* MUST be lower than 999999 */
}

/* When overlay is active, hamburger X gets contrast colors */
body .fullscreen-overlay.active ~ .hamburger.active .hamburger-inner,
body .fullscreen-overlay.active ~ .hamburger.active .hamburger-inner::before,
body .fullscreen-overlay.active ~ .hamburger.active .hamburger-inner::after {
  /* Default: white X on dark overlay */
  background-color: white !important;
}

/* Gold X for green background (about) */
body .fullscreen-overlay[data-bg-color="about"].active ~ .hamburger.active .hamburger-inner,
body .fullscreen-overlay[data-bg-color="about"].active ~ .hamburger.active .hamburger-inner::before,
body .fullscreen-overlay[data-bg-color="about"].active ~ .hamburger.active .hamburger-inner::after {
  background-color: var(--life-gold) !important;
}

/* Gold X for black background (what-we-do) */
body .fullscreen-overlay[data-bg-color="what-we-do"].active ~ .hamburger.active .hamburger-inner,
body .fullscreen-overlay[data-bg-color="what-we-do"].active ~ .hamburger.active .hamburger-inner::before,
body .fullscreen-overlay[data-bg-color="what-we-do"].active ~ .hamburger.active .hamburger-inner::after {
  background-color: var(--life-gold) !important;
}

/* Green X for gold background (community) */
body .fullscreen-overlay[data-bg-color="community"].active ~ .hamburger.active .hamburger-inner,
body .fullscreen-overlay[data-bg-color="community"].active ~ .hamburger.active .hamburger-inner::before,
body .fullscreen-overlay[data-bg-color="community"].active ~ .hamburger.active .hamburger-inner::after {
  background-color: var(--art-green) !important;
}

/* Green X for white background (projects) */
body .fullscreen-overlay[data-bg-color="projects"].active ~ .hamburger.active .hamburger-inner,
body .fullscreen-overlay[data-bg-color="projects"].active ~ .hamburger.active .hamburger-inner::before,
body .fullscreen-overlay[data-bg-color="projects"].active ~ .hamburger.active .hamburger-inner::after {
  background-color: var(--art-green) !important;
}

/* Regular hamburger (3 bars) colors for different overlays */
.fullscreen-overlay[data-bg-color="about"] ~ .hamburger:not(.active) .hamburger-inner,
.fullscreen-overlay[data-bg-color="about"] ~ .hamburger:not(.active) .hamburger-inner::before,
.fullscreen-overlay[data-bg-color="about"] ~ .hamburger:not(.active) .hamburger-inner::after {
  background-color: var(--light) !important; /* White on green */
}

.fullscreen-overlay[data-bg-color="what-we-do"] ~ .hamburger:not(.active) .hamburger-inner,
.fullscreen-overlay[data-bg-color="what-we-do"] ~ .hamburger:not(.active) .hamburger-inner::before,
.fullscreen-overlay[data-bg-color="what-we-do"] ~ .hamburger:not(.active) .hamburger-inner::after {
  background-color: var(--light) !important; /* White on black */
}

.fullscreen-overlay[data-bg-color="community"] ~ .hamburger:not(.active) .hamburger-inner,
.fullscreen-overlay[data-bg-color="community"] ~ .hamburger:not(.active) .hamburger-inner::before,
.fullscreen-overlay[data-bg-color="community"] ~ .hamburger:not(.active) .hamburger-inner::after {
  background-color: var(--dark) !important; /* Dark on gold */
}

.fullscreen-overlay[data-bg-color="projects"] ~ .hamburger:not(.active) .hamburger-inner,
.fullscreen-overlay[data-bg-color="projects"] ~ .hamburger:not(.active) .hamburger-inner::before,
.fullscreen-overlay[data-bg-color="projects"] ~ .hamburger:not(.active) .hamburger-inner::after {
  background-color: var(--dark) !important; /* Dark on white */
}

/* Hover effects */
.hamburger:hover .hamburger-inner,
.hamburger:hover .hamburger-inner::before,
.hamburger:hover .hamburger-inner::after {
  background-color: var(--primary) !important;
}

.hamburger-overlay {
  display: none;
}

/* ========== SMOOTHER DROPDOWN TRANSITIONS ========== */
.nav-toggle {
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.nav-submenu {
  transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  max-height: 0;
  overflow: hidden;
}

.nav-submenu.active {
  max-height: 500px; /* Adjust based on your content */
}

/* ========== PLUS TO MINUS TRANSFORMATION ========== */
.nav-toggle {
  position: relative;
  padding-right: 40px; /* Space for the icon */
}

.nav-toggle::after {
  content: "+";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.5rem;
  font-weight: 300;
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.nav-main-item.active .nav-toggle::after {
  content: "-";
  transform: translateY(-50%) rotate(0deg);
}

/* Adjust overlay content to accommodate social icons */
.overlay-content {
  padding-bottom: 80px; /* Space for social icons */
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ========== ENHANCED OVERLAY STYLES ========== */
.fullscreen-overlay {
  transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.fullscreen-nav {
  transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Ensure text colors work with new backgrounds */
.fullscreen-overlay[data-bg-color="community"] .nav-toggle,
.fullscreen-overlay[data-bg-color="projects"] .nav-toggle {
  color: #000000; /* Black text on light backgrounds */
}

.fullscreen-overlay[data-bg-color="community"] .nav-submenu a,
.fullscreen-overlay[data-bg-color="projects"] .nav-submenu a {
  color: #000000; /* Black text on light backgrounds */
  border-left-color: #000000; /* Black border on light backgrounds */
}

.fullscreen-overlay[data-bg-color="community"] .nav-submenu a:hover,
.fullscreen-overlay[data-bg-color="projects"] .nav-submenu a:hover {
  color: var(--art-green); /* Green on hover for light backgrounds */
}

/* ===== MOBILE NAV ===== */

.mobile-nav {
  position: fixed;
  top: 60px;
  right: -100%;
  width: 80%;
  max-width: 300px;
  height: calc(100vh - 60px);

  background: var(--darker);
  z-index: 2199;

  padding: 5rem 1.5rem 2rem;
  overflow-y: auto;

  display: none; /* mobile enables this */
  transition: right 0.3s ease-in-out;
}

.mobile-nav.active {
  right: 0;
}

@media (max-width: 768px) {
   .mobile-header {
    display: flex; /* Show on mobile */
  }

  .hamburger {
    display: flex;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .mobile-nav {
    top: 60px; /* Start below mobile header */
    height: calc(100vh - 60px);
    display: block;
    }
  
  .mobile-nav.active {
    right: 0;
  }
}

.close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--light);
  cursor: pointer;
  padding: 0.5rem;
}

.mobile-nav a {
  display: block;
  color: var(--light);
  text-decoration: none;
  font-size: 1.2rem;
  padding: 1rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  transition: color 0.2s ease;
}

.mobile-nav a:hover,
.mobile-nav a:focus {
  color: var(--primary);
}

.mobile-nav a.active {
  color: var(--primary);
  font-weight: bold;
}

/* ========== MOBILE NAV LOGO STYLES ========== */
.mobile-nav-logo {
  position: relative !important;
  display: flex;
  align-items: center;
  height: 100%;
  top: 0 !important;
  left: 0 !important;
  transform: none !important;
  margin-right: auto;
  margin-left: 1rem;
}

.mobile-nav-logo .subpage-logo-link {
  display: flex;
  gap: 0.2rem;
  text-decoration: none;
}

.mobile-nav-logo .word {
  transform: none !important;
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -1px;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  font-family: 'Playfair Display', serif;
}

.mobile-nav-logo .word.art {
  background-image: linear-gradient(120deg, var(--secondary-dark), var(--secondary));
}

.mobile-nav-logo .word.life {
  background-image: linear-gradient(120deg, var(--primary), var(--primary-light));
}

/* Override subpage logo styles for mobile header */
.mobile-header .subpage-logo-container {
  order: 2;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  margin: 0 auto;
  position: static !important; /* Remove any positioning */
  transform: none !important;
}

.mobile-header .word {
  font-size: clamp(1.7rem, 5vw, 2rem);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -1px;
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  font-family: 'Playfair Display', serif;
  line-height: 1;
  height: fit-content;
  display: flex;
  align-items: center;
}

.mobile-header .word.art {
  background-image: linear-gradient(120deg, var(--secondary-dark), var(--secondary));
}

.mobile-header .word.life {
  background-image: linear-gradient(120deg, var(--primary), var(--primary-light));
}

/* Ensure mobile logo stays on one line */
.mobile-header .subpage-logo-link {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-decoration: none;
  gap: 0.1em;
}

@media (max-width: 480px) {
  .mobile-header .word {
    font-size: 1.8rem; /* Slightly smaller on very small phones */
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .mobile-header .word {
    font-size: 2.5rem; /* Larger on tablets */
  }
}

/* ========== ALTERNATIVE: VIEWPORT-BASED SCALING ========== */
.mobile-header .word {
  font-size: clamp(1.8rem, 6vw, 2.5rem); /* Fluid scaling */
}

/* ========== ENSURE PROPER MOBILE HEADER HEIGHT ========== */
.mobile-header {
  height: 60px; /* Ensure fixed height */
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
}

/* ========== OVERLAY ========== */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 2199;
}

.overlay.active {
  display: block;
}

/* ========== MEDIA QUERIES ========== */
@media (max-width: 768px) {
  /* Show mobile header and hide desktop elements */
  .mobile-header {
    display: flex;
  }
  
  .menu-bar,
  .subpage-search-container,
  .subpage-logo-container:not(.mobile-nav-logo) {
    display: none;
  }
  
  /* Prevent scroll when menu is open */
  body.menu-open {
    overflow: hidden;
  }
  
  /* Enhanced touch targets */
  a, button, .btn, [role="button"] {
    min-width: 48px;
    min-height: 48px;
  }
  
  /* Optimized typography */
  body {
    font-size: 1.05rem;
    line-height: 1.7;
  }
}

@media (min-width: 769px) {
  .mobile-header,
  .hamburger,
  .mobile-nav {
    display: none !important;
  }
}

/* Hide desktop search on mobile */
@media (max-width: 768px) {
  .subpage-search-container {
    display: none;
  }
}

/* ========== FULLSCREEN OVERLAY Z-INDEX ========== */
.fullscreen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2400 !important; /* CHANGED: Added !important */
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fullscreen-overlay.active ~ .mobile-header {
  opacity: 0.5;
  pointer-events: none; 
}

/* Overlay close button (X) positioned exactly where hamburger was */
.fullscreen-overlay-close {
  position: absolute;
  top: 8px;
  right: 1rem;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 2401;
  display: none;
  align-items: center;
  justify-content: center;
}

.fullscreen-overlay.active .overlay-close {
  display: flex;
}

/* ======================================================
   PROGRESSIVE MOBILE EXPERIENCE - ENHANCED
   Welcoming skyline and typewriter for mobile/tablet
====================================================== */

/* Tablet & Mobile (max-width: 1023px) */
@media (max-width: 1023px) {
  /* --- WELCOMING SKYLINE --- */
  .skyline-container {
    /* Keep the real skyline SVG */
    background: transparent !important;
    height: auto !important;
    min-height: 100px !important;
    backdrop-filter: none !important;
    mask: none;
    -webkit-mask: none;
    border: none;
    opacity: 0; /* Start invisible for animation */
    visibility: hidden; /* Hidden until shown */
    pointer-events: none;
    transform: translateY(20px); /* Start position for animation */
    transition: none; /* We'll use animation instead of transition */
  }
  
  body.homepage.phase-3 .skyline-container.visible {
    visibility: visible !important;
  }

  /* When fade-in class is added, trigger animation */
  body.homepage.phase-3 .skyline-container.fade-in {
    animation: skylineFadeIn 1.5s ease-out forwards;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  /* Show the actual skyline SVG */
  .skyline-container .skyline-svg {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    opacity: 0.8 !important;
    filter: drop-shadow(0 -2px 15px rgba(218, 165, 32, 0.3));
  }
  
  /* Add soft gradient overlay for depth */
  .skyline-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: linear-gradient(to top,
      rgba(28, 28, 30, 0.7) 0%,
      rgba(28, 28, 30, 0.3) 30%,
      transparent 70%
    );
    pointer-events: none;
  }
  
  /* Remove the gradient bar decorations */
  .skyline-container::after {
    display: none !important;
  }
  
  /* --- WELCOMING TYPEWRITER TEXT --- */
  .hover-text {
    /* CENTERED WELCOME MESSAGE */
    position: fixed !important;
    top: 35% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    bottom: auto !important;
    right: auto !important;
    
    /* CLEAN, PROMINENT STYLING */
    background: transparent !important;
    backdrop-filter: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    max-width: 90% !important;
    width: auto !important;
    
    /* WELCOMING TYPOGRAPHY */
    font-size: clamp(1.8rem, 6vw, 2.5rem) !important;
    line-height: 1.3 !important;
    text-align: center !important;
    color: var(--primary-light) !important;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.9),
                 0 0 40px rgba(218, 165, 32, 0.4);
    font-family: var(--font-accent);
    white-space: normal;
    text-wrap: pretty;
    
    /* REMOVE TOOLTIP BEHAVIOR */
    max-height: none !important;
    overflow: visible !important;
    cursor: default !important;
    min-height: auto !important;
    min-width: auto !important;

    /* Start hidden - only show after phase-3 */
    opacity: 0 !important;
    visibility: hidden !important;
    display: block !important;
    z-index: 5 !important;
  }

  /* Make visible only when phase-3 and typewriter-ready */
  body.homepage.phase-3 .hover-text.typewriter-ready {
    opacity: 1 !important;
    visibility: visible !important;
    transition: opacity 0.5s ease-out;
  }
  
  /* Remove all tooltip indicators/buttons */
  .hover-text::after,
  .hover-text::before,
  .hover-text.expanded::after,
  .hover-text.expanded::before {
    display: none !important;
    content: none !important;
  }
  
  /* Remove expandable behavior */
  .hover-text.expanded {
    max-height: none !important;
    padding-right: 0 !important;
  }
  
  /* Typewriter cursor for mobile */
  .hover-text.typewriter-ready::after {
    content: '|';
    animation: blink 1s step-end infinite;
    color: var(--secondary);
    display: inline-block !important;
    margin-left: 2px;
  }
  
  /* --- SCROLL-BASED BEHAVIOR --- */
  /* Gentle fade when scrolling */
  body.scrolling .hover-text {
    opacity: 1;
    transform: translate(-50%, -50%) !important;
  }
  
  /* Restore when stopping */
  body:not(.scrolling) .hover-text {
    transition: opacity 0.5s ease, transform 0.5s ease;
  }
  
  /* Skyline slightly fades when scrolling */
  body.scrolling .skyline-container {
    opacity: 0.6 !important;
  }
  
  /* --- TABLET-SPECIFIC ADJUSTMENTS (768-1023px) --- */
  @media (min-width: 768px) and (max-width: 1023px) {
    .skyline-container {
      min-height: 120px !important;
    }
    
    .hover-text {
      top: 32% !important;
      font-size: clamp(2rem, 4vw, 3rem) !important;
      line-height: 1.4 !important;
    }
  }
  
  /* --- SMALL MOBILE ADJUSTMENTS (≤480px) --- */
  @media (max-width: 480px) {
    .skyline-container {
      min-height: 80px !important;
    }
    
    .skyline-container .skyline-svg {
      opacity: 0.9 !important;
    }
    
    .hover-text {
      top: 38% !important;
      font-size: clamp(1.5rem, 7vw, 2rem) !important;
      line-height: 1.4 !important;
      text-shadow: 0 2px 15px rgba(0, 0, 0, 0.9),
                   0 0 30px rgba(218, 165, 32, 0.3);
    }
    
    /* Better spacing on very small screens */
    .hover-text.typewriter-ready::after {
      margin-left: 1px;
    }
  }
}

/* Animation for the blinking cursor */
@keyframes blink {
  from, to { opacity: 1; }
  50% { opacity: 0; }
}

/* ======================================================
   SKYLINE FADE-IN ANIMATION
   For coordinated welcome with typewriter
====================================================== */

/* Skyline fade-in animation */
@keyframes skylineFadeIn {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Apply the animation when .fade-in class is added */
.skyline-container.fade-in {
  animation: skylineFadeIn 1.5s ease-out forwards;
}

/* Ensure the animation works with reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .skyline-container.fade-in {
    animation: none;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s ease;
  }
  
  .hover-text.typewriter-ready::after {
    animation: none !important;
  }
}

/* Force proper skyline display on mobile */
@media (max-width: 1023px) {
  .skyline-container {
    width: 100% !important;
  }
  
  .skyline-container::before {
    display: block !important;
  }
}

/* ========== MOBILE Z-INDEX FIXES ========== */
@media (max-width: 1023px) {
  /* Ensure overlay doesn't create stacking context that traps hamburger */
  .fullscreen-overlay {
    isolation: auto !important;
  }
  
  /* Make sure mobile header is below hamburger but above overlay */
  .mobile-header {
    z-index: 2200 !important;
  }

  /* Force typewriter to be below hamburger */
  .hover-text {
    z-index: 5 !important;
    pointer-events: none !important;
  }
  
  /* Hide typewriter when overlay is active */
  .fullscreen-overlay.active ~ .hover-text {
    opacity: 0 !important;
    visibility: hidden !important;
  }
  
  /* Ensure typewriter text doesn't block anything */
  .hover-text * {
    pointer-events: none !important;
  }
}

/* ========== CRITICAL: HAMBURGER EMERGENCY OVERRIDE ========== */
@media (max-width: 768px) {
  /* Force hamburger to break out of any stacking contexts */
  .hamburger {
    z-index: 999999 !important;
    position: fixed !important;
    transform: none !important;
    will-change: transform !important;
    isolation: isolate !important;
  }
  
  /* Override any parent opacity/visibility */
  body .hamburger,
  .mobile-header .hamburger,
  .header .hamburger {
    opacity: 1 !important;
    visibility: visible !important;
  }
}