/* ==========================================================================
   case-study.css — case study pages (loaded after base.css)
   Page grid, hero, sections, prose, figures, image stages, chart, stats,
   icon lists, and the image lightbox.
   ========================================================================== */

:root {
  --text-soft: #d6d1e4;   /* long-form reading text */
  --paper: #f3f0f9;       /* light panel behind screenshots with white backgrounds */
  --panel-dark:           /* dark violet panel behind cut-out screenshots */
    radial-gradient(70% 90% at 78% 100%, rgb(139 92 246 / 0.32), transparent 70%),
    radial-gradient(50% 70% at 0% 0%, rgb(255 63 164 / 0.1), transparent 70%),
    var(--bg-raised);
}

/* --- Page grid ------------------------------------------------------------
   Named lines let any block choose: content (the container), full (edge to
   edge), or bleed to one side (full-start / content-end).                   */
.cs-page {
  --cs-cols:
    [full-start] minmax(var(--gutter), 1fr)
    [content-start] minmax(0, var(--container))
    [content-end] minmax(var(--gutter), 1fr)
    [full-end];
  --cs-gap: clamp(2.25rem, 5vw, 4rem);

  display: grid;
  grid-template-columns: var(--cs-cols);
  overflow-x: clip;
  counter-reset: cs;
}

.cs-page > * {
  grid-column: full;
}

/* --- Hero ---------------------------------------------------------------- */
.cs-hero {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: var(--cs-cols);
  padding-block: clamp(3.5rem, 9vw, 7rem) clamp(3rem, 6vw, 5rem);
  overflow: hidden;
}

.cs-hero > * {
  grid-column: content;
}

.cs-hero__bg {
  grid-column: 1 / -1; /* absolutely-positioned grid children are sized by their grid area */
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 65%;
  opacity: 0.42;
  -webkit-mask-image: linear-gradient(to bottom, #000 50%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 50%, transparent 100%);
}

.cs-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg, rgb(5 4 10 / 0.92) 0%, rgb(5 4 10 / 0.55) 55%, rgb(5 4 10 / 0.15) 100%);
}

.cs-hero h1 {
  font-weight: 600;
}

.cs-hero__kicker {
  display: block;
  color: var(--text-muted);
  font-weight: 300;
  letter-spacing: -0.03em;
}

.cs-hero__lead {
  max-width: 48ch;
  margin-top: var(--space-4);
  color: var(--text-soft);
}

