/* Narrix — shared gallery: hub, home, and individual cases. */
.case-module {
  position: relative;
  padding: clamp(44px, 5vw, 72px) 0;
  background: var(--bg, #050505);
}

.case-module--showcase { padding-top: 0; background: #000; }

/* Only the case-study hub: make the existing dark layer a little lighter. */
/* Hub only: clearer footage, with a local shadow protecting contact text. */
.page-case-hub .footer-outro .outro-video-overlay { opacity: 0.6; }
.page-case-hub .footer-outro .outro-video-bg {
  opacity: 0.84;
  filter: saturate(0.86) contrast(1.08) brightness(0.82);
}
.page-case-hub .footer-outro .footer-outro-content {
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.95), 0 8px 28px rgba(0, 0, 0, 0.9);
}
.page-case-hub .footer-outro .footer-copy {
  text-shadow: 0 2px 5px #000, 0 4px 16px #000;
}

.case-module-container {
  width: min(calc(100% - 44px), var(--container-wide, 1180px));
  margin-inline: auto;
}

.case-module-heading {
  margin: 0 0 28px;
  color: var(--text-faint, #7a8594);
  font-family: var(--font-display);
  font-size: var(--type-label, 0.72rem);
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.18em;
  text-align: center;
}

/* Match the existing offer-card title "Reklamy AI i wideo". */
.case-module-heading--showcase {
  margin-bottom: 28px;
  color: #fff;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: normal;
}

.case-module-all { margin: 12px 0 0; text-align: center; }

/* Match the existing "zobacz więcej" action: underline the label, not the arrow. */
.case-module-all .ui-text-cta.ui-text-cta.ui-text-cta {
  min-height: 44px;
  gap: 8px;
  padding: 0;
  border-bottom: 0;
  color: var(--brand);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: 0.08em;
  text-transform: lowercase;
}

.case-module-all .ui-text-cta.ui-text-cta.ui-text-cta > span {
  padding-bottom: 2px;
  border-bottom: 1px solid rgba(59, 140, 235, 0.3);
}

.case-module-all .ui-text-cta.ui-text-cta.ui-text-cta svg {
  width: 16px;
  height: 16px;
  flex-basis: 16px;
}

.case-module-all .ui-text-cta.ui-text-cta.ui-text-cta:hover,
.case-module-all .ui-text-cta.ui-text-cta.ui-text-cta:focus-visible {
  color: var(--brand-hover);
}

.case-module-all .ui-text-cta.ui-text-cta.ui-text-cta:hover > span,
.case-module-all .ui-text-cta.ui-text-cta.ui-text-cta:focus-visible > span {
  border-bottom-color: currentColor;
}

.case-gallery {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: clamp(250px, 25vw, 320px);
  gap: 8px;
  padding: 0;
}

.case-tile {
  position: relative;
  display: flex;
  grid-column: span 4;
  min-width: 0;
  align-items: flex-end;
  isolation: isolate;
  overflow: hidden;
  border-radius: var(--radius-md, 12px);
  background: #0c1016;
  color: #fff;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.case-tile:nth-child(9n + 1),
.case-tile:nth-child(9n + 7) { grid-column: span 7; }
.case-tile:nth-child(9n + 2),
.case-tile:nth-child(9n + 6) { grid-column: span 5; }
.case-tile:nth-child(9n + 8),
.case-tile:nth-child(9n + 9) { grid-column: span 6; }

/* The same six-card composition on the home page and every individual case. */
@media (min-width: 981px) {
  [data-case-context="showcase"] .case-tile:nth-child(6) { grid-column: 1 / -1; }
}

.case-tile::after {
  content: '';
  position: absolute;
  z-index: 3;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: inherit;
  pointer-events: none;
  transition: border-color 240ms ease;
}

.case-tile-visual {
  position: absolute;
  z-index: -2;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
}

.case-tile-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform: translate3d(0, var(--case-drift, 0px), 0) scale(var(--case-zoom, 1.08));
}

.case-tile::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.025) 15%, rgba(0, 0, 0, 0.1) 38%, rgba(0, 0, 0, 0.69) 73%, rgba(0, 0, 0, 0.93) 100%);
  pointer-events: none;
}

