/* ad-morph.css: the #feed phone and the Velle ad built three times (4:5 feed, 9:16 story, 1:1 grid).
   One live HTML ad whose parts move to each format's own layout. Sizes are in cqw of the ad (and of the
   plate for the bottle label), so the layout scales with the phone. Velle is Shresht's sample brand. */

.phone { --ease-m: cubic-bezier(.65, 0, .35, 1); --dur-m: 760ms;
  position: relative; width: min(284px, 100%, calc((min(680px, 84svh) - 64px) * 9 / 19)); height: auto; aspect-ratio: 9 / 19; flex: none;
  border-radius: 40px; border: 9px solid #17130f; background: #17130f; overflow: hidden;
  box-shadow: 0 40px 80px -36px rgb(0 0 0 / .5), inset 0 0 0 1px rgb(255 255 255 / .06); }
.phone__screen { position: absolute; inset: 0; border-radius: 31px; overflow: hidden; background: #fff;
  display: flex; flex-direction: column; transition: background-color var(--dur-m) var(--ease-m); }
.phone__bar { flex: none; height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px;
  font: 800 16px/1 var(--font-display); color: #17130f; border-bottom: 1px solid #eee; overflow: hidden;
  transition: height var(--dur-m) var(--ease-m), opacity 300ms ease; }
