/* ==========================================================================
   Luminate — Comprehensive Mobile-First Responsive Design System
   Fluid, Adaptive Layouts & Touch-Optimized UX across all viewports
   Breakpoints: Mobile (< 480px) | Phablet (< 768px) | Tablet (< 1024px)
   ========================================================================== */

/* --- 1. Global Viewport Safety & Touch Constraints --- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  position: relative;
  -webkit-text-size-adjust: 100%;
}

img,
picture,
video,
canvas,
svg {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Touch Target Minimum (44px x 44px WCAG 2.2 AA) */
button,
input,
select,
textarea,
.btn,
.nav-link,
.filter-btn,
.accordion-trigger {
  touch-action: manipulation;
}

/* Prevent auto-zoom on iOS inputs when font-size < 16px */
@media (max-width: 768px) {
  input,
  select,
  textarea,
  .form-input,
  .form-select,
  .form-textarea {
    font-size: 16px !important;
    min-height: 48px;
  }

  .form-textarea {
    min-height: 110px;
  }
}

/* --- 2. Mobile Header & Fullscreen Navigation Drawer --- */
@media (max-width: 900px) {
  .site-header {
    height: 64px;
    padding: 0;
  }

  .header-inner {
    height: 64px;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .site-logo {
    font-size: 1.15rem;
    gap: 8px;
  }

  .site-logo .logo-mark svg {
    width: 24px;
    height: 24px;
  }

  .site-logo .logo-img,
  .site-footer .site-logo .logo-img {
    height: 36px;
  }

  .menu-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--color-rule);
    border-radius: var(--radius-sm);
    color: var(--color-ink);
    cursor: pointer;
    z-index: 10001;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
  }

  .menu-toggle:hover,
  .menu-toggle[aria-expanded="true"] {
    background-color: var(--color-rule-subtle);
    border-color: var(--color-ink);
  }

  .menu-toggle svg {
    width: 22px;
    height: 22px;
  }

  /* Fullscreen Slide-Down Navigation Drawer */
  .nav-menu {
    display: flex !important;
    position: fixed !important;
    top: 64px !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: calc(100vh - 64px) !important;
    height: calc(100dvh - 64px) !important;
    background: rgba(245, 244, 240, 0.99) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    padding: 1.5rem 1.25rem 2.5rem !important;
    gap: 0.25rem !important;
    border-top: 1px solid var(--color-rule) !important;
    box-shadow: 0 20px 40px rgba(25, 27, 29, 0.15) !important;
    transform: translateY(-8px) !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
    z-index: 10000 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .nav-menu.is-open {
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: translateY(0) !important;
  }

  .nav-menu .nav-link {
    font-size: 1.15rem !important;
    font-weight: var(--fw-semibold) !important;
    color: var(--color-ink) !important;
    padding: 0.85rem 0.5rem !important;
    border-bottom: 1px solid var(--color-rule-subtle) !important;
    min-height: 48px !important;
    display: flex !important;
    align-items: center !important;
    transition: color var(--transition-fast), padding-left var(--transition-fast) !important;
  }

  .nav-menu .nav-link:hover,
  .nav-menu .nav-link.active {
    color: var(--color-accent) !important;
    padding-left: 0.85rem !important;
  }

  .nav-menu .nav-link.active::after {
    display: none !important;
  }

  .nav-menu .mobile-nav-cta {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    min-height: 48px !important;
    margin-top: 1.5rem !important;
    padding: 0.85rem 1.5rem !important;
    font-size: 1rem !important;
    font-weight: var(--fw-bold) !important;
    border-radius: var(--radius-sm) !important;
    text-align: center !important;
  }

  body.menu-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    touch-action: none !important;
  }
}

/* --- 3. Grid & Column Responsive Collapses --- */
@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--space-lg) !important;
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--space-lg) !important;
  }

  .split-6-6,
  .split-5-7,
  .split-7-5 {
    grid-template-columns: 1fr !important;
    gap: 2.25rem !important;
  }

  /* Hero Section on Tablets & Small Laptops (<= 1024px) */
  .hero-section {
    padding-top: 3rem !important;
    padding-bottom: 3.5rem !important;
  }

  .hero-content {
    max-width: 720px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    text-align: left !important;
  }

  .hero-visual {
    max-width: 720px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    width: 100% !important;
  }

  .hero-actions {
    flex-direction: row !important;
    justify-content: flex-start !important;
    gap: 1rem !important;
  }

  .hero-actions .btn {
    width: auto !important;
    min-width: 180px !important;
  }
}

