/* BeargrassPublishing v2 — chrome.css.

   Persistent site chrome. Direct port of the v1 heritage chrome
   (cream paper-elev tint, sticky, uppercase nav, pill mode toggle,
   ink wordmark with barn "AI" accent), with mode-aware overrides
   layered through :root[data-mode="..."] selectors instead of the
   v1 patches that sat on top via !important. The result is the
   same visible chrome as v1, with no !important.
*/

/* ============================================================
   Heritage chrome (top bar) — sticky, cream-tinted, blurred
   ============================================================ */

.heritage-chrome {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--paper-elev) 92%, transparent);
  -webkit-backdrop-filter: blur(10px) saturate(115%);
          backdrop-filter: blur(10px) saturate(115%);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}
@supports not (backdrop-filter: blur(1px)) {
  .heritage-chrome { background: var(--paper-elev); }
}

.heritage-chrome__inner {
  max-width: var(--w-content);
  margin: 0 auto;
  padding: 16px var(--pad-x);
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem 1.25rem;
}

.heritage-header-cluster {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem 1.25rem;
  flex: 1 1 auto;
  min-width: 0;
}

/* ============================================================
   Wordmark
   ============================================================ */

.wordmark-lockup {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--ink);
  flex-shrink: 0;
}
.heritage-chrome .wordmark-type {
  font-family: var(--type-italic);
  font-size: clamp(20px, 2vw, 28px);
  line-height: 1;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.08em;
  letter-spacing: -0.02em;
}

/* Locked SVG wordmark: ink + barn on light, cream-fixed + warm-bright
   on dark. The light variant is for cream backgrounds, the dark
   variant is the cream-fill for navy/dark backgrounds. The chrome
   surface is dark on every page mode (heritage chrome sits on a
   navy band), so the chrome always shows the dark variant. Default
   page surfaces show the light variant unless a mode override
   flips it. Without explicit dimensions on the IMG, the SVG inline
   style "max-width:100%; height:auto" collapses to zero in an
   inline parent, which is why the chrome wordmark was invisible
   before this rule was added. */
.bgai-mark {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}
.bgai-mark img {
  width: auto;
  height: 100%;
}
.heritage-chrome .bgai-mark {
  height: clamp(22px, 2.4vw, 30px);
}
.site-foot__wm .bgai-mark {
  height: clamp(22px, 2vw, 28px);
}
.bgai-mark img.bgai-mark__light { display: block; }
.bgai-mark img.bgai-mark__dark { display: none; }
:root[data-mode="night"] .bgai-mark img.bgai-mark__light { display: none; }
:root[data-mode="night"] .bgai-mark img.bgai-mark__dark { display: block; }
.heritage-chrome .bgai-mark img.bgai-mark__light { display: none; }
.heritage-chrome .bgai-mark img.bgai-mark__dark { display: block; }
:root[data-mode="open"] .site-foot__wm .bgai-mark img.bgai-mark__light { display: none; }
:root[data-mode="open"] .site-foot__wm .bgai-mark img.bgai-mark__dark { display: block; }
.heritage-chrome .bgai-wm {
  display: inline-flex;
  align-items: baseline;
  gap: 0.05em;
  font-family: var(--type-italic);
  font-weight: 600;
  font-size: inherit;
  letter-spacing: 0.01em;
}
.heritage-chrome .bgai-wm .w-beargrass { color: var(--ink); }
.heritage-chrome .bgai-wm .w-ai {
  color: var(--barn);
  font-weight: 700;
}
.heritage-chrome .bgai-wm .w-section {
  font-family: var(--type-ui);
  font-size: 0.5em;
  letter-spacing: 0.05em;
  color: var(--ink-sec);
  margin-left: 0.6em;
  font-weight: 600;
}

/* ============================================================
   Primary nav (row 1)
   ============================================================ */

.heritage-sitenav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 1.1rem;
  font-family: var(--type-ui);
  font-size: 13px;
  letter-spacing: 0.05em;
  font-weight: 600;
  min-width: 0;
}
.heritage-sitenav a {
  color: var(--ink-sec);
  text-decoration: none;
  transition: color 0.18s ease;
}
.heritage-sitenav a:hover { color: var(--ink); }
.heritage-sitenav a.is-active { color: var(--barn); font-weight: 600; }

/* ============================================================
   Section nav (row 2)
   ============================================================ */

.heritage-chrome__inner--section {
  max-width: var(--w-content);
  margin: 0 auto;
  padding: 0.55rem var(--pad-x);
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1.5rem;
  font-family: var(--type-ui);
}

