/* =========================================================
   Recipe / Usage Inspiration component (zb-recipe-)
   =========================================================
   Self-contained styles for the recipe carousel + modal.
   External tokens have fallback values so the component
   works dropped into any project; override on host root
   to theme.
   ========================================================= */
.zb-recipe {
  --zb-surface: #f5efe2;
  --zb-text: var(--charcoal-90, #212121);
  --zb-text-muted: var(--charcoal-90-muted, rgba(33, 33, 33, 0.64));
  --zb-text-on-bg: #ffffff;
  --zb-text-on-bg-muted: rgba(255, 255, 255, 0.78);
  --zb-border: rgba(33, 33, 33, 0.08);
  --zb-radius: 24px;
  --zb-radius-sm: 16px;
  --zb-accent: var(--orange-digital, #ff961b);
  --zb-chip-bg: rgba(33, 33, 33, 0.72);
  --zb-chip-text: #ffffff;
  --zb-bg-image: url("assets/recipe-bg.png");

  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 80px 0;
  color: var(--zb-text-on-bg);
}
.zb-recipe__bg {
  position: absolute;
  inset: -15% 0;
  background-image: var(--zb-bg-image);
  background-size: cover;
  background-position: center;
  z-index: -2;
  pointer-events: none;
  will-change: transform;
}

/* Scroll-driven parallax: bg drifts -10% to +10% while in view.
   Chrome/Edge 115+. Graceful no-op elsewhere. */
@supports (animation-timeline: view()) {
  .zb-recipe__bg {
    animation: zb-recipe-parallax linear both;
    animation-timeline: view();
    animation-range: cover 0% cover 100%;
  }
}
@keyframes zb-recipe-parallax {
  from { transform: translateY(-10%); }
  to { transform: translateY(10%); }
}
.zb-recipe::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(40, 24, 12, 0.15) 0%,
    rgba(40, 24, 12, 0.28) 100%
  );
  z-index: -1;
  pointer-events: none;
}

.zb-recipe__inner {
  max-width: var(--content-max, 1344px);
  margin: 0 auto;
  padding: 0 var(--gutter-m, 16px);
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}

/* Intro (left column) ---------------------------------------- */
.zb-recipe__intro {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.zb-recipe__heading {
  font-weight: 500;
  font-size: 36px;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--zb-text-on-bg);
  margin: 0;
  max-width: 14ch;
}
.zb-recipe__caption {
  font-size: 15px;
  line-height: 1.4;
  color: var(--zb-text-on-bg-muted);
  margin: 0;
  max-width: 32ch;
}

/* Deck + stacked cards (right column) ------------------------ */
.zb-recipe__deck-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 24px 24px 0;
}
.zb-recipe__stack {
  position: relative;
  width: min(340px, 84vw);
  aspect-ratio: 340 / 530;
}
.zb-recipe__card {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: var(--zb-surface);
  border: 0;
  border-radius: 24px;
  padding: 8px;
  margin: 0;
  text-align: left;
  font: inherit;
  color: var(--zb-text);
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transform-origin: 50% 100%;
  transition:
    transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 0.4s ease,
    box-shadow 0.4s ease;
  box-shadow: 0 24px 56px rgba(20, 10, 0, 0.28);
}
.zb-recipe__card[data-pos="0"] {
  transform: translate(0, 0) rotate(0deg);
  z-index: 3;
}
.zb-recipe__card[data-pos="0"]:hover {
  transform: translate(0, -8px) rotate(0deg);
  box-shadow: 0 36px 72px rgba(20, 10, 0, 0.38);
}

/* Scroll-in: cards stack tight until the section enters the viewport,
   then fan out via the data-pos transforms. */
.zb-recipe__stack:not(.is-revealed) .zb-recipe__card[data-pos="1"],
.zb-recipe__stack:not(.is-revealed) .zb-recipe__card[data-pos="2"] {
  transform: translate(0, 0) rotate(0deg) scale(0.96);
  opacity: 0.6;
}
.zb-recipe__card[data-pos="1"] {
  transform: translate(10px, -10px) rotate(3.5deg);
  z-index: 2;
  box-shadow: 0 18px 40px rgba(20, 10, 0, 0.22);
}
.zb-recipe__card[data-pos="2"] {
  transform: translate(20px, -20px) rotate(7deg);
  z-index: 1;
  box-shadow: 0 14px 32px rgba(20, 10, 0, 0.18);
}
/* Cards beyond the visible 3 hide behind the stack */
.zb-recipe__card[data-pos]:not([data-pos="0"]):not([data-pos="1"]):not([data-pos="2"]) {
  transform: translate(20px, -20px) rotate(7deg);
  opacity: 0;
  z-index: 0;
  pointer-events: none;
}
.zb-recipe__card[data-pos="0"]:focus-visible {
  outline: 2px solid var(--zb-accent);
  outline-offset: 4px;
}
.zb-recipe__card:not([data-pos="0"]) {
  pointer-events: none;
}

