/* Shared components: header, nav, buttons, footer, title block, flash, info. */

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .05s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-600); }
.btn--ghost { background: transparent; color: var(--ink-strong); border-color: var(--border-public); }
.btn--ghost:hover { border-color: var(--color-primary); color: var(--color-primary-600); }
.btn.is-disabled { opacity: .5; cursor: default; pointer-events: none; }

/* ---- Semi-transparent + exterior-highlight treatment (third review) ----
   Division of weight (Bud, 2026-07-31): SERIOUS actions and states keep a
   SOLID fill — saves/confirms (.btn--primary), permanent delete
   (.btn--danger), failure/state pills — while lighter-weight actions use
   this translucent fill + outer highlight ring. Severity is carried by the
   refined hues (pine teal / garnet in tokens.css), not traffic-light
   green/red. Variants only set --btn-accent/--btn-ink; treatment is shared. */
.btn { --btn-accent: var(--color-primary); }
.btn--soft,
.btn--upgrade,
.btn--downgrade,
.btn--pause,
.btn--revoke {
  background: color-mix(in srgb, var(--btn-accent) 15%, transparent);
  color: var(--btn-ink, var(--btn-accent));
  border-color: color-mix(in srgb, var(--btn-accent) 50%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--btn-accent) 13%, transparent);
}
.btn--soft:hover,
.btn--upgrade:hover,
.btn--downgrade:hover,
.btn--pause:hover,
.btn--revoke:hover {
  background: color-mix(in srgb, var(--btn-accent) 27%, transparent);
  border-color: color-mix(in srgb, var(--btn-accent) 80%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--btn-accent) 20%, transparent);
}
.btn--soft:focus-visible,
.btn--upgrade:focus-visible,
.btn--downgrade:focus-visible,
.btn--pause:focus-visible,
.btn--revoke:focus-visible {
  outline: 2px solid var(--btn-accent);
  outline-offset: 2px;
}
/* Upgrade vs Downgrade must be visually distinct (third review): the member
   should not have to read the label to know which direction they are moving. */
.btn--upgrade   { --btn-accent: var(--action-upgrade);   --btn-ink: var(--color-success-300); }
.btn--downgrade { --btn-accent: var(--action-downgrade); --btn-ink: var(--color-orange-300); }
/* Reversible destructive (revoke, pause, disconnect) — orange, never red. */
.btn--revoke    { --btn-accent: var(--action-reversible); --btn-ink: var(--color-orange-300); }
/* Pause is recoverable-and-attention-worthy — gold, matching the paused pill. */
.btn--pause     { --btn-accent: var(--color-warning);     --btn-ink: var(--color-warning-300); }

/* .btn--ghost carries light-theme tokens (--ink-strong on --border-public).
   On the navy dashboard that rendered dark ink on a dark surface, which is
   why "Current" and "Cancel" were unreadable in the third review. Re-point
   the whole variant on the auth theme rather than patching each call site. */
body.theme-auth .btn--ghost {
  background: color-mix(in srgb, var(--on-dark) 7%, transparent);
  color: var(--on-dark);
  border-color: var(--border-dark);
}
body.theme-auth .btn--ghost:hover {
  border-color: var(--color-primary-300);
  color: #fff;
}
/* Non-interactive state chip rendered as a button (e.g. the "Current" tile
   marker): must read as a settled state, not a dimmed-out action. */
body.theme-auth .btn--ghost[aria-disabled="true"] {
  background: color-mix(in srgb, var(--on-dark) 12%, transparent);
  color: var(--on-dark);
  border-color: color-mix(in srgb, var(--on-dark) 28%, transparent);
  font-weight: 700;
}

/* ---- Header (shared) ---- */
.site-header { position: sticky; top: 0; z-index: 20; }
.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  min-height: var(--header-h);
}
.brand { display: inline-flex; align-items: center; gap: var(--space-3); font-weight: 700; }
.brand__mark { border-radius: 9px; }
.brand__name { font-size: var(--fs-lg); letter-spacing: -0.02em; }