.heritage-edition {
  font-family: var(--type-ui);
  font-size: 12px;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--barn);
  flex-shrink: 0;
}
.heritage-edition::after {
  content: "";
  display: inline-block;
  width: 1px;
  height: 0.85em;
  margin: 0 0.25rem 0 0.85rem;
  background: var(--rule);
  vertical-align: -0.1em;
}

.heritage-sectionnav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 1.4rem;
  font-family: var(--type-ui);
  font-size: 12px;
  letter-spacing: 0.05em;
  font-weight: 600;
  flex: 1 1 auto;
  min-width: 0;
}
.heritage-sectionnav a {
  color: var(--ink-ter);
  text-decoration: none;
  transition: color 0.18s ease;
}
.heritage-sectionnav a:hover { color: var(--ink); }
.heritage-sectionnav a.is-active {
  color: var(--barn);
  font-weight: 600;
}

@media (max-width: 700px) {
  .heritage-chrome__inner--section {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
  }
  .heritage-sectionnav { flex-wrap: nowrap; }
  .heritage-sectionnav a { white-space: nowrap; }
}

/* ============================================================
   CTA in chrome (Contact button)
   ============================================================ */

.heritage-cta {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  font-family: var(--type-ui);
  font-size: 12px;
  letter-spacing: 0.05em;
}
/* Contact CTA — locked to ONE color combination across every mode
   and every page. var(--paper) was resolving to dark navy in Night
   mode (since paper tokens swap per mode), producing dark-on-red
   low-contrast text. Mark 2026-05-05: Contact button must read the
   same on every page. Use fixed values, no token swaps. */
.heritage-cta a.cta,
:root[data-mode="paper"] .heritage-cta a.cta,
:root[data-mode="night"] .heritage-cta a.cta,
:root[data-mode="open"]  .heritage-cta a.cta {
  background: #a64b3b;
  color: #f0e6cf;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 0.85rem;
  border-radius: var(--r-pill);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  margin: 0;
  transition: filter 0.2s ease;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: none;
}
.heritage-cta a.cta:hover,
:root[data-mode="paper"] .heritage-cta a.cta:hover,
:root[data-mode="night"] .heritage-cta a.cta:hover,
:root[data-mode="open"]  .heritage-cta a.cta:hover {
  filter: brightness(1.08);
  color: #f0e6cf;
}
.heritage-cta a.cta.is-active { background: #a64b3b; color: #f0e6cf; }

/* ============================================================
   Mode toggle (pill, three-button)
   ============================================================ */

.mode-toggle {
  display: inline-flex;
  padding: 2px;
  background: var(--paper-tint);
  border: 1px solid var(--rule);
  border-radius: var(--r-pill);
  flex-shrink: 0;
  align-items: center;
}
.mode-toggle__btn {
  background: transparent;
  border: none;
  margin: 0;
  padding: 0;
  width: 22px;
  height: 22px;
  color: var(--ink-ter);
  cursor: pointer;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
  line-height: 1;
  font-size: 0;
}
.mode-toggle__icon {
  width: 14px;
  height: 14px;
  display: block;
  pointer-events: none;
  stroke-width: 1.6;
}
/* Active state — same warm yellow in every mode, no exceptions.
   Mark 2026-05-05: locked the active pill to one color so it reads
   as the same control regardless of which mode is on. */
.mode-toggle__btn[aria-pressed="true"],
:root[data-mode="paper"] .mode-toggle__btn[aria-pressed="true"],
:root[data-mode="night"] .mode-toggle__btn[aria-pressed="true"],
:root[data-mode="open"]  .mode-toggle__btn[aria-pressed="true"] {
  background: var(--warm-bright, #f4c45a);
  color: var(--ink-fixed);
  box-shadow: 0 1px 2px rgba(35, 31, 26, 0.16);
}
.mode-toggle__btn:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
}

/* On sunrise pages (banded layouts + the homepage), the chrome rides
   the dark scene; the toggle switches to a dark-friendly pill so the
   active state still reads. */
body[data-sunrise] .mode-toggle {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}
body[data-sunrise] .mode-toggle__btn { color: rgba(244, 235, 215, 0.75); }
/* The aria-pressed active-state pill is locked to --warm-bright in
   legacy-overrides.css across every mode and body class. Do not add a
   chrome.css rule that reads from --barn or --paper here; both swap and
   would produce coral-on-navy in Night. */

/* Night mode active-state — keep cream pill on dark surface. */
:root[data-mode="night"] .mode-toggle__btn[aria-pressed="true"] {
  background: var(--paper-elev);
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35), 0 2px 10px rgba(0, 0, 0, 0.25);
}

