/* Slide deck (src/case/deck.js + src/deck/deck.js): our presentation rebuilt in the site's colours.
   Slides are 16:9 and scale like a real slide (sizes in cqw = % of the deck's width).
   On narrow screens they turn into normal, readable cards instead of a shrunken slide. */

.case__section > .deck {
  max-width: var(--deck-max);
}
.deck__viewport {
  container: deck / inline-size;
  touch-action: pan-y;
}
.deck__slides {
  display: grid;
  gap: var(--space-4); /* only matters without JS, when every slide shows */
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ---------- One slide ---------- */
.slide[hidden] {
  display: none; /* the carousel script hides every slide but the current one; .slide below must not win over this */
}
.slide {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  aspect-ratio: var(--ratio-hero);
  padding: 4.5cqw 5cqw;
  overflow: hidden;
  font-size: 1.35cqw;
  line-height: var(--leading-snug);
  color: var(--deck-ink);
  background: var(--deck-paper);
}
.slide p {
  margin: 0;
}
.slide > :not(.slide__road) {
  position: relative; /* above the road */
}
.slide__date {
  position: absolute;
  top: 2.2cqw;
  left: 5cqw;
  font: 0.9cqw / 1 var(--font-mono);
  letter-spacing: 0.3em;
  color: var(--deck-blue-text);
}
.slide__title {
  margin: 0;
  font: var(--weight-heading) 4.4cqw / var(--leading-tight) var(--font-heading);
  text-wrap: balance;
}
.slide__title--xl {
  font-size: 7.6cqw;
}
.slide__title--blue {
  color: var(--deck-blue-text);
}
.slide__subtitle {
  margin-top: 0.8cqw !important;
  font: 1.1cqw / var(--leading-snug) var(--font-mono);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* Cards: light or blue, rounded like the original deck */
.slide__card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.8cqw;
  padding: 2cqw;
  text-align: center;
  background: var(--deck-card);
  border-radius: var(--deck-radius);
}
.slide__card--blue {
  color: var(--deck-on-blue);
  background: var(--deck-blue);
}
.slide__card-title {
  font: var(--weight-heading) 2.3cqw / var(--leading-tight) var(--font-heading);
  color: var(--deck-blue-text);
}
.slide__card--blue .slide__card-title,
.slide__card--blue .slide__title {
  color: var(--deck-on-blue);
}
.slide__num {
  display: grid;
  place-items: center;
  width: 5.2cqw;
  aspect-ratio: 1;
  font: var(--weight-heading) 2.2cqw / 1 var(--font-heading);
  color: var(--deck-on-blue);
  background: var(--deck-blue);
  border-radius: var(--deck-radius);
}

/* Images: rounded like the deck's photo frames (a slide, not a photo on the page) */
.slide__img {
  position: relative;
  margin: 0;
  overflow: hidden;
  border-radius: var(--deck-radius);
  background: var(--deck-card);
}
.slide__img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.slide__img--framed {
  border: 0.5cqw solid var(--deck-blue);
}

/* Decorative road with a dashed centre line */
.slide__road {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.slide__road path {
  fill: none;
  vector-effect: non-scaling-stroke;
  stroke-linecap: butt;
}
.slide__road-base {
  stroke: var(--deck-road);
  stroke-width: 4.2cqw;
}
.slide__road-line {
  stroke: var(--deck-road-line);
  stroke-width: 0.45cqw;
  stroke-dasharray: 1.6cqw 1.8cqw;
}

/* ---------- Slide types ---------- */
.slide__cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2cqw;
  width: 62%;
  text-align: center;
}
.slide__icon {
  width: 6cqw;
  fill: var(--deck-ink);
}
.slide__pill {
  padding: 1cqw 6cqw;
  font: var(--weight-heading) 2.4cqw / 1.2 var(--font-heading);
  color: var(--deck-on-blue);
  background: var(--deck-blue);
  border-radius: var(--deck-radius);
}
.slide--cover .slide__cover {
  position: static; /* the byline sits in the slide's corner, not under the title */
}
.slide__byline {
  position: absolute;
  left: 5cqw;
  bottom: 3cqw;
  font: 0.9cqw / 1 var(--font-mono);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--deck-blue-text);
}

.slide__bento {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 2cqw;
  height: 100%;
}

.slide__principles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.6cqw;
  margin: 4.5cqw 0 0;
  padding: 0;
  list-style: none;
}
.slide--principles .slide__title {
  text-align: center;
}
.slide__card--numbered {
  justify-content: flex-start;
  padding-top: 0;
  font-size: 1.2cqw;
}
.slide__card--numbered .slide__num {
  margin: -2.6cqw auto 0.6cqw;
}
.slide__card--numbered .slide__card-title {
  min-height: 2lh; /* titles of one and two lines start the text at the same height */
  font-size: 1.6cqw;
  color: var(--deck-ink);
}

