/*
 * TBBC UI kit: the visual language of the home page and /rating-widget/, for inner pages.
 * How to use: sites/tbbc.app/ui/README.md. Everything is scoped under .tbbc, so loading this
 * file on a page never restyles what is outside a .tbbc element.
 *
 * Load with the brand fonts:
 *   <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@600;700&family=JetBrains+Mono:wght@400;600&display=swap">
 *   <link rel="stylesheet" href="/ui/tbbc-ui.css">
 *
 * Brand rules (docs/business/brand.md section 9): black, blue and white only. "Working" glows
 * blue, "broken" goes white/grey. Red only for form validation. The blue/white glitch on hover
 * and keyboard focus is the brand signature.
 */

/* ---------- Tokens ---------- */
.tbbc {
  --tbbc-bg: #05070d;
  --tbbc-surface: #0a0f1c;
  --tbbc-surface-2: #0e1526;
  --tbbc-text: #e8eefc;
  --tbbc-muted: #93a1b8;
  --tbbc-border: rgba(120, 160, 255, 0.16);
  --tbbc-border-strong: rgba(127, 176, 255, 0.32);
  --tbbc-blue: #3b82f6;
  --tbbc-blue-text: #7fb0ff;
  --tbbc-btn: #2563eb;
  --tbbc-btn-hover: #1d4ed8;
  --tbbc-cyan: #60a5fa;
  --tbbc-white: #f5f8ff;
  --tbbc-ok: #4ade80;
  --tbbc-ok-text: #86efac;
  --tbbc-danger: #ff6b8b; /* form validation only */
  --tbbc-display: 'Chakra Petch', system-ui, sans-serif;
  --tbbc-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --tbbc-pad-x: clamp(16px, 5vw, 48px);

  min-height: 100vh;
  background: var(--tbbc-bg);
  color: var(--tbbc-text);
  font: 16px/1.55 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  position: relative;
  isolation: isolate;
}
.tbbc *, .tbbc *::before, .tbbc *::after { box-sizing: border-box; }
.tbbc a { color: inherit; }
.tbbc ::selection { background: var(--tbbc-blue); color: #fff; }
.tbbc :focus-visible { outline: 2px solid var(--tbbc-cyan); outline-offset: 3px; border-radius: 4px; }
.tbbc [hidden] { display: none !important; }

/* Page background: soft blue glows and a faint grid. Put <div class="tbbc-bg"></div> first in .tbbc. */
.tbbc-bg { position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 420px at 15% -5%, rgba(59, 130, 246, .16), transparent 60%),
    radial-gradient(700px 380px at 95% 10%, rgba(96, 165, 250, .10), transparent 60%),
    var(--tbbc-bg); }
