/* Case-study pages: hero with animated SVG, step carriage, next-case link.
   Loaded only on /case-studies/*. Shared chip/card rules live in styles.css. */

.use-case {
  --c: var(--accent1);
  width: min(1200px, 100%);
  font-family: Arial, sans-serif;
  color: var(--text);
  position: relative;
  z-index: 1;
}

/* Round back button, same as on the other detail pages */
.use-case .hero .topic-block__back-link,
body[data-theme="dark"] .use-case .hero .topic-block__back-link {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 3;
  width: auto;
  gap: 8px;
  padding: 0 14px 0 12px;
  font-size: 13.5px;
  white-space: nowrap;
}

.use-case .hero .topic-block__back-link span {
  font-family: Arial, sans-serif;
  letter-spacing: 0.02em;
}

/* ---- hero ---- */
.hero {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 12px 40px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(22px) saturate(120%);
  -webkit-backdrop-filter: blur(22px) saturate(120%);
}

@media (min-width: 900px) {
  .hero {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    align-items: center;
  }
}

.hero .art {
  padding: 48px 10px 0;
}

@media (min-width: 900px) {
  .hero .art {
    padding: 18px 8px 18px 18px;
  }
}

.hero svg {
  width: 100%;
  height: auto;
  display: block;
}

.hero .meta {
  padding: 14px 22px 22px;
}

.hero .tag {
  display: inline-block;
  font-size: 12.5px;
  color: var(--c, var(--accent1));
  letter-spacing: 0.3px;
  text-decoration: none;
}

.hero .tag:hover,
.hero .tag:focus-visible {
  text-decoration: underline dotted;
  text-underline-offset: 4px;
}

.hero h1 {
  margin: 4px 0 6px;
  font-size: 26px;
  line-height: 1.15;
  font-weight: 700;
}

.hero p {
  margin: 0;
  color: #c3c6dc;
  font-size: 15px;
  line-height: 1.55;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 16px 0 0;
}

.chip {
  font-size: 12.5px;
  line-height: 1;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.03);
  color: #cfd2e6;
}

/* ---- carriage / stepper ---- */
.carriage {
  margin-top: 18px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.025);
  overflow: hidden;
  outline: none;
}

.carriage:focus-visible {
  outline: 2px solid rgba(120, 180, 255, 0.6);
  outline-offset: 3px;
}

.rail {
  display: flex;
  gap: 6px;
  padding: 16px 18px 0;
}

.rail span {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
}

.rail span::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--c, var(--accent1));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.rail span.done::after,
.rail span.cur::after {
  transform: scaleX(1);
}

.rail span.cur::after { opacity: 1; }
.rail span.done::after { opacity: 0.45; }

.track-wrap {
  overflow: hidden;
  touch-action: pan-y;
  transition: height 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Without JS (no html.has-js) the steps simply stack; the flex row,
   rail and controls only exist once carriage.js can drive them. */
.has-js .track {
  display: flex;
  align-items: flex-start;
  transition: transform 0.55s cubic-bezier(0.2, 0.7, 0.2, 1);
  will-change: transform;
}

html:not(.has-js) .rail,
html:not(.has-js) .ctl {
  display: none;
}

html:not(.has-js) .step {
  padding-bottom: 18px;
}

.step {
  flex: 0 0 100%;
  padding: 18px 22px 6px;
}

.step .k {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.3px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.step .k i {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: inline-grid;
  place-items: center;
  font-style: normal;
  font-size: 11.5px;
  color: #0c0f1a;
  background: var(--c, var(--accent1));
  font-weight: 700;
}

.step h3 {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 700;
}

.step p {
  margin: 0 0 10px;
  color: #c3c6dc;
  font-size: 15px;
  line-height: 1.6;
}

.step ul {
  margin: 8px 0 0;
  padding-left: 0;
  list-style: none;
}

.step li {
  position: relative;
  padding-left: 16px;
  color: #c3c6dc;
  font-size: 14.5px;
  line-height: 1.55;
  margin-bottom: 4px;
}

.step li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c, var(--accent1));
  opacity: 0.8;
}

.ctl {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px 18px;
}

