/* vtw-vendor-credentials.css */
/* VendTheWeb Section Library — vendtheweb.com */
/* Version: 1.0.0 */

/* ── Variable resolution ─────────────────────────────── */
.vtw-vendor-credentials {
  --_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));
  --_gap:          var(--vtw-brand-element-gap, 24px);
  --_radius:       var(--vtw-brand-radius-md, 8px);
  --_max-width:    var(--vtw-brand-container-width, 1280px);
  --_speed:        var(--vtw-brand-speed, 250ms);

  /* Derived tokens — color-mix on theme vars per Section #03 learning */
  --_border:  color-mix(in srgb, var(--_text) 14%, var(--_bg) 86%);
  --_surface: color-mix(in srgb, var(--_text) 5%,  var(--_bg) 95%);
  --_muted:   color-mix(in srgb, var(--_text) 58%, var(--_bg) 42%);

  /* Per-card surface — overridable by inline style from Liquid */
  --_card-surface: var(--_surface);

  /* Merchant-tunable icon sizing (via CSS only for now — consistent across section) */
  --_icon-size: 40px;
  --_icon-wrap: 56px;
}

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

.vtw-vendor-credentials__inner {
  max-width: var(--_max-width);
  margin-inline: auto;
  padding-inline: clamp(24px, 4vw, 48px); /* Rule 6b */
}

.vtw-vendor-credentials[data-width="full"] .vtw-vendor-credentials__inner {
  max-width: none;
  padding-inline: clamp(24px, 6vw, 80px);
}

/* ── Header ─────────────────────────────────────────── */
.vtw-vendor-credentials__header {
  margin-bottom: 32px;
}

.vtw-vendor-credentials__subheading {
  font-family: var(--_body-font);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--_accent);
  font-weight: 500;
  margin: 0 0 12px;
}

.vtw-vendor-credentials__heading {
  font-family: var(--_heading-font);
  font-size: clamp(28px, 3.5vw, 40px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--_text);
  margin: 0;
  max-width: 640px;
}

/* Text alignment (desktop) */
.vtw-vendor-credentials[data-text-align="center"] .vtw-vendor-credentials__heading,
.vtw-vendor-credentials[data-text-align="center"] .vtw-vendor-credentials__subheading {
  text-align: center;
}
.vtw-vendor-credentials[data-text-align="center"] .vtw-vendor-credentials__heading {
  margin-inline: auto; /* max-width child needs auto margin to center — #04 learning */
}
.vtw-vendor-credentials[data-text-align="right"] .vtw-vendor-credentials__heading,
.vtw-vendor-credentials[data-text-align="right"] .vtw-vendor-credentials__subheading {
  text-align: right;
}
.vtw-vendor-credentials[data-text-align="right"] .vtw-vendor-credentials__heading {
  margin-inline-start: auto;
  margin-inline-end: 0;
}

/* ── Stats bar ──────────────────────────────────────── */
.vtw-vendor-credentials__stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 16px 24px;
  margin-bottom: 44px;
  padding: 24px 28px;
  background-color: var(--_surface);
  border: 1px solid var(--_border);
  border-radius: var(--_radius);
}

.vtw-vendor-credentials[data-text-align="center"] .vtw-vendor-credentials__stats {
  justify-content: center;
}
.vtw-vendor-credentials[data-text-align="right"] .vtw-vendor-credentials__stats {
  justify-content: flex-end;
}

.vtw-vendor-credentials__stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  line-height: 1.1;
}

.vtw-vendor-credentials__stat-value {
  font-family: var(--_heading-font);
  font-size: 20px;
  font-weight: 700;
  color: var(--_text);
}

.vtw-vendor-credentials__stat-label {
  font-family: var(--_body-font);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--_muted);
}

.vtw-vendor-credentials__stat-divider {
  font-family: var(--_heading-font);
  font-size: 18px;
  color: var(--_muted);
  opacity: 0.55;
  user-select: none;
  line-height: 1;
  align-self: center;
}

/* ── Credential list ────────────────────────────────── */
.vtw-vendor-credentials__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--_gap);
  align-items: start; /* Explicit per learnings.md #06 v1.6 */
}

/* Grid mode — three-tier responsive (mobile 1 / tablet 2 / desktop merchant-choice)
   Per Section #11 v1.1 learning: middle tier forces 2 cols so layout is visible
   at theme-editor preview widths, not silently stacking. */
