/* Damasca · ثلاث رؤى — scroll scenes.
   A scene is a tall run (height = one screen + (n − 1) steps) holding a sticky stage. The page keeps scrolling
   natively; the stage reads its progress. `.is-scene` is set by app.js only with motion on and enough room, so
   reduced motion, no JavaScript and very short screens keep the plain layouts in show.css. */

/* ------------------------------------------------------------------ phone compositions (any mode) */
@media (max-width: 699px) {
  .day__img { aspect-ratio: 390 / 844; }
  .verbs__panel picture { aspect-ratio: 390 / 844; }
  .day__item { flex-basis: 64vw; }
  .day__img img, .verbs__panel img { object-position: 50% 0; }
}

/* ------------------------------------------------------------------ the opening: a sticky stage instead of a pin */
html.js:not(.rm) .unveil { --run: 110svh; height: calc(100svh + var(--run)); min-height: 0; }
html.js:not(.rm) .unveil__stage { position: sticky; top: 0; }
@media (max-width: 699px) { html.js:not(.rm) .unveil { --run: 90svh; } }

/* ------------------------------------------------------------------ shared */
.is-scene { height: calc(100svh + (var(--n) - 1) * var(--step)); }
.is-scene > .day__sticky, .is-scene > .verbs__sticky, .is-scene > .cmp-sticky, .is-scene > .steps__sticky {
  position: sticky; top: 0; height: 100svh; overflow: hidden;
}

/* ------------------------------------------------------------------ A · a day at Damasca */
.day.is-scene {
  --step: 52svh;
  --dayW: min(60vw, calc((100svh - 400px) * 1.6), 1060px);
  margin-top: clamp(70px, 10vh, 130px);
}
.day.is-scene .day__sticky {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);
  padding: calc(var(--hdr) + clamp(14px, 3.2vh, 40px)) 0 clamp(16px, 3.6vh, 44px);
  contain: paint;
}
.day.is-scene .day__head { margin-bottom: 0; }
.day.is-scene .day__track {
  overflow: visible; contain: none; scroll-snap-type: none; cursor: default; padding-bottom: 0;
  align-items: center; will-change: transform; min-width: 0; width: 100%;
}
.day.is-scene .day__item { flex: 0 0 var(--dayW); transform-origin: 50% 50%; will-change: opacity, transform; }
.day.is-scene .day__item:last-child { margin-inline-end: 0; }
.day.is-scene .day__img { cursor: pointer; }
.day.is-scene .day__item.is-current .day__img { cursor: zoom-in; }
.day.is-scene .day__img img { transform: scale(1.06); transition: none; }
.day.is-scene .day__img:hover img { transform: scale(1.06); }
.day.is-scene .day__item figcaption { will-change: opacity; }
.day.is-scene .day__scale { margin-top: clamp(14px, 2.6vh, 30px); }
.day.is-scene .day__scale::before { transition: none; }
.day.is-scene .day__time { transition: color .5s; }
.day.is-scene .day__item:not(.is-current) .day__time { color: var(--ink-2); }

@media (min-width: 700px) and (max-width: 1099px) {
  .day.is-scene { --dayW: min(78vw, calc((100svh - 400px) * 1.6)); }
}
@media (max-width: 699px) {
  .day.is-scene { --step: 46svh; --dayW: min(64vw, calc((100svh - 300px) * .462)); }
  .day.is-scene .day__head { grid-template-columns: 1fr auto; row-gap: 4px; }
  .day.is-scene .day__head .muted { display: none; }
  .day.is-scene .day__ctrl .arrow { width: 44px; height: 44px; }
  .day.is-scene .day__track { gap: 14px; }
  .day.is-scene .day__item figcaption { font-size: 13px; line-height: 1.65; }
  .day.is-scene .day__time { font-size: 17px; margin-bottom: 8px; }
}

