/*
 * Case study body: the typography for block editor content and the three
 * "Case Studies" block patterns registered in inc/case-studies.php.
 *
 * Loaded on single case studies, where the content sits in .cs-body, and in
 * the block editor for case studies, where the canvas root carries
 * .editor-styles-wrapper (the <body> of the editor iframe, or a div when the
 * editor isn't iframed), so every rule targets both.
 *
 * functions.php dequeues core's block stylesheet, but WordPress enqueues it
 * again (in the footer, after this file) for every core block it renders, and
 * the editor has it anyway. Rules that must win over core's therefore carry
 * the block's own class as well. The column itself (width, spacing) is set in
 * template-parts/case-studies/section-body.php.
 */

@font-face {
  font-family: 'Poppins';
  src: url('../fonts/Poppins-Regular.woff2') format('woff2'), url('../fonts/Poppins-Regular.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Poppins';
  src: url('../fonts/Poppins-Medium.woff2') format('woff2'), url('../fonts/Poppins-Medium.woff') format('woff');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Poppins';
  src: url('../fonts/Poppins-SemiBold.woff2') format('woff2'), url('../fonts/Poppins-SemiBold.woff') format('woff');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Poppins';
  src: url('../fonts/Poppins-Bold.woff2') format('woff2'), url('../fonts/Poppins-Bold.woff') format('woff');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---- Base ---------------------------------------------------------- */

:is(.cs-body, .editor-styles-wrapper) {
  --cs-ink: #0e172a;
  --cs-text: #525760;
  --cs-muted: #6f7a8a;
  --cs-navy: #1d3f6e;
  --cs-orange: #f36649;
  --cs-orange-dark: #ee3610;
  --cs-line: #e5e7eb;
  --cs-tint-blue: #e8f2ff;
  --cs-tint-orange: #fff1ec;
  --cs-card: #f8f8f8;
  font-family: 'Poppins', sans-serif;
  font-size: 18px;
  line-height: 1.7;
  color: var(--cs-text);
  -webkit-font-smoothing: antialiased;
}

/* The editor canvas: same column width and title as the site. */
.editor-styles-wrapper {
  background: #fff;
}

.editor-styles-wrapper .wp-block {
  max-width: 760px;
}

.editor-styles-wrapper .wp-block[data-align="wide"] {
  max-width: 1100px;
}

.editor-styles-wrapper .wp-block[data-align="full"] {
  max-width: none;
}

.editor-styles-wrapper :is(.editor-post-title, .wp-block-post-title) {
  font-family: 'Poppins', sans-serif;
  font-size: 40px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--cs-ink);
}

/* ---- Text ---------------------------------------------------------- */

/* main.css sets every <p> to 16px with a fixed line height and its own
   colour, which the editor never loads. Inherit the body's instead, so text
   is the same size on the site as in the editor. */
:is(.cs-body, .editor-styles-wrapper) p {
  margin: 0 0 24px;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

:is(.cs-body, .editor-styles-wrapper) :is(h1, h2, h3, h4, h5, h6) {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--cs-ink);
  margin: 48px 0 16px;
}

/* main.css colours spans in headings orange; here they keep the heading's
   colour. */
:is(.cs-body, .editor-styles-wrapper) :is(h1, h2, h3, h4, h5, h6) span {
  color: inherit;
}

/* A heading never sits next to a floated image. */
:is(.cs-body, .editor-styles-wrapper) :is(h1, h2, h3, h4, h5, h6) {
  clear: both;
}

:is(.cs-body, .editor-styles-wrapper) h1 {
  font-size: 34px;
}

:is(.cs-body, .editor-styles-wrapper) h2 {
  font-size: 28px;
}

:is(.cs-body, .editor-styles-wrapper) h3 {
  font-size: 22px;
}

:is(.cs-body, .editor-styles-wrapper) h4 {
  font-size: 18px;
}

:is(.cs-body, .editor-styles-wrapper) :is(h5, h6) {
  font-size: 16px;
}

:is(.cs-body, .editor-styles-wrapper) :is(strong, b) {
  font-weight: 600;
  color: var(--cs-ink);
}

:is(.cs-body, .editor-styles-wrapper) a:not(.wp-block-button__link) {
  color: var(--cs-orange-dark);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

:is(.cs-body, .editor-styles-wrapper) a:not(.wp-block-button__link):hover {
  color: var(--cs-navy);
}

:is(.cs-body, .editor-styles-wrapper) :is(ul, ol) {
  margin: 0 0 24px;
  padding-left: 26px;
}

/* main.css removes the bullets and numbers from every list on the site, and
   the editor never loads it, so lists had bullets in the editor only. Put
   them back for List blocks (and class-less lists from pasted HTML), but not
   for other blocks built on <ul>, such as Social Icons. */
:is(.cs-body, .editor-styles-wrapper) ul:is(.wp-block-list, :not([class])) {
  list-style-type: disc;
}

:is(.cs-body, .editor-styles-wrapper) ol:is(.wp-block-list, :not([class])) {
  list-style-type: decimal;
}

:is(.cs-body, .editor-styles-wrapper) :is(ul, ol) ul:is(.wp-block-list, :not([class])) {
  list-style-type: circle;
}

:is(.cs-body, .editor-styles-wrapper) li {
  margin-bottom: 10px;
}

:is(.cs-body, .editor-styles-wrapper) li::marker {
  color: var(--cs-orange);
  font-weight: 600;
}

:is(.cs-body, .editor-styles-wrapper) :is(ul, ol) :is(ul, ol) {
  margin: 10px 0 0;
}

:is(.cs-body, .editor-styles-wrapper) .has-text-align-center {
  text-align: center;
}

:is(.cs-body, .editor-styles-wrapper) .has-text-align-right {
  text-align: right;
}

:is(.cs-body, .editor-styles-wrapper) .has-text-align-left {
  text-align: left;
}

:is(.cs-body, .editor-styles-wrapper) :is(code, kbd) {
  padding: 2px 6px;
  border-radius: 4px;
  background: #f3f4f6;
  color: var(--cs-ink);
  font-size: 0.9em;
}

:is(.cs-body, .editor-styles-wrapper) pre {
  margin: 0 0 24px;
  padding: 20px;
  border-radius: 12px;
  background: var(--cs-ink);
  color: var(--cs-line);
  font-size: 15px;
  line-height: 1.6;
  overflow-x: auto;
}

:is(.cs-body, .editor-styles-wrapper) pre code {
  padding: 0;
  background: none;
  color: inherit;
}

:is(.cs-body, .editor-styles-wrapper) hr.wp-block-separator {
  margin: 48px auto;
  border: 0;
  border-bottom: 1px solid var(--cs-line);
}

/* ---- Images and embeds --------------------------------------------- */

:is(.cs-body, .editor-styles-wrapper) .wp-block-image {
  margin: 40px 0;
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-image img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
}

:is(.cs-body, .editor-styles-wrapper) :is(.wp-block-image, .wp-block-embed, .wp-block-table) figcaption {
  margin: 12px 0 0;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  color: var(--cs-muted);
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-embed {
  margin: 40px 0;
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-embed iframe {
  max-width: 100%;
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-embed.is-type-video .wp-block-embed__wrapper {
  position: relative;
  aspect-ratio: 16 / 9;
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-embed.is-type-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 12px;
}

/* Alignments on the site: the body is a centred 760px column, so wide and
   full images grow out of it symmetrically. */
.cs-body .alignwide {
  width: min(1100px, 100vw - 48px);
  margin-left: calc(50% - min(550px, 50vw - 24px));
}

.cs-body .alignfull {
  width: 100vw;
  margin-left: calc(50% - 50vw);
}

.cs-body .alignfull img {
  border-radius: 0;
}

.cs-body .aligncenter {
  margin-left: auto;
  margin-right: auto;
}

.cs-body .alignleft {
  float: left;
  max-width: 50%;
  margin: 8px 32px 24px 0;
}

.cs-body .alignright {
  float: right;
  max-width: 50%;
  margin: 8px 0 24px 32px;
}

/* ---- Quotes -------------------------------------------------------- */

:is(.cs-body, .editor-styles-wrapper) .wp-block-quote {
  margin: 40px 0;
  padding: 4px 0 4px 28px;
  border-left: 4px solid var(--cs-orange);
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-quote p {
  margin: 0 0 16px;
  font-size: 22px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--cs-ink);
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-quote cite {
  display: block;
  font-style: normal;
  font-size: 15px;
  color: var(--cs-muted);
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-pullquote {
  margin: 48px 0;
  padding: 32px 0;
  border-top: 2px solid var(--cs-ink);
  border-bottom: 2px solid var(--cs-ink);
  text-align: center;
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-pullquote p {
  margin: 0 0 12px;
  font-size: 26px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--cs-ink);
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-pullquote cite {
  font-style: normal;
  font-size: 15px;
  color: var(--cs-muted);
}

/* Quotes and pullquotes always fill the text column. inc/case-studies.php
   removes both blocks' alignment options; this holds the ones saved with an
   alignment before that (floated, they left a gap beside them or the next
   heading wrapped round them). 760px is the column width, so in the editor
   (where the column is set per block) it matches. The top and bottom
   margins restate each block's own, which the phone rule for aligned
   blocks would otherwise halve. */
:is(.cs-body, .editor-styles-wrapper) :is(.wp-block-quote, .wp-block-pullquote):is(.alignleft, .alignright, .alignwide, .alignfull) {
  float: none;
  width: auto;
  max-width: 760px;
  margin: 40px auto;
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-pullquote:is(.alignleft, .alignright, .alignwide, .alignfull) {
  margin: 48px auto;
}

/* No gap above the first block or under the last block in a quote; the
   quote's own padding and margin space it. Without the first rule, a
   heading inside a quote added its 48px top margin to the padding. The
   last selector beats the customer quote's paragraph margin. */
:is(.cs-body, .editor-styles-wrapper) .wp-block-quote > :first-child {
  margin-top: 0;
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-quote > :last-child,
:is(.cs-body, .editor-styles-wrapper) .wp-block-quote.cs-customer-quote > p:last-child {
  margin-bottom: 0;
}

/* Core's quote styles for these live in a stylesheet the theme doesn't
   load, so they are restated here. Plain: no bar. Right-aligned text: the
   bar moves to the right. */
:is(.cs-body, .editor-styles-wrapper) .wp-block-quote.is-style-plain {
  padding: 0;
  border: 0;
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-quote.has-text-align-right:not(.is-style-plain, .cs-customer-quote) {
  padding: 4px 28px 4px 0;
  border-left: 0;
  border-right: 4px solid var(--cs-orange);
}

/* Pattern: Customer quote */
:is(.cs-body, .editor-styles-wrapper) .wp-block-quote.cs-customer-quote {
  position: relative;
  margin: 48px 0;
  padding: 44px 40px 36px;
  border: 0;
  border-radius: 16px;
  background: var(--cs-tint-blue);
}

.cs-customer-quote::before {
  content: "\201C";
  position: absolute;
  top: 10px;
  left: 28px;
  font-size: 110px;
  font-weight: 700;
  line-height: 1;
  color: var(--cs-orange);
  opacity: 0.3;
  pointer-events: none;
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-quote.cs-customer-quote p {
  position: relative;
  margin: 0 0 20px;
  font-size: 24px;
  line-height: 1.45;
}

/* Inline, not flex: in a flex row the name and the text after it became
   separate items with a gap between them ("Jane Doe , Head of …"). */
:is(.cs-body, .editor-styles-wrapper) .wp-block-quote.cs-customer-quote cite {
  display: block;
  color: var(--cs-navy);
}

.cs-customer-quote cite::before {
  content: "";
  display: inline-block;
  width: 24px;
  height: 2px;
  margin-right: 12px;
  vertical-align: middle;
  background: var(--cs-orange);
}

.cs-customer-quote cite strong {
  font-weight: 600;
  color: var(--cs-ink);
}

/* ---- Pattern: Callout box ------------------------------------------ */

.cs-callout {
  margin: 40px 0;
  padding: 20px 24px;
  border: 1px solid #ffd6c9;
  border-left: 4px solid var(--cs-orange);
  border-radius: 12px;
  background: var(--cs-tint-orange);
}

:is(.cs-body, .editor-styles-wrapper) .cs-callout p {
  margin: 0;
  font-size: 17px;
  line-height: 1.6;
  color: var(--cs-ink);
}

:is(.cs-body, .editor-styles-wrapper) .cs-callout p + p {
  margin-top: 12px;
}

/* ---- Pattern: Results row ------------------------------------------ */

.wp-block-columns.cs-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin: 40px 0;
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-columns.cs-results > .wp-block-column {
  margin: 0;
  padding: 28px 20px;
  border-radius: 12px;
  background: var(--cs-card);
  text-align: center;
}

:is(.cs-body, .editor-styles-wrapper) .cs-results .cs-results__value {
  margin: 0 0 6px;
  font-size: 40px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--cs-navy);
}

:is(.cs-body, .editor-styles-wrapper) .cs-results .cs-results__label {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--cs-muted);
}

/* ---- Buttons ------------------------------------------------------- */

:is(.cs-body, .editor-styles-wrapper) .wp-block-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 32px 0;
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-buttons.is-content-justification-center {
  justify-content: center;
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-buttons.is-content-justification-right {
  justify-content: flex-end;
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-button__link {
  display: inline-block;
  padding: 14px 28px;
  border: 2px solid var(--cs-navy);
  border-radius: 999px;
  background: var(--cs-navy);
  color: #fff;
  font-family: 'Poppins', sans-serif;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-button__link:hover {
  border-color: var(--cs-orange-dark);
  background: var(--cs-orange-dark);
  color: #fff;
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-button.is-style-outline {
  color: var(--cs-navy); /* core sets the outline style's text to currentColor */
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-button.is-style-outline > .wp-block-button__link {
  background: transparent;
  color: var(--cs-navy);
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-button.is-style-outline > .wp-block-button__link:hover {
  border-color: var(--cs-navy);
  background-color: var(--cs-navy);
  color: #fff;
}

/* ---- Tables -------------------------------------------------------- */

:is(.cs-body, .editor-styles-wrapper) .wp-block-table {
  margin: 32px 0;
  overflow-x: auto;
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-table :is(th, td) {
  padding: 12px 14px;
  border: 1px solid var(--cs-line);
  text-align: left;
  vertical-align: top;
}

:is(.cs-body, .editor-styles-wrapper) .wp-block-table th {
  background: #f9fafb;
  font-weight: 600;
  color: var(--cs-ink);
}

/* ---- Phones -------------------------------------------------------- */

@media (max-width: 767px) {
  :is(.cs-body, .editor-styles-wrapper) {
    font-size: 17px;
  }

  :is(.cs-body, .editor-styles-wrapper) :is(h1, h2, h3, h4, h5, h6) {
    margin: 36px 0 12px;
  }

  :is(.cs-body, .editor-styles-wrapper) h1 {
    font-size: 28px;
  }

  :is(.cs-body, .editor-styles-wrapper) h2 {
    font-size: 24px;
  }

  :is(.cs-body, .editor-styles-wrapper) h3 {
    font-size: 20px;
  }

  :is(.cs-body, .editor-styles-wrapper) .wp-block-quote p {
    font-size: 19px;
  }

  :is(.cs-body, .editor-styles-wrapper) .wp-block-quote.cs-customer-quote {
    padding: 36px 24px 28px;
  }

  :is(.cs-body, .editor-styles-wrapper) .wp-block-quote.cs-customer-quote p {
    font-size: 20px;
  }

  .cs-customer-quote::before {
    left: 16px;
    font-size: 90px;
  }

  :is(.cs-body, .editor-styles-wrapper) .wp-block-pullquote p {
    font-size: 22px;
  }

  :is(.cs-body, .editor-styles-wrapper) .cs-results .cs-results__value {
    font-size: 32px;
  }

  .cs-body :is(.alignleft, .alignright) {
    float: none;
    max-width: none;
    margin: 24px 0;
  }
}

/* ---- Editor column ------------------------------------------------- */

/* The editor centres each block in the column with auto side margins. The
   block rules above set side margins of 0 for the site (where the column
   itself is centred), which pinned quotes, images, buttons, tables and the
   results row to the left of the editor. Last in the file so it wins ties. */
.editor-styles-wrapper .is-root-container > .wp-block {
  margin-left: auto;
  margin-right: auto;
}
