/*
 * File: assets/css/tooltip.css
 * Purpose: Reusable tooltip + social-tooltip utility for 12D Elementor Addons
 */

/* =========================
   D12 Tooltip + Social vars
   ========================= */

:root {
  /* =========================================================
     D12 Tooltip defaults
     ---------------------------------------------------------
     These are widget-level defaults.
     Wherever possible, they inherit from site-level tokens first,
     and only fall back to hardcoded values if no site token exists.
     This keeps the widget portable across sites.
     ========================================================= */

  /* Tooltip surface + text */
  --d12-tt-bg: #ffffff;
  --d12-tt-text: var(--site-text, var(--e-global-color-text, #111111));
  --d12-tt-border: rgba(0, 0, 0, 0.18);

  /* Tooltip shape + elevation
     Inherit site tokens if available, otherwise use safe local fallbacks */
  --d12-tt-radius: var(--site-radius-sm, 2px);
  --d12-tt-shadow: var(--site-shadow-md, 0 6px 18px rgba(0, 0, 0, 0.12));

  /* Tooltip typography */
  --d12-tt-font-size: 13px;
  --d12-tt-line-height: 1.25;

  /* Tooltip spacing + geometry */
  --d12-tt-pad-y: 8px;
  --d12-tt-pad-x: 10px;

  /*
   * Four-side padding API.
   * Defaults remain derived from the legacy vertical/horizontal variables
   * so existing customisations of --d12-tt-pad-y / --d12-tt-pad-x
   * continue to work unchanged.
   */
  --d12-tt-pad-top: var(--d12-tt-pad-y);
  --d12-tt-pad-right: var(--d12-tt-pad-x);
  --d12-tt-pad-bottom: var(--d12-tt-pad-y);
  --d12-tt-pad-left: var(--d12-tt-pad-x);

  --d12-tt-position: top;
  --d12-tt-z: 9999;
  --d12-tt-offset: 10px;
  --d12-tt-maxw: 420px;
  --d12-tt-white-space: normal;

  /* Tooltip motion */
  --d12-tt-delay: 180ms;
  --d12-tt-anim: var(--site-transition-fast, 160ms);

  /* =========================================================
     D12 Social tooltip defaults
     ---------------------------------------------------------
     These govern icon sizing, spacing, and interactive hit areas.
     Keep these widget-scoped so the social tooltip system remains
     self-contained and portable.
     ========================================================= */
  --d12-social-icon-size: 20px;
  --d12-social-gap: 2px;
  --d12-social-hit-area: 28px;
  --d12-social-hover-ring-size: 3rem;
  --d12-social-radius: 999px;
  --d12-social-border-width: 0px;
  --d12-social-border-color: transparent;

  /* Site-driven colors
     These are intentionally mapped to site tokens so the widget
     adopts the branding of each site without changing plugin CSS. */
  --d12-social-icon-color: var(--site-text);
  --d12-social-bg: transparent;

  --d12-social-icon-hover: var(
    --site-accent-hover,
    var(--site-accent, var(--e-global-color-accent, currentColor))
  );
  --d12-social-hover-bg: #ffffff;
}

/* Slightly increase the email icon */
.d12-tt-email svg {
  transform: scale(1.35);
}

/* ================
   D12 Tooltip base
   Usage:
   <a class="d12-tt" data-tt="Tooltip text">...</a>
   ================ */

.d12-tt {
  position: relative;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  flex: 0 0 auto; /* prevent flex containers from shrinking tooltip triggers */
  vertical-align: middle; /* safer inline alignment */

  cursor: help;
  outline: none;
  text-decoration: none;
}
.d12-tt--active,
.d12-tt:focus,
.d12-tt:focus-visible {
  z-index: var(--d12-tt-z);
}

/* Clickable header tooltip triggers */
.elementor-location-header .d12-social-tooltips .d12-tt,
.elementor-location-header .d12-social-tooltips .d12-tt *,
.elementor-location-header .elementor-menu-cart__toggle_button.d12-tt,
.elementor-location-header .elementor-menu-cart__toggle_button.d12-tt * {
  cursor: pointer !important;
}

/* Tooltip bubble */
.d12-tt::after {
  content: attr(data-tt);
  position: absolute;
  z-index: var(--d12-tt-z);

  padding: var(--d12-tt-pad-top) var(--d12-tt-pad-right)
    var(--d12-tt-pad-bottom) var(--d12-tt-pad-left);

  background: var(--d12-tt-bg);
  border: 1px solid var(--d12-tt-border);
  border-radius: var(--d12-tt-radius);
  box-shadow: var(--d12-tt-shadow);
  color: var(--d12-tt-text);

  font-size: var(--d12-tt-font-size);
  line-height: var(--d12-tt-line-height);

  white-space: var(--d12-tt-white-space);
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;

  left: 50%;
  bottom: calc(100% + var(--d12-tt-offset));

  width: max-content;
  max-width: min(var(--d12-tt-maxw), calc(100vw - 24px));

  transform: translateX(-50%) translateY(4px);
  box-sizing: border-box;
  text-align: left;

  opacity: 0;
  visibility: hidden;
  pointer-events: none;

  transition:
    opacity var(--d12-tt-anim) ease,
    transform var(--d12-tt-anim) ease,
    visibility 0s linear var(--d12-tt-anim);
}

/* Show only when JS activates the tooltip, or when keyboard focus is present */
.d12-tt.d12-tt--active::after,
.d12-tt:focus::after,
.d12-tt:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  transition:
    opacity var(--d12-tt-anim) ease,
    transform var(--d12-tt-anim) ease,
    visibility 0s;
}

/* Motion sensitivity */
@media (prefers-reduced-motion: reduce) {
  .d12-tt::after {
    transition: none;
  }
}

/*
 * Mobile Portrait Tooltip geometry.
 *
 * Keep long Tooltips readable without allowing the bubble to expand across
 * almost the entire viewport. An Elementor responsive Maximum Width value
 * can still override this shared default at the widget instance level.
 */
@media (max-width: 767px) {
  :root {
    --d12-tt-maxw: 320px;
  }
}

/* Hide tooltip bubble on coarse touch devices */
@media (hover: none) and (pointer: coarse) {
  .d12-tt::after {
    display: none;
  }
}

/* =========================================
   Tooltip placement + viewport corrections
   ========================================= */

/*
 * Preferred top placement.
 *
 * This is also the backward-compatible default when no placement class
 * has yet been added by JavaScript.
 */
.d12-tt--place-top::after {
  left: 50%;
  right: auto;
  top: auto;
  bottom: calc(100% + var(--d12-tt-offset));
  transform: translateX(-50%) translateY(4px);
}

.d12-tt--place-top.d12-tt--active::after,
.d12-tt--place-top:focus::after,
.d12-tt--place-top:focus-visible::after {
  transform: translateX(-50%) translateY(0);
}

/* Preferred bottom placement */

.d12-tt--place-bottom::after {
  left: 50%;
  right: auto;
  top: calc(100% + var(--d12-tt-offset));
  bottom: auto;
  transform: translateX(-50%) translateY(-4px);
}

.d12-tt--place-bottom.d12-tt--active::after,
.d12-tt--place-bottom:focus::after,
.d12-tt--place-bottom:focus-visible::after {
  transform: translateX(-50%) translateY(0);
}

/* Preferred left placement */

.d12-tt--place-left::after {
  left: auto;
  right: calc(100% + var(--d12-tt-offset));
  top: 50%;
  bottom: auto;
  transform: translateX(4px) translateY(calc(-50% + var(--d12-tt-shift-y, 0px)));
}

.d12-tt--place-left.d12-tt--active::after,
.d12-tt--place-left:focus::after,
.d12-tt--place-left:focus-visible::after {
  transform: translateX(0) translateY(calc(-50% + var(--d12-tt-shift-y, 0px)));
}

/* Preferred right placement */

.d12-tt--place-right::after {
  left: calc(100% + var(--d12-tt-offset));
  right: auto;
  top: 50%;
  bottom: auto;
  transform: translateX(-4px)
    translateY(calc(-50% + var(--d12-tt-shift-y, 0px)));
}

.d12-tt--place-right.d12-tt--active::after,
.d12-tt--place-right:focus::after,
.d12-tt--place-right:focus-visible::after {
  transform: translateX(0) translateY(calc(-50% + var(--d12-tt-shift-y, 0px)));
}

/*
 * Horizontal viewport correction for top/bottom placements.
 *
 * These retain the existing class names because their meaning remains:
 * align the bubble to the trigger's left or right edge when centered
 * placement would overflow the viewport.
 */

/* Align bubble's right edge with trigger */

.d12-tt--place-top.d12-tt--left::after,
.d12-tt--place-bottom.d12-tt--left::after {
  left: auto;
  right: 0;
  transform: translateX(0) translateY(4px);
}

.d12-tt--place-bottom.d12-tt--left::after {
  transform: translateX(0) translateY(-4px);
}

.d12-tt--place-top.d12-tt--left.d12-tt--active::after,
.d12-tt--place-top.d12-tt--left:focus::after,
.d12-tt--place-top.d12-tt--left:focus-visible::after,
.d12-tt--place-bottom.d12-tt--left.d12-tt--active::after,
.d12-tt--place-bottom.d12-tt--left:focus::after,
.d12-tt--place-bottom.d12-tt--left:focus-visible::after {
  transform: translateX(0) translateY(0);
}

/* Align bubble's left edge with trigger */

.d12-tt--place-top.d12-tt--right::after,
.d12-tt--place-bottom.d12-tt--right::after {
  left: 0;
  right: auto;
  transform: translateX(0) translateY(4px);
}

.d12-tt--place-bottom.d12-tt--right::after {
  transform: translateX(0) translateY(-4px);
}

.d12-tt--place-top.d12-tt--right.d12-tt--active::after,
.d12-tt--place-top.d12-tt--right:focus::after,
.d12-tt--place-top.d12-tt--right:focus-visible::after,
.d12-tt--place-bottom.d12-tt--right.d12-tt--active::after,
.d12-tt--place-bottom.d12-tt--right:focus::after,
.d12-tt--place-bottom.d12-tt--right:focus-visible::after {
  transform: translateX(0) translateY(0);
}

/* ================================
   Inline glossary / technical term
   Tooltip trigger
   ================================ */

.d12-tt-term {
  color: var(--site-accent, var(--e-global-color-accent, currentColor));
  text-decoration: underline dotted;
  text-underline-offset: 0.14em;
  cursor: help;
  transition:
    color 0.15s ease,
    text-decoration-color 0.15s ease;
}

.d12-tt-term:hover {
  text-decoration-color: var(
    --site-accent-hover,
    var(--site-accent, currentColor)
  );
  color: var(--site-accent-hover, var(--site-accent, currentColor));
}

/* =========================================
   D12 tooltip icons – polished visual upgrade
   ========================================= */

.d12-social-tooltips {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  gap: var(--d12-social-gap);

  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;

  flex-wrap: wrap; /* important for small screens */
}

/* =========================================
   MOBILE: stack icons vertically only when requested
   ========================================= */

@media (max-width: 767px) {
  .d12-social-tooltips.d12-stack-mobile {
    flex-direction: column;
    align-items: center;

    --d12-social-hit-area: 28px;
    --d12-social-gap: 6px;
    --d12-social-hover-ring-size: 28px;
  }
}

.d12-social-tooltips .d12-tt {
  width: var(--d12-social-hit-area);
  min-width: var(--d12-social-hit-area);
  height: var(--d12-social-hit-area);
  flex: 0 0 var(--d12-social-hit-area);

  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  box-sizing: border-box;
  line-height: 0;

  color: var(--d12-social-icon-color, currentColor);
  background-color: var(--d12-social-bg, transparent);
  border: var(--d12-social-border-width) solid var(--d12-social-border-color);
  border-radius: var(--d12-social-radius);

  transition:
    color 0.2s ease,
    background-color 0.2s ease;
}

.d12-social-tooltips .d12-tt::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;

  width: var(--d12-social-hover-ring-size);
  height: var(--d12-social-hover-ring-size);

  transform: translate(-50%, -50%) scale(1);
  border-radius: var(--d12-social-radius);

  background-color: transparent;
  border: 1px solid transparent;
  box-shadow: none;
  pointer-events: none;
  opacity: 0;
  z-index: 0;

  transition:
    transform 0.25s ease,
    opacity 0.2s ease,
    background-color 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.d12-social-tooltips .d12-tt:hover,
.d12-social-tooltips .d12-tt:focus,
.d12-social-tooltips .d12-tt:focus-visible {
  color: var(--d12-social-icon-hover, currentColor);
  background-color: var(
    --d12-social-hover-bg,
    var(--d12-social-bg, transparent)
  );
  border-color: var(
    --d12-social-icon-hover,
    var(--d12-social-border-color, currentColor)
  );
}

.d12-social-tooltips .d12-tt:hover::before,
.d12-social-tooltips .d12-tt:focus::before,
.d12-social-tooltips .d12-tt:focus-visible::before {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  background-color: var(--d12-social-hover-bg, #ffffff);
  border: var(--d12-social-border-width, 1px) solid
    var(--d12-social-icon-hover, var(--site-accent, currentColor));
  box-shadow: var(--site-shadow-sm, 0 4px 12px rgba(0, 0, 0, 0.08));
}

/* =========================================
   Header – WooCommerce cart icon tooltip hover
   ========================================= */

.elementor-location-header .elementor-menu-cart__toggle_button.d12-tt {
  position: relative;
}

.elementor-location-header .elementor-menu-cart__toggle_button.d12-tt::before {
  content: "";
  position: absolute;
  left: 55%;
  top: 50%;

  width: 3.5rem;
  height: 3.5rem;

  transform: translate(-50%, -50%) scale(1);
  border-radius: var(--d12-social-radius);

  background-color: transparent;
  border: 1px solid transparent;
  box-shadow: none;
  pointer-events: none;
  opacity: 0;
  z-index: 0;

  transition:
    transform 0.25s ease,
    opacity 0.2s ease,
    background-color 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.elementor-location-header
  .elementor-menu-cart__toggle_button.d12-tt:hover::before,
.elementor-location-header
  .elementor-menu-cart__toggle_button.d12-tt:focus::before,
.elementor-location-header
  .elementor-menu-cart__toggle_button.d12-tt:focus-visible::before {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  background-color: #ffffff;
  border: 1px solid var(--site-accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Keep cart icon and item counter above the hover circle */
.elementor-location-header
  .elementor-menu-cart__toggle_button.d12-tt
  .elementor-button-icon,
.elementor-location-header
  .elementor-menu-cart__toggle_button.d12-tt
  .elementor-button-icon
  svg,
.elementor-location-header
  .elementor-menu-cart__toggle_button.d12-tt
  .elementor-button-icon-qty {
  position: relative;
  z-index: 1;
}

.d12-social-tooltips .d12-tt svg {
  position: relative;
  z-index: 1;

  width: var(--d12-social-icon-size);
  height: var(--d12-social-icon-size);
  display: block;
  flex: 0 0 auto;
  margin: 0;
  fill: currentColor;
}

.d12-social-tooltips .d12-tt i {
  position: relative;
  z-index: 1;

  display: inline-block;
  font-size: var(--d12-social-icon-size);
  line-height: 1;
  flex: 0 0 auto;
}

/* =========================================================
   12D Icon Actions – clickable cursor
   ========================================================= */

.d12-social-tooltips.d12-icon-actions .d12-tt,
.d12-social-tooltips.d12-icon-actions .d12-tt * {
  cursor: pointer;
}

/* End of file tooltip.css */
