/* Inner pages on phones (finishing pass, 27/10). Loaded after site.css.
   Scope: capabilities, work, the seven case studies, real estate, about, careers, contact, privacy, 404.
   Every rule sits under max-width 640 px (or 480 px) and under body:not(.page-home), so the desktop and the home
   page do not move. No change of structure or wording: layout only. */

@media (max-width: 640px) {

  /* 1. Spacing of the inner page heads. The type scale itself (h1, h2, lead, sections) is the common one of
        site.css section 25; this file does not redefine it. */
  body:not(.page-home) .hero-split .lead, body:not(.page-home) .page-head .lead { margin-top: 18px; }
  body:not(.page-home) .hero-split .btn-row { margin-top: 28px; }
  body:not(.page-home) .hero-split .wrap { gap: 32px; }
  body:not(.page-home) .hero-split { padding-block: 40px 56px; }
  body:not(.page-home) .page-head { padding-block: 40px 32px; }
  body:not(.page-home) .head-split { margin-bottom: 32px; gap: 14px; }

  /* 2. "Related work", "Related capabilities", "Nuxeo work", "Before the call", "Or go to": one pattern.
        Grey label on top, then one link per line; the arrow follows the last word and never sits alone. */
  body:not(.page-home) .related { flex-direction: column; align-items: flex-start; gap: 0; margin-top: 32px; }
  body:not(.page-home) .related > span { margin-bottom: 2px; }
  body:not(.page-home) .related > .link-arrow { display: block; min-height: 44px; padding-block: 10px; line-height: 1.4; text-wrap: pretty; }
  body:not(.page-home) .related > .link-arrow::after { display: inline-block; margin-left: 6px; vertical-align: 0; }

  /* 3. In-page pills (capabilities, privacy) and work filters: one row that scrolls under the finger,
        bleeding to the screen edges, instead of three to five wrapped lines. */
  body:not(.page-home) .jump,
  body:not(.page-home) .filters {
    flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
    margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); scroll-padding-inline: var(--gutter);
    scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
    padding-block: 6px; margin-block: -6px; /* room for the focus ring, which overflow would clip */
  }
  body:not(.page-home) .jump::-webkit-scrollbar, body:not(.page-home) .filters::-webkit-scrollbar { display: none; }
  body:not(.page-home) .jump > a, body:not(.page-home) .filters > .filter { flex: none; white-space: nowrap; scroll-snap-align: start; }
  body:not(.page-home) .page-head .filters, body:not(.page-home) .page-head .jump { margin-top: 28px; }
  .page-capabilities nav > .jump { padding-bottom: 2px; }
  .page-privacy .legal { gap: 32px; }
  .page-privacy .legal .jump { flex-direction: row; align-items: center; }

  /* 4. Facts in two columns had cells of very different heights: see the 480 px block below. */

  /* 5. Case study head: the client logo and the partner logo on one line, the credit under them, full width */
  .page-case .case-id { gap: 12px 20px; margin-top: 28px; }
  .page-case .case-id img { height: 36px; max-width: 128px; }
  .page-case .case-id i { height: 32px; }
  .page-case .case-id small { flex: 1 0 100%; max-width: none; font-size: 14px; }
  .page-case .case-figure .stat-v { font-size: 64px; }

  /* 6. Contact: cards as tall as their content, the button 24 px under the text */
  .page-contact .contact-card { min-height: 0; padding: 28px 24px; }
  .page-contact .contact-card .card-foot { padding-top: 24px; }
  .page-contact .contact-card .big { margin-top: 16px; }

  /* 7. Work: case photos fill their 4:3 frame (the img did not stretch to the grid cell, leaving grey bands) */
  .page-work .tile .tile-media.photo { position: relative; }
  .page-work .tile .tile-media.photo img { position: absolute; inset: 0; width: 100%; height: 100%; }
  /* Logo wall: every logo on the same line and every name starting at the same height in a row */
  .page-work .logo-wall .logo-cell { grid-template-rows: 64px 1fr; align-items: start; gap: 14px; }
  .page-work .logo-wall .logo-cell img { align-self: center; justify-self: center; max-height: 56px; }

  /* 8. Real estate: client logos on a lower grey band (4:3 was a large empty box for a small logo) */
  .page-real-estate .tile .tile-media.logo { aspect-ratio: 2 / 1; }
  .page-real-estate .tile .tile-media.logo img { max-width: 44%; max-height: 52%; }
  .page-real-estate .tile h3 { margin-top: 20px; }
  .page-real-estate .grid-3 { row-gap: 40px; }

  /* 9. Pills: a visible pressed state and the current section after a tap on the summary */
  body:not(.page-home) .jump a:active, body:not(.page-home) .filter:active { background: var(--card); }
  body:not(.page-home) .jump a, body:not(.page-home) .filter { -webkit-tap-highlight-color: transparent; }
}

