/* ============================================================
   12D – CARD WIDGET
   File: assets/css/card.css
   ============================================================ */

/* ============================================================
   BASE CARD WRAPPER
   ============================================================ */

.d12-card {
  width: 100%;
  height: auto;
  display: block;

  position: relative;
  box-sizing: border-box;
  overflow: hidden;

  text-decoration: none;
  color: inherit;

  /* Transition defaults (Elementor controls can override these vars or properties) */
  transition-property: var(--d12-card-transition-prop, transform, box-shadow);
  transition-duration: var(--d12-card-transition-dur, 0.45s);
  transition-timing-function: var(--d12-card-transition-ease, ease);
}

.d12-card--link {
  cursor: pointer;
  display: block;
  transform-origin: center center;
  will-change: transform;
}

/* Non-clickable cards should not feel interactive */
.d12-card:not(.d12-card--link) {
  cursor: default;
}

/* ============================================================
   CLICKABLE CARD: stop theme link color from bleeding into content
   ============================================================ */

a.d12-card.d12-card--link,
a.d12-card.d12-card--link:visited,
a.d12-card.d12-card--link:hover,
a.d12-card.d12-card--link:focus,
a.d12-card.d12-card--link:focus-visible,
a.d12-card.d12-card--link:active {
  color: inherit !important;
  text-decoration: none !important;
}

a.d12-card.d12-card--link .d12-card__title,
a.d12-card.d12-card--link .d12-card__text,
a.d12-card.d12-card--link .d12-card__text p {
  color: inherit;
}

/* ============================================================
   CARD INNER WRAPPER
   ============================================================ */

.d12-card__inner {
  width: 100%;
  height: auto; /* ✅ default: don't stretch */

  display: flex;
  flex-direction: column;

  box-sizing: border-box;
}

/* ============================================================
   OPTIONAL CONTENT HELPERS
   ============================================================ */

.d12-card__title {
  margin: 0 0 var(--d12-card-title-mb, 0.6rem) 0;
}

.d12-card__text {
  flex: 0 0 auto;
}

.d12-card__text p {
  margin: 0 0 var(--d12-card-text-mb, 0.8rem) 0;
}

.d12-card__actions {
  margin-top: var(--d12-card-actions-mt, 0.75rem);
  display: flex;
  flex-wrap: wrap;
  gap: var(--d12-card-actions-gap, 0.5rem);
}

.d12-card__btn {
  display: inline-block;
  text-decoration: none;
  line-height: 1.2;
  color: inherit;
}

