/* ============================================================ */
/*  Brandbook page styles (bb- prefix) + PDF export print rules  */
/* ============================================================ */

.bb-wrap { display: grid; grid-template-columns: 168px 1fr; gap: 20px; align-items: start; }
.bb-toc { position: sticky; top: 0; display: flex; flex-direction: column; gap: 1px; padding-top: 2px; }
.bb-toc a { font-size: 10px; color: var(--text-muted); padding: 4px 8px; border-radius: var(--r-sm); border-left: 2px solid transparent; }
.bb-toc a:hover { color: var(--text); background: var(--bg-2); }
.bb-toc a.on { color: var(--accent); border-left-color: var(--accent); background: color-mix(in oklab, var(--accent), transparent 92%); }
.bb-toc .bb-toc-hd { font-family: var(--font-mono); font-size: 8px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); padding: 10px 8px 3px; }

.bb-main { min-width: 0; display: flex; flex-direction: column; gap: 28px; padding-bottom: 60px; }
.bb-sec { scroll-margin-top: 12px; }
.bb-eyebrow { font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--accent); margin-bottom: 4px; }
.bb-sec > h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 4px; }
.bb-sec > .bb-intro { font-size: 11px; color: var(--text-muted); max-width: 560px; margin: 0 0 12px; text-wrap: pretty; }
.bb-sub { font-size: 11.5px; font-weight: 600; margin: 16px 0 8px; }

/* cover */
.bb-cover { border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--surface); padding: 28px; position: relative; overflow: hidden; }
.bb-cover .bb-version { font-family: var(--font-mono); font-size: 9px; color: var(--text-faint); }
.bb-cover h1 { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin: 10px 0 6px; }
.bb-cover p { font-size: 12px; color: var(--text-muted); max-width: 480px; margin: 0; }
.bb-cover .bb-words { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }

/* spec tables */
.bb-spec { width: 100%; border-collapse: collapse; font-size: 10px; }
.bb-spec th { text-align: center; font-family: var(--font-mono); font-size: 8px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-faint); font-weight: 500; padding: 5px 10px; border-bottom: 1px solid var(--border); }
.bb-spec td { padding: 5px 10px; border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; }
.bb-spec td.mono, .bb-spec .mono { font-family: var(--font-mono); font-size: 9px; color: var(--text-muted); }
.bb-spec tr:last-child td { border-bottom: 0; }

/* token & swatch rows */
.bb-swatch { width: 19px; height: 19px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); flex-shrink: 0; }
.bb-hex { width: 74px; height: 19px; font-family: var(--font-mono); font-size: 9px; padding: 0 6px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-sm); color: var(--text); outline: 0; }
.bb-hex:focus { border-color: var(--accent); }
.bb-pick { width: 19px; height: 19px; padding: 0; border: 1px solid var(--border); border-radius: var(--r-sm); background: none; cursor: pointer; }
.bb-pick::-webkit-color-swatch-wrapper { padding: 1px; }
.bb-pick::-webkit-color-swatch { border: 0; border-radius: 2px; }
.bb-edited-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }

/* specimen stages */
.bb-stage { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--bg); padding: 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bb-stage.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.bb-duo { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.bb-duo > div { padding: 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--bg); }
.bb-duo > .bb-light { border-left: 1px solid var(--border); }
.bb-duo-tag { font-family: var(--font-mono); font-size: 8px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-faint); width: 100%; }

