/* Case presentation only. Images and editorial fields remain owned by the CMS. */
.alaffia-case-main > .alaffia-hero:has(.deckdocs-case-hero) {
  display: block;
  height: auto;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background: #000;
}

.deckdocs-case-hero {
  --gallery-card-width: clamp(216px, 24vw, 600px);
  display: grid;
  width: 100%;
  min-height: clamp(700px, 46.7vw, 1040px);
  align-content: center;
  padding-block: clamp(112px, 8vw, 156px) clamp(40px, 3vw, 64px);
  color: #fff;
  background: #000;
}

.deckdocs-case-hero__heading {
  position: relative;
  z-index: 2;
  display: grid;
  /* Keep the category row even when this optional CMS field is empty. */
  grid-template-rows: minmax(clamp(24px, 2.04vw, 36px), auto) auto;
  width: min(64%, 1000px);
  gap: 24px;
  justify-items: center;
  margin-inline: auto;
  text-align: center;
}

.deckdocs-case-hero .alaffia-hero__industry {
  width: auto;
  max-width: 100%;
  margin: 0;
  font-size: clamp(20px, 1.7vw, 30px);
  line-height: 1.2;
}

.deckdocs-case-hero .alaffia-hero__title {
  grid-row: 2;
  width: auto;
  max-width: 100%;
  margin: 0;
  font-size: 56px;
  line-height: 1.05;
  letter-spacing: -0.045em;
  overflow-wrap: anywhere;
}

.deckdocs-gallery {
  position: relative;
  z-index: 1;
  width: 100%;
  margin-block: 20px 24px;
  outline: none;
}

.deckdocs-gallery__stage {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 180px;
  gap: 24px;
  align-items: center;
  overflow-x: auto;
  padding: 24px max(24px, calc((100% - 600px) / 2));
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
}

.deckdocs-gallery__item {
  position: relative;
  width: min(72vw, 600px);
  flex: 0 0 min(72vw, 600px);
  margin: 0;
  scroll-snap-align: center;
}

.deckdocs-gallery__image {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: auto 16 / 9;
  max-width: none;
  border-radius: 0;
  background: transparent;
  object-fit: fill;
  user-select: none;
  -webkit-user-drag: none;
}

.deckdocs-gallery[data-gallery-ready] .deckdocs-gallery__stage {
  display: block;
  height: calc(var(--gallery-card-width) * 0.5625 + 32px);
  min-height: 0;
  padding: 0;
  overflow: visible;
  /* Each card owns its perspective. The stage stays flat so z-index wins. */
  transform-style: flat;
  touch-action: pan-y pinch-zoom;
  cursor: grab;
}

.deckdocs-gallery[data-gallery-ready] {
  margin-block: 12px;
}

.deckdocs-gallery[data-gallery-ready] .deckdocs-gallery__item {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--gallery-card-width);
  height: auto;
  flex: none;
  transform: translate(-50%, -50%);
  transform-origin: 50% 50%;
  isolation: isolate;
}

.deckdocs-gallery[data-gallery-ready] .deckdocs-gallery__image {
  transform-origin: 50% 50%;
  backface-visibility: hidden;
  opacity: 0;
  transition: opacity 420ms ease var(--gallery-entry-delay, 0ms);
}

.deckdocs-gallery[data-gallery-ready] .deckdocs-gallery__image[data-gallery-image-ready="true"] {
  opacity: 1;
}

.deckdocs-gallery[data-gallery-dragging] .deckdocs-gallery__stage {
  cursor: grabbing;
}

.deckdocs-gallery__controls {
  position: relative;
  z-index: 3;
  display: none;
  width: max-content;
  max-width: 100%;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 0 auto;
}

.deckdocs-gallery[data-gallery-ready] .deckdocs-gallery__controls {
  display: flex;
}

.deckdocs-gallery__button {
  display: grid;
  width: 48px;
  height: 44px;
  flex: 0 0 48px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  color: #bbb;
  background: #000;
  cursor: pointer;
}

.deckdocs-gallery__button:hover {
  color: #fff;
  background: #161616;
}

.deckdocs-gallery__button svg {
  width: 25px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1;
}

.deckdocs-gallery__button:focus-visible {
  outline: 2px solid #d4c6b5;
  outline-offset: 3px;
}

.deckdocs-gallery:focus-visible .deckdocs-gallery__status {
  outline: 2px solid #d4c6b5;
  outline-offset: 7px;
}

.deckdocs-gallery__status {
  min-width: 48px;
  border-radius: 2px;
  color: #999;
  font: 12px/1.4 "Instrument Sans", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  text-align: center;
  user-select: none;
}

