/* ===========================================================
   LAYAN — section III «Наши врачи» v2 (js/doctors.js)
   After getty.edu/tracingart (client recording 2026-10-26). Pure white,
   full bleed (no padding, the field runs under the side nav and header).
   · .dstory is --units of scroll tall; .dstory__pin is sticky for all of it.
   · .dstory__field: the floating photo tiles (results, certificates)
     and their faint "shadow" copies. js moves them with the scroll (they
     drift up and wrap around) and away from the pointer.
   · .dstory__center: still. Photo, name + role, the story line, the two
     buttons, the loader (a rule with the beat's label riding on it).
   · Reduced motion: no pin, no field; every doctor is a static block.
   The previous carousel lives in archive/doctors-v1/.
   =========================================================== */

/* the white sheet: same torn top edge as the cream one, in white */
.sheet--white,
.sheet--white .sheet__lip{background-color:var(--white)}
.sheet--white .sheet__lip::before{background-image:url("../assets/img/ui/torn-edge-white.svg")}

.dstory{
  --units:12;--unit:80svh;
  position:relative;
  margin-top:calc(-1 * var(--lip, 0px));        /* starts right under the torn edge */
  height:calc(100svh + var(--units) * var(--unit));
  background:var(--white);
}
.dstory__pin{position:sticky;top:0;height:100svh;overflow:hidden}
/* touch screens, mid-section: fixed instead of sticky (no iOS wobble, js/doctors.js) */
.dstory.is-fixed .dstory__pin{position:fixed;left:0;right:0}

/* ---------- the field ---------- */
.dstory__field{position:absolute;inset:0;z-index:0;pointer-events:none}
.dtile{
  position:absolute;left:0;top:0;width:var(--w);aspect-ratio:var(--ar);
  will-change:transform,opacity;opacity:0;
}
.dtile > *{width:100%;height:100%}
.dtile img{display:block;object-fit:cover;opacity:0;transition:opacity .5s}
.dtile img.is-in{opacity:1}
/* shadows: a faint, colourless copy behind everything (the grey boxes in the reference) */
.dtile--ghost{z-index:0}
.dtile--ghost > *{filter:grayscale(1) contrast(.6) brightness(1.15) blur(1.5px)}
.dtile:not(.dtile--ghost){z-index:1}
.dstory__field{contain:strict}
/* touch screens: the whole field is one canvas (js/doctors.js) */
.dstory__canvas{position:absolute;inset:0;width:100%;height:100%;display:block}
/* the hero's pin while the doctors' stage covers it (touch, js/doctors.js) */
.hero__pin.is-covered{visibility:hidden}

/* ---------- the still centre ---------- */
.dstory__center{
  position:absolute;inset:0;z-index:2;pointer-events:none;
  display:grid;justify-items:center;
  grid-template-rows:clamp(48px,7.5svh,84px) var(--ph) auto 1fr auto 1fr auto auto clamp(18px,3.6svh,40px);
  /* the two 1fr rows keep the story line centred between the name and the buttons */
  --ph:min(44svh,64vw);
  color:var(--black);
}
.dstory__center > *{pointer-events:auto}
.dstory__photos{
  grid-row:2;position:relative;height:var(--ph);aspect-ratio:4/5;margin:0;
  background:var(--cream-300);overflow:hidden;
}
/* .dstory__ph slides up, its photo slides down by as much: the wipe (js) */
.dstory__ph{position:absolute;inset:0;overflow:hidden}
.dstory__ph + .dstory__ph{will-change:transform}
.dstory__photo{
  position:absolute;inset:0;width:100%;height:100%;object-fit:cover;display:block;
}
.dstory__ph + .dstory__ph .dstory__photo{will-change:transform}
.dstory__caps{grid-row:3;position:relative;width:min(560px,90vw);margin-top:clamp(12px,2svh,22px);text-align:center}
.dstory__cap{position:absolute;left:0;right:0;top:0;opacity:0;will-change:opacity}
.dstory__cap:first-child{position:relative}
.dstory__name{
  margin:0;font:400 clamp(18px,1.45vw,26px)/1.1 var(--font-display);color:var(--black);
}
.dstory__role{
  margin:.4em 0 0;font:400 clamp(11px,.8vw,13px)/1.3 var(--font-text);
  text-transform:lowercase;color:var(--black);
}

/* the story line: every beat is stacked in the same cell, js sets opacity */
.dstory__lines{
  grid-row:5;display:grid;width:min(660px,88vw);text-align:center;
}
.dstory__line{
  grid-area:1/1;align-self:center;margin:0;
  font:400 clamp(21px,2.05vw,36px)/1.22 var(--font-display);color:var(--black);
  opacity:0;will-change:opacity,transform;
}
.dstory__line em{font-style:italic;color:var(--burgundy)}

