/* Morgen shared UI foundation.
 * Keeps every public UI on the stable v4 width contract while preserving
 * version-scoped component styling and settings-driven color tokens.
 */
:root {
  --morgen-shell-max: 1500px;
  --morgen-shell-gutter: clamp(24px, 5.1vw, 72px);
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
  overflow-x: clip;
}

:where(#morgen-app-root, #morgen-v2-root, #morgen-v3-root, #morgen-v4-root, #morgen-v5-root, #morgen-v6-root) {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-x: clip;
}

#morgen-app-root .mg-shell,
#morgen-v2-root .mg2-shell,
#morgen-v3-root .mg3-shell,
#morgen-v4-root .mg4-shell,
#morgen-v5-root .mg5-shell,
#morgen-v6-root .mg6-shell {
  box-sizing: border-box;
  width: min(calc(100% - (var(--morgen-shell-gutter) * 2)), var(--morgen-shell-max));
  max-width: var(--morgen-shell-max);
  margin-inline: auto;
  min-width: 0;
}

/*
 * V1 and V2 define their shell reset in their own version stylesheet.
 * Keeping padding out of this late-loading shared rule lets a shell that is
 * also a card/panel retain its component padding. V3–V6 keep the original
 * stable-V4 zero-padding shell contract here.
 */
#morgen-v3-root .mg3-shell,
#morgen-v4-root .mg4-shell,
#morgen-v5-root .mg5-shell,
#morgen-v6-root .mg6-shell {
  padding-inline: 0;
}

/* V1 uses several dual-purpose shell + card elements. Preserve their
 * component safe area explicitly so later shell-width work cannot flatten it.
 */
#morgen-app-root .mg-shell.mg-feature {
  padding-inline: clamp(1.5rem, 4vw, 3rem);
}

#morgen-app-root .mg-shell.mg-about-story {
  padding-inline: clamp(1rem, 3vw, 2rem);
}

#morgen-app-root .mg-shell.mg-about-cta {
  padding-inline: clamp(1.2rem, 3vw, 2.25rem);
}

#morgen-app-root .mg-shell > *,
#morgen-v2-root .mg2-shell > *,
#morgen-v3-root .mg3-shell > *,
#morgen-v4-root .mg4-shell > *,
#morgen-v5-root .mg5-shell > *,
#morgen-v6-root .mg6-shell > * {
  min-width: 0;
  max-width: 100%;
}

