/* ============================================================
   CASE STUDY — page layout & content styles
   Complements main.css + components.css on case study pages.
   ============================================================ */

/* Case study pages use a wider column than the site default (960px).
   1440px matches the Figma canvas width: 800px center column + 320px
   annotation margin on each side. Text blocks have their own max-widths
   so prose stays narrow; figures get full page-margin space. */
.content-column--wide {
  max-width: 1440px;
}

/* --- Splash (title + hero image, full-bleed) -------------- */

.cs-splash {
  background: var(--color-surface);
  overflow: hidden;
}

.cs-splash__inner {
  max-width: 1440px;
  margin: 0 auto;
  padding-inline: clamp(var(--space-4), 6.25vw, 90px);
  padding-top:    clamp(var(--space-16), 5vw, var(--space-24));
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  align-items: center;
  gap: var(--space-12);
}

.cs-splash__text {
  padding-bottom: clamp(var(--space-12), 4vw, var(--space-20));
}

.cs-splash__title {
  font-size: clamp(2rem, 3.5vw, 3.125rem);   /* 50px @ Figma */
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  line-height: 1;
  color: var(--color-text);
}

.cs-splash__hero {
  margin: 0;
  align-self: end;
}

.cs-splash__hero img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 500px;
  object-fit: cover;
  object-position: top center;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  box-shadow: 0 8px 30px rgba(0,0,0,0.32);
}

@media (max-width: 640px) {
  .cs-splash__inner {
    grid-template-columns: 1fr;
    padding-inline: var(--gutter);
  }
  .cs-splash__text {
    padding-bottom: var(--space-4); /* collapse the 48px min gap on mobile */
  }
  .cs-splash__hero img {
    max-height: 280px;
    border-radius: var(--radius-md) var(--radius-md) 0 0; /* top rounded, bottom straight */
  }
}

/* --- Meta bar (below hero: Role / Skills / Team / Platform) */

.cs-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-8) var(--space-12);
  padding-block: var(--space-10);
  /* Escape the content column's 24px gutter, then match the hero's
     clamp padding exactly — left/right edges align with cs-splash. */
  margin-inline: calc(-1 * var(--gutter));
  padding-inline: clamp(var(--space-4), 6.25vw, 90px);
  border-bottom: var(--border-thin);
  margin-bottom: var(--space-12);
}

.cs-meta__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.cs-meta__value {
  font-size: var(--text-body);
  font-weight: var(--weight-medium);
  color: var(--color-text);
  line-height: 1.6;
}

ul.cs-meta__value {
  list-style: none;
  padding: 0;
  margin: 0;
}

.cs-meta__team {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cs-meta__team li {
  font-size: var(--text-body);
  line-height: 1.5;
}

.cs-meta__team li strong {
  font-weight: var(--weight-medium);
  color: var(--color-text);
}

.cs-meta__team li strong::after {
  content: ' —';
  font-weight: var(--weight-regular);
  color: var(--color-text-muted);
}

.cs-meta__team li span {
  color: var(--color-text-muted);
}

/* --- Text block (prose-constrained to ~680px) ------------- */

.cs-text {
  max-width: 800px;
  margin-inline: auto;
  margin-bottom: var(--space-6);
}

.cs-text h2 {
  font-size: var(--text-2xl);
  letter-spacing: var(--tracking-tight);
  margin-top: var(--space-16);
  margin-bottom: var(--space-4);
}

.cs-text h3 {
  font-size: var(--text-xl);
  margin-top: var(--space-10);
  margin-bottom: var(--space-3);
}

.cs-text p {
  color: var(--color-text-secondary);
  line-height: var(--leading-loose);
  margin-bottom: var(--space-5);
}

.cs-text p:last-child { margin-bottom: 0; }

.cs-text strong {
  color: var(--color-text);
  font-weight: var(--weight-semibold);
}

.cs-text ul {
  font-size: var(--text-body);
  color: var(--color-text-secondary);
  line-height: var(--leading-loose);
  padding-left: 80px; /* 2× browser default 40px */
  margin-bottom: var(--space-5);
}

.cs-text ul li {
  margin-bottom: var(--space-1);
}

/* --- Figure label (eyebrow above images) ------------------ */

.cs-figure-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
  display: block;
}

