/* =========================================================
   Case-study pages: the original centered reading column,
   structured with the site's rules, nodes and thread.
   ========================================================= */

.cs {
  --col: 760px;
  --wide: min(1040px, calc(100vw - 2 * var(--gutter)));
}

/* reading progress */
.cs-progress {
  display: none;
}

@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    .cs-progress {
      display: block;
      position: fixed;
      z-index: 49;
      top: var(--header-h);
      left: 0;
      right: 0;
      height: 2px;
      background: var(--teal);
      transform-origin: 0 50%;
      transform: scaleX(0);
      animation: cs-progress linear both;
      animation-timeline: scroll(root);
    }
  }
}

@keyframes cs-progress {
  to {
    transform: scaleX(1);
  }
}

/* ---------- Column ---------- */

.cs-col {
  width: 100%;
  max-width: calc(var(--col) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* blocks that step out of the column, centred on the page */
.cs-wide {
  width: var(--wide);
  max-width: none;
  margin-left: calc(50% - var(--wide) / 2);
}

/* ---------- Head ---------- */

.cs-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.cs-head .thread {
  --h: clamp(40px, 6vw, 64px);
  margin-bottom: 32px;
}

.cs-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
  font: 500 13px/1 var(--font-mono);
  color: var(--teal);
  text-decoration: none;
  text-transform: lowercase;
}

.cs-back .icon {
  transition: transform 0.3s var(--ease);
}

.cs-back:hover .icon {
  transform: translateX(-4px);
}

.cs-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font: 500 13px/1.3 var(--font-mono);
  color: var(--muted);
  text-transform: lowercase;
}

.cs-meta span:first-child {
  color: var(--teal);
}

.cs-meta span + span::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 1px;
  margin-right: 10px;
  vertical-align: middle;
  background: var(--rule-strong);
}

.cs-title {
  max-width: 18ch;
  font: 700 clamp(2.75rem, 1.4rem + 5.2vw, 5.5rem) / 0.98 var(--font-sans);
  letter-spacing: -0.055em;
  color: var(--teal-ink);
  text-wrap: balance;
}

.cs-tagline {
  max-width: 42rem;
  margin-top: 24px;
  font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.25rem);
  line-height: 1.6;
  color: var(--ink-2);
  text-wrap: pretty;
}

.cs-published {
  margin-top: 16px;
  font: 400 12.5px/1.4 var(--font-mono);
  color: var(--muted);
  text-transform: lowercase;
}

.cs-cover {
  margin-top: clamp(40px, 5vw, 64px);
}

.cs-cover img {
  width: 100%;
  border-radius: var(--radius);
  box-shadow: 0 30px 60px -32px rgba(11, 45, 58, 0.45);
}

/* ---------- At a glance + key numbers ---------- */

.cs-glance {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: clamp(48px, 6vw, 72px);
  border-top: 1px solid var(--rule-strong);
}

.cs-glance > div {
  padding: 20px 24px 20px 0;
  border-bottom: 1px solid var(--rule);
}

.cs-glance > div:nth-child(even) {
  padding-left: 24px;
  border-left: 1px solid var(--rule);
}

.cs-glance > div:last-child:nth-child(odd) {
  grid-column: span 2;
}

.cs-glance dt {
  margin-bottom: 8px;
  font: 500 12.5px/1.3 var(--font-mono);
  color: var(--teal);
  text-transform: lowercase;
}

.cs-glance dd {
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--ink);
}

@media (max-width: 600px) {
  .cs-glance {
    grid-template-columns: minmax(0, 1fr);
  }

  .cs-glance > div:nth-child(even) {
    padding-left: 0;
    border-left: 0;
  }

  .cs-glance > div:last-child:nth-child(odd) {
    grid-column: auto;
  }
}

.cs-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  border-bottom: 1px solid var(--rule);
}

.cs-stats > div {
  padding: 28px 24px 24px 0;
}

.cs-stats > div + div {
  padding-left: 24px;
  border-left: 1px solid var(--rule);
}