.nav { display: flex; align-items: center; gap: var(--space-2); }
.nav--public { margin-inline-end: auto; margin-inline-start: var(--space-4); }
.nav__link {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--ink-muted);
  transition: color .15s ease, background-color .15s ease;
}
.nav__link:hover { color: var(--ink-strong); }
.nav__link--pending { color: var(--ink-muted); opacity: .5; cursor: default; }
.nav__link--active { color: var(--ink-strong); font-weight: 600; }
.nav__actions { display: flex; align-items: center; gap: var(--space-3); }

/* Public header chrome */
.site-header--public {
  background: color-mix(in srgb, var(--bg-public) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-public);
}

/* Auth header chrome (dark) */
.site-header--auth {
  background: var(--color-navy-800);
  border-bottom: 1px solid var(--border-dark);
}
.site-header--auth .brand__name { color: var(--on-dark); }
.site-header--auth .nav__link { color: var(--on-dark-muted); }
.site-header--auth .nav__link:hover { color: var(--on-dark); background: rgba(255,255,255,.06); }
.site-header--auth .nav__link--active {
  color: var(--color-primary-300);
  background: rgba(30, 144, 255, 0.12);
}
.site-header--auth .nav__link--active:hover { color: var(--color-primary-300); background: rgba(30, 144, 255, 0.16); }
.site-header--auth .nav--auth { margin-inline: var(--space-4) auto; }
.site-header--auth .nav--auth-right { gap: var(--space-1); }

/* ---- Footer ---- */
.site-footer {
  flex-shrink: 0;
  margin-top: var(--space-9);
  padding-block: var(--space-6) var(--space-5);
  background: var(--color-navy-900);
  color: var(--on-dark-muted);
}
.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-6);
  justify-content: space-between;
}
.site-footer__col--right { text-align: right; }
.site-footer__tagline, .site-footer__secure { color: var(--on-dark); font-weight: 600; }
.site-footer__desc, .site-footer__version { font-size: var(--fs-sm); margin-top: 2px; }
.site-footer__link,
.site-footer__legal a { color: var(--color-primary-300); font-size: var(--fs-sm); }
.site-footer__link { display: inline-block; margin-top: var(--space-2); }
.site-footer__legal { margin-top: var(--space-2); display: flex; gap: var(--space-2); justify-content: flex-end; flex-wrap: wrap; }
.site-footer__legal a:hover { color: #fff; text-decoration: underline; }
.site-footer__sep { color: var(--border-dark); }
.site-footer__copy {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-dark);
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--on-dark-muted);
}

/* ---- Flash ---- */
.flash-region { display: grid; gap: var(--space-2); max-width: var(--container-max); margin: var(--space-4) auto 0; padding-inline: var(--space-5); }
.flash { padding: 6px 12px; border-radius: var(--radius-md); border: 1px solid; font-size: var(--fs-sm); }
/* Inside the title block the row grid already spaces the flash — strip the
   standalone region's outer margin/padding (first review: flash oversized). */
.title-block__row--flash .flash-region { margin: 0; padding-inline: 0; width: 100%; }
.flash--error { background: var(--flash-error-bg); border-color: var(--flash-error-border); color: var(--flash-error-ink); }
.flash--warning { background: var(--flash-warning-bg); border-color: var(--flash-warning-border); color: var(--flash-warning-ink); }
.flash--success { background: var(--flash-success-bg); border-color: var(--flash-success-border); color: var(--flash-success-ink); }
.flash--info { background: var(--flash-info-bg); border-color: var(--flash-info-border); color: var(--flash-info-ink); }

/* ---- Title block (§0.1.8) ---- */
.title-block { display: grid; gap: var(--space-2); padding-block: var(--space-5) var(--space-4); }
.title-block__row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.breadcrumbs { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-base); }
.breadcrumbs__item { color: var(--on-dark-muted); }
/* Current crumb doubles as the page title: larger + gold, mirroring the
   panel/table heading accent (first-review directive: contrast, not monotone). */
