/**
 * Mobile-only overrides (max-width: 767px)
 * Desktop styles are unchanged.
 */

@media (max-width: 767px) {
  /* clip avoids breaking position:sticky on iOS (overflow-x:hidden on body does) */
  html {
    overflow-x: clip;
    max-width: 100%;
  }

  body {
    overflow-x: clip;
  }

  /* Sphere shape/size handled in hero-particles.js (no CSS squash) */

  /* Header — space between logo title and Get Started */
  .site-header .container {
    gap: 0.75rem;
  }

  .logo-link {
    margin-right: 0.75rem;
    min-width: 0;
  }

  .logo-text {
    font-size: clamp(1rem, 4.2vw, 1.25rem);
  }

  .nav-actions {
    flex-shrink: 0;
    gap: 0.5rem;
    margin-left: auto;
  }

  .nav-actions .btn-primary {
    color: #030609;
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    white-space: nowrap;
  }

  /* Mobile menu — simple links; services expand on tap */
  .mobile-nav-services-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.75rem;
    margin: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    color: var(--muted-foreground);
    cursor: pointer;
    text-align: left;
  }

  .mobile-nav-services-toggle:hover,
  .mobile-nav-services-toggle[aria-expanded="true"] {
    background: var(--secondary);
    color: var(--foreground);
  }

  .mobile-nav-services-toggle .nav-chevron {
    width: 16px;
    height: 16px;
    transition: transform 0.2s;
  }

  .mobile-nav-services-toggle[aria-expanded="true"] .nav-chevron {
    transform: rotate(180deg);
  }

  .mobile-nav-services-panel {
    display: none;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0 0 0.5rem 0.75rem;
  }

  .mobile-nav-services-panel.open {
    display: flex;
  }

  .mobile-nav-sub {
    padding: 0.6rem 0.75rem !important;
    font-size: 0.9rem !important;
    color: var(--muted-foreground) !important;
    border-radius: 8px;
  }

  .mobile-nav .btn-primary.btn-full {
    color: #030609 !important;
    margin-top: 0.25rem;
  }

  /* Terminal — wrap long lines */
  .terminal-body {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    min-height: 200px;
    max-height: 220px;
    font-size: 0.7rem;
    line-height: 1.55;
    padding: 12px;
  }

  .terminal-card {
    max-width: 100%;
  }

  .hero-terminal-area {
    padding-bottom: 2rem;
    margin-top: 0.5rem;
  }

  main {
    overflow-x: clip;
  }

  /* Privacy / Terms — match header .container side padding (legal-content zeros horizontal) */
  .legal-content.container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  @media (min-width: 640px) {
    .legal-content.container {
      padding-left: 1.5rem;
      padding-right: 1.5rem;
    }
  }

  /*
   * Mobile: native horizontal swipe (class from products-carousel.js).
   * No scroll-hijack / fixed pin — avoids cards sticking over Why section on iOS.
   */
  .products-section--swipe {
    height: auto !important;
    overflow: visible;
  }

  .products-section--swipe .products-section-header {
    padding: 1.5rem 0 0.5rem;
  }

  .products-section--swipe .products-section-header .section-header-trisun {
    margin-bottom: 0.5rem;
  }

  .products-section--swipe .products-section-header .section-header-trisun .section-desc {
    font-size: 1rem;
  }

  .products-section--swipe .products-section-pin {
    position: relative;
    top: auto;
    height: auto;
    max-height: none;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 0 0 1rem;
    overflow: visible;
  }

  .products-section--swipe .products-carousel-viewport {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    /* Allow vertical page scroll when swiping on cards (no pan-x lock) */
    touch-action: auto;
    scrollbar-width: none;
  }

  .products-section--swipe .products-carousel-viewport::-webkit-scrollbar {
    display: none;
  }

  .products-section--swipe .products-carousel-track {
    --carousel-side-pad: 1rem;
    --carousel-card-w: 300px;
    padding-right: 1rem !important;
    transform: none !important;
    will-change: auto;
  }

  .products-section--swipe .product-card {
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  /* Edge fades sit on top of cards when swiping — hide on mobile */
  .products-section--swipe .products-carousel-fade {
    display: none;
  }

  .why-section.section {
    padding-top: 1.25rem;
    padding-bottom: 3rem;
  }

  .stack-marquee-section {
    padding-bottom: 3rem;
  }

  /* Services page */
  .services-page .services-hero {
    padding-bottom: 1.5rem;
  }

  .services-catalog {
    padding-bottom: 2.5rem;
    scroll-margin-top: calc(var(--header-h) + 0.5rem);
  }

  .services-filters {
    margin-bottom: 1.25rem;
    overflow-x: auto;
    flex-wrap: nowrap;
    justify-content: flex-start;
    padding-bottom: 0.25rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .services-filters::-webkit-scrollbar {
    display: none;
  }

  .services-filter-chip {
    flex-shrink: 0;
  }

  .reviews-section {
    padding-top: 3rem;
    padding-bottom: 3rem;
  }

  .review-card {
    padding: 1.25rem;
  }

  /* Lead Management card — shorter description (mobile only) */
  .project-card[data-project="lead-management"] .project-card-body > p:not(.project-card-desc--compact) {
    display: none;
  }

  .project-card[data-project="lead-management"] .project-card-desc--compact {
    display: block;
  }

  /* Case study modal — contain layout, no horizontal scroll */
  body.case-study-modal-open {
    overflow-x: hidden;
  }

  .case-study-modal {
    padding: 0;
    align-items: flex-end;
    overflow-x: hidden;
  }

  .case-study-modal-dialog,
  .case-study-modal-dialog--portfolio {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    height: 90vh;
    max-height: 90vh;
    height: 90dvh;
    max-height: 90dvh;
    border-radius: 1.25rem 1.25rem 0 0;
    transform: translateY(100%);
    overflow: hidden;
    box-sizing: border-box;
  }

  .case-study-modal.is-open .case-study-modal-dialog,
  .case-study-modal.is-open .case-study-modal-dialog--portfolio {
    transform: translateY(0);
  }

  .case-study-modal-header {
    flex-shrink: 0;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    max-width: 100%;
    box-sizing: border-box;
  }

  .case-study-modal-title {
    flex: 1 1 100%;
    min-width: 0;
    max-width: 100%;
    font-size: 1.0625rem;
    padding-right: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .case-study-modal-actions {
    flex-shrink: 0;
    margin-left: auto;
  }

  .case-study-copy-label {
    display: none;
  }

  .case-study-modal-body {
    width: 100%;
    max-width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    padding-bottom: 1.25rem;
  }

  .case-study-modal-dialog--portfolio .case-study-modal-body {
    max-height: 100%;
    flex: 1 1 auto;
    min-height: 0;
    height: 0;
    overflow-y: auto;
  }

  .case-study-modal-left,
  .case-study-modal-right {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 1rem;
    position: static;
    overflow-x: hidden;
    overflow-y: visible;
    box-sizing: border-box;
  }

  .case-study-modal-right {
    gap: 1rem;
    padding-bottom: 1.5rem;
  }

  .case-study-field {
    margin-bottom: 1rem;
  }

  .case-study-modal-dialog--portfolio .case-study-wp-highlight {
    margin-bottom: 1rem;
    padding: 0.875rem;
  }

  .case-study-field,
  .case-study-field-value,
  .case-study-field-value--desc,
  .case-study-wp-highlight,
  .case-study-wp-highlight-list {
    max-width: 100%;
    overflow-wrap: break-word;
    word-break: break-word;
  }

  .case-study-modal-tags {
    max-width: 100%;
  }

  .case-study-image-wrap {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .case-study-image-wrap.has-image {
    max-height: 130px;
    min-height: 0;
    aspect-ratio: 16 / 9;
  }

  .case-study-modal-dialog--portfolio .case-study-image-wrap.has-image {
    max-height: 120px;
    min-height: 0;
  }

  .case-study-modal-image {
    width: 100%;
    max-width: 100%;
    height: 100%;
    min-height: 0;
    display: block;
  }

  .case-study-image-placeholder {
    aspect-ratio: 2 / 1;
    min-height: 0;
    max-height: 130px;
    height: auto;
    padding: 0.875rem 0.75rem;
    gap: 0.5rem;
  }

  .case-study-image-placeholder svg {
    width: 2rem;
    height: 2rem;
  }

  .case-study-image-placeholder span {
    font-size: 0.75rem;
    line-height: 1.35;
    max-width: 11rem;
  }

  .case-study-more,
  .case-study-sites {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: visible;
    flex-shrink: 0;
    box-sizing: border-box;
  }

  .case-study-more {
    margin-top: 0.25rem;
    padding-bottom: 0.5rem;
  }

  .case-study-sites {
    padding: 0.85rem 0.75rem 0.75rem;
  }

  .case-study-more-head,
  .case-study-sites-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    max-width: 100%;
    flex-wrap: nowrap;
    box-sizing: border-box;
  }

  .case-study-more-heading,
  .case-study-sites-heading {
    flex: 1;
    min-width: 0;
    font-size: 0.75rem;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .case-study-more-nav,
  .case-study-sites-nav {
    display: flex;
    flex-shrink: 0;
    gap: 0.35rem;
  }

  .case-study-more-prev,
  .case-study-more-next,
  .case-study-sites-prev,
  .case-study-sites-next {
    width: 2.25rem;
    height: 2.25rem;
    flex-shrink: 0;
  }

  .case-study-more-track,
  .case-study-sites-track {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .case-study-more-card {
    flex: 0 0 108px;
  }

  .case-study-more-thumb {
    height: 64px;
  }

  .case-study-more-card .case-study-more-title {
    font-size: 0.625rem;
    line-height: 1.3;
  }

  .case-study-wp-highlight {
    padding: 1rem;
    margin-bottom: 1.25rem;
  }

  .case-study-site-card {
    flex: 0 0 108px;
  }

  .case-study-site-thumb {
    height: 64px;
  }

  .project-card--featured {
    flex-direction: column;
  }

  .project-card--featured .project-card-visual {
    flex: none;
    width: 100%;
    height: 200px;
    min-height: 0;
  }

  .about-team .team-card {
    padding: 1.5rem 1rem;
  }
}