.deckdocs-gallery__instructions {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.deckdocs-gallery[data-gallery-single] .deckdocs-gallery__controls {
  display: none;
}

.deckdocs-gallery[data-gallery-single] .deckdocs-gallery__stage {
  cursor: auto;
}

.deckdocs-case-hero__summary {
  position: relative;
  z-index: 2;
  display: grid;
  width: min(62%, 820px);
  gap: 16px;
  justify-items: center;
  margin-inline: auto;
  text-align: center;
}

.deckdocs-case-hero .alaffia-hero__description {
  width: auto;
  max-width: 100%;
  margin: 0;
  font-size: clamp(18px, 1.55vw, 26px);
  line-height: 1.3;
}

.deckdocs-case-hero .alaffia-hero__tags {
  height: auto;
  flex-wrap: wrap;
  gap: 6px;
}

.deckdocs-case-hero .alaffia-hero__tag {
  width: auto;
  height: auto;
  min-height: 22px;
  padding: 4px 10px;
  font-size: 11px;
  line-height: 1;
  letter-spacing: -0.02em;
}

.deckdocs-case-hero .alaffia-hero__stats-shell {
  width: min(76%, 1080px);
  height: auto;
  margin: clamp(32px, 2.5vw, 48px) auto 0;
}

.deckdocs-case-hero .alaffia-hero__stats {
  display: flex;
  width: 100%;
  height: auto;
  flex: 1 1 auto;
  align-items: stretch;
  justify-content: center;
  gap: 0;
}

.deckdocs-case-hero .alaffia-hero__stat {
  width: auto;
  height: auto;
  min-width: 0;
  flex: 1 1 0;
  justify-content: flex-start;
  gap: 12px;
  padding: 0 20px;
}

.deckdocs-case-hero .alaffia-hero__stat + .alaffia-hero__stat,
.deckdocs-case-hero .alaffia-hero__divider + .alaffia-hero__stat {
  border-left: 1px solid #333;
}

.deckdocs-case-hero .alaffia-hero__divider {
  display: none;
}

.deckdocs-case-hero .alaffia-hero__stat-label {
  font-size: 11px;
  line-height: 1.2;
}

.deckdocs-case-hero .alaffia-hero__stat-value {
  font-size: clamp(14px, 1.2vw, 20px);
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
}

@media (max-width: 810px) {
  .deckdocs-case-hero {
    --gallery-card-width: 32vw;
    min-height: 0;
    padding-block: 104px 40px;
  }
  .deckdocs-case-hero__heading { width: 80%; gap: 18px; grid-template-rows: none; }
  .deckdocs-case-hero .alaffia-hero__title { font-size: clamp(40px, 7.5vw, 56px); grid-row: auto; }
  .deckdocs-case-hero__summary { width: 76%; }
  .deckdocs-case-hero .alaffia-hero__stats-shell { width: 90%; }
  .alaffia-case-main .deckdocs-case-hero .alaffia-hero__stats[data-item-count] {
    grid-template-rows: none;
    grid-auto-rows: 1fr;
    gap: 0;
    align-items: stretch;
  }
  .alaffia-case-main .deckdocs-case-hero .alaffia-hero__stat {
    display: grid;
    grid-template-rows: auto 1fr;
    min-height: 64px;
    align-content: stretch;
    align-items: start;
    justify-content: stretch;
    gap: 8px;
    padding: 12px;
  }
}

@media (max-width: 600px) {
  .deckdocs-case-hero {
    --gallery-card-width: 52vw;
    padding-block: 96px 40px;
  }
  .deckdocs-case-hero__heading { width: calc(100% - 40px); gap: 16px; }
  .deckdocs-case-hero .alaffia-hero__industry { font-size: 18px; }
  .deckdocs-case-hero .alaffia-hero__title { font-size: 44px; }
  .deckdocs-gallery { margin-block: 12px 20px; }
  .deckdocs-gallery__controls { gap: 12px; }
  .deckdocs-case-hero__summary { width: calc(100% - 48px); gap: 16px; }
  .deckdocs-case-hero .alaffia-hero__description { font-size: 18px; line-height: 1.35; }
  .deckdocs-case-hero .alaffia-hero__stats-shell { width: calc(100% - 40px); margin-top: 36px; }
  .deckdocs-case-hero .alaffia-hero__stat-value { font-size: 15px; }
}

/* A short gallery shows larger central slides and needs their full height. */
.deckdocs-gallery[data-gallery-simple] {
  margin-block: 20px 16px;
}
.deckdocs-gallery[data-gallery-simple] .deckdocs-gallery__stage {
  height: clamp(140px, 38vw, 410px);
}
.deckdocs-gallery[data-gallery-simple] .deckdocs-gallery__controls {
  margin-top: 8px;
}

/* CMS metrics keep their editorial values and size to their rendered content. */
@media (max-width: 1099px) {
  .alaffia-case-main .alaffia-metrics {
    height: auto;
    min-height: 0;
  }
  .alaffia-case-main .alaffia-metrics .alaffia-metrics__grid {
    display: grid;
    height: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 32px;
    align-items: stretch;
  }
  .alaffia-case-main .alaffia-metrics .alaffia-metrics__grid[data-item-count="1"] {
    grid-template-columns: minmax(0, 1fr);
  }
  .alaffia-case-main .alaffia-metrics .alaffia-metrics__item {
    width: auto;
    height: auto;
    min-height: 0;
    padding: 12px 20px;
    overflow: visible;
  }
  .alaffia-case-main .alaffia-metrics .alaffia-metrics__value {
    max-width: 100%;
    font-size: clamp(28px, 5vw, 44px);
    line-height: 1.15;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .alaffia-case-main .alaffia-metrics .alaffia-metrics__description {
    width: 100%;
    margin-top: 12px;
    line-height: 1.4;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 600px) {
  .alaffia-case-main .alaffia-metrics .alaffia-metrics__grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .alaffia-case-main .alaffia-metrics .alaffia-metrics__item {
    padding: 0;
    border-left: 0;
  }
  .alaffia-case-main .alaffia-metrics .alaffia-metrics__grid[data-item-count="3"] .alaffia-metrics__item:last-child {
    width: 100%;
  }
  .alaffia-case-main .alaffia-metrics .alaffia-metrics__value {
    font-size: clamp(36px, 9vw, 48px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .deckdocs-gallery__stage { scroll-behavior: auto; }
  .deckdocs-gallery[data-gallery-ready] .deckdocs-gallery__image { transition: none; }
}

/* Simplified case hero: title, description, slide navigation and project facts. */
.deckdocs-case-hero { position: relative; isolation: isolate; align-content: start; padding-top: 140px; }
.deckdocs-case-hero__heading { grid-template-rows: auto; gap: 0; }
.deckdocs-case-hero .alaffia-hero__title { grid-row: auto; }
.deckdocs-case-hero__summary { margin-top: 24px; margin-bottom: 12px; }
.deckdocs-case-hero .alaffia-hero__description { font-size: 20px; line-height: 1.4; font-weight: 400; }
/* The side gradients span the whole hero, including projected slide edges.
   Text stays above them; there is no vertical mask or frosted overlay. */
.deckdocs-case-hero__heading,
.deckdocs-case-hero__summary,
.deckdocs-case-hero .alaffia-hero__stats-shell {
  position: relative;
  z-index: 3;
}
.deckdocs-case-hero::before,
.deckdocs-case-hero::after {
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 0;
  width: 34%;
  pointer-events: none;
  content: "";
}
.deckdocs-case-hero::before {
  left: -1px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.94), rgba(0, 0, 0, 0.68) 32%, rgba(0, 0, 0, 0.3) 66%, transparent);
}
.deckdocs-case-hero::after {
  right: -1px;
  background: linear-gradient(270deg, rgba(0, 0, 0, 0.94), rgba(0, 0, 0, 0.68) 32%, rgba(0, 0, 0, 0.3) 66%, transparent);
}
.alaffia-case-main .deckdocs-case-hero .alaffia-hero__stats[data-item-count] {
  display: flex;
  max-width: 1080px;
  gap: 0;
  align-items: stretch;
}
.alaffia-case-main .deckdocs-case-hero .alaffia-hero__stats[data-item-count] .alaffia-hero__stat {
  display: flex;
  width: auto;
  min-height: 0;
  height: auto;
  flex: 1 1 0;
  grid-column: auto;
  grid-row: auto;
  gap: 12px;
  padding: 0 24px;
  border: 0;
  border-left: 1px solid #333;
}
.alaffia-case-main .deckdocs-case-hero .alaffia-hero__stats[data-item-count] .alaffia-hero__stat:first-child { border-left: 0; }
.alaffia-case-main .deckdocs-case-hero .alaffia-hero__stats[data-item-count] .alaffia-hero__stat--timeline { display: none; }
@media (max-width: 810px) {
  .deckdocs-case-hero { padding-top: 132px; }
  .deckdocs-case-hero__summary { margin-top: 20px; }
  .alaffia-case-main .deckdocs-case-hero .alaffia-hero__stats[data-item-count] {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: auto;
    gap: 24px 0;
  }
  .alaffia-case-main .deckdocs-case-hero .alaffia-hero__stats[data-item-count] .alaffia-hero__stat { padding: 8px 16px; border: 0; }
  .alaffia-case-main .deckdocs-case-hero .alaffia-hero__stats[data-item-count] .alaffia-hero__stat--sector { display: none; }
  .alaffia-case-main .deckdocs-case-hero .alaffia-hero__stats[data-item-count] .alaffia-hero__stat--timeline { display: flex; }
  .alaffia-case-main .deckdocs-case-hero .alaffia-hero__stats[data-item-count] .alaffia-hero__stat--service,
  .alaffia-case-main .deckdocs-case-hero .alaffia-hero__stats[data-item-count] .alaffia-hero__stat--team { border-left: 1px solid #333; }
}
@media (max-width: 600px) {
  .deckdocs-case-hero { padding-top: 132px; }
  .deckdocs-case-hero .alaffia-hero__description { font-size: 20px; line-height: 1.4; }
  .deckdocs-case-hero::before,
  .deckdocs-case-hero::after { width: 22%; }
}