/* When a figure label sits directly above a pointer figure or storyboard,
   center it over the 800px screenshot (matches image alignment). */
.cs-pointer-fig > .cs-figure-label {
  max-width: 800px;
  margin-inline: auto;
  text-align: center;
}

/* --- Figure caption (below images, same size as annotation text) */

.cs-caption {
  max-width: 800px;
  margin-inline: auto;
  margin-top: calc(-1 * var(--space-5));
  margin-bottom: var(--space-6);
  font-size: var(--text-sm);
  line-height: 1.3;
  color: var(--color-text-muted);
}

/* --- Hierarchy diagram ------------------------------------ */

.hierarchy-diagram {
  display: block;
  width: fit-content;
  margin-inline: auto;
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-8) var(--space-10) var(--space-8) var(--space-8);
}

.hierarchy-list {
  list-style: none;
  counter-reset: hlist;
  padding: 0;
  margin: 0;
}

.hierarchy-list li {
  counter-increment: hlist;
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding-block: 0.3rem;
  font-size: var(--text-body);
  color: var(--color-text);
  line-height: 1.4;
}

.hierarchy-list li::before {
  content: counter(hlist) ".";
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
  min-width: 1.75em;
  font-size: var(--text-sm);
  flex-shrink: 0;
}

/* Progressive indentation by depth */
.hierarchy-list li:nth-child(1) { padding-left: 0; }
.hierarchy-list li:nth-child(2) { padding-left: 1.25rem; }
.hierarchy-list li:nth-child(3) { padding-left: 2.5rem; }
.hierarchy-list li:nth-child(4) { padding-left: 3.75rem; }
.hierarchy-list li:nth-child(5) {
  padding-left: 5rem;
  border-top: var(--border-thin);
  padding-top: var(--space-3);
  margin-top: var(--space-2);
}
.hierarchy-list li:nth-child(6) { padding-left: 6.25rem; }

/* --- Mobile screenshot frame ------------------------------ */

/* ── Storyboard: two-column within content column ── */
.cs-storyboard-wrap {
  max-width: 800px;
  margin-inline: auto;
}

.cs-storyboard {
  display: flex;
  gap: var(--space-8);
  align-items: stretch;
}

.cs-storyboard__image-col {
  flex: 0 0 44%;
  display: flex;
  flex-direction: column;
}

.cs-storyboard__image-col > .cs-figure-label {
  text-align: center;
  margin-bottom: var(--space-3);
}

.cs-storyboard__image {
  flex: 1;
  margin: 0;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 30px rgba(0,0,0,0.20);
  overflow: hidden;
}

.cs-storyboard__image img {
  display: block;
  width: 100%;
  height: auto;
}

.cs-storyboard__notes {
  flex: 1;
  position: relative;
}

/* Each note is pinned at its y-position within the notes column */
.cs-storyboard-note {
  position: absolute;
  top: var(--y);
  left: 0;
  right: 0;
}

.cs-storyboard-note__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-1);
}

.cs-storyboard-note__desc {
  font-size: var(--text-sm);
  line-height: 1.4;
  margin: 0;
  color: var(--color-text);
}

/* Wide-image variant: images take 65% of the column */
.cs-storyboard--wide-image .cs-storyboard__image-col { flex-basis: 65%; }

/* Mobile: stack */
@media (max-width: 700px) {
  .cs-storyboard {
    flex-direction: column;
  }
  .cs-storyboard__image {
    flex: none;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
  }
  .cs-storyboard__notes {
    position: static;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
  }
  .cs-storyboard-note {
    position: static;
  }
}

.cs-mobile-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-block: var(--space-12);
}

/* legacy annotated-image support */
.cs-mobile-frame .annotated-image {
  max-width: 390px;
  width: 100%;
}
.cs-mobile-frame .annotated-image__media img {
  border-radius: var(--radius-md);
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
}

