/* Case study detail — Diffblue-style editorial layout (SPARC Global) */

:root {
  --csd-ink: #0c1b2e;
  --csd-ink-muted: rgba(12, 27, 46, 0.72);
  --csd-ink-soft: rgba(12, 27, 46, 0.55);
  --csd-line: rgba(12, 27, 46, 0.1);
  --csd-accent: var(--accent-color, #0070b0);
  --csd-sticky-top: 100px;
}

html:has(body.case-study-detail) {
  scroll-behavior: smooth;
}

body.case-study-detail {
  background: #ffffff;
  color: var(--csd-ink);
}

.csd-article {
  overflow: visible;
  padding-bottom: clamp(72px, 9vw, 120px);
}

/* —— Masthead —— */

.csd-masthead {
  padding: clamp(32px, 4vw, 60px) 0 clamp(28px, 4vw, 48px);
  color: var(--csd-ink);
}

.csd-back {
  display: none;
  margin-bottom: clamp(32px, 5vw, 60px);
  font-family: var(--default-font, "DM Sans"), system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 400;
  color: var(--csd-ink);
  text-decoration: none;
}

.csd-back span {
  position: relative;
  display: inline-block;
  padding-bottom: 0.5rem;
}

.csd-back span::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: rgba(12, 27, 46, 0.2);
  transition: height 0.2s ease, background 0.2s ease;
}

.csd-back:hover span::after {
  height: 2px;
  background: var(--csd-line);
}

@media (min-width: 768px) {
  .csd-back {
    display: inline-flex;
  }
}

.csd-kicker {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1.5rem;
  font-family: var(--accent-font, Manrope), system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--csd-ink);
}

.csd-kicker__dot {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  background: var(--csd-ink);
}

.csd-title {
  margin: 0 0 clamp(1.5rem, 3vw, 2rem);
  max-width: 54rem;
  font-family: var(--accent-font, Manrope), system-ui, sans-serif;
  font-size: clamp(1.85rem, 3.8vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.12;
  color: var(--csd-ink);
}

.csd-masthead__row {
  display: flex;
  flex-direction: column;
  gap: clamp(1.75rem, 3vw, 2.5rem);
}

@media (min-width: 768px) {
  .csd-masthead__row {
    flex-direction: row;
    align-items: stretch;
    justify-content: space-between;
    gap: clamp(2rem, 4vw, 5rem);
  }
}

.csd-masthead__media {
  flex-shrink: 0;
  width: 100%;
  overflow: hidden;
  border-radius: 3px;
  background: #e8edf3;
}

@media (min-width: 768px) {
  .csd-masthead__media {
    max-width: 60%;
  }
}

.csd-masthead__img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
}

.csd-masthead__panel {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.5rem;
  min-width: 0;
}

.csd-intro p {
  margin: 0;
  font-family: var(--default-font, "DM Sans"), system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--csd-ink);
}

/* Legacy client / tech info boxes from DB HTML */
.csd-intro div[class*="rounded"],
.csd-body div[class*="rounded"],
.csd-section div[class*="rounded"] {
  margin: 0 0 1.5rem !important;
  padding: 1rem 1.15rem !important;
  border: 1px solid var(--csd-line) !important;
  border-radius: 3px !important;
  background: #f8fafc !important;
}

.csd-intro div[class*="rounded"] p,
.csd-body div[class*="rounded"] p,
.csd-section div[class*="rounded"] p {
  margin: 0 0 0.5rem !important;
  font-size: 0.9rem !important;
  line-height: 1.55 !important;
}

.csd-intro div[class*="rounded"] p:last-child,
.csd-body div[class*="rounded"] p:last-child,
.csd-section div[class*="rounded"] p:last-child {
  margin-bottom: 0 !important;
}

/* —— Stats (Diffblue border-top style) —— */

.csd-stats {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.csd-stat {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--csd-line);
}

.csd-stat__value {
  font-family: var(--accent-font, Manrope), system-ui, sans-serif;
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--csd-ink);
}

.csd-stat__label {
  font-family: var(--default-font, "DM Sans"), system-ui, sans-serif;
  font-size: clamp(1rem, 1.4vw, 1.25rem);
  line-height: 1.4;
  color: var(--csd-ink-muted);
}

.csd-stat--sidebar {
  padding: 1.5rem;
  border: 0;
  border-top: 1px solid var(--csd-line);
  border-left: 1px solid var(--csd-line);
  border-radius: 0;
  background: transparent;
}

