/* =========================================
   ARTNEST TREASURES — PORTFOLIO: LATEST WORK
   Full-screen coverflow carousel. The selected artwork fills the
   section behind it; each work hangs in a black wooden frame with
   a white mat (gallery / RIBBA style). Card positions are set by js/portfolio.js via --x, --z,
   --ry, --s, --o, --blur.
   ========================================= */

/* Tall runway; the section inside sticks to the screen while scrolling
   advances the carousel (height set by js/portfolio.js) */
.portfolio-scroll {
  position: relative;
  height: 400vh;
}

.portfolio {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  --card-w: clamp(270px, 31vw, 480px);

  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: calc(var(--header-h, 96px) + clamp(var(--space-4), 3vh, var(--space-6))) 0 clamp(var(--space-5), 4vh, var(--space-7));
  overflow: hidden;
  isolation: isolate;
  color: var(--color-brand-warm-ivory);
  background-color: #1E1C1A;
}

/* ---------- Backdrop: the selected artwork, full and sharp ---------- */

.portfolio__backdrop {
  position: absolute;
  inset: 0;
  z-index: -1;
}

.portfolio__bg {
  position: absolute;
  inset: -4%;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  /* a light blur softens the busy pattern so the framed cards lead */
  filter: blur(10px) saturate(0.88) contrast(1.02);
  opacity: 0;
  transition: opacity 1400ms ease;
  will-change: transform;
}

/* Slow, gallery-like drift: a gentle zoom and pan (direction set per
   artwork by js/portfolio.js through --kb-x / --kb-y) */
.portfolio__bg.is-on {
  opacity: 1;
  animation: kenburns 36s ease-in-out infinite alternate;
}

@keyframes kenburns {
  from { transform: scale(1.02) translate(0, 0); }
  to   { transform: scale(1.12) translate(var(--kb-x, 1.5%), var(--kb-y, -1%)); }
}

/* Soft gallery light drifting slowly across the artwork */
.portfolio__backdrop::before {
  content: "";
  position: absolute;
  inset: -20%;
  z-index: 1;
  background: radial-gradient(circle at 50% 50%, rgba(255, 244, 225, 0.22), rgba(255, 244, 225, 0) 38%);
  mix-blend-mode: soft-light;
  animation: gallery-light 24s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes gallery-light {
  from { transform: translate(-18%, -10%); }
  to   { transform: translate(18%, 8%); }
}

/* Deep, smooth vignette + fine film grain for a printed, premium finish;
   keeps the heading, cards and dots legible */
.portfolio__backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0.09 0'/></filter><rect width='100%' height='100%' filter='url(%23g)'/></svg>"),
    radial-gradient(ellipse 60% 45% at 50% 52%, rgba(18, 16, 14, 0.28), rgba(18, 16, 14, 0) 100%),
    radial-gradient(ellipse 85% 75% at 50% 50%, rgba(18, 16, 14, 0.12) 35%, rgba(18, 16, 14, 0.4) 70%, rgba(18, 16, 14, 0.8) 100%),
    linear-gradient(180deg, rgba(18, 16, 14, 0.62), rgba(18, 16, 14, 0) 24%, rgba(18, 16, 14, 0) 76%, rgba(18, 16, 14, 0.6));
  pointer-events: none;
}

/* ---------- Heading ---------- */

.portfolio__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-5);
  width: 100%;
  max-width: var(--container-max-width);
  margin-inline: auto;
  padding-inline: var(--container-padding-desktop);
}

.portfolio__eyebrow {
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0 0 var(--space-2);
  font-size: var(--font-size-caption);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.06em;
  color: rgba(248, 245, 236, 0.9);
}

.portfolio__eyebrow::before {
  content: "";
  width: 28px;
  height: 1px;
  background-color: var(--color-brand-burnt-orange);
}

.portfolio__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 4vw, 3.5rem);
  font-weight: var(--font-weight-display);
  line-height: 1;
  letter-spacing: var(--letter-spacing-display);
  color: var(--color-brand-warm-ivory);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45), 0 4px 30px rgba(0, 0, 0, 0.6);
}

