/**
 * Feature Block - CSS Grid Layout
 *
 * Uses CSS Grid to position content and media without JS DOM manipulation.
 * This preserves the original DOM structure.
 *
 * Structure:
 * - .feature-content (row 0): richtext content
 * - .feature-media (row 1): image/media
 * - .feature-meta (row 2): alt text metadata (hidden)
 */

/* Base grid layout - mobile first (stacked) */
.feature-block {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "media"
    "content";
  border-radius: var(--border-radius-xl);

  /* No background by default - use bg-secondary or bg-primary variants */
  overflow: hidden;

  --feature-svg-fallback-width: 512px;
}

/* Hide meta row (tab title) - not displayed, only used for data */
.feature-block > .feature-meta {
  display: none;
}

/* Content area styling */
.feature-block > .feature-content {
  grid-area: content;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-m);
  padding: var(--space-l);
  box-sizing: border-box;
}

@media (width >= 768px) {
  .feature-block > .feature-content {
    gap: var(--space-l);
    padding: var(--space-2xl) var(--space-xl);
  }
}

@media (width >= 900px) {
  .feature-block > .feature-content {
    padding: var(--space-2xl);
  }
}

/* Inner div wrapper from authored content */
.feature-block > .feature-content > div {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

/* Vertical rhythm has ONE source: the flex `gap` of each column context.
   Reset block margins on every flex item — at the content level AND inside
   nested groups — so no element's own margin stacks on top of the gap. The
   `> *` reset used to miss nodes nested in .button-group, letting base.css
   <p> margins leak back in and fight the gap (the recurring spacing bug). */
.feature-block .button-group > *,
.feature-block > .feature-content > div > * {
  margin-block: 0;
}

/* Body text */
.feature-block > .feature-content p,
.feature-block > .feature-content li {
  color: var(--text-color);
}

/* Bullets with small indent */
.feature-block > .feature-content ul {
  padding-left: var(--space-l);
  list-style-position: outside;
}

/* Media area styling - padded/contained is the default for illustrations/Lottie */
.feature-block > .feature-media {
  grid-area: media;
  position: relative;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center; /* Don't stretch to fill row when content is tall */
  padding: var(--space-l) var(--space-m);
}

@media (width >= 768px) {
  .feature-block > .feature-media {
    padding: var(--space-l);
  }
}

@media (width >= 900px) {
  .feature-block > .feature-media {
    padding: var(--space-xl);
  }
}

/* Inner div wrapper from AEM publishing */
.feature-block > .feature-media > div {
  display: flex;
  align-items: center;
  justify-content: center;
}

.feature-block > .feature-media picture {
  display: block;
}

.feature-block > .feature-media img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--border-radius-xl);
}

/* SVGs without intrinsic dimensions: fallback size matching typical illustrations.
   Constrained by max-width:100% on smaller viewports. */
.feature-block > .feature-media img[src*=".svg"] {
  width: var(--feature-svg-fallback-width);
}

/* Button styling - full-width stacked on mobile, inline on tablet+ */
.feature-block .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);
}

/* CTAs decorate to ONE canonical shape (feature.js normalizes all authoring
   variants): a.button alone in p.button-container, adjacent containers wrapped
   in .button-group. Bare adjacent a.button siblings cannot occur — style only
   the canonical shape here.

   Grouped CTAs (adjacent button-containers): stacked full-width on mobile.
   The group itself is the flex-column item; gap controls spacing between CTAs. */
.feature-block .button-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-m);
}

/* Gap is the single spacing source inside the group; drop the global
   .button-container .button margin so CTAs aren't double-spaced. */
.feature-block .button-group .button {
  margin: 0;
}

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

  /* Grouped CTAs sit side-by-side on a single row */
  .feature-block .button-group {
    flex-direction: row;
    align-items: center;
    gap: var(--space-l);
  }
}

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

.feature-block .button.btn-outlined,
.feature-block .button.secondary,
.feature-block .button.btn-dark-on-light.secondary {
  background: transparent;
  border: var(--btn-border-width) solid var(--digicert-blue);
  color: var(--digicert-blue);
}

.feature-block .button.btn-outlined:hover,
.feature-block .button.secondary:hover,
.feature-block .button.btn-dark-on-light.secondary:hover {
  background-color: var(--btn-transparent-hover);
}

.feature-block .button.btn-outlined:active,
.feature-block .button.secondary:active,
.feature-block .button.btn-dark-on-light.secondary:active {
  background-color: var(--btn-transparent-active);
}