/* ============================================================
   Mobile burger
   ============================================================ */

.nav-toggle {
  appearance: none;
  -webkit-appearance: none;
  background: rgba(244, 235, 215, 0.1);
  border: 1.5px solid rgba(244, 235, 215, 0.4);
  border-radius: var(--r-sm);
  display: none;
  align-items: center;
  justify-content: center;
  /* Mark 2026-05-08: 36x36 keeps the WCAG 44px tap target via touch
     padding while the visible button reads as a quieter chrome control,
     not a billboard. Visible glyph uses a 16x12 bar stack. */
  width: 36px;
  height: 36px;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.18s ease, border-color 0.18s ease;
  color: var(--cream-fixed);
}
.nav-toggle:hover,
.nav-toggle:focus-visible {
  background: rgba(244, 235, 215, 0.18);
  border-color: var(--warm-bright, #f4c45a);
}
.nav-toggle__bars {
  width: 16px; height: 12px;
  display: inline-flex; flex-direction: column; justify-content: space-between;
}
.nav-toggle__bars span {
  display: block;
  width: 100%;
  height: 2px;
  background: currentColor;
  border-radius: var(--r-xs);
}

/* Tablet-and-down: collapse the labelled primary nav into a hamburger
   so the wordmark, mode-toggle pill, and Contact CTA never overlap.
   Reviewer flagged 768-1100px as the broken range; raised the
   breakpoint to 980px and added wrap behavior so the chrome lays
   out cleanly across the band.

   Mark 2026-05-08: at mobile widths the mode-toggle pill collapsed to
   tiny non-tappable icons in the top chrome row. Hide it from chrome
   when the drawer is closed; reveal it as a labeled, full-width row
   inside the open drawer with phone-sized tap targets. */
@media (max-width: 980px) {
  /* Mobile chrome layout — single row: [hamburger | wordmark center | Contact].
     The hamburger lives inside .heritage-header-cluster in the DOM,
     not as a direct child of __inner; flatten the cluster with
     display: contents so each control becomes a flex item of __inner
     and reorderable. The wordmark uses margin: 0 auto to soak up the
     remaining space on both sides — flexbox auto-margins center it
     between the hamburger and the Contact pill. */
  .heritage-chrome__inner {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .heritage-header-cluster {
    display: contents;
  }
  .wordmark-lockup {
    order: 2;
    margin-left: auto;
    margin-right: auto;
    min-width: 0;
  }
  .nav-toggle { order: 1; display: inline-flex; flex: 0 0 auto; }
  .heritage-cta { order: 3; flex: 0 0 auto; }
  .heritage-sitenav {
    display: none;
    order: 99;
    flex-basis: 100%;
    box-sizing: border-box;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: var(--sp-sm) var(--sp-md);
    border-radius: var(--r-md);
    margin-top: var(--sp-sm);
    background: rgba(10, 16, 36, 0.94);
    -webkit-backdrop-filter: blur(12px);
            backdrop-filter: blur(12px);
    border: 1px solid rgba(244, 235, 215, 0.16);
  }
  .heritage-sitenav.is-open { display: flex; }
  .heritage-sitenav a {
    padding: 0.95em 0.5em;
    border-bottom: 1px solid rgba(244, 235, 215, 0.14);
    font-size: 16px;
    color: var(--cream-fixed);
  }
  .heritage-sitenav a:last-child { border-bottom: none; }

  /* Mode toggle: hidden in chrome row, revealed inside the drawer when
     the hamburger is tapped. Sibling selector: mode-toggle comes after
     heritage-sitenav in the DOM. flex-wrap: wrap is required so the
     "View" label takes its own row above the three buttons. */
  .heritage-header-cluster .mode-toggle { display: none; }
  .heritage-sitenav.is-open ~ .mode-toggle {
    display: flex;
    flex-wrap: wrap;
    order: 100;
    flex: 0 0 100%;
    width: 100%;
    box-sizing: border-box;
    justify-content: space-between;
    align-items: stretch;
    margin-top: var(--sp-sm);
    /* Mark 2026-05-09: horizontal padding now matches the sitenav
       above it (sp-md) so both drawer plates have the same visible
       width. Also added box-sizing: border-box so width:100% folds
       padding into the box width. */
    padding: var(--sp-sm) var(--sp-md);
    background: rgba(10, 16, 36, 0.94);
    -webkit-backdrop-filter: blur(12px);
            backdrop-filter: blur(12px);
    border: 1px solid rgba(244, 235, 215, 0.16);
    border-radius: var(--r-md);
    gap: 6px;
  }
  .heritage-sitenav.is-open ~ .mode-toggle::before {
    content: "View";
    flex: 0 0 100%;
    width: 100%;
    font-family: var(--type-ui);
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 700;
    color: rgba(244, 235, 215, 0.7);
    padding: 4px 4px 6px;
    order: -1;
  }
  .heritage-sitenav.is-open ~ .mode-toggle .mode-toggle__btn {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    height: 56px;
    padding: 8px;
    flex-direction: column;
    gap: 4px;
    color: var(--cream-fixed);
  }
  .heritage-sitenav.is-open ~ .mode-toggle .mode-toggle__icon {
    width: 22px;
    height: 22px;
  }
  .heritage-sitenav.is-open ~ .mode-toggle .mode-toggle__btn::after {
    font-family: var(--type-ui);
    font-size: 10px;
    line-height: 1;
    letter-spacing: 0.04em;
    font-weight: 600;
    color: inherit;
    text-transform: none;
  }
  .heritage-sitenav.is-open ~ .mode-toggle .mode-toggle__btn[aria-label="Paper mode"]::after { content: "Paper"; }
  .heritage-sitenav.is-open ~ .mode-toggle .mode-toggle__btn[aria-label="Night mode"]::after { content: "Night"; }
  .heritage-sitenav.is-open ~ .mode-toggle .mode-toggle__btn[aria-label="Open mode"]::after  { content: "Open"; }
  /* Active button readable inside the drawer.
     Mark 2026-05-09: the drawer's color: cream-fixed on
     .mode-toggle__btn (above) had higher specificity than the
     global active rule, so the active warm-yellow pill rendered
     cream-on-yellow (unreadable). This rule restores ink-on-yellow
     for the active button only, matching the intended chrome
     active-state read. */
  .heritage-sitenav.is-open ~ .mode-toggle .mode-toggle__btn[aria-pressed="true"] {
    color: var(--ink-fixed);
  }
}

/* Phone — give the wordmark and Contact pill room to breathe at 320.
   The single-row layout above (display: contents on the cluster +
   wordmark margin auto) holds; this block only tightens type and
   padding so the row fits a 320 viewport without wrap. */
@media (max-width: 700px) {
  .heritage-chrome__inner { padding: 10px var(--pad-x); gap: 0.4rem; }
  .heritage-cta a.cta { padding: 0.4rem 0.7rem; font-size: 12px; }
  .heritage-chrome .wordmark-type { font-size: clamp(15px, 4.4vw, 18px); }
  .heritage-chrome .bgai-mark { height: clamp(18px, 5vw, 22px); }
}

/* ============================================================
   Inverted chrome — every bgai page rides a sunrise scene; the
   chrome flips to cream-on-dark with a dark→transparent gradient
   so it lifts cleanly off the alpine massif behind. The horizon
   stripe at the top of Pattern Y pages (homepage + about) is the
   small indigo→barn→warm bar.
   ============================================================ */

body.bgai-studio .heritage-chrome,
body.bgai-learn  .heritage-chrome {
  background-color: transparent;
  background-image: linear-gradient(to bottom,
    rgba(10, 16, 36, 0.78) 0%,
    rgba(10, 16, 36, 0.42) 60%,
    rgba(10, 16, 36, 0)    100%);
  border-bottom: 0;
  box-shadow: none;
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
}
body.bgai-studio .heritage-chrome .bgai-wm .w-beargrass,
body.bgai-learn  .heritage-chrome .bgai-wm .w-beargrass {
  color: var(--cream-fixed);
  text-shadow: 0 1px 4px rgba(10, 16, 36, 0.85),
               0 0 14px rgba(10, 16, 36, 0.5);
}
body.bgai-studio .heritage-chrome .bgai-wm .w-ai,
body.bgai-learn  .heritage-chrome .bgai-wm .w-ai {
  color: var(--warm-bright);
  text-shadow: 0 1px 4px rgba(10, 16, 36, 0.85),
               0 0 14px rgba(10, 16, 36, 0.5);
}
body.bgai-studio .heritage-sitenav a,
body.bgai-learn  .heritage-sitenav a {
  color: var(--cream-fixed);
  opacity: 0.92;
  text-shadow: 0 1px 3px rgba(10, 16, 36, 0.85);
}
body.bgai-studio .heritage-sitenav a:hover,
body.bgai-learn  .heritage-sitenav a:hover { opacity: 1; }
body.bgai-studio .heritage-sitenav a.is-active,
body.bgai-learn  .heritage-sitenav a.is-active { color: var(--warm); }

body.bgai-studio .heritage-chrome__inner--section,
body.bgai-learn  .heritage-chrome__inner--section {
  border-top-color: rgba(244, 235, 215, 0.18);
  background: transparent;
}
body.bgai-studio .heritage-sectionnav a,
body.bgai-learn  .heritage-sectionnav a {
  color: rgba(244, 235, 215, 0.78);
  text-shadow: 0 1px 3px rgba(10, 16, 36, 0.85);
}
body.bgai-studio .heritage-sectionnav a:hover,
body.bgai-learn  .heritage-sectionnav a:hover { color: var(--cream-fixed); }
body.bgai-studio .heritage-sectionnav a.is-active,
body.bgai-learn  .heritage-sectionnav a.is-active { color: var(--warm); }

/* Horizon stripe at the top of every BeargrassAI page — banded pages
   plus the Learn library + essays so the indigo→barn→warm bar reads
   as a site-wide masthead accent. Mark 2026-05-05: Learn child
   pages were missing the stripe. */
body.page-index .heritage-chrome::before,
body.page-about .heritage-chrome::before,
body.layout-banded .heritage-chrome::before,
body.layout-learn-library .heritage-chrome::before,
body.layout-learn-essay .heritage-chrome::before,
body.bgai-learn .heritage-chrome::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg,
    var(--indigo) 0%,
    var(--barn)   50%,
    var(--warm)   100%);
  opacity: 0.85;
  z-index: 1;
}

