/* Bolt case study. The layout (sidebar, slides, grid) is shared: case.css and
   case.js. This file holds each slide's backdrop (.stage) in Bolt's colours and
   the pieces laid out on it: images cut from 2x exports of the Figma files
   "Website Bolt" and "Portal Designs". */

:root {
  --night: #43006d; /* the footer and page heroes */
  --violet: #9c32ff;
  --mint: #00f0c8;
  --lilac: #e3d9ff;
  --yellow: #f6df48;
  --cream: #fefef4; /* the portal's own background: the swipe tiles blend into it */
  --pad: clamp(20px, 5vw, 64px);
  --screen-shadow: 0 30px 70px rgba(30, 0, 50, 0.28), 0 6px 16px rgba(30, 0, 50, 0.14);
}

img {
  -webkit-user-drag: none;
}

/* Below 900 px the page is one 1fr column, which won't shrink below its content's
   minimum width; a slide with an aspect ratio and a set height (case.js) has a
   minimum width of height x ratio, so the column would grow with every snap. */
.case-body {
  min-width: 0;
}

/* ── Stages ─────────────────────────────────────────────── */

.stage {
  position: relative;
  overflow: hidden;
  padding: var(--pad);
}

.stage-night { background: var(--night); }
.stage-violet { background: var(--violet); }
.stage-mint { background: var(--mint); }
.stage-lilac { background: var(--lilac); }
.stage-yellow { background: var(--yellow); }
.stage-cream { background: var(--cream); }
.stage-mist { background: #ecebe4; } /* the design system's own documentation grey: every brand colour shows on it */

/* ── 1. Homepage ────────────────────────────────────────── */

/* The slide has a set shape; the page (the hero and everything below it) runs
   off its bottom edge and scrolls through it. */
.shot-hero {
  width: 100%;
  aspect-ratio: 1000 / 580;
}

.shot > .stage.hero {
  justify-content: flex-start;
  padding-bottom: 0;
}

.hero-screen {
  position: relative;
  z-index: 1;
  flex-shrink: 0; /* the whole page, running off the slide's bottom edge */
  width: 88%;
  margin: 0 auto;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.45), 0 6px 18px rgba(0, 0, 0, 0.2);
  transform-origin: 50% 0;
}

.hero-screen img {
  width: 100%;
}

/* The homepage's hero (1440 x 738 design px), rebuilt from its layers, without
   the language bar at its top (40 px): everything moves up by --cut. Each
   .layer is placed from its design px: --x, --y and --w, as shares of 1440. */
.site-hero {
  --cut: 40;
  position: relative;
  aspect-ratio: 1440 / 698;
  overflow: hidden;
  background: var(--night);
  container-type: inline-size;
}

.site-hero .layer {
  position: absolute;
  left: calc(var(--x) / 1440 * 100cqw);
  top: calc((var(--y) - var(--cut)) / 1440 * 100cqw);
  width: calc(var(--w) / 1440 * 100cqw);
  height: auto;
  max-width: none;
}

.site-hero .heart {
  will-change: transform;
}

/* each headline line rises out of its own slot */
.site-hero .line {
  overflow: hidden;
  padding-block: calc(8 / 1440 * 100cqw);
  margin-top: calc(-8 / 1440 * 100cqw);
}

.site-hero .line img {
  display: block;
  width: 100%;
}

/* The form and the navigation sit on progressive blurs, as in Figma: bands of
   stronger blur, each masked to a stretch of the gradient. */
.site-form,
.site-nav {
  position: absolute;
  left: 0;
  width: 100%;
}

.site-form {
  top: calc((463 - var(--cut)) / 1440 * 100cqw);
  height: calc(275 / 1440 * 100cqw);
}

.site-nav {
  top: calc(var(--cut) / -1440 * 100cqw);
  height: calc(172 / 1440 * 100cqw);
}

/* The shading sits in its own layer, so the pieces fade in one by one: fading
   the whole frame would make it the blurs' backdrop and switch them off mid-fade. */
.shade {
  position: absolute;
  inset: 0;
}

.site-form .shade {
  background: linear-gradient(to bottom, rgba(67, 0, 109, 0), var(--night));
}

.site-nav .shade {
  background:
    linear-gradient(rgba(100, 9, 157, 0.85), rgba(100, 9, 157, 0.85)) 0 0 / 100% calc(40 / 172 * 100%) no-repeat,
    linear-gradient(to bottom, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0));
}

.site-nav img {
  position: absolute;
  inset: 0 0 auto;
}