.breadcrumbs__item--current { color: var(--color-warning-300); font-weight: 600; font-size: var(--fs-lg); }
.breadcrumbs__sep { color: var(--color-accent-300); opacity: 1; } /* first review: '/' was near-invisible */
.title-block__indicators { display: flex; align-items: center; gap: var(--space-2); }
/* Breadcrumb-row actions (third review): page entries that belong beside the
   indicators — e.g. Profile's Change Level button. */
.title-block__actions { display: inline-flex; align-items: center; gap: var(--space-2); margin-right: var(--space-2); }
.indicator { position: relative; display: inline-flex; padding: 8px; border-radius: var(--radius-sm); color: var(--on-dark-muted); }
.indicator:hover { color: var(--on-dark); background: rgba(255,255,255,.06); }
.indicator__badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 16px; height: 16px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--color-primary); color: #fff;
  font-size: 10px; font-weight: 700; border-radius: var(--radius-pill);
}
.indicator__badge--system-alert {
  background: var(--color-warning);
  color: var(--color-navy-900);
}
.title-block__subtitle { margin: 0; color: var(--on-dark-muted); font-size: var(--fs-md); }
.title-block__controls { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }
.title-block__docs-btn { display: inline-flex; align-items: center; gap: 6px; }
.title-block__row--flash:empty { display: none; }
.info-box {
  width: 100%;
  padding: 12px 16px;
  background: var(--info-box-bg);
  border-left: 3px solid var(--info-box-border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  color: var(--on-dark-muted);
}
/* Callout inside a panel body (second review): same note convention as the
   title-block info box, with panel-rhythm margins. */
.panel .info-box { margin: 0 0 var(--space-4); }
.panel .info-box:last-child { margin-bottom: 0; }

/* ---- Info tooltip (second review: replaces native title= hints) ----
   Styled, readable hover/focus bubble; markup via info_tip() in
   templates/components/info_tip.html. */
.tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 1px solid var(--color-accent-300);
  border-radius: 50%;
  color: var(--color-accent-300);
  font-size: 11px;
  font-weight: 700;
  font-style: normal;
  line-height: 1;
  cursor: help;
}
.tip:hover, .tip:focus-visible { border-color: #fff; color: #fff; outline: none; }
.tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  width: max-content;
  max-width: 300px;
  padding: 10px 14px;
  background: var(--color-navy-900);
  border: 1px solid var(--color-primary-300);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  color: var(--on-dark);
  font-size: var(--fs-sm);
  font-weight: 400;
  line-height: 1.5;
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  transition: opacity .15s ease;
  pointer-events: none;
}
.tip:hover::after, .tip:focus-visible::after { opacity: 1; visibility: visible; }
/* Keep the bubble on-screen when the icon sits near a container edge. */
.tip--left::after { left: auto; right: -8px; transform: none; }
.tip--right::after { left: -8px; transform: none; }

/* Large indicator tooltip (third review): the title-block chat icon explains
   itself in a roomy bubble instead of navigating — Spheres arrive post-alpha.
   Anchored to the icon's right edge and opening downward so it stays
   on-screen at the top of the page. */
.indicator--tip { cursor: help; }
.indicator--tip::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 10px);
  right: -6px;
  z-index: 40;
  width: max-content;
  max-width: 380px;
  padding: 12px 16px;
  background: var(--color-navy-900);
  border: 1px solid var(--color-primary-300);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  color: var(--on-dark);
  font-size: var(--fs-sm);
  font-weight: 400;
  line-height: 1.55;
  text-align: left;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  transition: opacity .15s ease;
  pointer-events: none;
}
.indicator--tip:hover::after,
.indicator--tip:focus-visible::after { opacity: 1; visibility: visible; }

/* Responsive */
@media (max-width: 720px) {
  .nav--public { display: none; }
  .site-footer__inner { flex-direction: column; }
  .site-footer__col--right { text-align: left; }
  .site-footer__legal { justify-content: flex-start; }
}