/* Mode toggle on sunrise pages — already covered by body[data-sunrise]
   above, but body.bgai-studio is the same set in v2. */
body.bgai-studio .mode-toggle,
body.bgai-learn  .mode-toggle {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}
body.bgai-studio .mode-toggle__btn,
body.bgai-learn  .mode-toggle__btn { color: rgba(244, 235, 215, 0.85); }
body.bgai-studio .mode-toggle__btn[aria-pressed="true"],
body.bgai-learn  .mode-toggle__btn[aria-pressed="true"] {
  background: #d4a25a;
  color: var(--ink-fixed);
  font-weight: 800;
  text-shadow: none;
}

/* ============================================================
   Persistent sunrise hero (Pattern X / heritage pages)
   ============================================================ */

.sunrise-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}
.sunrise-bg object,
.sunrise-bg img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.sunrise-bg--dim::after {
  content: "";
  position: absolute; inset: 0;
  background: rgba(244, 235, 215, 0.42);
  pointer-events: none;
}
:root[data-mode="night"] .sunrise-bg--dim::after { background: rgba(10, 16, 36, 0.55); }
:root[data-mode="open"]  .sunrise-bg--dim::after { background: transparent; }

/* Banded pages don't show the persistent hero — each band carries
   its own scene. */
body.layout-banded .sunrise-bg { display: none; }

