/* ==========================================================================
   THE NEXUS LOGIC — RESPONSIVE MEDIA QUERIES
   Pixel-perfect scalability across 320px, 375px, 430px, 768px, 896px, 1024px, 1280px, 1440px
   ========================================================================== */

/* 1. LARGE DESKTOPS & SCREENS (< 1280px) */
@media (max-width: 1280px) {
  .mega-dropdown {
    width: 860px;
  }

  .tech-ecosystem-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .why-pillars-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 1.5. SMALL TABLETS & LARGE PHONES (< 896px) */
@media (max-width: 896px) {
  :root {
    --header-height: 68px;
  }

  .brand-logo-img {
    height: 52px;
    max-width: 150px;
  }

  .header-inner {
    gap: 12px;
  }

  .header-actions .btn {
    padding: 10px 16px;
    font-size: 0.75rem;
  }

  .header-actions .btn span {
    display: none;
  }

  .header-actions .btn svg {
    margin: 0;
  }

  /* Hide header CTA button on small tablets */
  .header-actions .btn {
    display: none;
  }

  .container {
    padding-left: clamp(16px, 3vw, 32px);
    padding-right: clamp(16px, 3vw, 32px);
  }

  .inner-hero-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .inner-hero-meta-panel {
    max-width: 400px;
  }

  .split-layout-12,
  .split-layout-equal,
  .split-layout-reversed {
    grid-template-columns: 1fr;
    gap: 36px;
  }

  .sticky-editorial-aside {
    position: static;
  }

  .footer-top-grid {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }

  /* Services Explorer on small tablets */
  .services-explorer-nav {
    gap: 0;
  }

  .service-explorer-tab {
    min-width: 220px;
  }

  .panel-capabilities-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  .panel-footer-actions {
    flex-direction: row;
  }

  .panel-footer-actions .btn {
    width: auto;
  }
}

/* 2. TABLETS & SMALL LAPTOPS (< 1024px) */
@media (max-width: 1024px) {
  :root {
    --header-height: 72px;
  }

  .brand-logo-img {
    height: 55px;
    max-width: 160px;
  }

  .header-inner {
    gap: 16px;
  }

  .header-actions .btn {
    padding: 10px 18px;
    font-size: 0.8125rem;
  }

  .header-actions .btn svg {
    width: 14px;
    height: 14px;
  }

  .main-nav {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 100%;
    height: calc(100vh - var(--header-height));
    background-color: rgba(2, 8, 23, 0.98);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    flex-direction: column;
    align-items: flex-start;
    padding: 36px 32px;
    gap: 16px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-10px);
    transition: all var(--transition-smooth);
    border-top: 1px solid var(--border-tech);
    z-index: 899;
  }

  .main-nav.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }

  .nav-item {
    width: 100%;
  }

  .nav-link {
    font-size: 1.125rem;
    padding: 12px 0;
    width: 100%;
    justify-content: space-between;
  }

  .mobile-toggle {
    display: flex;
  }

  /* Mobile Services Accordion */
  .mega-dropdown {
    position: static;
    transform: none !important;
    width: 100%;
    max-height: 0;
    overflow: hidden;
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: max-height 0.4s ease, padding 0.3s ease;
  }

  .nav-item.has-dropdown.mobile-expanded .mega-dropdown {
    max-height: 1200px;
    padding: 16px 0 24px;
  }

  .mega-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .mega-col-title {
    font-size: 0.8125rem;
  }

  /* Hero Section */
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 48px;
    text-align: left;
  }

  .hero-visual-container {
    max-width: 520px;
    margin: 0 auto;
  }

  /* Services Explorer */
  .services-explorer-wrapper {
    grid-template-columns: 1fr;
  }

  .services-explorer-nav {
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-tech);
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
  }

  .service-explorer-tab {
    min-width: 240px;
    border-bottom: none;
    border-right: 1px solid var(--border-tech);
    scroll-snap-align: start;
  }

  .service-explorer-tab.is-active {
    border-left: none;
    border-bottom: 3px solid var(--orange-accent);
  }

  .tab-title {
    font-size: 0.875rem;
  }

  .panel-capabilities-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .panel-footer-actions {
    flex-direction: column;
    gap: 12px;
  }

  .panel-footer-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Section Split Headers */
  .section-split-header {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .section-intro-text {
    font-size: 1rem;
  }

  /* Complexity to Clarity Track */
  .clarity-timeline-track {
    grid-template-columns: repeat(2, 1fr);
    gap: 32px 16px;
  }

  .clarity-timeline-track::before {
    display: none;
  }

  /* Work Showcase */
  .work-showcase-item {
    grid-template-columns: 1fr;
  }

  .work-showcase-visual {
    min-height: 300px;
    order: -1;
  }

  /* Footer */
  .footer-top-grid {
    grid-template-columns: 1fr 1fr;
    gap: 40px;
  }

  .site-footer {
    padding: 60px 0 32px;
  }

  .footer-brand-col p {
    max-width: 100%;
  }

  .brand-logo-img-footer {
    height: 100px;
  }

  /* Inner Pages */
  .inner-hero-grid {
    grid-template-columns: 1fr;
    gap: 36px;
  }

  .split-layout-12,
  .split-layout-equal,
  .split-layout-reversed {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .sticky-editorial-aside {
    position: static;
  }

  .service-dir-block {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 36px 0;
  }

  .service-dir-cta {
    justify-content: flex-start;
  }

  .project-index-row,
  .project-index-row.row-reversed {
    grid-template-columns: 1fr;
    direction: ltr;
  }

  .publication-featured {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .pub-list-row {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 24px 0;
  }

  .pub-arrow-ind {
    text-align: left;
  }

  .contact-split-wrapper {
    grid-template-columns: minmax(0, 1fr);
    gap: 48px;
  }

  .contact-split-wrapper > * {
    min-width: 0;
  }

  .contact-info-panel {
    min-width: 0;
  }

  .case-metadata-strip {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  .case-gallery-dual {
    grid-template-columns: 1fr;
  }

  .solution-narrative-block {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }

  .analyses-editorial-grid {
    grid-template-columns: 1fr;
    gap: 48px;
  }

  .analyses-intel-col {
    position: static;
  }
}

/* 3. MOBILE PHONES (< 768px) */
@media (max-width: 768px) {
  :root {
    --header-height: 64px;
  }

  .brand-logo-img {
    height: 48px;
    max-width: 140px;
  }

  .header-inner {
    gap: 8px;
  }

  .header-actions .btn {
    padding: 8px 14px;
    font-size: 0.75rem;
  }

  .header-actions .btn span {
    display: inline;
  }

  .header-actions .btn svg {
    width: 12px;
    height: 12px;
  }

  /* Hide header CTA button on mobile */
  .header-actions .btn {
    display: none;
  }

  .headline-hero {
    font-size: 2.25rem;
  }

  .headline-section {
    font-size: 1.85rem;
  }

  .solutions-grid {
    grid-template-columns: 1fr;
  }

  .tech-ecosystem-grid {
    grid-template-columns: 1fr;
  }

  .process-grid {
    grid-template-columns: 1fr;
  }

  .insights-grid {
    grid-template-columns: 1fr;
  }

  .why-pillars-grid {
    grid-template-columns: 1fr;
  }

  .about-intro-grid {
    grid-template-columns: 1fr;
    gap: 36px;
  }

  .form-row-2 {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .panel-capabilities-grid {
    grid-template-columns: 1fr;
  }

  .conversion-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .conversion-inner > div {
    max-width: 100%;
  }

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

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

  .site-footer {
    padding: 48px 0 24px;
  }

  .brand-logo-img-footer {
    height: 80px;
  }

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

  .testimonial-card {
    width: 320px;
    padding: 24px 20px;
  }

  .hero-badges-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  /* Inner Pages Mobile */
  .inner-hero {
    padding: calc(var(--header-height) + 40px) 0 60px 0;
  }

  .inner-hero-headline {
    font-size: 2.2rem;
  }

  .inner-hero-lead {
    font-size: 1rem;
  }

  .inner-hero-meta-panel {
    padding: 20px;
  }

  .hero-meta-stat {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .editorial-statement-row {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 28px 0;
  }

  .editorial-large-statement {
    font-size: 1.85rem;
  }

  .case-metadata-strip {
    grid-template-columns: 1fr;
  }

  .service-dir-block {
    padding: 28px 0;
  }

  .service-dir-name {
    font-size: 1.35rem;
  }

  .project-index-row {
    gap: 32px;
  }

  .project-idx-title {
    font-size: 1.75rem;
  }

  .publication-featured {
    padding-bottom: 48px;
    margin-bottom: 48px;
  }

  .analyses-line-item {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .analyses-line-num {
    display: none;
  }

  /* Contact Form Mobile */
  .contact-split-wrapper {
    gap: 36px;
  }

  .contact-direct-link {
    font-size: 1.25rem;
  }

  /* Breadcrumbs Mobile */
  .breadcrumbs {
    font-size: 0.6875rem;
    gap: 8px;
  }

  /* Mobile Navigation improvements */
  .main-nav {
    padding: 24px 20px;
  }

  .mega-link-item a {
    padding: 8px 10px;
  }

  .mega-link-desc {
    font-size: 0.8125rem;
  }
}

/* 4. COMPACT MOBILE (< 420px) */
@media (max-width: 420px) {
  :root {
    --header-height: 60px;
  }

  .brand-logo-img {
    height: 42px;
  }

  .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .btn {
    width: 100%;
  }

  .conversion-cta {
    max-width: 100%;
    padding: 14px 16px;
    white-space: normal;
  }

  .conversion-heading {
    font-size: clamp(1.5rem, 7.5vw, 2rem);
  }

  .hero-ctas {
    flex-direction: column;
    width: 100%;
  }

  .headline-hero {
    font-size: 1.95rem;
  }

  .headline-section {
    font-size: 1.65rem;
  }

  .headline-card {
    font-size: 1.125rem;
  }

  /* Inner heroes on very small screens */
  .inner-hero-headline {
    font-size: 1.85rem;
  }

  .inner-hero-lead {
    font-size: 0.9375rem;
  }

  .eyebrow {
    font-size: 0.75rem;
  }

  /* Mobile header actions */
  .header-actions {
    gap: 12px;
  }

  .header-actions .btn {
    padding: 10px 16px;
    font-size: 0.75rem;
  }

  .mobile-toggle {
    width: 40px;
    height: 40px;
  }

  /* Service directory mobile */
  .service-dir-block {
    padding: 24px 0;
  }

  .service-dir-idx {
    font-size: 1.5rem;
  }

  .service-dir-name {
    font-size: 1.25rem;
  }

  /* Project index mobile */
  .project-idx-title {
    font-size: 1.5rem;
  }

  .project-idx-desc {
    font-size: 0.9375rem;
  }

  /* Contact form mobile */
  .contact-channel-label {
    font-size: 0.625rem;
  }

  .contact-channel-val {
    font-size: 0.9375rem;
  }

  /* Services Explorer mobile optimization */
  .services-explorer-nav {
    padding-bottom: 4px;
  }

  .service-explorer-tab {
    min-width: 200px;
    padding: 16px 20px;
  }

  .tab-number {
    font-size: 0.75rem;
  }

  .tab-title {
    font-size: 0.8125rem;
  }

  .tab-arrow {
    display: none;
  }

  .services-explorer-content {
    padding: 24px 20px;
    min-height: auto;
  }

  .panel-header {
    margin-bottom: 20px;
  }

  .panel-title {
    font-size: 1.35rem;
  }

  .panel-desc {
    font-size: 0.9375rem;
  }

  .capability-item {
    font-size: 0.875rem;
    padding: 10px 0;
  }

  .panel-outcome-box {
    padding: 16px 20px;
  }

  .outcome-label {
    font-size: 0.6875rem;
  }

  .outcome-text {
    font-size: 0.875rem;
  }

  /* Footer on very small screens */
  .site-footer {
    padding: 40px 0 20px;
  }

  .brand-logo-img-footer {
    height: 70px;
  }

  .footer-heading {
    font-size: 0.75rem;
  }

  .footer-link {
    font-size: 0.8125rem;
  }

  /* Breadcrumbs on very small screens */
  .breadcrumbs {
    flex-wrap: wrap;
  }

  /* Analyses mobile */
  .analyses-primary-title {
    font-size: 1.125rem;
  }

  .analyses-primary-abstract {
    font-size: 0.875rem;
  }

  .analyses-line-title {
    font-size: 1rem;
  }

  .analyses-line-desc {
    font-size: 0.8125rem;
  }

  /* Services Explorer on very small screens */
  .services-explorer-nav {
    gap: 0;
  }

  .service-explorer-tab {
    min-width: 160px;
    padding: 14px 16px;
  }

  .tab-number {
    font-size: 0.6875rem;
    margin-right: 10px;
  }

  .tab-title {
    font-size: 0.75rem;
  }

  .panel-title {
    font-size: 1.15rem;
  }

  .panel-desc {
    font-size: 0.875rem;
  }

  .capability-item {
    font-size: 0.8125rem;
  }

  .panel-footer-actions .btn {
    padding: 12px 20px;
    font-size: 0.8125rem;
  }

  /* Feature lines mobile */
  .feature-line-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .feature-line-desc {
    margin-left: 0;
  }
}

/* 5. EXTRA SMALL MOBILE (< 360px) */
@media (max-width: 360px) {
  :root {
    --header-height: 56px;
  }

  .brand-logo-img {
    height: 38px;
  }

  .headline-hero {
    font-size: 1.75rem;
  }

  .inner-hero-headline {
    font-size: 1.65rem;
  }

  .hero-badges-row {
    gap: 10px;
  }

  .hero-badge-text {
    font-size: 0.6875rem;
  }

  /* Hero overlay tags mobile */
  .hero-overlay-tag {
    font-size: 0.625rem;
    padding: 6px 10px;
  }

  .hero-overlay-tag.tag-top-right {
    top: 12px;
    right: 12px;
  }

  .hero-overlay-tag.tag-bottom-left {
    bottom: 12px;
    left: 12px;
  }

  /* Button sizing on very small screens */
  .btn {
    padding: 12px 20px;
    font-size: 0.8125rem;
  }

  .btn svg {
    width: 14px;
    height: 14px;
  }

  /* Navigation text size */
  .nav-link {
    font-size: 1rem;
  }

  /* Mobile menu adjustments */
  .main-nav {
    padding: 20px 16px;
  }

  .mega-link-title {
    font-size: 0.8125rem;
  }

  .mega-link-desc {
    font-size: 0.75rem;
  }

  /* Service tags mobile */
  .service-dir-tag {
    font-size: 0.6875rem;
    padding: 4px 10px;
  }

  /* Project tech tags */
  .project-idx-tech {
    gap: 8px;
  }

  /* Contact info mobile */
  .contact-channel-item {
    padding-top: 16px;
  }

  /* Intel card mobile */
  .intel-flow-step {
    padding: 6px 10px;
  }

  .flow-step-name {
    font-size: 0.6875rem;
  }

  .flow-step-desc {
    font-size: 0.625rem;
  }
}

/* 6. LANDSCAPE MOBILE ORIENTATION FIXES */
@media (max-width: 768px) and (orientation: landscape) {
  .hero-section {
    min-height: auto;
    padding-top: calc(var(--header-height) + 20px);
    padding-bottom: 40px;
  }

  .inner-hero {
    padding: calc(var(--header-height) + 20px) 0 40px 0;
  }

  .section {
    padding: 60px 0;
  }

  .editorial-section {
    padding: 60px 0;
  }

  .editorial-section-tight {
    padding: 40px 0;
  }

  /* Services Explorer landscape optimization */
  .services-explorer-nav {
    padding-bottom: 0;
  }

  .service-explorer-tab {
    min-width: 180px;
    padding: 12px 16px;
  }

  .services-explorer-content {
    padding: 20px;
  }

  .panel-capabilities-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 7. TOUCH DEVICE OPTIMIZATIONS */
@media (hover: none) and (pointer: coarse) {
  /* Remove hover effects on touch devices */
  .btn:hover {
    transform: none;
  }

  .nav-link:hover::after {
    width: 0;
  }

  .nav-link.active::after {
    width: 100%;
  }

  .mega-link-item a:hover {
    background-color: transparent;
    border-left-color: transparent;
    padding-left: 10px;
  }

  .project-index-visual:hover img {
    transform: none;
  }

  .analyses-item-primary:hover {
    transform: none;
  }

  /* Ensure tap targets are large enough */
  .btn,
  .nav-link,
  .service-explorer-tab,
  .mega-link-item a,
  .pub-list-row {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}
