/* ------------------------------
   HEADER STYLES
   ------------------------------ */
:root {
  --header-bg: rgba(239, 236, 231, 0.82);
  --header-pink: #ff2d55;
  --header-pink-light: rgba(255, 45, 85, 0.08);
  --header-black: #0f0f0f;
  --header-gray: #000000;
  --header-border: rgba(0, 0, 0, 0.08);
}

header.main-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2000;
  height: calc(62px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 0px) max(48px, env(safe-area-inset-right, 48px)) 0 max(48px, env(safe-area-inset-left, 48px));
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom: none;
  font-family: 'Satoshi', sans-serif;
}

header.main-header,
.mobile-header,
.top-bar,
.preview-fixed-header {
  transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1), 
              opacity 0.4s ease,
              background-color 0.3s ease,
              box-shadow 0.3s ease !important;
  will-change: transform, opacity;
}

/* Full header style for homepage only */
header.main-header.full-header {
  background: rgba(255, 255, 255, 0.01);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

header.main-header.header-hidden,
.mobile-header.header-hidden,
.top-bar.header-hidden,
.preview-fixed-header.header-hidden {
  transform: translateY(-100%) !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Visible state */
header.main-header.header-visible,
.mobile-header.header-visible,
.top-bar.header-visible,
.preview-fixed-header.header-visible {
  transform: translateY(0) !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

header.main-header .logo,
header.main-header .app-logo,
.top-bar .app-logo,
.preview-fixed-header .output-logo-center {
  font-family: 'Satoshi', sans-serif;
  font-size: 24px;
  font-weight: 700; /* Standardized to 700 */
  text-decoration: none;
  color: #000 !important;
  display: flex;
  align-items: center;
  letter-spacing: -0.025em;
  gap: 0;
  cursor: pointer;
}

header.main-header .logo .lens,
header.main-header .app-logo .lens,
.top-bar .app-logo .lens,
.preview-fixed-header .output-logo-center .lens {
  color: #F12850 !important;
}

@media (min-width: 1025px) {
  header.main-header .logo,
  header.main-header .app-logo,
  .top-bar .app-logo,
  .preview-fixed-header .output-logo-center {
    font-size: 28px;
    letter-spacing: -0.03em;
  }
}


header.main-header nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

header.main-header nav a {
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--header-gray);
  padding: 7px 14px;
  border-radius: 8px;
  transition: all 0.18s;
}

header.main-header nav a:hover {
  color: var(--header-black);
  background: rgba(0, 0, 0, 0.05);
}

header.main-header .nav-cta {
  background: var(--header-black) !important;
  color: #fff !important;
  padding: 9px 20px !important;
  border-radius: 10px !important;
  font-weight: 500 !important;
  margin-left: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.2s !important;
}

header.main-header .nav-cta:hover {
  background: var(--header-pink) !important;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 45, 85, 0.3) !important;
}

/* Hide desktop header on mobile and tablets */
@media (max-width: 1024px) {
  header.main-header {
    display: none !important;
  }
}

/* Hide mobile header on large desktops only */
@media (min-width: 1025px) {
  .mobile-header, .mobile-menu-drawer, .mobile-menu-overlay {
    display: none !important;
  }
}


@media (max-width: 1024px) {
  .mobile-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: calc(64px + env(safe-area-inset-top, 0px)) !important;
    padding: 0 max(20px, env(safe-area-inset-right, 20px)) 0 max(20px, env(safe-area-inset-left, 20px)) !important;
    padding-top: env(safe-area-inset-top, 0px) !important;
    background: rgba(244, 244, 240, 0.01) !important; 
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    z-index: 9000 !important;
    border-bottom: none !important;
    box-sizing: border-box !important;
    margin: 0 !important;
  }

  /* Modern 2-Line Hamburger */
  .mobile-menu-toggle {
    width: 32px;
    height: 32px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    background: #ffffff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
    z-index: 10001;
    order: 1; /* Changed from 3 */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
  }

  .mobile-menu-toggle:active {
    transform: scale(0.92);
    background: rgba(0, 0, 0, 0.02);
  }

  .mobile-menu-toggle span {
    width: 18px;
    height: 2px;
    background-color: #000;
    border-radius: 10px;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
  }

  .mobile-menu-toggle span:last-child {
    width: 18px;
  }

  .mobile-menu-toggle.active span:first-child {
    transform: translateY(4px) rotate(45deg);
    width: 18px;
  }

  .mobile-menu-toggle.active span:last-child {
    transform: translateY(-3px) rotate(-45deg);
    width: 18px;
  }

  /* Center: Logo */
  .mobile-logo {
    position: absolute !important;
    left: 50% !important;
    top: calc(env(safe-area-inset-top, 0px) + 32px) !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    font-family: 'Satoshi', sans-serif;
    font-size: 18px; /* Mobile default */
    font-weight: 700;
    color: #000;
    text-decoration: none;
    letter-spacing: -0.025em;
    display: flex;
    align-items: center;
    white-space: nowrap;
    order: 2; /* Centered in absolute position */
  }

  @media (min-width: 768px) {
    .mobile-logo {
      font-size: 24px !important; /* Tablet size */
    }
  }

  .mobile-logo .lens {
    color: #F12850;
  }

  /* Right: CTA */
  .mobile-cta {
    background: #000;
    color: #fff;
    font-size: 12px; 
    font-weight: 700;
    height: 32px; 
    padding: 0 14px;
    border-radius: 8px; 
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.23, 1, 0.32, 1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 88px; 
    flex-shrink: 0;
    letter-spacing: -0.01em;
    gap: 4px;
    position: relative;
    z-index: 1;
    order: 2; 
  }

  /* Compact adjustment for smaller screens */
  @media (max-width: 370px) {
    .mobile-logo {
      font-size: 17px !important;
    }
    .mobile-cta {
      padding: 0 14px;
      font-size: 11px;
      height: 34px;
      min-width: 88px;
      border-radius: 8px;
    }
    .mobile-header {
      padding-left: 12px;
      padding-right: 12px;
    }
  }

  .mobile-cta:active {
    transform: scale(0.96);
    background: #F12850;
  }

  /* Hide header CTA when drawer is open to avoid redundancy */
  .mobile-menu-toggle.active ~ .mobile-cta {
    opacity: 0;
    pointer-events: none;
    transform: translateX(10px);
  }

  /* --- BACKDROP OVERLAY --- */
  .mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.4);
    z-index: 7000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }

  .mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
  }

  /* --- TOP DROPDOWN DRAWER (Slides down from behind header) --- */
  .mobile-menu-drawer {
    position: fixed;
    top: 0; /* Start from the very top to prevent any gaps */
    left: 0;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 100dvh;
    background: #F4F4F0;
    z-index: 8000; /* Behind header (9000) */
    display: flex;
    flex-direction: column;
    padding-top: calc(60px + env(safe-area-inset-top, 0px)); /* Offset content by header height */
    padding-bottom: 32px;
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    box-sizing: border-box;
    transform: translateY(-101%); /* Start tucked behind header */
    transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  }

  .mobile-menu-drawer.active {
    transform: translateY(0);
  }

  /* --- Hide redundant drawer header (using main header toggle) --- */
  .mobile-menu-drawer-header {
    display: none;
  }

  .mobile-menu-drawer-logo {
    font-family: 'Satoshi', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #000;
    letter-spacing: -0.02em;
    text-decoration: none;
  }

  .mobile-menu-drawer-logo .lens {
    color: #F12850;
  }

  .mobile-menu-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  }

  .mobile-menu-close:active {
    background: rgba(241, 40, 80, 0.1);
    border-color: rgba(241, 40, 80, 0.3);
    transform: scale(0.92);
  }

  .mobile-menu-close svg {
    width: 16px;
    height: 16px;
    stroke: #000;
    stroke-width: 2.5;
    fill: none;
  }

  /* --- Nav Links --- */
  .mobile-menu-links {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 8px 0;
    flex-shrink: 0;
  }

  .mobile-menu-links a {
    font-family: 'Satoshi', sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: #000;
    text-decoration: none;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: -0.01em;
    border-left: 3px solid transparent;
    /* Entrance animation */
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease,
                color 0.15s ease, background 0.15s ease,
                border-color 0.15s ease;
  }

  .mobile-menu-links a:active {
    background: rgba(241, 40, 80, 0.08);
    color: #F12850;
    border-left-color: #F12850;
  }

  .mobile-menu-drawer.active .mobile-menu-links a {
    opacity: 1;
    transform: translateY(0);
  }

  /* Staggered entrance */
  .mobile-menu-drawer.active .mobile-menu-links a:nth-child(1) { transition-delay: 0.06s; }
  .mobile-menu-drawer.active .mobile-menu-links a:nth-child(2) { transition-delay: 0.10s; }
  .mobile-menu-drawer.active .mobile-menu-links a:nth-child(3) { transition-delay: 0.14s; }
  .mobile-menu-drawer.active .mobile-menu-links a:nth-child(4) { transition-delay: 0.18s; }

  /* --- Divider --- */
  .mobile-menu-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.06);
    margin: 4px 20px;
    flex-shrink: 0;
  }

  /* --- Drawer CTA --- */
  .mobile-menu-cta {
    display: flex;
    padding: 16px 20px;
    flex-shrink: 0;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.35s ease 0.22s, transform 0.35s ease 0.22s;
  }

  .mobile-menu-drawer.active .mobile-menu-cta {
    opacity: 1;
    transform: translateY(0);
  }

  .mobile-menu-cta a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48px;
    background: #000;
    color: #fff;
    font-family: 'Satoshi', sans-serif;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    border-radius: 12px;
    border: none;
    transition: all 0.2s ease;
    letter-spacing: 0.01em;
  }

  .mobile-menu-cta a:active {
    background: #F12850;
    transform: scale(0.97);
  }

  /* --- Drawer Footer --- */
  .mobile-menu-footer {
    margin-top: auto;
    padding: 20px 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom, 16px));
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.35s ease 0.28s;
  }

  .mobile-menu-drawer.active .mobile-menu-footer {
    opacity: 1;
  }

  .mobile-menu-footer-brand {
    font-family: 'Satoshi', sans-serif;
    font-size: 10px;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.6) !important;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.5;
  }

  .mobile-menu-footer-version {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    font-family: 'Satoshi', sans-serif;
    font-size: 9px;
    font-weight: 700;
    color: rgba(0, 0, 0, 0.65) !important;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
}

