/* ══════════════════════════════════════════════
   Vatsal.OS Frontend Responsive Engine (v1.0.4)
   Expert Level UI/UX Scaling
   ══════════════════════════════════════════════ */

:root {
  --mobile-nav-height: 64px;
  --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
  --touch-target: 44px;
}

/* ── Container & Section Mobile ────────────────────── */
@media (max-width: 767px) {
  .container {
    padding-inline: 1.25rem !important;
    width: 100% !important;
  }
  .container-tight {
    padding-inline: 1.25rem !important;
    width: 100% !important;
  }
  .section {
    padding-block: clamp(3rem, 8vw, 5rem) !important;
  }
  /* EXPERT CLEARANCE: Prevent Navbar Island from hiding breadcrumbs/titles */
  section:first-of-type, main > section:first-of-type {
    padding-top: 110px !important;
  }
  .section-header {
    margin-bottom: 2rem !important;
    max-width: 100% !important;
    text-align: center !important;
  }
}

/* ── Typography Scaling ────────────────────────────── */
@media (max-width: 767px) {
  .title--display {
    font-size: clamp(2.4rem, 11vw, 3.8rem) !important;
    line-height: 1.02 !important;
    letter-spacing: -0.04em !important;
    word-break: break-word !important;
  }
  .title {
    font-size: clamp(1.85rem, 8vw, 2.4rem) !important;
    line-height: 1.15 !important;
    letter-spacing: -0.02em !important;
  }
  .desc {
    font-size: 1rem !important;
    max-width: 100% !important;
    line-height: 1.6 !important;
    opacity: 0.8 !important;
  }
  .label {
    font-size: 0.75rem !important;
    letter-spacing: 0.15em !important;
    margin-bottom: 0.75rem !important;
  }
}

/* ── Responsive Grids & Layout Utilities ─────────────── */
.grid-adaptive {
  display: grid !important;
  grid-template-columns: repeat(var(--grid-cols, 12), 1fr) !important;
  gap: var(--grid-gap, 1.5rem) !important;
}

/* Force all column spans to 100% on mobile */
@media (max-width: 767px) {
  .col-span-12, .col-span-11, .col-span-10, .col-span-9, 
  .col-span-8, .col-span-7, .col-span-6, .col-span-5, 
  .col-span-4, .col-span-3, .col-span-2 {
    grid-column: span 1 !important;
  }
}

@media (max-width: 1024px) {
  .grid-adaptive {
    --grid-cols: 1 !important;
    gap: 2rem !important;
  }
}

.mobile-stack {
  display: flex !important;
  flex-direction: column !important;
  gap: 1.25rem !important;
}

@media (min-width: 768px) {
  .mobile-stack {
    flex-direction: row !important;
  }
}

.hide-on-mobile {
  display: none !important;
}

@media (min-width: 768px) {
  .hide-on-mobile {
    display: block !important;
  }
}

/* ── Navbar Mobile Overrides ───────────────────────── */
@media (max-width: 1024px) {
  .navbar__drawer {
    background: #0a0a0b !important;
    border-left: 1px solid rgba(255,255,255,0.08) !important;
    box-shadow: -10px 0 30px rgba(0,0,0,0.5) !important;
    padding: var(--sp-5) var(--sp-5) !important; /* Compacting drawer padding */
    gap: var(--sp-4) !important; /* Reducing internal gaps */
  }

  #navbar-drawer-close {
    background: rgba(255,255,255,0.05) !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: rgba(255,255,255,0.7);
    transition: all 0.2s ease;
  }

  .navbar__drawer .navbar__link {
    color: rgba(255,255,255,0.7) !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    padding: 14px 16px !important;
    border-radius: 12px !important;
    min-height: 48px;
    display: flex;
    align-items: center;
    letter-spacing: 0.01em;
    text-transform: none !important;
    margin-bottom: 4px;
  }

  .navbar__drawer .navbar__link:hover,
  .navbar__drawer .navbar__link.active {
    background: rgba(255,255,255,0.06) !important;
    color: #ffffff !important;
  }

  /* Absolute-Grade Drawer Navigation Restoration */
  .navbar__drawer {
    max-height: 100vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .navbar__drawer .btn-primary {
    width: 100%;
    justify-content: center;
    padding: 16px 24px;
    font-size: 1rem;
    min-height: 52px;
    border-radius: 14px;
    margin-top: 1rem;
  }
}

