/**
 * Testimonial Block Styles
 *
 * Two-column grid layout with content and portrait photo.
 * Stacks vertically on mobile, side-by-side at 600px+.
 *
 * CSS custom properties on .testimonial define layout and color defaults.
 * Variant classes (align-right, full-bleed, bg-*) only mutate variables.
 *
 * SVG slots: this block has two image slots that may hold SVGs (logo,
 * media). Each slot imposes explicit dimensions in this file because
 * SVGs without intrinsic width/height/viewBox collapse to zero inside
 * flex and grid containers. Slot sizing is kept local to the slot —
 * intrinsic SVG dimensions and generic img[src*=".svg"] rules elsewhere
 * are not assumed to be present or correct.
 */

/* ==========================================================================
   Base Grid Layout
   ========================================================================== */

.testimonial {
  /* Layout variables */
  --testimonial-grid-columns: 1fr;
  --testimonial-grid-areas: "media" "content";

  /* Media variables - defaults for full-bleed portrait photos */
  --testimonial-media-padding: 0;
  --testimonial-media-align: flex-start;
  --testimonial-media-object-fit: cover;
  --testimonial-media-object-position: center top;

  /* Text color variables - defaults for light background */
  --testimonial-quote-color: var(--digicert-neutral-900);
  --testimonial-name-color: var(--digicert-blue);
  --testimonial-title-color: var(--digicert-neutral-900);

  display: grid;
  grid-template-columns: var(--testimonial-grid-columns);
  grid-template-areas: var(--testimonial-grid-areas);
  background-color: var(--digicert-neutral-100);
  border-radius: var(--border-radius-xl);
  overflow: hidden;
}

@media (width >= 600px) {
  .testimonial {
    --testimonial-grid-columns: 60% 40%;
    --testimonial-grid-areas: "content media";
  }
}

/* ==========================================================================
   Variants
   ========================================================================== */

/* Align-right: media on left, content on right */
.testimonial.align-right {
  --testimonial-media-object-position: center top;
}

@media (width >= 600px) {
  .testimonial.align-right {
    --testimonial-grid-columns: 40% 60%;
    --testimonial-grid-areas: "media content";
  }
}

/* Contained media: for illustrations/SVGs that should show in full with padding */
.testimonial.contained {
  --testimonial-media-padding: var(--space-l);
  --testimonial-media-align: center;
  --testimonial-media-object-fit: contain;
  --testimonial-media-object-position: center;
}

/* Dark backgrounds */
.testimonial.bg-primary {
  --testimonial-quote-color: var(--digicert-white);
  --testimonial-name-color: var(--digicert-neutral-100);
  --testimonial-title-color: var(--digicert-neutral-200);

  background-color: var(--digicert-blue);
}

.testimonial.bg-outlined {
  background: transparent;
  box-shadow: inset 0 0 0 var(--space-s) var(--digicert-neutral-200);
}

.testimonial.bg-image {
  position: relative;
  background-image: var(--background-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  min-height: calc(var(--space-5xl) * 3);
}

@media (width >= 900px) {
  .testimonial.bg-image {
    min-height: calc(var(--space-5xl) * 4);
  }
}

.testimonial.text-light-on-dark {
  --testimonial-quote-color: var(--digicert-white);
  --testimonial-name-color: var(--digicert-neutral-100);
  --testimonial-title-color: var(--digicert-neutral-200);
}

/* ==========================================================================
   Content Row
   ========================================================================== */

.testimonial-content-row {
  grid-area: content;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-m);
  padding: var(--space-xl) var(--space-l);
  box-sizing: border-box;
}

@media (width >= 600px) {
  .testimonial-content-row {
    gap: var(--space-l);
    padding: var(--space-3xl);
  }
}

/* Content container - flexbox for logo reordering */
.testimonial-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-m);
}

/* ==========================================================================
   Media Row
   ========================================================================== */

.testimonial-media {
  grid-area: media;
  position: relative;
  box-sizing: border-box;
  display: flex;
  align-items: var(--testimonial-media-align);
  justify-content: center;
  padding: var(--testimonial-media-padding);
  align-self: stretch; /* Photos fill the grid row */
}

@media (width >= 600px) {
  .testimonial-media {
    position: relative; /* Enable absolute positioning for full-bleed children */
  }
}