/* ------------------------------------------------------------------ B · the verb tour */
.verbs.is-scene { --step: 50svh; margin-top: clamp(70px, 10vh, 130px); }
.verbs.is-scene .verbs__sticky {
  display: flex; align-items: center;
  padding: calc(var(--hdr) + clamp(10px, 2.4vh, 30px)) 0 clamp(14px, 3vh, 36px);
}
.verbs.is-scene .verbs__grid {
  display: grid; grid-template-columns: minmax(230px, 340px) minmax(0, 1fr);
  grid-template-areas: "head head" "list stage"; column-gap: clamp(32px, 5vw, 96px); row-gap: clamp(18px, 3vh, 34px);
  align-items: start;
}
.verbs.is-scene .verbs__head { grid-area: head; display: grid; grid-template-columns: auto 1fr; gap: 10px 32px; align-items: end; }
.verbs.is-scene .verbs__list { position: relative; border-top: 0; border-inline-start: 1px solid var(--rule); padding-inline-start: 22px; }
.verbs.is-scene .verbs__list button { border-bottom: 0; padding: 7px 0 9px; }
.verbs.is-scene .verbs__list button::after { display: none; }
.verbs__mark {
  position: absolute; inset-inline-start: -1.5px; top: 0; width: 2px; height: 0; background: var(--gold);
  transition: transform .7s var(--ease), height .7s var(--ease); display: none;
}
.verbs.is-scene .verbs__mark { display: block; }
.verbs.is-scene .verbs__list b { transition: color .5s, font-weight .5s; }
.verbs.is-scene .verbs__stage {
  width: min(100%, calc((100svh - 330px) * 1.6)); justify-self: start;
}
/* a wipe in the reading direction; backwards it wipes the other way */
.verbs.is-scene .verbs__panel { opacity: 1; visibility: hidden; transition: visibility 0s 1.05s; z-index: 0; }
.verbs.is-scene .verbs__panel.is-on { visibility: visible; transition: none; z-index: 2; }
.verbs.is-scene .verbs__panel.is-off { visibility: visible; transition: none; z-index: 1; }
.verbs.is-scene .verbs__panel picture { clip-path: inset(0 0 0 100%); transition: clip-path 1s var(--ease-io); }
.verbs.is-scene [data-dir="back"] .verbs__panel picture { clip-path: inset(0 100% 0 0); }
.verbs.is-scene .verbs__panel.is-on picture, .verbs.is-scene .verbs__panel.is-off picture { clip-path: inset(0 0 0 0); }
.verbs.is-scene .verbs__panel.is-on img { animation: none; transform: scale(1); transition: transform 1.6s var(--ease); }
.verbs.is-scene .verbs__panel:not(.is-on) img { transform: scale(1.07); transition: none; }
.verbs.is-scene .verbs__panel figcaption { opacity: 0; transform: translateY(10px); transition: opacity .5s, transform .5s; }
.verbs.is-scene .verbs__panel.is-on figcaption { opacity: 1; transform: none; transition: opacity .7s var(--ease) .35s, transform .9s var(--ease) .35s; }
.verbs.is-scene .verbs__panel.is-off figcaption { opacity: 0; }

@media (max-width: 899px) {
  .verbs.is-scene .verbs__grid { grid-template-columns: 1fr; grid-template-areas: "head" "list" "stage"; row-gap: 14px; }
  .verbs.is-scene .verbs__head { grid-template-columns: 1fr; }
  .verbs.is-scene .verbs__list { border-inline-start: 0; padding-inline-start: 0; }
  .verbs.is-scene .verbs__list button { padding: 6px 18px; }
  .verbs.is-scene .verbs__mark { display: none; }
  .verbs.is-scene .verbs__stage { width: min(100%, calc((100svh - 340px) * 1.6)); justify-self: center; }
}
@media (max-width: 699px) {
  .verbs.is-scene { --step: 46svh; }
  .verbs.is-scene .verbs__head .muted { display: none; }
  .verbs.is-scene .verbs__stage { width: min(66vw, calc((100svh - 300px) * .462)); }
  .verbs.is-scene .verbs__panel figcaption { font-size: 13px; line-height: 1.65; margin-top: 10px; }
}

