/* ==========================================================================
   VIDEOBLAST.AI — category portfolio carousels (markup is created by assets/js/portfolio.js)
   ========================================================================== */

.portfolio { position: relative; padding-top: clamp(8px, 3vh, 32px); }

/* ---------- Carousel ---------- */

.carousel {
  --slide-w: min(64vw, 880px, 104vh);  /* width of the active slide */
  --slide-k: 0.5625;                   /* slide height / width */
  --stage-pad: 44px;                   /* room above and below for the active slide's shadow */
  --ring: clamp(48px, 4.4vw, 66px);
  position: relative;
  transition: opacity 1.1s var(--ease-out), transform 1.2s var(--ease-out);
}
.carousel--portrait {
  --slide-w: min(25vw, 340px, calc(60vh * 9 / 16));
  --slide-k: 1.7778;
}
.carousel + .carousel { margin-top: clamp(64px, 11vh, 128px); }
.carousel.is-pending { opacity: 0; transform: translateY(28px); }

/* head: chapter + title on the left, counter and arrows on the right */
.carousel__head {
  position: relative;
  z-index: 2; /* above the stage's shadow room */
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "chapter controls" "title controls";
  align-items: end;
  column-gap: 32px;
  margin-bottom: clamp(20px, 3vh, 30px);
}
.carousel__chapter {
  grid-area: chapter;
  display: flex; align-items: center; gap: 14px;
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--gold-300);
}
.carousel__chapter::before {
  content: "";
  flex: none;
  width: 28px; height: 1px;
  background: var(--gold-grad);
}
.carousel__title {
  grid-area: title;
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(24px, 2.5vw, 40px);
  line-height: 1.08;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--white);
  text-wrap: balance;
  text-shadow: 0 2px 30px rgba(5, 20, 50, 0.25);
}
.carousel__controls {
  grid-area: controls;
  align-self: end;
  display: flex; align-items: center; gap: 12px;
}
.carousel--plain .carousel__head { grid-template-areas: "controls"; grid-template-columns: 1fr; justify-items: end; }

.carousel__count {
  margin: 0 10px 0 0;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.24em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text-muted);
}
.carousel__now { color: var(--gold-400); }
.carousel__of { margin: 0 0.3em 0 0.5em; }

.carousel__arrow {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: rgba(8, 26, 62, 0.16);
  transition: border-color .3s, color .3s, background-color .3s, opacity .3s;
}
.carousel__arrow svg { width: 16px; height: 16px; transition: transform .5s var(--ease-out); }
.carousel__arrow[aria-disabled="true"] { opacity: 0.32; cursor: default; }