.cs-stats dt {
  font: 700 clamp(2.25rem, 1.8rem + 1.6vw, 3.25rem) / 1 var(--font-sans);
  letter-spacing: -0.05em;
  color: var(--teal-ink);
}

.cs-stats dd {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}

@media (max-width: 600px) {
  .cs-stats > div + div {
    padding-left: 0;
    border-left: 0;
    border-top: 1px solid var(--rule);
  }
}

/* ---------- Sections ---------- */

.cs-section {
  margin-top: clamp(72px, 9vw, 120px);
}

.cs-section > .rule {
  margin-bottom: 22px;
}

.cs-h2 {
  margin-bottom: 20px;
  font: 600 clamp(1.75rem, 1.35rem + 1.3vw, 2.375rem) / 1.12 var(--font-sans);
  letter-spacing: -0.035em;
  color: var(--ink);
  text-wrap: balance;
}

.cs-lead {
  margin-bottom: 18px;
  font-size: clamp(1.125rem, 1.04rem + 0.35vw, 1.3125rem);
  line-height: 1.6;
  color: var(--ink);
  text-wrap: pretty;
}

.cs-prose p {
  font-size: 17px;
  line-height: 1.75;
  color: var(--ink-2);
  text-wrap: pretty;
}

.cs-prose p + p {
  margin-top: 1em;
}

.cs-more {
  margin-top: 14px;
}

.cs-more summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font: 500 13px/1 var(--font-mono);
  color: var(--teal);
  text-transform: lowercase;
  cursor: pointer;
  list-style: none;
}

.cs-more summary::-webkit-details-marker {
  display: none;
}

.cs-more summary::before {
  content: "+";
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  transition: transform 0.3s var(--ease), background-color 0.3s var(--ease), color 0.3s var(--ease);
}

.cs-more[open] summary::before {
  content: "\2212";
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.cs-more summary .icon {
  display: none;
}

.cs-more[open] summary .cs-more__open,
.cs-more:not([open]) summary .cs-more__close {
  display: none;
}

.cs-more > .cs-prose {
  margin-top: 16px;
  padding-left: 20px;
  border-left: 1px solid var(--rule-strong);
}

/* ---------- Blocks ---------- */

.cs-block {
  margin-top: clamp(32px, 4vw, 44px);
}

.cs-frame {
  display: block;
  width: 100%;
  padding: clamp(8px, 1.2vw, 14px);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: zoom-in;
  transition: border-color 0.3s var(--ease), box-shadow 0.4s var(--ease);
}

.cs-frame:hover {
  border-color: var(--rule-strong);
  box-shadow: 0 18px 40px -24px rgba(11, 45, 58, 0.35);
}

.cs-frame img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
}

.cs-figure--column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(200px, 280px);
  gap: 16px 40px;
  align-items: end;
}

.cs-figure--column .cs-frame {
  width: auto;
  justify-self: start;
}

.cs-figure--column img {
  width: auto;
  max-width: 100%;
  max-height: 720px;
}

.cs-figure--column .cs-caption {
  position: relative;
  margin: 0 0 8px;
  padding-top: 16px;
  border-top: 1px solid var(--rule-strong);
}

.cs-figure--column .cs-caption::before {
  content: "";
  position: absolute;
  left: 0;
  top: -5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--teal);
}

@media (max-width: 760px) {
  .cs-figure--column {
    grid-template-columns: minmax(0, 1fr);
  }
}

.cs-figure--full .cs-frame {
  border-radius: 20px;
  padding: clamp(12px, 2vw, 24px);
  background: var(--tint);
  border-color: transparent;
}

.cs-caption {
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.cs-caption strong {
  margin-right: 4px;
  font: 500 12.5px/1 var(--font-mono);
  color: var(--teal);
  text-transform: lowercase;
}

/* pair */
.cs-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(12px, 2vw, 24px);
  align-items: start;
}

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

/* gallery: a ruled filmstrip */
.cs-gallery {
  padding: 16px 0 4px;
  border-top: 1px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule);
}

