/* =========================================================================
   CASE STUDY PAGES
   Used by: case-study-fraud.html, case-study-clinical-trial.html,
            case-study-cad.html
   Loaded after css/style.css, so base fonts, colours and the header
   come from there. Everything here is prefixed "cs-".

   Page structure (top to bottom):
     .cs-page            the whole case study
       .cs-intro         title, lead, at-a-glance table, hero image
       .cs-toolbar       "Expand all details" button + reading times
       .cs-section       one per chapter of the story
         .cs-takeaway    one bold sentence: the point of the section
         .cs-row         text beside image (stacks on small screens)
         details.cs-more the in-depth part, collapsed by default
       .cs-next          links to the next case study / back home
   ========================================================================= */

/* ---------- Colours (match the main site) ---------- */
:root {
  --cs-ink: #000333;          /* headings */
  --cs-text: #333;            /* body text (darker than the site default for contrast) */
  --cs-muted: #615d6b;        /* captions, notes */
  --cs-accent: #615d6b;       /* buttons, links */
  --cs-tint: hsla(258, 11%, 57%, 0.12);   /* light purple-grey backgrounds */
  --cs-tint-strong: hsla(258, 11%, 57%, 0.25);
  --cs-line: #d9d6df;
}

/* ---------- Page container ---------- */
.cs-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
  color: var(--cs-text);
  background: #fff;
}

.cs-page p { max-width: 70ch; }       /* comfortable line length */

.cs-page a:not([class]) { color: var(--cs-accent); }

/* ---------- Intro ---------- */
.cs-back { font-size: 0.9rem; margin-bottom: 2rem; }

.cs-eyebrow {
  color: var(--cs-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  margin: 0 0 0.5rem;
}

.cs-page h1 {
  display: block;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.15;
  margin: 0 0 1rem;
  color: var(--cs-ink);
}

.cs-lead {
  font-size: 1.25rem;
  line-height: 1.6;
  color: #000;
  margin-bottom: 2rem;
}

/* Intro on wide screens: text and glance table left, hero image right */
.cs-intro-grid {
  display: grid;
  gap: 2rem;
  align-items: start;
}

@media (min-width: 900px) {
  .cs-intro-grid { grid-template-columns: 5fr 7fr; }
}

.cs-hero {
  display: block;
  width: auto;          /* never larger than the image's own size (no blur) */
  max-width: 100%;      /* ...but shrink to fit smaller screens */
  height: auto;
  border-radius: 8px;
}

.cs-note { font-size: 0.85rem; color: var(--cs-muted); margin-top: 0.75rem; }

/* ---------- Tables (at-a-glance and comparisons) ---------- */
.cs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin: 0 0 1rem;
}

.cs-table th,
.cs-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--cs-line);
}

.cs-table th { font-weight: 600; color: var(--cs-ink); }

.cs-table--glance th { width: 30%; white-space: nowrap; }

.cs-table thead th { background: var(--cs-tint-strong); }

/* ---------- Toolbar: expand all + reading time ---------- */
.cs-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin: 2.5rem 0 1rem;
  padding: 1rem 1.25rem;
  background: var(--cs-tint);
  border-radius: 8px;
}

.cs-toolbar p { margin: 0; font-size: 0.95rem; }

/* ---------- Sections ---------- */
.cs-section {
  padding: 3rem 0 1rem;
  border-top: 1px solid var(--cs-line);
  margin-top: 2rem;
}

.cs-section h2 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  line-height: 1.2;
  margin: 0 0 0.75rem;
  color: var(--cs-ink);
}

.cs-section h3 { font-size: 1.3rem; margin: 1.5rem 0 0.5rem; }

.cs-takeaway {
  font-size: 1.15rem;
  font-weight: 600;
  color: #000;
  margin-bottom: 1.25rem;
}

/* Text beside image on wide screens; stacked on narrow ones */
.cs-row {
  display: grid;
  gap: 2rem;
  align-items: start;
}

@media (min-width: 900px) {
  .cs-row { grid-template-columns: 5fr 7fr; }
  .cs-row--wide-text { grid-template-columns: 7fr 5fr; }
}

