/* =====================================================================
   BA-SCROLL.CSS — "Before & after": current and updated app screens
   ba-scroll.js sets data-mode on .ba:
     (none)   no JavaScript: every part as a list
     "list"   reduced motion or a very short screen: the same list
     "scrub"  the section pins; scrolling steps through each part
   and data-layout: "wide" or "stacked" (phones and portrait tablets).
   In scrub mode the stage breaks out of the text column and is centred
   on the page; ba-scroll.js measures that space (--ba-w, --ba-shift) and
   the phone height for each part (--ba-phone-h).
   Each part: a centred caption, then the current screen, a pixel arrow,
   and one or more updated screens.
   ===================================================================== */

.csx .ba-section {
  padding-bottom: clamp(24px, 3vw, 40px);
}

.csx .ba-steps {
  margin: 0;
  padding: 0;
  list-style: none;
}

.csx .ba-step {
  display: grid;
  justify-items: center;
  gap: 18px;
}

/* ---- Caption: centred above the screens ---- */
.csx .ba-copy {
  order: -1;
  max-width: 88ch;
  text-align: center;
}

.csx .ba-copy .ba-name {   /* beats .csx-content p */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 0 0 8px;
  color: var(--blue);
  font: 400 clamp(1.7rem, 1.25rem + 1.1vw, 2.35rem)/1.05 Determination, 'Pixelify Sans', monospace;
  letter-spacing: .01em;
}

.csx .ba-copy .ba-credit {
  max-width: none;
  margin: -2px auto 8px;
  text-align: center;
  color: #6a716c;
  font-size: .88rem;
}

.csx .ba-tag {
  padding: 4px 8px 3px;
  background: var(--blue);
  color: #fff;
  font: 400 .4em/1.1 Determination, 'Pixelify Sans', monospace;
  clip-path: polygon(0 2px, 2px 2px, 2px 0, calc(100% - 2px) 0, calc(100% - 2px) 2px, 100% 2px,
    100% calc(100% - 2px), calc(100% - 2px) calc(100% - 2px), calc(100% - 2px) 100%,
    2px 100%, 2px calc(100% - 2px), 0 calc(100% - 2px));
}

.csx .ba-copy p:not(.ba-name, .ba-credit) {
  margin-inline: auto;
  line-height: 1.45;
}

.csx .ba[data-layout="wide"] .ba-copy p:not(.ba-name, .ba-credit) {
  font-size: .98rem;
}

.csx .ba-copy .ba-before {
  margin-bottom: 4px;
  color: #59645d;
}

.csx .ba-copy .ba-after {
  margin-bottom: 0;
}

/* ---- Screens: current → updated ---- */
.csx .ba-shots {
  --ba-gap: clamp(12px, 1.2vw, 18px);
  --ba-arrow: clamp(32px, 3vw, 48px);   /* the space the arrow sits in */
  display: flex;
  align-items: flex-start;
  gap: var(--ba-gap);
  max-width: 100%;
}

.csx .ba-shot {
  position: relative;
  flex: none;
  margin: 0;
}

/* Centred when they fit, scrollable from the first screen when they don't. */
.csx .ba-shot:first-child { margin-left: auto; }
.csx .ba-shot:last-child  { margin-right: auto; }

.csx .ba-shot.is-before {
  margin-right: var(--ba-arrow);
}

/* pixel arrow between the current screen and the updated ones */
.csx .ba-shot.is-before::after {
  content: "";
  position: absolute;
  top: calc(var(--ba-phone-h, 420px) / 2 - 10px);
  left: calc(100% + var(--ba-gap) / 2 + (var(--ba-arrow) - 28px) / 2);
  width: 28px;
  height: 20px;
  background: var(--blue);
  /* a 7 x 5 pixel arrow */
  clip-path: polygon(0 40%, 57.14% 40%, 57.14% 0, 71.43% 0, 71.43% 20%, 85.71% 20%, 85.71% 40%,
    100% 40%, 100% 60%, 85.71% 60%, 85.71% 80%, 71.43% 80%, 71.43% 100%, 57.14% 100%, 57.14% 60%, 0 60%);
}

