/* Device tiers. Loaded last, so each size range is designed rather than squeezed.
   - Very narrow:  up to 359px  (Galaxy Fold cover, small flip phones)
   - Phones:       360 to 599px
   - Tablets:      600 to 1023px (Surface Duo, unfolded Fold, iPad, Galaxy Tab)
   - Small laptop: 1024 to 1279px (iPad landscape, sidebar returns)
   The sidebar only returns once the content beside it can have real width. */

/* ---------- Any card that holds a demo: the demo sizes itself to the card, not the screen ---------- */
.hp-why-tile__media {
  container-type: inline-size;
}

.hp-merge__card {
  min-width: clamp(118px, 46cqw, 168px);
  padding: clamp(7px, 2.6cqw, 11px) clamp(12px, 4.4cqw, 18px) clamp(7px, 2.6cqw, 11px) clamp(9px, 3cqw, 12px);
  font-size: clamp(13px, 4.6cqw, 17px);
  transform: translate(-50%, calc(-50% + (var(--i) - 2) * clamp(21px, 7.9cqw, 40px)));
}

.hp-merge__card::before {
  width: clamp(13px, 4.6cqw, 20px);
  height: clamp(13px, 4.6cqw, 20px);
}

.hp-merge {
  --merge-top: 41%;
}

.hp-merge .hp-merge__card {
  top: var(--merge-top);
}

.hp-merge__label {
  font-size: clamp(12px, 3.9cqw, 15px);
}

.hp-ask {
  padding-inline: clamp(18px, 7cqw, 40px);
}

.hp-ask__q {
  font-size: clamp(16px, 7cqw, 28px) !important;
}

.hp-track__panel {
  width: min(86%, 380px);
  padding: clamp(12px, 5cqw, 22px) clamp(14px, 5.4cqw, 24px);
}

.hp-track__row {
  grid-template-columns: clamp(58px, 25cqw, 96px) 1fr;
  margin-bottom: clamp(6px, 2.8cqw, 12px);
}

.hp-track__title {
  margin-bottom: clamp(8px, 3.6cqw, 16px) !important;
  font-size: clamp(13px, 3.9cqw, 15px);
}

/* ---------- Small laptops and iPad landscape: the sidebar is back, so give the content its room ---------- */
@media (min-width: 1024px) and (max-width: 1279px) {
  body.ed {
    --aside: clamp(210px, 20vw, 250px);
  }

  .ed-title {
    font-size: clamp(66px, 7.2vw, 92px);
  }

  .ed-h2 {
    font-size: 44px;
  }

  .hp-why-tile .ap-caption,
  .ap-caption {
    max-width: none;
    padding-inline: 4px;
  }

  .hw-card {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 22px;
    min-height: 420px;
    padding: 24px;
  }
}