/* ============================================================
   Footer
   ============================================================ */

.site-foot {
  position: relative;
  background: var(--paper);
  color: var(--ink);
  padding: 0 0 var(--sp-2xl);
  border-top: 1px solid var(--rule);
}
.site-foot__inner {
  max-width: var(--w-content);
  margin: 0 auto;
  padding: var(--sp-3xl) var(--pad-x) 0;
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  gap: var(--sp-xl);
  text-align: center;
}
.site-foot__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-sm);
}
.site-foot__sprig {
  width: 48px; height: 48px;
  color: var(--barn);
  opacity: 0.75;
}
.site-foot__sprig svg { width: 100%; height: 100%; }
.site-foot__wm {
  text-decoration: none;
  color: var(--ink);
  font-family: var(--type-italic);
  font-size: 1.2rem;
  font-weight: 600;
}
.site-foot__wm .bgai-wm .w-beargrass { color: var(--ink); }
.site-foot__wm .bgai-wm .w-ai { color: var(--barn); font-weight: 700; }
.site-foot__nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--gap-xl);
  width: 100%;
  max-width: 720px;
  margin-top: var(--sp-md);
}
.site-foot__col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  text-align: center;
}
.site-foot__col-title {
  font-family: var(--type-ui);
  font-size: var(--fs-xs);
  letter-spacing: 0.05em;
  color: var(--ink-ter);
  margin-bottom: 0.4rem;
  font-weight: 700;
}
.site-foot__col a {
  font-family: var(--type-ui);
  font-size: var(--fs-sm);
  color: var(--ink-sec);
  text-decoration: none;
  transition: color 0.2s ease;
}
.site-foot__col a:hover { color: var(--barn); }
.site-foot__meta {
  width: 100%;
  max-width: 720px;
  margin-top: var(--sp-md);
  font-family: var(--type-ui);
  font-size: var(--fs-xs);
  color: var(--ink-ter);
  border-top: 1px solid var(--rule);
  padding-top: var(--sp-md);
  text-align: center;
}

