/* Phone and small-tablet layout fixes, shared by every page.
   Loaded from each page's <head>. Selectors are prefixed with "html body" so they win over the
   per-page rules, and several match inline styles as the browser serialises them (e.g. "0px auto"). */

@media (max-width: 1060px) {
  /* Two-column heroes carry a large left indent on desktop; drop it once the columns stack. */
  html body [data-sh="section"] > [style*="max-width: 1200px"] { padding-left: 32px !important; }
  html body [data-sh="grid2"], html body [data-sh="nphero"] { grid-template-columns: minmax(0, 1fr) !important; }
  html body [data-sh="hero"] > *, html body [data-sh="grid2"] > *, html body [data-sh="split"] > *,
  html body [data-sh="grid3"] > *, html body [data-sh="grid4"] > *, html body [data-sh="bento"] > *,
  html body [data-sh="nphero"] > *, html body [data-sh="howgrid"] > * { min-width: 0 !important; }
}

@media (max-width: 720px) {
  /* The section supplies the 20px gutter; inner wrappers must not add their own. */
  html body [data-sh="section"] > [style*="max-width: 1200px"],
  html body [data-sh="section"] > [style*="max-width: 1120px"],
  html body [data-sh="section"] > [style*="max-width: 960px"],
  html body [data-sh="section"] > [style*="max-width: 880px"],
  html body [data-sh="section"] > [style*="max-width: 760px"] { padding-left: 0 !important; padding-right: 0 !important; }
  html body [data-sh="section"][style*="max-width"], html body [data-sh="hero"] { padding-left: 20px !important; padding-right: 20px !important; }

  /* Every multi-column grid becomes a single column that is allowed to shrink. */
  html body [data-sh="hero"], html body [data-sh="split"], html body [data-sh="grid2"], html body [data-sh="grid3"],
  html body [data-sh="grid4"], html body [data-sh="stats"], html body [data-sh="steps"], html body [data-sh="pillars"],
  html body [data-sh="themes"], html body [data-sh="footgrid"], html body [data-sh="howgrid"], html body [data-sh="calc"],
  html body [data-sh="nphero"], html body [data-sh="bento"], html body [data-sh="formgrid"],
  html body [data-sh="checklist"], html body [data-sh="flow"] { grid-template-columns: minmax(0, 1fr) !important; }
  html body [data-sh="bento"] > * { grid-column: auto !important; grid-row: auto !important; }
  html body [data-sh="split"], html body [data-sh="grid2"], html body [data-sh="hero"], html body [data-sh="nphero"] { gap: 40px !important; }

  /* Tighter vertical rhythm and card padding. */
  html body [style*="padding: 112px 32px"] { padding-top: 72px !important; padding-bottom: 72px !important; }
  html body [style*="padding: 152px 32px 80px"] { padding-top: 132px !important; padding-bottom: 56px !important; }
  html body [style*="padding: 168px 32px 96px"] { padding-top: 136px !important; padding-bottom: 64px !important; }
  html body [style^="padding: 40px"], html body [style*="; padding: 40px"],
  html body [style^="padding: 36px"], html body [style*="; padding: 36px"] { padding: 24px !important; }

  /* Buttons may wrap instead of pushing the page wider. */
  html body a[style*="white-space: nowrap"][style*="padding: 14px 26px"],
  html body a[style*="white-space: nowrap"][style*="padding: 15px 30px"] { white-space: normal !important; text-align: center; }

  /* Floating cards that hang outside their frame on desktop stay inside it on phones. */
  html body [style*="position: absolute"][style*="left: -"] { left: 0 !important; }
  html body [style*="position: absolute"][style*="right: -"] { right: 0 !important; }
  html body [data-sh="desklabel"] { left: 8px !important; bottom: 12px !important; max-width: calc(100% - 16px); white-space: normal !important; }
  html body [data-sh="heroreport"] > [style*="white-space: nowrap"] { left: 8% !important; }
  html body [style*="margin-right: 48px"] { margin-right: 0 !important; }
  html body [style*="margin-left: 48px"] { margin-left: 0 !important; }

  html body [data-sh="floatlabel"] { transform: none !important; right: 8px !important; max-width: calc(100% - 16px); white-space: normal !important; }
  html body [data-sh="storycard"] { flex-wrap: wrap !important; }
  html body [data-sh="storycard"] > span:nth-child(2) { flex: 1 1 calc(100% - 70px) !important; }
  html body [data-sh="storycard"] > span:nth-child(3) { margin-left: 66px; }

  /* Logo strip: four across instead of seven. */
  html body [style*="repeat(7, minmax(0px, 1fr))"] { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; gap: 20px 16px !important; }

  /* Header pill: keep logo, button and menu icon inside it. */
  html body header > nav[data-sh="section"] { padding-left: 16px !important; padding-right: 8px !important; gap: 10px !important; }
  html body header > nav a[style*="padding: 11px 20px"] { padding: 10px 14px !important; font-size: 13px !important; }

  /* Homepage hero. */
  html body [data-sh="hero"] { padding-top: 132px !important; padding-bottom: 150px !important; }
  html body [data-sh="herobleed"] { width: 560px; zoom: 0.78; }
  html body [data-sh="herobleed"] .sh-report { width: 190px !important; right: -6px !important; bottom: -110px !important; }
}
@media (max-width: 480px) { html body [data-sh="herobleed"] { zoom: 0.66; } }
@media (max-width: 410px) { html body [data-sh="herobleed"] { zoom: 0.59; } }
@media (max-width: 370px) { html body [data-sh="herobleed"] { zoom: 0.5; } }
@media (max-width: 360px) {
  html body header { padding-left: 10px !important; padding-right: 10px !important; }
  html body header > nav[data-sh="section"] { padding-left: 12px !important; padding-right: 6px !important; gap: 6px !important; }
  html body header > nav > a > img { height: 22px !important; }
  html body header > nav a[style*="padding: 11px 20px"] { padding: 9px 11px !important; font-size: 12px !important; }
  html body header > nav [data-sh="menubtn"] { width: 34px !important; height: 34px !important; }
  html body [data-sh="heroreport"] > [style*="white-space: nowrap"] { left: 0 !important; font-size: 10.5px !important; padding: 7px 10px !important; }
}

/* Sample impact report: a tap opens it straight away (no hover-zoom first), and the viewer fits a phone. */
html body .sh-report, html body [data-sh="heroreport"] { cursor: pointer !important; -webkit-tap-highlight-color: transparent; }
@media (hover: none) {
  html body .sh-report:hover { transform: none !important; }
}
@media (max-width: 720px) {
  html body [style*="cursor: zoom-out"] { padding: 64px 8px 48px !important; gap: 0 !important; }
  html body [style*="cursor: zoom-out"] > img { max-width: 100% !important; max-height: calc(100vh - 128px) !important; min-width: 0 !important; height: auto !important; }
  html body [style*="cursor: zoom-out"] > button[aria-label="Previous"],
  html body [style*="cursor: zoom-out"] > button[aria-label="Next"] { position: absolute !important; top: 50% !important; margin-top: -20px !important; width: 40px !important; height: 40px !important; z-index: 2; background: rgba(4,8,42,0.72) !important; }
  html body [style*="cursor: zoom-out"] > button[aria-label="Previous"] { left: 8px !important; }
  html body [style*="cursor: zoom-out"] > button[aria-label="Next"] { right: 8px !important; }
}