/* The summary pill of the section in the address bar (#ai, #ecm...), at every width */
.page-capabilities:has(#ai:target) .jump a[href="#ai"],
.page-capabilities:has(#ecm:target) .jump a[href="#ecm"],
.page-capabilities:has(#platforms:target) .jump a[href="#platforms"],
.page-capabilities:has(#data:target) .jump a[href="#data"],
.page-capabilities:has(#hosting:target) .jump a[href="#hosting"],
.page-privacy:has(#who:target) .jump a[href="#who"],
.page-privacy:has(#data:target) .jump a[href="#data"],
.page-privacy:has(#use:target) .jump a[href="#use"],
.page-privacy:has(#receives:target) .jump a[href="#receives"],
.page-privacy:has(#retention:target) .jump a[href="#retention"],
.page-privacy:has(#rights:target) .jump a[href="#rights"],
.page-privacy:has(#security:target) .jump a[href="#security"],
.page-privacy:has(#changes:target) .jump a[href="#changes"] { border-color: var(--ink); }

/* 4. Facts (case studies, about) under 480 px: one column, label on the left, value on the right, one hairline
      per row, so no row is three times taller than its neighbour. */
@media (max-width: 480px) {
  body:not(.page-home) .facts { grid-template-columns: 1fr; }
  body:not(.page-home) .facts > div,
  body:not(.page-home) .facts > div + div,
  body:not(.page-home) .facts > div:nth-child(3) {
    display: grid; grid-template-columns: 6.5em 1fr; gap: 12px; align-items: baseline;
    padding: 14px 0; border-left: 0;
  }
  body:not(.page-home) .facts > div + div { border-top: 1px solid var(--line); }
  body:not(.page-home) .facts dd { margin: 0; }
}

@media (max-width: 640px) {
  /* Case studies: a list of points ends on a hairline and the next part starts with one: keep only the second */
  .page-case .case-part .points > li:last-child { border-bottom: 0; }
}

/* Very narrow phones (320 to 400 px) */
@media (max-width: 400px) {
  /* Two buttons side by side, same width, instead of two pills of different widths stacked off-centre */
  body:not(.page-home) :is(.hero-split, .cta) .btn-row { flex-wrap: nowrap; gap: 10px; }
  body:not(.page-home) :is(.hero-split, .cta) .btn-row > .btn { flex: 1 1 0; min-width: 0; padding-inline: 12px; }
  /* Where we work (about, careers): the four places in one column, the HQ address no longer squeezed to 130 px */
  body:not(.page-home) .loc-grid { grid-template-columns: 1fr; }
  body:not(.page-home) .loc-grid > li { padding: 16px; }
}

/* Anchors on phones (#ai, #ecm..., #public-sector..., #who...): the title lands about 20 px under the sticky
   header. html scroll-padding-top (site.css) and [id] scroll-margin-top (site.css) add up to twice the header;
   on inner pages only the scroll-margin counts, and a padded section subtracts its own top padding. */
@media (max-width: 640px) {
  html:has(> body:not(.page-home)) { scroll-padding-top: 0; }
  body:not(.page-home) section.section[id] { scroll-margin-top: calc(var(--hdr) + 20px - var(--section)); }
  body:not(.page-home) .section:not(.section-black):not(.section-grey) + section.section[id]:not(.section-black):not(.section-grey) { scroll-margin-top: calc(var(--hdr) + 20px); }
  body:not(.page-home) .legal section[id], body:not(.page-home) .filters [id] { scroll-margin-top: calc(var(--hdr) + 20px); }
}