.csx .ba-shot figcaption {
  padding-top: 10px;
  color: #59645d;
  font: 400 1rem/1.2 Determination, 'Pixelify Sans', monospace;
  text-align: center;
  white-space: nowrap;
}

.csx .ba-shot.is-after figcaption {
  color: var(--blue);
}

/* ---- List (default, reduced motion, no JS) ---- */
.csx .ba:not([data-mode="scrub"]) .ba-steps {
  display: grid;
  gap: clamp(40px, 6vw, 64px);
}

.csx .ba:not([data-mode="scrub"]) .ba-step {
  padding-top: 28px;
  border-top: 1px solid var(--rule);
}

.csx .ba:not([data-mode="scrub"]) .ba-shots {
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding-bottom: 6px;
}

.csx .ba:not([data-mode="scrub"]) .ba-shot {
  width: clamp(130px, 38vw, 220px);
  scroll-snap-align: center;
}

.csx .ba:not([data-mode="scrub"]) .ba-shot.is-before::after {
  top: calc(clamp(130px, 38vw, 220px) * 3356 / 1627 / 2 - 10px);
}

/* ---- Scrub: the stage pins, centred on the page ---- */
.csx .ba[data-mode="scrub"] {
  --ba-scroll: 330svh;   /* how much scrolling all the parts take */
  height: calc(100svh - var(--header-h) + var(--ba-scroll));
}

.csx .ba[data-mode="scrub"][data-layout="stacked"] {
  --ba-scroll: 260svh;
}

.csx .ba[data-mode="scrub"] .ba-sticky {
  position: sticky;
  top: var(--header-h);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: var(--ba-w, 100%);
  height: calc(100svh - var(--header-h));
  margin-left: var(--ba-shift, 0px);
  padding-block: 12px;
  box-sizing: border-box;
}

/* All parts share one spot; the one you're on shows. Screens and words
   fade together, so a caption never sits above the wrong screens. */
.csx .ba[data-mode="scrub"] .ba-steps {
  display: grid;
  min-height: 0;
}

.csx .ba[data-mode="scrub"] .ba-step {
  grid-area: 1 / 1;
  align-content: center;
  min-width: 0;
  opacity: 0;
  pointer-events: none;
}

.csx .ba[data-mode="scrub"] .ba-step.is-current {
  pointer-events: auto;
}

.csx .ba[data-mode="scrub"] .ba-shot {
  width: calc(var(--ba-phone-h, 520px) * 1627 / 3356);
}

.csx .ba[data-mode="scrub"] .ba-shot .csx-device {
  height: var(--ba-phone-h, 520px);
  aspect-ratio: auto;
}

/* Phones: two screens fill the width; any more scroll sideways. */
.csx .ba[data-layout="stacked"] .ba-step {
  gap: 12px;
}

.csx .ba[data-mode="scrub"][data-layout="stacked"] .ba-shots {
  --ba-gap: 12px;
  --ba-arrow: 26px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding-inline: 4px;
}

.csx .ba[data-mode="scrub"][data-layout="stacked"] .ba-shots::-webkit-scrollbar {
  display: none;
}

.csx .ba[data-mode="scrub"][data-layout="stacked"] .ba-shot {
  scroll-snap-align: start;
}

.csx .ba[data-layout="stacked"] .ba-shot.is-before::after {
  width: 14px;
  height: 10px;
  top: calc(var(--ba-phone-h, 420px) / 2 - 5px);
  left: calc(100% + var(--ba-gap) / 2 + (var(--ba-arrow) - 14px) / 2);
}

.csx .ba[data-layout="stacked"] .ba-copy p:not(.ba-name, .ba-credit) {
  font-size: .95rem;
}

.csx .ba[data-layout="stacked"] .ba-name {
  margin-bottom: 6px;
  font-size: 1.6rem;
}

/* Phones: arrows and pixel squares under parts with more screens than fit
   (same look as the Final Design carousel). Swiping still works. */