.glance {
  width: fit-content;
  max-width: 100%;
  margin-top: var(--space-5);
  padding: 1.5rem 1.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: rgb(11 9 18 / 0.62);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.glance__title {
  margin-bottom: 1.1rem;
  color: var(--violet-text);
  font: 500 var(--step--1) / 1 var(--font-body);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.glance__list {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem 3rem;
  margin: 0;
}

.glance dt {
  color: var(--text-muted);
  font-size: var(--step--1);
}

.glance dd {
  margin: 0.2rem 0 0;
  font-weight: 500;
}

/* --- Sections ------------------------------------------------------------ */
.cs-section {
  display: grid;
  grid-template-columns: var(--cs-cols);
  row-gap: var(--cs-gap);
  padding-block: clamp(3.25rem, 7vw, 6rem);
  counter-increment: cs;
}

.cs-section > * {
  grid-column: content;
  min-width: 0;
}

/* Heading on the left, reading column on the right (stacked on small screens) */
.cs-flow {
  display: grid;
  gap: var(--space-3);
}

@media (min-width: 60rem) {
  .cs-flow {
    grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
    column-gap: clamp(2rem, 5vw, 5rem);
  }

  .cs-head {
    grid-column: 1;
  }

  .cs-body {
    grid-column: 2;
  }
}

.cs-head h2::before {
  content: counter(cs, decimal-leading-zero);
  content: counter(cs, decimal-leading-zero) / "";
  display: block;
  margin-bottom: 1rem;
  color: var(--magenta);
  font: 500 var(--step--1) / 1 var(--font-body);
  letter-spacing: 0.22em;
}

/* --- Prose --------------------------------------------------------------- */
.prose {
  max-width: 68ch;
  color: var(--text-soft);
  line-height: 1.75;
}

.prose > * + * {
  margin-top: 1.25em;
}

.prose h3 {
  margin-top: 2.5em;
  color: var(--text);
  font-size: var(--step-1);
  letter-spacing: -0.01em;
}

.prose h3 + * {
  margin-top: 0.8em;
}

.prose .source {
  color: var(--text-muted);
  font-size: var(--step--1);
}

/* --- Figures ------------------------------------------------------------- */
.cs-figure,
.feature {
  margin: 0;
}

.zoom {
  position: relative;
  display: block;
  border-radius: var(--radius);
  text-decoration: none;
  cursor: zoom-in;
}

.zoom img {
  display: block;
  width: 100%;
  height: auto;
}

/* Small magnifier badge: shown on hover/focus, and always on touch screens */
.zoom::after {
  content: "";
  position: absolute;
  right: 0.75rem;
  bottom: 0.75rem;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f4f1fb' stroke-width='1.7' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6'/%3E%3Cpath d='m15 15 5 5M10.5 8v5M8 10.5h5'/%3E%3C/svg%3E")
      center / 1.4rem no-repeat,
    rgb(5 4 10 / 0.78);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
  pointer-events: none;
}

.zoom:hover::after,
.zoom:focus-visible::after {
  opacity: 1;
}

@media (hover: none) {
  .zoom::after {
    opacity: 0.9;
  }
}

/* Transparent screenshots: a soft violet halo gives them depth on the dark page */
.cs-figure--glow img,
.feature--glow img {
  filter: drop-shadow(0 0 2.5rem rgb(139 92 246 / 0.22));
}

.cs-figure--narrow {
  width: 100%; /* a grid item with auto margins would otherwise shrink to its caption */
  max-width: 52rem;
  margin-inline: auto;
}

.cs-figure--paper .zoom,
.cs-figure--paper .cs-figure__media {
  padding: clamp(0.75rem, 2.5vw, 2rem);
  background: var(--paper);
  box-shadow: 0 0 4rem -1.25rem rgb(139 92 246 / 0.4);
}

/* A figure with no lightbox: same panel, plain image */
.cs-figure__media {
  border-radius: var(--radius);
}

.cs-figure__media img {
  display: block;
  width: 100%;
  height: auto;
}

/* Breathing room when a figure follows prose */
.prose > .cs-figure {
  margin-top: clamp(2rem, 4vw, 3rem);
}

/* Screenshots with an opaque white background sit on a matching light "paper"
   panel; multiply makes their white vanish into the panel. */
.cs-figure--paper img {
  mix-blend-mode: multiply;
}

.caption {
  margin-top: 1rem;
  max-width: 62ch;
  color: var(--text-muted);
  font-size: var(--step--1);
  line-height: 1.65;
}

.caption[data-placeholder] {
  color: var(--magenta-bright);
  font-style: italic;
}

/* --- Final design: groups and features ----------------------------------- */
.cs-group__title {
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
  font-size: var(--step-2);
}

.feature {
  display: grid;
  gap: var(--space-4);
}

.feature__text h4 {
  margin-bottom: 0.6rem;
  font-size: var(--step-1);
}

.feature__text .caption {
  margin-top: 0;
  max-width: 58ch;
  font-size: var(--step-0);
  color: var(--text-soft);
}

.feature__image img {
  display: block;
  width: 100%;
  height: auto;
}

.feature__media .feature__image {
  margin-inline: auto;
}

/* Title left, caption right, then the media (same rhythm as the sections) */
.feature--stacked .feature__text {
  display: grid;
  gap: var(--space-2);
}

@media (min-width: 60rem) {
  .feature--stacked .feature__text {
    grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
    column-gap: clamp(2rem, 5vw, 5rem);
    align-items: start;
  }
}

/* Image panels that float a mockup over a background */
.stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: clamp(1.5rem, 5vw, 4.5rem);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) * 1.5);
}

.stage .feature__image {
  max-width: 64rem;
  margin-inline: auto;
}

/* Soften and darken photo backgrounds so they sit comfortably on the dark page */
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(120% 100% at 50% 40%, transparent 45%, rgb(5 4 10 / 0.5) 100%);
}

