/* ============================================================
   TRIBO — Production page (/vyrobnytstvo/)
   ============================================================ */

.page-hero__lead {
  max-width: 46ch;
  color: var(--text-muted);
  font-size: var(--fs-body);
  line-height: 1.6;
  margin-top: var(--space-2);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Process block — one full-height beat: copy left, media right.
   No pinning, no scrubbed pin-spacer — each block just scrolls by
   normally and fades in once when it enters the viewport. ── */
.process-block {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding-block: var(--space-8);
}
.process-block-inner {
  display: grid;
  grid-template-columns: 0.85fr 1.3fr;
  align-items: center;
  gap: var(--space-8);
  width: 100%;
}

/* ── Alternate sides on desktop only (02 & 04 mirror: media left, copy
   right) so the four beats don't read as one repeated template. Scoped
   to min-width so it never touches the ≤900px stacked layout below,
   where markup order (copy first) must stay intact.

   Block 01 and block 03 are deliberately left alone — 03 especially
   must NOT be mirrored: its door-open animation in production.js is
   driven by hardcoded left/right transform constants tied to the
   door images' actual left/right position, and flipping the column
   order here would desync the doors from their background photo. ── */
@media (min-width: 901px) {
  #block-dosing .process-block-inner,
  #block-post-curing .process-block-inner {
    grid-template-columns: 1.3fr 0.85fr;
  }
  #block-dosing .process-copy,
  #block-post-curing .process-copy {
    order: 2;
  }
  #block-dosing .process-scene {
    order: 1;
  }
  /* Block 04's media+readout are wrapped in .furnace-col, so the order
     flip targets that wrapper (not the now-nested .process-scene). */
  #block-post-curing .furnace-col {
    order: 1;
  }
}

/* ── Copy column ── */
.process-copy {
  max-width: 40ch;
}
.process-copy__step {
  display: block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: var(--fs-label);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}
.process-copy h2 {
  font-size: var(--fs-h2);
  line-height: 1.15;
  margin-bottom: var(--space-3);
}
.process-copy p {
  color: #999999;
  line-height: 1.6;
}

/* ── Visual scene — drafting-grid backdrop with the media centered
   on top. Media keeps its natural aspect ratio (object-fit: contain)
   since these are transparent cutouts, not fixed-ratio photos.
   Height-based sizing (not a fixed aspect-ratio box) so each image
   fills the available height regardless of its own proportions —
   a fixed box ratio would badly letterbox the near-square raw
   materials shot or the ultra-wide post-curing oven shot. ── */
.process-scene {
  position: relative;
  width: 100%;
  max-width: 720px;
  height: min(58vh, 580px);
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Block 04 — post-curing oven is a wide banner-shaped cutout;
   a tall box would leave huge empty grid above/below it. */
.process-scene--wide {
  max-width: 760px;
  height: min(26vh, 260px);
}

/* Code-drawn dosing reference: transparent surface, fitted without distortion. */
.dosing-mixer {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
}
.dosing-mixer__canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ============================================================
   Block 04 — interactive post-curing furnace.
   Cursor-driven "x-ray" reveal of the oven interior + a thermal
   readout of the 6 vulcanisation stages. The reveal is a clip-path
   circle on an overlaid interior image, positioned/sized from a
   stateless pointer listener in production.js (live rect every move,
   never a cached scrub) — so it scales per-device and is resize-proof
   like the block 03 doors. Both images use object-fit:fill into an
   identical box so the interior overlays the closed oven pixel-exact
   regardless of any small source-aspect mismatch.
   ============================================================ */
.furnace-col {
  display: flex;
  flex-direction: column;
  width: 100%;
}
.furnace {
  position: relative;
  overflow: clip;
  width: 100%;
  aspect-ratio: 1127 / 283;
  max-height: 100%;
  margin-inline: auto;
  z-index: 1;
  cursor: none;                 /* the reticle ring below is the cursor */
  --mx: 50%;
  --my: 50%;
  --lens-r: 0px;
}
.furnace__base,
.furnace__xray {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;             /* identical box → pixel-exact overlay */
  display: block;
  -webkit-user-drag: none;
  user-select: none;
}
.furnace__base {
  z-index: 1;
  filter: drop-shadow(0 20px 40px rgba(0,0,0,.45));
}
.furnace__xray {
  z-index: 2;
  pointer-events: none;
  clip-path: circle(var(--lens-r) at var(--mx) var(--my));
  filter: contrast(1.04) saturate(1.05);
}

/* Reticle — a thin measurement ring marking the scan lens; sized in
   JS to match the reveal radius, revealed only while scanning. */
.furnace__lens {
  position: absolute;
  left: var(--mx);
  top: var(--my);
  width: 0;
  height: 0;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .55);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, .25),
    0 0 22px rgba(255, 255, 255, .12),
    inset 0 0 14px rgba(255, 255, 255, .08);
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-base);
  overflow: hidden;
}
.furnace.is-scanning .furnace__lens {
  opacity: 1;
}
/* Sweeping scan line inside the reticle. */
.furnace__lens::after {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  height: 1px;
  background: rgba(255, 255, 255, .6);
  box-shadow: 0 0 8px rgba(255, 255, 255, .55);
  animation: furnaceScan 2.6s linear infinite;
}
@keyframes furnaceScan {
  0%   { top: 8%; }
  50%  { top: 92%; }
  100% { top: 8%; }
}

