/**
 * 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;
  /* How far the fixed stack is currently pulled up, written by header.js as
     the page scrolls. Zero here so the header is correct before the footer
     script has run, and for anyone with JS off: the strip simply stays put,
     which is the behaviour it shipped with. */
  --hello-notice-shift: 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 54px 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: 54px;
}

/* 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 {
  /**
   * Load-bearing, not tidiness: this is the containing block for the link's
   * stretched hit area below.
   *
   * Without it that overlay resolves against the next positioned ancestor,
   * which is the FIXED inner -- the whole header. The strip's link would
   * quietly cover the logo and all three buttons, and Get 7 Days Free would
   * start going wherever the sale banner pointed.
   */
  position: relative;
  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;
}

/**
 * No hover state, deliberately -- which takes a rule rather than no rule.
 *
 * Dropping the underline on hover was fine while the label WAS the link. Now
 * that the hit area is the whole strip, hovering anywhere -- the far end,
 * 800px away -- restyles a word the pointer is nowhere near. Nothing
 * explains why it changed, so it reads as a glitch rather than as feedback.
 *
 * Deleting this plugin's hover rule did not fix it: the underline still went,
 * because something in the theme's 90-odd stylesheets removes it too and our
 * rule had only been agreeing with it. So the resting state is re-asserted
 * explicitly, doubled up on .hello-header to outscore it.
 *
 * The cursor is the affordance instead: it is a pointer everywhere on the
 * strip, which says the strip is clickable without a word of it twitching.
 *
 * :focus is held to the same resting appearance. Losing an underline was
 * never a focus indicator -- the browser's own ring on the label is, and it
 * is left alone to do that.
 */
.hello-header .hello-header__notice-link:hover,
.hello-header .hello-header__notice-link:focus {
  /* Every property the resting state sets, restated. The theme changes two
     of them on hover -- it drops the underline AND recolours the label pink
     -- so pinning one just revealed the other. */
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/**
 * The whole strip is the link, not just the label at the end of it.
 *
 * Same stretched pseudo-element as the plan cards: one real anchor, so
 * middle-click and cmd-click still work, there is no second tab stop, and the
 * strip's own copy is not read out as a link name. It only exists when a
 * label does, since the anchor is what carries it -- a strip with no label
 * has nothing to be clicked through to.
 *
 * No transform trap here, unlike the cards: this link's hover drops an
 * underline rather than lifting the element, so the overlay's containing
 * block never changes under the pointer.
 */
.hello-header__notice-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.hello-header__notice-close {
  flex: 0 0 auto;
  /* Was already relative, for the two bars of the cross. Now it is also what
     lets the z-index lift the button clear of the link's overlay -- buried
     under it, the strip could be followed but never dismissed. */
  position: relative;
  z-index: 2;
  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));
}

/**
 * The notice sticks to the page, the nav sticks to the viewport.
 *
 * Both are inside this one fixed element, so instead of splitting them the
 * whole thing is pulled up by however far the page has scrolled, capped at the
 * strip's height (header.js, which writes --hello-notice-shift). At the top of
 * the page nothing has moved; 54px down the strip has gone and the bar is at
 * top: 0; past that nothing moves again.
 *
 * transform rather than `top`: it is composited, so a per-frame scroll handler
 * costs a paint rather than a layout, and it leaves the top offsets below free
 * to mean what they say. No transition -- see header.js.
 *
 * The transform makes this a containing block for fixed descendants, which is
 * free here because the header has none; it also makes a stacking context,
 * which changes nothing since z-index is already set on this element.
 */
.hello-header--sticky .hello-widget__inner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  transform: translateY(calc(var(--hello-notice-shift, 0px) * -1));
  /* 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 6px 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.
   *
   * Scaled with the wide one (36 -> 54, 32 -> 48) rather than kept where it
   * was: the two have to stay close or the strip is a different thing on a
   * phone than it is on a desktop.
   *
   * 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: 48px;
  }

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