/**
 * Brand chooser overlay and dual-brand navigation styles.
 *
 * Loaded after the compiled `custom-styles` bundle so it can override it.
 * Product-page presentation is intentionally excluded until it is approved.
 */

/* ---------------------------------------------------------------------------
   Brand tokens
   --------------------------------------------------------------------------- */

:root,
[data-brand="edwin-doran"] {
  --brand-surface: #ffffff;
  --brand-surface-raised: #ffffff;
  --brand-primary: #f26522;
  --brand-primary-ink: #ffffff;
  --brand-on-surface: #12294a;
  --brand-on-surface-muted: #5f7285;
  --brand-on-surface-body: #3f4f5f;
  --brand-line: #dbe3ea;
  --brand-accent: #f26522;
}

/* Masterclass homepage banner CTA ---------------------------------------- */

body.brand-masterclass.page-id-9509
  .block-banner
  .banner-button
  .btn,
body.brand-masterclass.page-id-9509
  .block-banner
  .banner-button
  .btn:hover,
body.brand-masterclass.page-id-9509
  .block-banner
  .banner-button
  .btn:focus-visible {
  background-color: #ffffff;
  border-color: #ffffff;
  color: var(--brand-on-surface, #12294a);
}

/* The overlay is a neutral chooser: it belongs to neither brand, so it always
   uses the light palette regardless of the surrounding page. */
.brand-overlay {
  --overlay-surface: #ffffff;
  --overlay-ink: #12294a;
  --overlay-muted: #5f7285;
  --overlay-body: #3f4f5f;
  --overlay-line: #dbe3ea;
  --overlay-ed: #f26522;
  --overlay-mc: #12294a;
  --overlay-radius: 16px;
}

/* The dedicated Masterclass menu stays available on Masterclass pages. On
   Edwin Doran, brand switching is provided by the left lockup instead, so the
   duplicate right-side logo trigger is removed at every responsive breakpoint. */
body.brand-edwin-doran #site-header .ws-masterclass-brand-menu-trigger {
  display: none;
}

/* ---------------------------------------------------------------------------
   Homepage brand chooser overlay
   --------------------------------------------------------------------------- */

.brand-overlay[hidden] {
  display: none;
}

.brand-overlay {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.brand-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 24, 43, 0.62);
  animation: brand-overlay-fade 180ms ease-out both;
}

.brand-overlay-dialog {
  position: relative;
  width: 100%;
  max-width: 815px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--overlay-surface);
  border-radius: var(--overlay-radius);
  padding: 44px 48px 32px;
  box-shadow: 0 24px 64px rgba(12, 24, 43, 0.28);
  animation: brand-overlay-rise 220ms cubic-bezier(0.2, 0.7, 0.3, 1) both;
  text-align: center;
}

@keyframes brand-overlay-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes brand-overlay-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .brand-overlay-backdrop,
  .brand-overlay-dialog {
    animation: none;
  }
}

/* Close ---------------------------------------------------------------- */

.brand-overlay-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  min-width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #eef1f5;
  color: var(--overlay-ink);
  cursor: pointer;
  transition: background 140ms ease-out;
}

.brand-overlay-close:hover,
.brand-overlay-close:focus-visible {
  background: #dfe5ec;
}

/* Head ----------------------------------------------------------------- */

.brand-overlay-title {
  margin: 0 0 10px;
  font-size: 28px;
  line-height: 1.25;
  font-weight: 700;
  color: var(--overlay-ink);
}

.brand-overlay-subtitle {
  margin: 0 auto 30px;
  max-width: 52ch;
  font-size: 16px;
  line-height: 1.5;
  color: var(--overlay-muted);
}

/* Choices -------------------------------------------------------------- */

.brand-overlay-choices {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  gap: 0 34px;
  align-items: start;
}

.brand-overlay-divider {
  align-self: stretch;
  background: var(--overlay-line);
}

.brand-overlay-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.brand-overlay-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  margin-bottom: 18px;
}

.brand-overlay-logo img {
  display: block;
  width: auto;
  max-width: 210px;
  height: auto;
  max-height: 46px;
}

.brand-overlay-kicker {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--overlay-muted);
}

.brand-overlay-text {
  margin: 0 0 26px;
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--overlay-body);
  max-width: 34ch;
}