.stage--green {
  background: #1f6a1a url("../assets/img/ouc/final_homepage_bg.jpg") center / cover no-repeat;
}

.stage--forest {
  background: #16401a url("../assets/img/ouc/final_automated_bg.jpg") center / cover no-repeat;
}

/* The mockup hangs below the bottom edge of its background panel.
   Tune the overhang with --overhang (bigger = more of the devices hang below). */
.stage--overhang {
  --overhang: clamp(3.5rem, 10vw, 9.5rem);

  overflow: visible;
  padding: clamp(1.5rem, 5vw, 4rem) clamp(1rem, 4vw, 3rem) 0;
  border: 0;
  border-radius: 0;
}

.stage--overhang::before {
  content: "";
  position: absolute;
  inset: 0 0 var(--overhang) 0;
  z-index: -1;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) * 1.5);
  background:
    radial-gradient(120% 100% at 50% 40%, transparent 45%, rgb(5 4 10 / 0.5) 100%),
    #1f6a1a url("../assets/img/ouc/final_homepage_bg.jpg") center / cover no-repeat;
}

.stage--overhang::after {
  display: none;
}

.stage--overhang .feature__image {
  max-width: 70rem;
}

/* Re-creation of the original blue backdrop in CSS */
.stage--blue {
  background:
    radial-gradient(55% 80% at 24% 62%, rgb(176 226 242 / 0.95), transparent 72%),
    radial-gradient(42% 75% at 80% 48%, rgb(128 212 236 / 0.85), transparent 72%),
    radial-gradient(60% 70% at 50% 55%, rgb(150 190 220 / 0.7), transparent 75%),
    linear-gradient(135deg, #3f88ba, #2a69a8);
}

/* These mockups are cropped at the bottom, so they run flush to the panel's bottom edge */
.stage--blue,
.stage--forest {
  padding-bottom: 0;
}

/* Side-by-side: media and text */
@media (min-width: 60rem) {
  .feature--split {
    grid-template-columns: minmax(0, 7fr) minmax(0, 4fr);
    align-items: center;
    column-gap: clamp(2rem, 5vw, 5rem);
  }

  .feature--split .feature__media {
    grid-column: 1;
    grid-row: 1;
  }

  .feature--split .feature__text {
    grid-column: 2;
    grid-row: 1;
  }

  .feature--split.feature--reverse {
    grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
  }

  .feature--split.feature--reverse .feature__media {
    grid-column: 2;
  }

  .feature--split.feature--reverse .feature__text {
    grid-column: 1;
  }
}

/* Bleeds off the left edge of the screen (the artwork is cropped on its left) */
.cs-section > .feature--bleed-left {
  grid-column: full;
  padding-inline: 0;
}

.feature--bleed-left .feature__text {
  padding-inline: var(--gutter);
}

@media (min-width: 60rem) {
  .cs-section > .feature--bleed-left {
    grid-column: full-start / content-end;
    grid-template-columns: minmax(0, 1fr) minmax(0, 21rem);
    align-items: center;
    column-gap: clamp(2rem, 4vw, 4rem);
  }

  .feature--bleed-left .feature__text {
    grid-column: 2;
    grid-row: 1;
    padding-inline: 0;
  }

  .feature--bleed-left .feature__media {
    grid-column: 1;
    grid-row: 1;
  }
}

/* Bleeds off the right edge of the screen (the artwork is cropped on its right) */
.cs-section > .feature--bleed-right {
  grid-column: full;
}

.feature--bleed-right .feature__text {
  padding-inline: var(--gutter);
}

@media (min-width: 60rem) {
  .cs-section > .feature--bleed-right {
    grid-column: content-start / full-end;
    grid-template-columns: minmax(0, 21rem) minmax(0, 1fr);
    align-items: center;
    column-gap: clamp(2rem, 4vw, 4rem);
  }

  .feature--bleed-right .feature__text {
    grid-column: 1;
    grid-row: 1;
    padding-inline: 0;
  }

  .feature--bleed-right .feature__media {
    grid-column: 2;
    grid-row: 1;
  }
}

/* Runs off the bottom of a dark panel (the artwork is cropped at its bottom) */
.cs-section > .feature--bleed-bottom {
  gap: 0;
  padding: clamp(1.75rem, 5vw, 4rem) clamp(1.25rem, 4vw, 3.5rem) 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) * 1.5);
  background: var(--panel-dark);
}

