/* R19: a shared reading rail, visible chapters, and connected diagram arrows. */
html[data-r18-system] {
  --r19-grid: minmax(0, .86fr) minmax(0, 1.14fr);
  --r19-gap: clamp(32px, 6vw, 88px);
  --r19-section-space: clamp(64px, 7vw, 112px);
  --r19-ground-a: radial-gradient(ellipse at 100% 18%, #87475288, transparent 65%), linear-gradient(120deg, #24182f, #42283f 68%, #523447);
  --r19-ground-b: radial-gradient(ellipse at 4% 95%, #61466b88, transparent 66%), linear-gradient(115deg, #171723, #30203b 58%, #42263b);
  --r19-ground-c: radial-gradient(ellipse at 100% 8%, #a4655b99, transparent 65%), linear-gradient(125deg, #3b223c, #65364c 76%, #82504d);
  --r10-field: radial-gradient(ellipse at 100% 5%, #a0645a 0, #63354c 28%, transparent 61%), linear-gradient(124deg, #21162c 10%, #462b47 63%, #6c4857 100%);
}
html[data-r18-system][data-theme="light"] {
  --r19-ground-a: radial-gradient(ellipse at 100% 18%, #eab28d88, transparent 65%), linear-gradient(120deg, #eee1f3, #f4e7ed 68%, #f7e8dc);
  --r19-ground-b: radial-gradient(ellipse at 4% 95%, #ceb9e888, transparent 66%), linear-gradient(115deg, #f9f2f7, #e7dbee 68%, #efe0ec);
  --r19-ground-c: radial-gradient(ellipse at 100% 8%, #e6b06b77, transparent 65%), linear-gradient(125deg, #f5e2dc, #f6e7d6 76%, #f7eddf);
  --r10-field: radial-gradient(ellipse at 100% 5%, #e9ba86 0, #f4dcbf 28%, transparent 65%), linear-gradient(125deg, #e3d5ec 4%, #f8edf2 55%, #fff5e6 100%);
}

/* Fine-grain belongs to the ambient field, and never intercepts a pointer. */
html[data-r18-system] body { background: var(--r10-field); }
html[data-r18-system] body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: url("assets/r11b-grain.png") repeat;
  opacity: .045;
}

/* Section introductions share the exact columns of their illustrations. */
[data-r18-system] :is(.r9-intro, .section-heading, .r8s-section-intro, .r17k-deployment-heading, .r10c-section-heading) {
  display: grid;
  grid-template-columns: var(--r19-grid) !important;
  align-items: start !important;
  column-gap: var(--r19-gap) !important;
  row-gap: 24px;
  width: 100%;
  max-width: none;
  margin-inline: 0;
  padding-inline: 0;
  box-sizing: border-box;
}
[data-r18-system] :is(.r9-intro, .section-heading, .r8s-section-intro, .r17k-deployment-heading, .r10c-section-heading) > :is(h2, p) {
  margin-top: 0 !important;
  margin-bottom: 0;
  min-width: 0;
  align-self: start;
}
[data-r18-system] :is(.r9-intro, .section-heading, .r8s-section-intro, .r17k-deployment-heading, .r10c-section-heading) > p {
  max-width: 54ch;
  font-family: Golos, GolosCurrency, Arial, sans-serif;
  font-size: clamp(17px, 1.2vw, 20px) !important;
  font-weight: 400;
  line-height: 1.55 !important;
  color: var(--r19-muted);
}
[data-r18-system] .r9-benefit-story > .r9-intro { width: 100%; }
[data-r18-system] .r9-benefit-story > :is(figure, .r17a-scene, .r17k-workspace) { margin-inline: 0; width: 100%; box-sizing: border-box; }

/* Full-width atmosphere changes, content stays on the original 1320px rail.
   Unlike a box-shadow bleed, this accepts a gradient and retains page grain. */
[data-r18-system] :is(#formats, #security, #delivery.r9-delivery, #requests, #benefits.r9-benefits, #benefits .r9-benefit-story, .r10c-bi-story, .r10c-cv-group) {
  position: relative;
  isolation: isolate;
  background: transparent !important;
  --r19-chapter: var(--r19-ground-a);
}
[data-r18-system] :is(#formats, #security, #delivery.r9-delivery, #requests, #benefits.r9-benefits, #benefits .r9-benefit-story, .r10c-bi-story, .r10c-cv-group)::after {
  content: "";
  position: absolute;
  inset-block: 0;
  left: 50%;
  right: auto;
  width: 100vw;
  z-index: -2;
  transform: translateX(-50%);
  background: var(--r19-chapter);
  box-shadow: none;
  clip-path: none;
  pointer-events: none;
}
[data-r18-system] :is(#formats, #security, #delivery.r9-delivery, #requests, #benefits.r9-benefits, #benefits .r9-benefit-story, .r10c-bi-story, .r10c-cv-group)::before {
  content: "";
  position: absolute;
  inset-block: 0;
  left: 50%;
  width: 100vw;
  max-width: none;
  z-index: -1;
  transform: translateX(-50%);
  background: url("assets/r11b-grain.png") repeat;
  opacity: .045;
  pointer-events: none;
}
[data-r18-system] #security { --r19-chapter: var(--r19-ground-a); padding-block: var(--r19-section-space); }
[data-r18-system] #delivery.r9-delivery {
  --r19-chapter: var(--r19-ground-b);
  padding-block: var(--r19-section-space);
  margin-top: 0 !important;
  border-top: 1px solid var(--r19-line);
}
[data-r18-system] #formats { --r19-chapter: var(--r19-ground-b); }
[data-r18-system] #requests { --r19-chapter: var(--r19-ground-c); }
[data-r18-system] #benefits .r9-benefit-story { --r19-chapter: var(--r19-ground-b); }
[data-r18-system] #benefits .r9-benefit-story:nth-of-type(2) { --r19-chapter: var(--r19-ground-c); }
[data-r18-system] #benefits .r9-benefit-story:nth-of-type(3) { --r19-chapter: var(--r19-ground-a); }

/* Each case family reads as a new story, with its own light and spacing. */
[data-r18-system] .r10c-bi-story {
  --r19-chapter: var(--r19-ground-b);
  padding-block: clamp(40px, 5vw, 72px);
  margin-block: 36px 0;
  gap: clamp(32px, 5vw, 72px);
  align-items: center;
}
[data-r18-system] .r10c-cv-group {
  --r19-chapter: var(--r19-ground-c);
  margin-top: 0;
  padding-block: clamp(56px, 6vw, 88px);
  border-top: 1px solid var(--r19-line);
}
[data-r18-system] .r10c-cv-stories { align-items: start; }
[data-r18-system] .r10c-fact {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  gap: clamp(20px, 2.5vw, 34px);
  padding: 24px 28px;
  margin-block: 24px 28px;
}
[data-r18-system] .r10c-fact strong {
  color: var(--r19-accent);
  font-size: clamp(68px, 6.5vw, 104px);
  font-weight: 400;
  line-height: .95;
  letter-spacing: -.055em;
  font-variant-numeric: tabular-nums;
}
[data-r18-system] .r10c-fact span { color: var(--r19-ink); font-size: 16px; line-height: 1.4; max-width: 21ch; }

/* C13 root cause: inbound class alone lost to '.crossing span::after'.
   Both ends now use selectors more specific than the shared span geometry. */
[data-r18-system] .r18-map-crossing {
  min-height: 68px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  overflow: visible;
}
[data-r18-system] .r18-map-crossing .r18-map-outbound::before { left: calc(var(--r18-ui-map-pad) + 15.5px); right: auto; }
[data-r18-system] .r18-map-crossing .r18-map-outbound::after { left: calc(var(--r18-ui-map-pad) + 12.5px); right: auto; }
[data-r18-system] .r18-map-crossing .r18-map-inbound::before { left: auto; right: calc(var(--r18-ui-map-pad) + 15.5px); }
[data-r18-system] .r18-map-crossing .r18-map-inbound::after { left: auto; right: calc(var(--r18-ui-map-pad) + 12.5px); }
[data-r18-system] .r18-map-crossing > span { font-size: 12px; line-height: 1.35; }
[data-r18-system] .r18-deployment > .r17k-mode { min-width: 0; }
[data-r18-system] .r18-deployment-map { min-width: 0; }
[data-r18-system] .r17k-mode-heading { min-height: 148px; }

/* Do not squeeze service content through the older nested-grid widths. */
[data-r18-system] :is(.r12s-team-work, .r12s-project, .r18-clarification, .r17k-workspace, .r17a-scene, .r18-pilot-report, .r12c-report) { max-width: 100%; box-sizing: border-box; }
[data-r18-system] :is(.r12s-team-work, .r12s-project, .r18-clarification, .r17k-workspace, .r17a-scene, .r18-pilot-report, .r12c-report) > * { min-width: 0; }

/* Keep staff chapter contrast and its intentional inverse colours, while
   replacing a flat full-bleed fill with the same softly lit atmosphere. */
[data-r18-system][data-staff-detail] .staff-chapter::before {
  inset-block: 0;
  inset-inline: auto;
  left: 50%;
  width: 100vw;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at 95% 5%, color-mix(in srgb, var(--staff-chapter) 70%, #bb82a0), transparent 69%), linear-gradient(120deg, var(--staff-chapter), color-mix(in srgb, var(--staff-chapter) 88%, #9e797d));
  box-shadow: none;
  clip-path: none;
  z-index: -2;
}
[data-r18-system][data-staff-detail] .staff-chapter::after {
  content: "";
  position: absolute;
  inset-block: 0;
  left: 50%;
  width: 100vw;
  transform: translateX(-50%);
  background: url("assets/r11b-grain.png") repeat;
  opacity: .045;
  z-index: -1;
  pointer-events: none;
}

/* Explicit geometry beats legacy R18 `inset:0`, even if styles are loaded out
   of order. The old reset put a 1440px shifted layer's right edge at x=780.
   Use paired viewport-relative edges, with no transform left to retain. */
html[data-r18-system] #benefits.r9-benefits,
html[data-r18-system] #benefits.r9-benefits .r9-benefit-story {
  background: transparent !important;
}
html[data-r18-system] #benefits.r9-benefits::before,
html[data-r18-system] #benefits.r9-benefits::after,
html[data-r18-system] #benefits.r9-benefits .r9-benefit-story::before,
html[data-r18-system] #benefits.r9-benefits .r9-benefit-story::after {
  position: absolute;
  inset: 0 calc(50% - 50vw);
  width: auto;
  height: auto;
  max-width: none;
  transform: none;
  box-shadow: none;
  clip-path: none;
  pointer-events: none;
}
html[data-r18-system] #benefits.r9-benefits::after,
html[data-r18-system] #benefits.r9-benefits .r9-benefit-story::after {
  content: "";
  z-index: -2;
  background: var(--r19-chapter);
}
html[data-r18-system] #benefits.r9-benefits::before,
html[data-r18-system] #benefits.r9-benefits .r9-benefit-story::before {
  content: "";
  z-index: -1;
  background: url("assets/r11b-grain.png") repeat;
  opacity: .045;
}

/* Separate the vision story along the complete width, including the left
   reading edge where the previous colour change was barely perceptible. */
html[data-r18-system] .r10c-cv-group {
  --r19-chapter: radial-gradient(ellipse at 100% 8%, #a4655b99, transparent 65%), linear-gradient(125deg, #4a2d48, #65364c 76%, #82504d);
}
html[data-r18-system][data-theme="light"] .r10c-cv-group {
  --r19-chapter: radial-gradient(ellipse at 100% 8%, #e6b06b77, transparent 65%), linear-gradient(125deg, #eed3ca, #f6e7d6 76%, #f7eddf);
}

/* Three parallel benefit stories share illustration, title and description
   tracks; the longest ticket determines the illustration row's real height. */
@media (min-width: 781px) {
  html[data-staff-detail] .staff-benefit-art { min-height: 380px; }
  @supports (grid-template-rows: subgrid) {
    html[data-staff-detail] .staff-benefits { grid-template-rows: auto auto auto; row-gap: 0; align-items: stretch; }
    html[data-staff-detail] .staff-benefit { display: grid; grid-row: span 3; grid-template-rows: subgrid; }
    html[data-staff-detail] .staff-benefit-art { min-height: 270px; height: 100%; }
  }
}
@media (max-width: 600px) {
  html[data-r18-system] .r13d-integration { grid-template-columns: minmax(0, 1fr); gap: 24px; padding: 24px; }
  html[data-r18-system] .r13d-integration .r13d-engine { width: 100%; box-sizing: border-box; }
  html[data-r18-system] .r13d-integration :is(.r13d-inputs, .r13d-outputs) > strong { font-size: 16px; }
  html[data-r18-system] .r13d-integration :is(.r13d-inputs > span, .r13d-outputs > span) { font-size: 13px; min-height: 0; }
}

/* Every benefit is its own chapter, including the first: its title must not
   sit against the previous chapter edge after the background is corrected. */
html[data-r18-system] #benefits.r9-benefits .r9-benefit-story {
  padding-block: 64px !important;
}
@media (max-width: 650px) {
  html[data-r18-system] #benefits.r9-benefits .r9-benefit-story {
    padding-block: 40px !important;
  }
}

@media (max-width: 900px) {
  [data-r18-system] :is(.r9-intro, .section-heading, .r8s-section-intro, .r17k-deployment-heading, .r10c-section-heading) {
    grid-template-columns: minmax(0, 1fr) !important;
    row-gap: 22px;
  }
  [data-r18-system] :is(.r9-intro, .section-heading, .r8s-section-intro, .r17k-deployment-heading, .r10c-section-heading) > p { max-width: 62ch; }
  [data-r18-system] .r10c-bi-story { grid-template-columns: minmax(0, 1fr); }
  [data-r18-system] .r17k-mode-heading { min-height: 0; }
}
@media (max-width: 650px) {
  html[data-r18-system] { --r19-section-space: 60px; --r19-gap: 24px; }
  [data-r18-system] :is(.r9-intro, .section-heading, .r8s-section-intro, .r17k-deployment-heading, .r10c-section-heading) > p { font-size: 17px !important; }
  [data-r18-system] .r10c-fact { padding: 20px; gap: 22px; }
  [data-r18-system] .r10c-fact strong { font-size: 72px; }
  [data-r18-system] .r10c-fact span { font-size: 15px; }
  [data-r18-system] .r10c-bi-story { gap: 32px; padding-block: 36px 48px; }
  [data-r18-system] .r10c-cv-group { padding-block: 48px; }
  [data-r18-system] .r10c-cv-stories { gap: 48px; }
  [data-r18-system] .r18-map-crossing > span { font-size: 12px; }
}