:where(#morgen-app-root, #morgen-v2-root, #morgen-v3-root, #morgen-v4-root, #morgen-v5-root, #morgen-v6-root)
:where([class*="__grid"], [class$="-grid"], [class*="-layout"], [class*="__layout"], [class*="__inner"]) {
  min-width: 0;
  max-width: 100%;
}

:where(#morgen-app-root, #morgen-v2-root, #morgen-v3-root, #morgen-v4-root, #morgen-v5-root, #morgen-v6-root)
:where([class*="__grid"], [class$="-grid"], [class*="-layout"], [class*="__layout"]) > * {
  min-width: 0;
  max-width: 100%;
}

:where(#morgen-app-root, #morgen-v2-root, #morgen-v3-root, #morgen-v4-root, #morgen-v5-root, #morgen-v6-root)
:where(img, video, canvas, iframe, svg, form, fieldset, input, select, textarea, button) {
  max-width: 100%;
}

:where(#morgen-app-root, #morgen-v2-root, #morgen-v3-root, #morgen-v4-root, #morgen-v5-root, #morgen-v6-root)
:where(p, li, dd, dt, blockquote, figcaption, label) {
  overflow-wrap: anywhere;
}

.morgen-ui-preview-notice {
  position: fixed;
  top: calc(var(--wp-admin--admin-bar--height, 0px) + 18px);
  right: 18px;
  z-index: 2147483000;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: min(390px, calc(100vw - 36px));
  padding: 11px 12px;
  border: 1px solid var(--morgen-active-accent);
  border: 1px solid color-mix(in srgb, var(--morgen-active-accent) 72%, var(--morgen-active-ink));
  border-radius: 14px;
  background: var(--morgen-active-accent);
  background: color-mix(in srgb, var(--morgen-active-accent) 91%, var(--morgen-active-surface));
  color: var(--morgen-active-on-accent);
  box-shadow: 0 18px 46px rgba(var(--morgen-active-main-rgb), .24);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  animation: morgen-preview-jiggle 760ms cubic-bezier(.22, 1, .36, 1) 420ms both;
}

.morgen-ui-preview-notice[hidden] {
  display: none;
}

.morgen-ui-preview-notice__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 30px;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(var(--morgen-active-surface-rgb), .14);
  background: color-mix(in srgb, var(--morgen-active-on-accent) 14%, transparent);
  color: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1;
  text-transform: uppercase;
}

.morgen-ui-preview-notice__copy {
  min-width: 0;
}

.morgen-ui-preview-notice__copy strong,
.morgen-ui-preview-notice__copy span {
  display: block;
}

.morgen-ui-preview-notice__copy strong {
  margin-bottom: 2px;
  font-size: 13px;
  line-height: 1.25;
}

.morgen-ui-preview-notice__copy span {
  font-size: 12px;
  line-height: 1.35;
  opacity: .86;
}

.morgen-ui-preview-notice__close {
  display: inline-grid;
  place-items: center;
  box-sizing: border-box;
  flex: 0 0 auto;
  width: 32px;
  min-width: 32px;
  height: 32px;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: rgba(var(--morgen-active-surface-rgb), .13);
  background: color-mix(in srgb, var(--morgen-active-on-accent) 13%, transparent);
  color: inherit;
  cursor: pointer;
  font: inherit;
  line-height: 0;
  appearance: none;
  -webkit-appearance: none;
  touch-action: manipulation;
}

.morgen-ui-preview-notice__close-icon {
  display: block;
  width: 16px;
  height: 16px;
  margin: 0;
  overflow: visible;
  pointer-events: none;
}

.morgen-ui-preview-notice__close:hover,
.morgen-ui-preview-notice__close:focus-visible {
  background: rgba(var(--morgen-active-surface-rgb), .22);
  background: color-mix(in srgb, var(--morgen-active-on-accent) 22%, transparent);
  outline: 2px solid var(--morgen-active-on-accent);
  outline: 2px solid color-mix(in srgb, var(--morgen-active-on-accent) 64%, transparent);
  outline-offset: 2px;
}

@keyframes morgen-preview-jiggle {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0); }
  22% { transform: translate3d(-4px, 0, 0) rotate(-1deg); }
  44% { transform: translate3d(4px, 0, 0) rotate(1deg); }
  66% { transform: translate3d(-2px, 0, 0) rotate(-.5deg); }
  82% { transform: translate3d(2px, 0, 0) rotate(.5deg); }
}

body.admin-bar .morgen-ui-preview-notice {
  top: 50px;
}

@media (max-width: 1024px) {
  :root { --morgen-shell-gutter: clamp(18px, 3vw, 32px); }
}

@media (max-width: 680px) {
  #morgen-app-root .mg-shell.mg-feature {
    padding-inline: var(--mg-space-4);
  }

  #morgen-app-root .mg-shell.mg-about-story {
    padding-inline: .75rem;
  }
}

@media (max-width: 640px) {
  :root { --morgen-shell-gutter: 12px; }
  .morgen-ui-preview-notice {
    top: 12px;
    right: 12px;
    width: calc(100vw - 24px);
  }
  body.admin-bar .morgen-ui-preview-notice { top: 58px; }
}

@media (prefers-reduced-motion: reduce) {
  .morgen-ui-preview-notice { animation: none; }
}