.feature--bleed-bottom__inner {
  display: grid;
  gap: var(--space-4);
  align-items: end;
}

.feature--bleed-bottom .feature__text {
  align-self: center;
  padding-bottom: var(--space-3);
}

.feature--bleed-bottom .feature__media .feature__image {
  max-width: 52rem;
}

@media (min-width: 60rem) {
  .feature--bleed-bottom__inner {
    grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
    column-gap: clamp(2rem, 4vw, 4rem);
  }

  .feature--bleed-bottom .feature__media .feature__image {
    margin-inline: 0 auto;
  }
}

/* --- Chart: cost of customer interactions ---------------------------------- */
.chart {
  margin: 0;
  padding: clamp(1.5rem, 4vw, 2.75rem);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) * 1.5);
  background:
    radial-gradient(70% 120% at 100% 0%, rgb(139 92 246 / 0.14), transparent 65%),
    var(--bg-raised);
}

.chart__title {
  margin-bottom: var(--space-4);
  font-size: var(--step-1);
}

.chart__rows {
  display: grid;
  gap: 1.5rem;
  padding-left: 1.25rem;
  border-left: 1px solid var(--line-strong); /* the baseline the bars grow from */
}

.chart__row {
  display: grid;
  grid-template-columns: minmax(0, 15rem) minmax(0, 1fr) 4.5rem;
  grid-template-areas: "label bar value";
  align-items: center;
  gap: 0.35rem 1.25rem;
}

.chart__label {
  grid-area: label;
  color: var(--text-soft);
  line-height: 1.3;
}

.chart__track {
  grid-area: bar;
  display: block;
}

.chart__bar {
  display: block;
  width: var(--w);
  min-width: 0.25rem;
  height: 0.9rem;
  border-radius: 0 4px 4px 0;
  background: var(--magenta);
  transform-origin: left center;
}

.chart__value {
  grid-area: value;
  font: 600 var(--step-1) / 1 var(--font-display);
  letter-spacing: -0.02em;
}

@media (max-width: 47.99rem) {
  .chart__row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "label value"
      "bar bar";
  }
}

/* Bars grow in once the chart scrolls into view */
.js .chart.reveal .chart__bar {
  transform: scaleX(0);
  transition: transform 1s var(--ease) calc(var(--i, 0) * 0.12s + 0.2s);
}

.js .chart.reveal.is-visible .chart__bar {
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .js .chart.reveal .chart__bar {
    transform: none;
  }
}

/* --- Icon list (key insights) ---------------------------------------------- */
.insights {
  display: grid;
  gap: var(--space-3);
}

.insights li {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr);
  gap: 1.1rem;
  align-items: start;
}

.insights__icon {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  border: 1px solid rgb(169 139 255 / 0.35);
  border-radius: 50%;
  background: radial-gradient(circle at 30% 20%, rgb(255 63 164 / 0.22), rgb(139 92 246 / 0.14));
  color: var(--magenta-bright);
}

.insights svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.insights li > span:last-child {
  padding-top: 0.55rem;
}

/* --- Stats row (outcome) --------------------------------------------------- */
.stats {
  display: grid;
  gap: var(--space-3);
}

@media (min-width: 48rem) {
  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.stat {
  position: relative;
  overflow: hidden;
  padding: clamp(1.5rem, 3vw, 2.25rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(90% 90% at 0% 0%, rgb(255 63 164 / 0.12), transparent 70%),
    var(--bg-raised);
}

.stat::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, var(--magenta), var(--violet));
}

.stat__value {
  font: 600 clamp(3.5rem, 7vw, 5.75rem) / 1 var(--font-display);
  letter-spacing: -0.04em;
}

.stat__label {
  display: block;
  margin-top: 0.75rem;
  color: var(--text-soft);
}

/* --- Lightbox (built by js/main.js; plain links open the image without JS) --- */
html:has(dialog.lightbox[open]) {
  overflow: hidden;
}

.lightbox {
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgb(5 4 10 / 0.96);
  color: var(--text);
}