/* ---------- Tablets, foldables and the Duo ---------- */
@media (min-width: 600px) and (max-width: 1023px) {
  body.ed {
    --gutter: clamp(24px, 4.4vw, 44px);
  }

  .ed-main {
    max-width: none;
  }

  /* Opening of every page */
  .ed-title {
    margin-bottom: 40px;
    font-size: clamp(72px, 11.4vw, 116px);
  }

  .ed-facts,
  .ed-section .ed-facts:has(> :nth-child(3)) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px clamp(20px, 3.4vw, 36px);
    max-width: none;
  }

  /* Two facts share the width evenly instead of leaving a third of the row empty. */
  .ed-section .ed-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px clamp(20px, 3.4vw, 36px);
    max-width: none;
  }

  .ed-overview {
    max-width: 44em;
    font-size: 17px;
  }

  /* Rhythm and type */
  .ed-section {
    padding-top: clamp(96px, 13vw, 132px);
  }

  .ed-section__head {
    max-width: none;
  }

  .ed-h2 {
    font-size: clamp(40px, 4.6vw, 44px);
  }

  .ed-text {
    max-width: 40em;
    font-size: 17px;
  }

  /* Grids that were one column on anything under 860px */
  .ed-quotes,
  .ed-art-grid--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ed-art-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ed-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ed-list li {
    grid-template-columns: 56px minmax(0, 0.85fr) minmax(0, 1.3fr);
  }

  .ed-list p {
    grid-column: auto;
  }

  .ed-rows li {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr) auto;
  }

  .ed-rows li > :nth-child(2) {
    grid-column: auto;
    grid-row: auto;
  }

  .ed-rows li > :nth-child(3) {
    grid-column: auto;
    grid-row: auto;
  }

  /* Why Vervestac */
  .hp-why-tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px clamp(14px, 2.4vw, 20px);
  }

  .hp-why-tile .ap-caption,
  .ap-caption {
    max-width: none;
    padding-inline: 4px;
  }

  /* Swipe rows become real grids: the width is there to show everything at once */
  .ap-gallery {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(12px, 2vw, 18px);
    margin-inline: 0;
    padding: 0;
    overflow: visible;
  }

  .ap-gallery > * {
    flex: none;
  }

  .ap-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .lv-steps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .cr-crafts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ed-section .cw__facts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  /* Services cards keep their side-by-side layout */
  .hw-card {
    top: calc(118px + var(--i) * 10px);
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
    gap: clamp(16px, 2.6vw, 26px);
    min-height: clamp(360px, 46vw, 460px);
    padding: clamp(20px, 3vw, 28px);
    border-radius: 24px;
  }

  .hw-card::before {
    background-size: 100% 600%;
  }

  .hw-card h3 {
    font-size: clamp(26px, 3.6vw, 34px);
  }

  .hw-card p:not([class]) {
    font-size: clamp(15px, 2vw, 17px);
  }

  .hw-card__n {
    font-size: clamp(54px, 8vw, 76px);
  }

  .hw-card__show {
    min-height: 0;
  }

  /* The opening band on Offerings */
  .ix {
    font-size: clamp(22px, 3vw, 28px);
    line-height: 2.1;
  }

  .ed-media--stage {
    padding: 56px clamp(18px, 3.4vw, 32px) 28px;
  }
}

/* A narrower tablet (Duo, first unfolded width): three across gets cramped, so two. */
@media (min-width: 600px) and (max-width: 719px) {
  .ed-title {
    font-size: clamp(66px, 12.6vw, 92px);
  }

  .ap-gallery,
  .lv-steps,
  .cr-crafts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ap-gallery > :last-child:nth-child(odd),
  .lv-steps > :last-child:nth-child(odd),
  .cr-crafts > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .ed-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hw-card {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }

  .hw-card__show {
    min-height: clamp(320px, 56vw, 400px);
  }

  .hw-card::before {
    background-size: 260% 600%;
  }
}

/* ---------- Large phones: the facts sit two across rather than leaving half the screen empty ---------- */
@media (min-width: 440px) and (max-width: 599px) {
  .ed-facts,
  .ed-section .ed-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 24px;
  }

  .hp-why-tile .ap-caption,
  .ap-caption {
    max-width: none;
  }
}

@media (min-width: 520px) and (max-width: 599px) {
  .ed-facts:has(> :nth-child(3)) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px 18px;
  }
}

@media (max-width: 599px) {
  .hp-why-tile .ap-caption,
  .ap-caption {
    max-width: none;
    padding-inline: 4px;
  }
}