/* Existing body typography: calm white labels across every gallery. */
.case-tile-title {
  min-width: 0;
  max-width: 32ch;
  margin: 0;
  padding: clamp(18px, 2vw, 26px);
  color: #fff;
  font-family: var(--font-body);
  font-size: clamp(1rem, 1.3vw, 1.2rem);
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: normal;
  text-wrap: pretty;
  overflow-wrap: break-word;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.45);
  transition: transform 420ms var(--ease-cinematic, ease);
}

/* Opt in only after this gallery's observer has been installed. */
[data-case-gallery-motion] .case-tile {
  transition: opacity 760ms ease, transform 900ms cubic-bezier(0.16, 1, 0.3, 1), clip-path 1000ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-case-gallery-motion] .case-tile:not(.is-case-visible) {
  opacity: 0;
  transform: translate3d(0, 46px, 0);
  clip-path: inset(8% 0 0 round 12px);
}

[data-case-gallery-motion] .case-tile.is-case-visible {
  opacity: 1;
  transform: none;
  clip-path: inset(0 round 12px);
  transition-delay: var(--case-delay, 0ms);
}

.case-tile:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 5px;
}

.case-tile:focus-visible::after { border-color: var(--brand-hover); }

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .case-tile-image { transition: transform 900ms cubic-bezier(0.16, 1, 0.3, 1); }
  .case-tile:hover { --case-zoom: 1.13; }
  .case-tile:hover::after { border-color: rgba(139, 195, 255, 0.7); }
  .case-tile:hover .case-tile-title { transform: translate3d(0, -4px, 0); }
}

@media (max-width: 980px) {
  .case-gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: clamp(260px, 34vw, 330px);
    gap: 8px;
  }
  .case-gallery .case-tile { grid-column: span 1; }
  .case-gallery .case-tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .case-gallery .case-tile-title { padding: 20px; font-size: 1.05rem; }
}

@media (max-width: 700px) {
  .case-module-container { width: calc(100% - 32px); }
}

@media (max-width: 768px) {
  .case-module-heading--showcase { font-size: 1.2rem; }
}

@media (max-width: 600px) {
  .case-gallery {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: auto;
    gap: 8px;
  }
  .case-gallery .case-tile {
    grid-column: 1;
    width: 100%;
    aspect-ratio: 1.3 / 1;
    min-height: 0;
  }
  .case-gallery .case-tile-title { padding: 20px; font-size: 1.05rem; }
}

@media (prefers-reduced-motion: reduce) {
  .case-gallery .case-tile,
  .case-gallery .case-tile-title,
  .case-gallery .case-tile-image {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
    transition: none !important;
  }
}

@media (forced-colors: active) {
  .case-tile { border: 1px solid CanvasText; }
  .case-tile-title { background: Canvas; color: CanvasText; text-shadow: none; }
}

/* Current case retains its position and image, with no link or preview. */
.case-tile--current { cursor: default; }
.case-tile--current:hover { --case-zoom: 1.08; }
.case-tile--current:hover::after { border-color: rgba(255,255,255,.11); }
.case-tile--current:hover .case-tile-title { transform: none; }
.case-tile-language { font-size: .7em; margin-inline-start: .5em; opacity: .8; }
/* One showcase geometry and motion on home, offer and case pages. */
.case-module--showcase .case-module-container { width: min(1180px, calc(100% - clamp(16px, 2.2vw, 28px) * 2)); }
[data-case-context="showcase"] .case-tile-image { transition: transform 650ms cubic-bezier(.22,.7,.22,1); }
[data-case-context="showcase"][data-case-gallery-motion] .case-tile { clip-path: none; transition: opacity 500ms ease, transform 650ms cubic-bezier(.22,.7,.22,1); }
[data-case-context="showcase"][data-case-gallery-motion] .case-tile:not(.is-case-visible) { transform: translate3d(0,18px,0); }
@media (max-width: 900px) {
  [data-case-context="showcase"][data-case-gallery-motion] .case-tile { transform: none; transition: opacity 240ms ease; }
  [data-case-context="showcase"] .case-tile-image { transform: none; transition: none; }
}
@media (prefers-reduced-motion: reduce) {
  [data-case-context="showcase"] .case-tile,
  [data-case-context="showcase"] .case-tile-image { transition: none !important; }
}

/* Desktop labels use the available card width; compact layouts retain their existing limits. */
@media (min-width: 981px) {
  .case-gallery .case-tile-title { max-width: 100%; text-wrap: wrap; }
}
