/*
 * RBTHelper shared component header — Wave 6 visual alignment
 *
 * Scope is still limited to elements carrying the rbth-component-header class
 * family; component bodies keep their own CSS, content, and behavior. Wave 6
 * restyles this chrome to match the v2 site shell: self-hosted brand
 * typography, the v2 accent bar and tint wash, softer radii, and the v2
 * control language. Per-component accent tokens are unchanged, and every
 * accessibility guarantee from the Wave 4B.1 pilot is preserved: 44 CSS-pixel
 * minimum control targets, visible focus, static positioning, wrapping
 * actions, both responsive breakpoints, and reduced-motion support.
 */

.rbth-component-header {
  --rbth-header-surface: #ffffff;
  --rbth-header-text: #203040;
  --rbth-header-muted: #5e6e7e;
  --rbth-header-soft-teal: #66b2a6;
  --rbth-header-ocean-ink: #203040;
  --rbth-header-boundary: #2f7d70;
  --rbth-header-light-blue: #ddf1f7;
  --rbth-header-sunlight: #f4c95d;
  --rbth-header-hairline: rgba(32, 48, 64, 0.07);
  --rbth-header-control-edge: rgba(32, 48, 64, 0.16);
  --rbth-header-display: Sora, "Segoe UI", system-ui, -apple-system, sans-serif;
  --rbth-header-body: "Nunito Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --rbth-component-accent: var(--rbth-header-soft-teal);
  --rbth-component-tint: var(--rbth-header-light-blue);
  --rbth-component-accent-dark: var(--rbth-header-boundary);
  box-sizing: border-box;
  color: var(--rbth-header-text);
  font-family: var(--rbth-header-body);
  background-color: var(--rbth-header-surface);
  background-image: linear-gradient(
    180deg,
    var(--rbth-component-tint) 0%,
    var(--rbth-header-surface) 5.5rem
  );
  border-block-start: 0.375rem solid var(--rbth-component-accent);
  border-block-end: 1px solid var(--rbth-header-hairline);
}

.rbth-component-header--choice {
  --rbth-component-accent: #ee8b6b;
  --rbth-component-tint: #fff0ea;
  --rbth-component-accent-dark: #934a33;
}

.rbth-component-header--timer {
  --rbth-component-accent: #7f94de;
  --rbth-component-tint: #eef1ff;
  --rbth-component-accent-dark: #465a9e;
}

.rbth-component-header--reference {
  --rbth-component-accent: #a482b8;
  --rbth-component-tint: #f4edf8;
  --rbth-component-accent-dark: #624874;
}

.rbth-component-header.rbth-component-header__layout,
.rbth-component-header .rbth-component-header__layout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "home identity"
    "actions actions";
  align-items: center;
  gap: 0.85rem;
}

.rbth-component-header--reference .rbth-component-header__layout {
  grid-template-areas:
    "home identity"
    "support support";
}

