/* ==========================================================================
 * Soulcraft Lead Magnet Popup
 * --------------------------------------------------------------------------
 * There is not a single hardcoded color, font or radius in this file. Every one
 * is a CSS custom property set by the active brand preset in PHP. That is the
 * point: a second brand is a preset, not a second stylesheet.
 *
 * Selector specificity is kept deliberately LOW (mostly 0-1-0 and 0-1-1) so the
 * responsive rules at the bottom can override the desktop rules at the top.
 * Raising the base specificity to win a fight with a theme is a trap: it also
 * beats every media query in here, which is how a headline ends up frozen at
 * desktop size on a phone. If a theme is genuinely overriding something, use
 * the Elementor-compatibility toggle or Additional CSS, not this file.
 * ========================================================================== */

body.bb-lead-modal-open { overflow: hidden; }

/* --------------------------------------------------------------------------
 * FLOATING BUTTON
 * -------------------------------------------------------------------------- */

.bbfloatwrap {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 99990;
}

.bbfloatbutton {
  background: var(--bb-button-bg);
  color: var(--bb-button-text);
  font-family: var(--bb-body-font);
  border: none;
  border-radius: var(--bb-radius);
  padding: 16px 24px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
  animation: bbBob 4.5s ease-in-out infinite;
  transition: background-color .2s ease, box-shadow .2s ease;
}

/* Feedback is background + shadow, NOT transform. The bbBob animation below
 * owns `transform` on this element, so a scale() here would be overwritten on
 * the next animation frame and appear to do nothing. */
.bbfloatbutton:hover {
  background: var(--bb-hover-bg);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.26);
}

.bbfloatbutton:focus-visible {
  outline: 2px solid var(--bb-hover-bg);
  outline-offset: 3px;
}

