/* ==========================================================================
   iHuB PHASE 4 — RESPONSIVE SAFETY & MOBILE LAYOUT SYSTEM
   Applied after page-specific styles so these rules can safely protect
   narrow screens without changing the desktop design.
   ========================================================================== */

/* Prevent flex/grid children from forcing the viewport wider. */
.grid > *,
.value-grid > *,
.curriculum-timeline > *,
.process-grid > *,
.engagement-grid > *,
.governance-grid > *,
.related-grid > *,
.event-featured > *,
.case-study > *,
.editorial-split > *,
.page-hero-split > *,
.instructor-grid > *,
.registration-wrapper > * {
  min-width: 0;
}

img,
svg,
video,
canvas,
iframe {
  max-width: 100%;
}

iframe {
  width: 100%;
  border: 0;
}

pre,
code {
  max-width: 100%;
}

pre {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

body,
button,
input,
textarea,
select {
  overflow-wrap: anywhere;
}

/* ==========================================================================
   Tablet and below — 1023px
   ========================================================================== */
@media (max-width: 1023px) {
  .header-inner {
    min-height: 68px;
  }

  .site-nav {
    top: 68px;
    height: calc(100dvh - 68px);
  }

  .page-hero {
    padding-top: clamp(3rem, 8vw, 5rem);
    padding-bottom: clamp(3.5rem, 9vw, 5rem);
  }

  .page-hero-content {
    max-width: 760px;
  }

  .event-featured-content,
  .case-study-content {
    padding: clamp(1.5rem, 4vw, 2.5rem);
  }

  .resource-pack-card,
  .registration-form-card {
    padding: clamp(1.5rem, 4vw, 2.5rem);
  }
}

/* ==========================================================================
   Phones — 767px and below
   ========================================================================== */
@media (max-width: 767px) {
  :root {
    --container-padding: 1rem;
    --space-8: 2.5rem;
    --space-9: 3rem;
    --space-10: 3.5rem;
    --space-11: 4rem;
    --space-12: 5rem;
  }

  .container {
    padding-inline: 1rem;
  }

  h1 {
    font-size: clamp(2rem, 9vw, 2.75rem);
  }

  h2 {
    font-size: clamp(1.65rem, 7vw, 2.25rem);
  }

  h3 {
    font-size: clamp(1.25rem, 5.5vw, 1.65rem);
  }

  .section {
    padding-block: 3.5rem;
  }

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

  .section-title {
    font-size: clamp(1.8rem, 7vw, 2.4rem);
  }

  .section-description,
  .lead {
    font-size: 1rem;
  }

  .page-hero-title {
    font-size: clamp(2rem, 9vw, 2.75rem);
    margin-bottom: 1rem;
  }

  .page-hero-description {
    font-size: 1rem;
  }

  .btn {
    width: auto;
    max-width: 100%;
    white-space: normal;
    line-height: 1.25;
  }

  .cta-actions,
  .hero-cta-group {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .cta-actions .btn,
  .hero-cta-group .btn {
    width: 100%;
  }

  .filter-bar {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.35rem;
    scrollbar-width: thin;
  }

  .filter-btn {
    flex: 0 0 auto;
  }

  .value-grid,
  .curriculum-timeline {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
  }

  .value-card,
  .curriculum-card,
  .service-overview-card,
  .consultancy-card,
  .process-card,
  .engagement-card {
    padding: 1.5rem;
  }

  .event-item {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1.25rem;
  }

  .event-date {
    width: 64px;
  }

  .event-details h3,
  .course-title {
    overflow-wrap: anywhere;
  }

  .editorial-split,
  .page-hero-split,
  .registration-wrapper,
  .instructor-grid,
  .event-featured,
  .case-study {
    grid-template-columns: minmax(0, 1fr);
  }

  .editorial-visual {
    min-height: 240px;
  }

  .timeline {
    padding-left: 1.5rem;
  }

  .timeline-item::before {
    left: calc(-1.5rem - 6px);
  }

  .hero-carousel-section {
    height: auto;
    min-height: 560px;
    max-height: none;
  }

  .hero-content {
    width: 100%;
    padding-inline: 1rem;
  }

  .hero-title,
  .landing-title {
    font-size: clamp(2rem, 9vw, 3rem);
  }

  .hero-description,
  .landing-subtitle {
    font-size: 1rem;
  }

  .carousel-control {
    width: 42px;
    height: 42px;
    font-size: 1.4rem;
  }

  .carousel-control.prev { left: 0.75rem; }
  .carousel-control.next { right: 0.75rem; }

  .hero-cta-box {
    padding: 1.5rem;
    max-width: 100%;
  }

  .resource-pack-card,
  .registration-form-card {
    padding: 1.5rem;
  }

  .case-study-content {
    padding: 1.5rem;
  }

  .related-card {
    align-items: flex-start;
    min-width: 0;
  }

  .related-card > * {
    min-width: 0;
  }

  .media-newsletter {
    padding: 1.5rem;
  }

  .media-newsletter-form {
    width: 100%;
  }

  .media-newsletter-form .btn {
    width: 100%;
  }

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

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

  .footer-legal {
    gap: 0.75rem 1rem;
  }
}

/* ==========================================================================
   Very small phones — 479px and below
   ========================================================================== */
@media (max-width: 479px) {
  :root {
    --container-padding: 0.875rem;
  }

  .container {
    padding-inline: 0.875rem;
  }

  .header-inner {
    gap: 0.75rem;
  }

  .site-logo {
    max-width: 130px;
    height: 34px;
  }

  .site-nav {
    width: min(94vw, 360px);
    padding-inline: 0.875rem;
  }

  .mobile-menu-toggle {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }

  .nav-link {
    min-height: 48px;
    padding-inline: 0.65rem;
  }

  .dropdown-toggle-button {
    width: 48px;
    min-height: 48px;
  }

  .hero-carousel-section {
    min-height: 600px;
  }

  .hero-slide {
    align-items: flex-start;
    padding-top: 6rem;
    padding-bottom: 4rem;
  }

  .hero-content {
    padding-inline: 0.875rem;
  }

  .hero-badge {
    max-width: 100%;
    font-size: 0.75rem;
    line-height: 1.4;
  }

  .hero-title,
  .landing-title {
    font-size: clamp(1.9rem, 9.5vw, 2.5rem);
  }

  .carousel-control {
    top: auto;
    bottom: 3.5rem;
    transform: none;
  }

  .carousel-control:hover {
    transform: scale(1.05);
  }

  .carousel-control.prev { left: 0.875rem; }
  .carousel-control.next { right: 0.875rem; }

  .carousel-indicators {
    bottom: 1.25rem;
  }

  .btn,
  .btn--large,
  .btn--small {
    min-height: 48px;
    padding-inline: 1rem;
  }

  .filter-bar {
    margin-inline: -0.25rem;
    padding-inline: 0.25rem;
  }

  .filter-btn {
    min-height: 44px;
  }

  .page-hero {
    padding-block: 3rem;
  }

  .page-hero-title {
    font-size: clamp(1.9rem, 9vw, 2.5rem);
  }

  .footer-grid {
    gap: 1.75rem;
  }

  .footer-bottom {
    gap: 1rem;
  }
}

/* Do not let hover-only interactions become sticky on touch devices. */
@media (hover: none) and (pointer: coarse) {
  .card:hover,
  .event-item:hover,
  .event-card:hover,
  .portfolio-card:hover,
  .related-card:hover {
    transform: none;
  }
}

/* Reduced motion is already supported globally; keep viewport-safe transitions here too. */
@media (prefers-reduced-motion: reduce) {
  .hero-slide {
    transition: none;
  }
}
