/* M39 functional additions only. Production styles remain the visual authority. */
:root {
  --m39-navy: var(--gpir-navy-900, #0f1f3a);
  --m39-gold: var(--gpir-gold-500, #c9a24a);
}

/* Contextual ASK GPIR action, secondary to existing section headings. */
.m39-ask-context {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 12px;
  padding: 6px 12px;
  border: 1px solid var(--m39-gold);
  border-radius: 999px;
  background: transparent;
  color: var(--m39-navy);
  font: 600 12px/1.3 Arial, sans-serif;
  cursor: pointer;
  white-space: normal;
}

.m39-ask-context:hover,
.m39-ask-context:focus-visible {
  background: #f7f0e3;
  outline: 2px solid var(--m39-gold);
  outline-offset: 2px;
}

/* ASK GPIR keeps its own accessible question field inside production search. */
.gpir-assistant-question-form {
  display: grid;
  gap: 7px;
  margin: 12px 0 16px;
}

.gpir-assistant-question-form label {
  color: var(--m39-navy);
  font: 600 13px Arial, sans-serif;
}

.gpir-assistant-question-row {
  display: flex;
  min-width: 0;
  gap: 8px;
}

.gpir-assistant-question-row input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid #b6c0ce;
  border-radius: 8px;
  background: #fff;
  color: #102747;
  font: 14px Arial, sans-serif;
  pointer-events: auto;
}

.gpir-assistant-question-row button {
  min-height: 42px;
  padding: 8px 18px;
  border: 0;
  border-radius: 8px;
  background: var(--m39-navy);
  color: #fff;
  cursor: pointer;
}

.gpir-assistant-question-row :is(input, button):focus-visible {
  outline: 2px solid var(--m39-gold);
  outline-offset: 2px;
}

.gpir-assistant-result-kind {
  display: block;
  margin-bottom: 4px;
  color: #80631f;
  font: 700 10px/1.2 Arial, sans-serif;
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* Unpublished intelligence remains visible in the production card hierarchy. */
#intelligence-library .m39-coming-soon {
  display: inline-block;
  margin-left: 6px;
  padding: 4px 8px;
  border-radius: 12px;
  background: #f5ecd7;
  color: #705116;
  font: 600 10px Arial, sans-serif;
  vertical-align: middle;
}

#intelligence-library .library-link {
  color: #735e3b;
  cursor: default;
  pointer-events: none;
  text-decoration: none;
}

#intelligence-library .library-image {
  cursor: default;
  pointer-events: none;
}

#intelligence-library .library-image img {
  opacity: .8;
}

@media (max-width: 600px) {
  .m39-ask-context {
    margin-bottom: 10px;
  }

  .gpir-assistant-question-row {
    flex-wrap: wrap;
  }
}

/* The approved eight-domain navigation cannot fit as a readable single row
   at tablet widths. Reuse the existing accordion/drawer through 1100px and
   override earlier P0 desktop grid rules that begin at 1024px. */
@media (max-width: 1100px) {
  .header .container.header-container {
    grid-template-columns: minmax(0, 1fr) auto auto !important;
    grid-template-rows: auto auto !important;
    width: 100% !important;
    padding: 10px 12px !important;
  }
  .header .header-container > .main-nav {
    position: fixed !important;
    grid-column: 1 / -1 !important;
    grid-row: 1 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    justify-self: stretch !important;
    align-items: stretch !important;
    box-sizing: border-box;
  }
}

/* M39 navigation containment: keep eight approved menu triggers in one desktop row.
   Scoped to the existing header; does not restyle the approved mega-menu cards. */
@media (min-width: 1101px) {
  /* Closed absolute mega-menus must not enlarge the document scroll area.
     The controller restores their normal absolute positioning by adding
     .is-open before they become visible. */
  .header .nav-item-mega:not(.is-open) > .mega-menu {
    position: fixed;
  }
  .header .header-container > .main-nav {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    gap: 8px;
  }
  .header .main-nav > ul {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: clamp(3px, .4vw, 8px);
    margin: 0;
    padding: 0;
    min-width: 0;
    list-style: none;
  }
  .header .main-nav > ul > .nav-item-mega {
    display: block;
    flex: 0 1 auto;
    min-width: 0;
    position: relative;
  }
  .header .main-nav > ul > .nav-item-mega > .nav-mega-trigger {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
    font-size: clamp(10px, .78vw, 14px);
    padding-inline: 2px;
  }
  .header .main-nav > .header-tools {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    margin-left: 8px;
  }
}

/* M39 final menu polish: internal spacing and readable pending labels only.
   No navigation structure, column assignment, or trigger behavior changes. */
@media (min-width: 1101px) {
  .header .mega-menu--headed {
    height: auto;
    min-height: 0;
  }
  .header .mega-menu-inner--headed {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
    column-gap: clamp(20px, 2.4vw, 30px);
    row-gap: 8px;
    height: auto;
    min-height: 0;
    max-height: 60vh;
    max-height: min(60vh, calc(100dvh - 160px));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 12px;
  }
}

.header .mega-menu-inner--headed > .mega-col--headed {
  justify-content: flex-start;
  align-items: stretch;
  align-self: start;
  height: max-content;
  min-width: 0;
  min-height: 0;
}
.header .mega-col--headed > .mega-col-header {
  flex: 0 0 auto;
  align-items: flex-start;
  min-width: 0;
  padding-bottom: 10px;
  margin-bottom: 4px;
  break-after: avoid;
}
.header .mega-col--headed > .mega-col-header:not(:first-child) {
  margin-top: 16px;
}
.header .mega-col--headed > .mega-col-desc-list {
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  margin: 0;
  gap: 0;
  break-before: avoid;
  break-inside: avoid;
}
.header .mega-col-desc-list > li {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 7px 4px 7px 44px;
}
.header .mega-col-desc-list > li > a {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
}
.header .mega-col-heading {
  min-width: 0;
}
.header .mega-col-heading strong,
.header .mega-col-heading small,
.header .mega-col-desc-list strong,
.header .mega-col-desc-list small {
  overflow-wrap: break-word;
}
.header .mega-item-soon > span {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}
.header .mega-item-soon strong { color: #64748b; }
.header .mega-item-soon small { color: #718096; }
