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

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

.d12-card {
  /* ============================================================
     D12 Card defaults
     ------------------------------------------------------------
     Widget-scoped defaults.
     These keep the Card portable while allowing site-level tokens
     to influence motion, elevation, and other shared UI behavior.
     ============================================================ */

  --d12-card-transition-prop: transform, box-shadow;
  --d12-card-transition-dur: var(--site-transition-base, 0.45s);
  --d12-card-transition-ease: ease;
  --d12-card-media-h-default: clamp(160px, 22vw, 260px);

  width: 100%;
  height: auto;
  display: block;

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

  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;
}

/*
 * Default clickable Card hover elevation.
 *
 * Applies only while the Card is hovered without keyboard focus.
 * Elementor's Hover Box Shadow control can override this fallback
 * when an explicit widget-level value is configured.
 */
.d12-card--link:hover:not(:focus-visible) {
  box-shadow: 0 18px 36px 4px rgba(0, 0, 0, 0.7);
}

/*
 * Card hover-effects bridge.
 *
 * The clickable Card is both the hover-effect wrapper and the animated target:
 *
 *   <a class="d12-card d12-card--link d12-hover-target"
 *      data-d12-hover="...">
 *
 * The shared Hover Effects stylesheet normally targets a descendant
 * .d12-hover-target. Card therefore needs same-element selectors locally.
 * Keep this bridge Card-scoped so the shared hover-effects contract remains
 * unchanged for other widgets.
 */

.d12-card--link.d12-hover-target[data-d12-hover] {
  transition:
    color var(--d12-hover-duration, 250ms) var(--d12-hover-easing, ease-out),
    background-color var(--d12-hover-duration, 250ms)
      var(--d12-hover-easing, ease-out),
    border-color var(--d12-hover-duration, 250ms)
      var(--d12-hover-easing, ease-out),
    box-shadow var(--d12-hover-duration, 250ms)
      var(--d12-hover-easing, ease-out),
    transform var(--d12-hover-duration, 250ms) var(--d12-hover-easing, ease-out);

  transform: translateZ(0);
}

.d12-card--link.d12-hover-target[data-d12-hover="grow"]:hover {
  transform: scale(var(--d12-hover-grow-scale, 1.06));
}

.d12-card--link.d12-hover-target[data-d12-hover="shrink"]:hover {
  transform: scale(var(--d12-hover-shrink-scale, 0.96));
}

.d12-card--link.d12-hover-target[data-d12-hover="lift"]:hover {
  transform: translateY(calc(-1 * var(--d12-hover-lift-distance, 3px)));
}

.d12-card--link.d12-hover-target[data-d12-hover="push"]:hover {
  transform: translateY(var(--d12-hover-push-distance, 2px)) scale(0.98);
}

.d12-card--link.d12-hover-target[data-d12-hover="pop"]:hover {
  animation: d12-hover-pop var(--d12-hover-duration, 250ms)
    var(--d12-hover-easing, ease-out) both;
}

.d12-card--link.d12-hover-target[data-d12-hover="pulse"]:hover {
  animation: d12-hover-pulse calc(var(--d12-hover-duration, 250ms) * 1.8)
    ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .d12-card--link.d12-hover-target[data-d12-hover] {
    transition-duration: 0.01ms;
  }

  .d12-card--link.d12-hover-target[data-d12-hover]:hover {
    animation: none;
    transform: none;
  }
}

/*
 * Card keyboard Focus presentation.
 *
 * Focus takes precedence over Hover when both states are active.
 * Suppress Hover motion and the ordinary Card border so the
 * Focus Indicator remains the single visible edge treatment.
 */
.d12-card--link.d12-hover-target[data-d12-hover]:focus-visible {
  transform: none;
  animation: none;
  border-color: transparent !important;
  box-shadow: none !important;
}

/* 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 HOVER MOTION ADAPTER
   ------------------------------------------------------------
   Card is both the hover-effect owner and the motion target.
   Unlike shared wrapper/descendant consumers, the complete
   Card must transform so its border, background, radius,
   shadow, content, and actions move as one component.
   ============================================================ */