/* ============================================================
   SSS triptych — Speedy / Safe / Simple
   ============================================================ */

.sss-triptych {
  background: var(--paper-elev);
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--sp-2xl);
}
.sss-triptych__inner {
  max-width: var(--w-content);
  margin: 0 auto;
  padding: var(--sp-2xl) var(--pad-x);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2xl);
}
@media (max-width: 720px) {
  /* Mark 2026-05-09: keep the three pillars as three columns at
     mobile. The triptych is symbolic: the whole site stands on
     Speedy / Safe / Simple. Collapsing them to a single column
     loses that read. Tighten gap, padding, and type so the three
     columns fit at 320 without wrapping the pillar word. */
  .sss-triptych__inner {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-sm);
    padding-block: var(--sp-xl);
    padding-inline: var(--pad-x);
  }
  .sss-triptych__col {
    padding-block: var(--sp-sm);
    padding-left: var(--sp-sm);
  }
  .sss-triptych__word {
    font-size: var(--fs-md);
    margin-bottom: 0.2rem;
  }
  .sss-triptych__sentence {
    font-size: var(--fs-xs);
    line-height: 1.4;
  }
}
.sss-triptych__col {
  text-decoration: none;
  color: var(--ink);
  display: block;
  border-left: 2px solid var(--barn);
  padding-left: var(--sp-md);
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.sss-triptych__col--safe   { border-left-color: var(--indigo); }
.sss-triptych__col--simple { border-left-color: var(--olive); }
.sss-triptych__col:hover   { transform: translateX(2px); }
.sss-triptych__word {
  display: block;
  font-family: var(--type-italic);
  font-variation-settings: "opsz" 80, "wght" 600, "SOFT" 30, "WONK" 1;
  font-size: var(--fs-2xl);
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 0.3rem;
}
.sss-triptych__col--speedy .sss-triptych__word { color: var(--barn); }
.sss-triptych__col--safe   .sss-triptych__word { color: var(--indigo); }
.sss-triptych__col--simple .sss-triptych__word { color: var(--olive); }
.sss-triptych__sentence {
  font-family: var(--type-italic);
  font-style: italic;
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
  color: var(--ink-sec);
  margin: 0;
  max-width: 32ch;
}

/* Open mode footer — adopts Night palette so the cinematic register
   carries through to bottom of the page. */
:root[data-mode="open"] .site-foot {
  background: var(--surface-night);
  color: var(--cream-fixed);
  border-top-color: rgba(240, 230, 207, 0.18);
}
:root[data-mode="open"] .site-foot__wm,
:root[data-mode="open"] .site-foot__col a { color: rgba(240, 230, 207, 0.85); }
:root[data-mode="open"] .site-foot__col a:hover { color: var(--warm); }
:root[data-mode="open"] .site-foot__col-title { color: rgba(240, 230, 207, 0.7); }
:root[data-mode="open"] .site-foot__meta {
  color: rgba(240, 230, 207, 0.7);
  border-top-color: rgba(240, 230, 207, 0.18);
}
:root[data-mode="open"] .site-foot__sprig { color: var(--warm); }
:root[data-mode="open"] .site-foot__wm .bgai-wm .w-beargrass { color: var(--cream-fixed); }
:root[data-mode="open"] .site-foot__wm .bgai-wm .w-ai { color: var(--warm); }
:root[data-mode="open"] .sss-triptych {
  background: rgba(22, 33, 46, 0.7);
  border-top-color: rgba(240, 230, 207, 0.18);
  border-bottom-color: rgba(240, 230, 207, 0.18);
}
:root[data-mode="open"] .sss-triptych__sentence { color: rgba(240, 230, 207, 0.85); }

/* Night — explicit footer override so the cream wordmark, cream column
   labels, cream column links all render correctly on the dark token-swapped
   --paper surface. Without this, the footer inherits Night cream type
   on Night dark surface but the per-element overrides we already shipped
   for Open are missing for Night. */
:root[data-mode="night"] .site-foot {
  background: var(--paper);
  color: var(--ink);
  border-top-color: var(--rule);
}
:root[data-mode="night"] .site-foot__sprig { color: var(--warm); }
:root[data-mode="night"] .site-foot__wm { color: var(--ink); }
:root[data-mode="night"] .site-foot__wm .bgai-wm .w-beargrass { color: var(--ink); }
:root[data-mode="night"] .site-foot__wm .bgai-wm .w-ai { color: var(--warm); }
:root[data-mode="night"] .site-foot__col a { color: var(--ink-sec); }
:root[data-mode="night"] .site-foot__col a:hover { color: var(--warm); }
:root[data-mode="night"] .site-foot__col-title { color: var(--ink-ter); }
:root[data-mode="night"] .site-foot__meta {
  color: var(--ink-ter);
  border-top-color: var(--rule);
}
:root[data-mode="night"] .sss-triptych {
  background: var(--paper-elev);
  border-top-color: var(--rule);
  border-bottom-color: var(--rule);
}
:root[data-mode="night"] .sss-triptych__sentence { color: var(--ink-sec); opacity: 0.92; }

/* SSS triptych on dark footer (Night and Open) — the canonical
   --barn / --indigo / --olive tokens render with uneven luminance on
   the dark paper-elev plate; --indigo and --barn fail or barely pass
   AA. Lift all three to cream-shifted bright variants tuned to the
   same luminance band (L≈0.64-0.67) so the red/blue/green chord
   reads as one row of consistent brightness, different hue. All three
   pass AAA contrast against the dark footer plate. */
:root[data-mode="night"] .sss-triptych__col--speedy,
:root[data-mode="open"]  .sss-triptych__col--speedy {
  border-left-color: #f5c8b0;
}
:root[data-mode="night"] .sss-triptych__col--speedy .sss-triptych__word,
:root[data-mode="open"]  .sss-triptych__col--speedy .sss-triptych__word {
  color: #f5c8b0;
}
:root[data-mode="night"] .sss-triptych__col--safe,
:root[data-mode="open"]  .sss-triptych__col--safe {
  border-left-color: #c0d8f0;
}
:root[data-mode="night"] .sss-triptych__col--safe .sss-triptych__word,
:root[data-mode="open"]  .sss-triptych__col--safe .sss-triptych__word {
  color: #c0d8f0;
}
:root[data-mode="night"] .sss-triptych__col--simple,
:root[data-mode="open"]  .sss-triptych__col--simple {
  border-left-color: #c8e0a8;
}
:root[data-mode="night"] .sss-triptych__col--simple .sss-triptych__word,
:root[data-mode="open"]  .sss-triptych__col--simple .sss-triptych__word {
  color: #c8e0a8;
}

/* ============================================================
   Agent chat widget. Corner-bubble toggle + slide-up panel.
   Ported from beargrassai.com 2026-05-06 with v2 brand tokens.
   The toggle is locked barn-red across all modes (matches .btn-cta).
   The panel is mode-aware (Paper, Night, Open) using the canonical
   plates from brand 4.4.
   ============================================================ */

#ba-chat-widget {
  position: fixed;
  bottom: var(--sp-md);
  right: var(--sp-md);
  z-index: 200;
  font-family: var(--type-ui);
}

