/*
 * Ask Gordon integration test — intentionally uses the ORIGINAL website's CSS variables.
 * No replacements for its layout, type scale, color system or navigation rules.
 * All component selectors are scoped to the injected panel and its focus indicators.
 */
:root { --gordon-guide-width: clamp(340px, 30vw, 430px); }
@media (min-width:1120px) {
  body.gordon-guide-open { margin-right: var(--gordon-guide-width); }
  body.gordon-guide-open header .pillars { gap: 0.25rem; font-size: 0.75em; line-height: 1em; display: flex; align-items: center; }
}
body.gordon-guide-open #gordon-guide-panel { display: flex; }
#gordon-guide-panel {
  position: fixed; z-index: 1300; top: 0; right: 0; bottom: 0;
  width: var(--gordon-guide-width); display: none; flex-direction: column;
  background: var(--cool-section-background); color: var(--page-text);
  box-shadow: 1px 0 5px 0 var(--warm-divider);
  font-family: inherit; font-size: 0.86rem; line-height: 1.5;
}
#gordon-guide-panel *, #gordon-guide-panel *::before, #gordon-guide-panel *::after { box-sizing: border-box; }
#gordon-guide-panel button, #gordon-guide-launch { cursor: pointer; font: inherit; }
#gordon-guide-panel p {
  display: block;
  margin: 0;
  padding: 0;
}
#gordon-guide-panel strong { color: inherit; }
/* Original site heading rules are authoritative. */
.gordon-guide-head {
  flex: 0 0 auto;
  padding: 1rem 1rem .75rem 1rem;
  background: var(--header-background);
  border-bottom: 1px solid var(--warm-divider);
  height: var(--height-header);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.gordon-guide-heading-row { display: flex; justify-content: space-between; align-items: center; }
#gordon-guide-panel .gordon-guide-title { font-size: 1.5rem; font-weight: 700; line-height: 1.25; color: var(--page-text); }
.gordon-guide-head-actions { display: flex; gap: .4rem; align-items: center; }
#gordon-guide-panel .gordon-guide-head-actions button {
  flex: 0 0 auto; border: 1px solid var(--control-border); background: transparent;
  color: var(--page-text); border-radius: 999px; padding: .35rem .5rem; font-size: .68rem;
}
#gordon-guide-panel #gordon-guide-close { width: 2rem; height: 2rem; padding: 0; font-size: 1.2rem; line-height: 1; }
/* Follow uses the site's Theme selection contract: filled when on, outlined when off. */
#gordon-guide-panel #gordon-guide-follow[aria-pressed="true"] {
  border-color: var(--cool-active-background);
  background: var(--cool-active-background);
  color: var(--cool-active-text);
  font-weight: 700;
}
#gordon-guide-panel .gordon-guide-intro { margin: 0; color: var(--muted-text); font-size: .73rem; }
.gordon-guide-context {
  flex: 0 0 auto; display: flex; justify-content: space-between; align-items: center; gap: .55rem;
  padding: .75rem 1rem; border-bottom: 1px solid var(--cool-divider);
}
.gordon-guide-context small { display: block; font-size: .62rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-text); }
#gordon-guide-panel .gordon-guide-context strong { display: block; font-weight: 700; font-size: .81rem; line-height: 1.3; }
#gordon-guide-panel .gordon-guide-context button {
  border: 1px solid var(--control-border); padding: .35rem .6rem; border-radius: 999px;
  color: var(--page-text); background: transparent; font-size: .66rem; flex-shrink: 0;
}
.gordon-guide-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: .7rem;
  display: flex;
  flex-direction: column;
}
.gordon-guide-message {
  padding: .72rem .85rem;
  border-radius: .4rem;
  color: var(--page-text);
  overflow-wrap: anywhere;
}
.gordon-guide-message.user {
  background: var(--cool-section-background);
  align-self: flex-end;
  max-width: 88%;
}
.gordon-guide-message.error { border-color: var(--warm-border); }
.gordon-guide-speaker { font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--cool-emphasis-text); margin-bottom: .3rem; }
.gordon-guide-message.user .gordon-guide-speaker, .gordon-guide-message.error .gordon-guide-speaker { color: var(--link-text); }
.gordon-guide-starters, .gordon-guide-related { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .65rem; }
.gordon-guide-starters { justify-content: center; }
#gordon-guide-panel .gordon-guide-starters button, #gordon-guide-panel .gordon-guide-related button {
  border: 1px solid var(--cool-border); background: transparent; border-radius: 1.25rem;
  color: var(--page-text); padding: .35rem .56rem; font-size: .68rem; text-align: left;
}
#gordon-guide-panel .gordon-guide-starters button:hover, #gordon-guide-panel .gordon-guide-related button:hover {
  background: var(--cool-active-background); color: var(--cool-active-text);
}
.gordon-guide-compose {
  flex: 0 0 auto;
  padding: .7rem;
}
#gordon-guide-form { display: flex; gap: .45rem; align-items: end; }
#gordon-guide-form textarea {
  flex: 1 1 auto; min-width: 0; min-height: 3.3rem; max-height: 12rem; resize: vertical;
  background: var(--page-background); color: var(--page-text);
  border: 1px solid var(--control-border); border-radius: .4rem; padding: .65rem;
  font: inherit; font-size: .78rem;
}
#gordon-guide-panel #gordon-guide-send {
  flex: 0 0 auto; background: var(--warm-active-background); color: var(--warm-active-text);
  border: 1px solid var(--warm-border); border-radius: .4rem; padding: .65rem .74rem;
  font-weight: 700; font-size: .76rem;
}
#gordon-guide-panel button:disabled { opacity: .55; cursor: wait; }
#gordon-guide-panel .gordon-guide-notice {
  margin: .5rem;
  font-size: .63rem;
  color: var(--muted-text);
  line-height: 1.45;
  text-align: center;
}
#gordon-guide-panel .gordon-guide-notice a {
  color: var(--link-text); text-decoration: underline; text-underline-offset: 2px;
}
#gordon-guide-panel .gordon-guide-notice a:hover { text-decoration-thickness: 2px; }
#gordon-guide-status { display: block; margin-top: .2rem; font-size: .64rem; color: var(--muted-text); }
#gordon-guide-status:empty { display: none; }
#gordon-guide-launch {
  position: fixed; z-index: 1290; bottom: 1rem; right: 1rem; border-radius: 999px;
  background: var(--warm-active-background); color: var(--warm-active-text);
  border: 1px solid var(--warm-border); padding: .7rem 1.1rem;
  box-shadow: 0 2px 12px color-mix(in srgb, var(--warm-surface) 28%, transparent);
  font-family: inherit; font-weight: 700; font-size: .88rem;
}
body.gordon-guide-open #gordon-guide-launch { display: none; }
.gordon-guide-sr { position: absolute!important; width: 1px!important; height: 1px!important; overflow: hidden!important; clip: rect(0,0,0,0)!important; }
/* One rectangular frame for every topic, sized to the complete semantic region.
   It is independent of the site's original bands, headings, article and nav styling. */
