/* ============================================
 * Text With Image - Two-Column Section Component
 * All values reference CSS variables from variables.css
 * ============================================ */

/* --- Section Layout --- */

.text-with-image {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
  align-items: center;
}

/* --- Image --- */

.text-with-image__image-wrap {
  overflow: hidden;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.text-with-image__image {
  width: 100%;
  height: auto;
  display: block;
}

/* --- Text --- */

.text-with-image__content {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.text-with-image__heading {
  font-family: var(--font-heading);
  font-size: var(--font-size-h2);
  font-weight: var(--weight-normal);
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
}

.text-with-image__text {
  font-size: var(--font-size-body-lg);
  line-height: var(--leading-body);
  color: var(--color-text-muted);
  max-width: 55ch;
}

.text-with-image__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: var(--weight-medium);
  color: var(--color-primary-dark);
  text-decoration: none;
  transition: gap var(--duration-fast) var(--easing-ease);
}

.text-with-image__link:hover {
  gap: var(--space-3);
  color: var(--color-primary);
}

.text-with-image__link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Arrow icon for link */
.text-with-image__link-arrow {
  display: inline-block;
  width: 16px;
  height: 16px;
  transition: transform var(--duration-fast) var(--easing-ease);
}

.text-with-image__link:hover .text-with-image__link-arrow {
  transform: translateX(2px);
}

/* --- Tablet (768px+) --- */

@media (min-width: 768px) {
  .text-with-image {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-12);
  }

  /* Default: image on the right */
  .text-with-image__image-wrap {
    order: 2;
  }

  .text-with-image__content {
    order: 1;
  }

  /* Image left variant */
  .text-with-image[data-image-position="left"] .text-with-image__image-wrap,
  .text-with-image--image-left .text-with-image__image-wrap {
    order: 1;
  }

  .text-with-image[data-image-position="left"] .text-with-image__content,
  .text-with-image--image-left .text-with-image__content {
    order: 2;
  }
}

/* --- Desktop (1024px+) --- */

@media (min-width: 1024px) {
  .text-with-image {
    gap: var(--space-16);
  }
}

/* ============================================
 * Modifier: --portrait
 * Locks the image column to a 3 / 4 portrait aspect ratio
 * so a portrait-native image does not visually dominate
 * the text column at desktop widths.
 * ============================================ */

.text-with-image--portrait .text-with-image__image-wrap {
  aspect-ratio: 3 / 4;
}

.text-with-image--portrait .text-with-image__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

@media (min-width: 768px) {
  /* Cap the portrait column height so it doesn't overpower
     a short text block; the image stays nicely cropped. */
  .text-with-image--portrait .text-with-image__image-wrap {
    max-height: 560px;
  }
}

/* ============================================
 * Modifier: --accent
 * Narrow tall image column (e.g. wind chime) sits beside
 * a wider text column. Image keeps its native silhouette
 * via object-fit: contain so nothing is cropped off.
 * ============================================ */

@media (min-width: 768px) {
  .text-with-image--accent {
    grid-template-columns: 1fr 220px;
    align-items: center;
  }

  .text-with-image--accent .text-with-image__image-wrap {
    max-height: 520px;
    background-color: var(--color-background);
    box-shadow: none;
    border-radius: var(--radius-lg);
  }

  .text-with-image--accent .text-with-image__image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center top;
  }
}

@media (min-width: 1024px) {
  .text-with-image--accent {
    grid-template-columns: 1fr 260px;
  }

  .text-with-image--accent .text-with-image__image-wrap {
    max-height: 600px;
  }
}

/* ============================================
 * Component: .process-accent
 * Standalone wide interstitial section showing a single
 * craft/process image with a short caption beneath. Used
 * on the about page between Story 1 and Story 2.
 * ============================================ */

.process-accent__figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  align-items: center;
}

.process-accent__image-wrap {
  width: 100%;
  max-height: 520px;
  aspect-ratio: 16 / 7;
  overflow: hidden;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.process-accent__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.process-accent__caption {
  font-family: var(--font-body);
  font-size: var(--font-size-small);
  line-height: var(--leading-body);
  color: var(--color-text-muted);
  font-style: italic;
  text-align: center;
  max-width: 48ch;
}

/* On mobile the 16/7 letterbox can feel too thin - relax it */
@media (max-width: 767px) {
  .process-accent__image-wrap {
    aspect-ratio: 4 / 3;
    max-height: none;
  }
}

/* --- Reduced Motion --- */

@media (prefers-reduced-motion: reduce) {
  .text-with-image__link {
    transition: none;
  }

  .text-with-image__link-arrow {
    transition: none;
  }
}