.cs-page ul,
.cs-page ol { padding-left: 1.25rem; margin: 0 0 1rem; }

.cs-page li { margin-bottom: 0.5rem; max-width: 70ch; }

/* ---------- Figures ---------- */
.cs-figure { margin: 0 0 1.5rem; }

.cs-figure img,
.cs-figure svg {
  display: block;
  height: auto;
  border-radius: 6px;
}

/* Photos/screenshots: never stretched beyond their real size, so they stay sharp */
.cs-figure img { width: auto; max-width: 100%; }

/* Diagrams (SVG) are vectors, so they can always fill the width */
.cs-figure svg { width: 100%; }

.cs-figure--full { margin-top: 1.5rem; }       /* full-width image under a row */

.cs-figure--narrow img { max-width: 520px; margin: 0 auto; }

.cs-figure figcaption {
  font-size: 0.85rem;
  color: var(--cs-muted);
  margin-top: 0.5rem;
}

/* Image links open the full-size file in a new tab */
.cs-zoom { display: block; cursor: zoom-in; }
.cs-zoom:hover img { opacity: 0.92; }
.cs-fullsize { white-space: nowrap; margin-left: 0.35em; color: var(--cs-accent); }

/* ---------- Quotes ---------- */
.cs-quote {
  margin: 1rem 0;
  padding: 0.75rem 1.25rem;
  border-left: 4px solid var(--cs-accent);
  background: var(--cs-tint);
  font-size: 1.1rem;
  font-style: italic;
  color: #000;
}

/* ---------- Expandable detail: <details class="cs-more"> ---------- */
.cs-more {
  margin: 1.5rem 0 0;
  border: 1px solid var(--cs-line);
  border-radius: 8px;
  background: #fff;
}

.cs-more > summary {
  cursor: pointer;
  list-style: none;                 /* hide the default triangle */
  padding: 0.9rem 1.25rem;
  font-weight: 600;
  color: var(--cs-accent);
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  flex-wrap: wrap;
}

.cs-more > summary::-webkit-details-marker { display: none; }

/* Our own arrow, rotates when open */
.cs-more > summary::before {
  content: "\25B8";                 /* ▸ */
  display: inline-block;
  transition: transform 0.2s ease;
}

.cs-more[open] > summary::before { transform: rotate(90deg); }

.cs-more > summary:hover { background: var(--cs-tint); }

.cs-more > summary:focus-visible { outline: 3px solid var(--cs-accent); outline-offset: 2px; }

/* "2 min · methods, quotes, affinity map" */
.cs-more-meta { font-weight: 400; color: var(--cs-muted); font-size: 0.9rem; }

.cs-more-body { padding: 0.5rem 1.25rem 1.25rem; }

/* ---------- Buttons ---------- */
.cs-button {
  display: inline-block;
  border: 0;
  border-radius: 8px;
  padding: 0.6rem 1.2rem;
  background-color: var(--cs-accent);
  color: #fff;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 2px 2px rgba(0, 0, 0, 0.45);
}

.cs-button:hover { box-shadow: none; filter: brightness(0.9); }

.cs-button:focus-visible { outline: 3px solid var(--cs-ink); outline-offset: 2px; }

.cs-button--quiet {
  background: #fff;
  color: var(--cs-accent);
  box-shadow: inset 0 0 0 2px var(--cs-accent);
}

/* ---------- Next case study / back ---------- */
.cs-next {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--cs-line);
}

/* ---------- Print / save as PDF: show everything, hide controls ---------- */
@media print {
  header,
  .cs-toolbar,
  .cs-next,
  .cs-back,
  .cs-fullsize { display: none !important; }

  .cs-more { border: 0; }
  .cs-more > summary::before { content: none; }
  .cs-page { padding: 0; max-width: none; }
}

/* The home page shades every other <article> grey; keep case studies white */
article.cs-page,
article.cs-page:nth-child(odd) { background: #fff; }

/* Back link: at least a 24px tall tap target */
.cs-back a { display: inline-block; padding: 6px 0; }

/* SVG files shown with <img> are vectors too: let them fill the width */
.cs-figure img[src$=".svg"] { width: 100%; }