/* --- Recirculation ---------------------------------------- */

.cs-recirc {
  width: 100%;
  background-color: var(--color-surface);
  border-top: var(--border-thin);
  padding-block: var(--space-16);
  margin-top: var(--space-16);
}

/* Recirc already acts as the page footer — no extra gap needed */
.site-footer { margin-top: 0; }

.cs-recirc__inner {
  max-width: var(--width-wide);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.cs-recirc__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

.cs-recirc__link {
  display: inline-block;
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
  text-decoration: none;
  line-height: var(--leading-snug);
  transition: color var(--duration-fast) var(--ease-out);
}

.cs-recirc__link:hover { color: var(--color-green); }

@media (max-width: 640px) {
  .cs-recirc__link { font-size: var(--text-xl); }
  .hierarchy-diagram { padding: var(--space-6); }
  .hierarchy-list li { font-size: 1rem; }
  .hierarchy-list li:nth-child(4) { padding-left: 2.25rem; }
  .hierarchy-list li:nth-child(5) { padding-left: 2.25rem; }
  .hierarchy-list li:nth-child(6) { padding-left: 2.25rem; }

  /* Team list: stack name + title, remove em dash */
  .cs-meta { padding-inline: var(--gutter); }
  .cs-meta__team { gap: 0.75rem; }
  .cs-meta__team li { line-height: 1.2; }
  .cs-meta__team li strong { display: block; }
  .cs-meta__team li strong::after { content: ''; }
  .cs-meta__team li span { display: block; font-size: 0.875rem; }
}


/* --- Side-by-side workflow comparison -----------------------
   Layout: [old] [240px center — caption overflow] [new]
   Dots live on the new workflow image (pointer--left at ~x:2%).
   Captions appear leftward into the center column gap.         */

/* Break out of the 960px content column; center with growing margins above ~1264px */
.cs-compare {
  width: 100vw;
  margin-left: 50%;
  transform: translateX(-50%);
  box-sizing: border-box;
  padding-inline: max(var(--space-8), calc((100vw - 1200px) / 2));

  display: grid;
  grid-template-columns: 1fr clamp(60px, 20%, 240px) 1fr;
  column-gap: 0;
  align-items: start;
  margin-block: var(--space-12);
}

.cs-compare__old {
  display: flex;
  flex-direction: column;
}

.cs-compare__old .cs-figure-label,
.cs-compare__new .cs-figure-label {
  text-align: center;
  margin-bottom: var(--space-3);
  min-height: 1.5em; /* keep labels the same height even if one wraps */
}

.cs-compare__old img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 30px rgba(0,0,0,0.20);
}

/* Center column: empty — exists only to reserve space for caption overflow */
.cs-compare__center { /* intentionally empty */ }

/* New workflow: inherits cs-pointer-fig structure */
.cs-compare .cs-compare__new {
  margin-block: 0;
}

.cs-compare__new .cs-pointer-fig__media {
  max-width: none;
  margin: 0;
}

/* Pointer captions: fluid width that shrinks with the center column */
.cs-compare__new .pointer--left .pointer__caption {
  width: clamp(100px, 17vw, 200px);
  text-align: left;
}

/* ≤768px: hide Old Workflow, center New Workflow */
@media (max-width: 768px) {
  .cs-compare {
    grid-template-columns: 1fr;
    padding-inline: var(--space-6);
  }
  .cs-compare__old,
  .cs-compare__center { display: none; }
  .cs-compare__new {
    max-width: 480px;
    margin-inline: auto;
  }
}

/* <600px: screenshot fills column */
@media (max-width: 600px) {
  .cs-compare__new {
    max-width: none;
  }
}


/* --- Layout variant figures (Trimming the Clutter pattern) ---
   Each block: image (65%) left, label + note (35%) right.        */

.cs-layout-variants {
  max-width: 800px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
  margin-block: var(--space-10);
}

.cs-layout-variant {
  display: flex;
  gap: var(--space-8);
  align-items: flex-start;
}

