/* Device layouts only. The existing desktop presentation starts at 1024px. */
@media (max-width: 1023px) {
  :root {
    --qa-gutter: clamp(20px, 4vw, 32px);
    --shell-gutter: var(--qa-gutter);
    --shell-frame-width: calc(100% - 2 * var(--shell-gutter));
  }

  html { scroll-padding-top: calc(var(--shell-header-height) + 16px); }
  main { min-width: 0; overflow-wrap: anywhere; }
  main :is(input, select, textarea) { font-size: max(1rem, 16px); }
  main :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select) { min-height: 48px; }
  main textarea { min-height: 144px; }
  main :is(button, summary) { touch-action: manipulation; }
  main summary { min-height: 44px; padding-block: 8px; }
  main :is(a, button, input, select, textarea, summary):focus-visible { scroll-margin-block: 96px 24px; }

  /* A full-width, independently scrollable menu fits portrait and landscape. */
  .site-header .brand-text { display: grid; font-size: .875rem; }
  .site-header .brand { min-width: 0; gap: 10px; }
  .site-header .nav-toggle { flex-shrink: 0; }
  .site-header .nav-toggle[aria-expanded="true"] > span:nth-child(2) { transform: translateY(7px) rotate(45deg); }
  .site-header .nav-toggle[aria-expanded="true"] > span:nth-child(3) { opacity: 0; }
  .site-header .nav-toggle[aria-expanded="true"] > span:nth-child(4) { transform: translateY(-7px) rotate(-45deg); }
  .site-header .site-nav {
    position: fixed;
    inset: var(--shell-header-height) 0 auto;
    width: 100%;
    height: calc(100vh - var(--shell-header-height));
    height: calc(100dvh - var(--shell-header-height));
    max-height: calc(100dvh - var(--shell-header-height));
    padding: 16px var(--shell-gutter) max(24px, env(safe-area-inset-bottom));
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }
  .site-header .site-nav__primary > a,
  .site-header .site-nav__actions > a,
  .site-header .features-menu a { min-height: 48px; font-size: 1rem; }
  /* Mobile Features is a single destination, with no disclosure control. */
  .site-header .nav-dropdown-trigger .nav-features-link { flex: 1; padding-inline: 16px; border-radius: var(--shell-radius-sm); font-size: 1rem; }
  .site-header .nav-dropdown-trigger .nav-dropdown-toggle,
  .site-header .nav-dropdown .features-menu { display: none; }
  .site-header .features-menu { min-width: 0; padding-inline: 8px; }
  .site-header .site-nav__actions { padding-top: 16px; border-top: 1px solid var(--shell-divider); }
  .site-header .site-nav__actions > .nav-cta { justify-content: center; margin-left: 0; }

  .site-footer .footer-link-group a { display: inline-flex; align-items: center; min-height: 44px; padding-block: 8px; }
  .site-footer .footer-link-group ul { gap: 0; }

  /* Keep images above card titles in document order, without sticky fades. */
  .home-v2 { scroll-snap-type: none; }
  .home-v2 .home-v2-opening--media-wall { min-height: 0; padding-block: 104px 40px; }
  .home-v2 .home-v2-opening--media-wall .home-v2-opening__copy { width: calc(100% - 2 * var(--qa-gutter)); max-width: 720px; margin-inline: auto; }
  .home-v2 .home-v2-opening__copy > p:not(.home-v2-kicker) { font-weight: 400; }
  .home-v2 .home-v2-scene {
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin: 20px var(--qa-gutter);
    scroll-margin-top: 48px;
  }
  .home-v2 .home-v2-scene::before { display: none; }
  .home-v2 .home-v2-scene__copy {
    position: relative;
    inset: auto;
    align-self: stretch;
    width: auto;
    margin: 0;
    padding: clamp(24px, 4vw, 40px);
    opacity: 1;
    transform: none;
  }
  .home-v2 .home-v2-scene__copy h2 { font-size: clamp(1.875rem, 4vw, 2.5rem); line-height: 1.2; }
  .home-v2 .home-v2-scene__copy > p:not(.home-v2-kicker) { font-weight: 400; }
  .home-v2 .home-v2-scene__media {
    position: relative;
    inset: auto;
    z-index: 0;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
  }
  .home-v2 .home-v2-scene__media picture { display: block; height: 100%; }
  .home-v2 .home-v2-scene__media img {
    position: static;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: none;
    visibility: visible;
    will-change: auto;
  }
  .home-v2 .home-v2-scene-nav { padding: 0 var(--qa-gutter); overflow-x: auto; overscroll-behavior-inline: contain; }
  .home-v2 .home-v2-scene-nav__links { display: flex; width: max-content; min-width: 100%; margin: 0; gap: 8px; }
  .home-v2 .home-v2-scene-nav a { flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 48px; padding: 10px 12px; font-size: .875rem; white-space: nowrap; }
  .home-v2 .home-v2-video-intro__line--brand { white-space: normal; }
  .home-v2 .home-v2-workflow-closing__layout { grid-template-columns: minmax(0, 1fr); }

  /* Keep 3D previews contained; controls wrap instead of widening the page. */
  .docsv2 .docsv2-carousel { min-width: 0; max-width: 100%; }
  .docsv2 .docsv2-carousel__stage { overflow: clip; }
  .docsv2 .docsv2-carousel__controls { grid-template-columns: minmax(0, 1fr) auto; }
  .docsv2 .docsv2-carousel__dots { grid-row: 2; grid-column: 1 / -1; flex-wrap: wrap; }
  .docsv2 .docsv2-carousel__dots button { width: 44px; min-width: 44px; }
  .docsv2 .docsv2-carousel__dots .pricing-v2-tooltip { position: static; }
  .docsv2 .docsv2-carousel__dots .pricing-v2-tooltip__bubble { max-width: 100%; }
  .docsv2 .docsv2-carousel__dots .pricing-v2-tooltip__bubble::before { display: none; }
  .docsv2 .docsv2-nav a { min-height: 48px; font-size: .875rem; }
  .docsv2 .docsv2-nav > div { justify-content: flex-start; overscroll-behavior-inline: contain; }

  .pricing-v2-page .pricing-v2-currency select,
  .demov2 .demo-video__language select,
  .home-v2 .home-v2-video__language-select { min-height: 48px; font-size: 1rem; }
  .pricing-v2-page .pricing-v2-mobile-details summary { min-height: 48px; }
  .pricing-v2-page .pricing-v2-mobile-details :is(dt, dd) { min-width: 0; overflow-wrap: anywhere; }

  .news .news-reading { grid-template-columns: minmax(0, 1fr); }
  .news .news-prose { max-width: 70ch; }
  .news .news-sidebar { position: static; }
  .news .news-sidebar nav { display: block; }
  .news .news-sidebar nav a { display: inline-flex; align-items: center; min-height: 44px; }
}