/* 2.23.9 — Ticket #989039: shared benefit rhythm and premium focus feedback. */
:where(#morgen-app-root, #morgen-v2-root, #morgen-v3-root, #morgen-v4-root, #morgen-v5-root, #morgen-v6-root)
:where(a, button, [role="button"], summary, input[type="button"], input[type="submit"], input[type="reset"]) {
  -webkit-tap-highlight-color: transparent;
}

:where(#morgen-app-root, #morgen-v2-root, #morgen-v3-root, #morgen-v4-root, #morgen-v5-root, #morgen-v6-root)
:where(a, button, [role="button"], summary, input[type="button"], input[type="submit"], input[type="reset"]):focus:not(:focus-visible) {
  outline: 0;
}

:where(#morgen-app-root, #morgen-v2-root, #morgen-v3-root, #morgen-v4-root, #morgen-v5-root, #morgen-v6-root)
:where(a, button, [role="button"], summary, input[type="button"], input[type="submit"], input[type="reset"]):focus-visible {
  outline: 2px solid var(--morgen-active-accent);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(var(--morgen-active-accent-rgb), .16);
}

#morgen-app-root .morgen-benefit-grid { --morgen-benefit-heading-min: 3.45em; }
#morgen-v3-root .morgen-benefit-grid {
  --morgen-benefit-marker-row: 52px;
  --morgen-benefit-header-gap: 14px;
  --morgen-benefit-title-min: 0px;
}
#morgen-v4-root .morgen-benefit-grid {
  --morgen-benefit-marker-row: 52px;
  --morgen-benefit-header-gap: 14px;
  --morgen-benefit-title-min: 0px;
}
#morgen-v4-root.mg4[data-mg4-layout="stable"] .morgen-benefit-grid {
  --morgen-benefit-marker-row: 36px;
  --morgen-benefit-header-gap: 12px;
}
#morgen-v5-root .morgen-benefit-grid,
#morgen-v6-root .morgen-benefit-grid { --morgen-benefit-heading-min: 3.55em; }

/* Follow-up: every repeated buyer-benefit pattern uses a true marker row.
   The icon/number occupies the first row and the heading begins beneath it. */