@media (max-width: 768px) {
  /* All multi-column grids collapse cleanly to 1 column */
  .grid,
  .grid-2,
  .grid-3,
  .grid-4,
  .split-6-6,
  .split-5-7,
  .split-7-5,
  .contact-layout {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }

  /* Section Spacing on Mobile */
  .section {
    padding-top: 3rem !important;
    padding-bottom: 3rem !important;
  }

  .section-header {
    margin-bottom: 2rem !important;
  }

  .section-description {
    font-size: 1rem !important;
  }

  /* Hero Section on Mobile (Standard Phones <= 768px) */
  .hero-section {
    padding-top: 2rem !important;
    padding-bottom: 2.25rem !important;
    border-bottom: 1px solid var(--color-rule) !important;
  }

  .hero-content {
    gap: 0.85rem !important;
    max-width: 100% !important;
  }

  .hero-content .eyebrow {
    font-size: 0.75rem !important;
    letter-spacing: 0.08em !important;
    display: inline-block !important;
  }

  .display-title {
    font-size: clamp(1.85rem, 1.45rem + 2.8vw, 2.45rem) !important;
    line-height: 1.16 !important;
    letter-spacing: -0.025em !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    hyphens: auto !important;
  }

  .hero-content .lead {
    font-size: 1rem !important;
    line-height: 1.55 !important;
    max-width: 100% !important;
    margin-top: 0.25rem !important;
    margin-bottom: 0.5rem !important;
  }

  .hero-actions {
    flex-direction: column !important;
    width: 100% !important;
    gap: 0.75rem !important;
    margin-top: 0.5rem !important;
  }

  .hero-actions .btn {
    width: 100% !important;
    min-height: 48px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    font-size: 0.95rem !important;
    padding: 0.8rem 1.25rem !important;
  }

  .hero-visual {
    max-width: 100% !important;
    width: 100% !important;
    perspective: none !important;
  }

  .hero-visual-card {
    padding: 0 !important;
    border-radius: var(--radius-md) !important;
    overflow: hidden !important;
    box-shadow: 0 10px 24px -6px rgba(25, 27, 29, 0.08), 0 3px 8px -2px rgba(25, 27, 29, 0.04) !important;
    animation: none !important;
    transform: none !important;
  }

  .hero-card-header {
    padding: 0.55rem 0.85rem !important;
    min-height: 38px !important;
  }

  .hero-terminal-title {
    max-width: 160px !important;
    font-size: 0.6875rem !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .hero-card-badge {
    font-size: 9px !important;
    padding: 0.2rem 0.5rem !important;
    flex-shrink: 0 !important;
  }

  .hero-card-image {
    aspect-ratio: 16 / 10 !important;
    max-height: 250px !important;
    width: 100% !important;
    object-fit: cover !important;
  }

  .hero-card-footer {
    padding: 0.65rem 0.85rem !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.25rem !important;
  }

  .hero-card-footer-title {
    font-size: 0.8125rem !important;
  }

  .hero-card-footer-metrics {
    font-size: 0.6875rem !important;
  }

  /* Proof Strip on Mobile */
  .proof-strip {
    padding: 1.25rem 0 !important;
  }

  .proof-inner {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.85rem !important;
  }

  .proof-label {
    font-size: 0.75rem !important;
  }

  .proof-items {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 0.5rem !important;
  }

  .proof-badge {
    width: 100% !important;
    padding: 0.5rem 0.75rem !important;
    background: var(--color-surface) !important;
    border: 1px solid var(--color-rule) !important;
    border-radius: var(--radius-sm) !important;
    font-size: 0.8125rem !important;
  }

  /* Featured Case Study Card on Mobile */
  .featured-project {
    grid-template-columns: 1fr !important;
    border-radius: var(--radius-md) !important;
  }

  .project-details {
    padding: 1.5rem !important;
  }

  .project-preview {
    min-height: 220px !important;
    border-left: none !important;
    border-top: 1px solid var(--color-rule) !important;
  }

  .featured-project div[style*="display: flex; gap: var(--space-xl)"] {
    flex-direction: column !important;
    gap: 1rem !important;
  }

  /* CTA Banner on Mobile */
  .cta-banner {
    padding: 2.25rem 1.25rem !important;
    border-radius: var(--radius-md) !important;
    background-color: var(--color-deep) !important;
    color: var(--color-deep-ink) !important;
  }

  .cta-banner .split-7-5 {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }

  .cta-banner h2 {
    font-size: 1.5rem !important;
    line-height: 1.25 !important;
    color: #FFFFFF !important;
    margin-bottom: 0.75rem !important;
  }

  .cta-banner p {
    font-size: 0.9375rem !important;
    line-height: 1.5 !important;
    color: var(--color-deep-muted) !important;
    margin-bottom: 1.25rem !important;
  }

  .cta-banner .btn {
    width: 100% !important;
    justify-content: center !important;
    text-align: center !important;
  }

  /* Process Steps on Mobile */
  .process-list {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }

  .process-step {
    padding-top: 1rem !important;
  }

  /* Filter Bar on Mobile (Horizontal Touch Scroll) */
  .filter-bar {
    display: flex !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 0.75rem !important;
    margin-bottom: 1.5rem !important;
    gap: 0.5rem !important;
    scrollbar-width: none;
  }

  .filter-bar::-webkit-scrollbar {
    display: none;
  }

  .filter-btn {
    flex-shrink: 0 !important;
    padding: 0.5rem 1rem !important;
    font-size: 0.875rem !important;
    min-height: 42px !important;
  }

  /* Portfolio Previews on Mobile */
  .portfolio-preview {
    height: 180px !important;
  }

  .portfolio-body {
    padding: 1.25rem !important;
  }

  /* Forms & Quote Options on Mobile */
  .quote-options-grid {
    grid-template-columns: 1fr !important;
    gap: 0.625rem !important;
  }

  .quote-option-label {
    padding: 0.85rem 1rem !important;
  }

  .quote-estimate-card {
    padding: 1.25rem !important;
  }

  .quote-estimate-card .estimate-details {
    flex-direction: column !important;
    gap: 0.5rem !important;
  }

  /* Live Search Inputs on Mobile */
  .live-search-wrapper {
    max-width: 100% !important;
    margin-bottom: 1.5rem !important;
  }

  .live-search-input {
    padding: 0.75rem 0.85rem 0.75rem 2.5rem !important;
    font-size: 16px !important;
  }

  /* Accordions on Mobile */
  .accordion-trigger {
    padding: 1rem 0 !important;
    font-size: 1rem !important;
  }

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

  /* Footer on Mobile */
  .site-footer {
    padding-top: 3rem !important;
    padding-bottom: 2rem !important;
  }

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

  .footer-bottom {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 1rem !important;
  }

  .footer-bottom div[style*="display: flex"] {
    flex-wrap: wrap !important;
    gap: 0.85rem !important;
  }
}

/* Compact Mobile Screens (<= 480px - e.g. iPhone 13 mini, Pixel, Galaxy S) */
@media (max-width: 480px) {
  .hero-section {
    padding-top: 1.75rem !important;
    padding-bottom: 2rem !important;
  }

  .display-title {
    font-size: clamp(1.7rem, 1.35rem + 2.5vw, 2.15rem) !important;
    line-height: 1.18 !important;
  }

  .hero-terminal-title {
    max-width: 130px !important;
    font-size: 0.65rem !important;
  }

  .hero-card-image {
    max-height: 210px !important;
  }

  .hero-card-header {
    padding: 0.45rem 0.75rem !important;
  }

  .hero-card-footer {
    padding: 0.65rem 0.75rem !important;
  }

  .hero-actions .btn {
    padding: 0.75rem 1rem !important;
    font-size: 0.9375rem !important;
  }
}

/* Ultra-Compact Screens (<= 360px - e.g. iPhone SE 1st gen, Galaxy Fold cover) */
@media (max-width: 360px) {
  :root {
    --gutter: 0.75rem !important;
  }

  .site-logo {
    font-size: 1rem !important;
  }

  .site-logo .logo-img,
  .site-footer .site-logo .logo-img {
    height: 32px;
  }

  .hero-section {
    padding-top: 1.25rem !important;
    padding-bottom: 1.5rem !important;
  }

  .display-title {
    font-size: 1.55rem !important;
    line-height: 1.2 !important;
    letter-spacing: -0.02em !important;
  }

  .hero-content .lead {
    font-size: 0.875rem !important;
    line-height: 1.5 !important;
  }

  /* Hide long file path on ultra-narrow screens to guarantee zero horizontal overflow */
  .hero-terminal-title {
    display: none !important;
  }

  .hero-card-header {
    padding: 0.4rem 0.5rem !important;
    min-height: 32px !important;
  }

  .hero-card-badge {
    font-size: 8.5px !important;
    padding: 0.15rem 0.4rem !important;
  }

  .hero-card-image {
    max-height: 170px !important;
  }

  .hero-card-footer {
    padding: 0.5rem 0.5rem !important;
  }

  .hero-card-footer-title {
    font-size: 0.75rem !important;
  }

  .hero-card-footer-metrics {
    font-size: 0.625rem !important;
    word-break: break-all !important;
  }

  .hero-actions .btn {
    min-height: 44px !important;
    font-size: 0.875rem !important;
    padding: 0.65rem 0.75rem !important;
  }

  .btn {
    padding: 0.65rem 0.85rem !important;
    font-size: 0.875rem !important;
  }
}

/* Mobile Devices in Landscape Orientation */
@media (max-height: 500px) and (orientation: landscape) {
  .hero-section {
    padding-top: 1.25rem !important;
    padding-bottom: 1.25rem !important;
  }

  .hero-section .split-6-6 {
    grid-template-columns: 1fr 1fr !important;
    gap: 1.25rem !important;
    align-items: center !important;
  }

  .hero-section .display-title {
    font-size: 1.45rem !important;
    line-height: 1.15 !important;
  }

  .hero-section .hero-content .lead {
    font-size: 0.85rem !important;
    line-height: 1.35 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .hero-section .hero-actions {
    flex-direction: row !important;
    gap: 0.5rem !important;
    margin-top: 0.25rem !important;
  }

  .hero-section .hero-actions .btn {
    width: auto !important;
    min-height: 38px !important;
    padding: 0.4rem 0.75rem !important;
    font-size: 0.8125rem !important;
  }

  .hero-section .hero-card-image {
    max-height: 140px !important;
  }
}

/* Visibility Utilities */
.hide-mobile {
  display: block;
}

.show-mobile {
  display: none;
}

@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }

  .show-mobile {
    display: block !important;
  }
}

/* General Layout Utilities */
.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

.w-100 { width: 100%; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
