/* ============================================================
   HBS Design Tokens
   Monochrome by intent. Black and warm white dominate; grey is
   functional, never decorative.
   ============================================================ */

:root {
  /* --- Palette --- */
  --hbs-black: #000000;
  --hbs-carbon: #141414;
  --hbs-white: #f7f7f5;
  --hbs-grey-system: #bdbdbd;
  --hbs-grey-interface: #e5e5e5;

  /* --- Semantic (light context is the default) --- */
  --hbs-bg: var(--hbs-white);
  --hbs-surface: var(--hbs-white);
  --hbs-surface-raised: #ffffff;
  --hbs-fg: var(--hbs-black);
  --hbs-fg-muted: #555553;
  --hbs-fg-faint: var(--hbs-grey-system);
  --hbs-border: var(--hbs-grey-interface);
  --hbs-border-strong: var(--hbs-black);
  --hbs-module-muted: var(--hbs-grey-interface);

  /* --- Spacing: 8-point scale --- */
  --hbs-space-1: 4px;
  --hbs-space-2: 8px;
  --hbs-space-3: 16px;
  --hbs-space-4: 24px;
  --hbs-space-5: 32px;
  --hbs-space-6: 48px;
  --hbs-space-7: 64px;
  --hbs-space-8: 96px;
  --hbs-space-9: 128px;

  /* --- Type --- */
  --hbs-font-sans: "Neue Haas Grotesk Display Pro", "Neue Haas Grotesk",
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  --hbs-text-display: clamp(40px, 6vw, 72px);
  --hbs-text-h1: clamp(32px, 5vw, 56px);
  --hbs-text-h2: clamp(24px, 3.2vw, 40px);
  --hbs-text-h3: 20px;
  --hbs-text-body-lg: 18px;
  --hbs-text-body: 16px;
  --hbs-text-small: 14px;
  --hbs-text-label: 11px;
  --hbs-tracking-tight: -0.02em;
  --hbs-tracking-label: 0.08em;
  --hbs-leading-display: 1.02;
  --hbs-leading-heading: 1.1;
  --hbs-leading-body: 1.5;

  /* --- Shape --- */
  --hbs-radius-sm: 3px;
  --hbs-radius-module: 16px;

  /* --- Motion: precise, linear, controlled --- */
  --hbs-duration: 180ms;
  --hbs-ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* --- Layout --- */
  --hbs-measure: 65ch;
  --hbs-container: 1280px;
  --hbs-gutter: 24px;
}

/* Dark context: applied via .hbs-dark or [data-hbs-theme="dark"].
   Components read only the semantic tokens, so a subtree flips
   wholesale by adding the class. */
.hbs-dark,
[data-hbs-theme="dark"] {
  --hbs-bg: var(--hbs-black);
  --hbs-surface: var(--hbs-carbon);
  --hbs-surface-raised: var(--hbs-carbon);
  --hbs-fg: var(--hbs-white);
  --hbs-fg-muted: #a3a3a0;
  --hbs-fg-faint: #6d6d6b;
  --hbs-border: #2e2e2c;
  --hbs-border-strong: var(--hbs-white);
  --hbs-module-muted: #2e2e2c;
}

/* ============================================================
   HBS Base
   The root wrapper carries font, background and color so the
   system works without global resets. Wrap apps in .hbs-root
   (or the <HBSRoot> component).
   ============================================================ */