.blur-band {
  position: absolute;
  inset: 0;
  -webkit-backdrop-filter: blur(var(--b));
  backdrop-filter: blur(var(--b));
  -webkit-mask-image: linear-gradient(var(--dir), transparent var(--s0), #000 var(--s1));
  mask-image: linear-gradient(var(--dir), transparent var(--s0), #000 var(--s1));
}

.site-form .blur-band { --dir: to bottom; }
.site-nav .blur-band { --dir: to top; }
.blur-band:nth-child(2) { --b: calc(3 / 1440 * 100cqw); --s0: 0%; --s1: 30%; }
.blur-band:nth-child(3) { --b: calc(8 / 1440 * 100cqw); --s0: 25%; --s1: 60%; }
.blur-band:nth-child(4) { --b: calc(20 / 1440 * 100cqw); --s0: 55%; --s1: 95%; }

/* the rest of the page, below the hero */
.site-page {
  display: block;
}

/* ── 2. Phones ──────────────────────────────────────────── */

/* The shapes go on the slide, not its stretched backdrop (Firefox), with a width
   so a set height doesn't turn the ratio into a width (Chrome). */
.shot-phone {
  min-width: 0;
}

.shot-phone {
  width: 100%;
  aspect-ratio: 4 / 5;
}

.shot-phone > .stage {
  align-items: center;
  padding: clamp(20px, 3vw, 40px);
}

/* Sized by the tile's height, so both phones match although the tiles' widths
   differ by a gutter. */
.phone {
  position: relative;
  height: 86%;
  max-width: 100%; /* before case.js sets the tile's height, don't grow to the images' own width */
  aspect-ratio: 390 / 844;
  overflow: hidden;
  border-radius: 7% / 3.2%;
  background: var(--cream);
  box-shadow: var(--screen-shadow);
  container-type: inline-size;
}

.phone img {
  width: 100%;
}

/* The home screen's cards (342 x 566 design px, every 590 px down), cut out with
   their shadow baked in: the image adds 0.1 of the card's height above it, 0.2
   at each side and 0.32 below (568 x 803.5 for the card). Each card sits in its
   --slot of the stack; --up (animated) moves it up by whole slots. */
.swipe-col {
  position: absolute;
  top: calc(146 / 390 * 100cqw);
  left: calc(24 / 390 * 100cqw);
  width: calc(342 / 390 * 100cqw);
}

.swipe-col img {
  --up: 0;
  position: absolute;
  /* in top, not translate: GSAP folds translate into the transform it animates */
  top: calc((-56.5 + (var(--slot) - var(--up)) * 590) / 390 * 100cqw);
  left: calc(-113 / 390 * 100cqw);
  width: calc(568 / 390 * 100cqw);
  max-width: none;
  transform-origin: 50% 42.25%; /* the card's own centre */
  will-change: transform, opacity, top;
}

.swipe-col img:nth-child(1) { --slot: 0; }
.swipe-col img:nth-child(2) { --slot: 1; }
.swipe-col img:nth-child(3) { --slot: 2; }
.swipe-col img:nth-child(4) { --slot: 3; }
.swipe-col img:nth-child(5) { --slot: 4; }

.phone-top {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

/* The navigation is frosted in the design: the next card shows through it. */
.phone-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  z-index: 1;
  width: 100%;
  border-radius: 0 0 7% 7% / 0 0 29.4% 29.4%; /* the phone's corners: the blur isn't clipped by its parent */
  background: rgba(252, 252, 236, 0.78);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.phone-nav img {
  display: block;
}

/* Two states of one screen, in one cell. */
.states {
  display: grid;
}

.states > img {
  grid-area: 1 / 1;
}

/* Usage, in use. The chart's designed states lie over the screen, at its place: a
   pane per tab, each 361 x 348 design px from 5, 332 (January's pill hangs out to
   the left of the chart), which slide past each other when the tab changes. In a
   pane, every month highlighted, one shown at a time by the script. The plot and
   the legend are the same images cut in two (the script copies the plot): bars
   fade, but the numbers change at once, so they never show through each other.
   The tabs lie over the screen's own, so the underline can slide. */
#usage > img {
  display: block;
}

.usage-chart {
  position: absolute;
  top: calc(332 / 390 * 100cqw);
  left: 0;
  width: 100%;
  height: calc(348 / 390 * 100cqw);
  overflow: hidden;
  background: var(--cream);
}

.usage-pane {
  position: absolute;
  top: 0;
  left: calc(5 / 390 * 100cqw);
  width: calc(361 / 390 * 100cqw);
  height: 100%;
}

.usage-pane[data-tab="gas"] {
  visibility: hidden; /* until the script puts it beside the first */
}

.usage-plot,
.usage-legend {
  position: absolute;
  inset: 0;
}

.usage-plot {
  clip-path: inset(17.25% 0 0 0);
  opacity: 0;
}

.usage-legend {
  clip-path: inset(0 0 82.75% 0);
}

.usage-pane img,
.usage-tabs img {
  position: absolute;
  inset: 0;
  height: 100%;
}

.usage-plot img,
.usage-legend img {
  visibility: hidden;
}

.usage-tab-gas {
  opacity: 0;
}

.usage-tabs {
  position: absolute;
  top: calc(122 / 390 * 100cqw);
  left: 0;
  width: 100%;
  aspect-ratio: 780 / 80;
}

.usage-line {
  --x: 24;
  --w: 89;
  position: absolute;
  top: calc(35 / 390 * 100cqw);
  left: calc(var(--x) / 390 * 100cqw);
  width: calc(var(--w) / 390 * 100cqw);
  height: calc(3 / 390 * 100cqw);
  background: #43006d;
}

/* the finger, as a phone shows a touch */
.usage-touch {
  --x: 37;
  --y: 540;
  position: absolute;
  top: calc(var(--y) / 390 * 100cqw);
  left: calc(var(--x) / 390 * 100cqw);
  width: calc(44 / 390 * 100cqw);
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(67, 0, 109, 0.2);
  box-shadow:
    inset 0 0 0 calc(1.5 / 390 * 100cqw) rgba(255, 255, 255, 0.8),
    0 calc(2 / 390 * 100cqw) calc(10 / 390 * 100cqw) rgba(67, 0, 109, 0.25);
  opacity: 0;
}

/* ── Tilted columns (the section library) ──────────────── */

.shot-feed {
  width: 100%;
  aspect-ratio: 16 / 10;
}

.feed {
  padding: 0;
}

.photo {
  overflow: hidden;
  border-radius: 8px;
}

.photo > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── 6. Tariff page ─────────────────────────────────────── */

#tariff {
  align-items: center;
}

.browser {
  width: 88%;
  overflow: hidden;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(107, 95, 27, 0.3), 0 6px 14px rgba(107, 95, 27, 0.14);
}

.browser-bar {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  background: #f1f0ea;
}

.browser-bar i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #d5d3ca;
}

