/**
 * Hello Home — landing-page header.
 *
 * Logo left, buttons right, on a white bar. Stands in for the theme header
 * on a page where the site menu is more exit than navigation.
 *
 * Matches the theme's own bar closely enough that the swap is not obvious:
 * 65px tall, logo around 130px wide, small buttons hard right.
 */

/**
 * The theme header goes when this one is present.
 *
 * Safe to put in a stylesheet rather than in page CSS because this file is
 * registered globally but only ENQUEUED when the widget actually renders --
 * so the rule reaches exactly the pages carrying a replacement header, and
 * nothing else. Dropping the widget from a page restores the site header on
 * its own, with nothing to remember to undo.
 *
 * Hiding #masthead is only half of it. The theme header is position: fixed,
 * so it is out of flow and the space for it is reserved by padding on
 * #content -- NOT on body, which is what misled the first version of this
 * rule. Hide the header without clearing that padding and you get 65px of
 * page background above the replacement, which on this site's dark body
 * reads as a black bar.
 */
#masthead {
  display: none;
}

#content.site-content {
  padding-top: 0;
}

.hello-header {
  --hello-pad-y: 0;
  --hello-pad-x: clamp(16px, 3vw, 40px);
  --hello-width: 100%;
  /* No strip unless PHP says there is one. The sticky spacer adds this to
     its own height, so zero here keeps a header without a notice at exactly
     the height it has always been. */
  --hello-notice-h: 0px;
  background: var(--hello-bg, #fff);
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}

/* ---- notice strip ------------------------------------------------------- */

/**
 * A sale line above the bar, inside the same fixed inner.
 *
 * ONE LINE, enforced rather than requested. The strip's height has to be
 * known to the in-flow spacer below (.hello-header--sticky) or the page slides
 * under the fixed header, and a height that depends on whether the copy wrapped
 * is not knowable from CSS -- it would have to be measured in JS and written
 * back, on load and on every resize, with the layout wrong for the frames in
 * between. nowrap removes the question: the strip is 36px because this file
 * says so, and copy too long to fit is trimmed with an ellipsis.
 *
 * The trade is real -- long copy gets cut -- so the field says so, and the
 * ellipsis is deliberately visible rather than a clean cut, so an editor who
 * writes an essay can see that it did not fit.
 */
.hello-header--has-notice {
  --hello-notice-h: 36px;
}

/* Dismissal removes the class, which both hides the strip and gives its space
   back to the page in one move -- hence :not() rather than a second class. */
.hello-header:not(.hello-header--has-notice) .hello-header__notice {
  display: none;
}

.hello-header__notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  height: var(--hello-notice-h);
  /* Edge to edge: cancel the inner's gutter, then put it back as padding so
     the text still clears the screen edge. */
  margin: 0 calc(var(--hello-pad-x) * -1);
  padding: 0 clamp(12px, 3vw, 40px);
  background: var(--hello-notice-bg, #0d0d0d);
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
}

.hello-header--notice-dark .hello-header__notice {
  color: #fff;
}

.hello-header--notice-light .hello-header__notice {
  color: #0d0d0d;
}

/**
 * min-width: 0 genuinely works here, unlike on the hero's grid items: this is
 * a flex item at its normal stretch, not something taken to fit-content by an
 * auto margin, so there is no min-content floor to fight.
 */
.hello-header__notice-text {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/**
 * The phone's own sentence, when one has been written. Hidden here and swapped
 * in by the narrow block at the foot of this file.
 *
 * A second string beats a cleverer truncation: the strip fits roughly 25-30
 * characters on a phone once the link and the close button have taken theirs,
 * and an ellipsis cuts whatever happens to be last rather than what matters
 * least. Blank, the full copy is used at every width and trims as before.
 */
.hello-header__notice-short {
  display: none;
}

/* The copy gives way before the call to action does -- a trimmed sentence
   still sells, a trimmed link is just a dead end. */
.hello-header__notice-link {
  flex: 0 0 auto;
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hello-header__notice-link:hover,
.hello-header__notice-link:focus {
  text-decoration: none;
}

.hello-header__notice-close {
  flex: 0 0 auto;
  position: relative;
  width: 24px;
  height: 24px;
  margin-right: -6px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  opacity: 0.65;
}

.hello-header__notice-close:hover,
.hello-header__notice-close:focus {
  opacity: 1;
}

.hello-header__notice-close::before,
.hello-header__notice-close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 11px;
  height: 1.5px;
  background: currentColor;
}

.hello-header__notice-close::before { transform: translate(-50%, -50%) rotate(45deg); }
.hello-header__notice-close::after  { transform: translate(-50%, -50%) rotate(-45deg); }

.hello-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 65px;
}

/* ---- logo --------------------------------------------------------------- */

.hello-header__logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
}

.hello-header__logo-img {
  display: block;
  width: auto;
  height: 38px;
  /* The theme rounds images in post content; a logo has no corners to round. */
  border-radius: 0;
}

/* ---- buttons ------------------------------------------------------------ */