.hbs-root {
  font-family: var(--hbs-font-sans);
  font-size: var(--hbs-text-body);
  line-height: var(--hbs-leading-body);
  background: var(--hbs-bg);
  color: var(--hbs-fg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.hbs-root *,
.hbs-root *::before,
.hbs-root *::after {
  box-sizing: border-box;
}

.hbs-root :focus-visible {
  outline: 1px solid var(--hbs-border-strong);
  outline-offset: 2px;
}

.hbs-root ::selection {
  background: var(--hbs-fg);
  color: var(--hbs-bg);
}

/* ============================================================
   HBS Components
   Flat surfaces, 1px borders, small radii, fill-inversion
   interaction. No shadows, no pills, no decorative motion.
   ============================================================ */

/* ---------- Typography ---------- */

.hbs-display {
  font-size: var(--hbs-text-display);
  font-weight: 600;
  letter-spacing: var(--hbs-tracking-tight);
  line-height: var(--hbs-leading-display);
  margin: 0;
  color: var(--hbs-fg);
}

.hbs-h1 {
  font-size: var(--hbs-text-h1);
  font-weight: 600;
  letter-spacing: var(--hbs-tracking-tight);
  line-height: var(--hbs-leading-heading);
  margin: 0;
  color: var(--hbs-fg);
}

.hbs-h2 {
  font-size: var(--hbs-text-h2);
  font-weight: 500;
  letter-spacing: var(--hbs-tracking-tight);
  line-height: var(--hbs-leading-heading);
  margin: 0;
  color: var(--hbs-fg);
}

.hbs-h3 {
  font-size: var(--hbs-text-h3);
  font-weight: 500;
  line-height: 1.25;
  margin: 0;
  color: var(--hbs-fg);
}

.hbs-body {
  font-size: var(--hbs-text-body);
  line-height: var(--hbs-leading-body);
  max-width: var(--hbs-measure);
  margin: 0;
  color: var(--hbs-fg);
}

.hbs-body--lg {
  font-size: var(--hbs-text-body-lg);
}

.hbs-body--muted {
  color: var(--hbs-fg-muted);
}

.hbs-label {
  display: inline-block;
  font-size: var(--hbs-text-label);
  font-weight: 500;
  letter-spacing: var(--hbs-tracking-label);
  text-transform: uppercase;
  line-height: 1.2;
  margin: 0;
  color: var(--hbs-fg-muted);
}

.hbs-label--strong {
  color: var(--hbs-fg);
}

/* ---------- Button ---------- */

.hbs-btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--hbs-space-4);
  font-family: var(--hbs-font-sans);
  font-size: var(--hbs-text-small);
  font-weight: 500;
  line-height: 1;
  padding: 0 var(--hbs-space-3);
  height: 44px;
  border: 1px solid var(--hbs-border-strong);
  border-radius: var(--hbs-radius-sm);
  background: var(--hbs-fg);
  color: var(--hbs-bg);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--hbs-duration) var(--hbs-ease),
    color var(--hbs-duration) var(--hbs-ease),
    border-color var(--hbs-duration) var(--hbs-ease);
}

.hbs-btn:hover {
  background: var(--hbs-bg);
  color: var(--hbs-fg);
}

.hbs-btn:active {
  background: var(--hbs-surface);
}

.hbs-btn:disabled {
  background: var(--hbs-module-muted);
  border-color: var(--hbs-module-muted);
  color: var(--hbs-fg-faint);
  cursor: not-allowed;
}

.hbs-btn--secondary {
  background: transparent;
  color: var(--hbs-fg);
}

.hbs-btn--secondary:hover {
  background: var(--hbs-fg);
  color: var(--hbs-bg);
}

.hbs-btn--ghost {
  background: transparent;
  color: var(--hbs-fg);
  border-color: transparent;
  padding: 0 var(--hbs-space-2);
}

.hbs-btn--ghost:hover {
  background: transparent;
  color: var(--hbs-fg);
  border-color: var(--hbs-border-strong);
}

.hbs-btn--sm {
  height: 36px;
  font-size: 13px;
  gap: var(--hbs-space-3);
}

.hbs-btn--lg {
  height: 52px;
  font-size: var(--hbs-text-body);
}

.hbs-btn__arrow {
  display: inline-flex;
  flex: none;
  transition: transform var(--hbs-duration) var(--hbs-ease);
}

.hbs-btn:hover .hbs-btn__arrow {
  transform: translateX(2px);
}

/* ---------- Card ---------- */

.hbs-card {
  display: flex;
  flex-direction: column;
  gap: var(--hbs-space-3);
  background: var(--hbs-surface);
  border: 1px solid var(--hbs-border);
  border-radius: var(--hbs-radius-sm);
  padding: var(--hbs-space-4);
  transition: border-color var(--hbs-duration) var(--hbs-ease);
}

