/**
 * Moust Boost — Block & primitive styles
 * Depends on assets/css/tokens.css. See BRAND-GUIDELINES.md.
 */

/* =========================================================
   Motion primitive

   Entry animations are gated on `html.mb-js`, a class added by
   assets/js/animate-on-scroll.js at runtime. That script is only enqueued on
   the front end, so inside the block editor the class never exists and content
   renders fully visible and static — no disorienting invisible text while
   editing. It also means content is visible if JS fails or is disabled.
   ========================================================= */

@keyframes mbFadeUp {
  from {
    opacity: 0;
    transform: translateY(var(--mb-fade-distance, 0.875rem));
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================================================
   Layout primitives
   ========================================================= */

.mb-container {
  max-width: var(--mb-container);
  margin: 0 auto;
  padding: 0 var(--mb-container-gutter);
}

.mb-container--narrow {
  max-width: var(--mb-container-narrow);
}

.mb-container--wide {
  max-width: var(--mb-container-wide);
}

.mb-section {
  padding: var(--mb-section-padding) 0;
  position: relative;
}

.mb-section--reduced-padding {
  padding-top: var(--mb-section-padding-reduced) !important;
}

/* Background options (shared by all section blocks) */
.mb-section--bg-transparent { background: transparent; }
.mb-section--bg-primary { background: var(--mb-bg-primary); }
.mb-section--bg-secondary { background: var(--mb-bg-secondary); }
.mb-section--bg-tertiary { background: var(--mb-bg-tertiary); }
.mb-section--bg-elevated { background: var(--mb-bg-elevated); }
.mb-section--bg-surface-subtle { background: var(--mb-surface-subtle); }
.mb-section--bg-surface-default { background: var(--mb-surface-default); }

/* Full-bleed escape for blocks rendered inside a constrained container.
 *
 * `100vw` includes the vertical scrollbar gutter, so using it directly makes
 * the section wider than the document and causes horizontal scroll. The
 * `calc(100vw - (100vw - 100%))` idiom resolves to the parent's true inner
 * width when the parent is full-width, minus the scrollbar — giving an exact
 * bleed with no overshoot. */
.mb-section.alignfull,
.mb-bleed {
  width: calc(100vw - (100vw - 100%));
  max-width: calc(100vw - (100vw - 100%));
  margin-left: calc(50% - 50vw + (100vw - 100%) / 2);
  margin-right: calc(50% - 50vw + (100vw - 100%) / 2);
}

/* =========================================================
   Button primitive

   Shared by every block's CTA — use `.mb-button` rather than restyling a
   button per block, so the system stays consistent. Colours come from the
   --mb-button-* tokens.

   Hover deliberately drops the fill for a white outline instead of shifting
   hue. The border is present (transparent) at rest so the box never resizes
   on hover.
   ========================================================= */

.mb-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: var(--mb-button-padding);
  border: var(--mb-button-border-width) solid var(--mb-button-border);
  border-radius: var(--mb-radius-sm);
  background: var(--mb-button-bg);
  color: var(--mb-button-text);
  font-family: inherit;
  font-size: var(--mb-font-size-base);
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background var(--mb-duration-fast) var(--mb-ease),
    border-color var(--mb-duration-fast) var(--mb-ease),
    color var(--mb-duration-fast) var(--mb-ease);
}

.mb-button:hover,
.mb-button:focus-visible {
  background: var(--mb-button-bg-hover);
  border-color: var(--mb-button-border-hover);
  color: var(--mb-button-text-hover);
  opacity: 1; /* override the global `a:hover` fade */
}

.mb-button:focus-visible {
  outline: 0.125rem solid var(--mb-button-border-hover);
  outline-offset: 0.125rem;
}

/* Icons sit subordinate to the label — noticeably smaller than the text. */
.mb-button svg,
.mb-button [data-lucide] {
  width: var(--mb-button-icon-size);
  height: var(--mb-button-icon-size);
  flex-shrink: 0;
  stroke-width: 2;
}

/* Quiet variant — outlined, low-contrast at rest.
 *
 * For lists where the CTA repeats on every row. A filled accent button is
 * right when there's one of them; twenty of them turn the page into a wall of
 * colour and nothing reads as primary any more. This states its presence and
 * resolves on hover instead.
 */
.mb-button--quiet {
  padding: 0.5rem 1rem;
  background: transparent;
  border-color: var(--mb-border-strong);
  color: var(--mb-text-secondary);
  font-size: var(--mb-font-size-sm);
  text-transform: none;
}

.mb-button--quiet:hover,
.mb-button--quiet:focus-visible {
  background: transparent;
  border-color: var(--mb-text-primary);
  color: var(--mb-text-primary);
}

/* =========================================================
   Hero block — mb-hero
   The site header is an invisible overlay; the hero reserves
   headroom rather than rendering a logo of its own.
   ========================================================= */

.mb-hero {
  display: flex;
  align-items: stretch;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  background: var(--mb-bg-secondary);
}

.mb-hero--auto-height {
  height: auto;
  max-height: none;
  min-height: 36rem;
}

.mb-hero__content {
  flex: 0 0 35%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--mb-header-height) var(--mb-space-lg) var(--mb-space-lg);
  background: var(--mb-bg-secondary);
  position: relative;
  z-index: 2;
}