.phone__bar span { font: 500 13px/1 var(--font-text); color: #6a6560; }
.phone__feed { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior-y: auto; scrollbar-width: none; }   /* at the end of its feed the scroll carries on to the page, so the page never feels stuck */
.phone__feed::-webkit-scrollbar { display: none; }

.post { border-bottom: 1px solid #eee; padding-bottom: 10px; }
.post.is-off { visibility: hidden; }
.post__head { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; font: 500 13px/1.1 var(--font-text); color: #17130f; overflow: hidden;
  transition: height var(--dur-m) var(--ease-m), opacity 300ms ease; }
.post__head i { width: 26px; height: 26px; border-radius: 50%; background: var(--brand-grad); flex: none; }
.post__head small { display: block; color: #6a6560; font-size: 11px; margin-top: 2px; }
.post__head .dots { margin-left: auto; color: #6a6560; letter-spacing: 1px; }
.post__media { background: #000; aspect-ratio: 4 / 5; overflow: hidden; transition: aspect-ratio 500ms var(--ease-m); }
.post__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.phone[data-format="1x1"] .post__media { aspect-ratio: 1 / 1; }
.post__cta { display: flex; justify-content: space-between; align-items: center; margin: 0; padding: 10px 12px; background: #f3f1ee;
  font: 500 13px/1 var(--font-text); color: #17130f; }
.post__cta span::after { content: " \203A"; }
.post__acts { display: flex; gap: 14px; padding: 10px 12px 0; color: #17130f; }
.post__acts svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.post__likes { padding: 6px 12px 0; font: 500 12px/1 var(--font-text); color: #17130f; }

/* story mode: the feed chrome folds away, the screen goes black, the Velle ad sits centred with story chrome over it */
.phone[data-format="9x16"] .phone__screen { background: #000; }
.phone[data-format="9x16"] .phone__bar,
.phone[data-format="9x16"] .post--velle .post__head { height: 0; opacity: 0; border: 0; }
.phone[data-format="9x16"] .phone__feed { overflow: hidden; }
.phone[data-format="9x16"] .post:not(.post--velle),
.phone[data-format="9x16"] .post--velle .post__cta,
.phone[data-format="9x16"] .post--velle .post__acts,
.phone[data-format="9x16"] .post--velle .post__likes { display: none; }
.phone[data-format="9x16"] .post--velle { border: 0; padding: 0; }
.post--velle .vad { transition: height var(--dur-m) var(--ease-m), margin-top var(--dur-m) var(--ease-m); }
.phone[data-format="9x16"] .post--velle .vad { margin-top: var(--story-pad, 0px); }

.story { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0; transition: opacity 400ms ease; color: #fff; }
.phone[data-format="9x16"] .story { opacity: 1; transition-delay: 380ms; }
.story__bars { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 4px; }
.story__bars i { flex: 1; height: 2.5px; border-radius: 2px; background: rgb(255 255 255 / .35); overflow: hidden; }
.story__bars i::after { content: ""; display: block; height: 100%; width: 100%; background: #fff; transform: scaleX(0); transform-origin: left; }
.phone[data-format="9x16"] .story__bars i:first-child::after { animation: story-fill 6s linear 400ms forwards; }
@keyframes story-fill { to { transform: scaleX(1); } }
.story__who { position: absolute; top: 22px; left: 12px; right: 12px; display: flex; align-items: center; gap: 8px; font: 500 13px/1.1 var(--font-text); text-shadow: 0 1px 6px rgb(0 0 0 / .35); }
.story__who i { width: 26px; height: 26px; border-radius: 50%; background: var(--brand-grad); flex: none; border: 1.5px solid #fff; }
.story__who small { display: block; font-size: 11px; opacity: .85; margin-top: 2px; }
.story__who b { margin-left: auto; font-weight: 500; font-size: 18px; opacity: .9; }
.story__shop { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: grid; justify-items: center; gap: 4px; font: 500 12px/1 var(--font-text); }
.story__shop span { background: #fff; color: #17130f; padding: 9px 18px; border-radius: 999px; box-shadow: 0 4px 14px rgb(0 0 0 / .25); }
.story__shop svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; animation: story-nudge 1.6s ease-in-out infinite; }
@keyframes story-nudge { 50% { transform: translateY(-3px); } }
/* the nudge rests while it is off screen (home.js marks .story__shop.is-near); it ran 60 times a second for nobody */
html.sw-js .story__shop:not(.is-near) svg { animation-play-state: paused; }

/* ── the ad ─────────────────────────────────────────────────────────────── */
.vad { position: relative; container-type: inline-size; width: 100%; aspect-ratio: 4 / 5; overflow: hidden; isolation: isolate;
  background: linear-gradient(180deg, #b9cad2 0%, #bfced6 55%, #c5d2d8 100%); color: #121214; font-family: var(--font-text); }
@property --mL { syntax: '<percentage>'; inherits: false; initial-value: 0%; }
@property --mT { syntax: '<percentage>'; inherits: false; initial-value: 12%; }
@property --mB { syntax: '<percentage>'; inherits: false; initial-value: 88%; }
.vad > *, .vad__plate { position: absolute; transition-property: top, left, width, height, font-size, opacity, --mL, --mT, --mB;
  transition-duration: var(--dur-m); transition-timing-function: var(--ease-m); }
.vad__plate { container-type: inline-size; z-index: 0; aspect-ratio: 1200 / 1489; top: 0; left: 0; width: 100cqw;
  --mL: 0%; --mT: 12%; --mB: 88%;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 var(--mL)), linear-gradient(180deg, transparent 0%, #000 var(--mT), #000 var(--mB), transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(90deg, transparent 0%, #000 var(--mL)), linear-gradient(180deg, transparent 0%, #000 var(--mT), #000 var(--mB), transparent 100%);
  mask-composite: intersect; }
.vad__plate img { display: block; width: 100%; height: 100%; }
.vad__label { position: absolute; left: 38.15%; top: 53.8%; width: 24.35%; height: 20.49%; mix-blend-mode: multiply; color: #1c1b1a; text-align: center; }
.vad__label b { position: absolute; left: 0; right: 0; top: 22%; font: 800 6.2cqw/1 var(--font-display); letter-spacing: -.05em; }
.vad__label em { position: absolute; left: 0; right: 0; top: 50%; font: 500 1.25cqw/1 ui-monospace, Menlo, monospace; letter-spacing: .14em; font-style: normal; }
.vad__label hr { position: absolute; left: 30%; right: 30%; top: 60%; margin: 0; border: 0; height: 1px; background: #1c1b1a; opacity: .5; }
.vad__label small { position: absolute; left: 0; right: 0; bottom: 12%; font: 500 1.1cqw/1 ui-monospace, Menlo, monospace; letter-spacing: .14em; opacity: .75; }

.vad__brand { z-index: 2; top: 6cqw; left: 6cqw; font: 800 5.4cqw/1 var(--font-display); letter-spacing: -.05em; }
.vad__head { z-index: 2; margin: 0; top: 15cqw; left: 6cqw; width: 88cqw; font: 800 8cqw/1.02 var(--font-display); letter-spacing: -.045em; text-align: left; }
.vad__sub { z-index: 2; margin: 0; top: 33.5cqw; left: 6cqw; width: 88cqw; font-size: 3.7cqw; line-height: 1.25; color: #2c2c30; text-align: left; }
.vad__proof { z-index: 2; margin: 0; top: 113.5cqw; left: 6cqw; width: 50cqw; font-size: 2.9cqw; line-height: 1.2; font-weight: 500; color: #2c2c30; text-align: left; }
.vad__proof span { color: #121214; letter-spacing: .06em; }
.vad__cta { z-index: 2; top: 111cqw; left: 64cqw; width: 30cqw; height: 8.6cqw; display: grid; place-items: center; border-radius: 99px;
  background: #121214; color: #fff; font-size: 3.3cqw; font-weight: 500; white-space: nowrap; }

/* 9:16: centred, the bottle lower, room left for the story bar (top) and the platform's button (bottom) */
.phone[data-format="9x16"] .vad { aspect-ratio: 9 / 16; }
.phone[data-format="9x16"] .vad__plate { width: 112cqw; left: -6cqw; top: 14cqw; --mT: 14%; --mB: 86%; }
.phone[data-format="9x16"] .vad__brand { top: 25cqw; left: 41.5cqw; font-size: 6cqw; }
.phone[data-format="9x16"] .vad__head { top: 33cqw; left: 4cqw; width: 92cqw; font-size: 9cqw; text-align: center; }
.phone[data-format="9x16"] .vad__sub { top: 53.5cqw; left: 4cqw; width: 92cqw; font-size: 4cqw; text-align: center; }
.phone[data-format="9x16"] .vad__proof { top: 60cqw; left: 20cqw; width: 60cqw; font-size: 3.2cqw; text-align: center; }
.phone[data-format="9x16"] .vad__cta { top: 140cqw; left: 30cqw; width: 40cqw; height: 10cqw; font-size: 3.8cqw; }

/* 1:1: headline across the top, the bottle to the right, the button bottom left */
.phone[data-format="1x1"] .vad { aspect-ratio: 1 / 1; }
.phone[data-format="1x1"] .vad__plate { width: 96cqw; left: 30cqw; top: -14cqw; --mL: 24%; --mT: 0%; --mB: 86%; }
.phone[data-format="1x1"] .vad__brand { top: 6cqw; left: 6cqw; font-size: 5cqw; }
.phone[data-format="1x1"] .vad__head { top: 14cqw; left: 6cqw; width: 88cqw; font-size: 7.4cqw; }
.phone[data-format="1x1"] .vad__sub { top: 31cqw; left: 6cqw; width: 52cqw; font-size: 3.5cqw; }
.phone[data-format="1x1"] .vad__proof { top: 41cqw; left: 6cqw; width: 46cqw; font-size: 2.8cqw; }
.phone[data-format="1x1"] .vad__cta { top: 84cqw; left: 6cqw; width: 30cqw; height: 8.4cqw; font-size: 3.2cqw; }

/* a format change: the text dips and re-lands in its new place (the parts move, the words never snap) */
.vad.is-moving .vad__head, .vad.is-moving .vad__sub, .vad.is-moving .vad__proof, .vad.is-moving .vad__brand { opacity: 0; }
.vad .vad__head, .vad .vad__sub, .vad .vad__proof, .vad .vad__brand { transition-duration: var(--dur-m), var(--dur-m), var(--dur-m), var(--dur-m), var(--dur-m), 240ms; }

@media (prefers-reduced-motion: reduce) {
  .phone *, .vad > *, .vad__plate { transition: none !important; animation: none !important; }
}