.ctl button {
  font: inherit;
  font-size: 13.5px;
  color: #dfe1f5;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 14px;
  min-height: 44px;
  min-width: 96px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.ctl button:disabled {
  opacity: 0.35;
  cursor: default;
}

@media (hover: hover) {
  .ctl button:not(:disabled):hover {
    background: rgba(255, 255, 255, 0.09);
  }
}

.ctl button:focus-visible {
  outline: 2px solid rgba(120, 180, 255, 0.6);
  outline-offset: 3px;
}

.dots {
  display: flex;
  gap: 8px;
}

.dots b {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  transition: background 0.3s ease, transform 0.3s ease;
}

.dots b.cur {
  background: var(--c, var(--accent1));
  transform: scale(1.25);
}

.next-case {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
}

.next-case a {
  font-size: 13.5px;
  color: var(--text-dim);
  text-decoration: none;
}

.next-case a b {
  color: var(--text);
  font-weight: 500;
  text-decoration: underline dotted rgba(255, 255, 255, 0.4);
  text-underline-offset: 4px;
}

/* ---- SVG animation utilities (scoped to .art) ---- */
.art text {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  fill: #cfd2e6;
}

.art .st {
  fill: none;
  stroke: rgba(255, 255, 255, 0.25);
  stroke-width: 1.2;
}

.art .box {
  fill: rgba(255, 255, 255, 0.03);
  stroke: rgba(255, 255, 255, 0.18);
  stroke-width: 1.2;
}

.art .flow {
  fill: none;
  stroke: var(--c);
  stroke-width: 1.4;
  stroke-dasharray: 4 6;
  stroke-linecap: round;
  opacity: 0.8;
  animation: uc-flow 1.6s linear infinite;
}

@keyframes uc-flow {
  to { stroke-dashoffset: -20; }
}

.art .pop {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: uc-pop 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes uc-pop {
  from { opacity: 0; transform: scale(0.85) translateY(6px); }
  to { opacity: 1; transform: none; }
}

.art .pulse {
  transform-box: fill-box;
  transform-origin: center;
  animation: uc-pulse 2.6s ease-in-out infinite;
}

@keyframes uc-pulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.06); }
}

.art .draw {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: uc-draw 2.2s ease forwards;
}

@keyframes uc-draw {
  to { stroke-dashoffset: 0; }
}

.art .grow {
  transform-box: fill-box;
  transform-origin: bottom;
  transform: scaleY(0);
  animation: uc-grow 1.1s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes uc-grow {
  to { transform: scaleY(1); }
}

.art .pkt {
  animation: uc-pkt 2.4s linear infinite;
}

@keyframes uc-pkt {
  0% { transform: translateX(0); opacity: 0; }
  8% { opacity: 1; }
  92% { opacity: 1; }
  100% { transform: translateX(var(--dx, 150px)); opacity: 0; }
}

.art .gauge {
  stroke-dasharray: 180;
  stroke-dashoffset: 180;
  animation: uc-gauge 3.2s ease-in-out infinite alternate;
}

@keyframes uc-gauge {
  from { stroke-dashoffset: 150; }
  to { stroke-dashoffset: 40; }
}

.art .blink {
  animation: uc-blink 1.4s ease-in-out infinite;
}

@keyframes uc-blink {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

.art .rot {
  transform-box: fill-box;
  transform-origin: center;
  animation: uc-rot 24s linear infinite;
}

@keyframes uc-rot {
  to { transform: rotate(360deg); }
}

/* Streaming only: bitrate ladder selector stepping through the rungs */
.art .ladder {
  animation: uc-ladder 4.8s steps(1, end) infinite;
}

@keyframes uc-ladder {
  0% { transform: translateY(0); }
  25% { transform: translateY(16px); }
  50% { transform: translateY(32px); }
  62% { transform: translateY(48px); }
  75% { transform: translateY(32px); }
  88% { transform: translateY(16px); }
  100% { transform: translateY(0); }
}

/* ---- reduced motion: everything static and visible ---- */
@media (prefers-reduced-motion: reduce) {
  .art * {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    stroke-dashoffset: 0 !important;
  }

  .track,
  .track-wrap,
  .rail span::after,
  .dots b,
  .ctl button {
    transition: none !important;
  }
}

/* ---- mobile ---- */
@media (max-width: 720px) {
  .hero .meta { padding: 12px 18px 18px; }
  .hero h1 { font-size: 22px; }
  .step { padding: 16px 18px 4px; }
  .ctl { padding: 8px 14px 14px; }
  .ctl button { min-width: 84px; padding: 10px 12px; }
}

/* ---- Outcome metrics (OUTCOME_METRICS_SPEC.md) ---- */
.step.outcome {
  display: grid;
  gap: 18px;
}

@media (min-width: 760px) {
  .step.outcome {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr);
    gap: 26px;
    align-items: start;
  }
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
  gap: 10px;
}

@media (min-width: 760px) {
  .metrics {
    grid-template-columns: repeat(3, 1fr);
  }
}

.metric {
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 16px;
  padding: 14px 14px 12px;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015));
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.metric::after {
  content: "";
  position: absolute;
  inset: auto -30% -60% -30%;
  height: 120%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--c) 16%, transparent), transparent);
  pointer-events: none;
}