:where(#morgen-v2-root, #morgen-v3-root, #morgen-v4-root, #morgen-v5-root, #morgen-v6-root)
.morgen-benefit-grid .morgen-benefit-marker {
  justify-self: start;
  align-self: start;
}

:where(#morgen-v2-root, #morgen-v3-root, #morgen-v4-root, #morgen-v5-root, #morgen-v6-root)
.morgen-benefit-grid .morgen-benefit-body {
  width: 100%;
  min-width: 0;
}

:where(#morgen-v2-root, #morgen-v3-root, #morgen-v4-root, #morgen-v5-root, #morgen-v6-root)
.morgen-benefit-grid .morgen-benefit-heading {
  width: 100%;
  min-width: 0;
}

#morgen-v2-root .morgen-benefit-grid .morgen-benefit-card,
:is(#morgen-v3-root, #morgen-v4-root, #morgen-v5-root, #morgen-v6-root)
.morgen-benefit-grid--home .morgen-benefit-card {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: start;
  justify-items: start;
}

:is(#morgen-v3-root, #morgen-v4-root)
.morgen-benefit-grid--about .morgen-benefit-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: var(--morgen-benefit-header-gap);
  align-content: start;
  align-items: start;
  justify-items: start;
  min-width: 0;
}

@media (min-width: 681px) {
  #morgen-app-root .morgen-benefit-grid .morgen-benefit-heading {
    display: block;
    min-block-size: var(--morgen-benefit-heading-min);
  }
}

@media (min-width: 821px) {
  #morgen-v3-root .morgen-benefit-grid--about {
    --morgen-benefit-title-min: 2.3em;
  }

  #morgen-v4-root:not([data-mg4-layout="stable"]) .morgen-benefit-grid--about {
    --morgen-benefit-title-min: 2.3em;
  }

  :is(#morgen-v3-root, #morgen-v4-root)
  .morgen-benefit-grid--about .morgen-benefit-header {
    grid-template-rows: var(--morgen-benefit-marker-row) minmax(var(--morgen-benefit-title-min), auto);
    min-block-size: calc(var(--morgen-benefit-marker-row) + var(--morgen-benefit-header-gap) + var(--morgen-benefit-title-min));
  }

  :is(#morgen-v3-root, #morgen-v4-root)
  .morgen-benefit-grid--about .morgen-benefit-heading {
    display: block;
    min-block-size: var(--morgen-benefit-title-min);
    align-self: start;
  }
}

@media (min-width: 721px) {
  #morgen-v4-root.mg4[data-mg4-layout="stable"] .morgen-benefit-grid--about {
    --morgen-benefit-title-min: 2.55em;
  }

  #morgen-v4-root.mg4[data-mg4-layout="stable"]
  .morgen-benefit-grid--about .morgen-benefit-header {
    grid-template-rows: var(--morgen-benefit-marker-row) minmax(var(--morgen-benefit-title-min), auto);
    min-block-size: calc(var(--morgen-benefit-marker-row) + var(--morgen-benefit-header-gap) + var(--morgen-benefit-title-min));
  }

  #morgen-v4-root.mg4[data-mg4-layout="stable"]
  .morgen-benefit-grid--about .morgen-benefit-heading {
    display: block;
    min-block-size: var(--morgen-benefit-title-min);
    align-self: start;
  }
}

@media (min-width: 1241px) {
  #morgen-v3-root .morgen-benefit-grid--about,
  #morgen-v4-root:not([data-mg4-layout="stable"]) .morgen-benefit-grid--about {
    --morgen-benefit-title-min: 4.35em;
  }
}

@media (min-width: 601px) {
  #morgen-v5-root .morgen-benefit-grid--about .morgen-benefit-heading,
  #morgen-v6-root .morgen-benefit-grid--about .morgen-benefit-heading {
    display: block;
    min-block-size: var(--morgen-benefit-heading-min);
  }
}

@media (min-width: 901px) {
  #morgen-v5-root .morgen-benefit-grid--home .morgen-benefit-heading,
  #morgen-v6-root .morgen-benefit-grid--home .morgen-benefit-heading {
    display: block;
    min-block-size: var(--morgen-benefit-heading-min);
  }
}


/* 2.23.9 — About benefit cards: use an oversized travelling highlight instead
   of translating a full-card overlay. Transparent edges enter and leave the
   clipped card naturally, so no vertical seam or cropped panel is exposed. */
:is(
  #morgen-v3-root .mg3-home2-tier,
  #morgen-v4-root .mg4-home2-tier
)::after {
  inset: -28% auto -28% -72%;
  width: 60%;
  background: linear-gradient(
    108deg,
    transparent 0%,
    rgba(var(--morgen-active-accent-rgb), .025) 24%,
    rgba(255, 255, 255, .10) 40%,
    rgba(255, 255, 255, .30) 50%,
    rgba(255, 255, 255, .08) 61%,
    rgba(var(--morgen-active-accent-rgb), .035) 72%,
    transparent 100%
  );
  opacity: 0;
  transform: skewX(-18deg) translateZ(0);
  transition: opacity .14s ease;
  will-change: left, opacity;
}

:is(
  #morgen-v3-root .mg3-home2-tier:hover,
  #morgen-v3-root .mg3-home2-tier:focus-within,
  #morgen-v4-root .mg4-home2-tier:hover,
  #morgen-v4-root .mg4-home2-tier:focus-within
)::after {
  left: 122%;
  opacity: .92;
  transform: skewX(-18deg) translateZ(0);
  transition: left .78s cubic-bezier(.22, 1, .36, 1), opacity .12s ease;
}

@media (prefers-reduced-motion: reduce) {
  :is(
    #morgen-v3-root .mg3-home2-tier,
    #morgen-v4-root .mg4-home2-tier
  )::after {
    display: none;
  }
}