/* CTAs ----------------------------------------------------------------- */

.brand-overlay-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: auto;
  min-height: 52px;
  padding: 13px 26px;
  border-radius: 6px;
  /* 19px/700 is "large text" under WCAG, so the 3:1 threshold applies to the
	   orange CTA — see the contrast note in the brand README. */
  font-size: 19px;
  font-weight: 400;
  line-height: 1.2;
  text-decoration: none;
  color: #ffffff;
  transition: filter 140ms ease-out;
}

.brand-overlay-cta:hover,
.brand-overlay-cta:focus-visible {
  color: #ffffff;
  text-decoration: none;
  filter: brightness(0.93);
}

.brand-overlay-cta-ed {
  background: var(--overlay-ed);
}
.brand-overlay-cta-mc {
  background: var(--overlay-mc);
}

.brand-overlay-chevron {
  flex: 0 0 auto;
}

/* Dismiss -------------------------------------------------------------- */

.brand-overlay-dismiss {
  display: inline-block;
  margin: 30px auto 0;
  font-size: 15px;
  color: var(--overlay-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.brand-overlay-dismiss:hover,
.brand-overlay-dismiss:focus-visible {
  color: var(--overlay-ink);
}

/* Focus ---------------------------------------------------------------- */

.brand-overlay :focus-visible {
  outline: 3px solid var(--overlay-ed);
  outline-offset: 3px;
}

/* Mobile — bottom sheet, never a full-screen interstitial ---------------- */

@media (max-width: 767.98px) {
  .brand-overlay {
    align-items: center;
    padding: 16px;
  }

  .brand-overlay-dialog {
    max-width: none;
    /* Spec: no more than ~75% of the viewport, page visible behind. */
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 18px;
    padding: 34px 22px 26px;
    animation-name: brand-overlay-sheet;
  }

  @keyframes brand-overlay-sheet {
    from {
      opacity: 0;
      transform: translateY(24px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  .brand-overlay-title {
    font-size: 23px;
    padding: 0 40px;
  }

  .brand-overlay-subtitle {
    margin-bottom: 24px;
    font-size: 15px;
  }

  .brand-overlay-choices {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .brand-overlay-divider {
    height: 1px;
    margin: 26px 0;
  }

  .brand-overlay-logo {
    min-height: 44px;
    margin-bottom: 14px;
  }

  .brand-overlay-logo img {
    max-width: 178px;
    max-height: 38px;
  }

  .brand-overlay-text {
    margin-bottom: 22px;
    max-width: none;
  }

  .brand-overlay-cta {
    width: 100%;
    max-width: 300px;
  }

  .brand-overlay-dismiss {
    margin-top: 24px;
  }
}

/* Small phones ---------------------------------------------------------- */

@media (max-width: 359.98px) {
  .brand-overlay-dialog {
    padding: 30px 16px 22px;
  }
  .brand-overlay-title {
    font-size: 21px;
    padding: 0 34px;
  }
}

/* Scroll lock while the overlay is open. Removed on close — the spec is
   explicit that overflow:hidden must never be left on <body>. */
body.brand-overlay-open {
  overflow: hidden;
}

/* Block editor preview ---------------------------------------------------
   The block renders nothing where it sits on the front end — its markup is
   relocated to wp_footer. In the editor it renders inline instead, otherwise
   the block would look like an empty space. Static rather than fixed, so it
   sits in the document flow like any other block. */

.brand-overlay-preview {
  position: static;
  inset: auto;
  display: block;
  padding: 0;
}

.brand-overlay-preview .brand-overlay-backdrop {
  display: none;
}

.brand-overlay-preview .brand-overlay-dialog {
  max-height: none;
  overflow: visible;
  margin: 0 auto;
  animation: none;
  border: 1px solid var(--overlay-line);
  box-shadow: none;
}

/* The close button is real on the front end but inert in a preview. */
.brand-overlay-preview .brand-overlay-close {
  pointer-events: none;
  opacity: 0.5;
}

/* ---------------------------------------------------------------------------
   Dual-brand logo lockup
   ---------------------------------------------------------------------------

   Deliberately borderless. The theme header is a clean white bar with no boxed
   controls anywhere, so a bordered tab reads as bolted on. The active brand is
   marked the way the rest of the site marks things: full colour plus a short
   accent rule in the house orange (#f60, the hex the compiled bundle actually
   uses), with the inactive brand lowered in opacity only.

   Sizes are optical, not mechanical. The two wordmarks carry very different
   amounts of built-in padding in their viewBoxes (Edwin Doran is 282x74 with a
   badge and two text lines; Masterclass is 158x32), so matching raw heights
   makes Masterclass look oversized. Tune with the two variables below.
   --------------------------------------------------------------------------- */

.brand-lockup {
  --lockup-ed-height: 48px;
  --lockup-mc-height: 32px;
  --lockup-item-height: 78px;
  --lockup-accent: #f60;
  --lockup-divider: #e3e7ec;
  --lockup-hover-bg: #f4f5f7;
}

/* The compiled bundle caps #logo at 10rem/15rem and stretches any child img to
   100%. Both have to go for a two-brand lockup. Specificity is deliberately
   raised to beat `#site-header .primary-navbar .primary-navbar-container #logo`. */
#site-header .primary-navbar .primary-navbar-container #logo.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0;
  max-width: none;
  padding: 0;
  flex-grow: 0;
  margin-right: 1.5rem;
}

#site-header
  .primary-navbar
  .primary-navbar-container
  #logo.brand-lockup
  .brand-lockup-logo {
  width: auto;
  height: var(--lockup-ed-height);
  max-height: var(--lockup-ed-height);
  object-fit: contain;
}

#site-header
  .primary-navbar
  .primary-navbar-container
  #logo.brand-lockup
  .brand-lockup-item-masterclass
  .brand-lockup-logo {
  height: var(--lockup-mc-height);
  max-height: var(--lockup-mc-height);
}

.brand-lockup-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: var(--lockup-item-height);
  padding: 0 20px 6px;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  text-decoration: none;
  transition:
    opacity 160ms ease-out,
    filter 160ms ease-out,
    background-color 160ms ease-out;
}

/* Hairline between the two brands, so they read as siblings rather than as one
   wide logo. Drawn as a pseudo-element so it takes no layout space. */
.brand-lockup-item + .brand-lockup-item:before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 26px;
  background: var(--lockup-divider);
}

.brand-lockup-logo {
  display: block;
  width: auto;
  height: var(--lockup-ed-height);
  max-height: var(--lockup-ed-height);
}

.brand-lockup-item-masterclass .brand-lockup-logo {
  height: var(--lockup-mc-height);
  max-height: var(--lockup-mc-height);
}

@media (min-width: 992px) {
  .brand-lockup-item.brand-lockup-item-masterclass {
    position: relative;
    top: -4px;
  }
}

/* Active brand: full colour, with a short accent rule on the header baseline.
   No border, no plate, no lift. */
.brand-lockup-item.is-active:after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 6px;
  height: 2px;
  border-radius: 2px;
  background: var(--lockup-accent);
}

/* Inactive brand: quiet, retains its full colour and remains a clear link. */
.brand-lockup-item[aria-current="false"] {
  opacity: 0.42;
}

.brand-lockup-item[aria-current="false"]:hover,
.brand-lockup-item[aria-current="false"]:focus-visible {
  opacity: 1;
  background-color: var(--lockup-hover-bg);
}

.brand-lockup-item:focus-visible {
  outline: 2px solid var(--lockup-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .brand-lockup-item {
    transition: none;
  }
}

/* Mobile: only the active compact brand, per Section 4. The other brand is
   available in the burger's explicit switch-brand row. Reserve flexible room
   for the logo so the search, quote and menu controls never compress it. */
@media (max-width: 991.98px) {
  #site-header .primary-navbar .primary-navbar-container #logo.brand-lockup {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    margin-right: 0.5rem;
  }

  .brand-lockup-item[aria-current="false"] {
    display: none;
  }

  .brand-lockup-item.is-active {
    height: auto;
    padding: 8px 0;
  }

  .brand-lockup-item.is-active:after,
  .brand-lockup-item + .brand-lockup-item:before {
    display: none;
  }

  .brand-lockup {
    --lockup-ed-height: 29px;
    --lockup-mc-height: 23px;
  }
}

/* Desktop header spacing. Kept here as an override because styles.css is a
   generated bundle with no editable source in this project. */
@media (min-width: 992px) {
  #site-header .primary-navbar {
    padding: 1rem 0;
  }
}

@media (max-width: 359.98px) {
  #site-header .primary-navbar .primary-navbar-container #logo.brand-lockup {
    margin-right: 0.25rem;
  }

  .brand-lockup {
    --lockup-ed-height: 26px;
    --lockup-mc-height: 21px;
  }
}

