/* ==========================================================================
   AGRAWAL GROUP — OFFICIAL RESPONSIVE & MOBILE DESIGN SYSTEM
   Production-Ready Multi-Device Engine (Mobile Phones, Tablets, Desktops)
   ========================================================================== */

/* ---------- Global Viewport Safeguards ---------- */
html, body {
  overflow-x: hidden !important;
  max-width: 100vw !important;
  width: 100% !important;
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after {
  box-sizing: border-box !important;
}

img {
  max-width: 100%;
  height: auto;
}

/* ---------- Desktop (>820px) ---------- */
@media (min-width: 821px) {
  .drawer-header,
  .drawer-ventures-accordion,
  .drawer-ventures-sublist,
  .drawer-close-btn {
    display: none !important;
  }
}

/* ---------- Large Desktops (>1200px) ---------- */
@media (min-width: 1200px) {
  .ventures-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 32px !important;
  }
}

/* ---------- Medium Desktops & Tablets (<1024px) ---------- */
@media (max-width: 1024px) {
  :root {
    --header-height: 76px;
  }

  .container {
    padding: 0 24px !important;
  }

  .nav-menu {
    gap: 18px;
  }

  /* Two-column layout collapse (Overrides inline grid styles) */
  .two-col-layout,
  div.two-col-layout[style*="grid"] {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
    gap: 36px !important;
  }

  .two-col-layout > div {
    width: 100% !important;
    max-width: 100% !important;
  }

  .two-col-layout > div:last-child {
    position: static !important;
    top: auto !important;
    margin-top: 10px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 16px !important;
  }

  .footer-top {
    grid-template-columns: 1fr 1fr !important;
    gap: 36px !important;
  }

  .hero-crest-stage {
    flex-direction: column;
    text-align: center;
  }
}