#ba-chat-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.95rem;
  background: #a64b3b;
  color: #f0e6cf;
  border: 1px solid #a64b3b;
  border-radius: var(--r-pill);
  cursor: pointer;
  font-family: var(--type-ui);
  font-weight: 600;
  font-size: var(--fs-sm);
  letter-spacing: 0.02em;
  box-shadow: 0 6px 18px rgba(35, 31, 26, 0.22);
  transition: filter 0.2s ease, transform 0.18s ease;
}
#ba-chat-toggle:hover,
#ba-chat-toggle:focus-visible {
  filter: brightness(1.08);
  transform: translateY(-1px);
  outline: none;
}
#ba-chat-toggle svg { color: #f0e6cf; }
.ba-chat-toggle-label { white-space: nowrap; }

@media (max-width: 480px) {
  .ba-chat-toggle-label { display: none; }
  #ba-chat-toggle { padding: 0.6rem; }
}

.ba-chat-panel {
  position: fixed;
  right: var(--sp-md);
  bottom: calc(var(--sp-md) + 3.2rem);
  width: min(360px, calc(100vw - 2 * var(--sp-md)));
  max-height: min(560px, calc(100vh - 6rem));
  display: flex;
  flex-direction: column;
  background: var(--paper-elev);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(35, 31, 26, 0.06);
  overflow: hidden;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.ba-chat-panel--hidden {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

@media (max-width: 480px) {
  .ba-chat-panel {
    right: 0;
    bottom: 0;
    width: 100vw;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }
}

:root[data-mode="night"] .ba-chat-panel,
:root[data-mode="open"]  .ba-chat-panel {
  background: rgba(22, 33, 46, 0.96);
  border-color: rgba(240, 230, 207, 0.18);
  color: var(--cream-fixed);
}

.ba-chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--rule);
}
.ba-chat-header-info { display: flex; flex-direction: column; gap: 0.1rem; }
.ba-chat-header-title {
  font-family: var(--type-italic);
  font-style: italic;
  font-weight: 600;
  font-size: var(--fs-md);
  color: var(--ink);
}
:root[data-mode="night"] .ba-chat-header-title,
:root[data-mode="open"]  .ba-chat-header-title { color: var(--cream-fixed); }
.ba-chat-header-subtitle {
  font-size: var(--fs-xs);
  color: var(--ink-sec);
  letter-spacing: 0.02em;
}
:root[data-mode="night"] .ba-chat-header-subtitle,
:root[data-mode="open"]  .ba-chat-header-subtitle { color: var(--ink-sec); opacity: 0.85; }