/* --- PREMIUM BLURRED MINIMAL HEADERS (Mobile & Tablet) --- */
@media (max-width: 1024px) {
  .mobile-header.minimal,
  .main-header.minimal,
  .preview-fixed-header,
  .error-nav,
  .top-bar {
    background: rgba(244, 244, 240, 0.01) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
    align-items: center !important;
    justify-content: center !important;
    height: calc(64px + env(safe-area-inset-top, 0px)) !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 9000 !important;
    padding-top: env(safe-area-inset-top, 0px) !important;
  }

  /* Visibility Logic: Ensure only one header is visible */
  .mobile-header.minimal {
    display: flex !important;
  }
  @media (min-width: 768px) {
    .mobile-header.minimal { display: none !important; }
    .main-header.minimal { display: flex !important; }
  }
  @media (max-width: 767px) {
    .main-header.minimal { display: none !important; }
  }

  /* Standardized Logo Size for Minimal Headers */
  .mobile-header.minimal .mobile-logo,
  .main-header.minimal .app-logo,
  .preview-fixed-header .output-logo-center,
  .error-nav .app-logo,
  .top-bar .app-logo {
    font-size: 18px !important; /* Mobile default */
    font-weight: 700 !important;
    font-family: 'Satoshi', sans-serif !important;
    letter-spacing: -0.025em !important;
    position: absolute !important;
    left: 50% !important;
    top: calc(env(safe-area-inset-top, 0px) + 32px) !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    white-space: nowrap !important;
    color: #000 !important;
  }

  /* Ensure the "Lens" part is always pink */
  .mobile-header.minimal .lens,
  .main-header.minimal .lens,
  .preview-fixed-header .lens,
  .error-nav .lens,
  .top-bar .lens {
    color: #F12850 !important;
  }

  @media (min-width: 768px) {
    .mobile-header.minimal .mobile-logo,
    .main-header.minimal .app-logo,
    .preview-fixed-header .output-logo-center,
    .top-bar .app-logo {
      font-size: 24px !important; /* Matches regular tablet size */
    }
  }

  .mobile-header.minimal .mobile-menu-toggle,
  .mobile-header.minimal .mobile-cta,
  .main-header.minimal nav {
    display: none !important;
  }

  /* Keep Exit button on the right for top-bar */
  .top-bar .exit-btn {
    position: absolute !important;
    right: 16px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    margin: 0 !important;
    z-index: 10 !important;
  }

  .top-bar .top-left {
    display: contents !important;
  }
}

/* Unified mobile/tablet vs desktop visibility */
@media (min-width: 1025px) {
  .mobile-header, .mobile-menu-drawer {
    display: none !important;
  }
}