.hbs-card--interactive {
  cursor: pointer;
}

.hbs-card--interactive:hover {
  border-color: var(--hbs-border-strong);
}

.hbs-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--hbs-space-3);
}

.hbs-card__title {
  font-size: var(--hbs-text-h3);
  font-weight: 500;
  line-height: 1.25;
  margin: 0;
  color: var(--hbs-fg);
}

.hbs-card__desc {
  font-size: var(--hbs-text-small);
  line-height: var(--hbs-leading-body);
  color: var(--hbs-fg-muted);
  margin: 0;
}

.hbs-card__footer {
  margin-top: auto;
  padding-top: var(--hbs-space-3);
  border-top: 1px solid var(--hbs-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--hbs-space-3);
}

/* ---------- Tag ---------- */

.hbs-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--hbs-space-2);
  font-size: var(--hbs-text-label);
  font-weight: 500;
  letter-spacing: var(--hbs-tracking-label);
  text-transform: uppercase;
  line-height: 1;
  padding: 6px 10px;
  border: 1px solid var(--hbs-border);
  border-radius: var(--hbs-radius-sm);
  color: var(--hbs-fg-muted);
  background: transparent;
  white-space: nowrap;
}

.hbs-tag--solid {
  background: var(--hbs-fg);
  border-color: var(--hbs-fg);
  color: var(--hbs-bg);
}

.hbs-tag--strong {
  border-color: var(--hbs-border-strong);
  color: var(--hbs-fg);
}

.hbs-tag__dot {
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: currentColor;
  flex: none;
}

/* ---------- Divider ---------- */

.hbs-divider {
  border: none;
  border-top: 1px solid var(--hbs-border);
  margin: 0;
}

.hbs-divider--strong {
  border-top-color: var(--hbs-border-strong);
}

.hbs-divider-labeled {
  display: flex;
  align-items: center;
  gap: var(--hbs-space-3);
}

.hbs-divider-labeled .hbs-divider {
  flex: 1;
}

/* ---------- Input ---------- */

.hbs-field {
  display: flex;
  flex-direction: column;
  gap: var(--hbs-space-2);
}

.hbs-field__hint {
  font-size: 12px;
  color: var(--hbs-fg-muted);
  margin: 0;
}

.hbs-field__hint--error {
  color: var(--hbs-fg);
  font-weight: 500;
}

.hbs-input {
  font-family: var(--hbs-font-sans);
  font-size: var(--hbs-text-small);
  height: 44px;
  padding: 0 var(--hbs-space-3);
  background: var(--hbs-surface-raised);
  border: 1px solid var(--hbs-border);
  border-radius: var(--hbs-radius-sm);
  color: var(--hbs-fg);
  width: 100%;
  transition: border-color var(--hbs-duration) var(--hbs-ease);
}

textarea.hbs-input {
  height: auto;
  min-height: 96px;
  padding: var(--hbs-space-2) var(--hbs-space-3);
  resize: vertical;
  line-height: var(--hbs-leading-body);
}

.hbs-input::placeholder {
  color: var(--hbs-fg-faint);
}

.hbs-input:hover {
  border-color: var(--hbs-fg-faint);
}

.hbs-input:focus {
  outline: none;
  border-color: var(--hbs-border-strong);
}

.hbs-input:disabled {
  background: var(--hbs-module-muted);
  color: var(--hbs-fg-faint);
  cursor: not-allowed;
}

.hbs-input--error {
  border-color: var(--hbs-border-strong);
}

/* ---------- Navbar ---------- */

.hbs-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--hbs-space-5);
  padding: var(--hbs-space-3) var(--hbs-space-4);
  background: var(--hbs-bg);
  color: var(--hbs-fg);
  border-bottom: 1px solid var(--hbs-border);
}

.hbs-navbar__brand {
  display: inline-flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
  flex: none;
}

