/* brek.design — case study pages (Figma "CaseStudy · Swap · 1" 352:4788,
   "Perps · 2" 363:4517, "Branding · 4" 363:4687).
   Loaded after v2.css, which provides the tokens and base styles. */

/* Page: column, then the prev/next pills 48 below; 64 + 16 padding after them (Figma 352:5130) */
.cs-page {
  position: relative;
  max-width: 1480px;
  margin: 0 auto;
  padding: 16px 16px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
}

/* "← Home" pinned top-left on wide screens (Figma 352:5149) */
.cs-home {
  position: absolute;
  top: 32px;
  left: 16px;
  font-size: 14px;
  line-height: 20px;
  transition: color 0.2s ease, opacity 1.1s cubic-bezier(0.22, 1, 0.36, 1), transform 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}

.cs-home:hover {
  color: var(--txt-secondary);
}

/* 720px reading column, blocks 32 apart */
.cs-col {
  width: 720px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  padding-top: 16px;
}

.cs-sec {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 32px;
}

.cs-sec--tight {
  gap: 16px;
}

/* Figma "h1": 28/36 */
.cs-title {
  margin: 0;
  font-size: 28px;
  font-weight: 400;
  line-height: 36px;
}

/* Section headings and copy share Figma "h2": 16/24, -2% */
.cs-h,
.cs-text {
  margin: 0;
  font-size: 16px;
  font-weight: 400;
  line-height: 24px;
  letter-spacing: -0.32px;
}

.cs-text {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Heading grouped with its copy, 16 apart (Figma "heading + copy" frames) */
.cs-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Figma "h2/bold": SemiBold 16/24 */
.cs-h--bold,
.cs-strong {
  font-weight: 600;
}

/* Pull quote: 2px divider bar with the copy 16 to its right */
.cs-quote {
  display: flex;
  gap: 16px;
  margin: 0;
}

.cs-quote::before {
  content: "";
  flex: none;
  width: 2px;
  background: var(--divider);
}

/* Some intro blocks and dividers are 660 wide */
.cs-narrow {
  width: 660px;
  max-width: 100%;
}

.cs-rule {
  flex: none;
  width: 100%;
  height: 1px;
  margin: 0;
  border: 0;
  background: var(--divider);
}

.cs-rule.cs-narrow {
  width: 660px;
}

.cs-stack {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* Figure: image or card, caption 8 below */
.cs-fig {
  width: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cs-shot {
  width: 100%;
  height: auto;
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  object-fit: cover;
}

.cs-shot--r16 {
  border-radius: var(--radius);
}

.cs-shot--bare {
  border: 0;
}

/* Two columns 16 apart (Perps Maze results): a stacked pair on the left, one image on the right */
.cs-pair {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.cs-pair > * {
  flex: 1 1 0;
  min-width: 0;
}

.cs-pair-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Caption (Figma "body", Secondary) */
.cs-cap {
  font-size: 14px;
  line-height: 20px;
  color: var(--txt-secondary);
}

/* Grey media cards: demo and core screens */
.cs-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--ui-bg);
  box-shadow: inset 0 0 0 0.78px var(--divider); /* Figma inside stroke: no extra height */
}

/* Demo videos have their own #f2f2f2 margin around the phone. Each page sets the video height
   that makes the phone 523px tall like the Figma placeholder, and the padding that keeps the
   card at Figma's 643px (defaults: Swap's swap.mp4) */
.cs-demo {
  padding: var(--demo-pad, 51.5px) 40px;
}

.cs-demo video {
  display: block;
  width: auto;
  max-width: 100%;
  height: var(--demo-h, 540px);
  background: var(--ui-bg);
  cursor: pointer;
}

.cs-screens {
  gap: 20px;
  padding: 60px 40px;
}

.cs-screens img {
  flex: 1 1 0;
  min-width: 0;
  height: auto;
  aspect-ratio: 936 / 1952;
  object-fit: fill; /* exports are within 0.1% of this ratio; cover would crop a sliver and lose mipmaps */
}

/* Previous / next case study (Figma 352:5348) */
.cs-next {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 17px;
}

.cs-pill {
  position: relative;
  isolation: isolate;
  border-radius: 40px; /* so the keyboard focus ring follows the pill shape */
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px 12px 12px;
  font-size: 16px;
  line-height: 24px;
  letter-spacing: -0.32px;
}

.cs-pill--next {
  gap: 16px;
  padding: 12px 12px 12px 20px;
}

/* Pink pill layer (separate so the appear animation can grow it from a 48px circle) */
.cs-pill-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 40px;
  background: #ffd3f3;
  transition: background 0.2s ease;
}

.cs-pill:hover .cs-pill-bg {
  background: #ffc2ee;
}

.cs-pill-knob {
  flex: none;
  width: 24px;
  height: 24px;
}

.cs-pill--prev .cs-pill-knob {
  transform: scaleX(-1);
}

.cs-pill-label {
  display: inline-block;
}

/* Appear: hidden until reveal.js plays the previous site's CTA animation (rise with a small bounce,
   pill opens out from a circle, arrow grows from a dot, label fades in) */
.js-reveal .cs-pill {
  opacity: 0;
}

.js-reveal .cs-pill.is-revealed {
  opacity: 1;
}

/* ---------- Small screens ---------- */

@media (max-width: 900px) {
  .cs-page {
    display: block;
    padding-bottom: 64px;
  }

  .cs-next {
    margin-top: 48px;
  }

  .cs-home {
    position: static;
    display: inline-block;
    padding-top: 8px;
    margin-bottom: 24px;
    margin-left: max(0px, calc((100% - 720px) / 2)); /* lines up with the centred column on tablets */
  }

  .cs-col {
    width: 100%;
    max-width: 720px; /* readable line length on tablets, centred like on desktop */
    margin-inline: auto;
    padding-top: 0;
  }

  .cs-demo {
    padding: 32px 16px;
  }

  .cs-demo video {
    width: min(100%, var(--demo-w, 405px));
    height: auto;
  }

  .cs-screens {
    gap: 8px;
    padding: 24px 16px;
  }

  .cs-pair {
    flex-direction: column;
  }

  .cs-pair > * {
    flex: none;
    width: 100%;
  }
}