.cs-gallery__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.cs-gallery__head .cs-caption {
  margin: 0;
}

.cs-gallery__nav {
  display: flex;
  gap: 8px;
  flex: none;
}

.cs-icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-pill);
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--teal-ink);
  cursor: pointer;
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease), border-color 0.25s var(--ease),
    opacity 0.25s var(--ease);
}

.cs-icon-btn:hover {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.cs-icon-btn:disabled {
  opacity: 0.3;
  pointer-events: none;
}

.cs-icon-btn .icon {
  width: 18px;
  height: 18px;
}

.cs-gallery__track {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  padding-bottom: 18px;
  scrollbar-width: thin;
  scrollbar-color: var(--rule-strong) transparent;
}

.cs-gallery__item {
  flex: none;
  scroll-snap-align: start;
}

.cs-gallery__item .cs-frame {
  width: auto;
  padding: 8px;
}

.cs-gallery__item img {
  width: auto;
  height: clamp(240px, 32vw, 420px);
  max-width: none;
  border-radius: 6px;
}

.cs-gallery__label {
  display: block;
  margin-top: 10px;
  font: 500 12.5px/1.4 var(--font-mono);
  color: var(--muted);
  text-transform: lowercase;
}

/* carousel inside case studies */
.cs .carousel {
  margin: 0;
  max-width: none;
}

.cs .carousel__slide img {
  cursor: zoom-in;
}

/* quote */
.cs-quote {
  padding: 4px 0 4px 28px;
  border-left: 2px solid var(--teal);
}

.cs-quote blockquote {
  margin: 0;
}

.cs-quote p {
  font: 500 clamp(1.25rem, 1.08rem + 0.6vw, 1.625rem) / 1.42 var(--font-sans);
  letter-spacing: -0.015em;
  color: var(--teal-ink);
  text-wrap: pretty;
}

.cs-quote figcaption {
  margin-top: 14px;
  font: 500 12.5px/1.4 var(--font-mono);
  color: var(--muted);
  text-transform: lowercase;
}

/* cards: a ruled grid like the project cards */
.cs-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--rule-strong);
  border-left: 1px solid var(--rule);
}

.cs-cards--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cs-card {
  padding: 20px 20px 22px;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  transition: background-color 0.3s var(--ease);
}

.cs-card:hover {
  background: var(--tint);
}

.cs-card h3 {
  position: relative;
  margin-bottom: 8px;
  padding-left: 16px;
  font: 600 16px/1.35 var(--font-sans);
  letter-spacing: -0.01em;
  color: var(--ink);
}

.cs-card h3::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1.5px solid var(--teal);
}

.cs-card p {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink-2);
}

@media (max-width: 760px) {
  .cs-cards,
  .cs-cards--2 {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* steps: a timeline on a rule */
.cs-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0 24px;
  border-top: 1px solid var(--rule-strong);
}

.cs-steps li {
  position: relative;
  padding-top: 22px;
}

.cs-steps li::before {
  content: "";
  position: absolute;
  left: 0;
  top: -5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--teal);
}

.cs-steps__n {
  display: block;
  margin-bottom: 8px;
  font: 500 12.5px/1 var(--font-mono);
  color: var(--teal);
}

.cs-steps h3 {
  margin-bottom: 6px;
  font: 600 16px/1.35 var(--font-sans);
  color: var(--ink);
}

.cs-steps p {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink-2);
}

@media (max-width: 640px) {
  .cs-steps {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }
}

/* callout */
.cs-callout {
  padding: 18px 22px;
  border: 1px solid var(--rule);
  border-left: 2px solid var(--teal);
  border-radius: 0 12px 12px 0;
  background: var(--surface);
}

.cs-callout__title {
  margin-bottom: 8px;
  font: 500 12.5px/1.3 var(--font-mono);
  color: var(--teal);
  text-transform: lowercase;
}