.on .metric,
html:not(.has-js) .metric {
  opacity: 1;
  transform: none;
}

.on .metric:nth-child(2) { transition-delay: 0.1s; }
.on .metric:nth-child(3) { transition-delay: 0.2s; }
.on .metric:nth-child(4) { transition-delay: 0.3s; }
.on .metric:nth-child(5) { transition-delay: 0.4s; }
.on .metric:nth-child(6) { transition-delay: 0.5s; }

.metric .top {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.metric .v {
  font-size: 28px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--c);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.metric .v small {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0;
}

.metric .l {
  font-size: 12.5px;
  color: #c3c6dc;
  line-height: 1.35;
}

.metric .s {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.3;
}

.metric .s s {
  text-decoration-color: rgba(255, 255, 255, 0.35);
}

.metric .s b {
  color: #c3c6dc;
  font-weight: 700;
}

.metric.fin {
  border-color: color-mix(in srgb, var(--c) 32%, transparent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--c) 11%, transparent), rgba(255, 255, 255, 0.02));
}

.metric.fin .l::before {
  content: "$";
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  margin-right: 6px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  color: #0c0f1a;
  background: var(--c);
  vertical-align: -2px;
}

.metric.span {
  grid-column: 1 / -1;
}

@media (min-width: 760px) {
  .metric.span {
    grid-column: span 2;
  }
}

@media (max-width: 400px) {
  .metric .v { font-size: 24px; }
  .metric { padding: 12px 12px 10px; min-height: 104px; }
}

@media (prefers-reduced-motion: reduce) {
  .metric {
    transition: none;
    opacity: 1;
    transform: none;
  }
}

/* ---- "Under the hood": read-only code-editor panel (step 3) ---- */
.step .hood {
  margin-top: 18px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 14px;
  background: #07060c;
  overflow: hidden;
  font-family: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

.hood-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  font-size: 12px;
  color: #b9bcd6;
}

.hood-dots {
  display: inline-flex;
  gap: 6px;
}

.hood-dots i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
}

.hood-dots i:first-child {
  background: var(--c, var(--accent1));
  opacity: 0.85;
}

.hood-file {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hood-ro {
  color: var(--text-dim);
  font-size: 11.5px;
}

.hood-code {
  margin: 0;
  padding: 12px 16px 14px 0;
  list-style: none;
  counter-reset: hood;
}

.step .hood-code li {
  position: relative;
  counter-increment: hood;
  padding-left: 46px;
  margin-bottom: 10px;
  font-size: 12.5px;
  line-height: 1.55;
  color: #dfe1f5;
}

.step .hood-code li:last-child {
  margin-bottom: 0;
}

.step .hood-code li::before {
  content: counter(hood);
  position: absolute;
  left: 0;
  top: 0;
  width: 30px;
  text-align: right;
  color: rgba(148, 151, 179, 0.55);
  background: none;
  border-radius: 0;
  height: auto;
  font-size: 12px;
  line-height: 1.55;
  opacity: 1;
}

.hood-code em {
  font-style: italic;
  color: var(--text-dim);
}

.hood-code b {
  color: var(--c, var(--accent1));
  font-weight: 700;
}

.hood-code .dim {
  color: var(--text-dim);
}

.hood-cursor {
  display: inline-block;
  width: 7px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.15em;
  background: var(--c, var(--accent1));
  animation: uc-cursor 1.1s steps(1, end) infinite;
}

@keyframes uc-cursor {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .hood-cursor { animation: none; opacity: 0.7; }
}

@media (max-width: 720px) {
  .step .hood-code li { padding-left: 36px; font-size: 12px; }
  .step .hood-code li::before { width: 24px; }
  .hood-code { padding-right: 12px; }
}

/* Desktop hero: text block starts below the back button (18px + 38px) */
@media (min-width: 900px) {
  .use-case .hero .meta {
    align-self: start;
    padding: 74px 22px 22px;
  }

  .use-case .hero .art {
    align-self: center;
  }
}
