/* Intro stories (js/stories.js). Fixed brand colours on purpose: each story is a poster of its own,
   whatever the theme. Flat fills only. */
.stories { --cream: #F1E6D2; --paper: #EFE4CF; position: fixed; inset: 0; z-index: 90; overflow: hidden;
  color: var(--cream); background: var(--navy); touch-action: none; user-select: none; -webkit-user-select: none; transition: transform .2s var(--ease); }
.stories[data-tone="cream"] { color: var(--navy); }
.stories__top { position: absolute; left: 0; right: 0; top: 0; z-index: 2;
  padding: calc(var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px) + 10px) 12px 0;
  transition: opacity .2s var(--ease-io); }
.stories.is-held .stories__top { opacity: 0; }
.stories__bars { display: flex; gap: 4px; }
.stories__bar { position: relative; flex: 1; height: 3px; border-radius: 2px; overflow: hidden; }
.stories__bar::before { content: ""; position: absolute; inset: 0; background: currentColor; opacity: .28; }
.stories__bar i { position: absolute; inset: 0; background: currentColor; transform: scaleX(0); transform-origin: left; }
.stories__head { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.stories__head .brand__mark { width: 26px; height: 26px; }
.stories__brand { flex: 1; font: 600 15px/1 var(--font-serif); letter-spacing: .02em; }
.stories__close { width: 40px; height: 40px; margin-right: -8px; display: grid; place-items: center; color: inherit; }
.stories__close .ic { width: 22px; height: 22px; }

.story { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: calc(var(--tg-safe-area-inset-top, env(safe-area-inset-top, 0px)) + var(--tg-content-safe-area-inset-top, 0px) + 72px) 28px calc(var(--safe-b) + 34px);
  opacity: 0; visibility: hidden; transition: opacity .35s var(--ease-io), visibility 0s .35s; }
.story.is-active { opacity: 1; visibility: visible; transition: opacity .35s var(--ease-io); }
.story--navy { background: var(--navy); color: var(--cream); }
.story--bordeaux { background: var(--bordeaux); color: #F8F1E3; }
.story--vinyl { background: #1A1410; color: var(--cream); }
.story--cream { background: var(--paper); color: var(--navy); }
.story__art { flex: 1; width: 100%; min-height: 0; display: grid; place-items: center; }
.story__copy { width: 100%; max-width: 380px; }
.story__title { margin: 0; font: 600 32px/1.12 var(--font-serif); letter-spacing: -.01em; }
.story__text { margin: 12px 0 0; font-size: 16px; line-height: 1.45; opacity: .84; }
.story__cta { margin-top: 24px; width: 100%; height: 52px; font-size: 16px; background: #F8F1E3; color: var(--bordeaux); }
.story__cta { display: flex; align-items: center; justify-content: center; gap: 8px; }
.story__cta .ic { width: 20px; height: 20px; }
.story__later { display: block; width: 100%; margin-top: 12px; height: 44px; color: #F3E7D3; font-size: 14px; opacity: .8; }
.sx-hero { position: relative; }
.sx-heart { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px; display: grid; place-items: center; border-radius: 50%; background: #F8F1E3; color: var(--bordeaux); }
.sx-heart .ic { width: 32px; height: 32px; fill: currentColor; stroke: none; }
.sx-hero--small .ic { width: 120px; height: 120px; stroke-width: 1; color: #F3E7D3; }
.story__cta:active { background: var(--paper); }
.story.is-active .story__art { animation: st-pop .6s var(--ease) both; }
.story.is-active .story__copy { animation: st-up .5s var(--ease) .08s both; }
@keyframes st-pop { from { opacity: 0; transform: scale(.92); } }
@keyframes st-up { from { opacity: 0; transform: translateY(14px); } }

/* the record */
.sx-record { display: block; width: min(66vw, 290px); height: auto; }
.sx-record .rim { fill: #0A0806; stroke: rgba(255, 240, 220, .14); stroke-width: 1.5; }
.sx-record .g { fill: none; stroke: rgba(255, 240, 220, .08); stroke-width: 1; }
.sx-record .s { fill: rgba(255, 240, 220, .06); }
.sx-record .l { fill: var(--bordeaux); }
.sx-record .lr { fill: none; stroke: rgba(255, 255, 255, .25); stroke-width: 1; }
.sx-record .h { fill: #EFE4CF; }
.story.is-active .sx-spin { animation: st-spin 1.8s linear infinite; }
@keyframes st-spin { to { transform: rotate(360deg); } }

/* search */
.sx-search { width: min(84vw, 340px); text-align: left; }
.sx-bar { display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 16px; border-radius: var(--r-md);
  background: rgba(255, 255, 255, .14); font-size: 17px; font-weight: 500; }
.sx-bar .ic { width: 20px; height: 20px; flex: none; opacity: .8; }
.sx-type { display: inline-block; overflow: hidden; white-space: nowrap; max-width: 14ch; }
.story.is-active .sx-type { animation: st-type 1.3s steps(var(--n, 8)) .35s both; }
@keyframes st-type { from { max-width: 0; } to { max-width: 14ch; } }
.sx-caret { width: 2px; height: 22px; margin-left: -8px; background: currentColor; animation: st-blink 1s steps(1) infinite; }
@keyframes st-blink { 50% { opacity: 0; } }
.sx-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.sx-row b { width: 48px; height: 48px; flex: none; border-radius: var(--r-sm); background: rgba(255, 255, 255, .2); }
.sx-row span { flex: 1; }
.sx-row i { display: block; width: 72%; height: 10px; border-radius: 5px; background: rgba(255, 255, 255, .26); }
.sx-row i + i { width: 44%; margin-top: 8px; opacity: .6; }
.story.is-active .sx-row { animation: st-up .45s var(--ease) both; animation-delay: calc(1.75s + var(--d)); }

/* turning and swiping the record */
.sx-hand { display: flex; align-items: center; gap: 6px; }
.sx-hand .sx-record { width: min(58vw, 250px); }
.sx-arrow { display: grid; place-items: center; opacity: .55; }
.sx-arrow .ic { width: 26px; height: 26px; }
.story.is-active .sx-scrub { animation: st-scrub 3s var(--ease-io) infinite; }
.story.is-active .sx-arrow--l { animation: st-nudge-l 1.6s var(--ease-io) infinite; }
.story.is-active .sx-arrow--r { animation: st-nudge-r 1.6s var(--ease-io) infinite; }
@keyframes st-scrub { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-80deg); } 60% { transform: rotate(50deg); } }
@keyframes st-nudge-l { 50% { transform: translateX(-6px); opacity: 1; } }
@keyframes st-nudge-r { 50% { transform: translateX(6px); opacity: 1; } }

/* library */
.sx-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: min(84vw, 340px); }
.sx-tile { aspect-ratio: 1.2; padding: 16px; border-radius: var(--r-md); background: var(--navy); color: var(--cream);
  display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; font-weight: 600; font-size: 15px; text-align: left; }
.sx-tile:nth-child(2), .sx-tile:nth-child(3) { background: var(--bordeaux); }
.sx-tile .ic { width: 28px; height: 28px; }
.story.is-active .sx-tile { animation: st-pop .5s var(--ease) both; animation-delay: calc(.25s + var(--d)); }

/* equalizer */
.sx-eq { display: flex; gap: 20px; height: min(34vh, 230px); }
.sx-f { width: 34px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.sx-f span { position: relative; flex: 1; width: 4px; border-radius: 2px; background: rgba(241, 230, 210, .22); }
.sx-f b { position: absolute; left: 50%; top: var(--a); width: 30px; height: 14px; margin-top: -7px; border-radius: 4px; background: var(--cream); transform: translateX(-50%); }
.story.is-active .sx-f b { animation: st-fader 2.8s var(--ease-io) var(--d) infinite; }
@keyframes st-fader { 50% { top: var(--b); } }
.sx-f small { font-size: 11px; opacity: .7; font-variant-numeric: tabular-nums; }

/* slowed + reverb: a slow record, rings of echo around it, the speeds and the name of the sound */
.sx-sound { display: grid; justify-items: center; gap: 26px; }
.sx-rings { position: relative; display: grid; place-items: center; }
.sx-rings .sx-record { position: relative; width: min(52vw, 220px); }
.sx-rings i { position: absolute; inset: 0; margin: auto; width: min(52vw, 220px); aspect-ratio: 1; border-radius: 50%;
  border: 1.5px solid rgba(248, 241, 227, .55); opacity: 0; }
.story.is-active .sx-slow { animation: st-spin 5.2s linear infinite; }
.story.is-active .sx-rings i { animation: st-ring 3.3s var(--ease-io) infinite; }
.story.is-active .sx-rings i:nth-child(2) { animation-delay: 1.1s; }
.story.is-active .sx-rings i:nth-child(3) { animation-delay: 2.2s; }
@keyframes st-ring { 0% { transform: scale(.96); opacity: .6; } 100% { transform: scale(1.65); opacity: 0; } }
.sx-chips { display: flex; gap: 8px; }
.sx-chip { min-width: 64px; padding: 9px 14px; border-radius: var(--r-sm); background: rgba(255, 255, 255, .14); font: 600 15px/1 var(--font-serif); font-variant-numeric: tabular-nums; }
.sx-chip.is-on { background: #F8F1E3; color: var(--bordeaux); }
.sx-pill { padding: 8px 16px; border-radius: 999px; border: 1.5px solid rgba(248, 241, 227, .5); font: 600 14px/1 var(--font-sans); letter-spacing: .04em; }
.story.is-active .sx-chips { animation: st-up .45s var(--ease) .5s both; }
.story.is-active .sx-pill { animation: st-up .45s var(--ease) .85s both; }

/* customization: records in five colours and the seven themes */
.sx-custom { display: grid; justify-items: center; gap: 34px; }
.sx-discs { display: flex; }
.sx-disc { position: relative; width: min(24vw, 96px); aspect-ratio: 1; margin-left: max(-9vw, -36px); border-radius: 50%; background: var(--c);
  box-shadow: 0 0 0 1px rgba(255, 240, 220, .14), 0 8px 18px rgba(0, 0, 0, .45); }
.sx-disc:first-child { margin-left: 0; }
.sx-disc::before { content: ""; position: absolute; inset: 14%; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .3); }
.sx-disc::after { content: ""; position: absolute; inset: 36%; border-radius: 50%; background: var(--bordeaux); box-shadow: 0 0 0 2px rgba(255, 255, 255, .2); }
.sx-themes { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 314px; } /* thirteen themes: two rows of seven */
.sx-theme { display: grid; grid-template-columns: 1fr 1fr; width: min(9vw, 36px); height: min(9vw, 36px); border-radius: var(--r-sm); overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255, 240, 220, .18); }
.story.is-active .sx-disc { animation: st-up .5s var(--ease) both; animation-delay: var(--d); }
.story.is-active .sx-theme { animation: st-pop .45s var(--ease) both; animation-delay: var(--d); }

/* chat */
.sx-chat { width: min(84vw, 340px); display: grid; gap: 12px; text-align: left; }
.sx-msg { justify-self: end; max-width: 80%; padding: 10px 14px; border-radius: 16px 16px 4px 16px; background: #F8F1E3; color: var(--bordeaux); font-weight: 600; }
.sx-audio { justify-self: start; display: flex; align-items: center; gap: 12px; padding: 10px 16px 10px 10px; border-radius: 16px 16px 16px 4px; background: rgba(255, 255, 255, .16); }
.sx-play { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 50%; background: #F8F1E3; color: var(--bordeaux); }
.sx-play .ic { width: 20px; height: 20px; }
.sx-audio__meta { display: grid; gap: 6px; font-size: 14px; }
.sx-wave { display: flex; align-items: center; gap: 2px; height: 16px; }
.sx-wave i { width: 3px; border-radius: 2px; background: currentColor; opacity: .7; }
.story.is-active .sx-msg { animation: st-up .4s var(--ease) .3s both; }
.story.is-active .sx-audio { animation: st-up .45s var(--ease) 1.1s both; }

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

/* the players slide: the six of them, appearing one after another */
.sx-players { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px 22px; }
.sx-player { display: flex; flex-direction: column; align-items: center; gap: 8px; color: #F3E7D3; }
.sx-player .ic { width: 52px; height: 52px; stroke-width: 1.3; }
.sx-player small { font-size: 12px; opacity: .8; }
.story.is-active .sx-player { animation: st-pop .45s var(--ease) both; animation-delay: var(--d); }

/* the first page: a record with the other machines going round it */
.sx-hero { position: relative; width: min(72vw, 300px); aspect-ratio: 1; display: grid; place-items: center; }
.sx-hero .sx-record { width: 58%; }
.sx-orbit { position: absolute; inset: 0; animation: sx-orbit 24s linear infinite; }
.sx-orbit__item { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px; display: grid; place-items: center; border-radius: 50%;
  background: #F8F1E3; color: var(--navy); transform: rotate(calc(var(--i) * 45deg)) translateY(calc(min(72vw, 300px) * -.46)) rotate(calc(var(--i) * -45deg)); }
.sx-orbit__item .ic { width: 28px; height: 28px; stroke-width: 1.5; animation: sx-orbit 24s linear infinite reverse; }
@keyframes sx-orbit { to { transform: rotate(360deg); } }
.sx-orbit__item:nth-child(2n) { background: var(--bordeaux); color: #F8F1E3; }

/* the radio page: a Fiat 500 in the rain, the decades running by, the seven countries */
.sx-radio { width: min(86vw, 380px); display: flex; flex-direction: column; gap: 14px; }
.sx-radio__car { position: relative; border-radius: 18px 18px 6px 6px; overflow: hidden; }
.sx-radio__car .rx-art { display: block; width: 100%; height: auto; overflow: hidden; margin-top: -7.5%; } /* the dash starts 30 of 400 down */
.sx-radio__glass { display: block; height: 70px; background: #7F97A4; position: relative; overflow: hidden; }
.sx-radio__glass i { position: absolute; bottom: -2px; width: 52%; height: 4px; background: #151515; border-radius: 3px; transform-origin: 2% 50%; animation: rx-wipe 3s var(--ease-io) infinite; }
.sx-radio__glass i:first-child { left: 4%; } .sx-radio__glass i:last-child { left: 50%; }
.sx-radio__home { padding: 6px 12px 0; }
.sx-radio__home .rx-art { display: block; width: 100%; height: auto; max-height: 190px; }
.sx-radio__drive { display: grid; place-items: center; height: 120px; color: #F3E7D3; }
.sx-radio__drive .ic { width: 96px; height: 96px; stroke-width: 1.2; }
.story.is-active .sx-radio__drive .ic { animation: sx-wheel 6s var(--ease-io) infinite; }
@keyframes sx-wheel { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-70deg); } 70% { transform: rotate(70deg); } }
.sx-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sx-steps li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: #F8F1E31A; color: #F3E7D3; font-size: 13px; font-weight: 600; line-height: 1.3; }
.sx-steps b { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #F8F1E3; color: var(--navy); font-size: 12px; }
.story.is-active .sx-steps li { animation: st-pop .45s var(--ease) both; animation-delay: calc(.4s + var(--i) * .25s); }
.sx-radio__years { display: flex; justify-content: space-between; font: 700 13px/1 var(--font-serif); color: #F3E7D3; }
.sx-radio__years b { opacity: .3; }
.story.is-active .sx-radio__years b { animation: sx-year 4s linear both; animation-delay: calc(var(--i) * .5s); }
@keyframes sx-year { 0%, 100% { opacity: .3; } 10%, 25% { opacity: 1; color: #F2C14E; } }
.sx-radio__flags { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.sx-radio__flags span { padding: 5px 9px; border-radius: 6px; background: #F8F1E31A; color: #F3E7D3; font-size: 12px; font-weight: 600; }
.story.is-active .sx-radio__flags span { animation: st-pop .45s var(--ease) both; animation-delay: calc(.6s + var(--i) * .08s); }
@keyframes rx-wipe { 0%, 60%, 100% { transform: rotate(-4deg); } 30% { transform: rotate(-150deg); } }

/* the last page: the players to choose from */
.sx-pick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; width: min(86vw, 380px); }
.sx-pick__item { display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 10px 12px; border-radius: 10px; background: #F8F1E314;
  color: #F3E7D3; text-align: left; font-size: 14px; font-weight: 600; box-shadow: inset 0 0 0 1px #F8F1E333; }
.sx-pick__item .ic { width: 30px; height: 30px; flex: none; stroke-width: 1.4; }
.sx-pick__item.is-on { background: #F8F1E3; color: var(--navy); }
@media (prefers-reduced-motion: reduce) { .sx-orbit, .sx-orbit__item .ic, .sx-radio__glass i, .sx-radio__drive .ic { animation: none; } }

/* A record halfway out of its printed sleeve. */
.sx-sleeve { width: min(78vw, 360px, 52vh); aspect-ratio: 1.4; position: relative; }
.sx-sleeve .sx-record { position: absolute; width: 70%; right: 0; top: 1%; }
.sx-sleeve__front { position: absolute; inset: 0 auto 0 0; aspect-ratio: 1; background: var(--bordeaux); color: var(--cream); padding: var(--s4); display: grid; align-content: space-between; text-align: left; box-shadow: 3px 2px 0 var(--navy); }
.sx-sleeve__front b { font: 600 clamp(56px, 16vw, 100px)/1 var(--font-serif); }
.sx-sleeve__front span { border-top: 3px double currentColor; padding-top: var(--s2); font-family: var(--font-serif); }