.portfolio__title em {
  font-style: italic;
  color: #E8865A; /* Burnt Orange, lifted for contrast on the artwork */
}

.portfolio__count {
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
  margin: 0;
  font-size: var(--font-size-caption);
  font-weight: var(--font-weight-medium);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2em;
  color: rgba(248, 245, 236, 0.8);
}

/* ---------- Stage & cards ---------- */

.portfolio__stage {
  display: grid;
  align-items: center;
  perspective: 1800px;
  touch-action: pan-y;
}

.portfolio__track {
  position: relative;
  height: calc(var(--card-w) * 0.8 + 118px);
  margin: 0;
  padding: 0;
  list-style: none;
  transform-style: preserve-3d;
}

.work {
  position: absolute;
  top: 0;
  left: 50%;
  width: var(--card-w);
  margin-left: calc(var(--card-w) / -2);
  transform:
    translateX(var(--x, 0px))
    translateZ(var(--z, 0px))
    rotateY(var(--ry, 0deg))
    scale(var(--s, 1));
  opacity: var(--o, 1);
  filter: blur(var(--blur, 0px));
  transition:
    transform 850ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 600ms ease,
    filter 600ms ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.work__card {
  padding: 14px;
  background-color: var(--color-brand-warm-ivory);
  border: 1px solid rgba(var(--ink-rgb, 46, 46, 43), 0.18);
  border-radius: 18px;
  backface-visibility: hidden;
  color: var(--color-neutral-charcoal);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.08),
    0 28px 50px -28px rgba(0, 0, 0, 0.55);
}

/* Gallery window: the artwork sits on the ivory card inside a fine
   charcoal hairline — light, editorial, artwork-first */
.work__frame {
  position: relative;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  aspect-ratio: 5 / 4;
  border: 1px solid rgba(var(--ink-rgb, 46, 46, 43), 0.22);
  border-radius: 10px;
  background: #FCFAF4;
  overflow: hidden;
}

.work__frame picture {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  min-height: 0;
}

/* Viewer: a fine black frame with a deep ivory mat */
.lightbox__frame {
  position: relative;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  border-radius: 2px;
  background: var(--color-neutral-charcoal);
}

.lightbox__mat {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  min-height: 0;
  background: var(--color-brand-warm-ivory);
  box-shadow: inset 0 0 0 1px rgba(var(--ink-rgb, 46, 46, 43), 0.2);
}

.work__frame picture {
  padding: clamp(14px, 2vw, 26px);
}

.work__frame img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain; /* the whole artwork, never cropped */
  transition: transform 900ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* Round pieces: cut out, so they float on the mat with a soft shadow */
.work--round .work__frame img {
  filter: drop-shadow(0 6px 12px rgba(var(--ink-rgb, 46, 46, 43), 0.2));
}

/* "See artwork" label on the active card */
.work__see {
  position: absolute;
  right: 14px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(248, 245, 236, 0.92);
  color: var(--color-brand-burnt-orange);
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-medium);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 400ms ease, transform 400ms ease;
}

.work__see svg {
  width: 14px;
  height: 9px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
}

.work.is-active .work__see {
  opacity: 1;
  transform: none;
  transition-delay: 300ms;
}

.work__body {
  padding: 16px 6px 4px;
}

.work__cat {
  margin: 0 0 4px;
  font-size: var(--font-size-small);
  font-weight: var(--font-weight-medium);
  letter-spacing: 0;
  color: var(--color-brand-burnt-orange);
}

.work__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: var(--font-weight-display);
  line-height: 1.3;
  letter-spacing: -0.005em;
}

.work__desc {
  margin: 4px 0 0;
  font-size: var(--font-size-small);
  line-height: 1.62;
  color: rgba(var(--ink-rgb, 46, 46, 43), 0.7);
}

.work:focus-visible {
  outline: none;
}

.work:focus-visible .work__card {
  outline: 3px solid var(--color-brand-forest-green);
  outline-offset: 4px;
}

