/*
 * Header refresh extension
 * Load after site.css, deep-dive.css, and about-page.css.
 * This file expects the header/footer contract documented in
 * research/header-refresh-design.md and intentionally leaves existing
 * category navigation, mobile-menu behaviour, and component scripts intact.
 */

:root {
  --header-refresh-navy: #061b2b;
  --header-refresh-ink: #173240;
  --header-refresh-gold: #c8a45c;
  --header-refresh-pale-gold: #e7d2a1;
  --header-refresh-focus: #74561c;
}

/*
 * Page keywords remain complete rather than becoming an ellipsis-only strip.
 * The block is deliberately outside .site-header, so it never joins the
 * sticky stack or consumes sticky-header-height.
 */
.keyword-meta {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  border-bottom: 1px solid #e5e6e0;
  background: #fff;
  color: #53656d;
  font-size: clamp(10px, 0.72vw, 11px);
  letter-spacing: 0.025em;
  line-height: 1.55;
  padding: 4px var(--space);
}

.keyword-meta > span {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Non-sticky, compact utility rail. */
.utility-bar {
  position: static;
  z-index: auto;
  max-width: 100%;
  background: var(--header-refresh-navy);
  color: var(--header-refresh-pale-gold);
  border-bottom: 1px solid #19384a;
}

.utility-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  min-height: 32px;
  max-width: 1800px;
  margin: 0 auto;
  padding: 3px var(--space);
}

.utility-service {
  flex: 0 1 auto;
  margin: 0;
  color: #f0ddb0;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.055em;
  line-height: 1.45;
  text-wrap: pretty;
}

.utility-links {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 2px 14px;
  min-width: 0;
}

.utility-links a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  color: #dfe9e7;
  font-size: 10px;
  letter-spacing: 0.015em;
  line-height: 1.35;
  white-space: nowrap;
}

.utility-links a:hover {
  color: #fff4d4;
}

.utility-links svg {
  width: 12px;
  height: 12px;
  color: var(--header-refresh-gold);
}

.utility-links .utility-official {
  margin-left: 2px;
  color: #f0ddb0;
  font-weight: 600;
}

.utility-links .utility-official::before {
  content: "";
  width: 1px;
  height: 13px;
  margin-right: 8px;
  background: #456071;
}

/* Sticky main header remains sticky; only its internal proportions change. */
.site-header {
  top: 0;
  overflow: visible;
}

.main-nav {
  height: auto;
  min-height: 138px;
  gap: clamp(18px, 2vw, 34px);
  padding-top: 12px;
  padding-bottom: 12px;
}

.brand {
  min-width: 0;
  gap: 16px;
  flex-shrink: 1;
}

.brand-logo {
  width: 114px;
  height: 114px;
  max-width: none;
  flex: 0 0 114px;
  object-fit: contain;
}

.brand-word {
  --brand-copy-width: clamp(288px, 24vw, 440px);
  flex: 0 1 var(--brand-copy-width);
  inline-size: min(var(--brand-copy-width), 100%);
  min-width: 0;
  max-inline-size: 100%;
  color: var(--header-refresh-ink);
  font-family: var(--sans);
  line-height: 1.25;
}

.brand-word strong,
.brand-word .brand-subtitle,
.brand-word small {
  display: block;
  max-width: 100%;
  overflow-wrap: normal;
  word-break: normal;
  white-space: nowrap;
}

.brand-word strong {
  color: var(--header-refresh-ink);
  font-family: var(--serif);
  font-size: clamp(31px, 1.9vw, 36px);
  font-weight: 600;
  letter-spacing: 0.025em;
  line-height: 1.22;
}