.hello-header__actions {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.2vw, 16px);
}

/* Smaller than the page's calls to action: this is chrome, not the pitch. */
.hello-header .hello-btn.hello-header__btn {
  padding: 9px 20px;
  border-width: 2px;
  font-size: 14px;
  white-space: nowrap;
}

/**
 * "Quiet" is the old nav item -- Shop was a menu link, and DC want it as a
 * button without it competing with Get 7 Days Free. Plain text until it is
 * hovered, then it picks up the accent.
 */
.hello-header .hello-btn.hello-header__btn--quiet {
  background: transparent;
  border-color: transparent;
  color: inherit;
}
.hello-header .hello-btn.hello-header__btn--quiet:hover,
.hello-header .hello-btn.hello-header__btn--quiet:focus-visible {
  background: transparent;
  border-color: transparent;
  color: var(--hello-accent);
}

/* ---- optional sticky ---------------------------------------------------- */

/**
 * Fixed, not sticky -- and the INNER is what gets fixed, not the section.
 *
 * position:sticky was the obvious implementation and it never worked on a
 * builder page. Sticky can only travel inside its own parent's box, and
 * WPBakery wraps a shortcode in wpb_wrapper > vc_column-inner > wpb_column >
 * vc_row, every one of which is exactly as tall as the header itself. Zero
 * range, so the bar scrolled away like any static element. Measured on the
 * hybrid page: the header's top went from 0 to -1200 after a 1200px scroll.
 *
 * Fixing the inner rather than the section is what keeps the layout honest.
 * A fixed element is out of flow, so fixing the section would collapse it to
 * nothing and yank the whole page up 65px. Here the section stays in flow as
 * an empty strip of exactly the bar's height -- it holds the space open --
 * and the inner is lifted out of it to the top of the viewport. The strip is
 * never actually seen: at the top of the page the bar covers it exactly, and
 * once scrolled it is above the viewport.
 *
 * This escapes the row containment entirely. The one thing that would break
 * it is an ancestor with a transform, filter or contain, since those make a
 * containing block for fixed children -- none on the chain today, and
 * WPBakery only adds them when a row animation is switched on.
 */
/* 65px of bar plus the 1px rule under it, plus the notice strip when there is
   one. The spacer has to match the fixed bar's OUTER height or the page sits a
   pixel high -- and --hello-notice-h is 0 unless PHP added the notice class,
   so this is the old 66px on a header without one. */
.hello-header--sticky {
  min-height: calc(66px + var(--hello-notice-h));
}

.hello-header--sticky .hello-widget__inner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  /* The background and rule come with it -- they were on the section, which
     is now just the spacer left behind. */
  background: var(--hello-bg, #fff);
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
}

/**
 * The admin bar is fixed at the top for logged-in users, so the header has to
 * start below it or the two overlap. WordPress's own breakpoints: 32px tall
 * normally, 46px at 782px and under, and below 601px it switches to
 * position:absolute and scrolls away with the page -- so the header takes the
 * top back.
 *
 * No z-index fight: the admin bar sits at 99999 and this at 60, so it stays
 * above where it belongs.
 */
body.admin-bar .hello-header--sticky .hello-widget__inner {
  top: 32px;
}

@media screen and (max-width: 782px) {
  body.admin-bar .hello-header--sticky .hello-widget__inner {
    top: 46px;
  }
}

@media screen and (max-width: 600px) {
  body.admin-bar .hello-header--sticky .hello-widget__inner {
    top: 0;
  }
}

/* ---- narrow ------------------------------------------------------------- */

@media (max-width: 599px) {
  /**
   * The logo shrinks before the buttons do. Losing a call to action costs
   * more than losing a few pixels of wordmark, and at this width the three
   * buttons are already the tighter constraint.
   */
  .hello-header__logo-img {
    height: 30px;
  }
  .hello-header .hello-btn.hello-header__btn {
    padding: 8px 12px;
    font-size: 13px;
  }
  .hello-header__bar {
    min-height: 56px;
  }

  /* The spacer tracks the bar it is holding space for: 56 + the 1px rule. */
  .hello-header--sticky {
    min-height: calc(57px + var(--hello-notice-h));
  }

  /**
   * The strip loses 4px and a little type here. It is the one place the
   * single-line rule bites hardest -- a phone has roughly half the width to
   * say the same thing in -- so the gaps tighten too, buying a few more
   * characters before the ellipsis.
   *
   * After this block in source order on purpose: same specificity as the
   * unprefixed .hello-header--has-notice, so it is the later rule that wins.
   */
  .hello-header--has-notice {
    --hello-notice-h: 32px;
  }

  .hello-header__notice {
    gap: 10px;
    font-size: 12px;
  }

  /* The swap. Only where a short version exists -- without the class the long
     copy stays put and ellipsises, rather than the strip going blank. */
  .hello-header--has-short-notice .hello-header__notice-long {
    display: none;
  }

  .hello-header--has-short-notice .hello-header__notice-short {
    display: inline;
  }
}