/* Navigation controls have the same high-visibility focus treatment as the
   lockup. It applies in either brand state, including the unthemed rollout. */
#site-header .primary-navbar .dropdown-item:focus-visible,
#site-header .primary-navbar .header-button-menu a:focus-visible,
#site-header .primary-navbar .search-toggle:focus-visible,
#site-header .primary-navbar .navbar-toggler:focus-visible {
  outline: 3px solid var(--lockup-accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Top-level Masterclass menu links intentionally have no boxed focus state. */
body.brand-masterclass
  #site-header
  .primary-navbar-content
  .navbar-nav
  > .nav-item
  > .nav-link:focus,
body.brand-masterclass
  #site-header
  .primary-navbar-content
  .navbar-nav
  > .nav-item
  > .nav-link:focus-visible {
  background-color: transparent;
  box-shadow: none;
  outline: 0;
}

/* Brand-grouped burger ---------------------------------------------------
   "You are browsing" indicator at the top of the menu, explicit switch-brand
   row at the bottom. */

.brand-menu-indicator {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 0 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--brand-line, #dbe3ea);
}

.brand-menu-indicator-label {
  font-size: 12px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--brand-on-surface-muted, #5f7285);
}

.brand-menu-indicator-brand {
  font-size: 17px;
  font-weight: 700;
  color: var(--brand-on-surface, #12294a);
}

.brand-menu-switch {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--brand-line, #dbe3ea);
}

.brand-menu-switch-label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--brand-on-surface-muted, #5f7285);
}

.brand-menu-switch-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--brand-line, #dbe3ea);
  border-radius: 8px;
  text-decoration: none;
  color: var(--brand-on-surface, #12294a);
}

.brand-menu-switch-link:hover,
.brand-menu-switch-link:focus-visible {
  border-color: var(--brand-accent, #f26522);
  color: var(--brand-on-surface, #12294a);
  text-decoration: none;
}

.brand-menu-switch-arrow {
  font-size: 18px;
  color: var(--brand-accent, #f26522);
}

.brand-menu-switch-logo {
  display: block;
  width: auto;
  max-width: calc(100% - 32px);
  height: 28px;
}

.brand-menu-switch-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.brand-menu-switch-name {
  font-size: 16px;
  font-weight: 700;
}

.brand-menu-switch-desc {
  font-size: 13px;
  color: var(--brand-on-surface-muted, #5f7285);
}

/* Mobile menu surface on Masterclass pages ------------------------------- */

@media (max-width: 991.98px) {
  /* The header remains white; only the opened burger drawer is navy. */
  body.brand-masterclass #site-header .primary-navbar-content {
    --brand-surface-deep: #183051;
    --brand-on-surface: #ffffff;
    --brand-on-surface-muted: #b9c6d8;
    --brand-line: rgba(255, 255, 255, 0.18);

    background-color: var(--brand-surface-deep);
    color: var(--brand-on-surface);
    height: calc(100dvh - 67px);
    padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  body.brand-masterclass #site-header .primary-navbar-content .nav-link,
  body.brand-masterclass #site-header .primary-navbar-content .dropdown-item {
    color: var(--brand-on-surface);
  }

  body.brand-masterclass #site-header .brand-menu-indicator-label,
  body.brand-masterclass #site-header .brand-menu-switch-label,
  body.brand-masterclass #site-header .brand-menu-switch-desc {
    color: var(--brand-on-surface-muted);
  }

  body.brand-masterclass #site-header .brand-menu-indicator-brand,
  body.brand-masterclass #site-header .brand-menu-switch-link,
  body.brand-masterclass #site-header .brand-menu-switch-link:hover,
  body.brand-masterclass #site-header .brand-menu-switch-link:focus-visible {
    color: var(--brand-on-surface);
  }

  body.brand-masterclass #site-header .brand-menu-switch-link {
    min-height: 0;
    padding: 12px 0;
    border: 0;
    border-bottom: 1px dotted var(--brand-line);
    border-radius: 0;
    background: transparent;
  }
}
