/* =====================================================
   Case Study v17 Override
   Loaded AFTER style.css on case study pages.
   Matches v17 homepage: DM Sans, refined spacing,
   sticky left-hand process TOC.
   ===================================================== */

/* ---------- Font imports ---------- */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,600;0,700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---------- Base overrides ---------- */
body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  color: #1d1d1f;
  background: #fff;
  -webkit-font-smoothing: antialiased;
}

/* overflow-x:hidden on .page-wrapper breaks position:sticky —
   switch to clip which doesn't create a scroll container */
.page-wrapper {
  overflow-x: clip;
}

/* ---------- Navigation refinements ---------- */
.nav {
  height: 64px;
  padding: 0 clamp(24px, 4vw, 56px);
  background-color: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid rgba(20, 20, 20, 0.06);
}
.nav__name {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: #1d1d1f;
}
.nav__link {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 500;
  font-size: 14px;
  letter-spacing: -0.005em;
  color: #6e6e73;
  padding: 8px 16px;
  border-radius: 10px;
}
.nav__link:hover {
  background-color: rgba(20, 20, 20, 0.05);
  color: #1d1d1f;
}
.nav__dot {
  width: 16px;
  height: 16px;
}

/* ---------- Two-column layout: TOC + content ---------- */
.case-study {
  padding-top: 64px;
}

.cs-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0 64px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 clamp(24px, 4vw, 56px);
  align-items: start;
}

/* ---------- Sticky Table-of-Contents ---------- */
.cs-toc {
  position: sticky;
  top: 96px;            /* nav + breathing room */
  padding: 40px 0 60px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.cs-toc::-webkit-scrollbar { display: none; }

.cs-toc__title {
  font-family: 'JetBrains Mono', 'IBM Plex Mono', Menlo, ui-monospace, monospace;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #9a9a9f;
  margin-bottom: 20px;
}

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

.cs-toc__item {
  position: relative;
}

.cs-toc__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 8px;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: #9a9a9f;
  text-decoration: none;
  transition:
    color 0.3s,
    background 0.3s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cs-toc__link:hover {
  color: #1d1d1f;
  background: rgba(20, 20, 20, 0.04);
}

/* Active state — a tiny accent bar + darker text */
.cs-toc__link.is-active {
  color: #1d1d1f;
  font-weight: 600;
  background: rgba(20, 20, 20, 0.05);
}

.cs-toc__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(20, 20, 20, 0.18);
  flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}
.cs-toc__link.is-active .cs-toc__dot {
  background: #1d1d1f;
  box-shadow: 0 0 0 3px rgba(29, 29, 31, 0.12);
}

/* Completed (scrolled past) — subtle check */
.cs-toc__link.is-done {
  color: #9a9a9f;
}
.cs-toc__link.is-done .cs-toc__dot {
  background: #0066cc;
  box-shadow: none;
}

/* ---------- Content column ---------- */
.cs-content {
  min-width: 0;   /* grid overflow guard */
}