.cs-layout-variant__image {
  flex: 0 0 65%;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 30px rgba(0,0,0,0.20);
  overflow: hidden;
}

.cs-layout-variant__image img {
  display: block;
  width: 100%;
  height: auto;
}

.cs-layout-variant__caption {
  flex: 1;
  padding-top: var(--space-1);
}

.cs-layout-variant__caption .cs-figure-label {
  margin-bottom: var(--space-2);
}

.cs-layout-variant__note {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.4;
  color: var(--color-text);
}

@media (max-width: 700px) {
  .cs-layout-variant {
    flex-direction: column;
  }
  .cs-layout-variant__image {
    flex: none;
    width: 100%;
  }
}


/* --- Before/after comparison table ------------------------- */

.cs-table {
  width: 100%;
  max-width: 560px;
  margin-inline: auto;
  border-collapse: collapse;
  font-size: var(--text-body);
}

.cs-table th,
.cs-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--color-surface);
}

.cs-table th {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--color-text-muted);
  border-bottom-color: var(--color-text-muted);
}

.cs-table tbody tr:last-child td { border-bottom: none; }

.cs-table__arrow {
  color: var(--color-green);
  text-align: center;
  padding-inline: var(--space-3);
  width: 2em;
  font-size: 1rem;
  white-space: nowrap;
}

/* Equal-width name columns so the arrow sits exactly between them */
.cs-table td:first-child,
.cs-table th:first-child {
  width: 48%;
}

.cs-table td:last-child,
.cs-table th:last-child {
  width: 48%;
}


/* ============================================================
   POINTER / ANNOTATION SYSTEM  (Erik Kennedy–style)

   Markup:
     <div class="cs-pointer-fig">
       <p class="cs-figure-label">Label</p>
       <div class="cs-pointer-fig__media">
         <img src="…" alt="…">
         <div class="pointer" style="--x: 87%; --y: 22%">
           <button type="button" class="pointer__dot" aria-label="…"></button>
           <span  class="pointer__line" aria-hidden="true"></span>
           <p     class="pointer__caption">Caption text.</p>
         </div>
         <div class="pointer pointer--left" style="--x: 14%; --y: 55%">
           …
         </div>
       </div>
     </div>

   --x / --y    Percentage position of the dot on the image (0–100%).
   pointer       Default: caption goes in the RIGHT margin.
   pointer--left Caption goes in the LEFT margin.

   Desktop ≥1200px  Captions always visible in side margins, connected
                    by a hairline from the dot to the figure edge.
   Mobile  <1200px  Pulsing dot; tap opens a tooltip above the dot.
   ============================================================ */

/* --- Figure wrapper --------------------------------------- */

.cs-pointer-fig {
  margin-block: var(--space-12);
}

/* The 800 px image box that anchors all absolutely-positioned children */
.cs-pointer-fig__media {
  position: relative;
  max-width: 800px;
  margin: 0 auto;
}

.cs-pointer-fig__media img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 30px rgba(0,0,0,0.20);
}

/* --- Dot -------------------------------------------------- */

.pointer__dot {
  position: absolute;
  top:  var(--y);
  left: var(--x);
  transform: translate(-50%, -50%);
  width:  22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,0.70);
  border: 1.5px solid rgba(255,255,255,0.70);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
  z-index: 2;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.2s ease;
}

.pointer__dot::before {
  content: '+';
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1;
  color: var(--color-green);
  transition: color 0.15s ease;
}

/* keyframes live outside media queries for browser compat */
@keyframes pointer-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(43,109,56,0.30); }
  60%  { box-shadow: 0 0 0 6px rgba(43,109,56,0);    }
  100% { box-shadow: 0 0 0 0   rgba(43,109,56,0);    }
}

/* --- Line ------------------------------------------------- */

.pointer__line {
  display: none; /* hidden on mobile; shown on desktop */
}

/* --- Caption ---------------------------------------------- */

/* (base rules overridden per breakpoint below) */
.pointer__caption {
  font-size: var(--text-sm);
  line-height: 1.3;
}