/* ------------------------------------------------------------------ the comparison */
.cmp-run.is-scene { --step: 42svh; }
.cmp-run.is-scene .cmp-sticky {
  display: flex; flex-direction: column; justify-content: center;
  padding: calc(var(--hdr) + 8px) 0 clamp(14px, 3vh, 36px);
}
.cmp-run.is-scene .aspects { margin-top: 0; position: relative; }
.cmp-run.is-scene .cmp { margin-top: clamp(18px, 3vh, 30px); }
.cmp-run.is-scene .cmp__views { align-items: center; }
.cmp-run.is-scene .cmp__view:not(.cmp__view--phone) picture { aspect-ratio: 4 / 3; max-height: calc(100svh - 470px); }
.cmp-run.is-scene .cmp { margin-top: clamp(14px, 2.4vh, 26px); }
.cmp-run.is-scene .cmp__view--phone .phone { width: min(196px, calc((100svh - 440px) * .462)); }
.cmp-run.is-scene .cmp__view figcaption { min-height: 3.7em; }
.aspects__line { display: none; }
.cmp-run.is-scene .aspects__line {
  display: block; position: absolute; inset-inline: 0; bottom: -2px; height: 1px; background: var(--rule);
}
.cmp-run.is-scene .aspects__line::after {
  content: ''; position: absolute; right: 0; top: 0; height: 1px; width: var(--cmp-p, 0%); background: var(--navy);
}

/* ------------------------------------------------------------------ quiet motion helpers */
.cascade__step, .trio__item { will-change: transform; }
.cmp-run.is-scene .cmp__view--type1 img { transform: scale(1.65); transform-origin: 92% 40%; }
.cmp-run.is-scene .cmp__view--type2 img { transform: scale(1.3); transform-origin: 62% 60%; }
.cmp-run.is-scene .cmp__view--type3 img { transform: scale(1.55); transform-origin: 72% 42%; }

/* ------------------------------------------------------------------ C · steps (Direction 03 «تدرّج»)
   The current moment stands large at the reading edge; each new one wipes in there while the earlier ones step
   down and away along the reading direction, smaller at every step: a staircase. Positions come from app.js
   (transforms on one shared box), so movement is continuous and nothing overlaps. */
.steps.is-scene { --step: 46svh; margin-top: clamp(70px, 10vh, 130px); }
.steps.is-scene .steps__sticky {
  display: grid; grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr);
  padding: calc(var(--hdr) + clamp(14px, 3.2vh, 40px)) 0 clamp(16px, 3.4vh, 40px);
}
.steps.is-scene .steps__head { margin-bottom: 0; }
.steps.is-scene .cascade {
  display: block; position: relative; padding: 0; width: calc(100% - 2 * var(--edge)); max-width: var(--max);
  margin: clamp(16px, 3vh, 34px) auto 0; height: auto;
}
.steps.is-scene .cascade__step {
  position: absolute; top: 0; right: 0; width: var(--w0, 50%); margin: 0 !important;
  transform-origin: 100% 0; will-change: transform;
  transition: transform 1.15s var(--ease-io), opacity .8s var(--ease);
}
.steps.is-scene .cascade__step picture { clip-path: inset(0 0 0 100%); transition: clip-path 1.05s var(--ease-io); box-shadow: 0 40px 90px -40px #000; }
.steps.is-scene .cascade__step.is-seen picture { clip-path: inset(0 0 0 0); }
.steps.is-scene .cascade__step figcaption { opacity: 0; transform: translateY(8px); transition: opacity .45s, transform .45s; max-width: 36em; }
.steps.is-scene .cascade__step.is-current figcaption { opacity: 1; transform: none; transition: opacity .7s var(--ease) .45s, transform .9s var(--ease) .45s; }
.steps.is-scene .cascade__step:not(.is-current) { cursor: pointer; }
@media (max-width: 699px) {
  .steps.is-scene { --step: 46svh; }
  .steps.is-scene .steps__head .muted { display: none; }
  .steps.is-scene .cascade__step figcaption { font-size: 13px; line-height: 1.6; }
}