.csd-stat--sidebar .csd-stat__value {
  font-size: clamp(2rem, 3.5vw, 2.75rem);
  color: var(--csd-ink);
}

.csd-stat--sidebar .csd-stat__label {
  font-size: 1.05rem;
  opacity: 0.7;
}

/* —— Content grid —— */

.csd-body-wrap {
  border-top: 1px solid var(--csd-line);
  padding-top: clamp(2rem, 4vw, 6rem);
  overflow: visible;
}

.csd-grid {
  display: grid;
  gap: clamp(2.5rem, 5vw, 4rem);
  overflow: visible;
}

@media (min-width: 992px) {
  .csd-grid {
    grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
    align-items: start;
    gap: clamp(2.5rem, 6vw, 5rem);
  }
}

.csd-main {
  min-width: 0;
  max-width: 700px;
}

@media (min-width: 992px) {
  .csd-main {
    grid-column: 2;
    justify-self: start;
  }
}

/* —— Article body —— */

.csd-body.post-content {
  max-width: none;
}

.csd-section {
  scroll-margin-top: var(--csd-sticky-top);
}

.csd-section + .csd-section {
  margin-top: clamp(2.5rem, 4vw, 3rem);
}

.csd-body h2 {
  margin: 0 0 1rem;
  font-family: var(--accent-font, Manrope), system-ui, sans-serif;
  font-size: clamp(1.35rem, 2.2vw, 1.65rem);
  font-weight: 700;
  line-height: 1.25;
  color: var(--csd-ink);
}

.csd-body h3 {
  margin: 1.75rem 0 0.75rem;
  font-family: var(--accent-font, Manrope), system-ui, sans-serif;
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  font-weight: 700;
  line-height: 1.35;
  color: var(--csd-ink);
}

.csd-body p,
.csd-body li {
  font-family: var(--default-font, "DM Sans"), system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.75;
  color: var(--csd-ink-muted);
}

.csd-body p {
  margin: 0 0 1.1rem;
}

.csd-body ul,
.csd-body ol {
  margin: 0 0 1.25rem;
  padding-left: 1.35rem;
}

/* Reset legacy colored list backgrounds from old CMS HTML */
.csd-body ul[style],
.csd-body ol[style] {
  padding: 0 0 0 1.35rem !important;
  border-radius: 0 !important;
  background: transparent !important;
}

.csd-body blockquote,
.csd-quote {
  margin: 2rem 0;
  padding: 1.5rem;
  border: 0;
  border-top: 1px solid var(--csd-line);
  border-left: 1px solid var(--csd-line);
  border-radius: 0;
  background: #ffffff;
}

.csd-body blockquote p,
.csd-quote p {
  margin: 0 0 1rem;
  font-family: var(--accent-font, Manrope), system-ui, sans-serif;
  font-size: clamp(1.1rem, 1.8vw, 1.35rem);
  font-weight: 600;
  font-style: normal;
  line-height: 1.45;
  color: var(--csd-ink);
}

.csd-body blockquote p:last-child,
.csd-quote p:last-child {
  margin-bottom: 0;
  font-family: var(--default-font, "DM Sans"), system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 400;
  opacity: 0.8;
  color: var(--csd-ink-muted);
}

.csd-body table {
  width: 100%;
  margin: 1.75rem 0;
  border-collapse: collapse;
  font-size: 0.95rem;
  background: #ffffff;
}

.csd-body caption h4 {
  margin: 0 0 0.75rem;
  font-family: var(--accent-font, Manrope), system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 700;
  text-align: left;
  color: var(--csd-ink);
}

.csd-body th,
.csd-body td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--csd-line);
  text-align: left;
  vertical-align: top;
  color: var(--csd-ink-muted);
}

.csd-body th {
  font-weight: 600;
  color: var(--csd-ink);
}

.csd-body tr:last-child td,
.csd-body tr:last-child th {
  border-bottom: 0;
}

/* —— Sidebar: flat sticky column (Diffblue — no card box) —— */

.csd-sidebar {
  align-self: start;
  width: 100%;
  max-width: 325px;
}

@media (min-width: 992px) {
  .csd-sidebar {
    grid-column: 1;
    grid-row: 1;
    position: sticky;
    top: var(--csd-sticky-top);
    max-height: calc(100vh - var(--csd-sticky-top) - 1.5rem);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(12, 27, 46, 0.15) transparent;
  }

  .csd-sidebar::-webkit-scrollbar {
    width: 4px;
  }

  .csd-sidebar::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(12, 27, 46, 0.15);
  }
}

