/*
 * RB base — document shell styles (v3).
 *
 * Owns the reset, the page-level layout of the shell elements, the skip
 * link, .sr-only, the @font-face rules and the pre-upgrade fallback chrome.
 * Theme colors come exclusively from tokens.css.
 *
 * v3 layout: a classic website. The document scrolls; <rb-topbar> is a
 * sticky header with the primary navigation; <rb-stage> renders the page
 * in normal flow; <rb-statusbar> is the footer at the end of the page; the
 * terminal (<rb-console>) is an overlay drawer at every width.
 */

@font-face {
  font-family: Space;
  src: url('/assets/fonts/space-grotesk-vf.ttf') format('truetype');
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Ubuntu Mono";
  src: url('/assets/fonts/ubuntu-mono-regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Ubuntu Mono";
  src: url('/assets/fonts/ubuntu-mono-bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* Shell metrics (layout, not theme — deliberately no root font-size so OS/browser text-scale works) */
:root {
  --header-h: 68px;
  --console-w: min(92vw, 460px);

  /*
   * Type scale. Prose is Space Grotesk at a real reading size; Ubuntu Mono
   * (small x-height) never goes below 0.8125rem and labels default to
   * 0.875rem.
   */
  --rb-fs-micro: 0.8125rem;
  --rb-fs-label: 0.875rem;
  --rb-fs-small: 0.9375rem;
  --rb-fs-body: 1.0625rem;
  --rb-fs-lead: clamp(1.125rem, 1.02rem + 0.35vw, 1.3125rem);
  --rb-fs-h3: clamp(1.1875rem, 1.08rem + 0.35vw, 1.375rem);
  --rb-fs-h2: clamp(1.875rem, 1.35rem + 1.9vw, 3rem);
  --rb-fs-h1: clamp(2.375rem, 1.5rem + 3.2vw, 4.5rem);
  --rb-lh-body: 1.6;
  --rb-track-label: 0.06em;

  /* Page rhythm */
  --rb-content-max: 76rem;
  --rb-pad-x: clamp(1.25rem, 5vw, 3rem);
  --rb-section-y: clamp(4rem, 9vw, 7.5rem);
  --rb-gap: clamp(1rem, 1.8vw, 1.5rem);

  /* Legacy aliases still read by a few component sheets */
  --rb-panel-max: var(--rb-content-max);
  --rb-panel-pad-x: var(--rb-pad-x);
  --rb-section-gap: clamp(2rem, 4vw, 3rem);
}

/* Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  scroll-padding-top: var(--header-h);
}
html,
body {
  margin: 0;
}
body {
  min-height: 100dvh;
  overflow-x: clip;
  background: var(--rb-surface, #14161b);
  color: var(--rb-text, #f2f0e9);
  font-family: var(--rb-font-sans, system-ui, sans-serif);
  -webkit-font-smoothing: antialiased;
}
button,
input {
  font: inherit;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  color: inherit;
}
a {
  color: inherit;
}
:focus-visible {
  outline: 2px solid var(--rb-tangerine);
  outline-offset: 4px;
}
::selection {
  background: var(--rb-lime);
  color: var(--rb-ink);
}

/* Accessibility helpers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: fixed;
  z-index: 200;
  left: 16px;
  top: -80px;
  padding: 12px 16px;
  background: var(--rb-lime);
  color: var(--rb-ink);
  font: 0.875rem var(--rb-font-mono);
}
.skip-link:focus {
  top: 12px;
}

/* Page shell: sticky header / page / footer */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
rb-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: block;
  height: var(--header-h);
}
.workspace {
  flex: 1 0 auto;
  display: block;
  min-width: 0;
}
rb-stage {
  display: block;
  min-width: 0;
}
rb-statusbar {
  display: block;
}
rb-palette:not(:defined) {
  display: none;
}

/* The terminal: an overlay drawer at every width */
rb-console {
  position: fixed;
  z-index: 60;
  top: var(--header-h);
  bottom: 0;
  left: 0;
  width: var(--console-w);
  transform: translateX(-105%);
  visibility: hidden;
  transition: transform 0.35s var(--rb-ease), visibility 0s linear 0.35s;
}
rb-console[open] {
  transform: none;
  visibility: visible;
  box-shadow: 24px 0 70px rgba(0, 0, 0, 0.45);
  transition: transform 0.35s var(--rb-ease), visibility 0s;
}
.workspace:has(> rb-console[open])::before {
  content: "";
  position: fixed;
  z-index: 55;
  inset: var(--header-h) 0 0 0;
  background: rgba(16, 18, 21, 0.5);
}

@media (max-width: 680px) {
  :root {
    --header-h: 60px;
  }
}

/*
 * Pre-upgrade fallback chrome (scoped under `:not(:defined)`): shown only
 * until the components upgrade, or permanently if the module graph fails.
 */
rb-topbar:not(:defined),
rb-statusbar:not(:defined),
rb-console:not(:defined),
rb-stage:not(:defined) {
  display: block;
}

/* — fallback header — */
rb-topbar:not(:defined) .topbar {
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 100%;
  padding: 0 var(--rb-pad-x);
  background: #101215;
  color: #f2f0e9;
  border-bottom: 1px solid #2b2e33;
}
rb-topbar:not(:defined) .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
}
rb-topbar:not(:defined) .brand img {
  width: 56px;
  height: 30px;
  object-fit: contain;
}
rb-topbar:not(:defined) .brand-name {
  font-size: 1.1875rem;
  font-weight: 650;
  letter-spacing: -0.04em;
}
rb-topbar:not(:defined) .brand-name b {
  color: var(--rb-lime);
}
rb-topbar:not(:defined) .main-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-left: auto;
}
rb-topbar:not(:defined) .main-nav a {
  color: #c9cfd5;
  font-size: 0.9375rem;
  text-decoration: none;
}
rb-topbar:not(:defined) .main-nav .nav-cta {
  padding: 0.55rem 1rem;
  background: var(--rb-lime);
  color: #101215;
  font-weight: 600;
}
rb-topbar:not(:defined) .console-mobile {
  border: 1px solid #41464c;
  background: transparent;
  color: #d9dde1;
  padding: 7px 10px;
  font: 0.8125rem var(--rb-font-mono);
  cursor: pointer;
}