.lightbox[open] {
  display: flex;
  flex-direction: column;
}

.lightbox::backdrop {
  background: rgb(5 4 10 / 0.85);
}

.lightbox__bar {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.75rem var(--gutter);
}

.lightbox__button {
  min-height: 2.75rem;
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.04);
  color: var(--text);
  font: 500 var(--step--1) / 1 var(--font-body);
  letter-spacing: 0.06em;
  cursor: pointer;
}

.lightbox__button:hover {
  border-color: var(--violet-text);
  background: rgb(139 92 246 / 0.16);
}

.lightbox__scroller {
  display: grid;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 var(--gutter);
  place-items: center;
}

/* Sized from the viewport rather than percentages, which Safari and Firefox
   don't resolve reliably inside a flex/grid scroller (the image would collapse). */
.lightbox__img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 11rem);
  max-height: calc(100dvh - 11rem);
  width: auto;
  height: auto;
  cursor: zoom-in;
  background: var(--paper);
  border-radius: 4px;
}

.lightbox.is-zoomed .lightbox__scroller {
  place-items: start;
}

.lightbox.is-zoomed .lightbox__img {
  max-width: none;
  max-height: none;
  cursor: zoom-out;
}

.lightbox__caption {
  padding: 0.9rem var(--gutter) 1.25rem;
  color: var(--text-muted);
  font-size: var(--step--1);
  text-align: center;
}

/* --- Dome additions: backdrop section, dark/panel figures, pairs ------------ */
.cs-section--backdrop {
  position: relative;
  isolation: isolate;
}

.cs-section--backdrop::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: url("../assets/img/dome/challenge_bg.jpg") right center / cover no-repeat;
  opacity: 0.3;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 25%, #000 75%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 25%, #000 75%, transparent);
}

/* Dark artwork on the dark page: a hairline keeps its edge visible */
.cs-figure--dark .zoom {
  overflow: hidden;
  border: 1px solid var(--line);
}

.cs-figure--small {
  width: 100%;
  max-width: 20rem;
  margin-inline: auto;
}

.cs-figure--small .caption {
  text-align: center;
}

.feature__media.cs-figure--paper {
  padding: clamp(0.75rem, 2.5vw, 2rem);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 0 4rem -1.25rem rgb(139 92 246 / 0.4);
}

.feature__media.cs-figure--paper .cs-stack {
  max-width: 60rem;
  margin-inline: auto;
}

/* The stacked slices read as one page */
.cs-stack img {
  display: block;
  width: 100%;
  height: auto;
}

.cs-pair {
  display: grid;
  gap: var(--space-3);
  align-items: start;
}

@media (min-width: 48rem) {
  .cs-pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.cs-pair--panel {
  align-items: center;
  padding: clamp(1rem, 3vw, 2.5rem);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) * 1.5);
  background: var(--panel-dark);
}

/* Phone screens that run off one edge of the page, over a violet glow */
.cs-section > .bleed-shot {
  position: relative;
  isolation: isolate;
  width: min(100%, 62rem);
}

.cs-section > .bleed-shot--right {
  grid-column: content-start / full-end;
  justify-self: end;
}

.cs-section > .bleed-shot--left {
  grid-column: full-start / content-end;
  justify-self: start;
}

.bleed-shot::before {
  content: "";
  position: absolute;
  inset: -12% -4%;
  z-index: -1;
  background: radial-gradient(closest-side, rgb(139 92 246 / 0.5), rgb(255 63 164 / 0.12) 60%, transparent 100%);
  pointer-events: none;
}

.bleed-shot--right::before {
  inset-inline-end: 0;
}

.bleed-shot--left::before {
  inset-inline-start: 0;
}

.bleed-shot .zoom {
  border-radius: 0;
}

.bleed-shot img {
  filter: drop-shadow(0 0 2.5rem rgb(139 92 246 / 0.25));
}

/* A caption under a feature's media: cancel the grid gap so it sits as close as other captions */
.feature__caption {
  margin-top: calc(1rem - var(--space-4));
}

