/*
 * Product stage — the scroll-driven 3D section on oil & gas product pages.
 *
 * Every rule is scoped under .am-stage. These pages carry the legacy site
 * stylesheet, which styles bare elements (canvas, figure, ul, h3) globally;
 * unscoped rules here would fight it, and its rules would leak in here.
 */

/*
 * The legacy stylesheet puts `overflow: hidden` on <body>. That makes body a
 * scroll container of its own, and `position: sticky` inside it then sticks to
 * a box that never scrolls - so the 3D canvas scrolled away with the page and
 * every step after the first showed nothing. `clip` hides sideways overflow
 * exactly as before WITHOUT creating a scroll container. Scoped to pages that
 * carry a stage, so no other page changes.
 */
body:has(.am-stage) {
  overflow-x: clip !important;
  overflow-y: visible !important;
}

.am-stage {
  /* Set from JS: the fixed header's real height, and the full-bleed geometry. */
  --am-top: 117px;
  --stage-bg: #121416;
  --stage-ink: #eceef0;
  --stage-mute: #a3aab1;
  --stage-line: #2a2f34;
  --brand: #e00910;

  position: relative;
  /* Break out of the site's centred container to the full viewport width,
     the way the site's own hero videos do. 100vw includes the scrollbar, so
     it is subtracted - otherwise the stage overhangs and its right edge is
     clipped off. */
  /* Measured in JS, not derived from 100vw: whether vw includes the
     scrollbar differs between browsers (and changes when the root has
     overflow-y: scroll), so any vw formula is wrong somewhere. */
  width: var(--am-w, 100%);
  margin-left: var(--am-ml, 0px);
  background: radial-gradient(120% 80% at 70% 30%, #1d2124 0%, var(--stage-bg) 60%);
  color: var(--stage-ink);
  display: grid;
  grid-template-columns: minmax(300px, 38%) 1fr;
  margin-top: 1.5rem;
  margin-bottom: 3rem;
}

.am-stage__canvas {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  /* Pinned directly below the fixed header, measured rather than guessed:
     at a guessed 90 px the canvas slid under a 117 px header and the top of
     the model was cut off. */
  top: var(--am-top);
  height: calc(100vh - var(--am-top));
  min-height: 460px;
}

.am-stage__canvas canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  cursor: grab;
}

.am-stage__canvas canvas:active { cursor: grabbing; }

.am-stage__loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: .8rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--stage-mute);
  background: var(--stage-bg);
  transition: opacity .6s ease;
}

.am-stage__bar {
  width: 180px;
  height: 2px;
  background: var(--stage-line);
  overflow: hidden;
}

.am-stage__bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--brand);
  transition: width .2s linear;
}

.am-stage.is-ready .am-stage__loader { opacity: 0; pointer-events: none; }

.am-stage__steps {
  grid-column: 1;
  grid-row: 1;
  padding: 0 3vw 0 5vw;
}

.am-stage__step {
  min-height: 78vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  opacity: .32;
  transition: opacity .5s ease;
}

.am-stage__step.is-active { opacity: 1; }

.am-stage__step:first-child { min-height: calc(100vh - var(--am-top)); }
.am-stage__step:last-child { min-height: calc(100vh - var(--am-top)); }

.am-stage__num {
  font-size: .72rem;
  letter-spacing: .18em;
  color: var(--brand);
  font-weight: 700;
  margin: 0 0 .7rem;
}

.am-stage__step h2,
.am-stage__step h3 {
  color: #fff;
  font-weight: 700;
  font-size: 1.55rem;
  line-height: 1.25;
  margin: 0 0 .9rem;
}

.am-stage__step p {
  color: var(--stage-mute);
  font-size: .95rem;
  line-height: 1.65;
  margin: 0 0 .9rem;
  max-width: 34rem;
}

.am-stage__step ul {
  list-style: none;
  padding: 0;
  margin: .4rem 0 0;
  max-width: 34rem;
}

.am-stage__step li {
  position: relative;
  padding: .55rem 0 .55rem 1.1rem;
  border-top: 1px solid var(--stage-line);
  color: var(--stage-mute);
  font-size: .88rem;
  line-height: 1.55;
}