.csx .ba-pager {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: -8px;
}

.csx .ba[data-mode="scrub"] .ba-step.has-more .ba-pager {
  display: flex;
}

.csx .ba-dots {
  display: flex;
}

.csx .ba-dot,
.csx .ba-arrow {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.csx .ba-dot {
  width: 30px;
}

.csx .ba-dot::before {
  content: "";
  width: 11px;
  height: 11px;
  box-shadow: inset 0 0 0 2px #b9b4a2;
}

.csx .ba-dot[aria-current="true"]::before {
  background: var(--blue);
  box-shadow: inset 0 0 0 2px var(--blue);
}

.csx .ba-arrow span {
  width: 10px;
  height: 16px;
  background: var(--blue);
  clip-path: polygon(0 43.75%, 20% 43.75%, 20% 31.25%, 40% 31.25%, 40% 18.75%, 60% 18.75%, 60% 6.25%, 80% 6.25%, 80% 0, 100% 0, 100% 100%, 80% 100%, 80% 93.75%, 60% 93.75%, 60% 81.25%, 40% 81.25%, 40% 68.75%, 20% 68.75%, 20% 56.25%, 0 56.25%);
}

.csx .ba-arrow[data-dir="1"] span {
  transform: scaleX(-1);
}

.csx .ba-arrow:disabled {
  cursor: default;
}

.csx .ba-arrow:disabled span {
  background: #c9c4b2;
}

.csx .ba-dot:focus-visible,
.csx .ba-arrow:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: -6px;
}

/* ---- Tabs: centred pixel words on a dotted line; the one you're on gets
        a blue pixel bar underneath ---- */
.csx .ba-tabs {
  position: relative;
  display: flex;
  justify-content: center;
  gap: clamp(4px, 1.2vw, 18px);
  width: max-content;
  max-width: 100%;
  margin: 0 auto 6px;
  padding: 0;
  list-style: none;
  background:
    repeating-linear-gradient(90deg, #b9b2a0 0 2px, #0000 2px 6px) left bottom / 100% 2px no-repeat;
}

.csx .ba-tabs[hidden] {
  display: none;
}

.csx .ba-tabs li {
  flex: none;
}

.csx .ba-tabs button {
  position: relative;
  min-height: 44px;
  padding: 4px 10px 10px;
  border: 0;
  background: none;
  color: #6a716c;
  font: 400 1.05rem/1 Determination, 'Pixelify Sans', monospace;
  white-space: nowrap;
  cursor: pointer;
}

/* the bar: 4px tall, the full width of the tab, sitting on the dotted line */
.csx .ba-tabs button::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: var(--blue);
  transform: scaleX(0);
  transition: transform .2s steps(4);
}

.csx .ba-tabs button:hover {
  color: var(--blue);
}

.csx .ba-tabs button[aria-current="true"] {
  color: var(--blue);
}

.csx .ba-tabs button[aria-current="true"]::after {
  transform: scaleX(1);
}

.csx .ba-tabs button:focus-visible {
  outline: 2px dashed var(--blue);
  outline-offset: 2px;
}

/* Narrow screens: one row of tabs that scrolls, centred when it fits. */
.csx .ba[data-layout="stacked"] .ba-tabs {
  justify-content: flex-start;
  gap: 2px;
  width: auto;
  overflow-x: auto;
  scrollbar-width: none;
  margin-inline: calc(-1 * var(--gutter));
  padding-inline: var(--gutter);
}

.csx .ba[data-layout="stacked"] .ba-tabs li:first-child { margin-left: auto; }
.csx .ba[data-layout="stacked"] .ba-tabs li:last-child  { margin-right: auto; }

.csx .ba[data-layout="stacked"] .ba-tabs::-webkit-scrollbar {
  display: none;
}

.csx .ba[data-layout="stacked"] .ba-tabs button {
  padding-inline: 8px;
  font-size: 1rem;
}

@media (prefers-reduced-motion: reduce) {
  .csx .ba-tabs button::after { transition: none; }
}