.cs-callout p:last-child {
  font: 500 clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem) / 1.5 var(--font-sans);
  color: var(--ink);
}

/* video */
.cs-video__stage {
  padding: clamp(8px, 1.2vw, 14px);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
}

.cs-video video {
  display: block;
  width: 100%;
  border-radius: 8px;
  background: #0d1b22;
  object-fit: cover;
}

.cs-video--portrait {
  max-width: 380px;
}

/* formula */
.cs-formula {
  padding: 14px 20px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
  font: 500 17px/1.6 var(--font-mono);
  text-align: center;
}

.cs-block + .cs-formula,
.cs-formula + .cs-formula {
  margin-top: 0;
}

/* ---------- Next project ---------- */

.cs-next {
  margin-top: clamp(96px, 12vw, 152px);
}

.cs-next .thread {
  --h: 56px;
  margin-bottom: 4px;
}

.cs-next__link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  align-items: center;
  gap: clamp(20px, 3vw, 40px);
  padding: clamp(16px, 2vw, 24px);
  border: 1px solid var(--rule);
  border-top-color: var(--rule-strong);
  color: var(--ink);
  text-decoration: none;
  transition: background-color 0.4s var(--ease);
}

.cs-next__link:hover {
  background: var(--tint);
}

.cs-next__media {
  overflow: hidden;
  border-radius: var(--radius-media);
  aspect-ratio: 16 / 10;
}

.cs-next__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.9s var(--ease);
}

.cs-next__link:hover .cs-next__media img {
  transform: scale(1.045);
}

.cs-next__label {
  display: block;
  margin-bottom: 12px;
  font: 500 13px/1 var(--font-mono);
  color: var(--teal);
  text-transform: lowercase;
}

.cs-next__title {
  display: block;
  font: 700 clamp(2rem, 1.3rem + 2.6vw, 3.5rem) / 1 var(--font-sans);
  letter-spacing: -0.05em;
  color: var(--teal-ink);
  text-wrap: balance;
}

.cs-next__go {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  font: 500 13px/1 var(--font-mono);
  color: var(--teal);
  text-transform: lowercase;
}

.cs-next__go .icon {
  transition: transform 0.35s var(--ease);
}

.cs-next__link:hover .cs-next__go .icon {
  transform: translateX(5px);
}

.cs-next__all {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 52px;
  border-bottom: 1px solid var(--rule);
}

@media (max-width: 700px) {
  .cs-next__link {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- Lightbox ---------- */

.lightbox {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(10, 18, 22, 0.92);
  color: #fff;
}

.lightbox::backdrop {
  background: transparent;
}

.lightbox__inner {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 16px;
  height: 100%;
  padding: clamp(16px, 4vw, 56px);
}

.lightbox__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: zoom-out;
}

.lightbox__caption {
  max-width: 60rem;
  margin: 0 auto;
  font-size: 15px;
  line-height: 1.5;
  text-align: center;
  color: rgba(255, 255, 255, 0.82);
}

.lightbox__close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
}

.lightbox__close:hover {
  background: #fff;
  color: var(--ink);
}

.lightbox__close .icon {
  width: 22px;
  height: 22px;
}

@media (prefers-reduced-motion: no-preference) {
  .lightbox[open] {
    animation: lightbox-in 0.35s var(--ease);
  }
}

@keyframes lightbox-in {
  from {
    opacity: 0;
  }
}

html.has-lightbox {
  overflow: hidden;
}


/* ---------- Expand affordance on framed images ---------- */

.cs-frame {
  position: relative;
}

.cs-frame::after {
  content: "";
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256' fill='%230b5b76'%3E%3Cpath d='M216,48V96a8,8,0,0,1-16,0V67.31l-42.34,42.35a8,8,0,0,1-11.32-11.32L188.69,56H160a8,8,0,0,1,0-16h48A8,8,0,0,1,216,48ZM98.34,146.34,56,188.69V160a8,8,0,0,0-16,0v48a8,8,0,0,0,8,8H96a8,8,0,0,0,0-16H67.31l42.35-42.34a8,8,0,0,0-11.32-11.32Z'/%3E%3C/svg%3E")
    center / 16px no-repeat;
  box-shadow: 0 2px 8px rgba(11, 45, 58, 0.18);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.25s var(--ease), transform 0.3s var(--ease);
}