.hbs-navbar__links {
  display: flex;
  align-items: center;
  gap: var(--hbs-space-5);
  list-style: none;
  margin: 0;
  padding: 0;
}

.hbs-navbar__link {
  font-size: var(--hbs-text-small);
  font-weight: 500;
  color: var(--hbs-fg-muted);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  transition: color var(--hbs-duration) var(--hbs-ease),
    border-color var(--hbs-duration) var(--hbs-ease);
}

.hbs-navbar__link:hover {
  color: var(--hbs-fg);
  border-bottom-color: var(--hbs-fg);
}

.hbs-navbar__link--active {
  color: var(--hbs-fg);
  border-bottom-color: var(--hbs-fg);
}

.hbs-navbar__actions {
  display: flex;
  align-items: center;
  gap: var(--hbs-space-3);
}

.hbs-navbar__menu {
  display: none;
}

@media (max-width: 720px) {
  .hbs-navbar__links {
    display: none;
  }
  .hbs-navbar__menu {
    display: inline-flex;
  }
}

/* ---------- Footer ---------- */

.hbs-footer {
  background: var(--hbs-bg);
  color: var(--hbs-fg);
  border-top: 1px solid var(--hbs-border);
  padding: var(--hbs-space-6) var(--hbs-space-4) var(--hbs-space-4);
  display: flex;
  flex-direction: column;
  gap: var(--hbs-space-6);
}

.hbs-footer__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--hbs-space-6);
  flex-wrap: wrap;
}

.hbs-footer__cols {
  display: flex;
  gap: var(--hbs-space-7);
  flex-wrap: wrap;
}

.hbs-footer__col {
  display: flex;
  flex-direction: column;
  gap: var(--hbs-space-2);
  min-width: 120px;
}

.hbs-footer__col-title {
  margin-bottom: var(--hbs-space-2);
}

.hbs-footer__link {
  font-size: var(--hbs-text-small);
  color: var(--hbs-fg-muted);
  text-decoration: none;
  transition: color var(--hbs-duration) var(--hbs-ease);
}

.hbs-footer__link:hover {
  color: var(--hbs-fg);
}

.hbs-footer__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--hbs-space-3);
  padding-top: var(--hbs-space-3);
  border-top: 1px solid var(--hbs-border);
  font-size: 12px;
  color: var(--hbs-fg-muted);
  flex-wrap: wrap;
}

/* ---------- Stat ---------- */

.hbs-stat {
  display: flex;
  flex-direction: column;
  gap: var(--hbs-space-2);
}

.hbs-stat--bordered {
  border-top: 1px solid var(--hbs-border-strong);
  padding-top: var(--hbs-space-3);
}

.hbs-stat__value {
  font-size: var(--hbs-text-h1);
  font-weight: 600;
  letter-spacing: var(--hbs-tracking-tight);
  line-height: 1;
  color: var(--hbs-fg);
}

.hbs-stat__desc {
  font-size: var(--hbs-text-small);
  color: var(--hbs-fg-muted);
  margin: 0;
  max-width: 32ch;
}

/* ---------- Logo / mark ---------- */

.hbs-mark {
  display: inline-block;
  flex: none;
}

.hbs-logo {
  display: inline-flex;
  color: var(--hbs-fg);
  text-decoration: none;
}

.hbs-logo--vertical {
  flex-direction: column;
  align-items: flex-start;
  gap: var(--hbs-space-3);
}

.hbs-logo--horizontal {
  flex-direction: row;
  align-items: center;
  gap: var(--hbs-space-3);
}

.hbs-logo__name {
  font-size: var(--hbs-text-body);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: var(--hbs-tracking-tight);
  white-space: pre-line;
}

/* ---------- Module pattern ---------- */

.hbs-pattern {
  display: inline-block;
  color: var(--hbs-fg);
}

.hbs-pattern--muted {
  color: var(--hbs-module-muted);
}

.hbs-pattern--faint {
  color: var(--hbs-fg-faint);
}

.hbs-pattern--cropped {
  overflow: hidden;
  display: block;
}