/* component card */
.bb-comp { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.bb-comp-hd { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.bb-comp-hd h3 { font-size: 11.5px; font-weight: 600; margin: 0; flex: 1; }
.bb-comp-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.bb-note { font-size: 9.5px; color: var(--text-faint); }
.bb-note strong { color: var(--text-muted); }

/* playground */
.bb-play-tabs { display: flex; gap: 2px; }
.bb-play-tab { font-family: var(--font-mono); font-size: 8.5px; text-transform: uppercase; letter-spacing: 0.05em; padding: 3px 8px; border-radius: var(--r-sm); border: 1px solid transparent; background: transparent; color: var(--text-faint); }
.bb-play-tab.on { background: var(--bg-2); border-color: var(--border); color: var(--text); }
.bb-code { width: 100%; min-height: 96px; resize: vertical; font-family: var(--font-mono); font-size: 9.5px; line-height: 1.5; padding: 8px 10px; background: #1e1e1e; color: #d4d4d4; border: 1px solid var(--border); border-radius: var(--r-md); outline: 0; tab-size: 2; white-space: pre; }
.bb-code:focus { border-color: var(--accent); }
/* VS Code-style overlay editor: pre paints tokens, textarea on top carries the caret */
.bb-codewrap { position: relative; }
.bb-codewrap .bb-hl { position: absolute; inset: 0; margin: 0; overflow: hidden; pointer-events: none; resize: none; }
.bb-codewrap .bb-src { position: relative; display: block; background: transparent; color: transparent; caret-color: #d4d4d4; overflow: auto; }
.bb-codewrap .bb-src::selection { background: rgba(38, 79, 120, 0.55); }
.bb-hl .tk-c { color: #6a9955; } /* comment */
.bb-hl .tk-s { color: #ce9178; } /* string */
.bb-hl .tk-k { color: #569cd6; } /* keyword / declaration */
.bb-hl .tk-ctl { color: #c586c0; } /* control flow */
.bb-hl .tk-n { color: #b5cea8; } /* number */
.bb-hl .tk-f { color: #dcdcaa; } /* function call */
.bb-hl .tk-t { color: #569cd6; } /* html tag */
.bb-hl .tk-a { color: #9cdcfe; } /* attr / css property */
.bb-hl .tk-v { color: #4fc1ff; } /* css custom property */
.bb-hl .tk-sel { color: #d7ba7d; } /* css selector */
.bb-hl .tk-p { color: #808080; } /* punctuation */
.bb-play-err { font-family: var(--font-mono); font-size: 9px; color: var(--c-danger); background: color-mix(in oklab, var(--c-danger), transparent 92%); border: 1px solid color-mix(in oklab, var(--c-danger), transparent 75%); border-radius: var(--r-sm); padding: 4px 8px; }

/* zoom inspect */
.bb-zoom { overflow: auto; border: 1px dashed var(--border-strong); border-radius: var(--r-md); background: repeating-conic-gradient(var(--bg-2) 0% 25%, var(--bg) 0% 50%) 0 0 / 12px 12px; }
.bb-zoom-inner { transform-origin: 0 0; display: inline-block; padding: 8px; }

/* logo section */
.bb-logo-tile { border-radius: var(--r-lg); display: grid; place-items: center; min-height: 90px; position: relative; border: 1px solid var(--border); }
.bb-logo-tile .tag { position: absolute; left: 8px; bottom: 6px; font-family: var(--font-mono); font-size: 8px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-faint); }
.bb-clearspace { position: relative; display: inline-grid; place-items: center; padding: 24px; border: 1px dashed color-mix(in oklab, var(--accent), transparent 40%); border-radius: var(--r-md); }

/* do / don't */
.bb-dd { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bb-dd-item { border: 1px solid var(--border); border-radius: var(--r-md); padding: 8px 10px; font-size: 10px; }
.bb-dd-item .k { font-family: var(--font-mono); font-size: 8px; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 500; display: block; margin-bottom: 3px; }
.bb-dd-item.do .k { color: var(--c-success); }
.bb-dd-item.dont .k { color: var(--c-danger); }
.bb-dd-item .sub { color: var(--text-faint); font-size: 9px; display: block; margin-top: 2px; }

/* contrast matrix */
.bb-ctr { display: inline-flex; align-items: center; gap: 5px; }
.bb-ctr .chip { display: inline-grid; place-items: center; min-width: 52px; height: 20px; border-radius: var(--r-sm); font-size: 10px; padding: 0 8px; border: 1px solid var(--border); }
.bb-pass { color: var(--c-success); font-family: var(--font-mono); font-size: 8.5px; }
.bb-fail { color: var(--c-danger); font-family: var(--font-mono); font-size: 8.5px; }

/* toolbar */
.bb-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bb-icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
.bb-icon-cell { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 9px 4px 7px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg); color: var(--text); }
.bb-icon-cell .nm { font-family: var(--font-mono); font-size: 7.5px; color: var(--text-faint); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* motion demos */
.bb-motion-demo { display: inline-flex; align-items: center; gap: 8px; }

/* ============================================================ */
/*  PDF EXPORT - active only while html.bb-printing (button)     */
/* ============================================================ */
@media print {
  html.bb-printing .sidebar, html.bb-printing .topbar,
  html.bb-printing .bb-toc, html.bb-printing .bb-toolbar { display: none !important; }
  html.bb-printing #app { position: static !important; overflow: visible !important; }
  html.bb-printing .app-shell { display: block !important; transform: none !important; width: auto !important; height: auto !important; }
  html.bb-printing .main { overflow: visible !important; height: auto !important; padding: 0 !important; }
  html.bb-printing .bb-wrap { display: block; }
  html.bb-printing .bb-sec { break-inside: avoid-page; margin-bottom: 18px; }
  html.bb-printing .bb-comp, html.bb-printing .bb-stage, html.bb-printing .bb-duo { break-inside: avoid; }
  /* print on white: force light tokens (identical to light theme above) */
  html.bb-printing {
    --bg: #ffffff; --bg-2: oklch(0.97 0.005 60); --surface: #ffffff; --surface-2: oklch(0.985 0.003 60);
    --elevated: #ffffff; --border: oklch(0.91 0.008 60); --border-strong: oklch(0.85 0.01 60);
    --text: oklch(0.22 0.012 250); --text-muted: oklch(0.50 0.012 250); --text-faint: oklch(0.65 0.01 250);
    --accent: oklch(0.62 0.21 45); --accent-fg: #ffffff; --accent-soft: oklch(0.95 0.05 45);
    --accent-soft-fg: oklch(0.45 0.18 45); --focus-ring: oklch(0.62 0.21 45 / 0.35); --grid-line: oklch(0.93 0.005 60);
  }
  html.bb-printing body { background: #fff; }
}
