/* Case study pages — cinematic product storytelling */
:root {
  --bg: #f4f0e6;
  --bg-elev: #fffcf6;
  --surface: #ffffff;
  --text: #0c1f1b;
  --muted: #4f635e;
  --border: #e0dbd0;
  --primary: #0d6e67;
  --primary-strong: #0a5751;
  --brand: #e8891a;
  --brand-strong: #c96f0d;
  --accent: #e8a317;
  --shadow: 0 12px 40px rgba(12, 31, 27, 0.08);
  --shadow-soft: 0 4px 18px rgba(12, 31, 27, 0.05);
  --radius-lg: 22px;
  --radius-md: 16px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --glass: color-mix(in srgb, var(--bg-elev) 78%, transparent);
  --ring: color-mix(in srgb, var(--primary) 35%, transparent);
}

[data-theme="dark"] {
  --bg: #071212;
  --bg-elev: #0c1a1a;
  --surface: #122424;
  --text: #eef8f6;
  --muted: #9dbbb6;
  --border: #243c3c;
  --primary: #2dd4bf;
  --primary-strong: #14b8a6;
  --brand: #f5a524;
  --brand-strong: #e8891a;
  --accent: #fbbf24;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 6px 20px rgba(0, 0, 0, 0.3);
  --glass: color-mix(in srgb, var(--bg-elev) 82%, transparent);
  --ring: color-mix(in srgb, var(--primary) 40%, transparent);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  background:
    radial-gradient(ellipse 70% 45% at 8% -5%, color-mix(in srgb, var(--brand) 16%, transparent), transparent 55%),
    radial-gradient(ellipse 55% 40% at 95% 8%, color-mix(in srgb, var(--primary) 14%, transparent), transparent 50%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

main#csMain {
  padding-bottom: 110px;
}

h1,
h2,
h3,
.brand {
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: -0.02em;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
video {
  display: block;
  max-width: 100%;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 9998;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 10000;
  background: var(--primary);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 700;
}

.skip-link:focus {
  top: 12px;
}

.shell {
  width: min(960px, calc(100% - 40px));
  margin: 0 auto;
}

.shell-wide {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.cs-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: var(--glass);
  border-bottom: 1px solid var(--border);
}

.cs-header-inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.cs-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chip-btn {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
}

.chip-btn i {
  font-size: 1.15rem;
}

.chip-btn:hover {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
}

.chip-btn:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.brand {
  font-weight: 700;
  font-size: 1.2rem;
}

.cs-back {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cs-back:hover {
  text-decoration: underline;
}

/* ——— Cinematic hero ——— */
.cs-hero {
  padding: 36px 0 18px;
}

.cs-hero-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 28px;
  align-items: center;
}

.cs-kicker {
  margin: 0;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cs-hero h1 {
  margin: 10px 0 12px;
  font-size: clamp(1.85rem, 3.6vw, 2.85rem);
  line-height: 1.1;
}

.cs-lead {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.65;
  max-width: 54ch;
}

.cs-meta {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cs-meta span,
.cs-meta a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.cs-meta a {
  color: #fff;
  background: var(--brand);
  border-color: transparent;
  font-weight: 700;
}

.cs-meta a:hover {
  background: var(--brand-strong);
}

.cs-meta a.ghost {
  background: transparent;
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
}

.cs-hero-stage {
  position: relative;
}

.cs-hero-frame {
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow:
    0 30px 60px rgba(12, 31, 27, 0.16),
    0 0 0 1px color-mix(in srgb, var(--brand) 18%, transparent);
  background: #0a1f1c;
  aspect-ratio: 16 / 10;
}

.cs-hero-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.cs-hero-frame video {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.cs-hero-frame.has-video video {
  display: block;
}

.cs-hero-frame.has-video img.cover-fallback {
  display: none;
}

.cs-live-pill {
  position: absolute;
  left: 14px;
  top: 14px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(8, 18, 16, 0.72);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 700;
  backdrop-filter: blur(8px);
}

.cs-live-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  70% {
    box-shadow: 0 0 0 8px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

.cs-section {
  padding: 34px 0;
}

.cs-section h2 {
  margin: 0 0 8px;
  font-size: 1.4rem;
}

.cs-section > .shell > .cs-sub,
.cs-section .cs-sub {
  margin: 0 0 18px;
  color: var(--muted);
  max-width: 60ch;
}

.cs-section p,
.cs-section li {
  color: var(--muted);
  line-height: 1.7;
}

.cs-section p {
  margin: 0 0 12px;
}

.cs-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.cs-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.cs-card h3 {
  margin: 0 0 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--brand);
}

.cs-card p,
.cs-card li {
  margin: 0;
  color: var(--text);
  font-size: 0.98rem;
}

.cs-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.cs-metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: center;
}

.cs-metric strong {
  display: block;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.65rem;
  color: var(--primary);
  letter-spacing: -0.03em;
}

.cs-metric span {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.cs-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cs-pills span {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

/* Portal tabs */
.cs-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.cs-tabs button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
}

.cs-tabs button.is-active {
  background: var(--brand);
  border-color: transparent;
  color: #fff;
}

.cs-tabs button:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* Showcase / walkthrough */
.cs-showcase {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.cs-showcase-main {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #0a1f1c;
}

.cs-showcase-main img,
.cs-showcase-main video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.cs-demo-reel {
  margin-top: 22px;
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.cs-demo-reel h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.cs-demo-reel video {
  width: 100%;
  border-radius: 14px;
  background: #0a1f1c;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.cs-filmstrip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  padding: 10px;
  background: color-mix(in srgb, var(--bg) 55%, var(--surface));
  border-top: 1px solid var(--border);
}

.cs-filmstrip button {
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  background: #0a1f1c;
  aspect-ratio: 16 / 10;
}

.cs-filmstrip button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  opacity: 0.78;
  transition: opacity 0.2s ease;
}

.cs-filmstrip button.is-active {
  border-color: var(--brand);
}

.cs-filmstrip button.is-active img,
.cs-filmstrip button:hover img {
  opacity: 1;
}

.cs-filmstrip button:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.cs-caption-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}

.cs-caption-bar p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 600;
}

.cs-mosaic {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
}

.cs-mosaic figure {
  margin: 0;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0a1f1c;
  box-shadow: var(--shadow-soft);
}

.cs-mosaic figure:first-child {
  grid-row: 1 / span 2;
}

.cs-mosaic img {
  width: 100%;
  height: 100%;
  min-height: 160px;
  object-fit: cover;
  object-position: top;
}

.cs-mosaic figcaption {
  padding: 8px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.cs-arch {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  overflow-x: auto;
}

.cs-arch svg {
  width: 100%;
  min-width: 640px;
  height: auto;
}

.cs-arch .box-primary {
  fill: var(--primary);
}

.cs-arch .box-api {
  fill: var(--bg-elev);
  stroke: var(--primary);
  stroke-width: 2;
}

.cs-arch .box-surface {
  fill: var(--bg);
  stroke: var(--border);
  stroke-width: 1.5;
}

.cs-arch .label-on-primary {
  fill: #fff;
  font-size: 14px;
  font-family: "Space Grotesk", sans-serif;
}

.cs-arch .label-on-api {
  fill: var(--primary);
  font-size: 14px;
  font-family: "Space Grotesk", sans-serif;
}

.cs-arch .label-on-surface {
  fill: var(--text);
  font-size: 13px;
  font-family: "Manrope", sans-serif;
}

.cs-arch .connector {
  stroke: var(--primary);
  stroke-width: 2;
  fill: none;
}

.cs-list {
  margin: 0;
  padding-left: 18px;
}

.cs-list li {
  margin-bottom: 8px;
}

.cs-next {
  margin-top: 20px;
  padding: 28px;
  border-radius: var(--radius-lg);
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--brand) 16%, var(--surface)),
    color-mix(in srgb, var(--primary) 10%, var(--surface))
  );
  border: 1px solid color-mix(in srgb, var(--brand) 28%, var(--border));
}

.cs-next h2 {
  margin: 0 0 8px;
}

.cs-actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 800;
  font-size: 0.9rem;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-strong);
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.cs-sticky-cta {
  position: sticky;
  bottom: 14px;
  z-index: 30;
  margin: 0 auto 18px;
  width: min(720px, calc(100% - 28px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.cs-sticky-cta p {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}

.cs-sticky-cta .btn {
  flex-shrink: 0;
}

.cs-footer {
  margin-top: 24px;
  padding: 24px 0 40px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .cs-hero-grid,
  .cs-mosaic {
    grid-template-columns: 1fr;
  }

  .cs-hero-grid {
    gap: 18px;
  }

  .cs-hero-stage {
    order: -1;
  }

  .cs-mosaic figure:first-child {
    grid-row: auto;
  }

  .cs-hero h1 {
    font-size: clamp(1.55rem, 5.2vw, 2.2rem);
  }

  .cs-lead {
    font-size: 0.98rem;
  }
}

@media (max-width: 780px) {
  .shell,
  .shell-wide {
    width: min(960px, calc(100% - 24px));
  }

  .cs-hero {
    padding: 16px 0 8px;
  }

  .cs-section {
    padding: 20px 0;
  }

  .cs-grid-2 {
    grid-template-columns: 1fr;
  }

  .cs-metrics {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .cs-metric {
    padding: 12px 10px;
  }

  .cs-metric strong {
    font-size: 1.25rem;
  }

  .cs-metric span {
    font-size: 0.72rem;
    line-height: 1.3;
  }

  .cs-header-inner {
    min-height: 52px;
    gap: 8px;
  }

  .cs-back {
    font-size: 0.8rem;
  }

  .cs-meta {
    gap: 6px;
  }

  .cs-meta span,
  .cs-meta a {
    font-size: 0.76rem;
    padding: 6px 9px;
  }

  .cs-hero-frame {
    aspect-ratio: 16 / 10;
    border-radius: 14px;
  }

  .cs-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .cs-tabs::-webkit-scrollbar {
    display: none;
  }

  .cs-tabs button {
    flex: 0 0 auto;
  }

  .cs-filmstrip {
    display: flex;
    grid-template-columns: none;
    overflow-x: auto;
    gap: 8px;
    padding: 10px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .cs-filmstrip button {
    flex: 0 0 46%;
    max-width: 160px;
    scroll-snap-align: start;
  }

  .cs-caption-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .cs-arch {
    padding: 12px;
  }

  .cs-arch svg {
    min-width: 480px;
  }

  .cs-next {
    padding: 16px;
  }

  .cs-actions {
    gap: 8px;
  }

  .cs-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .cs-sticky-cta {
    bottom: max(8px, env(safe-area-inset-bottom));
    width: min(720px, calc(100% - 16px));
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    text-align: left;
    padding: 8px 10px;
    gap: 8px;
    border-radius: 14px;
  }

  .cs-sticky-cta p {
    font-size: 0.78rem;
    flex: 1 1 auto;
    margin: 0;
    line-height: 1.3;
  }

  .cs-sticky-cta .btn {
    width: auto;
    flex: 0 0 auto;
    justify-content: center;
    padding: 9px 12px;
    font-size: 0.82rem;
  }

  main#csMain {
    padding-bottom: 96px;
  }

  .cs-live-pill {
    left: 8px;
    top: 8px;
    font-size: 0.68rem;
    padding: 4px 8px;
  }

  .cs-demo-reel {
    padding: 12px;
  }

  .cs-footer {
    padding: 20px 0 calc(28px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 420px) {
  .cs-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .cs-filmstrip button {
    flex-basis: 62%;
  }

  .cs-sticky-cta {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .cs-sticky-cta .btn {
    width: 100%;
  }

  .hero-actions .btn,
  .cs-meta a.btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .cs-live-pill::before {
    animation: none;
  }
}
