/*
  Work Order: Case Study Next-Step CTAs. Loaded only by the three pages with a
  src/lib/case-study-offers.js entry (Vuori, AG1, True Botanicals) — see
  CLAUDE.md's "CSS bundling" convention: page-specific code stays its own
  sheet rather than joining site.css, the same call success-story.css and
  offer-page.css already made. `so-` prefix, so-called after "story offer",
  to avoid colliding with `.cs-*`/`.pp-*`/`.ra-*`.

  Text colour rides on the ancestor band's --cs-ink/--cs-ink-dim/--cs-accent
  (set per .cs-band-* in success-story.css), so one card reads correctly on
  all three grounds it appears on. The button colours are a separate system
  (ds.css's --btn-* custom props) and need the .ds-on-light scope class on
  the two light bands — see StoryOfferCard.astro's `dark` prop.
*/

.so-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 40px;
  max-width: 1164px;
  margin: 0 auto;
  padding: 40px 48px;
  background: var(--cs-surface);
  border: 1px solid var(--cs-rule);
  border-radius: var(--radius-panel);
}
.so-copy { flex: 1 1 auto; min-width: 0; max-width: 620px; }
/* Same ramp as .cs-eyebrow. */
.so-eyebrow {
  margin: 0 0 8px;
  font-family: var(--font-sans);
  font-size: 16px; font-weight: 600; line-height: 1.5;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--cs-accent);
}
.so-headline {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(1.375rem, 1.6vw + 0.5rem, 1.75rem); font-weight: 500; line-height: 1.25;
  letter-spacing: 0.01em;
  color: var(--cs-ink);
}
.so-body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 18px; font-weight: 400; line-height: 1.5;
  color: var(--cs-ink-dim);
}
.so-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.so-secondary + .so-secondary { margin-left: -12px; }

@media (max-width: 991px) {
  .so-card { flex-direction: column; align-items: flex-start; gap: 24px; padding: 32px; }
  .so-copy { max-width: none; }
  .so-actions { width: 100%; flex-direction: column; align-items: stretch; gap: 16px; }
  /* The filled button takes the row; a text button keeps its own width,
     or its red rule runs the full card under a label a third as long. */
  .so-actions .ds-btn:not(.ds-btn--text) { width: 100%; }
  .so-actions .ds-btn--text { align-self: center; }
  /* A long secondary label ("Or book the Diagnostic ($5,000, credited)", on
     39 blog posts) wraps at phone width, and a wrapped box is as wide as the
     card — so the border rule ran ~30px past the text it underlines. Drawn as
     a text underline instead, the rule follows each line's own text. Same
     1px red, the same distance under the label. */
  .so-actions .ds-btn--text {
    border-bottom: 0; padding-bottom: 0;
    text-align: center; text-wrap: balance;
    text-decoration: underline; text-decoration-color: var(--color-brand-red);
    text-decoration-thickness: 1px; text-underline-offset: 0.42em;
  }
  .so-card.ds-on-light .so-actions .ds-btn--text { text-decoration-color: var(--color-brand-red-fill); }
  .so-secondary + .so-secondary { margin-left: 0; }
}
@media (max-width: 479px) {
  .so-card { padding: 28px 24px; }
  .so-headline { font-size: 1.25rem; }
}

/* ===== Task 4: desktop slide-in / mobile sticky bar ===== */