.tbbc-bg::after { content: ''; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(96, 165, 250, .06) 1px, transparent 1px), linear-gradient(90deg, rgba(96, 165, 250, .06) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, #000, transparent 70%); -webkit-mask-image: linear-gradient(to bottom, #000, transparent 70%); }

/* ---------- Header (same as the home page) ---------- */
.tbbc-header { position: sticky; top: 0; z-index: 30; background: rgba(5, 7, 13, .72); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--tbbc-border); }
.tbbc-header-inner { max-width: 1160px; margin: 0 auto; padding: 0 var(--tbbc-pad-x); position: relative; display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; }
.tbbc-logo { font-family: var(--tbbc-display); font-weight: 700; font-size: 22px; letter-spacing: .02em; text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; color: var(--tbbc-text); }
.tbbc-logo span { color: var(--tbbc-blue); text-shadow: 0 0 12px var(--tbbc-blue); }
.tbbc-nav { display: flex; align-items: center; gap: clamp(12px, 3vw, 28px); font-family: var(--tbbc-mono); font-size: 13px; }
.tbbc-nav a, .tbbc-nav button { text-decoration: none; color: var(--tbbc-muted); display: inline-flex; align-items: center; min-height: 44px; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.tbbc-nav a:hover, .tbbc-nav button:hover { color: var(--tbbc-cyan); }
.tbbc-nav .is-active { color: #fff; }
.tbbc-nav .is-cta { color: var(--tbbc-blue-text); }
.tbbc-nav .tbbc-who { color: var(--tbbc-muted); font-size: 12px; opacity: .8; }
.tbbc-progress { position: absolute; left: 0; bottom: -1px; height: 2px; width: 100%; background: linear-gradient(90deg, var(--tbbc-blue), var(--tbbc-cyan), #fff); transform-origin: 0 50%; transform: scaleX(var(--scroll, 0)); box-shadow: 0 0 10px var(--tbbc-cyan); }
@media (max-width: 700px) { .tbbc-nav .is-optional { display: none; } }

/* ---------- Layout and type ---------- */
.tbbc-main { max-width: 1160px; margin: 0 auto; padding: 32px var(--tbbc-pad-x) 72px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.tbbc-narrow { max-width: 780px; width: 100%; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.tbbc-label { font-family: var(--tbbc-mono); font-size: 12.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--tbbc-blue-text); margin: 0; }
.tbbc-label::before { content: '// '; color: var(--tbbc-blue); }
.tbbc-h1 { font-family: var(--tbbc-display); font-weight: 700; text-transform: uppercase; font-size: clamp(28px, 4.4vw, 44px); line-height: 1.06; letter-spacing: .01em; margin: 0; }
.tbbc-h1 em, .tbbc-h2 em { font-style: normal; color: var(--tbbc-cyan); text-shadow: 0 0 18px rgba(96, 165, 250, .55); }
.tbbc-h2 { font-family: var(--tbbc-display); font-weight: 700; text-transform: uppercase; font-size: 20px; letter-spacing: .02em; margin: 0; }
.tbbc-h3 { font-size: 16px; font-weight: 650; margin: 0; }
.tbbc-muted { color: var(--tbbc-muted); }
.tbbc-small { font-size: 13px; }
.tbbc-lede { font-size: 17px; color: var(--tbbc-muted); margin: 0; max-width: 640px; }
.tbbc-link { color: var(--tbbc-blue-text); }
.tbbc-link:hover { color: var(--tbbc-cyan); }
.tbbc-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tbbc code { font: 13px var(--tbbc-mono); color: var(--tbbc-blue-text); background: var(--tbbc-surface-2); padding: 1px 6px; border-radius: 4px; }

/* ---------- Buttons: cut corners + glitch on hover/focus ---------- */
.tbbc-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 600 14px var(--tbbc-mono); letter-spacing: .04em;
  padding: 12px 20px; border: 0; color: #fff; text-decoration: none; cursor: pointer; white-space: nowrap;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
  transition: background-color .2s, box-shadow .2s, color .2s; }
.tbbc-btn-primary { background: var(--tbbc-btn); box-shadow: 0 0 0 1px rgba(127, 176, 255, .4) inset, 0 0 30px -6px var(--tbbc-blue); }
.tbbc-btn-primary:hover { background: var(--tbbc-btn-hover); }
.tbbc-btn-ghost { background: transparent; color: var(--tbbc-text); box-shadow: 0 0 0 1px var(--tbbc-border-strong) inset; }
.tbbc-btn-ghost:hover { box-shadow: 0 0 0 1px var(--tbbc-cyan) inset, 0 0 24px -8px var(--tbbc-cyan); color: var(--tbbc-cyan); }
.tbbc-btn-sm { padding: 8px 14px; font-size: 12.5px; clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 9px 100%, 0 calc(100% - 9px)); }
.tbbc-btn-lg { padding: 15px 24px; font-size: 15px; }
.tbbc-btn:disabled { opacity: .5; cursor: default; animation: none !important; }

/* ---------- Cards ---------- */
.tbbc-card { background: rgba(10, 15, 28, .86); border: 1px solid var(--tbbc-border); border-radius: 10px; padding: 18px 20px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; min-width: 0; }
.tbbc-card-glow { border-color: var(--tbbc-border-strong); box-shadow: 0 24px 70px -34px rgba(37, 99, 235, .7); }
.tbbc-card-accent { background: linear-gradient(180deg, rgba(37, 99, 235, .14), rgba(37, 99, 235, .04)); border-color: rgba(127, 176, 255, .35); }
.tbbc-card-ok { background: linear-gradient(180deg, rgba(34, 197, 94, .12), rgba(34, 197, 94, .03)); border-color: rgba(134, 239, 172, .4); }
/* HUD corners: a work-order / terminal frame */
.tbbc-hud { position: relative; }
.tbbc-hud::before, .tbbc-hud::after { content: ''; position: absolute; width: 14px; height: 14px; border: 2px solid var(--tbbc-cyan); opacity: .7; pointer-events: none; }
.tbbc-hud::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
.tbbc-hud::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }
.tbbc-card-link { text-decoration: none; transition: border-color .2s, box-shadow .2s, transform .2s; }
.tbbc-card-link:hover, .tbbc-card-link:focus-visible { border-color: var(--tbbc-cyan); box-shadow: 0 0 30px -12px var(--tbbc-cyan); transform: translateY(-2px); }

/* ---------- Forms ---------- */
.tbbc-field { display: grid; gap: 6px; font: 600 12px var(--tbbc-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--tbbc-blue-text); }
.tbbc-hint { font: 13px system-ui, sans-serif; letter-spacing: 0; text-transform: none; color: var(--tbbc-muted); }
.tbbc-input { font: 15px system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; letter-spacing: 0; text-transform: none; color: var(--tbbc-text);
  background: #060a14; border: 1px solid rgba(160, 190, 255, .42); border-radius: 4px; padding: 10px 12px; width: 100%; min-width: 0; transition: border-color .2s, box-shadow .2s; }
select.tbbc-input { width: auto; padding-right: 30px; }
textarea.tbbc-input { resize: vertical; min-height: 40px; }
.tbbc-input::placeholder { color: var(--tbbc-muted); opacity: 1; }
.tbbc-input:focus-visible { outline: none; border-color: var(--tbbc-cyan); box-shadow: 0 0 0 3px rgba(96, 165, 250, .22), 0 0 20px -6px var(--tbbc-cyan); }
.tbbc-input[aria-invalid="true"] { border-color: var(--tbbc-danger); border-width: 2px; }
.tbbc-input-lg { font-size: 17px; padding: 13px 14px; }
.tbbc-error { color: var(--tbbc-danger); font-size: 14px; font-weight: 600; margin: 0; }

/* ---------- Chips, segmented control, table ---------- */
.tbbc-chip { display: inline-flex; align-items: center; gap: 6px; font: 600 12px var(--tbbc-mono); letter-spacing: .03em; color: var(--tbbc-blue-text); border: 1px solid var(--tbbc-border); background: var(--tbbc-surface-2); border-radius: 999px; padding: 2px 10px; }
.tbbc-chip-up { color: var(--tbbc-ok-text); background: rgba(34, 197, 94, .14); border-color: rgba(34, 197, 94, .3); }
.tbbc-chip-down { color: #e8eefc; background: rgba(148, 163, 184, .14); border-color: rgba(148, 163, 184, .3); }
.tbbc-seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border: 1px solid var(--tbbc-border); border-radius: 8px; background: var(--tbbc-surface); }
.tbbc-seg button { font: 600 12.5px var(--tbbc-mono); color: var(--tbbc-muted); background: transparent; border: 0; padding: 6px 11px; border-radius: 5px; cursor: pointer; }
.tbbc-seg button:hover { color: var(--tbbc-cyan); }
.tbbc-seg button[aria-pressed="true"] { background: var(--tbbc-btn); color: #fff; box-shadow: 0 0 18px -4px var(--tbbc-blue); }
.tbbc-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tbbc-table th, .tbbc-table td { text-align: right; padding: 9px 8px; border-bottom: 1px solid var(--tbbc-border); white-space: nowrap; }
.tbbc-table th:first-child, .tbbc-table td:first-child { text-align: left; }
.tbbc-table th { font: 600 11.5px var(--tbbc-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--tbbc-blue-text); }
.tbbc-table tr:last-child td { border-bottom: 0; }

/* ---------- Code blocks ---------- */
.tbbc-code { position: relative; }
.tbbc-code pre { margin: 0; background: #03050a; color: #d6e2ff; border: 1px solid var(--tbbc-border); border-radius: 8px; padding: 12px 14px; padding-right: 110px; overflow-x: auto; font: 13px/1.6 var(--tbbc-mono); }
.tbbc-code .tbbc-btn { position: absolute; top: 7px; right: 7px; }

/* ---------- Effects ---------- */
@keyframes tbbc-glitch {
  0% { transform: translate(0); text-shadow: -2px 0 var(--tbbc-white), 2px 0 var(--tbbc-cyan); }
  50% { transform: translate(2px, -1px); text-shadow: 2px 0 var(--tbbc-white), -2px 0 var(--tbbc-cyan); }
  100% { transform: none; text-shadow: none; }
}
.tbbc-btn:hover, .tbbc-btn:focus-visible, .tbbc-logo:hover, .tbbc-logo:focus-visible,
.tbbc-nav a:hover, .tbbc-nav a:focus-visible, .tbbc-nav button:hover, .tbbc-nav button:focus-visible,
.tbbc-glitch-hover:hover, .tbbc-glitch-hover:focus-visible { animation: tbbc-glitch .35s steps(2) 1; }
/* Add (or re-add) .tbbc-glitch-once to an element to make it glitch once, e.g. when a number changes. */
.tbbc-glitch-once { animation: tbbc-glitch .35s steps(2) 2; }
/* A live/waiting dot: blinks white; add .is-ok to turn it green and steady. */
.tbbc-dot { width: 8px; height: 8px; border-radius: 50%; background: #dbe7ff; box-shadow: 0 0 8px #dbe7ff; display: inline-block; flex: none; animation: tbbc-blink 1.4s steps(2) infinite; }
.tbbc-dot.is-ok { background: var(--tbbc-ok); box-shadow: 0 0 10px var(--tbbc-ok); animation: none; }
@keyframes tbbc-blink { 50% { opacity: .2; } }
/* Accomplishment: a check that draws itself with a ring pulse. Markup in README. */
.tbbc-check { width: 32px; height: 32px; flex: none; position: relative; }
.tbbc-check circle { fill: none; stroke: var(--tbbc-cyan); stroke-width: 2; opacity: .6; }
.tbbc-check path { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24; animation: tbbc-draw .5s .15s ease-out forwards; }
@keyframes tbbc-draw { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
  .tbbc *, .tbbc *::before, .tbbc *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .tbbc-check path { stroke-dashoffset: 0; }
}