.rbth-component-header .rbth-component-home {
  grid-area: home;
  position: static;
  align-self: center;
  display: inline-flex;
  min-block-size: 2.75rem;
  min-inline-size: 2.75rem;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.55rem 1.05rem;
  color: var(--rbth-header-ocean-ink);
  background: var(--rbth-header-surface);
  border: 1.5px solid var(--rbth-header-control-edge);
  border-radius: 0.75rem;
  box-shadow: 0 1px 2px rgba(32, 48, 64, 0.05);
  font-family: var(--rbth-header-body);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transform: none;
  transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.rbth-component-header .rbth-component-home:hover {
  color: var(--rbth-header-ocean-ink);
  background: var(--rbth-component-tint);
  border-color: var(--rbth-component-accent);
  box-shadow: 0 4px 12px rgba(32, 48, 64, 0.08);
  transform: none;
}

.rbth-component-header .rbth-component-home:active {
  background: var(--rbth-component-tint);
  box-shadow: none;
  transform: none;
}

.rbth-component-header .rbth-component-home:focus-visible,
.rbth-component-header .rbth-component-actions :is(a, button, input, select):focus-visible {
  outline: 3px solid var(--rbth-header-soft-teal);
  outline-offset: 2px;
  box-shadow: none;
}

.rbth-component-home__arrow {
  flex: 0 0 auto;
  font-size: 1.15em;
  line-height: 1;
  color: var(--rbth-component-accent-dark);
}

.rbth-component-home__label--compact {
  display: none;
}

.rbth-component-header .rbth-component-identity {
  grid-area: identity;
  display: flex;
  min-inline-size: 0;
  align-items: center;
  justify-content: flex-start;
  gap: 0.85rem;
  margin: 0;
  padding: 0.35rem 0.15rem;
  color: var(--rbth-header-text);
  background: transparent;
  border-inline-start: 0;
  border-radius: 0;
  text-align: start;
}

.rbth-component-header .rbth-component-identity > :not(.rbth-component-brand) {
  min-inline-size: 0;
}

.rbth-component-brand {
  display: block;
  flex: 0 0 2.75rem;
  inline-size: 2.75rem;
  block-size: 2.75rem;
}

.rbth-component-brand img {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: contain;
}

.rbth-component-header .rbth-component-actions {
  grid-area: actions;
  display: flex;
  min-inline-size: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin: 0;
  font-family: var(--rbth-header-body);
}

.rbth-component-header .rbth-component-header__support {
  grid-area: support;
  min-inline-size: 0;
}

/* Component title treatments: v2 display face, ocean-ink weight, accent eyebrow. */
.rbth-component-header--choice .cb-brand-name,
.rbth-component-header--timer .vt-heading-group h1,
.rbth-component-header--reference .rbt-ref__title-row h1 {
  color: var(--rbth-header-text);
  font-family: var(--rbth-header-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.rbth-component-header--choice .cb-eyebrow,
.rbth-component-header--timer .vt-kicker,
.rbth-component-header--reference .rbt-ref__eyebrow {
  color: var(--rbth-component-accent-dark);
  font-family: var(--rbth-header-body);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.rbth-component-header--reference .rbt-ref__subtitle,
.rbth-component-header--timer .vt-heading-group > div > p:last-child {
  color: var(--rbth-header-muted);
  font-family: var(--rbth-header-body);
}

.rbth-component-header--timer .vt-heading-group {
  text-align: start;
}

.rbth-component-header--timer .vt-heading-group > div > :where(h1, p) {
  margin-inline: 0;
}

.rbth-component-header--timer .vt-heading-group h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  line-height: 1.1;
}

.rbth-component-header--timer .vt-heading-group > div > p:last-child {
  margin-block: 0.25rem 0;
}

.rbth-component-header--reference .rbt-ref__title-row h1 {
  font-size: clamp(1.65rem, 4vw, 2.5rem);
  line-height: 1.1;
}

@media (min-width: 48rem) {
  .rbth-component-header.rbth-component-header__layout,
  .rbth-component-header .rbth-component-header__layout {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "home identity actions";
  }

  .rbth-component-header--reference .rbth-component-header__layout {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "home identity"
      "support support";
  }
}

@media (max-width: 29.999rem) {
  .rbth-component-header .rbth-component-home {
    padding-inline: 0.65rem;
  }

  .rbth-component-home__label--desktop {
    display: none;
  }

  .rbth-component-home__label--compact {
    display: inline;
  }

  .rbth-component-brand {
    flex-basis: 2.25rem;
    inline-size: 2.25rem;
    block-size: 2.25rem;
  }

  .rbth-component-header .rbth-component-identity {
    gap: 0.55rem;
  }

  .rbth-component-header--choice .cb-eyebrow,
  .rbth-component-header--timer .vt-kicker,
  .rbth-component-header--timer .vt-heading-group > div > p:last-child,
  .rbth-component-header--reference .rbt-ref__eyebrow,
  .rbth-component-header--reference .rbt-ref__subtitle {
    display: none;
  }

  .rbth-component-header--reference .rbt-ref__title-row h1 {
    font-size: clamp(1.35rem, 7vw, 1.7rem);
    overflow-wrap: normal;
    word-break: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rbth-component-header .rbth-component-home,
  .rbth-component-header .rbth-component-actions :is(a, button, input, select) {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .rbth-component-header .rbth-component-home,
  .rbth-component-header .rbth-component-actions {
    display: none !important;
  }

  .rbth-component-header,
  .rbth-component-header .rbth-component-identity {
    color: #000000;
    background: #ffffff;
    background-image: none;
    border-color: #000000;
    box-shadow: none;
  }
}

/*
 * Wave 8 — every tool on the shared chrome.
 *
 * Components 01, 02, 03, 05, 08, and 09 adopt the governed header in Wave 8.
 * They bring needs the pilots did not: a Home control that is a <button>
 * (Token Board's own script owns the click), controls that start hidden until
 * the component's script reveals them (Tact), a tool-owned label element the
 * component's script still writes into (Calendar, Schedule, Matching), and
 * tool-owned actions -- a mode switch, a help toggle, restart buttons, a save
 * indicator -- that must keep working while wearing the v2 control language.
 * Everything here stays scoped to the rbth-component-header family.
 */

.rbth-component-header--tact {
  --rbth-component-accent: #4bb8b2;
  --rbth-component-tint: #e6f8f6;
  --rbth-component-accent-dark: #286a68;
}

.rbth-component-header--token {
  --rbth-component-accent: #f4c95d;
  --rbth-component-tint: #fff5cd;
  --rbth-component-accent-dark: #765a00;
}

.rbth-component-header--calendar {
  --rbth-component-accent: #72b6e8;
  --rbth-component-tint: #eaf5ff;
  --rbth-component-accent-dark: #285f87;
}

.rbth-component-header--schedule {
  --rbth-component-accent: #7fbe91;
  --rbth-component-tint: #ecf8ef;
  --rbth-component-accent-dark: #356b43;
}

.rbth-component-header--matching {
  --rbth-component-accent: #6dbe70;
  --rbth-component-tint: #edf8ee;
  --rbth-component-accent-dark: #2f6c32;
}

.rbth-component-header--emotion {
  --rbth-component-accent: #d982a2;
  --rbth-component-tint: #fceef4;
  --rbth-component-accent-dark: #8a3d5a;
}

.rbth-component-header--soap {
  --rbth-component-accent: #7f9bb8;
  --rbth-component-tint: #eef3f9;
  --rbth-component-accent-dark: #3e5670;
}

.rbth-component-header--sketch {
  --rbth-component-accent: #f2a35f;
  --rbth-component-tint: #fff2e6;
  --rbth-component-accent-dark: #8b4a12;
}

/* The pilots keep their page gutter in their own stylesheets; the Wave 8
   pages dropped their former header classes, so the gutter lives here. */
.rbth-component-header.rbth-component-header--tact,
.rbth-component-header.rbth-component-header--token,
.rbth-component-header.rbth-component-header--calendar,
.rbth-component-header.rbth-component-header--schedule,
.rbth-component-header.rbth-component-header--matching,
.rbth-component-header.rbth-component-header--emotion,
.rbth-component-header.rbth-component-header--soap,
.rbth-component-header.rbth-component-header--sketch {
  inline-size: auto;
  max-inline-size: none;
  min-block-size: 0;
  margin: 0;
  padding: 0.75rem clamp(0.75rem, 2.5vw, 1.5rem) 0.875rem;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}

/* Identity text for pages that use the shared title classes. */
.rbth-component-header .rbth-component-eyebrow {
  margin: 0 0 0.125rem;
  color: var(--rbth-component-accent-dark);
  font-family: var(--rbth-header-body);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1.3;
  text-transform: uppercase;
}

.rbth-component-header .rbth-component-title {
  margin: 0;
  color: var(--rbth-header-text);
  font-family: var(--rbth-header-display);
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.rbth-component-header .rbth-component-subtitle {
  margin: 0.25rem 0 0;
  color: var(--rbth-header-muted);
  font-family: var(--rbth-header-body);
  font-size: 0.9rem;
  line-height: 1.35;
}

/* A Home control rendered as a button (component 02) shares the anchor look. */
.rbth-component-header button.rbth-component-home {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

/* Controls a component's own script keeps hidden must stay hidden, and the
   tool-owned label element exists only for that script to write into. */
.rbth-component-header .rbth-component-home[hidden],
.rbth-component-header .rbth-component-action[hidden],
.rbth-component-header .rbth-component-home__label--tool {
  display: none;
}

/* Tool-owned actions in the v2 control language. */
.rbth-component-header .rbth-component-action {
  display: inline-flex;
  min-block-size: 2.75rem;
  min-inline-size: 2.75rem;
  inline-size: auto;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.55rem 1rem;
  color: var(--rbth-header-ocean-ink);
  background: var(--rbth-header-surface);
  border: 1.5px solid var(--rbth-header-control-edge);
  border-radius: 0.75rem;
  box-shadow: 0 1px 2px rgba(32, 48, 64, 0.05);
  font-family: var(--rbth-header-body);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transform: none;
  filter: none;
  transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.rbth-component-header .rbth-component-action:hover {
  color: var(--rbth-header-ocean-ink);
  background: var(--rbth-component-tint);
  border-color: var(--rbth-component-accent);
  box-shadow: 0 4px 12px rgba(32, 48, 64, 0.08);
  transform: none;
  filter: none;
}

.rbth-component-header .rbth-component-action:active {
  background: var(--rbth-component-tint);
  box-shadow: none;
  transform: none;
}

.rbth-component-header .rbth-component-action > span {
  font-size: 1em;
  line-height: 1;
}

.rbth-component-header .rbth-component-action > svg {
  inline-size: 1.05em;
  block-size: 1.05em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Segmented mode switch (component 05). */
.rbth-component-header .rbth-component-segment {
  position: static;
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 0.25rem;
  margin: 0;
  padding: 0.25rem;
  background: var(--rbth-component-tint);
  border: 1px solid var(--rbth-header-hairline);
  border-radius: 0.9rem;
}

.rbth-component-header .rbth-component-action--segment {
  padding: 0.5rem 0.9rem;
  color: var(--rbth-header-muted);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  font-weight: 700;
}

.rbth-component-header .rbth-component-action--segment[aria-pressed="true"] {
  color: var(--rbth-header-ocean-ink);
  background: var(--rbth-header-surface);
  border-color: var(--rbth-component-accent);
  box-shadow: 0 1px 2px rgba(32, 48, 64, 0.08);
}

/* Read-only status chip (component 05 save indicator). */
.rbth-component-header .rbth-component-status {
  display: inline-flex;
  min-block-size: 2rem;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.3rem 0.7rem;
  color: var(--rbth-header-muted);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--rbth-header-hairline);
  border-radius: 999px;
  font-family: var(--rbth-header-body);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
}

/* Component 08's help toggle keeps its "?" badge, recolored to the accent. */
.rbth-component-header--matching .rbth-component-action > span:first-child {
  display: grid;
  inline-size: 1.4rem;
  block-size: 1.4rem;
  place-items: center;
  color: #ffffff;
  background: var(--rbth-component-accent-dark);
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 700;
}

.rbth-component-header--matching .rbth-component-action > span:last-child {
  position: static;
  inline-size: auto;
  block-size: auto;
  overflow: visible;
}

@media (max-width: 29.999rem) {
  .rbth-component-header .rbth-component-eyebrow,
  .rbth-component-header .rbth-component-subtitle {
    display: none;
  }

  .rbth-component-header .rbth-component-title {
    font-size: clamp(1.25rem, 6.5vw, 1.55rem);
  }

  .rbth-component-header .rbth-component-action {
    padding-inline: 0.75rem;
  }
}

/* Component 05's save indicator lives in the header now, outside the app
   wrapper that defines that page's own color tokens, so its dot takes the
   header accent instead. */
.rbth-component-header .vs-save-state__dot {
  inline-size: 10px;
  block-size: 10px;
  border-radius: 50%;
  background: var(--rbth-component-accent-dark);
  box-shadow: 0 0 0 4px var(--rbth-component-tint);
}

.rbth-component-header .vs-save-state[data-storage="unavailable"] .vs-save-state__dot {
  background: #c0533a;
  box-shadow: 0 0 0 4px rgba(238, 139, 107, 0.3);
}

/* ------------------------------------------------------------------
 * Wave 11 — the brand is the Home control.
 *
 * The Home control carries the RBTHelper wordmark (the micro icon under
 * 30rem) exactly as the site header does, in place of a bordered pill that
 * repeated the brand name beside a separate brand mark.  The accessible name
 * and the tool-owned label sinks are unchanged.
 * ------------------------------------------------------------------ */
.rbth-component-header .rbth-component-home--brand {
  padding: 0.3rem 1rem 0.3rem 0;
  background: transparent;
  border: 0;
  border-inline-end: 1px solid var(--rbth-header-hairline);
  border-radius: 0.25rem;
  box-shadow: none;
  transition: opacity 140ms ease;
}

.rbth-component-header .rbth-component-home--brand:hover {
  background: transparent;
  border-color: var(--rbth-header-hairline);
  box-shadow: none;
  opacity: 0.82;
}

.rbth-component-header .rbth-component-home--brand:active {
  background: transparent;
  opacity: 0.7;
}

.rbth-component-header .rbth-component-home__brand {
  display: block;
  flex: 0 0 auto;
  line-height: 0;
}

.rbth-component-header .rbth-component-home--brand img {
  display: block;
  inline-size: auto;
  block-size: 2.25rem;
  max-inline-size: none;
}

.rbth-component-header .rbth-component-home--brand + .rbth-component-identity {
  padding-inline-start: 0.35rem;
}

@media (max-width: 29.999rem) {
  .rbth-component-header .rbth-component-home--brand {
    padding-inline: 0 0.65rem;
  }

  .rbth-component-header .rbth-component-home--brand img {
    inline-size: 2.25rem;
    block-size: 2.25rem;
  }
}