.cs-frame:hover::after,
.cs-frame:focus-visible::after {
  opacity: 1;
  transform: none;
}

/* ---------- Carousel with thumbnails ---------- */

.cs .carousel__footer {
  align-items: flex-start;
}

.carousel__thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: none;
}

.carousel__thumbs::-webkit-scrollbar {
  display: none;
}

.carousel__thumb {
  flex: none;
  width: 68px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.25s var(--ease);
}

.carousel__thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.carousel__thumb:hover {
  opacity: 0.9;
}

.carousel__thumb[aria-current="true"] {
  opacity: 1;
  border-color: var(--teal);
  box-shadow: 0 0 0 1px var(--teal);
}

/* ---------- Devices ---------- */

.cs-device {
  text-align: center;
}

.cs-device .cs-caption {
  margin-top: 20px;
}

.device {
  --ar: 16 / 10;
  position: relative;
  margin-inline: auto;
  text-align: left;
}

.device__screen {
  position: relative;
  background: #121b20;
  box-shadow: inset 0 0 0 1px #2c373d, 0 40px 80px -40px rgba(11, 45, 58, 0.55);
}

.device__display {
  position: relative;
  overflow: hidden;
  aspect-ratio: var(--ar);
  background: #000;
}

.device__display > img,
.device__display > video,
.device__display > .device__zoom img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.device__zoom {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

/* laptop */
.device--laptop {
  width: min(100%, 1000px);
}

.device--laptop .device__screen {
  width: 88%;
  margin-inline: auto;
  padding: 2.4% 2.4% 3%;
  border-radius: 18px 18px 4px 4px;
}

.device--laptop .device__screen::before {
  content: "";
  position: absolute;
  top: 1%;
  left: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2f3b41;
  transform: translateX(-50%);
}

.device--laptop .device__display {
  border-radius: 3px;
}

.device__base {
  display: none;
}

.device--laptop .device__base {
  position: relative;
  display: block;
  width: 100%;
  height: clamp(10px, 1.6vw, 16px);
  border-radius: 2px 2px 18px 18px;
  background: linear-gradient(#e9edef, #b7c0c5);
  box-shadow: 0 14px 24px -14px rgba(11, 45, 58, 0.5);
}

.device--laptop .device__base::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 15%;
  height: 45%;
  border-radius: 0 0 8px 8px;
  background: #c9d1d5;
  transform: translateX(-50%);
}

/* tablet */
.device--tablet {
  width: min(100%, 780px);
}

.device--tablet .device__screen {
  padding: 3%;
  border-radius: 28px;
}

.device--tablet .device__display {
  border-radius: 8px;
}

/* phone */
.device--phone {
  width: min(300px, 72vw);
}

.device--phone .device__screen {
  padding: 11px;
  border-radius: 46px;
}

.device--phone .device__screen::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: 20px;
  left: 50%;
  width: 28%;
  height: 22px;
  border-radius: 12px;
  background: #121b20;
  transform: translateX(-50%);
}

.device--phone .device__display {
  border-radius: 36px;
}

/* screens carousel inside a device */
.device .carousel__track {
  width: 100%;
  height: 100%;
}

.device .carousel__slide {
  aspect-ratio: auto;
  height: 100%;
  padding: 0;
}

.device .carousel__slide img {
  object-fit: cover;
  object-position: top center;
  cursor: zoom-in;
}

.device-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
}

.device-nav .carousel__btn {
  position: static;
  flex: none;
  margin: 0;
}

.device-nav .carousel__thumbs {
  max-width: min(640px, 70vw);
}

/* ---------- Video ---------- */

.cs-video {
  text-align: center;
}

.cs-video .cs-caption {
  margin-top: 20px;
}