/* stage: full-bleed, slides are placed by portfolio.js around its centre */
.carousel__stage {
  position: relative;
  height: calc(var(--slide-w) * var(--slide-k) + var(--stage-pad) * 2);
  margin: calc(var(--stage-pad) * -1) 0;
  overflow: hidden;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
/* clip only the sides, so the shadow of the active slide is never cut off */
@supports (overflow: clip) {
  .carousel__stage { overflow: visible; overflow-x: clip; }
}
.carousel.is-dragging .carousel__stage { cursor: grabbing; }

.carousel__slide {
  --shade: 1;
  position: absolute;
  top: var(--stage-pad);
  left: 50%;
  width: var(--slide-w);
  height: calc(var(--slide-w) * var(--slide-k));
  margin-left: calc(var(--slide-w) / -2);
  transform-origin: 50% 50%;
  transition: transform .9s var(--ease-out);
  will-change: transform;
}

.carousel__media {
  position: relative;
  display: block;
  width: 100%; height: 100%;
  border-radius: 10px;
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(160deg, rgba(23, 64, 127, 0.9) 0%, rgba(11, 35, 80, 0.95) 100%);
  box-shadow: 0 26px 50px -34px rgba(4, 16, 44, 0.85);
  transition: box-shadow .9s var(--ease-out);
}
.carousel__slide.is-active .carousel__media {
  box-shadow: 0 36px 72px -38px rgba(3, 12, 32, 0.92), 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.carousel__media:focus-visible { outline: 2px solid var(--gold-400); outline-offset: 5px; }

.carousel__poster,
.carousel__backdrop,
.carousel__video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  -webkit-user-drag: none;
}
.carousel__poster {
  opacity: 0;
  transition: opacity .8s var(--ease), transform 1.4s var(--ease-out);
}
.carousel__poster.is-loaded { opacity: 1; }
.carousel__video {
  z-index: 1;
  opacity: 0;
  pointer-events: none; /* clicks reach the button; no media context menu on the preview */
  background: transparent;
  transition: opacity .6s var(--ease), transform 1.4s var(--ease-out);
}
.carousel__slide.is-playing .carousel__video { opacity: 1; }

/* a film of the other orientation: shown whole over a blurred copy of its own poster */
.carousel__backdrop { filter: blur(22px) brightness(0.7) saturate(1.1); transform: scale(1.2); opacity: 0; transition: opacity .8s var(--ease); }
.carousel__backdrop.is-loaded { opacity: 1; }
.is-fit .carousel__poster,
.is-fit .carousel__video { object-fit: contain; }

/* bottom vignette under the duration */
.carousel__media::before {
  content: "";
  position: absolute; inset: 0; z-index: 2;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 62%, rgba(0, 0, 0, 0.36) 100%);
}
/* neighbours are dimmed; --shade goes 0 → 1 with the distance from the centre */
.carousel__media::after {
  content: "";
  position: absolute; inset: 0; z-index: 4;
  pointer-events: none;
  background: rgba(7, 21, 48, 0.58);
  opacity: var(--shade);
  transition: opacity .8s var(--ease-out);
}

.carousel__play {
  position: absolute; inset: 0; z-index: 5;
  width: var(--ring); height: var(--ring);
  margin: auto;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  background: rgba(0, 0, 0, 0.2);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  color: var(--white);
  opacity: 0;
  transform: scale(0.86);
  transition: opacity .6s var(--ease-out), transform .6s var(--ease-out), background-color .4s, border-color .4s, color .4s;
}
.carousel__play svg { width: 34%; height: 34%; margin-left: 6%; }
.carousel__slide.is-active .carousel__play { opacity: 1; transform: none; }

.carousel__time {
  position: absolute; right: 14px; bottom: 10px; z-index: 3;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  color: var(--white);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

@media (hover: hover) {
  .carousel__arrow:not([aria-disabled="true"]):hover { border-color: var(--gold-400); color: var(--gold-300); background: rgba(8, 26, 62, 0.3); }
  .carousel__arrow[data-carousel-prev]:not([aria-disabled="true"]):hover svg { transform: translateX(-3px); }
  .carousel__arrow[data-carousel-next]:not([aria-disabled="true"]):hover svg { transform: translateX(3px); }
  .carousel__slide:not(.is-active) .carousel__media:hover::after { opacity: calc(var(--shade) * 0.6); }
  .carousel__slide.is-active .carousel__media:hover .carousel__poster,
  .carousel__slide.is-active .carousel__media:hover .carousel__video { transform: scale(1.035); }
  .is-fit.is-active .carousel__media:hover .carousel__poster,
  .is-fit.is-active .carousel__media:hover .carousel__video { transform: none; }
  .carousel__slide.is-active .carousel__media:hover .carousel__play {
    transform: scale(1.08);
    background: rgba(246, 207, 124, 0.92);
    border-color: transparent;
    color: var(--navy-900);
  }
}
.carousel__slide.is-active .carousel__media:focus-visible .carousel__play {
  background: rgba(246, 207, 124, 0.92);
  border-color: transparent;
  color: var(--navy-900);
}

/* first placement, resizing and dragging follow the finger / the layout without easing */
.carousel.is-instant .carousel__slide,
.carousel.is-instant .carousel__media::after,
.carousel.is-dragging .carousel__slide,
.carousel.is-dragging .carousel__media::after { transition: none; }

/* reduced motion or Save-Data: posters only, no transitions */
.portfolio.is-still .carousel,
.portfolio.is-still .carousel__slide,
.portfolio.is-still .carousel__media,
.portfolio.is-still .carousel__media::after,
.portfolio.is-still .carousel__poster,
.portfolio.is-still .carousel__play { transition: none; }

/* ---------- Loading ---------- */

.skeleton {
  display: block;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08) linear-gradient(100deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.13) 50%, rgba(255, 255, 255, 0) 70%) no-repeat;
  background-size: 220% 100%;
  animation: shimmer 1.8s var(--ease) infinite;
}
.skeleton--chapter { grid-area: chapter; width: 150px; height: 10px; margin-bottom: 20px; }
.skeleton--title { grid-area: title; width: min(420px, 70%); height: clamp(22px, 2.3vw, 34px); }
.skeleton--slide {
  position: absolute;
  top: var(--stage-pad);
  left: 50%;
  width: var(--slide-w);
  height: calc(var(--slide-w) * var(--slide-k));
  margin-left: calc(var(--slide-w) / -2);
  border-radius: 10px;
}
/* the first slide is active, so only the right neighbour shows */
.skeleton--next { opacity: 0.55; transform: translateX(calc(var(--slide-w) * 0.935)) scale(0.8); }
@keyframes shimmer { from { background-position: 130% 0; } to { background-position: -130% 0; } }