.brand-word .brand-company {
  color: #8c6b2e;
  font-size: 0.65em;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.brand-word .brand-subtitle {
  margin-top: 6px;
  color: #3d5c6b;
  font-family: var(--sans);
  font-size: clamp(13px, 0.95vw, 16px);
  font-weight: 500;
  letter-spacing: 0.025em;
  line-height: 1.35;
}

.brand-word small {
  margin-top: 4px;
  color: #876f3d;
  font-family: var(--sans);
  font-size: clamp(10px, 0.7vw, 12px);
  font-weight: 600;
  letter-spacing: 0.12em;
  line-height: 1.3;
}

/* The script restores no-wrap only after ranges have been fitted to this box. */
.brand-word.brand-fit-ready strong,
.brand-word.brand-fit-ready .brand-subtitle,
.brand-word.brand-fit-ready small {
  white-space: nowrap;
}

.primary-nav {
  gap: clamp(15px, 1.4vw, 30px);
}

.primary-nav > a {
  padding: 10px 0;
  font-size: 13px;
}

.primary-nav > a::after {
  bottom: 2px;
}

.nav-actions {
  gap: 16px;
}

.nav-actions .button {
  gap: 12px;
}

.contact-link {
  min-height: 32px;
}

/* Keyboard focus stays visible over both the pale main header and navy rail. */
.brand:focus-visible,
.primary-nav > a:focus-visible,
.nav-actions a:focus-visible,
.mobile-menu:focus-visible,
.utility-links a:focus-visible {
  outline: 2px solid var(--header-refresh-focus);
  outline-offset: 3px;
}

.utility-links a:focus-visible {
  outline-color: #fff4d4;
}

/*
 * 1280–1700 uses the otherwise underused second line for navigation. This
 * prevents the long three-line brand and all primary links competing in one
 * narrow row. At very wide widths the base flex layout remains a single row.
 */
@media (max-width: 1700px) and (min-width: 1101px) {
  .main-nav {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
    min-height: 160px;
    gap: 5px 28px;
  }

  .brand {
    grid-column: 1;
    grid-row: 1;
  }

  .nav-actions {
    grid-column: 2;
    grid-row: 1;
    justify-content: flex-end;
  }

  .primary-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: space-between;
    width: 100%;
    margin-left: 0;
    gap: 16px;
  }

  .primary-nav > a {
    padding: 8px 0;
  }
}

/* Source breakpoint was <=1280. Strict two-times presentation size: 102px. */
@media (max-width: 1280px) {
  .brand-logo {
    width: 102px;
    height: 102px;
    flex-basis: 102px;
  }

  .brand-word strong {
    font-size: clamp(28px, 2.25vw, 32px);
  }

  .brand-word .brand-subtitle {
    font-size: 14px;
  }

  .brand-word small {
    font-size: 10px;
  }

  .primary-nav {
    gap: 12px;
  }

  .primary-nav > a {
    font-size: 12px;
  }

  .utility-inner {
    gap: 5px 18px;
  }

  .utility-links {
    gap: 2px 10px;
  }
}

/*
 * This is intentionally above the legacy <=1024 toggle, so there is no
 * tablet interval in which both the primary navigation and menu are hidden.
 */
@media (max-width: 1100px) {
  .main-nav {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto;
    align-items: center;
    min-height: 130px;
    gap: 18px;
  }

  .brand {
    grid-column: 1;
    grid-row: 1;
  }

  .primary-nav {
    display: none;
  }

  .nav-actions {
    grid-column: 2;
    grid-row: 1;
    justify-content: flex-end;
  }

  .mobile-menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
  }

  .utility-inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 1px;
    padding-top: 4px;
    padding-bottom: 4px;
  }

  .utility-links {
    justify-content: flex-start;
    width: 100%;
  }
}