.vplay {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  width: 100%;
  padding: 0;
  border: 0;
  background: rgba(10, 30, 38, 0.16);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.35s var(--ease), visibility 0s linear 0s;
}

.vplay[hidden] {
  display: none;
}

/* once playing, the overlay fades away and the native controls take over */
.is-playing .vplay {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.35s var(--ease), visibility 0s linear 0.35s;
}

.vplay__btn {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(52px, 6vw, 72px);
  height: clamp(52px, 6vw, 72px);
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 12px 30px -8px rgba(0, 0, 0, 0.45);
  transition: transform 0.35s var(--ease), background-color 0.25s var(--ease);
}

.vplay__btn::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.75);
}

.vplay__btn .icon {
  width: 38%;
  height: 38%;
  margin-left: 6%;
}

.vplay:hover .vplay__btn,
.vplay:focus-visible .vplay__btn {
  transform: scale(1.08);
  background: var(--teal-ink);
}

.vplay__time {
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: rgba(10, 30, 38, 0.7);
  font: 500 12px/1 var(--font-mono);
  letter-spacing: 0.02em;
}

@media (prefers-reduced-motion: no-preference) {
  .vplay__btn::before {
    animation: vpulse 2.4s var(--ease) infinite;
  }
}

@keyframes vpulse {
  0% {
    opacity: 0.9;
    transform: scale(0.92);
  }

  70%,
  100% {
    opacity: 0;
    transform: scale(1.3);
  }
}

/* show the whole frame of a video, never crop it */
.device__display > video {
  object-fit: contain;
  object-position: center;
  background: #0d1b22;
}

.cs-videos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 32px;
  justify-items: center;
}

/* ---------- Code viewer ---------- */

.code {
  overflow: hidden;
  border-radius: var(--radius);
  background: #0c222b;
  color: #d7e4e8;
  box-shadow: 0 30px 60px -36px rgba(11, 45, 58, 0.7);
  text-align: left;
}

.code__bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 14px;
  background: #091a21;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.code__dots {
  display: flex;
  gap: 6px;
  flex: none;
}

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

.code__tabs {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
}

.code__tab {
  position: relative;
  flex: none;
  padding: 14px 16px 13px;
  border: 0;
  background: transparent;
  color: rgba(215, 228, 232, 0.6);
  font: 500 13px/1 var(--font-mono);
  text-transform: lowercase;
  cursor: pointer;
  transition: color 0.2s var(--ease);
}

.code__tab:hover {
  color: #fff;
}

.code__tab[aria-selected="true"] {
  color: #fff;
  background: #0c222b;
}

.code__tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: #5cc2dc;
}

.code__panel {
  padding: 18px 0 22px;
}

.code__panel[hidden] {
  display: none;
}

.code__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 12px;
}

.code__title {
  font: 600 15px/1.4 var(--font-sans);
  color: #fff;
}

.code__orig {
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  color: #5cc2dc;
  font: 500 12px/1 var(--font-mono);
  text-transform: lowercase;
  cursor: zoom-in;
}

.code__orig:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.code pre {
  margin: 0;
  overflow-x: auto;
  font: 400 14px/1.75 var(--font-mono);
  tab-size: 4;
}

.code__line {
  display: block;
  padding: 0 22px 0 0;
  white-space: pre;
}

.code__line:hover {
  background: rgba(255, 255, 255, 0.03);
}

.code__ln {
  display: inline-block;
  width: 52px;
  padding-right: 18px;
  text-align: right;
  color: rgba(215, 228, 232, 0.28);
  user-select: none;
}

.tok-kw {
  color: #6fd0e8;
  font-weight: 600;
}

.tok-fn {
  color: #ffffff;
  font-weight: 600;
}

.tok-num {
  color: #f2c48d;
}

.tok-op {
  color: rgba(215, 228, 232, 0.6);
}

/* ---------- Flow ---------- */

.flow {
  display: grid;
  grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr));
  gap: 28px;
  counter-reset: flow;
}