/* ── Thermal readout under the oven — a 6-segment progress bar (one
   segment per stage) plus a live status line. Sits directly below the
   scene, sharing its 760px measure so it lines up under the media. ── */
.furnace-readout {
  width: 100%;
  max-width: 760px;
  margin: var(--space-4) auto 0;
}
.furnace-progress {
  position: relative;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
  /* 6 equal segments = the 6 vulcanisation stages */
  background:
    repeating-linear-gradient(90deg,
      var(--surface) 0,
      var(--surface) calc(100% / 6 - 1px),
      rgba(255, 255, 255, .14) calc(100% / 6 - 1px),
      rgba(255, 255, 255, .14) calc(100% / 6));
}
.furnace-progress__fill {
  height: 100%;
  width: 0%;
  border-radius: 4px 0 0 4px;
  background: #f4c430;
  box-shadow: 0 0 12px rgba(244, 196, 48, .5);
  transition: width .28s ease-out, background-color .28s ease, box-shadow .28s ease;
}
.furnace-status {
  margin-top: var(--space-3);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
/* Both states size the same row, including when the translated hint wraps. */
.furnace-status__hint,
.furnace-status__details {
  grid-area: 1 / 1;
}
.furnace-status__details {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  visibility: hidden;
}
.furnace-status.is-scanning .furnace-status__hint {
  visibility: hidden;
}
.furnace-status.is-scanning .furnace-status__details {
  visibility: visible;
}
.furnace-status__stage {
  font-family: 'IBM Plex Mono', monospace;
  font-size: var(--fs-label);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
}
.furnace-status__time {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--text);
}
.furnace-status__temp {
  margin-left: auto;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  font-size: var(--fs-body);
}

@media (prefers-reduced-motion: reduce) {
  .furnace__lens::after { animation: none; }
}
.process-scene__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.1) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: center;
  -webkit-mask-image: radial-gradient(circle at 68% 45%, rgba(0,0,0,1) 35%, rgba(0,0,0,0) 78%);
  mask-image: radial-gradient(circle at 68% 45%, rgba(0,0,0,1) 35%, rgba(0,0,0,0) 78%);
  pointer-events: none;
}
.process-scene__media {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 20px 40px rgba(0,0,0,.45));
}

/* ── Block 01 — raw materials as three separate bowls that fly into
   place. .raw-stack recreates the original composite's canvas (same
   1148×1370 aspect ratio) inside the scene box, so the three 550×550
   bowl crops land exactly where the single composite image used to sit.
   Centres below are measured from the composite; translate(-50%,-50%)
   makes left/top mark each bowl's centre. Bowls default to visible and
   centred (no-JS fallback); production.js sets the hidden/offset start
   state and animates them in via a once-only, resize-safe reveal. ── */
.raw-stack {
  position: relative;
  z-index: 1;
  height: 100%;
  aspect-ratio: 1148 / 1370;
  margin-inline: auto;
  /* Nudge the whole group down + right (percent of own size → stays put
     on resize). Tune these two values to reposition the trio. */
  transform: translate(7%, 0%);
}
.raw-bowl {
  position: absolute;
  width: 47.9%;              /* 550 / 1148 → keeps each bowl at source scale */
  height: auto;              /* square crop → height tracks width */
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 16px 28px rgba(0,0,0,.5));
}
.raw-bowl--1 { left: 25.2%; top: 59.3%; }  /* yellow, bottom-left */
.raw-bowl--2 { left: 60.0%; top: 29.2%; }  /* green, top */
.raw-bowl--3 { left: 73.8%; top: 70.4%; }  /* brown, bottom-right */

/* Pointer response uses separate transform properties so the entrance
   animation can keep ownership of transform until it finishes. */
@media (min-width: 901px) and (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .raw-stack.is-ready .raw-bowl {
    translate: var(--bowl-x, 0px) var(--bowl-y, 0px);
    scale: 1;
    transition: translate .45s ease-out, scale .35s ease-out, filter .35s ease-out;
  }
  .raw-stack.is-ready .raw-bowl.is-hovered {
    scale: 1.025;
    filter: drop-shadow(0 21px 34px rgba(0,0,0,.55));
  }
}