/* ══════════════════════════════════════════════════════════
   DESKTOP  ≥1200px — lines + always-visible margin captions
   ══════════════════════════════════════════════════════════ */

@media (min-width: 1200px) {

  .pointer__dot {
    cursor: default; /* not interactive on desktop */
    background: rgba(255,255,255,0.80);
    border-color: var(--color-green);
  }

  /* Hairline from dot edge to figure edge */
  .pointer__line {
    display: block;
    position: absolute;
    top: var(--y);
    height: 1px;
    background: rgba(43,109,56,0.18);
    transition: background 0.12s ease;
    /* right-side: from dot's right edge to the container's right edge */
    left:  calc(var(--x) + 11px);
    width: calc(100% - var(--x) - 11px);
  }

  .pointer--left .pointer__line {
    /* left-side: from container's left edge to dot's left edge */
    left:  0;
    width: calc(var(--x) - 11px);
  }

  /* Caption lives OUTSIDE the figure, in the page margin.
     --label-y lets the caption sit at a different height than the dot
     (Figma uses angled connectors; we approximate by allowing the
     caption to float independently while the line still hugs the dot). */
  .pointer__caption {
    position: absolute;
    top: var(--label-y, var(--y));
    transform: translateY(-50%);
    color: var(--color-text-muted);
    /* right-side */
    left:  calc(100% + 16px);
    width: clamp(160px, calc((100vw - 875px) / 2), 230px);
    border-left: 1px solid rgba(43,109,56,0.18);
    padding-left: 12px;
    transition: color 0.12s ease, border-color 0.12s ease;
  }

  .pointer--left .pointer__caption {
    left:  auto;
    right: calc(100% + 16px);
    border-left: none;
    border-right: 1px solid rgba(43,109,56,0.18);
    padding-left: 0;
    padding-right: 12px;
    text-align: right;
  }


  /* Dot hover: triggered directly on the button */
  .pointer__dot:hover,
  .pointer:hover .pointer__dot {
    background: #C9D7C7;
    border-color: var(--color-green);
    cursor: default;
  }
  .pointer__dot:hover::before,
  .pointer:hover .pointer__dot::before { color: var(--color-green); }

  /* Line + caption: triggered by hovering anywhere in the pointer group
     (including the caption text itself, since :hover fires on any descendant) */
  .pointer:hover .pointer__line { background: rgba(43,109,56,0.38); }
  .pointer:hover .pointer__caption {
    color: var(--color-text);
    border-color: rgba(43,109,56,0.38);
  }
}

/* ══════════════════════════════════════════════════════════
   MOBILE / TABLET  <1200px — pulsing dot + tap-to-tooltip
   ══════════════════════════════════════════════════════════ */

@media (max-width: 1199px) {

  .pointer__dot {
    cursor: default;
    border-color: var(--color-green);
  }

  /* Active: fill the dot, rotate only the + glyph */
  .pointer.is-active .pointer__dot {
    background: var(--color-green);
    border-color: var(--color-green);
  }
  .pointer.is-active .pointer__dot::before {
    color: #fff;
    transform: rotate(45deg);
  }

  /* Tooltip: hidden by default, appears below the dot */
  .pointer__caption {
    position: absolute;
    top:    calc(var(--y) + 14px);
    bottom: auto;
    left:   clamp(100px, var(--x), calc(100% - 100px));
    transform: translateX(-50%) translateY(-10px);
    width: 200px;
    background: var(--color-neutral-900);
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: 0.75rem;
    line-height: 1.45;
    z-index: 10;
    pointer-events: none;
    opacity: 0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.28);
    transition: opacity 0.18s ease, transform 0.18s ease;
  }

  .pointer.is-active .pointer__caption {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
  }
}

/* Narrow mobile frame (375px) for the mobile screenshot section */
.cs-mobile-frame .cs-pointer-fig__media {
  max-width: 375px;
}

/* Ensure the wide column is wide enough for margin captions */
.content-column--wide {
  overflow: visible;
}