/* ── Bento Grid Responsive ─────────────────────────── */
@media (max-width: 767px) {
  .bento-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
    grid-auto-rows: auto !important;
  }
  .col-span-12, .col-span-8, .col-span-6, .col-span-4 {
    grid-column: span 1 !important;
  }
  .bento-item {
    transform: none !important;
    perspective: none !important;
    padding: 1.5rem !important;
  }
}

@media (max-width: 1023px) and (min-width: 768px) {
  .bento-grid {
    grid-template-columns: repeat(6, 1fr) !important;
  }
  .col-span-8 { grid-column: span 6 !important; }
  .col-span-6 { grid-column: span 3 !important; }
  .col-span-4 { grid-column: span 3 !important; }
}

/* ── Footer Overrides ──────────────────────────────── */
@media (max-width: 767px) {
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 3rem !important;
    text-align: center !important;
  }
  .footer-grid > div {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  
  .footer-menu-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.75rem 1.5rem !important;
    width: 100% !important;
    text-align: left !important;
  }
}

/* ── Global Touch & Component Overrides ──────────────── */
@media (max-width: 767px) {
  /* PREVENT PIXEL-LEAKAGE: GLOBAL BORDER-BOX LOCKDOWN */
  *, *::before, *::after {
    box-sizing: border-box !important;
    max-width: 100% !important;
  }

  /* KILL GHOST SCROLLS (THE 'WHITE LINE' ISSUE) */
  html, body {
    overflow-x: hidden !important;
    position: relative !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important; /* Strictly 100% instead of 100vw to skip scrollbar width */
    max-width: 100% !important;
    min-width: 100% !important;
    left: 0 !important;
    right: 0 !important;
  }

  /* RE-CENTERED NAVBAR (ELIMINATE SHIFTS) */
  .navbar-wrapper {
    padding-inline: 1rem !important;
    left: 0 !important;
    right: 0 !important;
    display: flex !important;
    justify-content: center !important;
    width: 100% !important;
  }

  .navbar {
    width: 100% !important;
    margin-inline: auto !important;
    max-width: calc(100% - 2rem) !important; /* Use 100% instead of 100vw */
  }

  /* TEXT & PILL CLIPPING FIXES */
  .title, .title--display {
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    max-width: 100% !important;
  }

  .hero .container {
    overflow: hidden !important; /* Ensure floating rings don't push width */
  }

  /* Specific fix for the "Available for Help" pill cutting */
  div[style*="Available for Help"] {
    right: 2.5rem !important; /* Absolute safe buffer to prevent clipping */
    bottom: 2rem !important;
    padding: 0.3rem 0.6rem !important;
    font-size: 0.55rem !important;
    overflow: hidden !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
    z-index: 10 !important;
    background: #FFFFFF !important;
    color: var(--clr-emerald) !important;
  }

  /* FORCED WRAPPING FOR STAT TITLES (Prevents 'Projects De') */
  .hero-stat-item div:last-child {
    white-space: normal !important;
    line-height: 1.2 !important;
    text-align: left !important;
    max-width: 100% !important;
    display: block !important;
  }

  /* FORCED SYMMETRY FOR HEADERS */
  .section-header {
    margin-inline: auto !important;
    padding-inline: 1rem !important;
    text-align: center !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
  }

  .section-header .title {
    margin-inline: auto !important;
    padding-inline: 1rem !important; /* Added more padding to ensure no edge clipping */
    text-align: center !important;
    word-break: break-word !important;
  }

  /* Root Viewport Safety */
  .container {
    padding-inline: 1.25rem !important;
    width: 100% !important;
  }

  /* Prevent Card Shadow Clipping */
  .jv3-card, .premium-card, .jv3-edu-card {
    margin-inline: 4px !important;
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.3) !important;
  }

  /* ABSOLUTE GRID SAFETY RESET (EXPERT OVERRIDE) */
  .grid-adaptive {
    width: 100% !important;
    margin-inline: auto !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }

  /* High-Performance 2-Column Opt-In (Use ONLY for simple data) */
  .grid-stats-2col, .grid-2-col-mobile {
    grid-template-columns: repeat(2, 1fr) !important;
    display: grid !important;
    gap: 1rem !important;
  }

  /* Leadership Specific Overrides  [FIXED: Selective 2-Column Restoration] */
  .lead-stats-2col {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1.5rem !important;
    margin-top: 40px !important;
    width: 100% !important;
    padding-inline: 0.5rem !important;
  }
  .lead-stats-2col > div:last-child {
      grid-column: span 2 !important;
      text-align: center !important;
  }
  .lead-stats-2col > div:last-child div {
      justify-content: center !important;
  }

  /* Vertical Spacing Optimization (Remove "Blank Spaces") */
  .section, .section-ls {
    padding-block: 60px !important;
  }

  /* FORCED 2-COLUMN EXPERT GRIDS */
  .about-stats-grid, .tech-arsenal-grid, .stats-2-col {
    grid-template-columns: 1fr 1fr !important;
    display: grid !important;
    gap: 1rem !important;
  }

  .grid-adaptive > div {
    width: 100% !important;
    max-width: 100% !important;
    margin-inline: auto !important;
  }

  /* Input zoom prevention for iOS */
  input, select, textarea {
    font-size: 16px !important;
  }

  /* Cookie Banner Mobile */
  .cookie-banner {
    flex-direction: column !important;
    width: calc(100% - 24px) !important;
    left: 12px !important;
    transform: none !important;
    padding: 1.25rem !important;
    text-align: center !important;
  }
  .cookie-banner--visible {
    bottom: calc(12px + env(safe-area-inset-bottom)) !important;
  }
  .cookie-banner__actions {
    width: 100%;
    margin-top: 1rem;
    display: flex;
    gap: 8px;
  }
  .btn-cookie {
    flex: 1;
    min-height: 48px;
  }

  /* Hero Section Overrides */
  .hero .container > div {
    display: flex !important;
    flex-direction: column-reverse !important;
    gap: 3rem !important;
  }

  .hero {
    overflow-x: hidden !important; /* Critical: Prevent ghost scrolls from orbs */
    position: relative;
  }

  .hero-stats-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important; /* Forces 2-column safe wrap */
    justify-content: center !important;
    gap: 1.5rem !important;
    text-align: left !important;
    width: 100% !important;
    padding-inline: 1rem !important;
  }

  .hero-stat-item {
    border-left: 2px solid var(--clr-accent-primary);
    padding-left: 0.75rem;
  }

  .hero__content {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 100% !important;
  }

  .hero__visual {
    width: 260px !important; /* Shrunk from 280px to prevent leak */
    margin: 0 auto !important;
    overflow: hidden !important; /* Lockdown image edges */
    position: relative !important;
    transform: scale(0.95) !important; /* Slight shrink for safety */
  }

  .hero-states-container {
    display: none !important; /* Hide floating chips on mobile to avoid overlap */
  }

  /* Leadership Page Overrides */
  .stat-odometer {
    font-size: 2.8rem !important;
  }
  
  .vstack-card, .scale-card, .bento-item {
    padding: 1.5rem !important;
    border-radius: 20px !important;
  }

  .os-number {
    font-size: 2.5rem !important;
    opacity: 0.15 !important;
  }

  /* Case Study Cards */
  .case-card {
    min-height: auto !important;
    aspect-ratio: auto !important;
    padding: 1.5rem !important;
  }

  .case-card h3 {
    font-size: 1.5rem !important;
  }

  /* Progress Bars */
  .leadership-progress-container {
    padding: 1.5rem !important;
  }

  /* Blockquote Decoupling */
  .blockquote-premium {
    font-size: var(--fs-xl) !important;
    font-family: var(--ff-head) !important;
    line-height: var(--lh-tight) !important;
    color: var(--clr-heading) !important;
    margin-bottom: var(--sp-8) !important;
    border-left: 4px solid var(--clr-accent-primary) !important;
    padding-left: var(--sp-6) !important;
    text-align: left !important;
  }
  /* DECORATIVE ORBS - ELIMINATE OVERFLOW LEAKAGE */
  .orb {
    width: 25vw !important; /* Slashed from 40vw to prevent leak */
    height: 25vw !important;
    filter: blur(40px) !important; /* Reduced blur to save composite performance */
  }
  .orb-1 { top: -5% !important; left: -15% !important; }
  .orb-2 { bottom: -5% !important; right: -5% !important; }

  /* PORTRAIT RINGS - ELIMINATE BLEED */
  div[style*="border: 1px dashed var(--clr-border-glow)"] {
    inset: 1rem !important;
    animation-duration: 60s !important; /* Slow down mobile paint calls */
  }
  div[style*="border: 1px solid rgba(255,255,255,0.05)"] {
    inset: 2rem !important;
  }
}

/* ── Landscape & Tablet Optimization ───────────────── */
@media (min-width: 768px) and (max-width: 1024px) {
  .title--display {
    font-size: 4rem !important;
  }
  
  .grid-adaptive {
    --grid-cols: 2 !important;
  }
}