.flow__step {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 16px 16px 18px;
  border: 1px solid var(--rule-strong);
  border-radius: 12px;
  background: var(--surface);
  transition: border-color 0.25s var(--ease), background-color 0.25s var(--ease);
}

.flow__step:hover {
  border-color: var(--teal);
  background: var(--tint);
}

.flow__step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -29px;
  width: 28px;
  height: 1px;
  background: var(--teal);
}

.flow__step:not(:last-child)::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: calc(50% - 4px);
  right: -6px;
  width: 0;
  height: 0;
  border-left: 7px solid var(--teal);
  border-top: 4.5px solid transparent;
  border-bottom: 4.5px solid transparent;
  transform: translateX(100%);
}

.flow__n {
  margin-bottom: 10px;
  font: 500 12px/1 var(--font-mono);
  color: var(--teal);
}

.flow__label {
  font: 600 15px/1.35 var(--font-sans);
  color: var(--ink);
}

.flow__items {
  margin-top: 8px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-2);
}

.flow__items li + li {
  margin-top: 4px;
}

.flow__loop {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  font: 500 12.5px/1.4 var(--font-mono);
  color: var(--teal);
  text-transform: lowercase;
}

.flow__loop::before {
  content: "\21BA";
  font-size: 18px;
}

@media (max-width: 900px) {
  .flow {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
    max-width: 420px;
  }

  .flow__step:not(:last-child)::after {
    top: auto;
    bottom: -23px;
    right: auto;
    left: 24px;
    width: 1px;
    height: 22px;
  }

  .flow__step:not(:last-child)::before {
    top: auto;
    bottom: -7px;
    right: auto;
    left: 20px;
    border-left: 4.5px solid transparent;
    border-right: 4.5px solid transparent;
    border-top: 7px solid var(--teal);
    border-bottom: 0;
    transform: translateY(100%);
  }
}

/* ---------- Chat ---------- */

.cs-chats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  align-items: start;
}

.chat {
  overflow: hidden;
  border: 1px solid var(--rule-strong);
  border-radius: 20px;
  background: var(--surface);
  text-align: left;
}

.chat__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--rule);
  background: var(--tint);
}

.chat__avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--teal-ink);
  color: #fff;
  font: 600 14px/1 var(--font-sans);
}

.chat__title {
  font: 600 15px/1.2 var(--font-sans);
  color: var(--ink);
}

.chat__sub {
  display: block;
  margin-top: 3px;
  font: 500 11.5px/1 var(--font-mono);
  color: var(--muted);
  text-transform: lowercase;
}

.chat__list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
}

.msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
}

.msg__from {
  margin-bottom: 4px;
  font: 500 11.5px/1.2 var(--font-mono);
  color: var(--muted);
}

.msg__bubble {
  padding: 10px 14px;
  border-radius: 16px 16px 16px 4px;
  background: var(--surface-2);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink);
}

.msg--right {
  align-self: flex-end;
  align-items: flex-end;
}

.msg--right .msg__bubble {
  border-radius: 16px 16px 4px 16px;
  background: var(--teal);
  color: #fff;
}

.msg--note {
  align-self: stretch;
  max-width: none;
}

.msg--note .msg__bubble {
  border: 1px dashed var(--rule-strong);
  border-radius: 12px;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
}

@media (prefers-reduced-motion: no-preference) {
  html.js .chat .msg {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
    transition-delay: calc(var(--m, 0) * 70ms);
  }

  html.js .reveal.is-in .chat .msg {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Board (affinity notes) ---------- */

.board {
  display: grid;
  grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--rule-strong);
  border-radius: 20px;
  overflow: hidden;
  background:
    radial-gradient(circle, var(--rule) 1px, transparent 1.2px) 0 0 / 18px 18px,
    var(--surface);
  text-align: left;
}

.board__col {
  padding: 18px;
}

.board__col + .board__col {
  border-left: 1px dashed var(--rule-strong);
}

.board__title {
  display: inline-block;
  margin-bottom: 16px;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--teal-ink);
  color: #fff;
  font: 600 13px/1.2 var(--font-sans);
}