@media (max-width: 760px) {
  .keyword-meta {
    font-size: 10px;
    line-height: 1.5;
    padding-top: 3px;
    padding-bottom: 3px;
  }

  .utility-service {
    font-size: 9px;
  }

  .utility-links {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    padding-bottom: 1px;
    scrollbar-width: thin;
    white-space: nowrap;
  }

  .utility-links a {
    flex: 0 0 auto;
    font-size: 9px;
  }

  .main-nav {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    min-height: 0;
    gap: 6px 12px;
    padding-top: 9px;
    padding-bottom: 9px;
  }

  .brand {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    gap: 12px;
  }

  .brand-logo {
    width: 86px;
    height: 86px;
    flex-basis: 86px;
  }

  .brand-word {
    --brand-copy-width: 100%;
    flex: 1 1 auto;
    inline-size: auto;
  }

  .brand-word strong {
    font-size: clamp(17px, 4.9vw, 24px);
    letter-spacing: 0.02em;
    line-height: 1.25;
  }

  .brand-word .brand-subtitle {
    margin-top: 3px;
    font-size: clamp(11px, 3.1vw, 14px);
    line-height: 1.35;
  }

  .brand-word small {
    margin-top: 3px;
    font-size: clamp(9px, 2.55vw, 11px);
    letter-spacing: 0.1em;
    line-height: 1.3;
  }

  .brand-word:not(.brand-fit-ready) strong,
  .brand-word:not(.brand-fit-ready) .brand-subtitle,
  .brand-word:not(.brand-fit-ready) small {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .contact-link {
    display: none;
  }

  .nav-actions {
    grid-column: 1;
    grid-row: 2;
    justify-content: flex-end;
    gap: 8px;
    width: 100%;
  }

  .nav-actions .button {
    min-height: 44px;
    padding: 8px 12px;
    gap: 8px;
    font-size: 11px;
    line-height: 1.25;
    white-space: nowrap;
  }

  .nav-actions .button svg {
    width: 13px;
    height: 13px;
  }

  .mobile-menu {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
  }
}

@media (max-width: 480px) {
  .utility-links {
    gap: 2px 9px;
  }

  .utility-links .utility-official::before {
    margin-right: 6px;
  }

  .main-nav {
    min-height: 0;
    gap: 6px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .brand {
    gap: 10px;
    align-items: center;
  }

  .brand-word strong {
    font-size: clamp(16px, 5vw, 20px);
    line-height: 1.28;
  }

  .brand-word .brand-subtitle {
    font-size: clamp(10.5px, 3.2vw, 12px);
    line-height: 1.35;
  }

  .brand-word small {
    font-size: 9px;
    letter-spacing: 0.075em;
  }

  .nav-actions {
    gap: 6px;
  }

  .nav-actions .button {
    display: inline-flex;
    flex-direction: row;
    justify-content: center;
    width: auto;
    max-inline-size: none;
    min-height: 44px;
    padding: 8px 10px;
    font-size: 10px;
  }
}

/* The original <=380 rule changed only width (37px); preserve that geometry at 2x. */
@media (max-width: 380px) {
  .brand-logo {
    width: 74px;
    height: 86px;
    flex-basis: 74px;
  }
}

/* Footer uses the same required three-line identity without widening columns. */
.site-footer .brand {
  align-items: center;
  max-width: 100%;
  gap: 16px;
}

.site-footer .brand-logo {
  width: 114px;
  height: 114px;
  max-width: none;
  flex-basis: 114px;
}

.site-footer .brand-word {
  --brand-copy-width: min(23rem, 100%);
  flex: 1 1 var(--brand-copy-width);
  inline-size: min(var(--brand-copy-width), 100%);
  min-width: 0;
  max-width: calc(100% - 130px);
}

.site-footer .brand-word strong {
  color: #fff;
  font-size: clamp(26px, 1.65vw, 30px);
  letter-spacing: 0.025em;
  line-height: 1.22;
}

.site-footer .brand-word .brand-company {
  color: #e7d2a1;
}

.site-footer .brand-word .brand-subtitle {
  margin-top: 6px;
  color: #c8d8df;
  font-size: clamp(12px, 0.82vw, 14px);
  line-height: 1.35;
}

.site-footer .brand-word small {
  margin-top: 4px;
  color: var(--header-refresh-pale-gold);
  font-size: clamp(9px, 0.62vw, 10px);
  letter-spacing: 0.11em;
}

@media (max-width: 1280px) {
  .footer-top {
    gap: 30px;
  }

  .footer-top > * {
    min-width: 0;
  }

  .site-footer .brand-logo {
    width: 102px;
    height: 102px;
    flex-basis: 102px;
  }

  .site-footer .brand-word {
    --brand-copy-width: 100%;
    max-width: calc(100% - 120px);
  }

  .site-footer .brand-word strong {
    font-size: clamp(22px, 2vw, 26px);
  }

  .site-footer .brand-word .brand-subtitle {
    font-size: 12px;
  }

  .site-footer .brand-word:not(.brand-fit-ready) strong,
  .site-footer .brand-word:not(.brand-fit-ready) .brand-subtitle,
  .site-footer .brand-word:not(.brand-fit-ready) small {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 1024px) {
  .site-footer .brand-word {
    max-width: calc(100% - 130px);
  }
}

@media (max-width: 760px) {
  .site-footer .brand-logo {
    width: 86px;
    height: 86px;
    flex-basis: 86px;
  }

  .site-footer .brand-word {
    max-width: calc(100% - 100px);
  }

  .site-footer .brand-word strong {
    font-size: 20px;
  }

  .site-footer .brand-word .brand-subtitle {
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  .site-footer .brand {
    gap: 10px;
  }

  .site-footer .brand-word strong {
    font-size: 18px;
  }

  .site-footer .brand-word .brand-subtitle {
    font-size: 10.5px;
  }

  .site-footer .brand-word small {
    font-size: 8px;
  }
}

@media (max-width: 380px) {
  .site-footer .brand-logo {
    width: 74px;
    height: 86px;
    flex-basis: 74px;
  }

  .site-footer .brand-word {
    max-width: calc(100% - 84px);
  }
}

/* Sticky table of contents and native targets follow the measured header only. */
html {
  scroll-padding-top: var(--sticky-header-height, 170px);
}

:target {
  scroll-margin-top: var(--sticky-header-height, 170px);
}

.guide-toc {
  top: calc(var(--sticky-header-height, 170px) + 18px);
  max-height: calc(100vh - var(--sticky-header-height, 170px) - 36px);
  max-height: calc(100dvh - var(--sticky-header-height, 170px) - 36px);
}