#ba-chat-close {
  background: transparent;
  border: 0;
  color: inherit;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.4rem;
  border-radius: var(--r-sm);
  opacity: 0.7;
}
#ba-chat-close:hover,
#ba-chat-close:focus-visible { opacity: 1; outline: none; }

.ba-chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.85rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.ba-chat-message p {
  margin: 0;
  padding: 0.55rem 0.75rem;
  border-radius: var(--r-md);
  font-family: var(--type-body);
  font-size: var(--fs-sm);
  line-height: 1.45;
  max-width: 86%;
  word-wrap: break-word;
}
.ba-chat-message--assistant p {
  align-self: flex-start;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
}
.ba-chat-message--user {
  display: flex;
  justify-content: flex-end;
}
.ba-chat-message--user p {
  background: #a64b3b;
  color: #f0e6cf;
}
:root[data-mode="night"] .ba-chat-message--assistant p,
:root[data-mode="open"]  .ba-chat-message--assistant p {
  background: rgba(240, 230, 207, 0.10);
  color: var(--cream-fixed);
  border-color: rgba(240, 230, 207, 0.18);
}

.ba-chat-typing .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 1px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
  animation: baChatDot 1.2s ease-in-out infinite;
}
.ba-chat-typing .dot:nth-child(2) { animation-delay: 0.15s; }
.ba-chat-typing .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes baChatDot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40%           { opacity: 1;   transform: scale(1); }
}

.ba-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0 0.9rem 0.6rem;
}
.ba-chat-chip {
  background: var(--paper-tint);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--r-pill);
  padding: 0.28rem 0.7rem;
  font-family: var(--type-ui);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.ba-chat-chip:hover,
.ba-chat-chip:focus-visible { background: var(--paper-elev); outline: none; }
:root[data-mode="night"] .ba-chat-chip,
:root[data-mode="open"]  .ba-chat-chip {
  background: rgba(240, 230, 207, 0.08);
  color: var(--cream-fixed);
  border-color: rgba(240, 230, 207, 0.18);
}

.ba-chat-input-row {
  display: flex;
  gap: 0.4rem;
  padding: 0.55rem 0.7rem 0.7rem;
  border-top: 1px solid var(--rule);
  background: var(--paper-elev);
}
:root[data-mode="night"] .ba-chat-input-row,
:root[data-mode="open"]  .ba-chat-input-row {
  background: transparent;
  border-top-color: rgba(240, 230, 207, 0.18);
}
#ba-chat-input {
  flex: 1 1 auto;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--r-pill);
  padding: 0.4rem 0.85rem;
  font-family: var(--type-body);
  font-size: var(--fs-sm);
  line-height: 1.4;
}
#ba-chat-input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
:root[data-mode="night"] #ba-chat-input,
:root[data-mode="open"]  #ba-chat-input {
  background: rgba(10, 16, 36, 0.55);
  color: var(--cream-fixed);
  border-color: rgba(240, 230, 207, 0.22);
}
#ba-chat-send {
  flex: 0 0 auto;
  height: 2rem;
  width: 2rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#ba-chat-send svg { color: #f0e6cf; }