.slide__concepts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3cqw 4cqw;
  width: 72%;
  margin: 0 auto;
  padding: 0;
  list-style: none;
}
.slide__concepts .slide__card {
  padding: 2.4cqw 2cqw;
}
.slide__concept {
  font: var(--weight-heading) 3.3cqw / var(--leading-tight) var(--font-heading);
}
.slide__quote {
  font-weight: var(--weight-strong);
  font-style: italic;
  font-size: 1.45cqw;
}

.slide__split {
  display: grid;
  grid-template-columns: 2fr 3fr;
  gap: 4cqw;
  align-items: center;
  height: 100%;
}
.slide__frame {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.6cqw;
  background: var(--deck-blue);
  border-radius: var(--deck-radius);
}
.slide__frame .slide__img {
  flex: 1;
  min-height: 0;
}
.slide__quote--banner {
  padding: 0 0 1.4cqw;
  font-size: 1.9cqw;
  text-align: center;
  color: var(--deck-on-blue);
}
.slide__stack {
  display: flex;
  flex-direction: column;
  gap: 1.4cqw;
  min-height: 0;
}
.slide__stack--center {
  align-items: center;
  height: 100%;
  justify-content: center;
  text-align: center;
}
.slide__points {
  display: grid;
  gap: 1.4cqw;
  margin: 1cqw 0 0;
  padding: 0;
  list-style: none;
}
.slide__card--row {
  flex-direction: row;
  align-items: center;
  gap: 2cqw;
  padding: 1.6cqw 2cqw;
  text-align: left;
}
.slide__card--row .slide__num {
  flex: none;
}
.slide__card--row .slide__card-title {
  margin-bottom: 0.4cqw;
  color: var(--deck-ink);
}

.slide__split--elements {
  grid-template-columns: 11fr 9fr;
}
.slide__elements {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2cqw;
  height: 100%;
  margin: 0;
  padding: 2cqw;
  list-style: none;
  background: var(--deck-blue);
  border-radius: var(--deck-radius);
}
.slide__elements li {
  position: relative;
  min-height: 0;
}
.slide__img--tile {
  height: 100%;
  border: 0.4cqw solid var(--deck-card);
}
.slide__label {
  position: absolute;
  left: 50%;
  bottom: 1.2cqw;
  padding: 0.3cqw 1cqw;
  font: var(--weight-heading) 1.35cqw / 1.2 var(--font-heading);
  white-space: nowrap;
  color: var(--deck-blue-text);
  background: var(--deck-card);
  border-radius: calc(var(--deck-radius) / 2);
  transform: translateX(-50%);
}
.slide--elements .slide__img--framed {
  width: 100%;
  aspect-ratio: var(--ratio-landscape);
}

.slide--image .slide__stack {
  gap: 1cqw;
}
.slide__img--screen {
  flex: 1;
  min-height: 0;
  width: 100%;
  margin-top: 1cqw;
  border: var(--border-width) solid var(--line);
}
.slide__img--screen img {
  object-fit: contain;
  background: var(--white);
}

.slide__thanks {
  gap: 1.2cqw;
}
.slide__img--square {
  height: 32cqw;
  aspect-ratio: var(--ratio-square);
  flex: none;
}
.slide__spaced {
  font: 1.9cqw / 1 var(--font-body);
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--deck-blue-text);
}

/* ---------- Controls (shown by the script) ---------- */
.deck__controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  font: var(--text-small) / 1 var(--font-mono);
}
.deck__controls[hidden] {
  display: none;
}
.deck__btn {
  display: grid;
  place-items: center;
  width: var(--toggle-size);
  height: var(--toggle-size);
  padding: 0;
  font: var(--text-label) / 1 var(--font-mono);
  background: none;
  border: var(--border-width) solid var(--line);
  cursor: pointer;
}
.deck__btn:not(:disabled):hover,
.deck__btn:focus-visible {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--white);
}
.deck__btn:disabled {
  color: var(--ink-muted);
  opacity: 0.45;
  cursor: default;
}
.deck__btn--full {
  margin-left: auto;
}
.deck__count {
  min-width: 7ch;
  margin: 0 var(--space-2);
  letter-spacing: var(--tracking-label);
  color: var(--ink-muted);
}
.deck__dots {
  display: flex;
  flex: 1;
  gap: var(--space-1);
  max-width: calc(var(--space-8) * 4);
  margin: 0;
  padding: 0;
  list-style: none;
}
.deck__dots li {
  flex: 1;
}
.deck__dot {
  display: block;
  width: 100%;
  height: var(--toggle-size);
  padding: 0;
  background: none;
  border: 0;
  cursor: pointer;
}
/* The visible bar is thin; the button around it stays a comfortable target */
@media (max-width: 600px) { .deck__dots { max-width: none; gap: 0; } .deck__dots li { min-width: 24px; } }
.deck__dot::before {
  content: "";
  display: block;
  height: 3px;
  background: var(--line);
  transition: background-color var(--heat-up) var(--heat-ease);
}
.deck__dot[aria-current="step"]::before {
  background: var(--accent-cold);
}
.deck__dot:hover::before {
  background: var(--ink);
}