.vtw-vendor-credentials[data-layout="grid"] .vtw-vendor-credentials__list {
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .vtw-vendor-credentials[data-layout="grid"] .vtw-vendor-credentials__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 900px) {
  .vtw-vendor-credentials[data-layout="grid"][data-columns="2"] .vtw-vendor-credentials__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .vtw-vendor-credentials[data-layout="grid"][data-columns="3"] .vtw-vendor-credentials__list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .vtw-vendor-credentials[data-layout="grid"][data-columns="4"] .vtw-vendor-credentials__list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* List mode — always 1 column, wider horizontal cards, capped width for readability */
.vtw-vendor-credentials[data-layout="list"] .vtw-vendor-credentials__list {
  grid-template-columns: 1fr;
  gap: 16px;
  max-width: 820px;
}
.vtw-vendor-credentials[data-layout="list"][data-text-align="center"] .vtw-vendor-credentials__list {
  margin-inline: auto;
}
.vtw-vendor-credentials[data-layout="list"][data-text-align="right"] .vtw-vendor-credentials__list {
  margin-inline-start: auto;
  margin-inline-end: 0;
}

/* Item wrapper — keeps featured badge positioning anchored */
.vtw-vendor-credentials__item {
  min-width: 0; /* Rule 6d */
  list-style: none;
  position: relative;
}

/* ── Card ──────────────────────────────────────────── */
.vtw-vendor-credentials .vtw-vendor-credentials__card {
  position: relative; /* Anchor for __link-indicator absolute positioning — reviewer fix */
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 24px;
  background-color: var(--_card-surface);
  border: 1px solid var(--_border);
  border-radius: var(--_radius);
  height: 100%;
  box-sizing: border-box;
  text-decoration: none;
  color: inherit;
  transition:
    transform var(--_speed) ease,
    box-shadow var(--_speed) ease,
    border-color var(--_speed) ease,
    background-color var(--_speed) ease;
}

/* Linked-card hover — double-class specificity per #08 learning (0,2,0 beats host theme 0,1,1) */
.vtw-vendor-credentials .vtw-vendor-credentials__card--link:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -8px color-mix(in srgb, var(--_text) 20%, transparent);
  border-color: color-mix(in srgb, var(--_accent) 42%, var(--_border));
}
.vtw-vendor-credentials .vtw-vendor-credentials__card--link:focus-visible {
  outline: 2px solid var(--_accent);
  outline-offset: 3px;
}

/* List mode card — slightly looser vertical rhythm */
.vtw-vendor-credentials[data-layout="list"] .vtw-vendor-credentials__card {
  padding: 20px 24px;
  align-items: center;
  gap: 20px;
}

/* Featured card — base treatment (all layouts) */
.vtw-vendor-credentials__item[data-featured="true"] .vtw-vendor-credentials__card {
  border-width: 1.5px;
  border-color: color-mix(in srgb, var(--_accent) 38%, var(--_border));
  background-color: color-mix(in srgb, var(--_accent) 8%, var(--_card-surface));
  box-shadow: 0 4px 16px -6px color-mix(in srgb, var(--_accent) 28%, transparent);
}

/* Featured in grid mode — spans 2 columns once the grid is at least 2-col.
   At 640–899px the grid is always 2-col; at 900px+ the grid follows data-columns.
   Span-2 at 2-col grid = full-width row, at 3-col = two-thirds, at 4-col = half.
   All three land the featured card visibly wider than its siblings. */
@media (min-width: 640px) {
  .vtw-vendor-credentials[data-layout="grid"] .vtw-vendor-credentials__item[data-featured="true"] {
    grid-column: span 2;
  }
}

/* Featured icon/padding bump reserved for 3-col and 4-col desktop grids, where the
   featured card has enough horizontal room to justify a larger icon. At 2-col the
   card is already full-width and doesn't need the extra weight. */
@media (min-width: 900px) {
  .vtw-vendor-credentials[data-layout="grid"][data-columns="3"] .vtw-vendor-credentials__item[data-featured="true"] .vtw-vendor-credentials__card,
  .vtw-vendor-credentials[data-layout="grid"][data-columns="4"] .vtw-vendor-credentials__item[data-featured="true"] .vtw-vendor-credentials__card {
    align-items: center;
    padding: 28px;
  }
  .vtw-vendor-credentials[data-layout="grid"][data-columns="3"] .vtw-vendor-credentials__item[data-featured="true"] .vtw-vendor-credentials__icon,
  .vtw-vendor-credentials[data-layout="grid"][data-columns="4"] .vtw-vendor-credentials__item[data-featured="true"] .vtw-vendor-credentials__icon {
    --_icon-wrap: 68px;
    --_icon-size: 44px;
  }
}

/* Featured in list mode — accent-colored left border (4px), sibling-border-width re-asserted
   per Section #09 learning: "Border shorthand cascade — explicit width in combined overrides" */
.vtw-vendor-credentials[data-layout="list"] .vtw-vendor-credentials__item[data-featured="true"] .vtw-vendor-credentials__card {
  border-left-width: 4px;
  border-left-color: var(--_accent);
}