@keyframes bbBob {
  0%   { transform: translateY(0); }
  50%  { transform: translateY(-8px); }
  100% { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .bbfloatbutton { animation: none; }
}

/* --------------------------------------------------------------------------
 * MODAL SHELL
 * -------------------------------------------------------------------------- */

.bbmodaloverlay {
  position: fixed;
  inset: 0;
  background: var(--bb-overlay-bg);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 20px;
  overflow-y: auto;
}

.bbmodaloverlay.bbshow { display: flex; }

.bbmodalbox {
  width: 980px;
  max-width: 100%;
  max-height: 92vh;
  background: var(--bb-modal-bg);
  border-radius: var(--bb-radius);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  /* minmax(0, 1fr), not the default `auto`.
   *
   * Grid rows size to CONTENT by default, so the row grows to the form's full
   * height while the box stays capped at max-height. The row then overflows and
   * is clipped by overflow:hidden, and .bbmodalright never becomes scrollable
   * because nothing ever constrains it -- the submit button becomes physically
   * unreachable. min-height:0 alone does NOT fix this; the ROW has to be told
   * it may shrink, which is exactly what minmax(0, 1fr) does. */
  grid-template-rows: minmax(0, 1fr);
  position: relative;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  font-family: var(--bb-body-font);
}

/* No image configured: one clean column instead of an empty panel. */
.bb-no-image .bbmodalbox {
  grid-template-columns: 1fr;
  width: 560px;
}

.bbmodalclose {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 44px;
  height: 44px;
  border: none;
  background: var(--bb-close-bg);
  color: var(--bb-button-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
  border-radius: var(--bb-radius);
  cursor: pointer;
  z-index: 10;
  transition: background-color .2s ease, transform .2s ease;
}

/* This one has no animation, so transform IS available here. */
.bbmodalclose:hover {
  background: var(--bb-hover-bg);
  transform: scale(1.08);
}

.bbmodalclose:focus-visible {
  outline: 2px solid var(--bb-hover-bg);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
 * IMAGE PANEL
 * -------------------------------------------------------------------------- */

.bbmodalleft,
.bbmodalright {
  /* Required. Without it grid items refuse to shrink below their content size
   * and the modal content gets clipped by the box's overflow:hidden. */
  min-height: 0;
}

.bbimagepanel {
  height: 100%;
  background-size: cover;
  background-position: center;
  position: relative;
}

.bbimageoverlaytext {
  position: absolute;
  left: 24px;
  bottom: 24px;
  color: #fff;
  background: rgba(0, 0, 0, .35);
  padding: 8px 16px;
  border-radius: var(--bb-radius);
  font-size: 13px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* --------------------------------------------------------------------------
 * CONTENT COLUMN
 * -------------------------------------------------------------------------- */

.bbmodalright {
  padding: 48px 44px 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
}

.bbkicker {
  display: inline-block;
  background: var(--bb-accent-bg);
  color: var(--bb-accent-text);
  padding: 6px 18px;
  border-radius: var(--bb-radius);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 20px;
  width: fit-content;
}

.bbmodalright h2 {
  color: var(--bb-heading);
  font-family: var(--bb-heading-font);
  font-size: var(--bb-heading-size);
  font-weight: var(--bb-heading-weight);
  text-transform: var(--bb-heading-tt);
  letter-spacing: var(--bb-heading-ls);
  line-height: 1.06;
  margin: 0 0 14px 0;
}

.bbsubcopy {
  font-size: 17px;
  line-height: 1.5;
  color: #4b4b4b;
  margin: 0 0 22px 0;
}

.bbfineprint {
  font-size: 12px;
  line-height: 1.5;
  color: #777;
  margin: 16px 0 0 0;
}

.bbnothanks {
  margin-top: 18px;
  align-self: center;
  background: none;
  border: none;
  color: #666;
  font-size: 15px;
  cursor: pointer;
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
 * CONTACT FORM 7 INSIDE THE MODAL
 * --------------------------------------------------------------------------
 * CF7 renders its own <form class="wpcf7-form"> and wraps every field in a <p>.
 * None of the generic form styling above reaches it, so without this block the
 * form renders as raw browser defaults inside an otherwise finished modal.
 * -------------------------------------------------------------------------- */

.bbcf7wrap .wpcf7-form p { margin: 0; }
.bbcf7wrap .wpcf7-form .bbfieldwrap { margin-bottom: 14px; }
.bbcf7wrap .wpcf7-form-control-wrap { display: block; }

/* Paired fields side by side (first/last, email/phone) */
.bbcf7wrap .bbnamerow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* CF7 runs its own autop over the form template, so two field tags written on
 * separate lines inside a wrapper div come out wrapped in a single <p>. The
 * grid above then sees ONE child, puts it in column 1, and both fields stack
 * inside it at half width -- which looks like the grid silently failed.
 *
 * `display: contents` removes the <p> from the box tree so its children become
 * the grid items directly, which is what the markup was always meant to
 * produce. Keeping this as a CSS rule rather than only fixing the template
 * means the layout survives someone editing the form in the CF7 editor later
 * and reintroducing the line break. */
.bbcf7wrap .bbnamerow > p { display: contents; }

/* And CF7's autop puts a <br> between the two fields.
 *
 * This is the part that actually bites. Once the <p> is display:contents, that
 * <br> is no longer an inline line break inside a paragraph -- it is a sibling
 * of the two fields and therefore a GRID ITEM in its own right. It silently
 * eats column 2 of row 1, pushing the second field down to row 2 column 1. The
 * visible symptom is two half-width fields stacked vertically, which reads as
 * "the grid didn't apply" rather than "there is an invisible third item".
 *
 * Scoped to .bbnamerow so line breaks anywhere else in the form still work. */
.bbcf7wrap .bbnamerow br { display: none; }

.bbcf7wrap .wpcf7-form input[type="text"],
.bbcf7wrap .wpcf7-form input[type="email"],
.bbcf7wrap .wpcf7-form input[type="tel"],
.bbcf7wrap .wpcf7-form input[type="date"],
.bbcf7wrap .wpcf7-form select {
  width: 100%;
  border: 1px solid #111;
  border-radius: var(--bb-radius);
  background: #fff;
  color: #111;
  font-family: var(--bb-body-font);
  padding: 14px;
  /* Never drop below 16px. iOS Safari zooms the whole page when a field with a
   * smaller font receives focus, which throws the modal off screen. */
  font-size: 16px;
  box-sizing: border-box;
}

.bbcf7wrap .bbdatelabel {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: #4b4b4b;
}

.bbcf7wrap .wpcf7-form input[type="submit"] {
  width: 100%;
  border: none;
  background: var(--bb-submit-bg);
  color: var(--bb-submit-text);
  font-family: var(--bb-body-font);
  border-radius: var(--bb-radius);
  padding: 16px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
  margin-top: 4px;
  transition: background-color .2s ease;
}

.bbcf7wrap .wpcf7-form input[type="submit"]:hover {
  background: var(--bb-hover-bg);
}

/* Some themes ship an UNSCOPED `input[type="date"]::before { content: "..." }`
 * to fake a label, because date inputs cannot take a placeholder. It applies to
 * every date input on the site, duplicates the real <label> this form has, and
 * inflates the control height by adding a line box inside it. It is also
 * unreliable -- ::before on a replaced element is not guaranteed to render, so
 * Chrome shows it and Firefox does not. Killed here, scoped to the popup so
 * other forms on the site keep whatever behaviour they had. */
.bbcf7wrap input[type="date"]::before { content: none; }

.bbcf7wrap .wpcf7-not-valid-tip { font-size: 13px; margin-top: 4px; }

.bbcf7wrap .wpcf7-response-output {
  margin: 12px 0 0 0 !important;
  padding: 8px 10px !important;
  font-size: 14px;
  border-radius: var(--bb-radius);
}

/* CF7 only hides its status box while the form carries the `init`, `resetting`
 * or `submitting` class. It does NOT hide it during `validating`, which is the
 * class applied while CF7 checks a field over REST after the visitor tabs out
 * of it. Net effect on a real fill-in: an empty box with a 2px blue border pops
 * into existence under the submit button as soon as they leave the first field,
 * and stays there.
 *
 * Keying on :empty rather than on the class list fixes it for every state that
 * has nothing to say, including any CF7 adds later. Verified :empty matches --
 * CF7 leaves zero child nodes, not a whitespace text node, so this is safe. */
.bbcf7wrap .wpcf7-response-output:empty {
  display: none !important;
}

.bbcf7wrap .wpcf7-spinner { display: block; margin: 8px auto 0; }

/* ==========================================================================
 * RESPONSIVE
 * --------------------------------------------------------------------------
 * Two independent axes, and they are queried separately on purpose.
 *
 * WIDTH handles layout: below 1100px there is no room for the two-column photo
 * layout to look right, so the image is dropped and the modal becomes a single
 * column form that fits at any width.
 *
 * HEIGHT handles density on short desktop windows.
 *
 * The trap worth naming: a modern phone reports a CSS viewport TALLER than
 * 820px, so a `max-height: 820px` query never fires on the devices that most
 * need compaction. Phone compaction therefore lives in the max-width: 600px
 * block, not the height block.
 * ========================================================================== */

@media (max-width: 1100px) {
  .bbmodalbox {
    grid-template-columns: 1fr;
    max-height: 94vh;
    width: 560px;
  }
  .bbmodalleft { display: none; }
  .bbmodalright { padding: 24px 22px; }

  /* Reserve room so neither the kicker nor the headline runs under the
   * absolutely-positioned close button (44px wide at 14px from the edge). */
  .bbkicker { margin-right: 56px; }
  .bbmodalright h2 { padding-right: 56px; }
}

@media (max-height: 820px) {
  .bbmodalright { padding: 16px 22px; }
  .bbkicker { margin-bottom: 8px; }
  .bbmodalright h2 { font-size: 30px; margin-bottom: 6px; }
  .bbsubcopy { font-size: 15px; line-height: 1.4; margin-bottom: 12px; }
  .bbcf7wrap .wpcf7-form .bbfieldwrap { margin-bottom: 8px; }
  .bbcf7wrap .wpcf7-form input[type="text"],
  .bbcf7wrap .wpcf7-form input[type="email"],
  .bbcf7wrap .wpcf7-form input[type="tel"],
  .bbcf7wrap .wpcf7-form input[type="date"],
  .bbcf7wrap .wpcf7-form select { padding: 10px 12px; }
  .bbcf7wrap .wpcf7-form input[type="submit"] { padding: 12px 16px; }
  .bbfineprint { margin-top: 8px; font-size: 11px; }
}

@media (max-width: 600px) {
  .bbmodaloverlay { padding: 10px; }

  .bbmodalbox {
    grid-template-columns: 1fr;
    max-height: 94vh;
    width: 100%;
  }

  .bbmodalright { padding: 22px 18px 16px; }

  .bbkicker {
    margin-bottom: 14px;
    margin-right: 56px;
    font-size: 10px;
  }

  .bbmodalright h2 {
    font-size: 26px;
    line-height: 1.05;
    margin-bottom: 6px;
    padding-right: 56px;
  }

  /* The subcopy is the single biggest vertical cost on a phone (three lines).
   * The kicker and headline already establish what this is, so it goes. */
  .bbsubcopy { display: none; }

  /* Stack paired fields. Without restoring the margin the collapsed rows sit
   * flush against each other. */
  .bbcf7wrap .bbnamerow { grid-template-columns: 1fr; gap: 0; }
  .bbcf7wrap .bbnamerow .wpcf7-form-control-wrap { margin-bottom: 8px; display: block; }

  .bbcf7wrap .wpcf7-form .bbfieldwrap { margin-bottom: 8px; }
  .bbcf7wrap .bbdatelabel { margin-bottom: 2px; font-size: 12px; }

  .bbcf7wrap .wpcf7-form input[type="text"],
  .bbcf7wrap .wpcf7-form input[type="email"],
  .bbcf7wrap .wpcf7-form input[type="tel"],
  .bbcf7wrap .wpcf7-form input[type="date"],
  .bbcf7wrap .wpcf7-form select { padding: 10px 12px; font-size: 16px; }

  .bbcf7wrap .wpcf7-form input[type="submit"] { padding: 13px 16px; margin-top: 4px; }

  /* iOS Safari gives <input type="date"> its own inflated height and centers
   * the value, ignoring the padding that sizes every other field, so it ends up
   * visibly taller than its neighbours. Strip the native appearance and reset
   * the internal date pseudo-elements. Scoped to phones so the desktop calendar
   * icon, which depends on native appearance, is left alone. */
  .bbcf7wrap .wpcf7-form input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    min-height: 43px;
    padding: 9px 12px;
    line-height: 1.2;
    text-align: left;
  }
  .bbcf7wrap .wpcf7-form input[type="date"]::-webkit-date-and-time-value {
    text-align: left;
    margin: 0;
  }
  .bbcf7wrap .wpcf7-form input[type="date"]::-webkit-datetime-edit {
    padding: 0;
    line-height: 1.2;
  }

  .bbfineprint { margin-top: 8px; font-size: 11px; line-height: 1.35; }

  .bbfloatwrap { right: 14px; bottom: 14px; }
  .bbfloatbutton { font-size: 14px; padding: 14px 18px; }
}