.d12-card__link {
  display: inline-block;
  line-height: 1.2;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ============================================================
   SAFETY NORMALIZATIONS
   ============================================================ */

.d12-card img {
  max-width: 100%;
  display: block;
}

/* Only images inside the WYSIWYG/text should keep natural height */
.d12-card__text img {
  height: auto;
}

.d12-card__actions a.d12-card__btn {
  text-decoration: none;
}

/* BUT: allow the CTA text-link to underline */
.d12-card__actions a.d12-card__link {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ============================================================
   INNER EDGE / ONE-SIDE SHADOW (supports solid OR gradient)
   ============================================================ */

.d12-card::before {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: 1;

  background: var(--d12-card-edge-color, transparent);

  filter: blur(var(--d12-card-edge-blur, 0px));
  opacity: var(--d12-card-edge-opacity, 1);

  transform: translateZ(0);
  will-change: transform, filter;

  display: none;
}

/* Enable */
.d12-card[data-edge="yes"]::before {
  display: block;
}

/* Gradient mode */
.d12-card[data-edge="yes"][data-edge-grad="yes"]::before {
  background: linear-gradient(var(--d12-card-edge-grad-dir, 90deg), var(--d12-card-edge-color, transparent), var(--d12-card-edge-color-2, var(--d12-card-edge-color, transparent)));
}

/* LEFT */
.d12-card[data-edge-side="left"]::before {
  top: 0;
  left: 0;
  width: var(--d12-card-edge-size, 4px);
  height: 100%;
  border-top-left-radius: inherit;
  border-bottom-left-radius: inherit;
}

/* RIGHT */
.d12-card[data-edge-side="right"]::before {
  top: 0;
  right: 0;
  width: var(--d12-card-edge-size, 4px);
  height: 100%;
  border-top-right-radius: inherit;
  border-bottom-right-radius: inherit;
}

/* TOP */
.d12-card[data-edge-side="top"]::before {
  top: 0;
  left: 0;
  height: var(--d12-card-edge-size, 4px);
  width: 100%;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}

/* BOTTOM */
.d12-card[data-edge-side="bottom"]::before {
  bottom: 0;
  left: 0;
  height: var(--d12-card-edge-size, 4px);
  width: 100%;
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;
}

/* ============================================================
   MEDIA (IMAGE / ICON)
   ============================================================ */

/* Media wrapper: no default spacing (Elementor controls it) */
.d12-card__media {
  margin: 0;
  min-width: 0;
}

/* Ensure image media respects fixed media height */
.d12-card__media--image {
  height: var(--d12-card-media-h, auto);
}

/*
  Image box behavior:
  - Default: aspect-ratio controls height (nice for “top/bottom” image cards)
  - If media height is set, height wins and the image fills that box
*/
.d12-card__imgbox {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: var(--d12-card-media-bg, transparent);

  aspect-ratio: var(--d12-card-imgbox-ar, var(--d12-card-img-ar, 4 / 3));
  height: var(--d12-card-media-h, auto);
}

/* Placeholder if no image selected */
.d12-card__img-placeholder {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.06);
}

/* IMPORTANT: make the <img> fill the box (kills the “gap”) */
.d12-card__img {
  position: absolute;
  inset: 0;

  width: 100%;
  height: 100%;

  object-fit: cover;
  object-position: center;
}

/* Icon */
.d12-card__media--icon {
  display: flex;
}

.d12-card__icon-wrap {
  width: var(--d12-card-icon-wrap, 56px);
  height: var(--d12-card-icon-wrap, 56px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.d12-card__icon {
  font-size: var(--d12-card-icon-size, 28px);
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.d12-card__icon svg {
  width: 1em;
  height: 1em;
  display: block;
}

/* ============================================================
   MEDIA POSITIONING (top / bottom / left / right)
   ============================================================ */

/* Top (default) */
.d12-card[data-media-pos="top"] .d12-card__inner {
  flex-direction: column;
}

/* Bottom */
.d12-card[data-media-pos="bottom"] .d12-card__inner {
  flex-direction: column;
}

.d12-card[data-media-pos="bottom"] .d12-card__media {
  order: 2;
}

.d12-card[data-media-pos="bottom"] .d12-card__content {
  order: 1;
}

/* Left */
.d12-card[data-media-pos="left"] .d12-card__inner {
  flex-direction: row;
  align-items: stretch;
  gap: var(--d12-card-media-gap, 0);
}

/* Right */
.d12-card[data-media-pos="right"] .d12-card__inner {
  flex-direction: row-reverse;
  align-items: stretch;
  gap: var(--d12-card-media-gap, 0);
}

/* Left/Right image column width (so it never collapses) */
.d12-card[data-media-pos="left"] .d12-card__media--image,
.d12-card[data-media-pos="right"] .d12-card__media--image {
  flex: 0 0 var(--d12-card-media-side-w, 40%);
  display: flex;
}

/* In left/right layouts, let height come from the row, not aspect-ratio */
.d12-card[data-media-pos="left"] .d12-card__imgbox,
.d12-card[data-media-pos="right"] .d12-card__imgbox {
  flex: 1;
  height: 100%;
  aspect-ratio: auto;
}

/* In left/right layouts, make media column a flexbox so vertical alignment works */
.d12-card[data-media-pos="left"] .d12-card__media,
.d12-card[data-media-pos="right"] .d12-card__media {
  display: flex;
  flex-direction: column;
}

/* Content fills remaining space */
.d12-card__content {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

/* ============================================================
   EQUAL HEIGHT HELPERS
   ============================================================ */

.d12-card__inner--stick {
  height: auto;
}

.d12-card__inner--stick .d12-card__actions {
  margin-top: auto;
}

/* ============================================================
   Cards Grid context: allow equal-height fill
   ============================================================ */
.d12-cards-grid .d12-card,
.d12-cards-grid .d12-card__inner,
.d12-cards-grid .d12-card__inner--stick {
  height: 100%;
}

/* ============================================================
   DEFAULT MEDIA HEIGHT CAP (prevents gigantic ratio-driven cards)
   ============================================================ */

.d12-card {
  --d12-card-media-h-default: clamp(160px, 22vw, 260px);
}

/* Default: apply cap to normal images */
.d12-card__imgbox {
  height: var(--d12-card-media-h, var(--d12-card-media-h-default));
}

.d12-card__media--image {
  height: var(--d12-card-media-h, var(--d12-card-media-h-default));
}

/* ============================================================
   CARD HOVER SHADOW IN CARDS GRID
   ============================================================ */

.d12-cards-grid .d12-card.d12-card--link:hover {
  box-shadow: 0 20px 38px rgba(0, 0, 0, 0.32) !important;
}

/* End of file card.css */
