/* ------------------------------------------------------------------
   Case studies: the story card slides out from behind a phone that plays
   the client's ads as Instagram-style feed posts (js/stories.js). The phone
   and feed post are a port of ms-web /work's mock-up: the frame scales from
   /work's 651px-tall phone (--u = 1/341.54 of the frame width), and each
   post is drawn at a 390-wide logical screen scaled to fit (--s).
   ------------------------------------------------------------------ */
.stories { --ss-phone-w: 225px; --ss-overlap: 63px; margin-top: -49px; padding: 0 0 77px; }
.ss-stage { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) calc(var(--ss-phone-w) - var(--ss-overlap)); align-items: center; }
.ss-stage .stories-viewport { min-height: 0; }
.ss-stage .ss-slide { grid-template-columns: 1fr; gap: 0; }
.ss-stage .ss-copy { padding-right: calc(46px + var(--ss-overlap)); }

/* frame: /work's .phone (9 : 19.5, 651px tall there) */
.ss-phone {
  --u: calc(var(--ss-phone-w) / 341.54);
  width: var(--ss-phone-w); aspect-ratio: 9 / 19.5; box-sizing: border-box;
  padding: calc(11 * var(--u)); border-radius: calc(52 * var(--u));
  background: #0B0F13;
  box-shadow: 0 0 0 1.5px #39434d, 0 40px 90px -30px #000;
  margin-left: calc(var(--ss-overlap) * -1); position: relative; z-index: 2;
}
.ss-screen { position: relative; width: 100%; height: 100%; overflow: hidden; border-radius: calc(42 * var(--u)); background: #fff; color: #111; }
.ss-island { position: absolute; z-index: 6; top: calc(11 * var(--u)); left: 50%; transform: translateX(-50%); width: 31%; height: calc(27 * var(--u)); border-radius: calc(20 * var(--u)); background: #000; }
.ss-media, .ss-item { position: absolute; inset: 0; }
.ss-item { opacity: 0; transition: opacity .35s ease; }
.ss-item.on { opacity: 1; }

/* feed post: /work's .ig.feed at 390 logical px, scaled to the screen by --s (set in js) */
.ss-phone .ig { position: absolute; left: 0; top: 0; width: 390px; height: calc(100% / var(--s)); transform: scale(var(--s)); transform-origin: 0 0; display: flex; flex-direction: column; overflow: hidden; background: #fff; color: #000; font-family: -apple-system, "SF Pro Text", "Helvetica Neue", Roboto, sans-serif; font-size: 14px; -webkit-font-smoothing: antialiased; }
.ss-phone .ig::after { content: ""; position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); width: 134px; height: 5px; border-radius: 3px; background: #000; z-index: 9; }
.ss-phone .ig .sbar { height: 47px; display: flex; align-items: center; justify-content: space-between; padding: 14px 30px 0 40px; font-weight: 600; font-size: 17px; position: relative; z-index: 5; flex-shrink: 0; }
.ss-phone .ig svg { width: 24px; height: 24px; flex-shrink: 0; }
.ss-phone .ig .sbar svg { width: 66px; height: 13px; }
.ss-phone .ig .av { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px rgba(0, 0, 0, .1); display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .02em; flex-shrink: 0; }
.ss-phone .ig .ig-ph { height: 54px; display: flex; align-items: center; gap: 10px; padding: 0 12px; flex-shrink: 0; }
.ss-phone .ig .who { min-width: 0; }
.ss-phone .ig .who b { display: block; font-size: 14px; font-weight: 600; line-height: 18px; }
.ss-phone .ig .who small { display: block; font-size: 12px; color: #737373; line-height: 16px; }
.ss-phone .ig .dots3 { margin-left: auto; }
.ss-phone .ig .hsk { display: block; width: 110px; height: 10px; border-radius: 5px; background: #E6E6E6; margin: 4px 0; }
.ss-phone .ig .skel { padding: 2px 12px 0; display: grid; gap: 8px; }
.ss-phone .ig .skel i { display: block; height: 10px; border-radius: 5px; background: #EFEFEF; }
/* not scrollable: the tap zones cover the screen, and a scroller would become a tab stop */
.ss-phone .fscroll { flex: 1; overflow: hidden; }
.ss-phone .prevpost { height: 56px; position: relative; flex-shrink: 0; }
.ss-phone .prevpost i { position: absolute; display: block; background: #EFEFEF; }
.ss-phone .prevpost .pp1 { left: 0; right: 0; top: 0; height: 14px; }
.ss-phone .prevpost .pp2 { left: 12px; top: 22px; width: 96px; height: 16px; border-radius: 6px; }
.ss-phone .prevpost .pp3 { left: 12px; top: 44px; width: 60%; height: 8px; border-radius: 4px; }
.ss-phone .pmedia { position: relative; background: #f3f3f3; }
.ss-phone .pmedia img, .ss-phone .pmedia video { display: block; width: 100%; height: 100%; object-fit: cover; }
.ss-phone .fm { overflow: hidden; aspect-ratio: 1 / 1.25; }
.ss-phone .fcta { height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px 0 14px; font-weight: 600; border-bottom: 1px solid #DBDBDB; }
.ss-phone .fcta svg { width: 18px; height: 18px; }
/* the CTA bar turns blue 1.5s after each post comes on, as on /work */
@media (prefers-reduced-motion: no-preference) {
  .ss-phone .ss-item.on .fcta { animation: ctaon .35s ease 1.5s forwards; }
}
@media (prefers-reduced-motion: reduce) {
  .ss-phone .fcta { background: #0095F6; color: #fff; border-color: #0095F6; }
}
@keyframes ctaon { to { background: #0095F6; color: #fff; border-color: #0095F6; } }
.ss-phone .fa { height: 46px; display: flex; align-items: center; gap: 16px; padding: 0 12px; flex-shrink: 0; }
.ss-phone .fa .sv { margin-left: auto; }
.ss-phone .capt { position: relative; padding: 0 12px; line-height: 18px; }
.ss-phone .capt .ct { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.ss-phone .capt .ct b { font-weight: 600; }
.ss-phone .capt .mr { position: absolute; right: 12px; bottom: 0; padding-left: 30px; color: #737373; background: linear-gradient(90deg, rgba(255, 255, 255, 0), #fff 24px); }
.ss-phone .nextp { margin-top: 18px; }
.ss-phone .ig .av.sk { background: #EFEFEF; box-shadow: none; }
.ss-phone .nextimg { display: block; height: 390px; background: #EFEFEF; }
.ss-phone .ig-nav { height: 84px; flex-shrink: 0; margin-top: auto; display: flex; justify-content: space-around; align-items: flex-start; padding-top: 11px; border-top: 1px solid #DBDBDB; background: #fff; color: #000; position: relative; z-index: 3; }
.ss-phone .ig-nav svg { width: 26px; height: 26px; }
.ss-phone .ig-nav .me { width: 26px; height: 26px; border-radius: 50%; background: #DBDBDB; }

.ss-tap { position: absolute; top: 0; bottom: 0; z-index: 2; border: 0; background: transparent; cursor: pointer; padding: 0; }
.ss-tap.prev { left: 0; width: 33%; }
.ss-tap.next { right: 0; width: 67%; }
.ss-tap:focus-visible { outline: 2px solid var(--btn); outline-offset: -4px; }

.ss-tabs { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 28px; margin-bottom: 49px; }
.ss-tabs [role="tab"] { position: relative; background: none; border: 0; padding: 10px 2px 12px; cursor: pointer; opacity: .45; filter: grayscale(1); transition: opacity .3s, filter .3s; }
.ss-tabs [role="tab"][aria-selected="true"], .ss-tabs [role="tab"]:hover { opacity: 1; filter: none; }
.ss-tabs [role="tab"]:focus-visible { outline: 2px solid var(--btn); outline-offset: 4px; border-radius: 4px; }
.ss-tabs img { height: 19px; width: auto; max-width: 123px; object-fit: contain; display: block; }
.ss-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--line); overflow: hidden; }
.ss-fill::after { content: ""; position: absolute; inset: 0; background: var(--accent); transform: scaleX(var(--p, 0)); transform-origin: left; transition: transform var(--t, 0s) linear; }

/* phone and tablet: the phone sits above the card, centred, overlapping its top edge */
@media (max-width: 1199px) {
  .stories { --ss-phone-w: 208px; --ss-overlap: 42px; padding-bottom: 56px; }
  .ss-stage { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .ss-phone { order: -1; margin: 0 0 calc(var(--ss-overlap) * -1); }
  .ss-stage .stories-viewport { width: 100%; }
  .ss-stage .ss-copy { padding: calc(35px + var(--ss-overlap)) 35px 35px; }
  .ss-tabs { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; gap: 21px; padding: 0 4px; margin: 0 0 28px; }
  .ss-tabs::-webkit-scrollbar { display: none; }
  .ss-tabs [role="tab"] { flex: none; }
}
@media (max-width: 600px) {
  .ss-stage .ss-copy { padding: calc(28px + var(--ss-overlap)) 18px 28px; }
}