.csd-sidebar__inner {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.csd-sidebar__heading {
  margin: 0 0 1rem;
  font-family: var(--accent-font, Manrope), system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--csd-ink);
}

.csd-toc {
  display: none;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0 0 2.75rem;
  padding: 0 0 2.75rem;
  border-bottom: 1px solid var(--csd-line);
}

@media (min-width: 992px) {
  .csd-toc {
    display: flex;
  }
}

.csd-toc__link {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  font-family: var(--default-font, "DM Sans"), system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1.4;
  color: var(--csd-ink-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.csd-toc__link:hover,
.csd-toc__link.is-active {
  color: var(--csd-ink);
}

.csd-toc__link.is-active {
  font-weight: 600;
}

.csd-toc__link.is-active .csd-toc__num {
  color: var(--csd-accent);
}

.csd-toc__num {
  flex-shrink: 0;
  font-family: var(--accent-font, Manrope), system-ui, sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--csd-ink-soft);
}

.csd-meta-block {
  margin-bottom: 2.25rem;
}

.csd-meta__value {
  margin-top: 0.75rem;
  padding: 0.75rem 0 0 1rem;
  border: 0;
  border-top: 1px solid var(--csd-line);
  border-left: 1px solid var(--csd-line);
  border-radius: 0;
  background: transparent;
  font-family: var(--default-font, "DM Sans"), system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--csd-ink);
}

.csd-website-link {
  display: inline-flex;
  margin-bottom: 1.5rem;
  font-family: var(--default-font, "DM Sans"), system-ui, sans-serif;
  font-size: 1rem;
  color: var(--csd-ink);
  text-decoration: none;
}

.csd-website-link span {
  position: relative;
  padding-bottom: 0.5rem;
}

.csd-website-link span::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: rgba(12, 27, 46, 0.2);
}

.csd-website-link:hover span::after {
  height: 2px;
}

.csd-sidebar__stats {
  display: grid;
  gap: 1.5rem;
  margin-top: 2.5rem;
}

@media (max-width: 991px) {
  .csd-sidebar {
    position: static;
    max-width: none;
    max-height: none;
    overflow: visible;
  }

  .csd-toc {
    display: flex;
  }

  .csd-sidebar__stats {
    display: none;
  }

  .csd-meta-block:nth-child(n+4) {
    display: inline-block;
    width: calc(50% - 0.75rem);
    margin-right: 1rem;
    vertical-align: top;
  }
}

/* —— Bottom CTA (Diffblue “Book a demo” block) —— */

.csd-cta {
  margin-top: clamp(2.5rem, 4vw, 3rem);
}

.csd-cta__inner {
  position: relative;
  overflow: hidden;
  padding: clamp(1.75rem, 3vw, 2rem);
  border-radius: 3px;
  background: var(--csd-accent);
  color: #ffffff;
}

.csd-cta__title {
  margin: 0 0 0.75rem;
  max-width: 28rem;
  font-family: var(--accent-font, Manrope), system-ui, sans-serif;
  font-size: clamp(1.35rem, 2.5vw, 2rem);
  font-weight: 700;
  line-height: 1.2;
  color: #ffffff;
}

.csd-cta__text {
  margin: 0 0 1.5rem;
  max-width: 36rem;
  font-size: 1rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.88);
}

.csd-cta__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 45px;
  padding: 0.65rem 1.35rem;
  border: 1px solid #ffffff;
  border-radius: 3px;
  font-family: var(--accent-font, Manrope), system-ui, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--csd-accent);
  background: #ffffff;
  transition: background 0.2s ease, color 0.2s ease;
}

.csd-cta__btn:hover {
  color: #ffffff;
  background: transparent;
}

/* —— Not found —— */

.case-study-missing {
  padding: 120px 0 100px;
  background: #ffffff;
}

.case-study-missing__panel {
  max-width: 520px;
  padding: 28px 24px;
  border-radius: 3px;
  border: 1px solid var(--csd-line);
  background: #ffffff;
}

.case-study-missing__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 22px;
  border-radius: 3px;
  font-family: var(--accent-font, Manrope), system-ui, sans-serif;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  color: #ffffff;
  background: var(--csd-accent);
}

@media (max-width: 575px) {
  .csd-masthead__img {
    aspect-ratio: 16 / 10;
  }
}
