/* Shared responsive rules for THEICT-HUB web pages. */
html {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  /* No floor: the narrowest phones (foldables ~280px) must fit without
     the page sticking out horizontally. */
  min-width: 0;
  overflow-x: hidden;
  overflow-wrap: break-word;
}

img,
video,
iframe,
canvas,
svg {
  max-width: 100%;
}

img,
video {
  height: auto;
}

video {
  object-fit: cover;
}

iframe {
  border: 0;
}

pre,
code,
table {
  max-width: 100%;
}

pre,
.table-wrapper,
.table-responsive {
  overflow-x: auto;
}

input,
select,
textarea,
button {
  max-width: 100%;
  font: inherit;
}

button,
a {
  touch-action: manipulation;
}

@media (max-width: 768px) {
  body:has(.nav-links.open) {
    overflow: hidden;
  }

  body:has(.nav-links.open) .main-site::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 1090;
  }

  .THEICT-HUB-header {
    z-index: 1200;
    width: calc(100% - 1rem) !important;
    max-width: none !important;
    left: 0.5rem !important;
    right: 0.5rem !important;
    top: 0.5rem !important;
    transform: none !important;
    padding: 0.55rem 0.75rem !important;
    border-radius: 1rem !important;
    gap: 0.5rem;
    /* A backdrop-filter/filter on the header turns it into the containing block for
       the position:fixed mobile drawer, so its inset:0 resolves against the ~64px
       header instead of the viewport and the menu is clipped. Mobile blur is also
       costly, so it is disabled here and replaced by a more opaque background. */
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(255, 255, 255, 0.92) !important;
  }

  .THEICT-HUB-header .logo-img,
  header .logo-img {
    max-width: 48vw;
    height: 2.25rem !important;
    object-fit: contain;
  }

  /* The scrolled state re-applies a blur; it must stay disabled on mobile for the
     same containing-block reason as above. */
  .THEICT-HUB-header.scrolled {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(255, 255, 255, 0.95) !important;
  }

  .menu-toggle {
    display: block !important;
    flex: 0 0 auto;
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0.5rem !important;
    font-size: 0 !important;
    line-height: 1;
    border-radius: 0.65rem;
  }

  .menu-toggle::before {
    content: "\2630";
    font-size: 1.35rem;
  }

  .nav-links {
    display: flex !important;
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: auto !important;
    width: min(88vw, 23rem) !important;
    max-width: 100vw !important;
    max-height: 100dvh;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.35rem !important;
    padding: 5.75rem 1rem 1.25rem !important;
    background: rgba(255, 255, 255, 0.98) !important;
    color: #1d1d1f;
    border: 1px solid rgba(29, 29, 31, 0.12);
    border-radius: 1.25rem 0 0 1.25rem !important;
    box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.18);
    z-index: 1150;
    visibility: hidden;
    transform: translateX(105%) !important;
    transition: transform 0.24s ease, visibility 0.24s ease;
  }

  .nav-links.open {
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    right: 0 !important;
    left: auto !important;
    transform: none !important;
    transition: none !important;
  }

  .nav-links > a,
  .nav-links > .nav-item,
  .nav-links > .dropdown {
    width: 100%;
  }

  .nav-links > a,
  .nav-links .nav-link,
  .nav-links .btn-outline {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 3.25rem;
    padding: 0.8rem 0.85rem !important;
    white-space: normal !important;
    font-size: 0.95rem !important;
    border-radius: 0.65rem;
  }

  .nav-links > a:hover,
  .nav-links .nav-link:hover {
    background: rgba(74, 74, 80, 0.08);
  }

  .dropdown-menu {
    position: static !important;
    display: none;
    width: 100% !important;
    min-width: 0 !important;
    max-height: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    margin: 0 !important;
    padding: 0.2rem 0 0.35rem !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
  }

  .dropdown.active .dropdown-menu {
    display: block;
  }

  .dropdown-menu a {
    min-height: 2.9rem;
    padding: 0.7rem 0.85rem 0.7rem 1.2rem !important;
    white-space: normal !important;
    font-size: 0.85rem !important;
  }

  main,
  section,
  .main-site,
  .main-content {
    max-width: 100%;
  }

  section,
  .hero,
  .hero-premium,
  .portfolio-hero,
  .websites-section,
  .new-section-padding {
    padding-left: clamp(1rem, 5vw, 2rem) !important;
    padding-right: clamp(1rem, 5vw, 2rem) !important;
  }

  .hero-content,
  .hero-premium-inner,
  .about-studio-container,
  .featured-container,
  .showcase-container,
  .container,
  .content-container {
    width: 100% !important;
    max-width: 100% !important;
  }

  .hero-content,
  .hero-premium-inner,
  .about-studio-container,
  .featured-container {
    display: flex !important;
    flex-direction: column !important;
    gap: 1.5rem;
  }

  .hero-left,
  .hero-right,
  .hero-text,
  .hero-image,
  .about-studio-text,
  .about-studio-image,
  .featured-content,
  .featured-image {
    width: 100% !important;
    max-width: 100% !important;
  }

  .hero h1,
  .hero-premium h1,
  .portfolio-hero h1,
  h1 {
    overflow-wrap: anywhere;
    font-size: clamp(2rem, 10vw, 3.25rem);
  }

  .service-card-floating,
  .card {
    max-width: 100%;
  }

  /* "width: max-content" pills and nowrap text can exceed the viewport on
     small phones; let them wrap instead of sticking out. */
  .service-card-floating {
    width: auto !important;
    max-width: calc(100% - 0.5rem);
  }

  .card-text,
  .rotating-text {
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .hero-buttons,
  .button-group,
  .cta-buttons,
  .form-actions {
    display: flex !important;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .hero-buttons > *,
  .button-group > *,
  .cta-buttons > *,
  .form-actions > * {
    max-width: 100%;
  }

  .grid-services-injected,
  .service-grid,
  .websites-grid,
  .portfolio-grid,
  .creative-grid,
  .founders-grid,
  .pricing-grid,
  .products-grid,
  .product-grid,
  .category-grid,
  .showcase-grid {
    grid-template-columns: 1fr !important;
  }

  .websites-grid,
  .products-grid,
  .product-grid {
    gap: 1rem !important;
  }

  .card,
  .service-card,
  .service-card-injected,
  .website-card,
  .product-card,
  .pricing-card,
  .form-section {
    min-width: 0 !important;
    max-width: 100%;
  }

  .website-preview,
  .video-container,
  .video-wrapper,
  .hero-video,
  .media-frame {
    width: 100% !important;
    aspect-ratio: 16 / 9;
    min-height: 0 !important;
  }

  .website-preview iframe,
  .video-container video,
  .video-wrapper video,
  .hero-video video,
  .media-frame video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
  }

  form,
  .form-grid {
    grid-template-columns: 1fr !important;
  }

  label.full,
  .full-width,
  form button {
    grid-column: 1 / -1 !important;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .chat-widget-container {
    left: 0.5rem !important;
    right: 0.5rem !important;
    bottom: 0.5rem !important;
    width: auto !important;
    height: min(600px, calc(100dvh - 1rem)) !important;
    max-height: calc(100dvh - 1rem);
    border-radius: 1rem !important;
  }

  .chat-widget-button {
    right: 1rem !important;
    bottom: 1rem !important;
    width: 3.5rem !important;
    height: 3.5rem !important;
  }

  .modal,
  .modal-content,
  .dialog,
  .drawer {
    width: calc(100% - 1rem) !important;
    max-width: calc(100% - 1rem) !important;
    max-height: calc(100dvh - 1rem);
    overflow-y: auto;
  }
}

@media (max-width: 420px) {
  .THEICT-HUB-header .logo-img,
  header .logo-img {
    max-width: 42vw;
    height: 2rem !important;
  }

  .btn-primary,
  .btn-secondary,
  .btn-outline {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .section-heading,
  .hero-heading {
    font-size: clamp(1.75rem, 9vw, 2.5rem) !important;
  }
}

/* Extra-small phones (foldables and ~360px devices): scale headings and
   controls down further so nothing sticks past the screen edge. */
@media (max-width: 380px) {
  h1,
  .hero h1,
  .hero-premium h1,
  .portfolio-hero h1 {
    font-size: clamp(1.6rem, 9vw, 2.2rem);
  }

  h2,
  .showreel-heading {
    font-size: clamp(1.3rem, 7vw, 1.9rem);
  }

  .btn-primary,
  .btn-secondary,
  .btn-outline {
    padding-left: 1rem;
    padding-right: 1rem;
    font-size: 0.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Auth-aware nav widget (site-auth.js) */
.nav-auth-slot { display: flex; gap: 1rem; align-items: center; }
.auth-link { font-weight: 600; color: #1d1d1f; text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; gap: .4rem; }
.auth-link:hover { color: #06d6a0; }
.auth-link-primary { background: #06d6a0; color: #fff !important; padding: .4rem .9rem; border-radius: 999px; }
.auth-link-primary:hover { background: #05b98a; color: #fff !important; }
.auth-username { max-width: 10ch; overflow: hidden; text-overflow: ellipsis; }