/* Four fixed, inert panes darken everything outside the current topic.
   The Ask Gordon panel (z-index 1300) remains fully lit and interactive. */
.gordon-guide-spotlight-scrim {
  position: fixed;
  z-index: 1250;
  pointer-events: none;
  background: rgba(0, 0, 0, .58);
}
.gordon-guide-spotlight-scrim[hidden] { display: none; }
#gordon-guide-focus-frame {
  position: absolute;
  z-index: 1251;
  pointer-events: none;
  background: color-mix(in srgb, var(--cool-accent) 2%, transparent);
  box-shadow: inset 0 0 0 2px var(--cool-accent);
  border-radius: 2px;
}
#gordon-guide-focus-frame[hidden], body:not(.gordon-guide-open):not(.gordon-guide-mobile-evidence) #gordon-guide-focus-frame { display: none; }
.gordon-guide-focus-label {
  position: absolute;
  left: 50%;
  top: 0;
  width: max-content;
  max-width: min(98%, 26rem);
  padding: .3rem .6rem;
  background: var(--cool-section-background);
  color: var(--cool-emphasis-text);
  font: 700 .71rem/1.3 'Roboto Slab', Georgia, serif;
  text-align: center;
  white-space: normal;
  transform: translate(-50%, -50%);
  border-radius: 20px;
  box-shadow: 0 0 0 2px var(--cool-accent);
}
@media(max-width:1119px) {
  #gordon-guide-panel { top: var(--height-link,60px); width: min(440px, 100vw); z-index: 1300; }
  body.gordon-guide-open { margin-right: 0; }
}
@media(max-width:640px) {
  #gordon-guide-panel { top: 0; width: 100vw; }
}
@media(prefers-reduced-motion:reduce){ #gordon-guide-focus-frame { transition: none; } }

/* When the conversational spotlight is active, it—not the site's scroll spy—
   determines the highlighted left-navigation item. The site's classes and
   original CSS resume control whenever the spotlight is hidden. */
body.gordon-guide-spotlight-active nav#site-nav .navlink.active:not(.gordon-guide-nav-focus) {
  background: transparent;
  color: var(--muted-text);
  border-left-color: transparent;
  box-shadow: none;
}
body.gordon-guide-spotlight-active nav#site-nav .navlink.gordon-guide-nav-focus {
  background: var(--warm-active-background);
  color: var(--warm-active-text);
  border-left-color: var(--nav-active-border);
}