/* ---------- Empty category ---------- */

.portfolio__screen {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 18px;
  min-height: clamp(300px, 46vh, 460px);
  padding: clamp(44px, 7vh, 72px) clamp(24px, 4vw, 64px);
  text-align: center;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.16);
  background:
    radial-gradient(80% 90% at 50% 0%, rgba(140, 185, 245, 0.22), rgba(140, 185, 245, 0) 70%),
    rgba(10, 36, 88, 0.28);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 40px 90px -50px rgba(3, 12, 32, 0.8);
  animation: portfolioIn 1.1s var(--ease-out) both;
}
.portfolio__headline { font-size: clamp(30px, 3.6vw, 56px); max-width: 14em; text-wrap: balance; }
.portfolio__note { margin: 0; max-width: 32em; font-size: 16px; line-height: 1.7; color: var(--text); }
.portfolio__screen .btn { margin-top: 14px; }
@keyframes portfolioIn { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

/* ---------- Responsive ---------- */

@media (max-width: 960px) {
  .carousel { --slide-w: min(74vw, 104vh); }
  .carousel--portrait { --slide-w: min(46vw, calc(62vh * 9 / 16)); }
}

/* phones: the active slide takes ~78 % of the width, neighbours peek in at the edges */
@media (max-width: 768px) {
  .carousel { --slide-w: 78vw; --stage-pad: 28px; }
  .carousel--portrait { --slide-w: min(78vw, calc(64vh * 9 / 16)); }
  .carousel + .carousel { margin-top: clamp(56px, 9vh, 88px); }
  .carousel__head {
    grid-template-areas: "chapter controls" "title title";
    align-items: center;
    column-gap: 16px;
    margin-bottom: 16px;
  }
  .carousel__chapter { margin: 0; gap: 10px; letter-spacing: 0.32em; }
  .carousel__chapter::before { width: 18px; }
  .carousel__title { margin-top: 10px; font-size: clamp(22px, 6.4vw, 30px); }
  .carousel__controls { align-self: center; gap: 8px; }
  .carousel__count { margin-right: 6px; font-size: 12px; letter-spacing: 0.18em; }
  .carousel__arrow { width: 40px; height: 40px; }
  .carousel__time { right: 10px; bottom: 6px; font-size: 12px; }
  .portfolio__screen { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .carousel, .carousel__slide, .carousel__media, .carousel__media::after, .carousel__poster, .carousel__play { transition: none; }
  .carousel.is-pending { opacity: 1; transform: none; }
  .skeleton { animation: none; }
  .portfolio__screen { animation: none; }
}