.so-slidein {
  position: fixed;
  z-index: 60;
  right: 24px;
  /* Nudged above the cookie banner (public/js/consent.js's .ac-banner) or any
     other bottom-fixed chrome case-study-cta.js finds at show time — Task 4's
     "must not cover cookie banners, chat widgets, or the page's primary
     nav." */
  bottom: calc(24px + var(--so-avoid, 0px));
  width: 360px;
  max-width: calc(100vw - 48px);
  padding: 28px 28px 28px 32px;
  background: var(--color-neutral-black);
  border: 1px solid var(--color-glass-border);
  border-left: 4px solid var(--color-brand-red);
  border-radius: var(--radius-panel);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.35);
  transform: translateY(24px);
  opacity: 0;
  transition: transform 250ms ease, opacity 250ms ease;
}
.so-slidein[hidden] { display: none; }
.so-slidein.is-visible { transform: translateY(0); opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .so-slidein { transition: opacity 1ms; transform: none; }
}
.so-widget-headline {
  margin: 0 32px 8px 0;
  font-family: var(--font-display);
  font-size: 1.25rem; font-weight: 500; line-height: 1.25;
  color: var(--color-neutral-white);
}
.so-widget-body {
  margin: 0 0 20px;
  font-family: var(--font-sans);
  font-size: 15px; font-weight: 400; line-height: 1.45;
  color: var(--color-text-secondary);
}
/* .ds-btn is nowrap, and the card's measure is ~295px: "Book the 5-Day
   Horizon Readiness Audit" ran ~50px out of both sides of its own fill
   (visual QA, Oct 2026). Here the label wraps, balanced and centred, and
   the button grows a line rather than overflowing. */
.so-widget-cta {
  width: 100%;
  white-space: normal;
  text-align: center;
  text-wrap: balance;
  padding-top: calc(0.314em + 8px);
  padding-bottom: 8px;
}
.so-widget-close {
  position: absolute; top: 16px; right: 16px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 50%;
  font-size: 22px; line-height: 1; color: var(--color-text-secondary);
  cursor: pointer; transition: background-color .15s ease, color .15s ease;
}
.so-widget-close:hover { background: var(--color-glass-fill); color: var(--color-neutral-white); }
.so-widget-close:focus-visible { outline: 2px solid var(--color-neutral-white); outline-offset: 2px; }

.so-stickybar {
  position: fixed;
  z-index: 60;
  left: 0; right: 0;
  bottom: var(--so-avoid, 0px);
  display: flex; align-items: center; gap: 16px;
  max-height: 64px;
  padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--color-neutral-black);
  border-top: 1px solid var(--color-glass-border);
  transform: translateY(100%);
  transition: transform 250ms ease;
}
.so-stickybar[hidden] { display: none; }
.so-stickybar.is-visible { transform: translateY(0); }
@media (prefers-reduced-motion: reduce) {
  .so-stickybar { transition: opacity 1ms; }
}
/* Two lines rather than one with an ellipsis: on a 320-375px phone the
   single line cut most offers to their first few words ("Canvas or agents?
   Fi…"), which is the whole pitch (visual QA, Oct 2026). Two 14px lines fit
   the bar's 64px. */
.so-stickybar-line {
  flex: 1 1 auto; min-width: 0;
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px; font-weight: 500; line-height: 1.3;
  color: var(--color-neutral-white);
  overflow: hidden;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  text-wrap: balance;
}
.so-stickybar-cta { flex: none; }
.so-stickybar .so-widget-close {
  position: static; flex: none;
  width: 28px; height: 28px; font-size: 20px;
}

/* Desktop only above 1024px; the mobile bar takes over below it. */
@media (min-width: 1024px) {
  .so-stickybar { display: none !important; }
}
@media (max-width: 1023px) {
  .so-slidein { display: none !important; }
}

/* Large-desktop tier (see tokens.css): from 1680px the column is 1344px and
   the root type 18px, so what this sheet draws in px takes the same step —
   layout widths x1.2, px type x1.125, the 1118/1164 column measures to 1344.
   Keep a value here in step with its base rule above. */
@media (min-width: 1680px) {
  .so-card { max-width: 1344px; }
  .so-copy { max-width: 744px; }
  .so-eyebrow { font-size: 18px; }
  .so-headline { font-size: clamp(1.375rem, 1.6vw + 0.5rem, 1.75rem); }
  .so-body { font-size: 20px; }
  .so-slidein { width: 432px; max-width: calc(100vw - 48px); }
  .so-widget-headline { font-size: 1.25rem; }
  .so-widget-body { font-size: 17px; }
  .so-widget-cta { width: 100%; }
  .so-widget-close { width: 32px; font-size: 25px; }
  .so-stickybar-line { font-size: 16px; }
  .so-stickybar .so-widget-close { width: 28px; font-size: 23px; }
}