.am-stage__step li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1.05rem;
  width: 5px;
  height: 5px;
  background: var(--brand);
}

.am-stage__step li strong { color: var(--stage-ink); font-weight: 600; }

.am-stage__hint {
  font-size: .75rem;
  color: #6f777e;
  margin-top: 1.4rem !important;
}

@media (max-width: 900px) {
  .am-stage { grid-template-columns: 1fr; }
  .am-stage__canvas {
    grid-column: 1;
    top: var(--am-top);
    height: 46vh;
    min-height: 300px;
    z-index: 1;
    background: var(--stage-bg);
  }
  .am-stage__steps { grid-row: 2; padding: 0 20px; }
  /*
   * On a phone the model is pinned over the top of the screen and the text
   * reads below it. Text at the TOP of each step, a step 40vh tall, and the
   * trigger line low on the screen (allmarc-product-stage.js) keep the active
   * step's heading in view 88% of the time; the desktop layout managed 38%,
   * so you read one step while the model showed the previous one. Measured by
   * simulating the trigger against real layout at 375 x 812.
   */
  .am-stage__step,
  .am-stage__step:first-child,
  .am-stage__step:last-child { min-height: 40vh; justify-content: flex-start; padding-top: 1rem; }
  .am-stage__step h2, .am-stage__step h3 { font-size: 1.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  .am-stage__step { transition: none; }
}

/*
 * Light mode (client's call): the page sits on a pale grey, and every section
 * is a white card with rounded corners and breathing room around it. The 3D
 * stage is the largest card, inset from the screen edges. The WebGL canvas is
 * transparent, so the card colour shows through behind the model.
 */
body:has(.am-stage) { background: #e4e6e9 !important; }

body:has(.am-stage) main section.mod {
  background: #fff;
  border-radius: 24px;
  padding: clamp(28px, 4vw, 56px) clamp(20px, 4vw, 64px) !important;
  margin: 24px 0 !important;
  box-shadow: 0 1px 2px rgba(20, 24, 28, .04), 0 12px 32px -18px rgba(20, 24, 28, .12);
}
body:has(.am-stage) main section.mod.h-expand-background::before { display: none; }

.am-stage {
  --stage-bg: #ffffff;
  --stage-ink: #17171b;
  --stage-mute: #5d6369;
  --stage-line: #e4e6e9;
  --gut: clamp(12px, 2vw, 32px);
  width: calc(var(--am-w, 100%) - 2 * var(--gut));
  margin-left: calc(var(--am-ml, 0px) + var(--gut));
  margin-top: 24px;
  margin-bottom: 24px;
  border-radius: 28px;
  overflow: clip;
  /* Plain white behind the model (2 Oct). */
  background: #fff;
  box-shadow: 0 1px 2px rgba(20, 24, 28, .04), 0 18px 40px -22px rgba(20, 24, 28, .18);
}
.am-stage__step h2,
.am-stage__step h3 { color: var(--stage-ink); }
.am-stage__hint { color: #8a9096; }
.am-stage__loader { background: transparent; }

@media (max-width: 900px) {
  body:has(.am-stage) main section.mod { border-radius: 18px; margin: 14px 0 !important; }
  .am-stage { border-radius: 20px; }
  .am-stage__canvas { background: #fff; }
}
body:has(.am-stage) main section.mod :is(img, video) { border-radius: 14px; }
body:has(.am-stage) { --amk-line: #d2d4d8; --amk-ground: #e4e6e9; }

/* "How is it possible at Allmarc?" under a step: the machine that does it. */
.am-stage .am-how { margin: 18px 0 0; max-width: 34rem; border-top: 1px solid var(--stage-line); padding-top: 14px; }
.am-stage .am-how__q { display: block; font-size: 11.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--brand); margin-bottom: 10px; }
.am-stage .am-how__m { display: flex; align-items: center; gap: 12px; padding: 8px; margin: 0 0 8px; background: rgba(255,255,255,.7); border-radius: 10px; text-decoration: none; color: var(--stage-ink); transition: background .2s ease, transform .2s ease; }
.am-stage .am-how__m:hover { background: #fff; transform: translateX(3px); }
.am-stage .am-how__m img, .am-stage .am-how__iso { flex: none; width: 64px; height: 48px; border-radius: 6px; object-fit: cover; background: #fff; display: grid; place-items: center; }
.am-stage .am-how__iso svg { width: 80%; height: auto; color: var(--stage-ink); }
.am-stage .am-how__m b { display: block; font-size: 14px; font-weight: 600; line-height: 1.3; }
.am-stage .am-how__m small { display: block; font-size: 12.5px; color: var(--stage-mute); }
.am-stage .am-how__m::after { content: ""; margin-left: auto; flex: none; width: 7px; height: 7px; border-top: 1.5px solid var(--brand); border-right: 1.5px solid var(--brand); transform: rotate(45deg); margin-right: 6px; }

/* How panel v2: a button per machine, opening in place. */
.am-stage .am-how__i { margin: 0 0 8px; }
.am-stage .am-how__m { all: unset; box-sizing: border-box; cursor: pointer; width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px; background: rgba(255,255,255,.7); border-radius: 10px; color: var(--stage-ink); transition: background .2s ease, box-shadow .2s ease; }
.am-stage .am-how__m:hover, .am-stage .am-how__m:focus-visible { background: #fff; box-shadow: 0 0 0 2px var(--brand); }
.am-stage .am-how__m img, .am-stage .am-how__m .am-how__iso { flex: none; width: 64px; height: 48px; border-radius: 6px; object-fit: cover; background: #fff; display: grid; place-items: center; }
.am-stage .am-how__m::after { content: ""; margin-left: auto; flex: none; width: 7px; height: 7px; border-right: 1.5px solid var(--brand); border-bottom: 1.5px solid var(--brand); transform: rotate(45deg); margin-right: 8px; transition: transform .25s ease; }
.am-stage .am-how__i.is-open .am-how__m::after { transform: rotate(-135deg); }
.am-stage .am-how__d { display: grid; grid-template-rows: 0fr; overflow: hidden; transition: grid-template-rows .35s ease; background: #fff; border-radius: 0 0 10px 10px; margin-top: -6px; }
.am-stage .am-how__d > * { min-height: 0; }
.am-stage .am-how__i.is-open .am-how__d { grid-template-rows: 1fr; }
.am-stage .am-how__d { display: block; max-height: 0; transition: max-height .4s ease, padding .3s ease; padding: 0 14px; }
.am-stage .am-how__i.is-open .am-how__d { max-height: 640px; padding: 14px; }
.am-stage .am-how__d img { width: 100%; border-radius: 8px; aspect-ratio: 16 / 10; object-fit: cover; margin-bottom: 10px; display: block; }
.am-stage .am-how__d p, .am-stage .am-how__d li { font-size: 13.5px; line-height: 1.5; color: #3a3a40; }
.am-stage .am-how__d ul { list-style: none; padding: 0; margin: 6px 0 8px; }
.am-stage .am-how__d li { padding: 2px 0 2px 14px; border: 0; position: relative; }
.am-stage .am-how__d li::before { content: ""; position: absolute; left: 0; top: 10px; width: 6px; height: 1.5px; background: var(--brand); }
.am-stage .am-how__d a { font-size: 12.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); text-decoration: none; }
.am-stage .am-how__ctx { margin: 0 0 4px; }

/* Toolbar over the model. */
.am-stage__tools { position: absolute; right: 18px; top: 18px; z-index: 3; display: flex; gap: 6px; padding: 5px; background: rgba(255,255,255,.75); backdrop-filter: blur(8px); border-radius: 100px; box-shadow: 0 6px 20px -8px rgba(20,24,28,.25); }
.am-stage__tools button { all: unset; cursor: pointer; font-size: 12.5px; font-weight: 500; letter-spacing: .04em; padding: 8px 14px; border-radius: 100px; color: #17171b; }
.am-stage__tools button:hover { background: #fff; }
.am-stage__tools button[aria-pressed="true"] { background: #17171b; color: #fff; }
.am-stage__tools button:focus-visible { outline: 2px solid var(--brand); }
@media (max-width: 900px) { .am-stage__tools { left: 50%; right: auto; top: auto; transform: translateX(-50%); bottom: 10px; height: auto; } .am-stage__tools button { padding: 7px 10px; font-size: 12px; } }

/* Wide screens: the machine card as a callout over the model, with a leader
   line to the parts it works on. */
.am-stage__callout { position: absolute; right: 24px; top: 72px; width: min(330px, 40%); max-height: calc(100% - 100px); overflow: auto; z-index: 4;
  background: rgba(255,255,255,.94); backdrop-filter: blur(10px); border-radius: 16px; padding: 18px 18px 16px; box-shadow: 0 24px 60px -24px rgba(20,24,28,.45);
  opacity: 0; transform: translateX(16px); pointer-events: none; transition: opacity .3s ease, transform .35s cubic-bezier(.2,.7,.2,1); }
.am-stage__callout.is-on { opacity: 1; transform: none; }
.am-stage__callout-q { display: block; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--brand); margin-bottom: 6px; }
.am-stage__callout h4 { font-size: 18px; font-weight: 500; line-height: 1.25; margin: 0 0 10px; color: #17171b; }
.am-stage__callout img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 10px; display: block; margin-bottom: 10px; }
.am-stage__callout p, .am-stage__callout li { font-size: 13.5px; line-height: 1.5; color: #3a3a40; margin: 0 0 6px; }
.am-stage__callout ul { list-style: none; padding: 0; margin: 6px 0 8px; }
.am-stage__callout li { position: relative; padding-left: 14px; }
.am-stage__callout li::before { content: ""; position: absolute; left: 0; top: 9px; width: 6px; height: 1.5px; background: var(--brand); }
.am-stage__callout a { display: none; }
.am-stage__leader { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; opacity: 0; transition: opacity .3s ease; }
.am-stage__leader.is-on { opacity: 1; }
.am-stage__leader path { fill: none; stroke: var(--brand); stroke-width: 1.5; stroke-dasharray: 5 4; animation: am-dash 1s linear infinite; }
.am-stage__leader circle { fill: rgba(224,9,16,.18); stroke: var(--brand); stroke-width: 1.5; animation: am-ping 1.4s ease-out infinite; transform-box: fill-box; transform-origin: center; }
.am-stage__leader circle.c2 { fill: var(--brand); stroke: none; animation: none; }
@keyframes am-dash { to { stroke-dashoffset: -18; } }
@keyframes am-ping { 0% { transform: scale(.6); opacity: 1 } 100% { transform: scale(2.4); opacity: 0 } }
/* On wide screens the in-place detail never opens. */
@media (min-width: 901px) and (hover: hover) { .am-stage .am-how__d { display: none !important; } .am-stage .am-how__m::after { transform: rotate(-45deg); } }

/* Annotations pinned to the highlighted parts. */
.am-stage__annot { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.am-stage__tag { position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 12.5px; letter-spacing: .02em; padding: 6px 11px; border-radius: 100px;
  background: rgba(23,23,27,.88); color: #fff; box-shadow: 0 8px 20px -10px rgba(0,0,0,.5); opacity: 0; transition: opacity .35s ease; will-change: transform; }
.am-stage__tag b { font-weight: 500; }
.am-stage__annot.is-on .am-stage__tag { opacity: 1; }
.am-stage__annot.is-on .am-stage__tag:nth-child(2) { transition-delay: .08s; } .am-stage__annot.is-on .am-stage__tag:nth-child(3) { transition-delay: .16s; }
.am-stage__annot-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.am-stage__annot-lines path { fill: none; stroke: #17171b; stroke-width: 1.2; opacity: .75; }
@media (max-width: 900px) { .am-stage__tag { font-size: 11px; padding: 4px 8px; } }

/* Callouts (28 Sep): two lines, sketched leaders; numbered pins and a legend on phones */
.am-stage__tag { background: none !important; border: 0 !important; box-shadow: none !important; padding: 0 0 6px !important; border-radius: 0 !important;
  display: flex; flex-direction: column; gap: 2px; white-space: normal; max-width: 220px; color: #17171b;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 8' preserveAspectRatio='none'%3E%3Cpath d='M2 5 C50 2 120 3 198 4' fill='none' stroke='%23e00910' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important; background-position: 0 100% !important; background-size: 100% 6px !important; }
.am-stage__tag b { font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.am-stage__tag small { font-size: 11.5px; line-height: 1.35; color: #50545b; }
.am-stage__annot-lines path { stroke: #17171b; stroke-width: 1.1; opacity: .8; stroke-linecap: round; }
.am-stage__annot-lines path.s2 { opacity: .3; stroke-width: .8; }
.am-stage__annot-lines circle { fill: #fff; stroke: #e00910; stroke-width: 2; }
.am-stage__pin { position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; background: #e00910; color: #fff; font-size: 12px; font-weight: 600;
  display: grid; place-items: center; box-shadow: 0 0 0 3px rgba(255,255,255,.85); opacity: 0; transition: opacity .3s ease; }
.am-stage__annot.is-on .am-stage__pin { opacity: 1; }
.am-stage__legend { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.am-stage__legend[hidden] { display: none; }
.am-stage__legend li { display: grid; grid-template-columns: 24px 1fr; gap: 2px 10px; align-items: start; padding: 8px 0; border-bottom: 1px solid #e6e7ea; }
.am-stage__legend li::before { display: none; }
.am-stage__legend i { grid-row: span 2; width: 22px; height: 22px; border-radius: 50%; background: #e00910; color: #fff; font-style: normal; font-size: 12px; font-weight: 600; display: grid; place-items: center; }
.am-stage__legend b { font-size: 14px; } .am-stage__legend small { font-size: 12.5px; color: #50545b; }
.am-how__clip { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; background: #111; display: block; margin-bottom: 10px; }

/* Labels stand in one column on the right; a soft backing keeps them readable
   when the camera is in close and the model sits behind them. */
.am-stage__tag { background: rgba(255, 255, 255, .86) !important; padding: 6px 10px 7px !important; border-radius: 6px !important; transition: opacity .35s ease !important; }

/*
 * Wide screens (2 Oct): the canvas runs the full width behind the text, so a
 * close-up is never sliced at the column edge. The camera's view is shifted
 * right in JS (baseShift) so the model still sits beside the text. The text
 * side is a soft grey that fades to white under the model.
 */
@media (min-width: 901px) {
  .am-stage {
    background: linear-gradient(90deg, #e9ebee 0%, #f1f2f4 24%, #fbfbfc 44%, #fff 58%, #fff 100%);
  }
  .am-stage__canvas { grid-column: 1 / -1; }
  .am-stage__steps { position: relative; z-index: 2; pointer-events: none; }
  .am-stage__steps .am-stage__step > * { pointer-events: auto; }
  .am-stage__loader { background: transparent; }
}

/*
 * 21 Oct 2026 (client): the model controls are hidden on every page; the model always runs
 * in cinematic mode and turns on its own (both default on in the script).
 * On wide screens a white fade sits over the left of the 3D view, under the step text,
 * so a large model never makes the text hard to read.
 */
.am-stage__tools { display: none !important; }
@media (min-width: 901px) {
  .am-stage__canvas::after {
    content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
    background: linear-gradient(90deg, #fff 0%, rgba(255,255,255,.97) 28%, rgba(255,255,255,.85) 38%, rgba(255,255,255,.45) 46%, rgba(255,255,255,0) 54%);
  }
}
/* 21 Oct 2026 (client): step headings red; the "How is it possible at Allmarc?" label grey;
   machine names black; part annotations white text on a grey pill. */
.am-stage .am-stage__step h2, .am-stage .am-stage__step h3 { color: var(--brand) !important; }
.am-stage .am-how__q { color: #7a7e85 !important; }
.am-stage .am-how__m b { color: #17171b !important; }
.am-stage__tag { background: rgba(78,82,89,.92) !important; color: #fff !important; padding: 7px 12px 8px !important; border-radius: 10px !important;
  box-shadow: 0 6px 18px -8px rgba(0,0,0,.35) !important; }
.am-stage__tag b, .am-stage__tag small { color: #fff !important; }
.am-stage__tag small { opacity: .82; }