/* Chat-first entry: reuse the same chat and site tokens, but render it as the
   primary content rather than a fixed sidebar. Integrated pages are unchanged. */
body.gordon-chat-first.gordon-guide-open { margin-right: 0; }
body.gordon-chat-first header .pillars { gap: initial; font-size: inherit; }
.gordon-chat-first-main {
  padding: 0;
  min-height: calc(100vh - var(--height-header, 100px));
}
.gordon-chat-first-stage { max-width: 850px; margin: 0 auto; }
body.gordon-chat-first #gordon-guide-panel {
  position: relative;
  inset: auto;
  display: none;
  width: 100%;
  height: calc(100vh - var(--height-header, 100px));
  min-height: 480px;
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
  background: transparent;
}
body.gordon-chat-first.gordon-guide-open #gordon-guide-panel { display: flex; }
/* The dedicated chat homepage stays open; content-page chat remains closable. */
body.gordon-chat-first #gordon-guide-close { display: none; }
body.gordon-chat-first .gordon-guide-context,
body.gordon-chat-first #gordon-guide-follow { display: none; }
body.gordon-chat-first > footer { display: none !important; }
body.gordon-chat-first .gordon-chat-first-starters { padding: .25rem 0 .5rem; }

@media (min-width: 1120px) {
  body.gordon-chat-first .gordon-chat-first-main {
    height: calc(100vh - var(--height-header));
    height: calc(100dvh - var(--height-header));
    min-height: 0;
    padding: 0;
  }
  body.gordon-chat-first .gordon-chat-first-stage { height: 100%; }
  body.gordon-chat-first #gordon-guide-panel { height: 100%; min-height: 0; }
}
@media (max-width: 1119px) {
  body.gordon-chat-first.gordon-guide-open { margin-right: 0; }
  .gordon-chat-first-main { padding: 1rem .6rem 3rem; }
  body.gordon-chat-first #gordon-guide-panel {
    position: relative; inset: auto; width: 100%; height: min(78vh, 770px);
    min-height: 420px;
  }
}
@media (max-width: 640px) {
  body.gordon-chat-first #gordon-guide-panel { min-height: 470px; }
}