/* ---------- Dots ---------- */

.portfolio__dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.portfolio__dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background-color: rgba(248, 245, 236, 0.4);
  cursor: pointer;
  transition: width 400ms cubic-bezier(0.22, 1, 0.36, 1), background-color 300ms ease;
}

.portfolio__dot[aria-selected="true"] {
  width: 30px;
  background-color: var(--color-brand-burnt-orange);
}

.portfolio__dot:focus-visible {
  outline: 2px solid var(--color-brand-warm-ivory);
  outline-offset: 3px;
}

/* ---------- Cursor badge over the active card ---------- */

.portfolio__cursor {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 20;
  padding: 7px 14px;
  border-radius: 999px;
  background-color: var(--color-brand-burnt-orange);
  color: #FFFFFF;
  font-size: var(--font-size-micro);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(var(--cx, 0px), var(--cy, 0px)) translate(-50%, -50%) scale(0.6);
  transition: opacity 250ms ease, transform 250ms cubic-bezier(0.22, 1, 0.36, 1);
}

.portfolio__cursor.is-on {
  opacity: 1;
  transform: translate(var(--cx, 0px), var(--cy, 0px)) translate(-50%, -50%) scale(1);
}

@media (hover: none) {
  .portfolio__cursor { display: none; }
}

/* ---------- Lightbox ---------- */

.lightbox {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-brand-warm-ivory);
}

/* a warm, softly lit gallery wall */
.lightbox::backdrop {
  background:
    radial-gradient(ellipse 60% 55% at 50% 42%, rgba(70, 62, 54, 0.98), rgba(22, 20, 18, 0.99) 75%);
}

.lightbox[open] {
  display: grid;
  place-items: center;
  animation: lb-in 400ms ease;
}

.lightbox__figure {
  display: grid;
  justify-items: center;
  gap: var(--space-4);
  margin: 0;
  padding: var(--space-7) var(--space-8);
}

.lightbox__frame {
  padding: clamp(8px, 0.9vw, 12px);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    inset 1px 1px 0 rgba(255, 255, 255, 0.14),
    inset -1px -1px 0 rgba(0, 0, 0, 0.6),
    0 40px 70px -30px rgba(0, 0, 0, 0.85),
    0 12px 24px -12px rgba(0, 0, 0, 0.6);
}

.lightbox__mat {
  padding: clamp(28px, 4vw, 64px);
}

.lightbox__img {
  display: block;
  max-width: min(68vw, 980px);
  max-height: 62dvh;
  width: auto;
  height: auto;
  margin: auto;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.lightbox figcaption {
  text-align: center;
}

.lightbox__cat {
  color: #E8865A;
}

/* the artwork's story, from Veda's catalogue */
.lightbox__desc {
  max-width: 34rem;
  margin: var(--space-3) auto var(--space-5);
  font-size: var(--font-size-small);
  line-height: 1.7;
  color: rgba(248, 245, 236, 0.82);
}

.lightbox[open] { overflow-y: auto; } /* long stories scroll on small screens */

/* wide screens: framed work on the left, its name and story on the right */
@media (min-width: 1024px) {
  .lightbox__figure {
    grid-template-columns: auto minmax(16rem, 24rem);
    align-items: center;
    column-gap: clamp(var(--space-7), 4vw, var(--space-9));
  }
  .lightbox figcaption { text-align: left; }
  .lightbox__title { font-size: 2.25rem; line-height: 1.1; margin-top: var(--space-2); }
  .lightbox__desc { margin: var(--space-4) 0 var(--space-6); font-size: var(--font-size-body); }
  .lightbox__img { max-width: min(46vw, 800px); max-height: 66dvh; }
}

.lightbox__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: var(--font-weight-display);
}

