/* ---------- Case study page ---------- */

/* Hero: copy on the left, annotated email on the right */
.cs-hero {
  position: relative; overflow: hidden;
  padding: 168px var(--gutter) 40px;
  background:
    radial-gradient(900px 520px at 85% 30%, rgba(24, 80, 225, .10), transparent 70%),
    radial-gradient(600px 400px at 0% 0%, rgba(191, 208, 255, .45), transparent 70%),
    #fff;
}
.cs-hero-inner {
  max-width: 1280px; margin: 0 auto;
  display: grid; grid-template-columns: 1.05fr 1fr; gap: 64px;
  align-items: center;
}
.cs-title {
  font-family: "Heebo", sans-serif;
  font-size: clamp(46px, 5.4vw, 78px); font-weight: 800;
  line-height: 1.02; letter-spacing: -.045em;
  color: var(--navy);
  text-wrap: balance;
}
.cs-title span {
  background: linear-gradient(100deg, var(--blue) 0%, #4f7cf5 45%, var(--blue) 90%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: heroShimmer 6s linear infinite;
}
.cs-sub {
  max-width: 520px; margin-top: 24px;
  font-size: 18px; line-height: 1.65; color: var(--muted);
  text-wrap: pretty;
}
.cs-ctas { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 34px; }
.cs-anatomy-list {
  list-style: none; margin-top: 44px;
  display: grid; grid-template-columns: repeat(2, max-content); gap: 14px 34px;
}
.cs-anatomy-list li {
  display: flex; align-items: center; gap: 12px;
  font-family: "Heebo", sans-serif; font-size: 15px; font-weight: 500; color: var(--ink);
}
.cs-anatomy-list i {
  font-style: normal; font-size: 12px; font-weight: 700;
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center;
  color: var(--blue); background: var(--soft); border: 1px solid var(--line);
}

/* Hero visual: a fanned stack of three designs */
.cs-stack { position: relative; isolation: isolate; justify-self: center; width: min(100%, 560px); height: 600px; }
.cs-stack-glow {
  position: absolute; inset: 14% 10% 6%; z-index: -1;
  border-radius: 48px;
  background: var(--brand-gradient);
  transform: rotate(-6deg);
}
.cs-stack img {
  position: absolute; top: 50%; left: 50%;
  width: 250px; aspect-ratio: 600 / 1238; object-fit: cover; object-position: top;
  border-radius: 20px; background: #fff;
  box-shadow: 0 30px 60px rgba(7, 16, 61, .25);
}
.cs-stack .s1 { transform: translate(-112%, -46%) rotate(-9deg); }
.cs-stack .s3 { transform: translate(12%, -46%) rotate(9deg); }
.cs-stack .s2 { transform: translate(-50%, -52%); width: 280px; z-index: 1; animation: csStackFloat 6s ease-in-out infinite; }
@keyframes csStackFloat { 50% { transform: translate(-50%, -55%); } }
.cs-stack-tag {
  position: absolute; z-index: 2; left: 0; bottom: 40px;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: 999px;
  background: var(--navy); color: #fff;
  font-family: "Heebo", sans-serif; font-size: 14px; font-weight: 600;
  box-shadow: 0 16px 36px rgba(7, 16, 61, .28);
  animation: csTagFloat 3.6s ease-in-out infinite;
}
@keyframes csTagFloat { 50% { transform: translateY(-6px); } }
.cs-stack-tag i {
  width: 9px; height: 9px; border-radius: 50%;
  background: #5ee0a0; box-shadow: 0 0 0 4px rgba(94, 224, 160, .25);
}

/* Anatomy: the email with every label rebuilt as live text.
   The email is a 3x upscale of the 283 x 1484 original, shown smaller so it stays crisp.
   Only the countdown and the review stars animate, so those are separate animated strips. */
.anat {
  --W: 260px;                          /* email width on screen */
  --H: calc(var(--W) * 1484 / 283);
  --gap: 56px;                         /* space between the email and the notes */
  --nw: min(350px, calc((100vw - 2 * var(--gutter) - var(--W)) / 2 - var(--gap) - 48px));   /* note width */
  padding: var(--section) var(--gutter) 0;
}
.anat-stage { position: relative; height: var(--H); max-width: 1180px; margin: 72px auto 0; }
.anat-email {
  position: absolute; top: 0; left: 50%; z-index: 1;
  width: var(--W); height: var(--H);
  transform: translateX(-50%);
  overflow: hidden; border-radius: 18px;
  background: #fff;
  box-shadow: 0 0 0 1px var(--line), 0 40px 90px rgba(7, 16, 61, .16);
}
.anat-email > img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.anat-email > .anat-anim { height: auto; }
.anat-email > .anim-countdown { top: calc(20 / 1484 * 100%); }
.anat-email > .anim-stars { top: calc(1068 / 1484 * 100%); }

.anat-note { position: absolute; top: calc(var(--H) * var(--y) - 40px); width: var(--nw); }
.anat-note.left  { left: calc(50% - var(--W) / 2 - var(--gap) - var(--nw)); }
.anat-note.right { left: calc(50% + var(--W) / 2 + var(--gap)); }
.anat-note h3 {
  display: flex; align-items: center; gap: 10px;
  height: 30px;
  font-family: "Heebo", sans-serif; font-size: 22px; font-weight: 700; letter-spacing: -.02em;
  color: var(--navy);
}
.anat-note p { margin-top: 20px; font-size: 14px; line-height: 1.55; color: var(--muted); text-wrap: pretty; }
.anat-note code { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; color: var(--blue); background: var(--soft); padding: 1px 5px; border-radius: 5px; }
.anat-num {
  position: absolute; top: 3px; left: -40px;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: "Heebo", sans-serif; font-size: 12px; font-weight: 700;
  color: var(--blue); background: var(--soft); border: 1px solid var(--blue-light);
  transition: background .3s, color .3s;
}
.anat-note.right .anat-num { left: auto; right: -40px; }
.anat-swatches { display: flex; margin-top: 14px; }
.anat-swatches i {
  width: 30px; height: 30px; border-radius: 50%; margin-right: -6px;
  background: var(--c); box-shadow: 0 0 0 3px #fff, 0 0 0 4px var(--line);
}

/* connector lines (added by case-study.js) run from the note into the email */
.anat-line {
  position: absolute; z-index: 2; top: calc(var(--H) * var(--y) - 1px); height: 0;
  border-top: 2px solid #9db4f2;   /* solid, so it covers the GIF's own red pointer lines */
  transition: border-color .3s;
}
.anat-line.left  { left: calc(50% - var(--W) / 2 - var(--gap) - var(--nw)); width: calc(var(--nw) + var(--gap) + var(--x) * var(--W)); }
.anat-line.right { left: calc(50% - var(--W) / 2 + var(--x) * var(--W)); width: calc((1 - var(--x)) * var(--W) + var(--gap) + var(--nw)); }
.anat-line::after {   /* the dot on the email */
  content: ""; position: absolute; top: -7px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 2.5px solid var(--blue);
  box-sizing: border-box;
}
.anat-line.left::after { right: -6px; }
.anat-line.right::after { left: -6px; }
.js .anat-line { transform: scaleX(0); transition: transform 1s var(--ease), border-color .3s; }
.js .anat-line.left { transform-origin: left; }
.js .anat-line.right { transform-origin: right; }
.js .anat-line.is-in { transform: scaleX(1); }
.anat-line.is-active { border-top-color: var(--blue); }
.anat-line.is-active::after { box-shadow: 0 0 0 6px rgba(24, 80, 225, .2); }
.anat-note.is-active .anat-num { background: var(--blue); color: #fff; }
.anat-pin { display: none; }

/* Results: navy band with metric tiles */
.cs-results { padding: var(--section) var(--gutter) 0; }
.cs-results-band {
  position: relative; overflow: hidden; isolation: isolate;
  max-width: 1280px; margin: 0 auto;
  padding: 80px 64px 64px;
  border-radius: var(--r-lg);
  background:
    radial-gradient(700px 380px at 100% 0%, rgba(79, 124, 245, .45), transparent 70%),
    radial-gradient(500px 340px at 0% 100%, rgba(24, 80, 225, .35), transparent 70%),
    var(--navy);
  color: #fff;
}
.cs-results-band::before {   /* faint grid texture */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image:
    linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, #000, transparent 85%);
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent 85%);
}
.cs-results-head { text-align: center; max-width: 760px; margin: 0 auto 52px; }
.cs-results-head .section-title { color: #fff; }
.cs-results-head .section-title span { color: var(--blue-light); }
.cs-results-head p { margin-top: 16px; font-size: 17px; color: rgba(255,255,255,.7); }

.cs-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.cs-metric {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 26px 24px 24px;
  border-radius: var(--r-md);
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
}
.cs-metric:hover { background: rgba(255,255,255,.1); }
.cs-metric-label {
  font-family: "Heebo", sans-serif;
  font-size: 12px; font-weight: 600; letter-spacing: 1.4px; text-transform: uppercase;
  color: rgba(255,255,255,.65);
}
.cs-metric strong {
  margin-top: 14px;
  font-family: "Heebo", sans-serif;
  font-size: 54px; font-weight: 800; line-height: 1; letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}
.cs-delta {
  margin-top: 14px;
  padding: 5px 11px; border-radius: 999px;
  font-family: "Heebo", sans-serif; font-size: 13px; font-weight: 700;
  color: #5ee0a0; background: rgba(94, 224, 160, .12);
}
.cs-bar {
  display: block; width: 100%; height: 6px; margin-top: 22px;
  border-radius: 6px; background: rgba(255,255,255,.1); overflow: hidden;
}
.cs-bar::after {
  content: ""; display: block; height: 100%; width: var(--w);
  border-radius: inherit; background: linear-gradient(90deg, #4f7cf5, var(--blue-light));
  transform: scaleX(0); transform-origin: left;
  transition: transform 1.4s var(--ease) .3s;
}
.cs-metric.is-in .cs-bar::after, html:not(.js) .cs-bar::after { transform: scaleX(1); }

.cs-metric-hero { background: var(--blue); border-color: transparent; box-shadow: 0 24px 50px rgba(24, 80, 225, .45); }
.cs-metric-hero:hover { background: #2a5ff0; }
.cs-metric-hero .cs-metric-label { color: rgba(255,255,255,.85); }
.cs-spark {
  display: flex; align-items: flex-end; gap: 6px;
  width: 100%; height: 70px; margin-top: auto; padding-top: 16px;
}
.cs-spark i {
  flex: 1; height: var(--h); border-radius: 4px 4px 2px 2px;
  background: rgba(255,255,255,.35);
  transform: scaleY(0); transform-origin: bottom;
  transition: transform .8s var(--ease);
}
.cs-spark i:last-child { background: #fff; }
.cs-metric-hero.is-in .cs-spark i, html:not(.js) .cs-spark i { transform: scaleY(1); }
.cs-spark i:nth-child(2) { transition-delay: .35s; } .cs-spark i:nth-child(3) { transition-delay: .4s; }
.cs-spark i:nth-child(4) { transition-delay: .45s; } .cs-spark i:nth-child(5) { transition-delay: .5s; }
.cs-spark i:nth-child(6) { transition-delay: .55s; } .cs-spark i:nth-child(7) { transition-delay: .6s; }
.cs-spark i:nth-child(1) { transition-delay: .3s; }

/* Gallery */
.cs-gallery { padding: var(--section) var(--gutter) 0; }
.cs-grid {
  list-style: none;
  max-width: 1280px; margin: 56px auto 0;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 22px;
}
.cs-card { animation: csCardIn .6s var(--ease) both; }
.cs-card[hidden] { display: none; }
@keyframes csCardIn { from { opacity: 0; transform: translateY(24px); } }
.cs-card button {
  position: relative; display: block; width: 100%;
  padding: 0; border: 1px solid var(--line); cursor: zoom-in;
  aspect-ratio: 600 / 1238;
  border-radius: 18px; overflow: hidden;
  background: var(--soft);
  transition: transform .45s var(--ease), box-shadow .45s var(--ease), border-color .45s;
}
.cs-card img {
  width: 100%; height: 100%; object-fit: cover; object-position: top;
  transition: transform .8s var(--ease);
}
.cs-card-cta {
  position: absolute; left: 12px; right: 12px; bottom: 12px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 14px; border-radius: 999px;
  background: rgba(7, 16, 61, .88); color: #fff;
  font-family: "Heebo", sans-serif; font-size: 14px; font-weight: 600;
  opacity: 0; transform: translateY(10px);
  transition: opacity .35s var(--ease), transform .35s var(--ease);
}
.cs-card button:hover, .cs-card button:focus-visible {
  transform: translateY(-6px);
  border-color: var(--blue-light);
  box-shadow: 0 26px 50px rgba(24, 80, 225, .18);
}
.cs-card button:hover img, .cs-card button:focus-visible img { transform: scale(1.04); }
.cs-card button:hover .cs-card-cta, .cs-card button:focus-visible .cs-card-cta { opacity: 1; transform: none; }
.cs-card button:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

.cs-more { margin-top: 44px; text-align: center; }
.cs-more-btn[hidden] { display: none; }
.cs-count { margin-top: 14px; font-size: 14px; color: var(--muted); }

/* Full-email viewer */
.cs-viewer {
  position: fixed; inset: 0;
  width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 24px; border: 0;
  background: transparent;
  display: none; place-items: center;
}
.cs-viewer[open] { display: grid; animation: csFade .3s var(--ease); }
.cs-viewer::backdrop { background: rgba(7, 16, 61, .72); backdrop-filter: blur(6px); }
@keyframes csFade { from { opacity: 0; transform: scale(.97); } }
html.viewer-open { overflow: hidden; }

.cs-viewer-bar, .cs-viewer-body { width: min(620px, 100%); }
.cs-viewer-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 12px 12px 20px;
  background: #fff; border-radius: 20px 20px 0 0;
  border-bottom: 1px solid var(--line);
}
.cs-viewer-count {
  font-family: "Heebo", sans-serif; font-size: 14px; font-weight: 600; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.cs-viewer-close {
  width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--soft); color: var(--navy); font-size: 24px; line-height: 1;
  transition: background .25s, color .25s;
}
.cs-viewer-close:hover { background: var(--blue); color: #fff; }
.cs-viewer-body {
  height: min(80vh, 900px); overflow-y: auto;
  background: #fff; border-radius: 0 0 20px 20px;
  box-shadow: 0 40px 90px rgba(0, 0, 0, .35);
  scrollbar-width: thin;
}
.cs-viewer-body img { display: block; width: 100%; height: auto; transition: opacity .3s; }
.cs-viewer.is-loading .cs-viewer-body img { opacity: .25; }
.cs-viewer > :first-child { align-self: end; }
.cs-viewer > .cs-viewer-body { align-self: start; }
.cs-viewer { grid-template-rows: auto auto; align-content: center; }
.cs-viewer-bar, .cs-viewer-body { grid-column: 1; }

.cs-nav {
  position: fixed; top: 50%; transform: translateY(-50%);
  width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  background: #fff; color: var(--navy);
  font-size: 34px; line-height: 1; padding-bottom: 4px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .25);
  transition: background .25s, color .25s, transform .25s var(--ease);
}
.cs-nav:hover { background: var(--blue); color: #fff; transform: translateY(-50%) scale(1.06); }
.cs-prev { left: max(24px, calc(50% - 400px)); }
.cs-next { right: max(24px, calc(50% - 400px)); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .cs-hero-inner { grid-template-columns: 1fr; gap: 56px; }
  .cs-hero-copy { text-align: center; }
  .cs-sub { margin-left: auto; margin-right: auto; }
  .cs-ctas { justify-content: center; }
  .cs-anatomy-list { justify-content: center; }
  .cs-metrics { grid-template-columns: repeat(2, 1fr); }
  .cs-grid { grid-template-columns: repeat(4, 1fr); }

  /* Anatomy: email with numbered pins, notes listed underneath */
  .anat-stage { height: auto; max-width: 860px; margin-top: 56px; display: grid; grid-template-columns: 1fr 1fr; gap: 28px 40px; }
  .anat-email { position: relative; left: auto; transform: none; grid-column: 1 / -1; justify-self: center; margin-bottom: 24px; }
  .anat-line { display: none; }
  .anat-note { position: relative; top: auto; left: auto !important; width: auto; padding-left: 40px; }
  .anat-note.right .anat-num { left: 0; right: auto; }
  .anat-num { left: 0; }
  .anat-note h3 { font-size: 20px; }
  .anat-note p { margin-top: 6px; }
  .anat-pin {
    display: block; position: absolute;
    left: calc(var(--x) * 100%); top: calc(var(--y) * 100%);
    width: 24px; height: 24px; margin: -12px 0 0 -12px;
  }
  .anat-pin::after {   /* the numbered badge, painted over the line */
    content: attr(data-n);
    position: absolute; inset: 0;
    display: grid; place-items: center; border-radius: 50%;
    font-family: "Heebo", sans-serif; font-size: 11px; font-weight: 700;
    color: #fff; background: var(--blue);
    box-shadow: 0 0 0 3px #fff, 0 4px 12px rgba(7, 16, 61, .3);
  }
  /* covers the GIF's own pointer line between the pin and the email edge */
  .anat-pin::before {
    content: ""; position: absolute; top: 11px; height: 2px;
    background: #9db4f2;
  }
  .anat-pin.left::before { right: 12px; width: calc(var(--x) * var(--W)); }
  .anat-pin.right::before { left: 12px; width: calc((1 - var(--x)) * var(--W)); }
}
@media (max-width: 860px) {
  .cs-hero { padding-top: 132px; }
  .cs-anatomy-list { grid-template-columns: 1fr 1fr; gap: 12px 16px; text-align: left; }
  .cs-anatomy-list li { font-size: 14px; }
  .cs-stack { height: 420px; }
  .cs-stack img { width: 160px; border-radius: 14px; }
  .cs-stack .s2 { width: 180px; }
  .cs-stack-tag { left: 50%; transform: translateX(-50%); bottom: 0; white-space: nowrap; animation: none; font-size: 13px; }
  .anat-stage { grid-template-columns: 1fr; gap: 24px; }
  .cs-results-band { padding: 56px 20px 24px; }
  /* metrics become compact rows: label + lift on the left, the number on the right */
  .cs-metrics { grid-template-columns: 1fr; gap: 10px; }
  .cs-metric { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 12px; padding: 18px 18px 16px; }
  .cs-metric strong { grid-column: 2; grid-row: 1 / 3; margin: 0; font-size: 40px; }
  .cs-metric-label { grid-column: 1; grid-row: 1; }
  .cs-delta { grid-column: 1; grid-row: 2; justify-self: start; margin-top: 8px; }
  .cs-bar { grid-column: 1 / -1; margin-top: 16px; }
  .cs-metric-hero { display: flex; align-items: flex-start; padding: 22px 18px 18px; }
  .cs-metric-hero strong { margin-top: 10px; font-size: 48px; }
  .cs-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; margin-top: 40px; }
  .cs-card button { border-radius: 14px; }
  .cs-card-cta { display: none; }
  .cs-viewer { padding: 12px 12px 84px; }
  .cs-viewer-body { height: calc(100dvh - 170px); }
  .cs-nav { top: auto; bottom: 16px; transform: none; width: 52px; height: 52px; }
  .cs-nav:hover { transform: none; }
  .cs-prev { left: calc(50% - 64px); }
  .cs-next { right: calc(50% - 64px); }
}
@media (prefers-reduced-motion: reduce) {
  .cs-stack-tag, .cs-stack .s2, .cs-title span, .cs-card, .cs-viewer[open] { animation: none; }
  .js .anat-line { transform: none; }
}