.testimonial-media-wrapper {
  display: flex;
  align-items: var(--testimonial-media-align);
  justify-content: center;
  width: 100%;
  height: 100%;
}

.testimonial-media-picture {
  display: block;
  width: 100%;
  height: 100%;
}

.testimonial-media-img {
  width: 100%;
  height: 100%;
  object-fit: var(--testimonial-media-object-fit);
  object-position: var(--testimonial-media-object-position);
  border-radius: var(--border-radius-xl);
}

/* SVGs are matched at higher specificity (0,2,0) than a generic
   img[src*=".svg"] rule (0,1,1), so the slot dimensions always win
   over any global SVG sizing applied elsewhere in the project. */
.testimonial-media-img[src*=".svg"] {
  width: 100%;
  height: 100%;
}

/* Full-bleed (default): no border-radius, media absolutely fills the column on desktop */
.testimonial:not(.contained) .testimonial-media-img {
  border-radius: 0;
}

@media (width >= 600px) {
  .testimonial:not(.contained) .testimonial-media-picture,
  .testimonial:not(.contained) .testimonial-media-img {
    position: absolute;
    inset: 0;
    max-height: none;
  }
}

/* Contained: let content column drive the row height */
.testimonial.contained .testimonial-media {
  min-height: 0;
  overflow: hidden;
}

/* ==========================================================================
   Content Elements
   ========================================================================== */

/* Logo - visually first via order, even though last in DOM */
.testimonial-logo {
  order: -1;
  display: flex;
  align-items: center;
  height: var(--space-2xl);
  margin-bottom: var(--space-m);
}

/* The <picture> wrapper sits between the flex container and the <img>,
   preventing aspect-ratio from resolving width:auto. Removing the
   wrapper from the layout tree lets the img act as a direct flex child. */
.testimonial-logo picture {
  display: contents;
}

/* aspect-ratio: auto 5/1 — the "auto" keyword tells the browser to
   prefer the image's natural ratio when present (raster, or SVG with
   intrinsic dimensions). Only when the image has no natural ratio (SVG
   without width/height/viewBox) does the 5/1 fallback kick in, giving
   the logo a reasonable wordmark shape instead of collapsing to 0. */
.testimonial-logo-img {
  height: 100%;
  width: auto;
  aspect-ratio: auto 5 / 1;
}

/* Quote */
.testimonial-quote {
  font-size: var(--heading-font-size-s);
  line-height: var(--line-height-normal);
  color: var(--testimonial-quote-color);
  margin: 0 0 var(--space-l) 0;
}

/* Reset inner p margin when quote is wrapped in div (UE richtext) */
.testimonial-quote p {
  margin: 0;
}

/* Name */
.testimonial-name {
  font-family: var(--heading-font-family);
  font-size: var(--body-font-size-l);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  color: var(--testimonial-name-color);
  margin: 0;
}

/* Title */
.testimonial-title {
  font-family: var(--heading-font-family);
  font-size: var(--body-font-size-m);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  color: var(--testimonial-title-color);
  margin: calc(var(--space-m) * -0.5) 0 0;
}

/* CTA */
.testimonial-cta {
  margin-top: var(--space-l);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.testimonial .button {
  display: block;
  width: 100%;
  padding: var(--space-s) var(--space-m);
  border-radius: var(--border-radius-s);
  text-decoration: none;
  cursor: pointer;
  font-weight: var(--font-weight-semibold);
  margin-top: var(--space-s);
}

/* Grouped CTAs (adjacent button-containers, see testimonial.js): stacked on
   mobile, one row from tablet up. Gap is the single spacing source inside the
   group, so the <p> and .button margins are dropped. */
.testimonial .button-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-s);
}

.testimonial .button-group > *,
.testimonial .button-group .button {
  margin: 0;
}

@media (width >= 600px) {
  .testimonial .button {
    display: inline-block;
    width: auto;
  }

  .testimonial .button-group {
    flex-flow: row wrap;
    align-items: center;
    gap: var(--space-l);
  }
}

.testimonial .button.btn-text {
  background: transparent;
  border: none;
  padding: var(--space-xs);
  color: inherit;
}

.testimonial .button.btn-outlined {
  background: transparent;
  border: var(--btn-border-width) solid currentcolor;
  padding: var(--space-s) var(--space-m);
}