.dstory__acts{
  grid-row:7;display:flex;flex-direction:column;align-items:center;gap:clamp(6px,1svh,10px);
}
.dstory__skip{
  font:400 clamp(11px,.8vw,13px)/1 var(--font-text);color:var(--black);
  background:none;border:0;padding:6px 4px;cursor:pointer;
  transition:color .25s;
}
.dstory__skip:hover{color:var(--garnet)}
.dstory__next{
  font:400 clamp(11px,.8vw,13px)/1 var(--font-text);color:var(--cotton-fluff);
  background:var(--burgundy);border:0;border-radius:0;cursor:pointer;
  padding:.85em 1.35em;display:inline-flex;align-items:center;gap:.6em;
  transition:background-color .3s;
}
.dstory__next svg{width:1em;height:1em;stroke:currentColor;fill:none;stroke-width:1.6;transition:transform .3s}
.dstory__next:hover{background:var(--garnet)}
.dstory__next:hover svg{transform:translateY(2px)}
.dstory__skip[hidden],.dstory__next[hidden]{display:none}
.dstory__skip:focus-visible,.dstory__next:focus-visible{outline:2px solid var(--garnet);outline-offset:3px}

/* the loader: dark rule up to the label, light rule after it */
.dstory__bar{
  grid-row:8;position:relative;width:min(372px,72vw);height:1em;
  margin-top:clamp(20px,4svh,48px);
  font:700 clamp(11px,.8vw,13px)/1 var(--font-text);color:var(--black);
  --p:0;
}
.dstory__bar::before,.dstory__bar::after{
  content:"";position:absolute;top:50%;height:1px;
}
/* the rules stop short of the label (--lw = its width, set by js): no backing box */
.dstory__bar{--gap:calc(var(--lw, 0px) / 2 + 10px)}
.dstory__bar::before{left:0;width:max(0px, calc(var(--p) * 100% - var(--gap)));background:var(--black)}
.dstory__bar::after{left:min(100%, calc(var(--p) * 100% + var(--gap)));right:0;background:var(--ink-200)}
.dstory__lbl{
  position:absolute;top:50%;left:calc(var(--p) * 100%);
  transform:translate(-50%,-50%);white-space:nowrap;
  transition:opacity .25s;
}
.dstory__lbl.is-swap{opacity:0}

@media (max-width:760px){
  .dstory{--unit:70svh}
  /* bigger portrait on phones (client 2026-11-04): ~80 % of the width,
     still leaving room for the line, buttons and loader on a 667px screen */
  .dstory__center{--ph:min(47svh,100vw);grid-template-rows:clamp(60px,8svh,72px) var(--ph) auto 1fr auto 1fr auto auto clamp(14px,2.4svh,24px)}
  .dstory__photos{justify-self:center}
  .dstory__bar{margin-top:clamp(14px,2.6svh,28px)}
  /* bigger name, role, line and button on phones (client iPhone video
     2026-11-04); the loader label stays as it is */
  .dstory__name{font-size:clamp(22px,6.2vw,27px)}
  .dstory__role{font-size:14px;margin-top:.35em}
  .dstory__line{font-size:clamp(21px,5.8vw,26px)}
  .dstory__next{font-size:14px;padding:.9em 1.4em}
  .dstory__skip{font-size:13px}
}
/* short phones (SE-size with Safari's bars): a smaller portrait keeps the loader on screen */
@media (max-width:760px) and (max-height:640px){
  .dstory__center{--ph:min(42svh,100vw)}
}

/* ---------- reduced motion: a plain list, no pin, no field ---------- */
.dstory--static{height:auto;margin-top:calc(var(--lip, 0px) * -.6);padding:0 var(--pad-x) clamp(64px,10svh,120px)}
.dstory--static .dstory__pin{position:static;height:auto;overflow:visible}
.dstory--static .dstory__field{display:none}
.dstory--static .dstory__center{position:static;display:block}
.dstatic{display:grid;justify-items:center;text-align:center;gap:18px;margin:0 auto clamp(64px,10svh,120px);max-width:720px}
.dstatic img{width:min(320px,70vw);aspect-ratio:4/5;object-fit:cover;display:block}
.dstatic p{margin:0;font:400 clamp(19px,1.8vw,28px)/1.25 var(--font-display)}
.dstatic p em{font-style:italic;color:var(--burgundy)}