/* Animating-out state (the "fly off the deck" feel) */
.zb-recipe__card.is-leaving {
  transform: translate(120%, -40px) rotate(20deg) !important;
  opacity: 0;
}
.zb-recipe__card.is-entering {
  transition: none;
  opacity: 0;
}

/* Media inside card (inset, padded, rounded, vertical 4:5) */
.zb-recipe__media {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: 4 / 5;
  background-color: var(--zb-tile-placeholder, #eeeeee);
  background-size: cover;
  background-position: center;
  border-radius: 12px;
  overflow: hidden;
}
.zb-recipe__media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Glass chip overlaid on card image (bottom-left) */
.zb-recipe__chip[data-on-media="true"] {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 3;
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  backdrop-filter: blur(16px) saturate(1.6);
  color: var(--zb-text);
  padding: 4px 12px 4px 4px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

/* Card body (title + description) */
.zb-recipe__card-body {
  flex: 0 0 auto;
  padding: 4px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--zb-surface);
}
.zb-recipe__card-title {
  font-weight: 500;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--zb-text);
  margin: 0;
}
.zb-recipe__card-desc {
  font-size: 14px;
  line-height: 1.4;
  color: var(--zb-text-muted);
  margin: 0;
}

/* Nav arrows ------------------------------------------------- */
.zb-recipe__nav {
  display: flex;
  gap: 12px;
}
.zb-recipe__nav-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: transparent;
  color: var(--zb-surface);
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    background 0.15s ease,
    color 0.15s ease;
}
.zb-recipe__nav-btn:hover {
  background: var(--zb-surface);
  color: var(--zb-text);
  transform: translateY(-1px);
}
.zb-recipe__nav-btn:focus-visible {
  outline: 2px solid var(--zb-accent);
  outline-offset: 3px;
}
.zb-recipe__nav-btn svg {
  width: 18px;
  height: 18px;
}

/* Creator chip ------------------------------------------------ */
.zb-recipe__chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--zb-text);
  align-self: flex-start;
}
.zb-recipe__chip-avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--zb-accent);
  color: var(--zb-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 13px;
  flex-shrink: 0;
  overflow: hidden;
}
.zb-recipe__chip-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.zb-recipe__chip[data-on-media="true"] .zb-recipe__chip-avatar {
  width: 24px;
  height: 24px;
  font-size: 11px;
}
.zb-recipe__chip-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.1;
}
.zb-recipe__chip-name {
  font-weight: 500;
  font-size: 15px;
  line-height: 1.2;
}
.zb-recipe__chip-role {
  font-size: 13px;
  line-height: 1.2;
  opacity: 0.6;
}
.zb-recipe__chip[data-on-media="true"] .zb-recipe__chip-name {
  font-size: 12px;
}
.zb-recipe__chip[data-on-media="true"] .zb-recipe__chip-role {
  font-size: 11px;
}

/* Testimonial-quote variant (reserved for future entries) ---- */
.zb-recipe__tile--quote {
  grid-template-columns: 1fr;
  padding: 24px;
  gap: 16px;
}
.zb-recipe__tile--quote .zb-recipe__quote {
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--zb-text);
  margin: 0;
}

/* Desktop two-column ---------------------------------------- */
@media (min-width: 900px) {
  .zb-recipe {
    padding: 96px 0;
  }
  .zb-recipe__inner {
    padding: 0 var(--gutter-d, 48px);
    grid-template-columns: minmax(280px, 1fr) minmax(0, 1fr);
    gap: 56px;
    align-items: center;
  }
  .zb-recipe__intro {
    padding-top: 8px;
    gap: 16px;
  }
  .zb-recipe__heading {
    font-size: 60px;
    line-height: 1;
    max-width: none;
  }
  .zb-recipe__caption {
    font-size: 16px;
  }
  .zb-recipe__deck-wrap {
    padding: 24px 32px 0;
    gap: 32px;
  }
  .zb-recipe__stack {
    width: 380px;
    aspect-ratio: 380 / 560;
  }
  .zb-recipe__card-title {
    font-size: 20px;
  }
  .zb-recipe__nav-btn {
    width: 48px;
    height: 48px;
  }
  .zb-recipe__nav-btn svg {
    width: 20px;
    height: 20px;
  }
}

