/*
 * ILM Research Solutions — v51 responsive corrections
 * Loaded LAST, after style.css, enhancements.css and service-pages.css.
 * Desktop styling is deliberately unchanged.
 */

/* Ensure long labels never force content wider than the tablet viewport. */
@media (max-width: 960px) {
  .navin,
  .brand,
  .links,
  .hero-copy,
  .section-head,
  .detail-hero-grid > *,
  .detail-head > *,
  .scope-panel,
  .feature-card,
  .blog-topic,
  .service-card { min-width: 0; }

  .brand { max-width: calc(100% - 52px); }
  .brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  img, svg, video, iframe { max-width: 100%; }

  /* Keep the expanded mobile navigation inside the actual header. */
  .nav .links {
    top: 100%;
    max-height: calc(100dvh - 112px);
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: 0 18px 30px rgba(0, 10, 20, .25);
  }
  .nav .links.open { gap: 0; align-items: stretch; }
  .nav .links.open a {
    display: flex;
    align-items: center;
    min-height: 46px;
    padding: 11px 8px;
    overflow-wrap: anywhere;
  }
  .nav .links.open .navcta {
    margin-top: 9px;
    justify-content: center;
    text-align: center;
  }
  .menu {
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 44px;
    cursor: pointer;
  }
}

@media (max-width: 650px) {
  /* Undo the legacy .hero-grid {width:100%} override. */
  .hero-grid.wrap,
  .stats.wrap {
    width: calc(100% - 28px) !important;
    max-width: 1160px;
    margin-left: auto;
    margin-right: auto;
  }

  .hero-grid { min-width: 0; }
  .hero-copy { width: 100%; max-width: 100%; }
  .hero h1 {
    max-width: 100%;
    font-size: clamp(2.15rem, 9.5vw, 3.05rem);
    line-height: 1.09;
    letter-spacing: -.045em;
    overflow-wrap: break-word;
    padding-bottom: .13em;
  }
  .hero h1 span { line-height: 1.13; }
  .hero .eyebrow { font-size: .69rem; letter-spacing: .15em; line-height: 1.6; }
  .hero .intro { max-width: 100%; font-size: .98rem; line-height: 1.65; }
  .hero .actions { margin-top: 3px; }
  .hero .actions .ghost { min-height: 48px; }
  .hero-poster {
    display: block;
    width: 100%;
    max-width: 460px;
    margin: 27px auto 0;
  }
  .hero-poster img { width: 100%; height: auto; }
  .stats { margin-top: 28px; }
  .stats div { padding: 15px 12px; }
  .stats strong { font-size: clamp(1.05rem, 5vw, 1.3rem); }
  .stats small { overflow-wrap: anywhere; line-height: 1.4; }

  /* Keep long headings readable without cropping at narrow widths. */
  .section-head h2,
  .paper-motion-copy h2,
  .contact h2 { font-size: clamp(2rem, 9vw, 2.55rem); overflow-wrap: break-word; }
  .section-head > p { line-height: 1.6; }
  .blog-hero h1 {
    font-size: clamp(2.3rem, 10vw, 3.2rem);
    line-height: 1.08;
    overflow-wrap: break-word;
  }
  .blog-hero .blog-lead { font-size: 1rem; }
  .blog-topic { overflow-wrap: break-word; }

  .detail-hero h1,
  .detail-head h2,
  .detail-cta h2 { overflow-wrap: break-word; }
  .detail-hero-grid,
  .detail-head,
  .detail-cta .wrap { min-width: 0; }
  .detail-hero-aside { width: 100%; }
  .detail-hero .degree-pills span,
  .detail-hero .degree-pills a { overflow-wrap: anywhere; }
  .feature-card, .process-step, .scope-panel, .technical-card,
  .deliverable { overflow-wrap: break-word; }

  /* Popup / forms must remain operable with the phone keyboard open. */
  .service-enquiry-card,
  .popup-card,
  .success-card { max-width: 100%; }
  .service-popup-field input,
  .service-popup-field select,
  .service-popup-field textarea,
  .enquiry-form input,
  .enquiry-form select,
  .enquiry-form textarea { min-width: 0; font-size: 16px; }
  .whatsapp, .live-chat, .instagram-float {
    right: max(12px, env(safe-area-inset-right));
  }
  .live-chat { bottom: max(12px, env(safe-area-inset-bottom)); }
  .whatsapp { bottom: calc(max(12px, env(safe-area-inset-bottom)) + 56px); }
}

/* One comfortably readable service per row on actual phones. */
@media (max-width: 599px) {
  #services .services {
    grid-template-columns: minmax(0, 1fr);
    column-gap: 0;
    row-gap: 57px;
    padding-top: 41px;
    padding-bottom: 9px;
  }
  #services .service-card {
    min-width: 0;
    border-radius: 21px;
  }
  #services .service-card article {
    min-height: 250px;
    height: 100%;
    padding: 79px 23px 20px;
    border-radius: 21px;
  }
  #services .service-card article::before {
    height: 138px;
    border-radius: 20px 20px 12px 12px;
  }
  #services .service-card article::after {
    top: 43px;
    right: 11px;
    bottom: 9px;
    left: 11px;
    border-radius: 16px;
  }
  #services .service-icon { top: -34px; width: 82px; height: 82px; }
  #services .service-icon svg { width: 31px; height: 31px; }
  #services .services article h3 {
    display: block;
    min-height: 0;
    width: auto;
    max-width: 26ch;
    margin: 0 auto 9px;
    font-size: clamp(1.12rem, 4.5vw, 1.28rem);
    line-height: 1.3;
    overflow-wrap: anywhere;
  }
  #services .service-teaser {
    display: block;
    min-height: 0;
    margin: 8px auto 19px !important;
    max-width: 35ch;
    overflow: visible;
    -webkit-line-clamp: unset;
    -webkit-box-orient: initial;
    font-size: .9rem !important;
    line-height: 1.55 !important;
    text-wrap: pretty;
  }
  #services .service-arrow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 43px;
    padding: 7px 8px 7px 15px;
    margin-top: auto;
    font-size: .84rem;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  #services .service-arrow > span { flex: 0 0 28px; width: 28px; height: 28px; }
}

@media (max-width: 359px) {
  .brand { gap: 8px; }
  .brand span { font-size: .77rem; }
  .brand img { width: 37px; height: 37px; }
  .hero h1 { font-size: clamp(2rem, 9.4vw, 2.3rem); }
  .stats div { padding-inline: 9px; }
  #services .service-card article { padding-inline: 18px; }
  .detail-hero h1 { font-size: 2.15rem; }
}