/* ---------- Very narrow: folded phones ---------- */
@media (max-width: 359px) {
  body.ed {
    --gutter: 14px;
  }

  .ed-title {
    margin-bottom: 26px;
    font-size: clamp(40px, 15.5vw, 54px);
  }

  .ed-h2 {
    font-size: clamp(30px, 10.6vw, 38px);
  }

  .ed-text,
  .ed-overview {
    font-size: 16px;
  }

  .hw-card {
    padding: 16px;
    border-radius: 18px;
  }

  .hw-card h3 {
    font-size: 24px;
  }

  .hw-card__show {
    min-height: 250px;
  }

  .ed-stats {
    gap: 22px 12px;
  }

  .ed-toc {
    gap: 14px;
  }

  .ed-toc a {
    font-size: 18px;
  }

  .floating-discovery {
    font-size: 12px !important;
  }

  .floating-discovery__button {
    min-width: 72px;
    padding: 0 12px;
  }

  .ed-list li {
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 6px 12px;
  }

  /* Illustrations shrink to the column instead of pushing past it. */
  .ed-visual,
  .ed-visual > * {
    min-width: 0;
    max-width: 100%;
  }

  .svc-brand__top {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .svc-brand__type {
    min-width: 0;
    overflow: hidden;
  }
}

/* Mid-size screens have no room for the nav button's full label, so it says one word. */
@media (min-width: 761px) and (max-width: 1240px) {
  body.ed .site-header .header-cta {
    width: auto;
    min-width: 0;
    padding: 0 20px;
  }

  body.ed .site-header .header-cta::after {
    content: "Book";
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.02em;
  }
}

/* ---------- Phones: facts never leave half the screen empty ---------- */
@media (max-width: 599px) {
  .ed-facts,
  .ed-section .ed-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 18px;
  }

  /* Three facts: the first stands beside the other two, so both columns stay full. */
  .ed-facts > div:first-child:nth-last-child(3) {
    grid-row: span 2;
  }

  /* Three short facts simply sit in a row. */
  .ed-section .ed-facts.ed-facts--row,
  .ed-facts.ed-facts--row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px 14px;
  }

  .ed-facts--row > div:first-child:nth-last-child(3) {
    grid-row: auto;
  }

  .ed-section .rh-facts.ed-facts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px 14px;
  }

  .rh-facts.ed-facts > div:first-child:nth-last-child(3) {
    grid-row: auto;
  }
}

/* Section headings only ever grow with the screen. */
@media (min-width: 1280px) {
  .ed-h2 {
    font-size: clamp(44px, 3.3vw, 58px);
  }
}

/* ---------- Audit: nothing left alone on a row, and links big enough for a thumb ---------- */
@media (min-width: 600px) and (max-width: 1023px) {
  /* A last fact with no neighbours takes the whole row. */
  .ed-section .ed-facts > div:nth-child(3n + 4):last-child {
    grid-column: 1 / -1;
  }

  .ed-tags--even {
    display: grid;
    grid-template-columns: repeat(3, max-content);
    justify-content: start;
    justify-items: start;
  }
}

@media (max-width: 599px) {
  .ed-tags--even {
    display: grid;
    grid-template-columns: repeat(2, max-content);
    justify-content: start;
    justify-items: start;
  }

  .ed .ed-link {
    padding-block: 9px;
    margin-block: -9px;
  }

  .ed-facts dd .ed-facts__link {
    margin-top: 3px;
    margin-bottom: -9px;
  }

  .ed-foot__inner a,
  .pg .ed-rows li > a:not(.ed-btn):not(.ed-link) {
    padding-block: 6px;
    margin-block: -6px;
  }
}

@media (max-width: 359px) {
  .ed-tags--even li {
    font-size: 12px;
  }
}

/* Side by side, the card keeps its desktop layout at every width: number at the top, words at the bottom. */
@media (min-width: 720px) and (max-width: 1023px) {
  .hw-deck .hw-card h3,
  .pg-deck .pg-card h2 {
    margin-top: auto;
  }
}

/* Between 761 and 1240px the booking button says just "Book", so the open menu fits the space beside it
   instead of the space the full-length button would leave. */
@media (min-width: 761px) and (max-width: 1240px) {
  body.ed .navigation.is-open {
    width: min(780px, calc(100vw - 248px));
  }
}

/* On narrow tablets the open menu keeps only its close icon and tightens the links, so all six fit. */
@media (min-width: 761px) and (max-width: 900px) {
  body.ed .navigation.is-open .navigation__toggle {
    flex-basis: 46px;
    gap: 0;
    padding: 0;
  }

  body.ed .navigation.is-open .navigation__toggle > span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  body.ed .navigation__links {
    gap: 2px;
  }

  body.ed .navigation__links a {
    padding: 0 10px;
  }
}

/* From 1241px the full "Book free discovery call" button is back, so the open menu leaves room for it. */
@media (min-width: 1241px) {
  body.ed .navigation.is-open {
    width: min(740px, calc(100vw - 550px));
  }
}