/* Copy is allowed to overhang the panel and sit over the gradient */
.mb-hero__inner {
  width: 180%;
  max-width: 180%;
}

.mb-hero__eyebrow {
  margin: 0 0 var(--mb-space-sm);
  font-size: var(--mb-font-size-sm);
  font-weight: 600;
  letter-spacing: var(--mb-letter-spacing-meta);
  text-transform: uppercase;
  color: var(--mb-accent);
}

.mb-hero__heading {
  margin: 0;
  font-size: var(--mb-font-size-display);
  font-weight: 700;
  line-height: var(--mb-line-height-display);
  letter-spacing: var(--mb-letter-spacing-display);
  color: var(--mb-text-primary);
  text-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.3);
}

.mb-hero__subheading {
  margin: 0 0 var(--mb-space-sm);
  max-width: 34rem;
  font-size: clamp(1.125rem, 2vw, 1.5rem);
  font-weight: 400;
  line-height: var(--mb-line-height-body);
  color: var(--mb-text-secondary);
}

.mb-hero__meta {
  margin: 0;
  font-size: var(--mb-font-size-sm);
  letter-spacing: var(--mb-letter-spacing-meta);
  color: var(--mb-text-secondary);
}

.mb-hero__footnote {
  margin: var(--mb-space-2xs) 0 0;
  font-size: var(--mb-font-size-sm);
  letter-spacing: var(--mb-letter-spacing-meta);
  color: var(--mb-text-secondary);
}

.mb-hero__footnote-link {
  color: var(--mb-text-primary);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.1875rem;
  transition: opacity var(--mb-duration-fast) var(--mb-ease);
}

.mb-hero__footnote-link:hover {
  opacity: 0.8;
  text-decoration-color: var(--mb-accent);
}

.mb-hero__cta {
  align-self: flex-start;
  margin-top: var(--mb-space-sm);
}

.mb-hero__media {
  flex: 0 0 65%;
  position: relative;
  background-color: var(--mb-bg-primary);
  background-size: cover;
  background-repeat: no-repeat;
  background-position: bottom right;
}

.mb-hero__media--center { background-position: center center; }
.mb-hero__media--center-right { background-position: center right; }
.mb-hero__media--top-right { background-position: top right; }
.mb-hero__media--bottom-center { background-position: bottom center; }

/* Tone treatment
 * Not a true greyscale: the image's luminance is blended over a flat brand
 * colour (--mb-hero-tone, default the navy copy-panel background), so the photo
 * becomes a monochrome wash of that colour and fuses with the hero panel.
 * `filter: none` is explicit so this never stacks with a filter-based grayscale.
 */
.mb-hero__media--tone {
  filter: none;
  background-color: var(--mb-hero-tone, var(--mb-bg-secondary));
  background-blend-mode: luminosity;
}

/* Fallback: browsers without background-blend-mode get a plain desaturation
   rather than a full-strength photo, preserving the intent. */
@supports not (background-blend-mode: luminosity) {
  .mb-hero__media--tone {
    filter: grayscale(1);
  }
}

/* Gradient scrim that fuses the copy panel into the image */
.mb-hero__media::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(
    to right,
    var(--mb-bg-secondary) 0%,
    rgba(17, 24, 39, 0.8) 15%,
    rgba(17, 24, 39, 0.3) 30%,
    transparent 50%
  );
}