/* — fallback console (inside the closed drawer) — */
rb-console:not(:defined) {
  overflow-y: auto;
  padding: 1.25rem;
  background: #101215;
  color: #d9dde1;
  font: 0.9375rem/1.6 var(--rb-font-mono);
}
rb-console:not(:defined) .console-chrome,
rb-console:not(:defined) .quick-label,
rb-console:not(:defined) .console-foot {
  color: #9aa2aa;
  font-size: var(--rb-fs-micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
rb-console:not(:defined) .console-close,
rb-console:not(:defined) .cli-line button,
rb-console:not(:defined) .console-form button {
  border: 0;
  background: transparent;
  color: var(--rb-lime);
  font: inherit;
  cursor: pointer;
}
rb-console:not(:defined) .ascii {
  margin: 0.75rem 0;
  color: var(--rb-tangerine);
  font-weight: 700;
  font-size: 1.75rem;
}
rb-console:not(:defined) .ascii small {
  display: block;
  color: var(--rb-lime);
  font-size: var(--rb-fs-micro);
  font-weight: 400;
}
rb-console:not(:defined) .prompt {
  color: var(--rb-lime);
}
rb-console:not(:defined) .quick-commands {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 0.5rem 0 1rem;
}
rb-console:not(:defined) .quick-commands button {
  padding: 8px;
  border: 1px solid #30343a;
  background: #15171b;
  color: #c4cbd1;
  font: var(--rb-fs-micro) var(--rb-font-mono);
  text-align: left;
  cursor: pointer;
}
rb-console:not(:defined) .console-form input {
  border: 0;
  background: transparent;
  color: #f2f4f6;
  font: inherit;
}

/* — fallback page (static home hero) — */
rb-stage:not(:defined) .panels {
  max-width: calc(var(--rb-content-max) + 2 * var(--rb-pad-x));
  margin: 0 auto;
  padding: clamp(3rem, 7vw, 6rem) var(--rb-pad-x);
  outline: none;
}
rb-stage:not(:defined) .kicker {
  margin: 0 0 1.25rem;
  color: var(--rb-text-eyebrow);
  font: var(--rb-fs-label) var(--rb-font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
rb-stage:not(:defined) h1 {
  max-width: 15ch;
  margin: 0 0 1.5rem;
  font-size: var(--rb-fs-h1);
  font-weight: 620;
  letter-spacing: -0.045em;
  line-height: 1.03;
}
rb-stage:not(:defined) h1 .accent {
  color: var(--rb-tangerine);
}
rb-stage:not(:defined) .lead {
  max-width: 58ch;
  margin: 0 0 2rem;
  color: var(--rb-text-lead);
  font-size: var(--rb-fs-lead);
  line-height: 1.55;
}
rb-stage:not(:defined) .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.875rem;
  margin-bottom: 1.5rem;
}
rb-stage:not(:defined) .button {
  min-height: 48px;
  padding: 0 1.25rem;
  border: 1px solid var(--rb-primary);
  background: var(--rb-primary);
  color: var(--rb-primary-text);
  font: 700 0.875rem var(--rb-font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}
rb-stage:not(:defined) .button.secondary {
  border-color: var(--rb-border-strong);
  background: transparent;
  color: var(--rb-text);
}
rb-stage:not(:defined) .home-note {
  color: var(--rb-text-note);
  font: var(--rb-fs-small)/1.5 var(--rb-font-sans);
}

/* — fallback footer — */
rb-statusbar:not(:defined) .statusbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem var(--rb-pad-x);
  background: #101215;
  color: #b9c0c7;
  font: var(--rb-fs-micro) var(--rb-font-mono);
}
rb-statusbar:not(:defined) .footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #f2f0e9;
}
rb-statusbar:not(:defined) .footer-brand img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}
rb-statusbar:not(:defined) .footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
rb-statusbar:not(:defined) .footer-contact {
  border: 0;
  background: transparent;
  color: #d0d6dc;
  font: inherit;
  cursor: pointer;
}

@media (max-width: 1080px) {
  rb-topbar:not(:defined) .main-nav a:not(.nav-cta) {
    display: none;
  }
}
@media (max-width: 480px) {
  rb-topbar:not(:defined) .brand-name,
  rb-topbar:not(:defined) .main-nav {
    display: none;
  }
}
