/* vtw-sourcing-story.css */
/* VendTheWeb Section Library — vendtheweb.com */
/* Version: 1.0.0 */

/* ── Variable resolution ─────────────────────────────── */
.vtw-sourcing-story {
  --_bg:           var(--vtw-section-bg,     var(--vtw-brand-bg,     #faf9f7));
  --_text:         var(--vtw-section-text,   var(--vtw-brand-text,   #1a1a1a));
  --_accent:       var(--vtw-section-accent, var(--vtw-brand-accent, #5c6b3a));
  --_accent-text:  var(--vtw-section-accent-text, var(--vtw-brand-accent-text, #ffffff));
  --_heading-font: var(--vtw-section-heading-font,
                   var(--vtw-brand-heading-font, Georgia, serif));
  --_body-font:    var(--vtw-section-body-font,
                   var(--vtw-brand-body-font, 'Assistant', Georgia, serif));
  --_padding:      var(--vtw-section-padding,
                   var(--vtw-brand-section-padding, 80px));
  --_radius:       var(--vtw-brand-radius-md, 10px);
  --_max-width:    var(--vtw-brand-container-width, 1280px);
  --_speed:        var(--vtw-brand-speed, 250ms);

  /* Derived tokens — surface, border, muted text via color-mix
     so they remain visible on light AND dark host themes. */
  --_card-surface: color-mix(in srgb, var(--_text) 5%,  var(--_bg));
  --_card-border:  color-mix(in srgb, var(--_text) 12%, var(--_bg));
  --_pill-bg:      color-mix(in srgb, var(--_text) 8%,  var(--_bg));
  --_muted-text:   color-mix(in srgb, var(--_text) 62%, var(--_bg));
  --_card-shadow:  0 1px 2px color-mix(in srgb, var(--_text) 6%, transparent),
                   0 12px 28px -12px color-mix(in srgb, var(--_text) 22%, transparent);
}

/* ── Base layout ─────────────────────────────────────── */
.vtw-sourcing-story {
  background-color: var(--_bg);
  color: var(--_text);
  padding-top: var(--_padding);
  padding-bottom: var(--_padding);
  font-family: var(--_body-font);
}

.vtw-sourcing-story__inner {
  max-width: var(--_max-width);
  margin-inline: auto;
  padding-inline: clamp(24px, 4vw, 48px);
}

.vtw-sourcing-story[data-section-width="full"] .vtw-sourcing-story__inner {
  max-width: none;
  padding-inline: clamp(24px, 6vw, 80px);
}

/* ── Header ──────────────────────────────────────────── */
.vtw-sourcing-story__header {
  margin-bottom: clamp(32px, 4vw, 56px);
  text-align: left;
}

.vtw-sourcing-story[data-text-align="center"] .vtw-sourcing-story__header { text-align: center; }
.vtw-sourcing-story[data-text-align="right"]  .vtw-sourcing-story__header { text-align: right; }

.vtw-sourcing-story__subheading {
  font-family: var(--_body-font);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--_accent);
  margin: 0 0 14px;
}

.vtw-sourcing-story__heading {
  font-family: var(--_heading-font);
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 700;
  line-height: 1.15;
  color: var(--_text);
  margin: 0 0 20px;
  max-width: 22ch;
}

.vtw-sourcing-story[data-text-align="center"] .vtw-sourcing-story__heading { margin-inline: auto; }
.vtw-sourcing-story[data-text-align="right"]  .vtw-sourcing-story__heading { margin-inline: auto 0; }

.vtw-sourcing-story__body {
  font-size: 16px;
  line-height: 1.65;
  color: var(--_muted-text);
  max-width: 60ch;
  margin: 0;
}

.vtw-sourcing-story[data-text-align="center"] .vtw-sourcing-story__body { margin-inline: auto; }
.vtw-sourcing-story[data-text-align="right"]  .vtw-sourcing-story__body { margin-inline: auto 0; }

.vtw-sourcing-story__body p { margin: 0 0 12px; color: inherit; }
.vtw-sourcing-story__body p:last-child { margin-bottom: 0; }

/* ── List ────────────────────────────────────────────── */
.vtw-sourcing-story__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--_card-gap);
  grid-template-columns: 1fr;
}

.vtw-sourcing-story__item {
  min-width: 0; /* Rule 6d — let grid cells shrink below max-width children */
}

/* ── Card-grid layout ────────────────────────────────── */
/* Two-column threshold raised to 720px (was 640px). Below 720px the cards become
   too narrow once the 4:3 photo dominates and content compresses. The 640–719px
   range stays single-column for readability. */
@media (min-width: 720px) {
  .vtw-sourcing-story[data-layout="card-grid"] .vtw-sourcing-story__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .vtw-sourcing-story[data-layout="card-grid"][data-cols-desktop="3"] .vtw-sourcing-story__list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ── Card surface ────────────────────────────────────── */
.vtw-sourcing-story__card {
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: var(--_radius);
  background: transparent;
  overflow: hidden;
  transition: transform var(--_speed) ease, box-shadow var(--_speed) ease, background-color var(--_speed) ease;
}

.vtw-sourcing-story[data-card-surface="warm-tint"] .vtw-sourcing-story__card {
  background: var(--_card-surface);
}

.vtw-sourcing-story[data-card-surface="shadow"] .vtw-sourcing-story__card {
  background: var(--_bg);
  box-shadow: var(--_card-shadow);
}

/* Slight lift on hover when there's a link inside the card */
.vtw-sourcing-story__card:has(.vtw-sourcing-story__link:hover) {
  transform: translateY(-2px);
}

/* ── Media (photo) ───────────────────────────────────── */
.vtw-sourcing-story__media {
  position: relative;
  width: 100%;
  aspect-ratio: var(--_aspect, 4 / 3);
  background: var(--_card-surface);
  overflow: hidden;
}

/* Rounded-square is the base shape — same radius as the card.
   In transparent / shadow card-surfaces, the photo sits inside the card flush
   with the top corners; we round only the top corners so the photo "caps" the card. */
.vtw-sourcing-story[data-card-surface="warm-tint"] .vtw-sourcing-story__media,
.vtw-sourcing-story[data-card-surface="shadow"]    .vtw-sourcing-story__media {
  border-radius: 0;
}

/* Transparent surface: photo stands alone with full radius */
.vtw-sourcing-story[data-card-surface="transparent"] .vtw-sourcing-story__media {
  border-radius: var(--_radius);
}

/* Circle shape — overrides aspect-ratio + radius, photo becomes a portrait disk */
.vtw-sourcing-story[data-image-shape="circle"] .vtw-sourcing-story__media {
  aspect-ratio: 1 / 1;
  width: clamp(180px, 28vw, 240px);
  margin: 24px auto 0;
  border-radius: 50%;
  background: transparent;
}

.vtw-sourcing-story[data-image-shape="circle"][data-card-surface="transparent"] .vtw-sourcing-story__media {
  margin-top: 0;
}

.vtw-sourcing-story__photo,
.vtw-sourcing-story__photo-placeholder {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.vtw-sourcing-story__photo-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--_pill-bg);
  color: var(--_muted-text);
}

.vtw-sourcing-story__placeholder-svg {
  width: 56px;
  height: 56px;
  opacity: 0.5;
}

/* ── Content (right of / below photo) ────────────────── */
.vtw-sourcing-story__content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px;
  flex: 1;
}

.vtw-sourcing-story[data-card-surface="transparent"] .vtw-sourcing-story__content {
  padding: 20px 4px 4px;
}

/* Circle shape centers the content under the portrait disk */
.vtw-sourcing-story[data-image-shape="circle"] .vtw-sourcing-story__content {
  text-align: center;
  align-items: center;
}

.vtw-sourcing-story__location {
  font-family: var(--_body-font);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--_accent);
  margin: 0 0 2px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.vtw-sourcing-story__pin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.vtw-sourcing-story__name {
  font-family: var(--_heading-font);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--_text);
  margin: 0;
}

.vtw-sourcing-story__relationship {
  font-family: var(--_body-font);
  font-size: 15px;
  font-style: italic;
  color: var(--_muted-text);
  margin: 0;
  line-height: 1.5;
}

.vtw-sourcing-story__practices {
  list-style: none;
  margin: 8px 0 4px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.vtw-sourcing-story[data-image-shape="circle"] .vtw-sourcing-story__practices {
  justify-content: center;
}

.vtw-sourcing-story__practice {
  font-family: var(--_body-font);
  font-size: 12px;
  font-weight: 500;
  color: var(--_text);
  background: var(--_pill-bg);
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

/* On warm-tint card surface, the pill background needs more contrast or it disappears
   into the card — bump opacity by deriving from a stronger blend. */
.vtw-sourcing-story[data-card-surface="warm-tint"] .vtw-sourcing-story__practice {
  background: color-mix(in srgb, var(--_text) 11%, var(--_bg));
}

.vtw-sourcing-story__story {
  font-family: var(--_body-font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--_text);
  margin: 8px 0 0;
}

.vtw-sourcing-story__story p { margin: 0 0 10px; color: inherit; }
.vtw-sourcing-story__story p:last-child { margin-bottom: 0; }

.vtw-sourcing-story__link {
  font-family: var(--_body-font);
  font-size: 14px;
  font-weight: 600;
  color: var(--_accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: auto;
  padding-top: 12px;
  align-self: flex-start;
  transition: gap var(--_speed) ease;
}

.vtw-sourcing-story[data-image-shape="circle"] .vtw-sourcing-story__link {
  align-self: center;
}

.vtw-sourcing-story__link:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.vtw-sourcing-story__link-arrow {
  display: inline-flex;
  transform: translateX(0);
  transition: transform var(--_speed) ease;
}

.vtw-sourcing-story[data-show-arrow="true"] .vtw-sourcing-story__link:hover .vtw-sourcing-story__link-arrow {
  transform: translateX(4px);
}

/* Focus ring */
.vtw-sourcing-story__link:focus-visible {
  outline: 2px solid var(--_accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ── Feature-list layout (alternating) ───────────────── */
@media (min-width: 769px) {
  .vtw-sourcing-story[data-layout="feature-list"] .vtw-sourcing-story__card {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: clamp(24px, 4vw, 56px);
    align-items: center;
    background: transparent;
    box-shadow: none;
  }

  .vtw-sourcing-story[data-layout="feature-list"] .vtw-sourcing-story__media {
    aspect-ratio: var(--_aspect, 4 / 3);
    border-radius: var(--_radius);
    overflow: hidden;
  }

  /* Alternate image side every other supplier */
  .vtw-sourcing-story[data-layout="feature-list"] .vtw-sourcing-story__item:nth-child(even) .vtw-sourcing-story__card {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  }

  .vtw-sourcing-story[data-layout="feature-list"] .vtw-sourcing-story__item:nth-child(even) .vtw-sourcing-story__media {
    order: 2;
  }

  .vtw-sourcing-story[data-layout="feature-list"] .vtw-sourcing-story__content {
    padding: 0;
    gap: 10px;
  }

  /* Feature-list with circle shape — center photo, content sits beside */
  .vtw-sourcing-story[data-layout="feature-list"][data-image-shape="circle"] .vtw-sourcing-story__media {
    aspect-ratio: 1 / 1;
    width: clamp(220px, 28vw, 320px);
    margin: 0;
    border-radius: 50%;
    justify-self: center;
  }

  /* Feature-list typography — story gets more room, name a touch larger */
  .vtw-sourcing-story[data-layout="feature-list"] .vtw-sourcing-story__name {
    font-size: 24px;
    line-height: 1.2;
  }

  .vtw-sourcing-story[data-layout="feature-list"] .vtw-sourcing-story__story {
    font-size: 16px;
    max-width: 60ch;
  }

  /* Feature-list rows need larger vertical breathing room */
  .vtw-sourcing-story[data-layout="feature-list"] .vtw-sourcing-story__list {
    gap: clamp(48px, 6vw, 80px);
  }
}

/* ── Mobile responsive ───────────────────────────────── */
@media (max-width: 768px) {
  /* All layouts collapse to single column on mobile */
  .vtw-sourcing-story__card {
    /* Keep the warm-tint / shadow card surfaces in mobile too */
  }

  /* Feature-list mobile: photo on top, content below — same as card-grid baseline */
  .vtw-sourcing-story[data-layout="feature-list"] .vtw-sourcing-story__media {
    aspect-ratio: var(--_aspect, 4 / 3);
  }

  .vtw-sourcing-story[data-layout="feature-list"][data-image-shape="circle"] .vtw-sourcing-story__media {
    aspect-ratio: 1 / 1;
    width: clamp(160px, 40vw, 220px);
    margin: 24px auto 0;
    border-radius: 50%;
  }

  /* Mobile alignment cascade — header text only */
  .vtw-sourcing-story[data-text-align-mobile="left"]   .vtw-sourcing-story__header { text-align: left; }
  .vtw-sourcing-story[data-text-align-mobile="center"] .vtw-sourcing-story__header { text-align: center; }
  .vtw-sourcing-story[data-text-align-mobile="right"]  .vtw-sourcing-story__header { text-align: right; }

  .vtw-sourcing-story[data-text-align-mobile="left"]   .vtw-sourcing-story__heading { margin-inline: 0 auto; }
  .vtw-sourcing-story[data-text-align-mobile="center"] .vtw-sourcing-story__heading { margin-inline: auto; }
  .vtw-sourcing-story[data-text-align-mobile="right"]  .vtw-sourcing-story__heading { margin-inline: auto 0; }

  .vtw-sourcing-story[data-text-align-mobile="left"]   .vtw-sourcing-story__body { margin-inline: 0 auto; }
  .vtw-sourcing-story[data-text-align-mobile="center"] .vtw-sourcing-story__body { margin-inline: auto; }
  .vtw-sourcing-story[data-text-align-mobile="right"]  .vtw-sourcing-story__body { margin-inline: auto 0; }
}

/* ── Scroll-entry reveal (no-JS-safe) ────────────────── */
/* Default state: visible. JS adds `.vtw-animate-ready` synchronously on init,
   which is what gates the hidden state. Ensures no-JS / failed-script
   visitors see content rather than an invisible void. */
.vtw-sourcing-story[data-animate="true"].vtw-animate-ready .vtw-sourcing-story__header,
.vtw-sourcing-story[data-animate="true"].vtw-animate-ready .vtw-sourcing-story__item {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 600ms cubic-bezier(0.25, 0.1, 0.25, 1),
              transform 600ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.vtw-sourcing-story[data-animate="true"].vtw-animate-ready.vtw-is-visible .vtw-sourcing-story__header,
.vtw-sourcing-story[data-animate="true"].vtw-animate-ready.vtw-is-visible .vtw-sourcing-story__item {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger the suppliers */
.vtw-sourcing-story[data-animate="true"].vtw-animate-ready.vtw-is-visible .vtw-sourcing-story__header { transition-delay: 0ms; }
.vtw-sourcing-story[data-animate="true"].vtw-animate-ready.vtw-is-visible .vtw-sourcing-story__item:nth-child(1) { transition-delay: 100ms; }
.vtw-sourcing-story[data-animate="true"].vtw-animate-ready.vtw-is-visible .vtw-sourcing-story__item:nth-child(2) { transition-delay: 180ms; }
.vtw-sourcing-story[data-animate="true"].vtw-animate-ready.vtw-is-visible .vtw-sourcing-story__item:nth-child(3) { transition-delay: 260ms; }
.vtw-sourcing-story[data-animate="true"].vtw-animate-ready.vtw-is-visible .vtw-sourcing-story__item:nth-child(4) { transition-delay: 340ms; }
.vtw-sourcing-story[data-animate="true"].vtw-animate-ready.vtw-is-visible .vtw-sourcing-story__item:nth-child(5) { transition-delay: 420ms; }
.vtw-sourcing-story[data-animate="true"].vtw-animate-ready.vtw-is-visible .vtw-sourcing-story__item:nth-child(6) { transition-delay: 500ms; }
.vtw-sourcing-story[data-animate="true"].vtw-animate-ready.vtw-is-visible .vtw-sourcing-story__item:nth-child(7) { transition-delay: 580ms; }
.vtw-sourcing-story[data-animate="true"].vtw-animate-ready.vtw-is-visible .vtw-sourcing-story__item:nth-child(8) { transition-delay: 660ms; }

/* ── Reduced motion ──────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  /* Render content visible immediately even with animation enabled — JS still
     runs at normal cadence to avoid the Brave fingerprinting issue. */
  .vtw-sourcing-story[data-animate="true"].vtw-animate-ready .vtw-sourcing-story__header,
  .vtw-sourcing-story[data-animate="true"].vtw-animate-ready .vtw-sourcing-story__item {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .vtw-sourcing-story * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
