/* ---------- Case study pages (loaded after styles.css) ---------- */
.case-page { padding-top: 120px; --accent: #4b3bc4; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: var(--text-2);
  transition: color 0.2s, gap 0.2s;
}

.back-link:hover { color: var(--text); gap: 12px; }

/* Header */
.cs-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  column-gap: 64px;
  max-width: 960px;
  margin: 40px auto 0;
}

.cs-header > :not(.cs-meta) { grid-column: 1; }

.cs-header .case-cat { margin: 0 0 16px; color: var(--accent); }

.cs-header h1 {
  font-size: clamp(34px, 4.8vw, 52px);
  letter-spacing: -0.03em;
}

.cs-lead {
  margin: 24px 0 0;
  max-width: 680px;
  font-size: clamp(17px, 2vw, 20px);
  color: var(--text-2);
}

.cs-hero {
  margin: 56px 0 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.cs-hero img { width: 100%; }

/* Meta list (right column of the header) */
.cs-meta {
  grid-column: 2;
  grid-row: 1 / span 4;
  display: grid;
  align-content: start;
  gap: 20px;
  margin: 0;
  padding-top: 6px;
}

.cs-meta dt {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
}

.cs-meta dd { margin: 0; font-weight: 500; }

.cs-note {
  max-width: 720px;
  margin: 16px auto 0;
  font-size: 14px;
  color: var(--text-2);
}

/* Header jump link, hero replay button and in-page anchors */
.cs-jump { margin: 20px 0 0; }
.hero-replay { position: absolute; bottom: 16px; padding: 8px 14px; border: 0; border-radius: 999px; background: #fff; color: var(--accent); font: 500 14px/1 Inter, sans-serif; cursor: pointer; }
.hero-replay:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.case-page [id] { scroll-margin-top: 96px; }

/* Sections */
.cs-section { padding: 112px 0 0; }

.cs-text { max-width: 720px; margin: 0 auto; }

.cs-eyebrow {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.cs-concept {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 10px;
  border: 1px solid currentColor;
  border-radius: 99px;
  font-size: 11px;
  letter-spacing: 0.08em;
  vertical-align: 1px;
}

.cs-text p.cs-concept-note {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  font-size: 14px;
  color: var(--text-3);
}

.cs-text h2 { font-size: clamp(28px, 3.6vw, 40px); margin-bottom: 20px; }
.cs-text h3 { font-size: 22px; margin: 40px 0 12px; }

.cs-text p {
  margin: 0 0 18px;
  font-size: 17px;
  color: var(--text-2);
}

.cs-text strong { color: var(--text); font-weight: 600; }

.cs-tldr {
  margin-top: 32px;
  padding: 28px 32px;
  border-left: 4px solid var(--accent);
  background: #f4f2fd;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.cs-tldr p:last-child { margin-bottom: 0; }

/* Figures */
.cs-figure { margin: 48px 0 0; }

.cs-figure img {
  width: 100%;
  border-radius: var(--radius-md);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 12px 40px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--line);
}

.cs-figure.plain img { box-shadow: none; border: 0; }

.cs-figure figcaption {
  margin-top: 14px;
  font-size: 14px;
  color: var(--text-3);
}

.cs-figure a { display: block; cursor: zoom-in; }

.cs-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-top: 48px;
}

.cs-pair .cs-figure { margin: 0; }

.compare-label {
  display: inline-block;
  margin-bottom: 12px;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--panel);
  color: var(--text-2);
}

.compare-label.after { background: #efedfc; color: var(--accent); }

/* Cards (findings, principles) */
.cs-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin-top: 48px;
}

.cs-card {
  padding: 28px;
  background: var(--panel);
  border-radius: var(--radius-md);
}

.cs-card .num {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
  margin-bottom: 14px;
}

.cs-card h3 { font-size: 19px; margin-bottom: 10px; }
.cs-card p { margin: 0; font-size: 15px; color: var(--text-2); }

.cs-cards--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.cs-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 40px 24px;
  margin-top: 48px;
}