/* ── Block 03 — pressform machine, door-open scroll-scrub.
   Scroll-linked (progress tied to scroll position) but NOT pinned —
   scrolling itself is never taken over, the doors just slide open as
   this block passes through the middle of the viewport. ── */
.process-scene--door {
  max-width: 760px;
  height: auto;
  aspect-ratio: 1000 / 468;
  /* Moving full-frame door images include transparent pixels; keep their
     translated bounds from widening the document. */
  overflow: hidden;
}
.door-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  will-change: transform;
}
.door-bg { z-index: 1; }
.door-left, .door-right {
  z-index: 2;
  /* Small smoothing so per-frame scroll updates read fluidly and any
     resize reposition eases in rather than snapping. Kept short so the
     doors never visibly lag behind a fast scroll. */
  transition: transform 0.1s ease-out;
}

/* ============================================================
   Block 05 — product selection and video in a shared panel.
   ============================================================ */
.process-block--lab { padding-block: var(--space-8); }
.lab-layout {
  display: grid;
  grid-template-columns: minmax(0, .75fr) minmax(0, 1.4fr);
  align-items: start;
  gap: var(--space-8);
}
.process-lab-content { max-width: 460px; }
.lab-interactive { min-width: 0; }
.lab-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin-top: var(--space-4);
}
.lab-pick {
  position: relative;
  display: grid;
  grid-template-columns: minmax(80px, 1fr) minmax(0, 1.1fr) 24px;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-card);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--fs-body);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--t-fast), color var(--t-fast);
}
.lab-pick img { width: 100%; height: 84px; object-fit: contain; }
.lab-pick:not(.is-active)::after { content: ''; position: absolute; bottom: -1px; left: 16px; right: 16px; height: 1px; background: var(--border); }
.lab-pick:hover { color: var(--text); }
.lab-pick.is-active { border-color: var(--text); color: var(--text); }
.lab-pick__arrow { font-size: 24px; line-height: 1; text-align: right; }
.lab-pick:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.lab-caption {
  margin: 0 0 12px;
  min-height: 3em;
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--text);
}
.lab-video-frame { aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--radius-card); background: #000; }
.lab-video { display: block; width: 100%; height: 100%; object-fit: contain; }
.lab-stats { display: flex; gap: var(--space-6); margin-top: var(--space-3); }
.lab-stat__num {
  display: block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(1.25rem, 2vw, 1.75rem);
  font-weight: 500;
  letter-spacing: -0.01em;
}
.lab-stat__label {
  display: block;
  font-size: var(--fs-label);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 2px;
}

@media (max-width: 900px) {
  .process-block-inner {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
  }
  /* Stacked layout: the scene below is centred (.process-scene has
     margin-inline:auto), so left-aligned text above it reads lopsided.
     Centre the copy column itself, not just its text, so the step
     label/heading/paragraph share the same midline as the scene. */
  .process-copy {
    min-width: 0;
    max-width: min(46ch, 100%);
    margin-inline: auto;
    text-align: center;
  }
  .process-scene {
    max-width: 420px;
    height: min(42vh, 360px);
    margin-inline: auto;
  }
  .process-scene--wide { height: min(20vh, 180px); }
  /* Keep the thermal readout the same measure as the (now 420px-capped)
     oven above it so the bar lines up under the furnace, not the column. */
  .furnace-readout { max-width: 420px; }
  /* Stacked mobile layout centres the media column — drop the desktop
     down-right nudge so the trio stays centred here. */
  .raw-stack { transform: none; }
  /* Door scene keeps aspect-ratio-driven sizing (not the generic
     height override above) — it must stay proportional or the
     overlaid door panels desync from the background machine photo. */
  .process-scene--door { height: auto; max-width: 420px; }
  .process-block { min-height: auto; padding-block: var(--space-6); }
  /* First block starts at the very top of the page (the page-hero that
     used to clear the fixed header is gone). On desktop the block's
     100vh + vertical centring keeps content below the header, but with
     min-height:auto here the first line ("01 / Сировина") tucks under
     the fixed header — add explicit top clearance. */
  #block-raw-materials { padding-top: calc(var(--header-h) + var(--space-4)); }

  .lab-layout { grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
  .lab-interactive { width: 100%; max-width: 680px; margin-inline: auto; }
  .process-lab-content { width: 100%; max-width: 680px; }
  .lab-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .lab-pick { display: flex; flex-direction: column; gap: 8px; font-size: .75rem; padding: 8px 4px; text-align: center; }
  .lab-pick__arrow, .lab-pick:not(.is-active)::after { display: none; }
  .lab-pick img { height: 48px; }
  .lab-caption { text-align: center; }
  .lab-stats { justify-content: center; }
}
@media (max-width: 360px) {
  .lab-caption { min-height: 4.5em; }
}