/* ---------- Back link ---------- */
.back-link {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 500;
  font-size: 13px;
  color: #6e6e73;
  padding: 40px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: -0.005em;
  transition: color 0.25s;
}
.back-link:hover { color: #1d1d1f; }

/* ---------- Hero ---------- */
.case-study__hero {
  padding: 48px 0 56px;
  max-width: none;
  margin: 0;
  border-bottom: 1px solid rgba(20, 20, 20, 0.08);
}

.case-study__tag {
  font-family: 'JetBrains Mono', 'IBM Plex Mono', Menlo, ui-monospace, monospace;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #0066cc;
  margin-bottom: 16px;
}

.case-study__title {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(2rem, 4.5vw, 3rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
  color: #1d1d1f;
  margin-bottom: 20px;
}

.case-study__summary {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 400;
  font-size: clamp(1.05rem, 1.8vw, 1.2rem);
  line-height: 1.55;
  letter-spacing: -0.008em;
  color: #6e6e73;
  max-width: 600px;
  margin-bottom: 32px;
}

.case-study__meta {
  display: flex;
  gap: 36px;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 13.5px;
  font-weight: 400;
  color: #9a9a9f;
  letter-spacing: -0.005em;
}
.case-study__meta strong {
  display: block;
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Section blocks ---------- */
.case-study__section {
  max-width: none;
  margin: 0;
  padding: 52px 0;
  border-bottom: 1px solid rgba(20, 20, 20, 0.06);
}
.case-study__section:last-of-type {
  border-bottom: 0;
}

.case-study__section-label {
  font-family: 'JetBrains Mono', 'IBM Plex Mono', Menlo, ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #9a9a9f;
  margin-bottom: 14px;
}

.case-study__section-title {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 600;
  font-size: clamp(1.25rem, 2.4vw, 1.65rem);
  line-height: 1.22;
  letter-spacing: -0.025em;
  color: #1d1d1f;
  margin-bottom: 14px;
  max-width: 620px;
}

.case-study__section-text {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.65;
  letter-spacing: -0.005em;
  color: #6e6e73;
  max-width: 600px;
}

/* ---------- Quote blocks ---------- */
.case-study__quote {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 400;
  font-size: clamp(1.1rem, 1.8vw, 1.25rem);
  line-height: 1.55;
  color: #3a3a3a;
  font-style: italic;
  border-left: 2px solid #0066cc;
  padding-left: 24px;
  margin: 24px 0;
  max-width: 580px;
}
.case-study__quote span {
  font-size: 13px !important;
  color: #9a9a9f !important;
  font-style: normal !important;
}

/* ---------- Impact block ---------- */
.case-study__impact {
  background: #f5f5f7;
  border-radius: 20px;
  padding: 44px 40px;
  margin: 52px 0 0;
  border: none;
}

.case-study__impact-title {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(1.2rem, 2.2vw, 1.5rem);
  line-height: 1.22;
  letter-spacing: -0.025em;
  color: #1d1d1f;
  margin-bottom: 14px;
}

.case-study__impact-text {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.65;
  color: #6e6e73;
  max-width: 600px;
}

/* ---------- Pills ---------- */
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.pill {
  border: 1px solid rgba(20, 20, 20, 0.14);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 500;
  font-size: 13px;
  color: #6e6e73;
  letter-spacing: -0.005em;
  background: rgba(20, 20, 20, 0.02);
}

/* ---------- Bottom back link ---------- */
.cs-content > .back-link:last-child {
  padding: 48px 0 80px;
}

/* ---------- Responsive: collapse TOC on smaller screens ---------- */
@media (max-width: 900px) {
  .cs-layout {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0 clamp(20px, 4vw, 40px);
  }
  .cs-toc {
    display: none;
  }
  .cs-toc__list {
    flex-direction: row;
    gap: 4px;
    padding-bottom: 16px;
  }
  .cs-toc__link {
    font-size: 11px;
    padding: 6px 10px;
  }
  .cs-toc__title {
    margin-bottom: 12px;
  }
  .case-study__hero { padding: 32px 0 40px; }
  .case-study__section { padding: 36px 0; }
  .case-study__meta { flex-wrap: wrap; gap: 20px; }
  .case-study__impact { padding: 32px 24px; border-radius: 16px; }
  .nav { height: 56px; }
  .case-study { padding-top: 56px; }

  /* Mobile reading scale: bigger headings + quotes + impact closer. */
  .case-study__section-title {
    font-size: clamp(1.55rem, 5.2vw, 2.15rem);
    line-height: 1.15;
    max-width: 22ch;
  }
  .case-study__quote {
    font-size: clamp(1.2rem, 4.2vw, 1.6rem);
    line-height: 1.5;
    max-width: 30ch;
  }
  .case-study__impact-title {
    font-size: clamp(1.55rem, 5.4vw, 2.2rem);
    line-height: 1.15;
    max-width: 24ch;
  }
  .case-study__section--feature .case-study__section-title {
    font-size: clamp(1.75rem, 6.4vw, 2.45rem);
    line-height: 1.12;
    max-width: 22ch;
  }
}

/* ---------- Learning closing graf (e.g. Run feedback, Helsinki Bus) ---------- */
#learning.case-study__section .case-study__section-text {
  text-align: center;
  max-width: 46ch;
  margin-left: auto;
  margin-right: auto;
}