/* Slide change: a short slide-in from the side you're heading to */
.slide--from-right { animation: deck-in-right var(--deck-slide-in) var(--heat-ease); }
.slide--from-left { animation: deck-in-left var(--deck-slide-in) var(--heat-ease); }
@keyframes deck-in-right { from { opacity: 0; transform: translateX(3%); } }
@keyframes deck-in-left { from { opacity: 0; transform: translateX(-3%); } }
@media (prefers-reduced-motion: reduce) {
  .slide--from-right,
  .slide--from-left {
    animation: none;
  }
}

/* Full screen: the slide as large as the screen allows, controls underneath */
.deck:fullscreen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 0;
  padding: var(--deck-gutter);
  background: var(--page-bg);
}
.deck:fullscreen .deck__viewport {
  width: min(100%, (100vh - var(--space-10)) * 16 / 9);
  margin: 0 auto;
}
.deck:fullscreen .deck__controls,
.deck:fullscreen .media__caption {
  width: min(100%, (100vh - var(--space-10)) * 16 / 9);
  margin-left: auto;
  margin-right: auto;
}

/* ---------- Narrow screens: readable cards instead of a tiny slide ---------- */
@container deck (max-width: 639px) {
  .slide {
    aspect-ratio: auto;
    min-height: 100cqw;
    padding: var(--space-7) var(--space-4) var(--space-5);
    font-size: var(--text-small);
    --deck-radius: var(--space-2);
  }
  .slide__date {
    top: var(--space-4);
    left: var(--space-4);
    font-size: var(--text-tag);
  }
  .slide__road {
    display: none;
  }
  .slide__title { font-size: 28px; }
  .slide__title--xl { font-size: 40px; }
  .slide__subtitle { margin-top: var(--space-1) !important; font-size: var(--text-tag); }
  .slide__card { gap: var(--space-2); padding: var(--space-4); }
  .slide__card-title { font-size: 18px; }
  .slide__num { width: 36px; font-size: 16px; }
  .slide__img--framed { border-width: 3px; }

  .slide__cover { width: 100%; gap: var(--space-4); }
  .slide__icon { width: 44px; }
  .slide__pill { padding: var(--space-2) var(--space-6); font-size: 18px; }
  .slide--cover .slide__byline { bottom: var(--space-4); left: var(--space-4); right: var(--space-4); font-size: 10px; line-height: 1.4; }

  .slide__bento { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: none; gap: var(--space-3); }
  .slide__bento .slide__img--card { aspect-ratio: var(--ratio-card); }
  .slide__bento .slide__card--title,
  .slide__bento .slide__card:not(.slide__card--title):not(:nth-child(2)) { grid-column: 1 / -1; }

  .slide__principles { grid-template-columns: 1fr; gap: var(--space-6); margin-top: var(--space-7); }
  .slide__card--numbered { font-size: var(--text-small); }
  .slide__card--numbered .slide__num { margin: -18px auto var(--space-1); }
  .slide__card--numbered .slide__card-title { min-height: 0; font-size: 18px; }

  .slide__concepts { grid-template-columns: 1fr; width: 100%; gap: var(--space-3); }
  .slide__concept { font-size: 24px; }
  .slide__quote { font-size: var(--text-small); }

  .slide__split,
  .slide__split--elements { grid-template-columns: 1fr; gap: var(--space-5); }
  .slide__frame { padding: var(--space-3); }
  .slide__frame .slide__img { aspect-ratio: var(--ratio-portrait); }
  .slide__quote--banner { padding-bottom: var(--space-3); font-size: 18px; }
  .slide__stack { gap: var(--space-3); }
  .slide__card--row { gap: var(--space-3); padding: var(--space-3); }

  .slide__elements { gap: var(--space-2); padding: var(--space-2); }
  .slide__img--tile { aspect-ratio: var(--ratio-square); border-width: 2px; }
  .slide__label { bottom: var(--space-2); padding: 2px var(--space-2); font-size: 12px; }

  .slide__img--screen { flex: none; aspect-ratio: var(--ratio-landscape); }
  .slide__img--square { height: auto; width: 80%; }
  .slide__spaced { font-size: var(--text-small); }
}