.d12-card.d12-hover-target[data-d12-hover="grow"]:hover {
  transform: scale(var(--d12-hover-grow-scale, 1.06));
}

/* ============================================================
   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__actions--with-price {
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.d12-card__price-inline {
  margin-left: auto;
  white-space: nowrap;
  line-height: 1.2;
  font-weight: 700;
}

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

/*
 * Whole-card Button focus bridge.
 *
 * When the Card itself is the link, Button presentation is rendered with
 * non-anchor markup to avoid invalid nested anchors. Keyboard focus therefore
 * belongs to the surrounding Card link rather than the visual Button element.
 */
.d12-card--link:focus-visible .d12-card__btn.d12-button .d12-button__icon {
  color: var(--d12-button-icon-focus-color, inherit);
}

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

/*
 * Independent Text Link CTA keyboard Focus.
 *
 * Elementor's Text Link Focus controls own color, width, offset, and radius.
 * Radius is applied as border-radius on the focused link because CSS outline
 * does not provide an independently controllable radius of its own; the outline
 * follows the rounded geometry of the focused element.
 *
 * Card supplies the structural outline style so the focus indicator remains
 * predictable across browsers and themes.
 */
a.d12-card__link:focus-visible {
  outline-style: solid;
}

/* ============================================================
   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;
}

/* ============================================================
   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;
}

.d12-card__media--image {
  height: auto;
  min-height: 0;
}

/*
  ============================================================
  MEDIA HEIGHT SYSTEM (IMPORTANT)
  ------------------------------------------------------------
  Media height is controlled via --d12-card-media-h.

  When a height is set (via Elementor control):
  - aspect-ratio is explicitly disabled
  - the media box becomes a fixed-height crop container
  - the <img> is forced to fully fill the box (object-fit: cover)

  This avoids proportional scaling limits and ensures:
  - consistent image heights across cards
  - predictable layout in grids
  - no extra whitespace below images

  If you remove this logic, images may appear "capped"
  based on width (aspect-ratio behavior).
  ============================================================
*/
.d12-card__imgbox {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: var(--d12-card-media-bg, transparent);
  line-height: 0;

  /* Default = ratio mode */
  aspect-ratio: var(--d12-card-img-ar, 4 / 3);
  height: auto;
  min-height: 0;
}

/* Fixed-height mode: activated only when Elementor Media Height is explicitly set */
.d12-card[style*="--d12-card-media-mode:fixed"] .d12-card__media--image {
  height: var(--d12-card-media-h, var(--d12-card-media-h-default));
  min-height: var(--d12-card-media-h, var(--d12-card-media-h-default));
}

.d12-card[style*="--d12-card-media-mode:fixed"] .d12-card__imgbox {
  aspect-ratio: auto !important;
  height: var(--d12-card-media-h, var(--d12-card-media-h-default));
  min-height: var(--d12-card-media-h, var(--d12-card-media-h-default));
}

/* Top-positioned image media: image and box must use top-only rounding */
.d12-card[data-media-pos="top"] .d12-card__imgbox,
.d12-card[data-media-pos="top"] .d12-card__img-placeholder,
.d12-card[data-media-pos="top"] .d12-card__img {
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

/* 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;

  display: block;
  width: 100% !important;
  height: 100% !important;
  min-height: 100% !important;
  max-height: none !important;

  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;
}

/* Prevent image media from shrinking in vertical card layouts */
.d12-card[data-media-pos="top"] .d12-card__media--image,
.d12-card[data-media-pos="bottom"] .d12-card__media--image {
  display: flex;
  flex: 0 0 auto;
  flex-shrink: 0;
  width: 100%;
}

.d12-card[data-media-pos="top"] .d12-card__imgbox,
.d12-card[data-media-pos="bottom"] .d12-card__imgbox {
  width: 100%;
  flex: 0 0 auto;
  flex-shrink: 0;
}

/* 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 {
  height: 100%;
}

/* End of file card.css */
