/* Load after component and scene styles. Viewport-fit=cover enables device insets. */
:root {
  --device-gutter: 56px;
  --device-side-inset: max(var(--device-gutter), env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(108px + env(safe-area-inset-top, 0px));
}

.wrap { width: calc(100% - 2 * var(--device-side-inset)); }
.site-header { padding-top: env(safe-area-inset-top, 0px); }
.site-footer { padding-bottom: max(28px, env(safe-area-inset-bottom, 0px)); }

/* Footer hierarchy is independent of the compact navigation typography. */
.site-footer .footer-grid { grid-template-columns: minmax(0,1fr) minmax(0,1.1fr) minmax(0,1.15fr); gap: 40px; }
.site-footer .footer-brand { width: 188px; max-width: 100%; margin: 0 0 20px; }
.site-footer .footer-brand img { width: 100%; height: auto; }
.site-footer .footer-grid p { font-size: 14px; line-height: 1.65; color: #b4c1d0; }
.site-footer .eyebrow { font-size: 11px; line-height: 1.5; letter-spacing: .12em; color: #a9b6c8; margin-bottom: 16px; }
.site-footer .footer-links { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 4px 20px; }
.site-footer .footer-links a, .site-footer .footer-grid>div:last-child>a { display: flex; align-items: center; min-height: 44px; font-size: 14px; line-height: 1.5; margin-top: 0; overflow-wrap: anywhere; }
.site-footer .footer-bottom { font-size: 12px; line-height: 1.6; color: #a9b6c8; gap: 16px 28px; align-items: center; }
.site-footer .footer-bottom a { font-size: 13px; flex-shrink: 0; }
@media(max-width:980px) {
  .site-footer .footer-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 32px; }
  .site-footer .footer-grid>div:last-child { grid-column: 1/-1; }
}
@media(max-width:650px) {
  .site-footer { padding-top: 36px; }
  .site-footer .footer-grid { grid-template-columns: minmax(0,1fr); gap: 28px; padding-bottom: 28px; }
  .site-footer .footer-grid>div:last-child { grid-column: auto; }
  .site-footer .footer-grid>div+div { padding-top: 24px; border-top: 1px solid var(--line); }
  .site-footer .footer-brand { width: 170px; margin-bottom: 12px; }
  .site-footer .footer-grid p { margin: 10px 0; }
  .site-footer .footer-bottom { display: grid; grid-template-columns: minmax(0,1fr) auto; padding-block: 20px 0; }
  .site-footer .footer-bottom span:nth-child(2) { order: 3; grid-column: 1/-1; }
  .site-footer .footer-bottom a { margin-left: 0; }
}

/* Reused dark-section copy must not override the light leadership section. */
.paper.leadership-teaser p:not(.person-role) { color: #465360; }
.paper.leadership-teaser p.lead { color: var(--ink); }
.paper.leadership-teaser p.person-role { color: #9b3618; }
.paper.leadership-teaser p.fineprint { color: #5b6672; }

/* Service equipment cards remain dark when their containing section is paper. */
.paper .service-options,
.paper .service-detail { color: var(--white); }
.paper .service-detail p { color: #bdc8d5; }
.paper .service-detail .eyebrow,
.paper .service-detail .detail-disclosure[open] summary { color: #ffad7d; }
.paper .service-detail .detail-disclosure { border-color: #ffffff35; }
.paper .service-detail .source-link { color: var(--white); }

/* Real hit areas, rather than invisible pseudo-elements overlapping neighbors. */
button,
.button,
.text-link,
.header-cta,
.desktop-nav a,
#mobile-nav a,
.footer-links a,
.footer-bottom a,
.breadcrumb a,
.contact-panel > a,
.commissioning-strip > a,
.related-nodes a,
.hf-card > a,
.pw-model-grid a,
.pw-advanced > a,
.workspace__list a {
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
}

.text-link,
.source-link,
.desktop-nav a,
.footer-bottom a,
.breadcrumb a,
.contact-panel > a,
.commissioning-strip > a,
.related-nodes a,
.hf-card > a,
.pw-model-grid a,
.pw-advanced > a,
.workspace__list a {
  display: inline-flex;
  align-items: center;
}

.source-link { text-align: left; }
.technical-node .source-tags button,
.related-nodes a { font-size: 12px; }
.desktop-nav a::after { bottom: 0; }
.footer-links a { display: flex; align-items: center; }
.menu-toggle { width: 44px; height: 44px; flex: 0 0 44px; }
.hero-bottom > a { display: grid; place-items: center; width: 44px; min-height: 44px; flex: 0 0 44px; }
.dialog-close { width: 44px; height: 44px; padding: 6px; }

summary {
  min-height: 44px;
  padding-block: 9px;
  touch-action: manipulation;
}

summary:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 4px;
}

.workspace summary { min-height: 44px; }
.pressure-lab__auto,
.pressure-lab__segmented span,
.check-grid label,
.workspace__notice { min-height: 44px; }
.check-grid label { align-items: center; }
.check-grid input { flex: 0 0 20px; width: 20px; height: 20px; margin: 0; }
.pressure-lab__slider,
.pwave input[type="range"],
.pw-snapshot input { min-height: 44px; height: 44px; }

/* Grid children and long references can shrink without clipping the document. */
.header-inner,
.map-toolbar > *,
.map-reading > *,
.semantic-path > li,
.service-options > *,
.service-detail > *,
.brief-layout > *,
.field-grid > *,
.workspace__grid > *,
.footer-grid > * { min-width: 0; }

:is(.concept-panel, .source-entry, .reference-item, .technical-node, .service-detail, .workspace, .hf-card) :is(h2, h3, h4, p, code),
.map-connections button,
.service-option strong,
.semantic-path button strong { overflow-wrap: anywhere; }

.map-toolbar select,
.hf-controls input,
.hf-controls select { max-width: 100%; }
.source-tags > * { max-width: 100%; }
.concept-panel .button,
.service-detail .button,
.brief-result .button { max-width: 100%; }
.map-connections button { white-space: normal; }
.semantic-path li { grid-template-rows: minmax(47px, auto) 1fr; }
.semantic-path button { grid-template-rows: minmax(26px, auto) 1fr; gap: 8px; }

/* The scene retains one uncropped coordinate system at every size. */
.pressure-scene { min-width: 0; }
.scene-image { width: 100%; height: 100%; object-fit: contain; }
.scene-hotspot,
.scene-zone-key,
.scene-zone-key button { min-width: 44px; min-height: 44px; touch-action: manipulation; }
.scene-hotspot:focus-visible,
.scene-zone-key:focus-visible,
.scene-zone-key button:focus-visible {
  outline: 3px solid var(--white);
  outline-offset: 4px;
  box-shadow: 0 0 0 7px #061320;
}
.scene-hotspot:focus-visible { z-index: 5; }
.scene-zone-key { overflow-wrap: anywhere; }

#source-dialog {
  max-width: calc(100% - 2 * max(16px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px)));
  max-height: calc(100vh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-top: 60px;
}

@media (max-width: 1200px) {
  :root { --device-gutter: 36px; }
}

@media (max-width: 980px) {
  html { scroll-padding-top: calc(96px + env(safe-area-inset-top, 0px)); }
  #mobile-nav {
    max-height: calc(100vh - 80px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    max-height: calc(100dvh - 80px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding-inline: var(--device-side-inset);
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
  }
  #mobile-nav a { display: flex; align-items: center; line-height: 1.4; }
  .hero { height: auto; min-height: 660px; padding-bottom: 112px; }
  .header-cta { flex-shrink: 0; }
  .map-toolbar > label { min-width: 0; }
  .timeline-controls .buttons { flex-wrap: wrap; }
}

/* Coarse pointers cover touch tablets even when their viewport is desktop width. */
@media (any-pointer: coarse), (max-width: 980px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select,
  textarea,
  .pwave :is(input, select, textarea),
  .workspace :is(input, select, textarea),
  .hf-controls :is(input, select),
  .map-toolbar select { font-size: 16px; }
  .pwave .pw-json { font-size: 16px !important; }
  .button:hover { transform: none; }
}

@media (hover: none) {
  .source-hover { display: none !important; }
}

@media (max-width: 700px) {
  :root { --device-gutter: 20px; }
  .hero h1 { font-size: clamp(44px, 11.5vw, 78px); overflow-wrap: anywhere; }
  .page-masthead h1 { font-size: clamp(38px, 8.7vw, 58px); overflow-wrap: anywhere; }
  .section-title { font-size: clamp(34px, 7.5vw, 44px); overflow-wrap: anywhere; }
  .page-masthead .lead { overflow-wrap: anywhere; }
  .hero-bottom { align-items: center; }
  .hero-topline { flex-wrap: wrap; }
  .semantic-path li { grid-template-rows: minmax(44px, auto) 1fr; }
  .lens-group button { flex: 1 1 120px; }
  .concept-panel { padding: 22px; }
  .concept-panel .actions { width: 100%; }
  .concept-panel .button { gap: 18px; }
  .service-detail { padding: 22px; }
  .service-option strong { font-size: clamp(22px, 5.8vw, 25px); }
  .detail-disclosure summary { line-height: 1.5; }
  .wholewell-tabs button { font-size: 12px; }
  .timeline-controls { gap: 12px; }
  .timeline-controls .buttons { width: 100%; }
  .timeline-controls #timeline-play { flex: 1; justify-content: center; padding-inline: 12px; }
  .timeline-track { scroll-padding-inline: 6px; }
  .timeline-stop { scroll-margin-inline: 6px; }
  .hf-controls > label { min-width: 0; flex-basis: 100%; }
  .hf-card { padding: 20px; }
  .hf-card a { margin-right: 12px; }
  .pw-chart { overflow-x: auto; overscroll-behavior-x: contain; padding-bottom: 4px; }
  .pw-chart svg { min-width: 640px; }
  .pw-metrics > div { padding: 14px 12px; }
  .pw-metrics dd { overflow-wrap: anywhere; }
  .pw-header { flex-wrap: wrap; }
  .pw-equation { font-size: 20px; overflow-wrap: anywhere; }
  .pw-body { padding: 18px; }
  .workspace__badge { max-width: 100%; overflow-wrap: anywhere; }
  .workspace__row { align-items: flex-start; }
  .footer-bottom { align-items: center; }
}

@media (max-width: 420px) {
  .field-grid,
  .pw-fields { grid-template-columns: 1fr; }
  .pw-snapshot input { flex-basis: 100%; min-width: 0; }
  .pw-tabs button { font-size: 11px; padding: 13px 8px; }
  .service-detail .button { gap: 16px; padding-inline: 16px; }
}

@media (max-width: 380px) {
  :root { --device-gutter: 16px; }
  .header-cta { display: none; }
  .menu-toggle { margin-left: auto; }
  .header-inner { gap: 16px; }
  .semantic-path,
  .semantic-path:has(li:nth-child(8)) { grid-template-columns: 1fr; }
  .semantic-path li { grid-template-rows: auto 1fr; }
  .semantic-path button { min-height: 88px; }
  .path-relation { padding-top: 10px; }
  .hero-bottom { flex-wrap: wrap; }
  .hero-bottom > span:first-child { flex: 1 1 calc(100% - 54px); }
  .hero-bottom > span:nth-child(2) { margin-left: 0; text-align: left; max-width: none; }
  .hero-bottom > a { margin-left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .button:hover { transform: none; }
  .scene-flow { animation: none !important; }
}

@media print {
  .wrap { width: 100%; }
  .pw-chart { overflow: visible; }
  .pw-chart svg { min-width: 0; }
  .scene-hotspot,
  .scene-zone-key { display: none; }
}