.cs-grid-2 .cs-figure { margin: 0; }
.cs-grid-2 figcaption { text-align: left; color: var(--text-2); }
.cs-grid-2 figcaption strong { color: var(--text); }

/* Process steps: one thin rail, a number and two words per step */
.cs-steps {
  list-style: none;
  margin: 32px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0 16px;
  counter-reset: step;
}

.cs-steps li {
  counter-increment: step;
  position: relative;
  padding-top: 18px;
  border-top: 2px solid var(--line);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
}

.cs-steps li::after {
  content: "";
  position: absolute;
  left: 0;
  top: -5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.cs-steps li::before {
  content: "0" counter(step);
  display: block;
  margin-bottom: 2px;
  font: 600 12px/1.4 var(--font-body);
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.cs-steps li span { display: block; margin-top: 4px; font: 400 13px/1.4 var(--font-body); color: var(--text-2); }

/* Responsive devices: tablet and two phones, bottom-aligned on one tinted stage */
.gd-stage {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 4%;
  padding: 56px 6% 52px;
  border-radius: var(--radius-md);
  background: #f4f2fd;
}

.cs-figure .gd-device {
  display: block;
  flex: none;
  padding: var(--bw);
  border-radius: var(--r);
  background: #1e2235;
  box-shadow: 0 2px 4px rgba(30, 34, 53, 0.12), 0 24px 48px rgba(75, 59, 196, 0.18);
}

.gd-device--tablet { --bw: 10px; --r: 24px; width: 42%; }
.gd-device--phone { --bw: 6px; --r: 26px; width: 19%; }

.cs-figure .gd-device > img {
  display: block;
  width: 100%;
  height: auto;
  border: 0;
  border-radius: calc(var(--r) - var(--bw));
  box-shadow: none;
}

.gd-device:nth-child(1) { --d: 0s; }
.gd-device:nth-child(2) { --d: 0.12s; }
.gd-device:nth-child(3) { --d: 0.24s; }

.gym-devices.is-visible .gd-device {
  animation: gd-rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) var(--d) both;
}

@keyframes gd-rise { from { transform: translateY(32px); opacity: 0; } }

@media (max-width: 760px) {
  .gd-stage { gap: 3%; padding: 32px 4% 28px; }
  .gd-device--tablet { --bw: 5px; --r: 14px; width: 46%; }
  .gd-device--phone { --bw: 3px; --r: 14px; width: 22%; }
}

@media (prefers-reduced-motion: reduce) {
  .gym-devices.is-visible .gd-device { animation: none; }
}

/* Feature blocks (text + image side by side) */
.cs-feature {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 5fr);
  gap: 40px;
  align-items: center;
  margin: 80px -40px 0;
}

.cs-feature--flip { grid-template-columns: minmax(0, 5fr) minmax(0, 2fr); }
.cs-feature--flip > div { order: 2; }

.cs-feature .cs-figure { margin: 0; }
.cs-feature h3 { font-size: 22px; margin-bottom: 12px; }
.cs-feature p { margin: 0 0 12px; color: var(--text-2); }

.cs-feature ul {
  margin: 16px 0 0;
  padding-left: 20px;
  color: var(--text-2);
  font-size: 15px;
}

.cs-feature li { margin-bottom: 6px; }

/* Role & responsibilities */
.cs-role {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px 40px;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
}

.cs-role li {
  position: relative;
  padding-left: 22px;
  font-size: 16px;
  color: var(--text-2);
}

.cs-role li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

/* Insights: numbered, problem → design response */
.cs-insights { margin: 48px auto 0; max-width: 880px; display: grid; gap: 16px; }

.cs-insight {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.cs-insight .num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  line-height: 1;
  color: var(--accent);
}

.cs-insight h3 { font-size: 18px; margin-bottom: 8px; }
.cs-insight p { margin: 0; font-size: 15px; color: var(--text-2); }

.cs-insight .response {
  padding-left: 24px;
  border-left: 1px solid var(--line);
}

