/* vtw-image-with-text.css */
/* VendTheWeb Section Library — vendtheweb.com */
/* Version: 1.0.0 */

/* ── Variable resolution ─────────────────────────────── */
.vtw-image-with-text {
  --_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));
  --_surface:        var(--vtw-section-surface,     var(--vtw-brand-surface,     #f0ede8));
  --_border:         var(--vtw-section-border,      var(--vtw-brand-border,      #e8e3dc));
  --_heading-font:   var(--vtw-section-heading-font,
                     var(--vtw-brand-heading-font, Georgia, serif));
  --_heading-weight: var(--vtw-section-heading-weight, var(--vtw-brand-heading-weight, 700));
  --_body-font:      var(--vtw-section-body-font,
                     var(--vtw-brand-body-font, 'Assistant', Georgia, serif));
  --_radius:         var(--vtw-brand-radius-md, 8px);
  --_radius-lg:      var(--vtw-brand-radius-lg, 12px);
  --_max-width:      var(--vtw-brand-container-width, 1280px);
  --_speed:          var(--vtw-brand-speed, 250ms);
  --_text-muted:     var(--vtw-section-text-muted, var(--vtw-brand-text-muted, color-mix(in srgb, var(--_text) 70%, var(--_bg))));
  --_focus:          var(--vtw-section-focus,      var(--vtw-brand-focus, var(--_accent)));
  --_focus-width:    var(--vtw-brand-focus-width, 2px);
  --_heading-scale:  var(--vtw-brand-heading-scale, 1);
  --_body-size:      var(--vtw-brand-body-size, 16px);
  --_body-line-height: var(--vtw-brand-body-line-height, 1.65);
  --_button-radius:  var(--vtw-brand-button-radius, var(--_radius));
  --_button-border-width: var(--vtw-brand-button-border-width, 1px);
  --_media-radius:   var(--vtw-brand-media-radius, var(--_radius));
  --_shadow:         var(--vtw-brand-shadow, 0 8px 24px rgb(26 26 26 / 0.08));

  /* Local layout tokens */
  --_gutter:      clamp(24px, 4vw, 48px);   /* css-standards Rule 6b */
  --_col-gap:     clamp(32px, 6vw, 96px);
  --_overlap:     clamp(40px, 5vw, 72px);
  --_media-max-h: 85vh;
  --_scrim:       rgb(26 26 26 / 0.6); /* video toggle sits on footage, not on a brand surface */
  --_scrim-hover: rgb(26 26 26 / 0.8);
  --_on-scrim:    #ffffff;
  --_frame-bg:    var(--_surface);
  --_panel-bg:    var(--_surface);
  /* Small accent text (eyebrow, links, outline label) is pulled 18% toward the
     text color: mid-tone brand accents (terracotta, olive) sit near 4:1 on the
     warm surface tones; this keeps them at 4.5:1+ on light and dark palettes. */
  --_accent-ink:  color-mix(in srgb, var(--_accent) 82%, var(--_text));

  /* Alignment tokens — resolved per breakpoint below */
  --_align:   start;
  --_justify: flex-start;
  --_panel-ms: 0;
  --_panel-me: auto;
}

/* On the warm surface band, frame and panel flip to the page tone so they still read */
.vtw-image-with-text[data-background="surface"] {
  --_frame-bg: var(--_bg);
  --_panel-bg: var(--_bg);
}

/* ── Base layout ─────────────────────────────────────── */
.vtw-image-with-text {
  background-color: var(--_bg);
  color: var(--_text);
  font-family: var(--_body-font);
  padding-top: var(--_pad-y-start, 64px);
  padding-bottom: var(--_pad-y-end, 64px);
}

.vtw-image-with-text[data-background="surface"] {
  background-color: var(--_surface);
}

.vtw-image-with-text__inner {
  box-sizing: border-box;
  max-width: var(--_max-width);
  margin-inline: auto;
  padding-inline: var(--_gutter);
}

/* Full width: the image runs to the screen edge, copy stays on the page grid.
   --_edge is the distance from the screen edge to where contained content would
   start, measured against the section width (cqw) so scrollbars never skew it. */
.vtw-image-with-text[data-width="full"] {
  container-type: inline-size;
}

.vtw-image-with-text[data-width="full"] .vtw-image-with-text__inner {
  --_edge: max(var(--_gutter), calc((100cqw - var(--_max-width)) / 2 + var(--_gutter)));
  max-width: none;
  padding-inline: 0;
}

.vtw-image-with-text__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: 32px;
}

.vtw-image-with-text__media,
.vtw-image-with-text__content {
  min-width: 0; /* css-standards Rule 6d */
}

.vtw-image-with-text[data-mobile-order="content-first"] .vtw-image-with-text__content {
  order: -1;
}

/* ── Media ───────────────────────────────────────────── */
.vtw-image-with-text__media {
  position: relative;
  margin: 0;
}

.vtw-image-with-text__frame {
  position: relative;
  display: block;
  box-sizing: border-box;
  width: 100%; /* definite width: with aspect-ratio + max-height the height clamps, not the width */
  overflow: hidden;
  max-height: var(--_media-max-h);
  border-radius: var(--_media-radius);
  background-color: var(--_frame-bg);
  color: inherit;
}

.vtw-image-with-text[data-ratio="portrait"]  .vtw-image-with-text__frame { aspect-ratio: 4 / 5; }
.vtw-image-with-text[data-ratio="square"]    .vtw-image-with-text__frame { aspect-ratio: 1 / 1; }
.vtw-image-with-text[data-ratio="landscape"] .vtw-image-with-text__frame { aspect-ratio: 3 / 2; }

.vtw-image-with-text__img {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 600ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.vtw-image-with-text[data-ratio="adapt"] .vtw-image-with-text__img {
  height: auto;
  max-height: var(--_media-max-h);
}

/* Contain: whole packshot on the warm tone, with breathing room inside the frame */
.vtw-image-with-text[data-fit="contain"]:not([data-ratio="adapt"]) .vtw-image-with-text__img {
  object-fit: contain;
  padding: clamp(16px, 6%, 48px);
}

.vtw-image-with-text__placeholder {
  fill: color-mix(in srgb, var(--_text) 28%, var(--_frame-bg));
}

.vtw-image-with-text__frame--link:hover .vtw-image-with-text__img {
  transform: scale(1.03);
}

.vtw-image-with-text__caption {
  margin-top: 12px;
  font-size: 14px;
  font-style: italic;
  line-height: 1.5;
  color: color-mix(in srgb, var(--_text) 30%, var(--_text-muted));
}

/* Video pause/play — WCAG 2.2.2 for looping motion. JS unhides it. */
.vtw-image-with-text__video-toggle {
  position: absolute;
  inset-block-start: 12px;
  inset-inline-end: 12px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background-color: var(--_scrim);
  color: var(--_on-scrim);
  cursor: pointer;
  transition: background-color var(--_speed) ease;
}

.vtw-image-with-text__video-toggle[hidden] {
  display: none;
}

.vtw-image-with-text__video-toggle:hover {
  background-color: var(--_scrim-hover);
}

.vtw-image-with-text__video-toggle svg {
  width: 18px;
  height: 18px;
}

.vtw-image-with-text__video-toggle .vtw-image-with-text__icon-play,
.vtw-image-with-text__video-toggle[aria-pressed="true"] .vtw-image-with-text__icon-pause {
  display: none;
}

.vtw-image-with-text__video-toggle[aria-pressed="true"] .vtw-image-with-text__icon-play {
  display: block;
}

/* ── Copy ────────────────────────────────────────────── */
.vtw-image-with-text__panel {
  box-sizing: border-box;
  max-width: 560px;
  margin-inline-start: var(--_panel-ms);
  margin-inline-end: var(--_panel-me);
  text-align: var(--_align);
}

.vtw-image-with-text__eyebrow {
  margin: 0 0 16px;
  font-family: var(--_body-font);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--_accent-ink);
}

.vtw-image-with-text__heading {
  margin: 0;
  font-family: var(--_heading-font);
  font-weight: var(--_heading-weight);
  font-size: calc(clamp(26px, 4vw, 44px) * var(--_heading-scale));
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--_text);
  text-wrap: balance;
  max-width: 34ch;
  margin-inline: var(--_panel-ms) var(--_panel-me);
}

.vtw-image-with-text[data-heading-size="compact"] .vtw-image-with-text__heading {
  font-size: calc(clamp(22px, 2.8vw, 32px) * var(--_heading-scale));
  line-height: 1.2;
}

.vtw-image-with-text[data-heading-size="display"] .vtw-image-with-text__heading {
  font-size: calc(clamp(32px, 5vw, 56px) * var(--_heading-scale));
  line-height: 1.08;
}

.vtw-image-with-text__heading em {
  font-style: italic;
}

.vtw-image-with-text__body {
  max-width: 56ch;
  margin-top: 20px;
  margin-inline: var(--_panel-ms) var(--_panel-me);
  font-size: var(--_body-size);
  line-height: var(--_body-line-height);
  color: var(--_text);
}

.vtw-image-with-text__body p {
  margin: 0 0 12px;
  color: inherit;
}

.vtw-image-with-text__body > *:last-child {
  margin-bottom: 0;
}

.vtw-image-with-text__body a {
  color: var(--_accent-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.vtw-image-with-text__details {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  width: fit-content;
  max-width: 100%;
  margin-block: 24px 0;
  margin-inline: var(--_panel-ms) var(--_panel-me);
  padding: 0;
  list-style: none;
}

.vtw-image-with-text__detail {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 15px;
  line-height: 1.5;
  text-align: start;
}

.vtw-image-with-text__detail-icon {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  color: var(--_accent);
}

/* ── Actions ─────────────────────────────────────────── */
.vtw-image-with-text__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: var(--_justify);
  gap: 16px 32px;
  margin-top: 32px;
}

.vtw-image-with-text__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 48px;
  padding: 14px 28px;
  border: var(--_button-border-width) solid var(--_accent);
  border-radius: var(--_button-radius);
  font-family: var(--_body-font);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform var(--_speed) ease, filter var(--_speed) ease, background-color var(--_speed) ease;
}

.vtw-image-with-text__cta--primary {
  background-color: var(--_accent);
  color: var(--_accent-text);
}

.vtw-image-with-text__cta--primary:hover {
  filter: brightness(0.92);
  transform: translateY(-1px);
}

.vtw-image-with-text__cta--secondary {
  border-width: max(1.5px, var(--_button-border-width));
  border-color: var(--_accent-ink);
  background-color: transparent;
  color: var(--_accent-ink);
}

.vtw-image-with-text__cta--secondary:hover {
  background-color: color-mix(in srgb, var(--_accent) 8%, transparent);
}

.vtw-image-with-text__link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-block: 8px;
  font-family: var(--_body-font);
  font-size: 15px;
  font-weight: 600;
  color: var(--_accent-ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.vtw-image-with-text__link-arrow {
  flex: none;
  width: 16px;
  height: 16px;
  transition: transform var(--_speed) ease;
}

.vtw-image-with-text__link:hover .vtw-image-with-text__link-arrow {
  transform: translateX(4px);
}

.vtw-image-with-text__cta:focus-visible,
.vtw-image-with-text__link:focus-visible,
.vtw-image-with-text__video-toggle:focus-visible {
  outline: var(--_focus-width) solid var(--_focus);
  outline-offset: 3px;
}

/* ── Overlap panel ───────────────────────────────────── */
.vtw-image-with-text[data-layout="overlap"] .vtw-image-with-text__content {
  position: relative;
  z-index: 1;
}

.vtw-image-with-text[data-layout="overlap"] .vtw-image-with-text__panel {
  max-width: 600px;
  padding: clamp(28px, 4vw, 56px);
  border-radius: var(--_radius-lg);
  background-color: var(--_panel-bg);
  box-shadow: var(--_shadow);
}

/* ── Desktop (769px+) ────────────────────────────────── */
@media (min-width: 769px) {
  .vtw-image-with-text {
    --_media-fr: 1fr;
    --_copy-fr: 1fr;
  }

  .vtw-image-with-text[data-image-width="narrow"] { --_media-fr: 1fr; --_copy-fr: 2fr; }
  .vtw-image-with-text[data-image-width="wide"]   { --_media-fr: 7fr; --_copy-fr: 5fr; }

  .vtw-image-with-text[data-text-align="center"] {
    --_align: center;
    --_justify: center;
    --_panel-ms: auto;
    --_panel-me: auto;
  }

  .vtw-image-with-text[data-text-align="right"] {
    --_align: end;
    --_justify: flex-end;
    --_panel-ms: auto;
    --_panel-me: 0;
  }

  .vtw-image-with-text__grid {
    grid-template-columns: minmax(0, var(--_media-fr)) minmax(0, var(--_copy-fr));
    grid-template-areas: "media content";
    column-gap: var(--_col-gap);
    align-items: center;
  }

  .vtw-image-with-text[data-image-position="right"] .vtw-image-with-text__grid {
    grid-template-columns: minmax(0, var(--_copy-fr)) minmax(0, var(--_media-fr));
    grid-template-areas: "content media";
  }

  .vtw-image-with-text[data-valign="top"]    .vtw-image-with-text__grid { align-items: start; }
  .vtw-image-with-text[data-valign="bottom"] .vtw-image-with-text__grid { align-items: end; }

  .vtw-image-with-text__media   { grid-area: media; }
  .vtw-image-with-text__content { grid-area: content; }

  .vtw-image-with-text[data-has-media="false"] .vtw-image-with-text__grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "content";
  }

  /* Copy alone: center the block, keep its text alignment */
  .vtw-image-with-text[data-has-media="false"] .vtw-image-with-text__panel {
    margin-inline: auto;
  }

  /* Full width: square off the image corners that meet the screen edge and
     hold the copy on the page grid. */
  .vtw-image-with-text[data-width="full"][data-image-position="left"] .vtw-image-with-text__frame {
    border-start-start-radius: 0;
    border-end-start-radius: 0;
  }

  .vtw-image-with-text[data-width="full"][data-image-position="right"] .vtw-image-with-text__frame {
    border-start-end-radius: 0;
    border-end-end-radius: 0;
  }

  /* Padding 0 + full width: the image meets the band edge, so square those corners too */
  .vtw-image-with-text[data-width="full"][data-flush-top] .vtw-image-with-text__frame {
    border-start-start-radius: 0;
    border-start-end-radius: 0;
  }

  .vtw-image-with-text[data-width="full"][data-flush-bottom] .vtw-image-with-text__frame {
    border-end-start-radius: 0;
    border-end-end-radius: 0;
  }

  /* Copy keeps its own breathing room when the image bleeds and padding is 0 */
  .vtw-image-with-text[data-width="full"] .vtw-image-with-text__content {
    padding-block: clamp(24px, 4vw, 48px);
  }

  .vtw-image-with-text[data-width="full"][data-image-position="left"] .vtw-image-with-text__content {
    padding-inline-end: var(--_edge);
  }

  .vtw-image-with-text[data-width="full"][data-image-position="right"] .vtw-image-with-text__content {
    padding-inline-start: var(--_edge);
  }

  .vtw-image-with-text[data-width="full"][data-image-position="left"] .vtw-image-with-text__caption {
    padding-inline-start: var(--_gutter);
  }

  .vtw-image-with-text[data-width="full"][data-image-position="right"] .vtw-image-with-text__caption {
    padding-inline-end: var(--_gutter);
    text-align: end;
  }

  /* Overlap: the panel runs over the image's inner edge and always hugs it,
     whatever the text alignment inside the panel. */
  .vtw-image-with-text[data-layout="overlap"] .vtw-image-with-text__grid {
    column-gap: 0;
  }

  .vtw-image-with-text[data-layout="overlap"][data-image-position="left"] .vtw-image-with-text__content {
    margin-inline-start: calc(-1 * var(--_overlap));
  }

  .vtw-image-with-text[data-layout="overlap"][data-image-position="right"] .vtw-image-with-text__content {
    margin-inline-end: calc(-1 * var(--_overlap));
  }

  .vtw-image-with-text[data-layout="overlap"][data-image-position="left"] .vtw-image-with-text__panel {
    margin-inline-start: 0;
    margin-inline-end: auto;
  }

  .vtw-image-with-text[data-layout="overlap"][data-image-position="right"] .vtw-image-with-text__panel {
    margin-inline-start: auto;
    margin-inline-end: 0;
  }
}

/* ── Mobile (768px and below) ────────────────────────── */
@media (max-width: 768px) {
  .vtw-image-with-text[data-text-align-mobile="center"] {
    --_align: center;
    --_justify: center;
    --_panel-ms: auto;
    --_panel-me: auto;
  }

  .vtw-image-with-text[data-text-align-mobile="right"] {
    --_align: end;
    --_justify: flex-end;
    --_panel-ms: auto;
    --_panel-me: 0;
  }

  .vtw-image-with-text {
    --_media-max-h: 70vh; /* keeps the heading near the fold on stacked tablets */
  }

  .vtw-image-with-text__panel,
  .vtw-image-with-text[data-layout="overlap"] .vtw-image-with-text__panel {
    max-width: none;
  }

  .vtw-image-with-text[data-layout="overlap"][data-mobile-order="content-first"] .vtw-image-with-text__panel,
  .vtw-image-with-text[data-layout="overlap"]:has(.vtw-image-with-text__caption) .vtw-image-with-text__panel {
    box-shadow: none;
  }

  /* Full width on phones: image edge to edge, copy and caption keep the gutter */
  .vtw-image-with-text[data-width="full"] .vtw-image-with-text__frame {
    border-radius: 0;
  }

  .vtw-image-with-text[data-width="full"] .vtw-image-with-text__content,
  .vtw-image-with-text[data-width="full"] .vtw-image-with-text__caption {
    padding-inline: var(--_gutter);
  }

  .vtw-image-with-text[data-width="full"] .vtw-image-with-text__grid {
    row-gap: 8px;
  }

  .vtw-image-with-text[data-width="full"] .vtw-image-with-text__content {
    padding-block: 24px;
  }

  /* Overlap on phones: the panel rides up over the bottom of the image.
     Skipped when copy comes first or a caption sits under the image. */
  .vtw-image-with-text[data-layout="overlap"][data-mobile-order="image-first"]:not(:has(.vtw-image-with-text__caption)) .vtw-image-with-text__grid {
    row-gap: 0;
  }

  .vtw-image-with-text[data-layout="overlap"][data-mobile-order="image-first"]:not(:has(.vtw-image-with-text__caption)) .vtw-image-with-text__content {
    margin-top: -48px;
    padding-inline: 16px;
  }

  .vtw-image-with-text[data-layout="overlap"][data-width="full"][data-mobile-order="image-first"]:not(:has(.vtw-image-with-text__caption)) .vtw-image-with-text__content {
    padding-inline: var(--_gutter);
    padding-top: 0;
  }
}

@media (max-width: 480px) {
  .vtw-image-with-text__cta {
    flex: 1 1 100%;
  }
}

/* ── Motion ──────────────────────────────────────────── */
/* No-JS safe: the hidden state is gated on .vtw-animate-ready, which only the
   section JS adds (learnings.md 2026-04, #04). */
.vtw-image-with-text[data-animate="true"].vtw-animate-ready .vtw-image-with-text__media,
.vtw-image-with-text[data-animate="true"].vtw-animate-ready .vtw-image-with-text__panel > * {
  opacity: 0;
  transform: translateY(20px);
}

.vtw-image-with-text[data-animate="true"].vtw-animate-ready.vtw-is-visible .vtw-image-with-text__media,
.vtw-image-with-text[data-animate="true"].vtw-animate-ready.vtw-is-visible .vtw-image-with-text__panel > * {
  animation: vtw-image-with-text-rise 600ms cubic-bezier(0.25, 0.1, 0.25, 1) var(--_delay, 0ms) forwards;
}

/* Stagger via a custom property so the animation shorthand above doesn't reset it */
.vtw-image-with-text__panel > *:nth-child(1)   { --_delay: 80ms; }
.vtw-image-with-text__panel > *:nth-child(2)   { --_delay: 160ms; }
.vtw-image-with-text__panel > *:nth-child(3)   { --_delay: 240ms; }
.vtw-image-with-text__panel > *:nth-child(4)   { --_delay: 320ms; }
.vtw-image-with-text__panel > *:nth-child(n+5) { --_delay: 400ms; }

@keyframes vtw-image-with-text-rise {
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .vtw-image-with-text * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  .vtw-image-with-text[data-animate="true"].vtw-animate-ready .vtw-image-with-text__media,
  .vtw-image-with-text[data-animate="true"].vtw-animate-ready .vtw-image-with-text__panel > * {
    opacity: 1;
    transform: none;
    animation: none;
  }
}