/* ── Icon ──────────────────────────────────────────── */
.vtw-vendor-credentials__icon {
  flex-shrink: 0;
  width: var(--_icon-wrap);
  height: var(--_icon-wrap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden;
  background-color: color-mix(in srgb, var(--_accent) 11%, var(--_card-surface));
  color: var(--_accent);
}

.vtw-vendor-credentials__icon svg {
  width: var(--_icon-size);
  height: var(--_icon-size);
  display: block;
}

/* Image-upload override fills the circle with padding breathing room.
   Rule 6e: width/height 100% on img inside sized wrapper, not width: auto. */
.vtw-vendor-credentials__icon-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  padding: 8px;
  box-sizing: border-box;
}

/* ── Body ──────────────────────────────────────────── */
.vtw-vendor-credentials__body {
  min-width: 0; /* Rule 6d — flex child with long org names */
  flex: 1;
  display: flex;
  flex-direction: column;
}

.vtw-vendor-credentials__title {
  font-family: var(--_heading-font);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--_text);
  margin: 0;
  letter-spacing: -0.005em;
}

.vtw-vendor-credentials__org {
  font-family: var(--_body-font);
  font-size: 14px;
  color: var(--_muted);
  line-height: 1.6;
  margin: 4px 0 0;
}

.vtw-vendor-credentials__year {
  font-family: var(--_body-font);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--_accent);
  margin: 8px 0 0;
}

.vtw-vendor-credentials__description {
  font-family: var(--_body-font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--_text);
  opacity: 0.82;
  margin: 8px 0 0;
}

/* Featured body scales up */
.vtw-vendor-credentials__item[data-featured="true"] .vtw-vendor-credentials__title {
  font-size: 18px;
}
.vtw-vendor-credentials__item[data-featured="true"] .vtw-vendor-credentials__description {
  font-size: 14px;
  opacity: 0.88;
}

/* ── Link indicator (external-arrow) ───────────────── */
.vtw-vendor-credentials__link-indicator {
  position: absolute;
  top: 14px;
  right: 14px;
  color: var(--_muted);
  opacity: 0.5;
  transition:
    color var(--_speed) ease,
    opacity var(--_speed) ease,
    transform var(--_speed) ease;
  pointer-events: none;
}
.vtw-vendor-credentials .vtw-vendor-credentials__card--link:hover .vtw-vendor-credentials__link-indicator {
  color: var(--_accent);
  opacity: 1;
  transform: translate(2px, -2px);
}

/* ── Responsive (mobile) ───────────────────────────── */
/* Inline padding is handled by clamp() above — do NOT override padding-inline here.
   Per css-standards Rule 6b. Per #12 learning: use max-width 767px to avoid 768px gap. */
@media (max-width: 767px) {
  .vtw-vendor-credentials__header {
    margin-bottom: 24px;
  }

  .vtw-vendor-credentials__stats {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 20px;
  }

  /* Hide divider on mobile stack — column layout doesn't need inline separator */
  .vtw-vendor-credentials__stat-divider {
    display: none;
  }

  .vtw-vendor-credentials__stat {
    flex-direction: row;
    align-items: baseline;
    gap: 8px;
  }

  /* Mobile alignment cascade — per #06 learning: flex containers need align-items, not text-align */
  .vtw-vendor-credentials[data-text-align-mobile="left"] .vtw-vendor-credentials__heading {
    text-align: left;
    margin-inline-start: 0;
    margin-inline-end: 0;
  }
  .vtw-vendor-credentials[data-text-align-mobile="center"] .vtw-vendor-credentials__heading,
  .vtw-vendor-credentials[data-text-align-mobile="center"] .vtw-vendor-credentials__subheading {
    text-align: center;
  }
  .vtw-vendor-credentials[data-text-align-mobile="center"] .vtw-vendor-credentials__heading {
    margin-inline: auto;
  }
  .vtw-vendor-credentials[data-text-align-mobile="center"] .vtw-vendor-credentials__stats {
    align-items: center;
  }
  .vtw-vendor-credentials[data-text-align-mobile="right"] .vtw-vendor-credentials__heading,
  .vtw-vendor-credentials[data-text-align-mobile="right"] .vtw-vendor-credentials__subheading {
    text-align: right;
  }
  .vtw-vendor-credentials[data-text-align-mobile="right"] .vtw-vendor-credentials__heading {
    margin-inline-start: auto;
    margin-inline-end: 0;
  }
  .vtw-vendor-credentials[data-text-align-mobile="right"] .vtw-vendor-credentials__stats {
    align-items: flex-end;
  }

  /* Featured in grid mode on mobile — no column span (we're at 1 col anyway) */
  .vtw-vendor-credentials[data-layout="grid"] .vtw-vendor-credentials__item[data-featured="true"] {
    grid-column: auto;
  }

  /* Mobile card — slightly tighter padding */
  .vtw-vendor-credentials .vtw-vendor-credentials__card {
    padding: 20px;
    gap: 16px;
  }

  /* Link indicator — nudge inward so it doesn't crowd the corner on small cards */
  .vtw-vendor-credentials__link-indicator {
    top: 12px;
    right: 12px;
  }
}

/* ── Motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .vtw-vendor-credentials * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