/* ---------- Tablets & Standard Mobile (<820px) ---------- */
@media (max-width: 820px) {
  :root {
    --header-height: 72px;
  }

  .container {
    padding: 0 20px !important;
  }

  /* Navigation Actions & Mobile Hamburger */
  .nav-actions {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }

  /* Hide desktop Inquire button in header on mobile */
  .nav-actions .btn {
    display: none !important;
  }

  /* Mobile Navigation Toggle (Hamburger Button) */
  .mobile-toggle {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    border-radius: var(--radius-sm) !important;
    background: rgba(212, 163, 61, 0.15) !important;
    border: 1px solid rgba(212, 163, 61, 0.45) !important;
    color: var(--gold-light) !important;
    cursor: pointer !important;
    touch-action: manipulation !important;
    z-index: 1002 !important;
    padding: 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35) !important;
    transition: all 0.25s ease !important;
  }

  .mobile-toggle:hover,
  .mobile-toggle:focus {
    background: rgba(212, 163, 61, 0.28) !important;
    border-color: var(--gold-primary) !important;
  }

  .mobile-toggle:active {
    background: rgba(212, 163, 61, 0.38) !important;
    transform: scale(0.95);
  }

  .mobile-toggle svg {
    display: block !important;
    width: 22px !important;
    height: 22px !important;
    stroke: var(--gold-light) !important;
  }

  .mobile-toggle.active {
    background: rgba(212, 163, 61, 0.3) !important;
    border-color: var(--gold-primary) !important;
  }

  /* Header and Drawer Layering (Header must sit above backdrop overlay) */
  .site-header {
    z-index: 10000 !important;
  }

  .site-header.drawer-open {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  /* Mobile Navigation Drawer */
  .nav-menu-wrapper {
    position: fixed !important;
    top: 0 !important;
    right: -100% !important;
    width: min(340px, 88vw) !important;
    height: 100vh !important;
    height: 100dvh !important;
    background: #0E121A !important; /* Solid opaque luxury obsidian - prevents dark overlay bleedthrough */
    border-left: 1px solid rgba(212, 163, 61, 0.4) !important;
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.95) !important;
    padding: 24px 22px 36px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    gap: 16px !important;
    transition: right 0.32s cubic-bezier(0.16, 1, 0.3, 1) !important;
    z-index: 10001 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .nav-menu-wrapper.active {
    right: 0 !important;
  }

  .nav-menu {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 14px !important;
    width: 100% !important;
  }

  .nav-link {
    font-size: 1.05rem !important;
    font-weight: 600 !important;
    color: #FFFFFF !important; /* High contrast crisp white */
    padding: 12px 0 !important;
    width: 100% !important;
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
    border-bottom: 1px solid rgba(212, 163, 61, 0.15) !important;
    transition: color 0.2s ease !important;
  }

  .nav-link.active,
  .nav-link:hover {
    color: #F5D580 !important; /* Imperial Gold highlight */
  }

  .mobile-drawer-cta {
    display: block !important;
    margin-top: 24px;
    width: 100%;
  }

  /* Drawer Top Bar & Close Button */
  .drawer-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding-bottom: 16px !important;
    margin-bottom: 4px !important;
    border-bottom: 1px solid rgba(212, 163, 61, 0.3) !important;
    width: 100% !important;
  }

  .drawer-header span {
    font-family: var(--font-heading) !important;
    font-size: 0.98rem !important;
    color: #FFE699 !important;
    font-weight: 700 !important;
    letter-spacing: 0.12em !important;
  }

  .drawer-close-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 38px !important;
    height: 38px !important;
    border-radius: 8px !important;
    background: rgba(212, 163, 61, 0.15) !important;
    border: 1px solid rgba(212, 163, 61, 0.45) !important;
    color: #FFE699 !important;
    cursor: pointer !important;
    touch-action: manipulation !important;
    transition: all 0.2s ease !important;
  }

  .drawer-close-btn:active {
    background: rgba(212, 163, 61, 0.3) !important;
    transform: scale(0.95);
  }

  /* Drawer 9 Ventures Sub-List */
  .drawer-ventures-accordion {
    width: 100% !important;
    margin-top: 6px !important;
  }

  .drawer-ventures-sublist {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    padding: 8px 0 8px 14px !important;
    border-left: 2px solid rgba(212, 163, 61, 0.45) !important;
    margin-left: 8px !important;
  }

  .drawer-sublink {
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    color: #DDE2E1 !important; /* High contrast crisp silver-white */
    padding: 8px 0 !important;
    display: block !important;
    transition: color 0.2s ease !important;
    text-decoration: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04) !important;
  }

  .drawer-sublink:hover,
  .drawer-sublink:active {
    color: #FFE699 !important; /* Bright Gold */
  }

  /* Backdrop Overlay — MUST be below Header and Drawer */
  .nav-backdrop-overlay {
    position: fixed !important;
    inset: 0 !important;
    background: rgba(0, 0, 0, 0.7) !important;
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
    z-index: 9990 !important; /* Sits behind site-header (10000) and drawer (10001) */
    opacity: 0 !important;
    visibility: hidden !important;
    transition: opacity 0.3s ease, visibility 0.3s ease !important;
    pointer-events: none !important;
  }

  .nav-backdrop-overlay.active {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  /* All Grid Reductions (Single Column Stack) */
  .ventures-grid-3,
  .ventures-grid-2,
  div[style*="grid-template-columns: repeat(auto-fit"] {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }

  /* Hero Section Optimizations */
  .page-hero {
    padding: calc(var(--header-height) + 32px) 0 44px !important;
  }

  .page-title {
    font-size: clamp(1.85rem, 6vw, 2.4rem) !important;
    line-height: 1.25 !important;
    margin-bottom: 10px !important;
  }

  .page-subtitle {
    font-size: 1rem !important;
    line-height: 1.55 !important;
  }

  .breadcrumb {
    flex-wrap: wrap !important;
    gap: 6px !important;
    font-size: 0.82rem !important;
    margin-bottom: 16px !important;
  }

  .hero-tagline {
    font-size: 1rem !important;
  }

  .hero-btn-group {
    flex-direction: column;
    width: 100%;
    gap: 12px;
  }

  .hero-btn-group .btn {
    width: 100%;
    justify-content: center;
  }

  /* Card and Panel Padding */
  .glass-panel,
  .glass-card {
    padding: 26px 20px !important;
  }

  .glass-obsidian {
    padding: 24px 20px !important;
  }

  /* Footer Layout */
  .footer-top {
    grid-template-columns: 1fr !important;
    gap: 32px !important;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .footer-legal-links {
    flex-wrap: wrap;
    gap: 14px;
  }

  /* Journey Timeline Mobile Adjustments */
  .timeline-stem {
    padding-left: 32px !important;
  }

  .timeline-item::before {
    left: -32px !important;
    width: 26px !important;
    height: 26px !important;
  }

  .timeline-item::after {
    left: -24px !important;
    top: 15px !important;
    width: 10px !important;
    height: 10px !important;
  }

  .timeline-item .glass-obsidian {
    padding: 22px 18px !important;
  }

  /* Capabilities Table Responsive Scroll */
  .glass-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  /* Inquiry Modal Window */
  .glass-modal-window {
    width: calc(100% - 32px) !important;
    max-width: 480px !important;
    max-height: 88vh !important;
    overflow-y: auto !important;
    padding: 28px 20px !important;
    -webkit-overflow-scrolling: touch;
  }
}

/* ---------- Small Mobile Phones (<480px) ---------- */
@media (max-width: 480px) {
  :root {
    --header-height: 66px;
  }

  .container {
    padding: 0 16px !important;
  }

  /* Brand Crest & Title */
  .brand-crest {
    width: 40px !important;
    height: 40px !important;
  }

  .brand-name {
    font-size: 1.12rem !important;
  }

  .brand-motto {
    font-size: 0.5rem !important;
    letter-spacing: 0.12em !important;
  }

  /* Hero Banner */
  .page-hero {
    padding: calc(var(--header-height) + 20px) 0 32px !important;
  }

  .page-title {
    font-size: 1.65rem !important;
  }

  .page-subtitle {
    font-size: 0.9rem !important;
  }

  /* Section Spacing */
  section[style*="padding: 70px 0"],
  section[style*="padding: 80px 0"],
  section[style*="padding: 90px 0"] {
    padding: 42px 0 !important;
  }

  /* Cards & Panels */
  .glass-panel,
  .glass-card,
  .glass-obsidian {
    padding: 20px 16px !important;
    border-radius: 12px !important;
  }

  /* Deep Dive List Items */
  ul[style*="list-style: none"] li {
    font-size: 0.92rem !important;
    line-height: 1.65 !important;
    padding-left: 18px !important;
  }

  /* Sidebar Metrics Grid (2 columns on mobile, scaling cleanly) */
  .glass-card div[style*="grid-template-columns: repeat(2, 1fr)"],
  div[style*="grid-template-columns: repeat(2, 1fr)"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }

  .glass-card div[style*="grid-template-columns: repeat(2, 1fr)"] > div,
  div[style*="grid-template-columns: repeat(2, 1fr)"] > div {
    padding: 12px 10px !important;
  }

  .glass-card div[style*="font-family: var(--font-heading)"] {
    font-size: 1.25rem !important;
  }

  .glass-card div[style*="font-size: 0.72rem"] {
    font-size: 0.68rem !important;
    line-height: 1.25 !important;
  }

  /* Stats Grid (Home / About) */
  .stats-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .stat-card {
    padding: 18px 16px !important;
  }

  .stat-number {
    font-size: 2rem !important;
  }

  /* Touch Targets & Buttons */
  .btn {
    width: 100% !important;
    padding: 14px 18px !important;
    font-size: 0.88rem !important;
    justify-content: center !important;
    min-height: 48px !important;
    touch-action: manipulation;
  }

  /* Forms & iOS Zoom Prevention (Inputs must have >=16px font-size) */
  .glass-input,
  input,
  select,
  textarea {
    font-size: 16px !important;
    padding: 13px 15px !important;
  }

  /* Venture Lens Badge */
  .venture-lens {
    width: 48px !important;
    height: 48px !important;
    font-size: 1.15rem !important;
  }

  /* Back to Top Floating Button */
  .back-to-top {
    bottom: 16px !important;
    right: 16px !important;
    width: 44px !important;
    height: 44px !important;
  }
}

/* ---------- Ultra Narrow Mobile (<360px) ---------- */
@media (max-width: 360px) {
  .container {
    padding: 0 12px !important;
  }

  .brand-name {
    font-size: 1rem !important;
  }

  .glass-card div[style*="grid-template-columns: repeat(2, 1fr)"],
  div[style*="grid-template-columns: repeat(2, 1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .page-title {
    font-size: 1.5rem !important;
  }
}
