/**
 * Here, Mostly — CTA section (Connect / Share / Contact). Theme-owned presentation.
 * Shortcodes and click handlers remain in the heremostly plugin.
 */

.hm-cta-section,
.hm-cta-grid,
.elementor-element.hm-cta-grid > .e-con-inner {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  justify-content: center;
  align-items: start;
  margin: clamp(36px, 6vw, 60px) auto 0;
  padding: clamp(12px, 2vw, 24px) clamp(12px, 3vw, 24px) clamp(16px, 3vw, 32px);
  box-sizing: border-box;
  background: #fff;
}

/*
 * Desktop / tablet landscape — reference .cta-inner row: 1180px, 380px columns, 20px gap,
 * icon centers ~400px apart (1280×900: x 240 / 640 / 1040).
 */
@media (min-width: 768px) {
  .elementor-element.hm-cta-grid.e-con {
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: calc(50% - 50vw) !important;
    margin-right: calc(50% - 50vw) !important;
    box-sizing: border-box;
  }

  .hm-cta-section,
  .hm-cta-grid,
  .elementor-element.hm-cta-grid > .e-con-inner {
    /*
     * Full-bleed row (escape .hm-landing / .hm-main) + 1180px track @ 50px viewport inset.
     * Reference @ 1280: icon centers 240 / 640 / 1040 (400px apart).
     */
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding-left: max(50px, calc((100vw - 1180px) / 2));
    padding-right: max(50px, calc((100vw - 1180px) / 2));
    padding-top: clamp(12px, 2vw, 24px);
    padding-bottom: clamp(16px, 3vw, 32px);
    gap: 20px;
    margin-top: clamp(36px, 6vw, 60px);
  }

  /* Short viewports: keep breathing room below Read the Book (hero art height is fixed separately). */
  @media (max-height: 920px) {
    .hm-cta-section,
    .hm-cta-grid,
    .elementor-element.hm-cta-grid > .e-con-inner {
      margin-top: clamp(24px, 4vw, 40px);
      padding-top: clamp(8px, 1.2vw, 16px);
    }
  }

  /* Reference .cta-icon: 90×90, 12px below icon (see .hm-cta-icon base + desktop repeat). */
  .hm-cta-icon {
    width: 90px;
    height: 90px;
    margin-bottom: 12px;
  }
}

.elementor-element.hm-cta-grid.e-flex > .e-con-inner {
  flex-direction: unset !important;
}

.elementor-element.hm-cta-grid.e-con {
  --padding-top: 0px;
  --padding-bottom: 0px;
  --margin-top: 0px;
  --margin-bottom: 0px;
  min-height: 0 !important;
  width: 100%;
  max-width: none;
}

.elementor-element.hm-cta-grid > .e-con-inner {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  min-height: 0 !important;
  flex-wrap: nowrap !important;
  overflow: visible !important;
}

.elementor-element.hm-cta-grid > .e-con-inner > .elementor-element,
.elementor-element.hm-cta-grid .elementor-widget-shortcode,
.elementor-element.hm-cta-grid .elementor-shortcode {
  overflow: visible !important;
}

.elementor-element.hm-cta-grid .elementor-widget-shortcode {
  width: 100%;
  max-width: none;
}

.elementor-element.hm-cta-grid > .e-con-inner > .elementor-element {
  width: 100% !important;
  max-width: none !important;
  flex: unset !important;
}

.hm-cta-section,
.hm-cta-grid {
  overflow: visible;
}

.hm-cta {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  cursor: pointer;
  padding: 8px 12px;
  width: 100%;
  max-width: none;
  margin: 0 auto;
  box-sizing: border-box;
  overflow: visible;
}

a.hm-cta,
a.hm-cta:hover,
a.hm-cta:visited {
  text-decoration: none;
  color: inherit;
}