@media (min-width: 640px) and (max-width: 1023px) {
  .ganttv2 .ganttv2-outcomes,
  .controlv2 .controlv2-approvals__benefits { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
}

@media (max-width: 639px) {
  .site-header .brand-logo { width: 38px; height: 34px; }
  .site-header .brand-text { font-size: .8125rem; }
  .site-footer .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 20px; }
  .site-footer .footer-intro { grid-column: 1 / -1; max-width: 38ch; }
  .site-footer .footer-link-heading { line-height: 1.5; }
  .site-footer .footer-link-group a { font-size: .875rem; }

  body[data-page-kind="interior"] main:is(.apqpv2, .ganttv2, .docsv2) :is(.apqpv2-hero, .ganttv2-hero, .docsv2-hero) h1,
  body[data-page-kind="interior"] main.pricing-v2-page h1 {
    font-size: clamp(2rem, 8.4vw, 2.5rem);
    line-height: 1.18;
    overflow-wrap: anywhere;
  }
  .apqpv2 .apqpv2-hero__copy,
  .ganttv2 .ganttv2-hero__copy,
  .docsv2 .docsv2-hero__copy { padding-block: 32px; }
  .trialv2 .apqpv2-hero__copy { padding: 0; }
  .apqpv2 .apqpv2-lede,
  .ganttv2 .ganttv2-lede,
  .docsv2 .docsv2-lede { font-size: 1.0625rem; font-weight: 400; line-height: 1.65; }
  .apqpv2 .apqpv2-section,
  .ganttv2 .ganttv2-section,
  .docsv2 .docsv2-section { padding-block: 48px; }
  .apqpv2 .apqpv2-actions,
  .ganttv2 .ganttv2-actions,
  .docsv2 .docsv2-actions,
  .home-v2 .home-v2-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .apqpv2 .apqpv2-actions > a,
  .ganttv2 .ganttv2-actions > a,
  .docsv2 .docsv2-actions > a,
  .home-v2 .home-v2-actions > a { justify-content: center; width: 100%; min-height: 48px; margin-inline: 0; text-align: center; }
  .home-v2 .home-v2-opening h1 { font-size: clamp(2rem, 9vw, 2.75rem); }
  .home-v2 .home-v2-opening__copy > p:not(.home-v2-kicker) { font-size: 1.0625rem; line-height: 1.65; }
  .home-v2 .home-v2-scene__copy { padding: 24px 20px; }
  .home-v2 .home-v2-scene__copy h2 { font-size: 1.875rem; }
  .home-v2 .home-v2-workflow__panel { padding: 24px 20px; min-height: 0; }
  .home-v2 .home-v2-workflow__controls button { flex-basis: 168px; }
  .home-v2 .home-v2-editorial-link { max-width: 100%; }

  .docsv2 .docsv2-carousel__controls { gap: 12px 8px; }
  .docsv2 .docsv2-carousel__selection { font-size: .875rem; }
  .docsv2 .docsv2-carousel.is-ready .docsv2-carousel__stage { padding-block: 36px; }
  .pricing-v2-page .pricing-v2-mobile-details dl > div:not(.pricing-v2-mobile-details__group) { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .pricing-v2-page .pricing-v2-mobile-details dd { text-align: left; }
  .news .news-frame { width: var(--shell-frame-width); }
}

@media (max-width: 359px) {
  .site-footer .footer-grid { grid-template-columns: minmax(0, 1fr); }
  .docsv2 .docsv2-carousel__controls { grid-template-columns: minmax(0, 1fr); }
  .docsv2 .docsv2-carousel__buttons { justify-self: start; }
  .docsv2 .docsv2-carousel__dots { grid-row: auto; }
}

/* Preserve reading space when a phone is rotated or a keyboard reduces height. */
@media (max-width: 1023px) and (max-height: 500px) {
  .home-v2 .home-v2-scene-nav,
  .docsv2 .docsv2-nav { position: static; }
}
/* Device crops use their own intrinsic proportions; desktop compositions are unchanged. */
@media (max-width: 1023px) {
  .home-v2 .home-v2-scene__media { aspect-ratio: auto; }
  .home-v2 .home-v2-scene__media picture,
  .home-v2 .home-v2-scene__media img { height: auto; }
  .demov2 .demo-feature-video__poster::before {
    background-image: image-set(url("../img/home/apqp-process-fmea-document-device-960.webp") 1x, url("../img/home/apqp-process-fmea-document-device-1600.webp") 2x);
  }
}
@media (max-width: 639px) {
  .demov2 .demo-feature-video__poster::before {
    background-image: image-set(url("../img/home/apqp-process-fmea-document-device-480.webp") 1x, url("../img/home/apqp-process-fmea-document-device-960.webp") 2x);
  }
}

/* A single row of training previews sits above the device heading. */
@media (max-width: 1023px) {
  .home-v2 .home-v2-training { min-height: 0; padding-block: 32px 56px; }
  .home-v2 .home-v2-training::before { display: none; }
  .home-v2 .home-v2-training__media {
    position: relative;
    inset: auto;
    height: clamp(112px, 30vw, 152px);
    margin-bottom: 24px;
    mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 16px), transparent);
  }
  .home-v2 .home-v2-training__media-track {
    opacity: 1;
    animation-play-state: paused;
  }
  .home-v2 .home-v2-training__media-track img { aspect-ratio: 3480 / 208; }
  .home-v2 .home-v2-training[data-training-motion="running"] .home-v2-training__media-track { animation-play-state: running; }
  .home-v2 .home-v2-training__layout { min-height: 0; grid-template-columns: minmax(0, 1fr); align-items: start; }
}