/* Light-on-dark outlined/secondary - white border + text for dark backgrounds */
.feature-block .button.btn-light-on-dark.btn-outlined,
.feature-block .button.btn-light-on-dark.secondary {
  background: transparent;
  border-color: var(--btn-outlined-border-light);
  color: var(--btn-outlined-fg-light);
}

.feature-block .button.btn-light-on-dark.btn-outlined:hover,
.feature-block .button.btn-light-on-dark.secondary:hover {
  background-color: var(--btn-transparent-hover-on-dark);
}

.feature-block .button.btn-light-on-dark.btn-outlined:active,
.feature-block .button.btn-light-on-dark.secondary:active {
  background-color: var(--btn-transparent-active-on-dark);
}

/* ==========================================================================
   Background Variants (from classes_background in model)
   ========================================================================== */

/* Default is no background (transparent) */

.feature-block.bg-neutral {
  background-color: var(--digicert-neutral-100);
}

.feature-block.bg-primary {
  background-color: var(--digicert-blue);
}

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

.feature-block.bg-image {
  position: relative;
  background-image: var(--background-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;

  /* Minimum height ensures background image is visible even with minimal content */
  min-height: calc(var(--space-4xl) * 3);
}

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

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

/* ==========================================================================
   Center Alignment - single column centered layout
   ========================================================================== */

.feature-block.align-center {
  grid-template-columns: 1fr;
  grid-template-areas:
    "media"
    "content";
  text-align: center;
}

.feature-block.align-center > .feature-content {
  align-items: center;
}

@media (width >= 768px) {
  .feature-block.align-center {
    grid-template-columns: 1fr;
    max-width: 800px;
  }
}

/* ==========================================================================
   Background Image Variant - image as full background
   ========================================================================== */

.feature-block.feature-bg {
  position: relative;
  grid-template-columns: 1fr;
  grid-template-areas: "content";
  text-align: center;
  min-height: var(--space-6xl);
}

.feature-block.feature-bg > .feature-content {
  position: relative;
  z-index: 1;
  align-items: center;
}

.feature-block.feature-bg > .feature-media {
  position: absolute;
  inset: 0;
  padding: 0;
  z-index: 0;
}

.feature-block.feature-bg > .feature-media picture,
.feature-block.feature-bg > .feature-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--border-radius-xl);
}

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

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

/* ==========================================================================
   Full-bleed Variant - for photos that need edge-to-edge coverage
   ========================================================================== */

.feature-block.full-bleed > .feature-media {
  padding: 0;
  align-self: stretch; /* Override center - photos fill the grid row */
}

.feature-block.full-bleed > .feature-media > div {
  width: 100%;
  height: 100%;
}

.feature-block.full-bleed > .feature-media picture {
  width: 100%;
  height: 100%;
}

.feature-block.full-bleed > .feature-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
}

/* Text contrast for dark backgrounds - uses utilities.css .text-light-on-dark
   which sets color and --text-color. Feature inherits color naturally. */

/* ==========================================================================
   Desktop Layout - side by side
   Default: content left, media right
   align-right: content right, media left
   ========================================================================== */

@media (width >= 768px) {
  .feature-block {
    /* Default: content left (60%), media right (40%) */
    grid-template-columns: 60% 40%;
    grid-template-areas: "content media";
  }

  /* Align right: content right, media left */
  .feature-block.align-right {
    grid-template-columns: 40% 60%;
    grid-template-areas: "media content";
  }

  /* No media - single column layout (class added by JS) */
  .feature-block.no-media {
    grid-template-columns: 1fr;
    grid-template-areas: "content";
  }
}

/* ==========================================================================
   Lottie Player - created by utils/media/lottie.js
   ========================================================================== */

.feature-block .lottie-player {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.feature-block .lottie-player svg {
  width: 100%;
  height: auto;
}

.feature-block .lottie-player canvas {
  width: 100%;
  height: 100%;
}

/* Video play button overlay */
.feature-block .play-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: var(--space-5xl);
  height: var(--space-5xl);
  background: var(--digicert-white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--duration-normal) ease;
}

.feature-block .play-button:hover {
  transform: translate(-50%, -50%) scale(1.1);
}

.feature-block .play-button::after {
  content: '';
  width: 0;
  height: 0;
  border-style: solid;

  /* Triangle: 12px top/bottom = 3 × --space-xs, 20px left = 5 × --space-xs */
  border-width: calc(var(--space-xs) * 3) 0 calc(var(--space-xs) * 3) calc(var(--space-xs) * 5);
  border-color: transparent transparent transparent var(--digicert-neutral-700);
  margin-left: var(--space-xs);
}