/* Mobile chat-first: composer stays visible on load without forcing browser focus. */
@media (max-width: 640px) {
  body.gordon-chat-first #gordon-guide-panel {
    height: auto;
    min-height: 0;
  }
}


/* Mobile chat-first: full-viewport aside below the website header. */
@media (max-width: 1119px) {
  /* The global header and its expandable navigation remain available. */
  body.gordon-chat-first { overflow: hidden; }
  body.gordon-chat-first .gordon-chat-first-main > :not(.gordon-chat-first-stage),
  body.gordon-chat-first > footer,
  body.gordon-chat-first #gordon-guide-launch { display: none !important; }
  body.gordon-chat-first .gordon-chat-first-main { padding: 0; margin: 0; min-height: 0; height: 0; }
  body.gordon-chat-first .gordon-chat-first-stage { max-width: none; margin: 0; }

  body.gordon-chat-first.gordon-guide-open #gordon-guide-panel {
    display: flex;
    position: fixed;
    inset: var(--height-link) 0 0;
    width: 100vw;
    height: calc(100vh - var(--height-link));
    height: calc(100dvh - var(--height-link));
    min-height: 0;
    box-shadow: none;
    border: 0;
    border-radius: 0;
    overflow: hidden;
  }
  /* One title/description, inside the aside rather than duplicated in main. */
  body.gordon-chat-first .gordon-guide-head { height: unset; }

  /* Messages scroll; the composer stays inside the visible viewport. */
  body.gordon-chat-first .gordon-guide-compose {
    flex: 0 0 auto;
    padding-bottom: max(.5rem, env(safe-area-inset-bottom));
  }
}

/* Mobile site navigation takes precedence over the chat when opened. */
@media (max-width: 1119px) {
  body.menu-open nav#site-nav.is-open {
    z-index: 1400; /* site drawer > Ask Gordon (1300) and spotlight (1250) */
  }
}


/* Ask Gordon follows the site's Definitions theme. */
body.definitions-active header {
  background: var(--definitions-header-background);
  box-shadow: inset 0 -1px var(--cool-divider);
}
body.definitions-active:not(.gordon-chat-first) #gordon-guide-panel {
  box-shadow: -1px 0 5px 0 var(--cool-divider);
}

body.definitions-active:not(.gordon-chat-first) #gordon-guide-panel .gordon-guide-title,
body.definitions-active:not(.gordon-chat-first) #gordon-guide-panel .gordon-guide-message.user .gordon-guide-speaker,
body.definitions-active:not(.gordon-chat-first) #gordon-guide-panel .gordon-guide-notice a,
body.definitions-active:not(.gordon-chat-first) #gordon-guide-panel .gordon-guide-message a {
  color: var(--definitions-header-text);
}

body.definitions-active:not(.gordon-chat-first) #gordon-guide-panel #gordon-guide-send {
  background: var(--cool-active-background);
  color: var(--cool-active-text);
  border-color: var(--cool-divider);
}

body.definitions-active.gordon-guide-spotlight-active nav#site-nav .navlink.gordon-guide-nav-focus {
  background: var(--cool-active-background);
  color: var(--cool-active-text);
  border-left-color: var(--nav-active-border);
}

/* Original site navigation width is authoritative. */

.gordon-guide-message.user {
  filter: brightness(93%) saturate(2.67);
}

/* Privacy and deletion: an accessible, collapsed disclosure separate from the
   exact approved notice. Shared by chat-first and site-integrated chat. */
#gordon-guide-panel .gordon-guide-privacy {
  margin: .1rem .5rem 0;
  font-size: .68rem;
  line-height: 1.45;
  text-align: center;
  color: var(--muted-text);
}
#gordon-guide-panel .gordon-guide-privacy summary {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
#gordon-guide-panel .gordon-guide-privacy-description {
  max-height: min(23vh, 9rem);
  overflow-y: auto;
  padding: .25rem .2rem;
}
#gordon-guide-panel .gordon-guide-privacy a {
  color: var(--link-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}
