/*!
Context archive — Column hamburger menu
Loaded after header.css.

>>> TABLE OF CONTENTS
# Variables
# Popup overrides
# Box model
# Three-band scaffolding
# Column 1
# Columns 2 and 3 (sub-levels)
# Items
# Utility menu and social
# Hamburger to close icon
# Mobile
*/

/*--------------------------------------------------------------
# Variables
--------------------------------------------------------------*/

.ctx-hb {
  --hb-col-1: var(--ctx-blue-deep, #004a7c);
  --hb-col-2: #02385e;
  --hb-col-3: #002742;
  --hb-veil: rgba(0, 64, 107, 0.95);

  --hb-h: 450px; /* fixed panel height on desktop */
  --hb-col-w: 33.3333%; /* each column is one third of .ctx-hb-center */
  --hb-pad: 39px 30px 30px;
  --hb-rule: rgba(255, 255, 255, 0.3);
  --hb-back-w: 56px; /* back button strip, mobile only */
}

/*--------------------------------------------------------------
# Popup overrides
# .ctx-popup comes from header.css: padding and max width are
# reset here because the menu handles its own layout.
--------------------------------------------------------------*/

.ctx-nav-popup {
  background-color: transparent;
  box-shadow: none;
}

.ctx-nav-popup .ctx-popup-inner {
  max-width: none;
  margin: 0;
  padding: 0;
}

/* The close control lives on the header toggle, not inside the panel */
.ctx-nav-popup > .ctx-popup-inner > .ctx-popup-close {
  display: none;
}

/*--------------------------------------------------------------
# Box model
# The panel is rendered outside #masthead.ctx-header, so it never
# inherits the border-box reset declared there. Without this rule
# the horizontal padding of each column is added on top of its
# percentage width, and the columns stop lining up.
--------------------------------------------------------------*/

.ctx-hb,
.ctx-hb *,
.ctx-hb *::before,
.ctx-hb *::after {
  box-sizing: border-box;
}

/*--------------------------------------------------------------
# Three-band scaffolding
# left:   extends the colour of column 1 to the viewport edge
# centre: the columns themselves
# right:  transparent, so the veil over the page stays visible
--------------------------------------------------------------*/

.ctx-hb {
  display: flex;
  width: 100%;
  height: var(--hb-h);
  background-color: var(--hb-veil);
}

.ctx-hb-bg-left {
  flex-grow: 1;
  background-color: var(--hb-col-1);
}

.ctx-hb-bg-right {
  flex-grow: 1;
}

.ctx-hb-center {
  position: relative; /* containing block for column 2 */
  display: flex;
  min-width: 320px;
  width: 100%;
}

@media (min-width: 1440px) {
  .ctx-hb-center {
    width: 1440px;
    margin: 0 auto;
  }
}

/*--------------------------------------------------------------
# Column 1
--------------------------------------------------------------*/

.ctx-hb-col-1 {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: var(--hb-col-w);
  max-width: var(--hb-col-w);
  padding: var(--hb-pad);
  background-color: var(--hb-col-1);
}

.ctx-hb-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/*--------------------------------------------------------------
# Columns 2 and 3
#
# Both are nested WordPress menu lists and both are absolutely
# positioned, but they do not share a containing block:
#
#   column 2 is a descendant of .ctx-hb-center, and the items in
#   between stay position:static, so it resolves against the centre
#   band and can be placed with the shared column width.
#
#   column 3 is a descendant of column 2, which is itself absolutely
#   positioned and therefore becomes its containing block. Its
#   offsets resolve against column 2, not against the centre band,
#   so percentages taken from the centre band would compound instead
#   of adding up. It is placed at 100% instead: flush to the right
#   edge of column 2, at the same width.
#
# overflow stays visible so column 3 is not clipped by column 2,
# which it deliberately sits outside of. Scrolling is restored in
# the mobile block below, where the panels overlap at full width.
--------------------------------------------------------------*/

.ctx-hb-sub {
  position: absolute;
  top: 0;
  height: 100%;
  width: var(--hb-col-w);
  margin: 0;
  padding: var(--hb-pad);
  list-style: none;
  overflow: visible;
  display: none;
}

.ctx-hb-sub--1 {
  left: var(--hb-col-w);
  background-color: var(--hb-col-2);
}

.ctx-hb-sub--2 {
  left: 100%;
  width: 100%;
  background-color: var(--hb-col-3);
}

.ctx-hb-item.is-open > .ctx-hb-sub {
  display: block;
}

/*--------------------------------------------------------------
# Items
--------------------------------------------------------------*/

.ctx-hb-item {
  position: static; /* required for sub-menu positioning */
  margin: 0;
  border-top: 1px solid var(--hb-rule);
}

.ctx-hb-list > .ctx-hb-item:last-child,
.ctx-hb-sub > .ctx-hb-item:last-child {
  border-bottom: 1px solid var(--hb-rule);
}

.ctx-hb-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 11px 0;
  border: 0;
  background: none;
  color: var(--ctx-white, #fff);
  font-family: inherit;
  font-size: 18px;
  font-weight: 600;
  line-height: 22px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.ctx-hb-link:hover .ctx-hb-label,
.ctx-hb-item.is-open > .ctx-hb-link .ctx-hb-label {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.ctx-hb-link:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -2px;
}

/* Chevron: shown on hover and on the open item */
.ctx-hb-item.has-children > .ctx-hb-link::after {
  content: "";
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  opacity: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 5 7 7-7 7'/%3E%3C/svg%3E")
    no-repeat center / contain;
  transition: opacity 0.15s linear;
}

.ctx-hb-item.has-children:hover > .ctx-hb-link::after,
.ctx-hb-item.has-children.is-open > .ctx-hb-link::after {
  opacity: 1;
}

/*--------------------------------------------------------------
# Utility menu and social (bottom of column 1)
--------------------------------------------------------------*/

.ctx-hb-foot {
  margin-top: 24px;
}

.ctx-hb-utility {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}

.ctx-hb-utility a {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.ctx-hb-utility a:hover {
  text-decoration: underline;
}

.ctx-hb-social {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ctx-hb-social a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background-color: #fff;
  color: var(--hb-col-1);
}

.ctx-hb-social svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.ctx-hb-social a:hover {
  opacity: 0.85;
}

/*--------------------------------------------------------------
# Hamburger to close icon while the menu is open
--------------------------------------------------------------*/

.ctx-menu-toggle .ctx-burger span {
  transition: transform 0.25s ease, opacity 0.15s linear;
}

.ctx-menu-toggle[aria-expanded="true"] .ctx-burger span:nth-child(1) {
  transform: translateY(10px) rotate(45deg);
}

.ctx-menu-toggle[aria-expanded="true"] .ctx-burger span:nth-child(2) {
  opacity: 0;
}

.ctx-menu-toggle[aria-expanded="true"] .ctx-burger span:nth-child(3) {
  transform: translateY(-10px) rotate(-45deg);
}

/*--------------------------------------------------------------
# Mobile — columns become full width panels
#
# Every level is reset to left:0 and full width, so the nesting of
# column 3 inside column 2 no longer matters: each panel covers the
# one below it. These declarations come last, so they override the
# desktop offsets at equal specificity.
--------------------------------------------------------------*/

@media (max-width: 899px) {
  .ctx-nav-popup {
    bottom: 0;
    overflow-y: auto;
  }

  .ctx-hb {
    height: 100%;
    min-height: 100%;
    background-color: var(--hb-col-1);
  }

  .ctx-hb-bg-left,
  .ctx-hb-bg-right {
    display: none;
  }

  .ctx-hb-center {
    min-width: 0;
  }

  .ctx-hb-col-1 {
    min-width: 100%;
    max-width: 100%;
    padding: 24px 20px 32px;
  }

  .ctx-hb-sub {
    left: 0;
    width: 100%;
    min-height: 100%;
    padding: 24px 20px 32px calc(var(--hb-back-w) + 20px);
    background-color: var(--hb-col-1);
    overflow-y: auto;
    z-index: 2;
  }

  .ctx-hb-item.is-open > .ctx-hb-sub {
    animation: ctxHbSlideIn 0.12s ease-in-out both;
  }

  @keyframes ctxHbSlideIn {
    from {
      transform: translateX(100%);
    }
    to {
      transform: translateX(0);
    }
  }

  /* Back button strip */
  .ctx-hb-back {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--hb-back-w);
    border: 0;
  }

  .ctx-hb-back-btn {
    width: 100%;
    height: 100%;
    border: 0;
    cursor: pointer;
    background: var(--ctx-blue-accent, #006daa)
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m15 5-7 7 7 7'/%3E%3C/svg%3E")
      no-repeat center / 14px;
  }

  .ctx-hb-back-btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: -2px;
  }

  /* On mobile the chevron is always visible: it signals drill-down */
  .ctx-hb-item.has-children > .ctx-hb-link::after {
    opacity: 1;
  }

  .ctx-hb-link {
    font-size: 16px;
  }
}

/* The back strip is not needed on desktop */
@media (min-width: 900px) {
  .ctx-hb-back {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ctx-hb *,
  .ctx-menu-toggle .ctx-burger span {
    animation: none !important;
    transition: none !important;
  }
}