.browser-view {
  aspect-ratio: 1440 / 860;
  overflow: hidden;
}

.browser-view img {
  width: 100%;
  will-change: transform;
}

/* ── 3. My Bolt on desktop ──────────────────────────────── */

/* the window shows a 1680 x 1080 screen; the pages are stacked, and each page's sidebar
   (321 px) lies over them, so the content can move while the sidebar stays put */
#desk {
  align-items: center;
}

#desk .browser-view {
  position: relative;
  aspect-ratio: 1680 / 1080;
}

.desk-page {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.desk-page + .desk-page,
.desk-sidebar + .desk-sidebar {
  opacity: 0;
}

.desk-page img {
  display: block;
  width: 100%;
  height: auto;
}

#desk .desk-sidebar {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(321 / 1680 * 100%);
  will-change: auto;
}

/* The tariff slide is 4:3; its window fills it, inside the padding. */
.shot-tariff {
  width: 100%;
  aspect-ratio: 4 / 3;
}

#tariff .browser {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#tariff .browser-view {
  flex: 1;
  min-height: 0;
  aspect-ratio: auto;
}

/* ── Extra slides ───────────────────────────────────────── */

/* invoices: a row of phones */
.bills {
  padding-inline: 0;
  padding-block: clamp(48px, 7vw, 90px);
}

.bill-row {
  --h: clamp(280px, 34vw, 480px);
  display: flex;
  gap: clamp(14px, 2vw, 28px);
  width: max-content;
  will-change: transform;
}

.bill-row img {
  width: auto;
  height: var(--h);
  max-width: none;
  border-radius: calc(var(--h) * 0.032);
  box-shadow: var(--screen-shadow);
}

/* ── Design system: components and web sections ─────────── */

/* the design system in use: a rendered film, its backdrop the stage's grey */
.shot-film {
  width: 100%;
  aspect-ratio: 1920 / 1056;
}

#ds-film {
  padding: 0;
}

#ds-film video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* the web sections in three tilted columns */
.section-cols {
  position: absolute;
  inset: auto var(--pad);
  top: -50%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(8px, 1.4vw, 18px);
  transform: rotate(-4deg);
}

.section-col {
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.4vw, 18px);
}

.section-col .photo {
  position: relative;
  box-shadow: 0 10px 30px rgba(67, 0, 109, 0.12);
}

/* the next theme or brand, fading in over the current one */
.section-col .photo > img.swap-in {
  position: absolute;
  inset: 0;
}

/* ── Phones ─────────────────────────────────────────────── */

@media (max-width: 699px) {
  .shot-feed { aspect-ratio: 3 / 4; }
  .section-cols { inset: auto 12px; top: -50%; grid-template-columns: repeat(2, 1fr); }
  .section-col:nth-child(n + 3) { display: none; }
  .browser { width: 100%; }
}
