/* Case study page structure: header, sub-navigation, the three parts
   (01 Overview, 02 In depth, 03 Insights) and their separators. */

.case-hero { padding: var(--space-6) 0 var(--space-7); }
.back-link { display: inline-block; padding: 0.3em 0; margin-bottom: calc(var(--space-5) - 0.3em); font-size: var(--text-sm); }
.case-hero__head { display: grid; grid-template-columns: 1fr; gap: var(--space-5); align-items: end; margin-bottom: var(--space-6); }
.case-hero h1 { margin: 0; font-size: clamp(2.75rem, 6.5vw, 5.5rem); letter-spacing: -0.045em; line-height: 0.92; text-wrap: balance; max-width: 18ch; }
.case-hero__meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-4); }
.case-hero__meta p { margin: 0; max-width: 52ch; color: var(--color-ink); line-height: 1.4; text-align: right; }
.case-hero__media { overflow: hidden; border-radius: var(--radius-tile); background: #000; }
.case-hero__media video, .case-hero__media img { width: 100%; }
.case-hero__media--plain { background: var(--color-tile); }
@media (max-width: 860px) { .case-hero__meta p { text-align: left; } }

/* Typevibes cover */
.tv-cover { position: relative; }
.tv-cover img { display: block; width: 100%; }
.tv-cover .btn { position: absolute; right: clamp(1rem, 3vw, 2rem); bottom: clamp(1rem, 3vw, 2rem); }

/* ---------- Case study: sub-navigation ---------- */
.subnav { position: sticky; top: 4rem; z-index: 40; background: rgba(244, 244, 246, 0.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--color-line); }
.subnav ol { display: flex; gap: var(--space-2); list-style: none; padding: var(--space-3) 0; margin: 0; max-width: none; overflow-x: auto; }
.subnav li { margin: 0; white-space: nowrap; }
.subnav a { display: inline-flex; gap: var(--space-2); padding: 0.4em 0.9em; border-radius: var(--radius-pill); color: var(--color-ink-2); text-decoration: none; font-size: var(--text-sm); font-weight: 600; transition: background 250ms, color 250ms; }
.subnav a:hover { color: var(--color-accent-text); }
.subnav a.is-active { background: var(--color-ink); color: #fff; }
.subnav a span { color: var(--color-ink-2); font-weight: 400; }
.subnav a.is-active span { color: var(--color-ink-3); }

/* ---------- Case study: parts (01 Overview, 02 In depth, 03 Insights) ---------- */
.part { --rule: var(--color-line); --rule-strong: var(--color-ink); padding: var(--space-9) 0; }
.part p, .part ul, .part ol { max-width: none; }
.part--overview { background: var(--color-paper); }
.part--indepth { --rule: rgba(255, 255, 255, 0.16); --rule-strong: rgba(255, 255, 255, 0.85); background: var(--color-black); color: rgba(255, 255, 255, 0.86); }
.part--insights { background: var(--color-surface-2); }

/* Section head: number + title left, short description right */
.part__head { position: relative; display: grid; grid-template-columns: auto auto 1fr; align-items: end; column-gap: var(--space-4); margin-bottom: var(--space-7); padding-bottom: var(--space-6); }
.part__num { align-self: start; padding-top: 0.6em; font-size: clamp(1.25rem, 2vw, 1.5rem); color: var(--color-ink-2); }
.part--indepth .part__num { color: var(--color-ink-3); }
.part__head h2 { font-size: clamp(2.5rem, 6vw, 4.5rem); letter-spacing: -0.045em; }
.part .part__head p { grid-column: 3; justify-self: end; max-width: 44ch; margin: 0; color: var(--color-ink); text-align: right; }
@media (max-width: 860px) {
  .part__head { grid-template-columns: auto 1fr; }
  .part .part__head p { grid-column: 1 / -1; justify-self: start; text-align: left; margin-top: var(--space-3); }
}
/* small phones: long single words ("Aprenentatges") still fit next to the number */
@media (max-width: 480px) { .part__head h2 { font-size: clamp(1.75rem, 9vw, 2.5rem); } }

/* Section-title separator: 3-tier progress bar with crosshair ends.
   Overview fills 1/3, In depth 2/3, Insights 3/3. */
.part__head::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 11px; transform: translateY(50%); pointer-events: none;
  --s: calc((100% - 44px) / 3);
  --a: 16px; --b: calc(16px + var(--s)); --c: calc(22px + var(--s));
  --d: calc(22px + 2 * var(--s)); --e: calc(28px + 2 * var(--s)); --f: calc(100% - 16px);
  --fill: var(--rule-strong);
  background:
    /* filled tiers (set per part below) */
    var(--tiers, none) 0 50% / 100% 3px no-repeat,
    /* empty track: three thin slots */
    linear-gradient(90deg, transparent var(--a), var(--rule) var(--a) var(--b), transparent var(--b) var(--c), var(--rule) var(--c) var(--d), transparent var(--d) var(--e), var(--rule) var(--e) var(--f), transparent var(--f)) 0 50% / 100% 1px no-repeat,
    /* crosshair ends */
    linear-gradient(var(--rule-strong), var(--rule-strong)) 5px 0 / 1px 11px no-repeat,
    linear-gradient(var(--rule-strong), var(--rule-strong)) 0 50% / 11px 1px no-repeat,
    linear-gradient(var(--rule-strong), var(--rule-strong)) calc(100% - 5px) 0 / 1px 11px no-repeat,
    linear-gradient(var(--rule-strong), var(--rule-strong)) 100% 50% / 11px 1px no-repeat;
}
.part--overview .part__head::after {
  --tiers: linear-gradient(90deg, transparent var(--a), var(--fill) var(--a) var(--b), transparent var(--b));
}
.part--indepth .part__head::after {
  --tiers: linear-gradient(90deg, transparent var(--a), var(--fill) var(--a) var(--b), transparent var(--b) var(--c), var(--fill) var(--c) var(--d), transparent var(--d));
}
.part--insights .part__head::after {
  --tiers: linear-gradient(90deg, transparent var(--a), var(--fill) var(--a) var(--b), transparent var(--b) var(--c), var(--fill) var(--c) var(--d), transparent var(--d) var(--e), var(--fill) var(--e) var(--f), transparent var(--f));
}

/* Overview: description + mini bento (Challenge, Solution, Impact, Tools) */
.lede { font-size: var(--text-lg); font-weight: 500; letter-spacing: -0.02em; line-height: 1.35; margin-bottom: var(--space-7); }
.lede__note { display: block; margin-top: var(--space-3); font-size: var(--text-sm); font-weight: 400; letter-spacing: 0; color: var(--color-ink-2); }
.info-bento { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-4); }
.info { display: flex; flex-direction: column; gap: var(--space-3); min-height: 200px; padding: var(--space-6); border-radius: var(--radius-tile); }
.info h3 { font-family: var(--font-body); font-size: var(--text-xs); font-weight: 400; letter-spacing: 0; color: var(--color-ink-2); }
.info p { margin: 0; font-size: var(--text-md); line-height: 1.5; }
.info--challenge { grid-column: span 3; background: var(--color-surface); color: var(--color-ink); }
.info--solution { grid-column: span 3; background: var(--color-surface); }
.info--impact { grid-column: span 4; background: var(--color-black); color: #fff; }
.info--impact h3 { color: var(--color-ink-3); }
.info--impact p { font-size: var(--text-lg); font-weight: 500; letter-spacing: -0.02em; line-height: 1.35; }
.info--tools { grid-column: span 2; border: 1px solid var(--color-line); }
@media (max-width: 860px) {
  .info-bento { grid-template-columns: 1fr; }
  .info-bento .info { grid-column: auto; min-height: 0; }
}

/* In depth (dark): each method is a row — label column left, content right */
.part--indepth .wrap { counter-reset: method; }
.part--indepth .part__head h2, .part--indepth h3, .part--indepth h4, .part--indepth strong { color: #fff; }
.part--indepth .part__head p, .part--indepth .figure figcaption { color: rgba(255, 255, 255, 0.65); }
.part--indepth a, .info--impact a { color: #fff; text-decoration: underline; text-underline-offset: 0.2em; }
.part--indepth a.btn { text-decoration: none; }   /* buttons keep their own look */
.part--indepth .block {
  counter-increment: method; position: relative;
  display: grid; grid-template-columns: minmax(180px, 1fr) minmax(0, 2.8fr); column-gap: var(--space-8);
  padding: var(--space-7) 0; margin: 0;
}
.part--indepth .block:not(:last-child)::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; grid-column: 1 / -1; height: 1px; background: var(--rule); pointer-events: none; }
.part--indepth .block > h3 { grid-column: 1; grid-row: 1 / span 30; align-self: start; position: sticky; top: 8.5rem; font-size: var(--text-xl); margin: 0; }
.part--indepth .block > h3::before { content: "Method " counter(method, decimal-leading-zero); display: block; margin-bottom: var(--space-2); font-family: var(--font-body); font-size: var(--text-xs); font-weight: 500; letter-spacing: 0; color: var(--color-ink-3); }
.part--indepth .block > *:not(h3) { grid-column: 2; }
.part--indepth .block > p:first-of-type { margin-top: 0; }
@media (max-width: 860px) {
  .part--indepth .block { grid-template-columns: minmax(0, 1fr); }   /* minmax(0, …) so wide content can't push the column past the screen */
  .part--indepth .block > h3 { grid-row: auto; position: static; margin-bottom: var(--space-4); }
  .part--indepth .block > *:not(h3) { grid-column: 1; }
}