/* Entry animation — only when JS is running on the front end.
 *
 * The hero animates as a SINGLE unit rather than staggering its children.
 * Staggering six elements meant the CTA didn't begin until every line above it
 * had started, so the block read as slow and the last item felt disconnected
 * from the first. Moving the copy group as one keeps the lines visually locked
 * together and the whole thing resolves in one duration.
 */
.mb-js .mb-hero__inner {
  opacity: 0;
  transform: translateY(var(--mb-fade-distance, 0.875rem));
}

.mb-js .mb-hero.mb-animate .mb-hero__inner {
  animation: mbFadeUp var(--mb-duration) var(--mb-ease) both;
}

/* =========================================================
   Content Grid block — mb-content-grid
   Universal grid: features, services, credits, process steps.
   ========================================================= */

.mb-grid-section {
  padding: var(--mb-section-padding-lg) 0;
}

.mb-grid-header {
  margin: 0 auto;
  text-align: center;
  max-width: 45rem;
}

.mb-grid-header__heading {
  margin: 0 0 var(--mb-space-sm);
  font-size: var(--mb-font-size-3xl);
  font-weight: 700;
  line-height: var(--mb-line-height-heading);
  letter-spacing: var(--mb-letter-spacing-display);
  color: var(--mb-text-primary);
}

.mb-grid-header--medium .mb-grid-header__heading {
  font-size: var(--mb-font-size-2xl);
}

.mb-grid-header__subheading {
  margin: 0 auto;
  max-width: 40rem;
  font-size: var(--mb-font-size-lg);
  line-height: var(--mb-line-height-body);
  color: var(--mb-text-secondary);
}

/* Optional lead media between header and grid */
.mb-grid-media {
  margin: var(--mb-space-xl) auto var(--mb-space-2xl);
  max-width: 100%;
  overflow: hidden;
  border-radius: var(--mb-radius);
  position: relative;
}

.mb-grid-media img,
.mb-grid-media video {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  margin: 0 auto;
  border: 0.0625rem solid var(--mb-border);
  border-radius: var(--mb-radius-sm);
}

.mb-grid-media__embed {
  position: relative;
  width: 100%;
}

.mb-grid-media__embed iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: var(--mb-radius);
  display: block;
}

/* The grid itself */
.mb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17.5rem, 1fr));
  gap: var(--mb-space-2xl) var(--mb-space-xl);
  margin: 0 auto;
}

.mb-grid--cols-2 { grid-template-columns: repeat(2, 1fr); }
.mb-grid--cols-3 { grid-template-columns: repeat(3, 1fr); }
.mb-grid--cols-4 { grid-template-columns: repeat(4, 1fr); }

.mb-grid-header + .mb-grid {
  margin-top: var(--mb-space-2xl);
}

.mb-grid__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--mb-space-xs);
  text-align: center;
}

.mb-grid--align-left .mb-grid__item {
  align-items: flex-start;
  text-align: left;
}

.mb-grid--align-right .mb-grid__item {
  align-items: flex-end;
  text-align: right;
}

.mb-grid--align-left .mb-grid__item-description,
.mb-grid--align-right .mb-grid__item-description {
  max-width: 100%;
}

.mb-grid__item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 6.25rem;
  height: auto;
  margin-bottom: var(--mb-space-2xs);
}

.mb-grid__item-icon svg {
  width: 3.125rem;
  height: 3.125rem;
  color: var(--mb-text-primary);
  stroke-width: 1;
}

.mb-grid__item-image {
  width: 100%;
  height: 18.75rem;
  margin-bottom: var(--mb-space-sm);
  border-radius: var(--mb-radius-sm);
  background-color: var(--mb-bg-elevated);
  background-size: cover;
  background-position: center 15%;
  background-repeat: no-repeat;
}

.mb-grid__item-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  margin-bottom: var(--mb-space-2xs);
  border: 0.0625rem solid var(--mb-border-strong);
  border-radius: 50%;
  font-size: var(--mb-font-size-lg);
  font-weight: 600;
  color: var(--mb-text-primary);
}