.hm-cta:focus-visible {
  outline: 2px solid var(--hm-blue, #4576bb);
  outline-offset: 4px;
  border-radius: 10px;
}

.hm-cta-icon {
  width: 90px;
  height: 90px;
  object-fit: contain;
  margin: 0 auto 12px;
  transition: transform 0.3s ease;
}

.hm-cta:hover .hm-cta-icon,
.hm-cta:focus-within .hm-cta-icon {
  transform: scale(1.12);
}

.hm-cta h3 {
  color: var(--hm-blue, #4576bb);
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}

/* Desktop: tooltip-only; mobile stack shows .hm-cta-desc (approved copy). */
.hm-cta-desc {
  display: none;
  margin: 10px 0 0;
  padding: 0 clamp(8px, 3vw, 16px);
  max-width: 340px;
  color: var(--hm-text, #383751);
  font-size: 0.95rem;
  line-height: 1.55;
  font-weight: 400;
}

.hm-cta-tooltip {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  /* Reference .cta-desc: plain text, no card chrome */
  background: transparent;
  color: var(--hm-text, #383751);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  padding: 0;
  border: none;
  border-radius: 0;
  white-space: normal;
  width: min(340px, calc(100vw - 24px));
  max-width: min(340px, calc(100vw - 24px));
  box-shadow: none;
  pointer-events: none;
  z-index: 30;
  text-align: center;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.18s ease, visibility 0.18s ease;
  box-sizing: border-box;
}

.hm-cta-tooltip::after {
  display: none;
}

.hm-cta.is-tooltip-below .hm-cta-tooltip {
  bottom: auto;
  top: calc(100% + 12px);
}

.hm-cta.is-tooltip-below .hm-cta-tooltip::after {
  display: none;
}

.hm-cta.is-tooltip-open .hm-cta-tooltip {
  visibility: visible;
  opacity: 1;
}

/* Tablet landscape: same reference row width; slightly tighter vertical rhythm */
@media (max-width: 1024px) and (min-width: 768px) {
  .hm-cta-section,
  .hm-cta-grid,
  .elementor-element.hm-cta-grid > .e-con-inner {
    margin-top: clamp(28px, 5vw, 48px);
  }
}

/* Mobile: vertical stack (reference demo) — icon, heading, description per CTA */
@media (max-width: 767px) {
  .elementor-element.hm-cta-grid.e-con {
    margin-top: 0;
    padding-top: 0;
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }

  .elementor-element.hm-cta-grid > .e-con-inner {
    padding-left: 0;
    padding-right: 0;
  }

  .hm-cta-section,
  .hm-cta-grid,
  .elementor-element.hm-cta-grid > .e-con-inner {
    grid-template-columns: 1fr;
    justify-items: center;
    width: 100%;
    max-width: calc(100% - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
    gap: clamp(24px, 6vw, 38px);
    margin-top: 0;
    margin-inline: auto;
    /* Top gap comes from hero margin-bottom (--hm-mobile-book-cta-gap in hero.css). */
    padding: 0 0 clamp(28px, 6vw, 40px);
  }

  .elementor-element.hm-cta-grid > .e-con-inner > .elementor-element {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: none !important;
  }

  .hm-cta {
    padding: 0 8px;
    min-height: 44px;
    max-width: 340px;
    margin-inline: auto;
  }

  .hm-cta-icon {
    width: 90px;
    height: 90px;
    margin: 0 auto 10px;
    object-fit: contain;
  }

  .hm-cta h3 {
    font-size: 19px;
    line-height: 1.25;
    letter-spacing: normal;
    text-transform: none;
    font-weight: 700;
  }

  .hm-cta-desc {
    display: block;
    margin-top: 10px;
    margin-inline: auto;
    max-width: 300px;
    font-size: 0.95rem;
    line-height: 1.55;
    text-align: center;
  }

  .hm-cta-tooltip {
    display: none;
    visibility: hidden;
    opacity: 0;
  }

  .hm-cta.is-tooltip-open .hm-cta-tooltip {
    display: none;
    visibility: hidden;
    opacity: 0;
  }

  .hm-cta:hover .hm-cta-icon,
  .hm-cta:focus-within .hm-cta-icon {
    transform: none;
  }
}

/*
 * Desktop CTA titles — reference .cta-title @ 1280: 32px / 40px.
 * Placed after base .hm-cta h3 so min-width:768 wins over 1.35rem.
 */
@media (min-width: 768px) {
  .hm-cta h3 {
    font-size: 32px;
    line-height: 40px;
    font-weight: 700;
  }

  /*
   * Reference .cta-desc: copy below icon + title (static flow), fades in on hover.
   * Tooltip span is first in DOM — flex order places it after h3.
   */
  .hm-cta-icon {
    order: 1;
  }

  .hm-cta h3 {
    order: 2;
  }

  .hm-cta-tooltip {
    order: 3;
    position: static;
    inset: auto;
    transform: none !important;
    width: 100%;
    max-width: 100%;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition:
      opacity 0.2s ease,
      max-height 0.25s ease,
      visibility 0.2s ease,
      margin 0.2s ease;
  }

  .hm-cta.is-tooltip-open .hm-cta-tooltip {
    visibility: visible;
    opacity: 1;
    max-height: 8em;
    margin-top: 15px;
  }

  .hm-cta.is-tooltip-below .hm-cta-tooltip {
    top: auto;
    bottom: auto;
  }
}

/*
 * CTA spacing only (hero artwork / object-position rules live in hero.css — do not change there).
 */
.hm-landing .hm-hero-read,
section.hm-hero.hm-elementor-hero-block .hm-hero-read {
  margin-top: clamp(16px, 3vw, 24px);
  padding-bottom: clamp(10px, 1.6vw, 16px);
}

@media (min-width: 768px) {
  .hm-landing .hm-hero-read,
  section.hm-hero.hm-elementor-hero-block .hm-hero-read {
    margin-top: clamp(22px, 2vw, 34px) !important;
    padding-bottom: clamp(12px, 1.4vw, 18px);
  }

  .hm-landing > .hm-cta-grid,
  .elementor-element.hm-cta-grid.e-con {
    margin-top: clamp(36px, 5.5vw, 60px) !important;
  }
}

@media (max-width: 767px) {
  .hm-landing .hm-hero-read,
  section.hm-hero.hm-elementor-hero-block .hm-hero-read {
    margin-top: clamp(14px, 3.5vw, 22px) !important;
  }

  .hm-landing > .hm-cta-grid {
    margin-top: clamp(22px, 6vw, 34px);
  }
}