.cs-insight .response span {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

/* Wide figures break out of the text column */
.cs-figure.wide { margin-left: -40px; margin-right: -40px; }

/* Tall images: show the top part, fade out, open full size on click */
.cs-figure.capped a {
  position: relative;
  max-height: 760px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.cs-figure.capped img { border: 0; box-shadow: none; border-radius: 0; }

.cs-figure.capped a::after {
  content: "View full design system";
  position: absolute;
  inset: auto 0 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 180px;
  padding-bottom: 28px;
  background: linear-gradient(rgba(255, 255, 255, 0), var(--bg) 75%);
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
}

/* Multi-step flow: JS turns the 2×2 grid into tabs with one large step */
.cs-flow.is-tabbed { display: block; margin-left: -40px; margin-right: -40px; }
.cs-flow.is-tabbed .cs-figure[hidden] { display: none; }
.cs-flow.is-tabbed figcaption { margin-top: 16px; font-size: 15px; }

.cs-flow-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.cs-flow-tabs button {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--bg);
  font: 500 14px/1.4 var(--font-body);
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.cs-flow-tabs button:hover { color: var(--text); border-color: var(--text-3); }

.cs-flow-tabs button[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.cs-flow-tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Lightbox */
dialog.lb {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
}

dialog.lb::backdrop { background: rgba(16, 18, 22, 0.92); }

.lb-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  height: 100%;
  padding: 56px 72px 24px;
}

.lb-stage img {
  max-width: 92vw;
  max-height: 84vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}

.lb-cap { margin: 0; max-width: 760px; font-size: 14px; text-align: center; color: rgba(255, 255, 255, 0.75); }

.lb-btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.lb-btn:hover { background: rgba(255, 255, 255, 0.24); }
.lb-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.lb-close { top: 12px; right: 12px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }

body.lb-open { overflow: hidden; }

/* Light motion: blocks ease in once, design steps stagger, step tabs and lightbox fade between images */
.cs-rise { opacity: 0; transform: translateY(24px); transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1); }
.cs-rise.is-in { opacity: 1; transform: none; }
.cs-steps.cs-rise { opacity: 1; transform: none; }
.cs-steps.cs-rise li { opacity: 0; transform: translateY(12px); transition: opacity 0.45s ease, transform 0.45s ease; }
.cs-steps.cs-rise li::after { transform: scaleX(0); transform-origin: 0 50%; transition: transform 0.5s ease; }
.cs-steps.cs-rise.is-in li { opacity: 1; transform: none; }
.cs-steps.cs-rise.is-in li::after { transform: none; }
.cs-steps.cs-rise li:nth-child(2), .cs-steps.cs-rise li:nth-child(2)::after { transition-delay: 0.08s; }
.cs-steps.cs-rise li:nth-child(3), .cs-steps.cs-rise li:nth-child(3)::after { transition-delay: 0.16s; }
.cs-steps.cs-rise li:nth-child(4), .cs-steps.cs-rise li:nth-child(4)::after { transition-delay: 0.24s; }
.cs-steps.cs-rise li:nth-child(5), .cs-steps.cs-rise li:nth-child(5)::after { transition-delay: 0.32s; }
.cs-steps.cs-rise li:nth-child(6), .cs-steps.cs-rise li:nth-child(6)::after { transition-delay: 0.4s; }

/* Zoomable screens lift slightly on hover, hinting that they open larger */
.cs-figure:not(.capped):not(.plain) a img { transition: transform 0.25s ease, box-shadow 0.25s ease; }
.cs-figure:not(.capped):not(.plain) a:hover img {
  transform: translateY(-3px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 18px 48px rgba(0, 0, 0, 0.12);
}

.cs-figure.is-entering, .lb-stage img.is-entering { animation: cs-fade 0.3s ease both; }
@keyframes cs-fade { from { opacity: 0; transform: translateY(6px); } }

@media (prefers-reduced-motion: reduce) {
  .cs-rise, .cs-steps.cs-rise li { opacity: 1; transform: none; transition: none; }
  .cs-steps.cs-rise li::after { transform: none; transition: none; }
  .cs-figure:not(.capped):not(.plain) a img { transition: none; }
  .cs-figure:not(.capped):not(.plain) a:hover img { transform: none; }
  .cs-figure.is-entering, .lb-stage img.is-entering { animation: none; }
}

/* End-of-page links: home on the left, back to top on the right */
.cs-endnav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 112px 0 0;
  padding: 0 8px;
  font-size: 15px;
}
.cs-endnav .hero-link { color: var(--text-2); transition: color 0.2s; }
.cs-endnav .hero-link:hover { color: var(--text); }
.cs-home:hover span { transform: translateX(-4px); }
.cs-top:hover span { transform: translateY(-3px); }

.cs-footer { margin: 48px 0 64px; text-align: center; }

/* Responsive */
/* Sitemap: root on top, ten module columns, pages listed under each on one thin rail */
.cs-sitemap { margin: 48px 0 0; }

.sm-tree {
  --sm-line: color-mix(in srgb, var(--accent) 32%, #fff);
  --sm-tint: color-mix(in srgb, var(--accent) 12%, #fff);
  padding: 32px 28px 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 12px 32px rgba(0, 0, 0, 0.05);
}

.sm-tree ol,
.sm-tree ul { list-style: none; margin: 0; padding: 0; }

.sm-node {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 14px;
  line-height: 1.35;
  color: var(--text);
}

.sm-node small {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-2);
}

.sm-module > .sm-node { color: #2b2170; }

.sm-badge {
  flex: none;
  min-width: 26px;
  margin-top: 1px;
  font: 600 11px/1.3 var(--font-body);
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.sm-root {
  width: max-content;
  margin: 0 auto;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--accent);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: #fff;
}

.sm-root .sm-badge { min-width: 0; color: rgba(255, 255, 255, 0.7); }

.sm-rows {
  display: grid;
  gap: 32px;
  margin-top: 28px;
  padding-top: 28px;
  border-top: 1px solid var(--sm-line);
}

.sm-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.sm-module { min-width: 0; }

.sm-module > .sm-node {
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--sm-tint);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
}

.sm-module > .sm-node .sm-badge { min-width: 0; margin-top: 0; }

.sm-module ul {
  display: grid;
  gap: 10px;
  margin: 12px 0 0 12px;
  padding-left: 12px;
  border-left: 1px solid var(--sm-line);
}

.cs-sitemap figcaption {
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-2);
}

@media (max-width: 900px) {
  .sm-tree { padding: 24px 16px; }
  .sm-root { margin: 0; }
  .sm-rows { gap: 12px; margin-top: 20px; padding-top: 20px; }
  .sm-row { grid-template-columns: 1fr; gap: 12px; }
}

@media (max-width: 900px) {
  .cs-header { grid-template-columns: minmax(0, 1fr); }
  .cs-meta { grid-column: 1; grid-row: auto; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; margin-top: 32px; padding: 24px 0 0; border-top: 1px solid var(--line, rgba(0,0,0,.1)); }
  .cs-cards { grid-template-columns: 1fr; }
  .cs-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 16px; }
  .cs-feature, .cs-feature--flip { grid-template-columns: 1fr; gap: 24px; margin-top: 64px; }
  .cs-feature--flip > div { order: 0; }
  .cs-insight { grid-template-columns: 1fr; gap: 12px; }
  .cs-insight .response { padding: 16px 0 0; border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 1200px) {
  .cs-figure.wide, .cs-flow.is-tabbed { margin-left: 0; margin-right: 0; }
  .cs-feature { margin-left: 0; margin-right: 0; }
}

@media (max-width: 760px) {
  .case-page { padding-top: 96px; }
  .cs-hero { border-radius: 20px; margin-top: 40px; }

  .cs-section { padding-top: 80px; }
  .cs-pair, .cs-grid-2, .cs-cards--2, .cs-role { grid-template-columns: 1fr; }
  .cs-tldr { padding: 20px; }
  .cs-endnav { margin: 80px 0 0; }
  .cs-footer { margin: 40px 0 48px; }
  .cs-figure.capped a { max-height: 520px; }
  .lb-stage { padding: 64px 12px 24px; }
  .lb-prev, .lb-next { top: auto; bottom: 16px; transform: none; }
}