.mb-grid__item-title {
  margin: 0;
  font-size: var(--mb-font-size-xl);
  font-weight: 600;
  line-height: 1.3;
  color: var(--mb-text-primary);
}

.mb-grid__item-description {
  margin: 0 auto;
  max-width: 90%;
  font-size: var(--mb-font-size-base);
  line-height: var(--mb-line-height-body);
  color: var(--mb-text-secondary);
}

.mb-grid__item-link {
  margin-top: var(--mb-space-2xs);
  font-size: var(--mb-font-size-sm);
  font-weight: 600;
  color: var(--mb-accent);
  text-decoration: underline;
  text-underline-offset: 0.1875rem;
}

/* Entry animation — only when JS is running on the front end */
.mb-js .mb-grid-header,
.mb-js .mb-grid-media,
.mb-js .mb-grid__item {
  opacity: 0;
  transform: translateY(var(--mb-fade-distance, 0.875rem));
}

.mb-js .mb-animate .mb-grid-header,
.mb-js .mb-animate .mb-grid-media,
.mb-js .mb-animate .mb-grid__item {
  animation: mbFadeUp var(--mb-duration) var(--mb-ease) both;
}

.mb-js .mb-animate .mb-grid-media { animation-delay: calc(var(--mb-stagger) * 1); }
.mb-js .mb-animate .mb-grid__item:nth-child(1) { animation-delay: calc(var(--mb-stagger) * 2); }
.mb-js .mb-animate .mb-grid__item:nth-child(2) { animation-delay: calc(var(--mb-stagger) * 3); }
.mb-js .mb-animate .mb-grid__item:nth-child(3) { animation-delay: calc(var(--mb-stagger) * 4); }
.mb-js .mb-animate .mb-grid__item:nth-child(4) { animation-delay: calc(var(--mb-stagger) * 5); }
.mb-js .mb-animate .mb-grid__item:nth-child(5) { animation-delay: calc(var(--mb-stagger) * 6); }
.mb-js .mb-animate .mb-grid__item:nth-child(6) { animation-delay: calc(var(--mb-stagger) * 7); }

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 75rem) and (min-width: 60.5625rem) {
  .mb-hero__media {
    background-position: center right;
  }
}

/* Layout shift — header becomes an opaque in-flow bar, hero stacks.
 *
 * Because the header no longer overlays the hero, `.mb-hero__content` drops the
 * `--mb-header-height` top padding it carries on desktop: that padding exists
 * purely to keep copy clear of the floating logo, and here there is nothing to
 * clear. The min-height subtraction below accounts for the space the header now
 * genuinely occupies, so the hero still fills exactly one screen.
 */
@media (max-width: 60.5rem) {
  .mb-hero {
    flex-direction: column;
    height: auto;
    max-height: none;
    min-height: calc(100dvh - var(--mb-header-height, 5.5rem));
  }

  .mb-hero__content {
    flex: none;
    width: 100%;
    padding: var(--mb-space-lg) var(--mb-space-xl);
    text-align: center;
  }

  .mb-hero__inner {
    width: 100%;
    max-width: 100%;
  }

  .mb-hero__heading {
    font-size: clamp(2rem, 8vw, 3rem);
  }

  .mb-hero__subheading {
    width: 80%;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
  }

  .mb-hero__cta {
    align-self: center;
    margin-top: 6px
  }

  .mb-hero__media {
    flex: 1 1 auto;
    width: 100%;
    min-height: 20rem;
    background-position: center center !important;
  }

  .mb-hero__media::before {
    background: linear-gradient(
      to bottom,
      var(--mb-bg-secondary) 0%,
      rgba(17, 24, 39, 0.8) 15%,
      rgba(17, 24, 39, 0.3) 30%,
      transparent 50%
    );
  }

  .mb-grid-section {
    padding: var(--mb-section-padding) 0;
  }

  .mb-grid--cols-3,
  .mb-grid--cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 48rem) {
  .mb-grid__item-description {
    max-width: 100%;
    margin: 0;
  }
}

@media (max-width: 40rem) {
  .mb-hero__content {
    padding: var(--mb-space-md) var(--mb-space-md);
  }

  .mb-grid {
    gap: var(--mb-space-xl) var(--mb-space-md);
  }

  .mb-grid--cols-2,
  .mb-grid--cols-3,
  .mb-grid--cols-4 {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