.board__notes {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.note {
  width: calc(50% - 6px);
  min-height: 92px;
  padding: 12px;
  border-radius: 3px;
  background: #e3f1f5;
  box-shadow: 0 1px 1px rgba(11, 45, 58, 0.1), 0 8px 14px -10px rgba(11, 45, 58, 0.45);
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--ink);
  transform: rotate(var(--r, 0deg));
  transition: transform 0.3s var(--ease);
}

.note:nth-child(3n + 1) {
  --r: -1.2deg;
}

.note:nth-child(3n + 2) {
  --r: 0.8deg;
  background: #fff6d6;
}

.note:nth-child(3n) {
  --r: -0.4deg;
  background: #ffffff;
}

.note:hover {
  transform: rotate(0deg) scale(1.04);
}

@media (max-width: 760px) {
  .board {
    grid-template-columns: minmax(0, 1fr);
  }

  .board__col + .board__col {
    border-left: 0;
    border-top: 1px dashed var(--rule-strong);
  }
}

/* ---------- Tree ---------- */

.tree {
  text-align: center;
}

.tree__root {
  position: relative;
  display: inline-block;
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  background: var(--teal-ink);
  color: #fff;
  font: 600 15px/1.3 var(--font-sans);
}

.tree__root::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 1px;
  height: 24px;
  background: var(--teal);
}

.tree__branches {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--n, 5), minmax(0, 1fr));
  gap: 12px;
  margin-top: 48px;
  padding-top: 24px;
}

.tree__branches::before {
  content: "";
  position: absolute;
  top: -24px;
  left: calc(100% / var(--n, 5) / 2);
  right: calc(100% / var(--n, 5) / 2);
  height: 1px;
  background: var(--teal);
}

.tree__branch {
  position: relative;
}

.tree__branch::before {
  content: "";
  position: absolute;
  top: -48px;
  left: 50%;
  width: 1px;
  height: 48px;
  background: var(--teal);
}

.tree__label {
  display: inline-block;
  padding: 8px 14px;
  border: 1.5px solid var(--teal);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font: 600 14px/1.2 var(--font-sans);
  color: var(--teal-ink);
}

.tree__leaves {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.tree__leaves li {
  padding: 6px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--surface);
  font-size: 13.5px;
  color: var(--ink-2);
}

.tree__legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  margin-top: 24px;
  font: 500 12px/1 var(--font-mono);
  color: var(--muted);
  text-transform: lowercase;
}

.tree__legend span::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 10px;
  margin-right: 8px;
  vertical-align: -1px;
  border-radius: 4px;
}

.tree__legend span:nth-child(1)::before {
  background: var(--teal-ink);
}

.tree__legend span:nth-child(2)::before {
  border: 1.5px solid var(--teal);
}

.tree__legend span:nth-child(3)::before {
  border: 1px solid var(--rule-strong);
}

@media (max-width: 760px) {
  .tree {
    text-align: left;
  }

  .tree__root::after {
    left: 24px;
  }

  .tree__branches {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    margin-top: 24px;
    margin-left: 24px;
    padding: 0 0 0 20px;
    border-left: 1px solid var(--teal);
  }

  .tree__branches::before,
  .tree__branch::before {
    display: none;
  }

  .tree__leaves {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    margin-top: 10px;
  }

  .tree__legend {
    justify-content: flex-start;
  }
}

/* ---------- Rebuilt diagram: link to the original figure ---------- */

.cs-figcap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  margin-top: 16px;
  text-align: left;
}

.cs-figcap .cs-caption {
  margin: 0;
}

.cs-orig {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  color: var(--teal);
  font: 500 12.5px/1 var(--font-mono);
  text-transform: lowercase;
  cursor: zoom-in;
}

.cs-orig:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.cs-videos {
  align-items: start;
}

.cs-videos .device--phone {
  width: min(280px, 72vw);
}