/* --- Back-to-top button (created by js/main.js) ------------------------------- */
.to-top {
  position: fixed;
  right: clamp(1rem, 3vw, 2rem);
  bottom: clamp(1rem, 3vw, 2rem);
  z-index: 40;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgb(11 9 18 / 0.78);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--text);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(0.5rem);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease), visibility 0s 0.25s, border-color 0.2s, background 0.2s;
}

.to-top.is-shown {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}

.to-top:hover {
  border-color: var(--violet-text);
  background: rgb(139 92 246 / 0.3);
}

.to-top svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (prefers-reduced-motion: reduce) {
  .to-top {
    transition: none;
    transform: none;
  }
}

/* Smaller artwork that shouldn't be stretched to the full narrow width */
.cs-figure--compact {
  max-width: 38rem;
}

/* --- Section notches (created by js/main.js; desktop with a mouse only) ------- */
.section-nav {
  display: none;
}

@media (min-width: 64rem) and (hover: hover) {
  .to-top {
    display: none; /* the notches replace it */
  }

  .section-nav {
    position: fixed;
    top: 50%;
    right: 0.5rem;
    z-index: 40;
    display: block;
    max-height: calc(100vh - var(--header-h) - 2rem);
    padding: 0.4rem 0.25rem 0.4rem 0.5rem;
    overflow: hidden auto;
    border: 1px solid transparent;
    border-radius: 1rem;
    transform: translateY(-50%);
    transition: background 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
    scrollbar-width: thin;
  }

  /* Opens on hover or when a link inside has keyboard focus */
  .section-nav:hover,
  .section-nav:focus-within {
    border-color: var(--line-strong);
    background: rgb(11 9 18 / 0.94);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    box-shadow: 0 1rem 3rem rgb(0 0 0 / 0.55);
  }

  .section-nav__list {
    display: grid;
    gap: 0;
  }

  .section-nav__link {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-height: 1.75rem;
    padding-inline: 0.5rem 0.4rem;
    border-radius: 0.5rem;
    color: var(--text-muted);
    font-size: var(--step--1);
    line-height: 1.3;
    text-decoration: none;
    white-space: nowrap;
  }

  .section-nav__label {
    max-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transition: max-width 0.25s var(--ease), opacity 0.2s var(--ease), margin 0.25s var(--ease);
  }

  .section-nav:hover .section-nav__label,
  .section-nav:focus-within .section-nav__label {
    max-width: 24rem;
    margin-right: 0.9rem;
    opacity: 1;
  }

  .section-nav__notch {
    flex: none;
    width: 1.1rem;
    height: 2px;
    border-radius: 2px;
    background: rgb(255 255 255 / 0.3);
    transition: width 0.2s var(--ease), background 0.2s var(--ease);
  }

  /* Currently reading: a longer, brighter notch */
  .section-nav__link[aria-current] .section-nav__notch {
    width: 1.6rem;
    background: var(--text);
  }

  .section-nav__link:hover .section-nav__notch,
  .section-nav__link:focus-visible .section-nav__notch {
    width: 1.6rem;
    background: var(--magenta-bright);
  }

  .section-nav__link:hover,
  .section-nav__link:focus-visible {
    background: rgb(255 255 255 / 0.07);
    color: var(--text);
  }

  .section-nav__link[aria-current] {
    color: var(--text);
  }

  /* In the open menu the current section also gets a highlighted row */
  .section-nav:hover .section-nav__link[aria-current],
  .section-nav:focus-within .section-nav__link[aria-current] {
    background: rgb(255 255 255 / 0.1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .section-nav,
  .section-nav__label,
  .section-nav__notch {
    transition: none;
  }
}

/* Violet glow behind a bleed image (same look as the Dome's phone screens) */
.feature--violet-glow .feature__media {
  position: relative;
  isolation: isolate;
}

.feature--violet-glow .feature__media::before {
  content: "";
  position: absolute;
  inset: -12% -4%;
  z-index: -1;
  background: radial-gradient(closest-side, rgb(139 92 246 / 0.5), rgb(255 63 164 / 0.12) 60%, transparent 100%);
  pointer-events: none;
}

.feature--bleed-left.feature--violet-glow .feature__media::before {
  inset-inline-start: 0;
}

/* Source line centered under the stats */
.cs-source {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--step--1);
  text-align: center;
}