.lightbox__close,
.lightbox__nav {
  position: absolute;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid rgba(248, 245, 236, 0.45);
  border-radius: 50%;
  background: transparent;
  color: var(--color-brand-warm-ivory);
  font: inherit;
  font-size: 1.25rem;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.lightbox__close:hover,
.lightbox__nav:hover {
  background-color: var(--color-brand-warm-ivory);
  color: var(--color-neutral-charcoal);
}

.lightbox__close { top: var(--space-5); right: var(--space-5); }
.lightbox__nav { top: 50%; margin-top: -23px; }
.lightbox__nav--prev { left: var(--space-5); }
.lightbox__nav--next { right: var(--space-5); }

@keyframes lb-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@media (max-width: 1024px) {
  .portfolio__head {
    padding-inline: var(--container-padding-tablet);
  }

  .portfolio {
    --card-w: clamp(270px, 44vw, 420px);
  }
}

@media (max-width: 768px) {
  .portfolio {
    --card-w: min(78vw, 360px);
    gap: var(--space-5);
  }

  .portfolio__head {
    padding-inline: var(--container-padding-mobile);
  }

  .lightbox__figure {
    padding: calc(var(--space-8) + 16px) var(--space-4) 112px;
  }

  .lightbox__img { max-height: 44dvh; }

  .lightbox__nav {
    position: fixed;
    top: auto;
    bottom: var(--space-5);
    margin-top: 0;
    z-index: 2;
    background: rgba(22, 20, 18, 0.9);
  }

  .lightbox__close { position: fixed; z-index: 2; background: rgba(22, 20, 18, 0.9); }

  .lightbox__nav--prev { left: calc(50% - 56px); }
  .lightbox__nav--next { right: calc(50% - 56px); }
}

@media (prefers-reduced-motion: reduce) {
  .portfolio__bg.is-on,
  .portfolio__backdrop::before {
    animation: none;
  }

  .work,
  .work__frame img {
    transition-duration: 1ms;
  }

  .lightbox[open] {
    animation: none;
  }
}

/* ---------- Intro sub-text and buying calls to action ---------- */

.portfolio__head {
  align-items: flex-end;
}

.portfolio__sub {
  max-width: 30rem;
  margin: var(--space-3) 0 0;
  font-size: var(--font-size-body);
  line-height: 1.68;
  color: rgba(248, 245, 236, 0.86);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.55);
}

/* Calls to action use the site's shared button system (css/hero.css);
   the secondary gets an ivory treatment for the dark backdrop */
.portfolio__ctas {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: var(--button-gap);
}

.button--on-dark {
  --ring-color: var(--color-brand-warm-ivory);
  color: var(--color-brand-warm-ivory);
  border-color: rgba(248, 245, 236, 0.7);
  background-color: rgba(30, 28, 26, 0.3);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.button--on-dark:hover {
  color: var(--color-neutral-charcoal);
  border-color: var(--color-brand-warm-ivory);
  background-color: var(--color-brand-warm-ivory);
}

/* "Enquire to buy": solid Warm Ivory with charcoal type, so it reads
   clearly over the artwork backdrop */
.portfolio .button-primary {
  --ring-color: var(--color-brand-warm-ivory);
  color: var(--color-neutral-charcoal);
  background-color: var(--color-brand-warm-ivory);
  border-color: var(--color-brand-warm-ivory);
}

.portfolio .button-primary:hover {
  color: var(--color-neutral-charcoal);
  background-color: #FFFFFF;
  border-color: #FFFFFF;
}

.button--on-dark:focus-visible,
.portfolio .button-primary:focus-visible {
  outline-color: var(--color-brand-warm-ivory);
}

/* dots with the counter centred beneath */
.portfolio__nav {
  display: grid;
  justify-items: center;
  gap: var(--space-3);
}

/* viewer: enquire about the piece on screen (shared button-primary) */
.lightbox__buy {
  margin-top: var(--space-4);
}

@media (max-width: 768px) {
  .portfolio__head {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-4);
  }

  .portfolio__sub {
    font-size: var(--font-size-small);
  }

  .portfolio__ctas {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: var(--space-3);
  }

  .portfolio__ctas > a {
    padding-inline: var(--space-3);
    white-space: nowrap;
  }
}