/* =========================================================
   Modal
   =========================================================
   position: fixed + inset:0 + margin:auto guarantees the modal
   is always centered as an overlay even when top-layer
   rendering is suspended (which Chrome can do during a View
   Transition).
   ========================================================= */
.zb-recipe-modal {
  border: 0;
  margin: auto;
  background: var(--zb-surface, #f5efe2);
  color: var(--charcoal-90, #212121);
  border-radius: 24px;
  width: min(540px, 92vw);
  max-width: 92vw;
  max-height: 90vh;
  overflow: hidden;
  position: fixed;
  inset: 0;
  z-index: 9999;
  padding: 16px;
  gap: 16px;
}
.zb-recipe-modal:not([open]) {
  display: none;
}
.zb-recipe-modal[open] {
  display: grid;
  grid-template-rows: auto 1fr;
}
.zb-recipe-modal::backdrop {
  background: rgba(17, 17, 17, 0.55);
  backdrop-filter: blur(4px);
}
.zb-recipe-modal__close {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--charcoal-90, #212121);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
  box-shadow: 0 2px 8px rgba(17, 34, 17, 0.12);
  border: 0;
  cursor: pointer;
}
.zb-recipe-modal__close:hover {
  background: #fff;
}
.zb-recipe-modal__close svg {
  width: 18px;
  height: 18px;
}
.zb-recipe-modal__content {
  display: contents;
}
.zb-recipe-modal__media {
  width: 100%;
  aspect-ratio: 4 / 5;
  background-size: cover;
  background-position: center;
  position: relative;
  border-radius: 12px;
  overflow: hidden;
}
.zb-recipe-modal__media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Big play button on the modal image */
.zb-recipe-modal__play {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: var(--zb-text);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
  transform: translate(-50%, -50%);
  z-index: 2;
}
.zb-recipe-modal__play svg {
  width: 24px;
  height: 24px;
  margin-left: 3px;
}

/* Primary CTA in modal */
.zb-recipe-modal__cta {
  width: 100%;
  height: 48px;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--orange-digital, #ff961b);
  color: var(--charcoal-90, #212121);
  cursor: pointer;
  transition: filter 0.15s ease;
}
.zb-recipe-modal__cta:hover {
  filter: brightness(0.96);
}

.zb-recipe-modal__body {
  padding: 4px 4px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.zb-recipe-modal__title {
  font-weight: 500;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0;
}
.zb-recipe-modal__desc {
  font-size: 15px;
  line-height: 1.4;
  color: var(--charcoal-90-muted, rgba(33, 33, 33, 0.64));
  margin: 0;
}
.zb-recipe-modal__steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.zb-recipe-modal__step {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.4;
}
.zb-recipe-modal__step-num {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--orange-10, #ffeddc);
  color: var(--orange-100, #c67123);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 13px;
  flex-shrink: 0;
}
.zb-recipe-modal__step-text {
  padding-top: 2px;
  color: var(--charcoal-90, #212121);
}

/* Two-column layout on desktop: image left, content right ---- */
@media (min-width: 720px) {
  .zb-recipe-modal[open] {
    width: min(820px, 92vw);
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto;
    align-items: start;
    gap: 24px;
    padding: 20px;
  }
  .zb-recipe-modal__close {
    top: 28px;
    right: 28px;
  }
  .zb-recipe-modal__media {
    align-self: start;
  }
  .zb-recipe-modal__body {
    padding: 8px 8px 8px 4px;
    gap: 16px;
    align-self: start;
    overflow-y: visible;
  }
}

/* =========================================================
   Shared-element morph: card → modal
   =========================================================
   Five shared elements with view-transition-name pairs. The
   card and modal each claim them in their own state; JS
   suppresses the card's inline names inside the transition
   callback so only the modal claims them in NEW.
     zb-recipe-frame  — the cream rounded surface
     zb-recipe-image  — the photo inside
     zb-recipe-title  — the recipe title
     zb-recipe-desc   — the recipe short description
     zb-recipe-chip   — the creator chip (avatar + name)
   ========================================================= */
.zb-recipe__card[data-pos="0"] {
  view-transition-name: zb-recipe-frame;
}
.zb-recipe-modal[open] {
  view-transition-name: zb-recipe-frame;
}
.zb-recipe__card[data-pos="0"] .zb-recipe__media {
  view-transition-name: zb-recipe-image;
}
.zb-recipe-modal[open] .zb-recipe-modal__media {
  view-transition-name: zb-recipe-image;
}
.zb-recipe__card[data-pos="0"] .zb-recipe__card-title {
  view-transition-name: zb-recipe-title;
}
.zb-recipe-modal[open] .zb-recipe-modal__title {
  view-transition-name: zb-recipe-title;
}
.zb-recipe__card[data-pos="0"] .zb-recipe__card-desc {
  view-transition-name: zb-recipe-desc;
}
.zb-recipe-modal[open] .zb-recipe-modal__desc {
  view-transition-name: zb-recipe-desc;
}
.zb-recipe__card[data-pos="0"] .zb-recipe__chip {
  view-transition-name: zb-recipe-chip;
}
.zb-recipe-modal[open] .zb-recipe-modal__body .zb-recipe__chip {
  view-transition-name: zb-recipe-chip;
}

/* Sync all named groups so they morph as one fluid motion. */
::view-transition-group(zb-recipe-frame),
::view-transition-group(zb-recipe-image),
::view-transition-group(zb-recipe-title),
::view-transition-group(zb-recipe-desc),
::view-transition-group(zb-recipe-chip),
::view-transition-old(zb-recipe-frame),
::view-transition-new(zb-recipe-frame),
::view-transition-old(zb-recipe-image),
::view-transition-new(zb-recipe-image),
::view-transition-old(zb-recipe-title),
::view-transition-new(zb-recipe-title),
::view-transition-old(zb-recipe-desc),
::view-transition-new(zb-recipe-desc),
::view-transition-old(zb-recipe-chip),
::view-transition-new(zb-recipe-chip) {
  animation-duration: 0.6s;
  animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Root crossfade for the modal frame + body (everything else). */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.5s;
  animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Modal-only elements get their own view-transition-name so they're
   extracted from the modal frame snapshot. The frame morph is then a
   PURE shape morph (no content crossfade), then these elements fade
   in via their NEW-only VT pseudos with staggered delays. */
.zb-recipe-modal[open] .zb-recipe-modal__cta {
  view-transition-name: zb-recipe-cta;
}
.zb-recipe-modal[open] .zb-recipe-modal__step:nth-child(1) {
  view-transition-name: zb-recipe-step-1;
}
.zb-recipe-modal[open] .zb-recipe-modal__step:nth-child(2) {
  view-transition-name: zb-recipe-step-2;
}
.zb-recipe-modal[open] .zb-recipe-modal__step:nth-child(3) {
  view-transition-name: zb-recipe-step-3;
}
.zb-recipe-modal[open] .zb-recipe-modal__close {
  view-transition-name: zb-recipe-close;
}
.zb-recipe-modal[open] .zb-recipe-modal__play {
  view-transition-name: zb-recipe-play;
}

/* Custom delays on the new-only entries so they appear AFTER the
   morph finishes (~0.6s). */
::view-transition-new(zb-recipe-play),
::view-transition-new(zb-recipe-close),
::view-transition-new(zb-recipe-step-1),
::view-transition-new(zb-recipe-step-2),
::view-transition-new(zb-recipe-step-3),
::view-transition-new(zb-recipe-cta) {
  animation-duration: 0.32s;
  animation-timing-function: ease-out;
}
::view-transition-new(zb-recipe-play)   { animation-delay: 0.45s; }
::view-transition-new(zb-recipe-close)  { animation-delay: 0.5s; }
::view-transition-new(zb-recipe-step-1) { animation-delay: 0.7s; }
::view-transition-new(zb-recipe-step-2) { animation-delay: 0.85s; }
::view-transition-new(zb-recipe-step-3) { animation-delay: 1.0s; }
::view-transition-new(zb-recipe-cta)    { animation-delay: 1.15s; }

/* The OLD pseudos for these elements don't exist (no card equivalent). */
::view-transition-old(zb-recipe-play),
::view-transition-old(zb-recipe-close),
::view-transition-old(zb-recipe-step-1),
::view-transition-old(zb-recipe-step-2),
::view-transition-old(zb-recipe-step-3),
::view-transition-old(zb-recipe-cta) {
  display: none;
}
