/* Be Creative brand skin for the Omnigent web UI.
 *
 * Loaded from index.html after Omnigent's own stylesheet (see ../branding/Dockerfile), so equal
 * selectors win on order. The skin is design tokens first — a new Omnigent build changes chunk
 * names and markup, not the token contract (--background, --primary, --sidebar-*, …) — and the
 * few blocks that do reach into component markup (logo, copy, file rows) say so, key on the most
 * stable handle they can find, and fail soft when it moves.
 *
 * Palette: be-creative.ch (Divi theme, inline CSS) and BC-logo-CMYK.pdf.
 *   gold        #F3BE6F  links, active nav, icons on dark
 *   gold mid    #D6B36F  button gradient, light end
 *   gold deep   #C79449  button gradient, dark end — the accessible gold on white
 *   gold shade  #BE8F48  hover borders
 *   ink         #151515 / #1C1C1C / #000  page and section grounds
 *   logo grey   #3F4142  the print logo's ink
 * Type: Roboto, the brand face (bundled woff2 — the UI must not phone home to Google). Two
 *   variable subsets, latin and latin-ext, weight 100–900; the mono face is Omnigent's own
 *   (Geist Mono) and is left alone.
 *
 * Semantic status colours (--success / --warning / --destructive / --status-*) are deliberately
 * left alone: they mean something, and a gold "warning" next to a gold brand reads as noise.
 */

/* ── Type ──────────────────────────────────────────────────────────────────────────────── */

@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 100%;
  font-display: swap;
  src: url("/assets/bcdm/Roboto-latin.woff2?v=6-9a0049ca") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 100 900;
  font-stretch: 100%;
  font-display: swap;
  src: url("/assets/bcdm/Roboto-latin-ext.woff2?v=6-9a0049ca") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}

:root,
:host {
  --font-sans: "Roboto", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji",
    "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --default-font-family: var(--font-sans);
}

/* ── Brand constants ──────────────────────────────────────────────────────────────────── */

:root {
  --bc-gold: #f3be6f;
  --bc-gold-mid: #d6b36f;
  --bc-gold-deep: #c79449;
  --bc-gold-shade: #be8f48;
  --bc-ink: #151515;
  --bc-ink-soft: #1c1c1c;
  --bc-logo-grey: #3f4142;
  /* The site's CTA gradient, 122deg #C79449 → #D6B36F. */
  --bc-gradient: linear-gradient(122deg, var(--bc-gold-deep) 7%, var(--bc-gold-mid) 100%);
  /* Shadows pick up the brand's warmth instead of Omnigent's cool neutral. */
  --ui-shadow-warm-rgb: 60 40 10;
}

/* ── Default light theme ──────────────────────────────────────────────────────────────────
 * Same selector Omnigent uses, so the five built-in themes (dracula, github, …) still win for
 * anyone who picks one — this only re-paints the default everybody lands on.
 */

:root:not(.dark):not([data-theme]) {
  --background: #fff;
  --foreground: var(--bc-ink);
  --card: #fff;
  --card-solid: #fff;
  --card-foreground: var(--bc-ink);
  --tray: #fff;
  --popover: #fff;
  --popover-foreground: var(--bc-ink);
  /* Ink, not gold: gold text on white fails contrast, and the site's own dark buttons agree. */
  --primary: var(--bc-ink);
  --primary-foreground: #fff;
  --secondary: #f4f2ee;
  --secondary-foreground: var(--bc-ink);
  --muted: #00000010;
  --muted-foreground: #70706c;
  --code-bg: #00000010;
  --accent: #fbf1e1;
  --accent-foreground: #7d5a20;
  --border: #e6e2da;
  --border-strong: #b3ada1;
  --button-border: #dbd6cc;
  --input: #e6e2da;
  --ring: var(--bc-gold-deep);
  --brand-accent: var(--bc-gold-deep);
  --sidebar: #faf8f4;
  --sidebar-foreground: var(--bc-ink);
  --sidebar-primary: var(--bc-gold-deep);
  --sidebar-primary-foreground: #fff;
  --sidebar-accent: #fbf1e1;
  --sidebar-accent-foreground: #7d5a20;
  --sidebar-border: #e6e2da;
  --sidebar-ring: var(--bc-gold-deep);
  --sidebar-active: #c794491f;
  --sidebar-active-foreground: #7d5a20;
}

/* ── Default dark theme (black + gold, the site's own register) ───────────────────────── */

.dark:not([data-theme]) {
  --background: #0f0f0f;
  --foreground: #f5f3f0;
  --card: #1c1c1cd9;
  --card-solid: #1a1a1a;
  --card-foreground: #f5f3f0;
  --tray: #1c1c1cd9;
  --popover: #151515f2;
  --popover-foreground: #f5f3f0;
  --primary: var(--bc-gold);
  --primary-foreground: var(--bc-ink);
  --secondary: #1f1f1f;
  --secondary-foreground: #f5f3f0;
  --muted: #2a2a2a;
  --muted-foreground: #a5a09a;
  --code-bg: #171717;
  --accent: #3a2b12;
  --accent-foreground: var(--bc-gold);
  --border: #282828;
  --border-strong: #4d4a45;
  --button-border: #3a3a3a;
  --input: #282828;
  --ring: var(--bc-gold);
  --brand-accent: var(--bc-gold);
  --sidebar: #0a0a0abf;
  --sidebar-foreground: #f5f3f0;
  --sidebar-primary: var(--bc-gold);
  --sidebar-primary-foreground: var(--bc-ink);
  --sidebar-accent: #3a2b12;
  --sidebar-accent-foreground: var(--bc-gold);
  --sidebar-border: #282828;
  --sidebar-ring: #f3be6f66;
  --sidebar-active: #f3be6f26;
  --sidebar-active-foreground: var(--bc-gold);
}

/* ── Omnigent's pink and blue outside the theme tokens ────────────────────────────────────
 * What the token blocks above cannot reach: colours the 0.12.0 bundle sets in :root / .dark for
 * every theme, or hardcodes in a class of its own. Found by sweeping its stylesheet for saturated
 * non-gold colours; what is left after this block is semantic (status, info, markdown alerts).
 * Fail-soft: a renamed class simply shows Omnigent's colour again.
 */

:root {
  /* The working dot in the session list and the "launching" label (stock #2f7fd4). */
  --session-active: var(--bc-gold-deep);
  /* Project icon tiles (stock #f001960f). */
  --tag-pink: #c7944914;
  /* Avatar initials cycle through chart-1…4 + brand-accent; 1 and 2 are Omnigent's blues. */
  --chart-1: var(--bc-gold-deep);
  --chart-2: var(--bc-logo-grey);
}

.dark {
  --session-active: var(--bc-gold);
  --tag-pink: #f3be6f26;
  --chart-1: var(--bc-gold);
}

/* The header Share button: a pink gradient of its own (stock #fa3d99 → #d51d74). The site's CTA
   gradient instead, with ink text — white on the light gold end fails contrast. */
.share-button-glassy,
.dark .share-button-glassy {
  color: var(--bc-ink);
  background: var(--bc-gradient);
}

.share-button-glassy:hover,
.dark .share-button-glassy:hover {
  background: var(--bc-gold-deep);
}

/* Skill icons in the composer's / menu, the only user of text-pink-500 in the bundle. */
.text-pink-500,
.dark\:text-pink-400:is(.dark *) {
  color: var(--brand-accent);
}

/* "Show more" under long comments and one Tasks-page template icon, its only users. */
.text-blue-600,
.dark\:text-blue-400:is(.dark *) {
  color: var(--accent-foreground);
}

/* ── Logo ─────────────────────────────────────────────────────────────────────────────────
 * Two places show a logo, and neither can be themed through branding config (which takes one
 * raster file per variant, see ../README.md §branding):
 *
 * 1. The sidebar head. With branding.app_name set, Omnigent renders the name as text there;
 *    this puts the horizontal lock-up in its place and keeps the text as the fallback — if a
 *    future build renames .sidebar-brand, the name simply shows as words again.
 * 2. The home-screen and working-indicator logos, served from /v1/branding/logo/*. They are
 *    the ink artwork (right for the light theme); on dark, invert() lifts the greys to white.
 *    Safe here because the artwork is greyscale — invert leaves no hue behind.
 */

.sidebar-brand > span {
  display: block;
  width: 108px;
  height: 23px;
  overflow: hidden;
  text-indent: -200vw;
  background: url("/assets/bcdm/bcdm-wordmark-ink.svg?v=6-9a0049ca") left center / contain no-repeat;
}

.dark .sidebar-brand > span {
  background-image: url("/assets/bcdm/bcdm-wordmark-light.svg?v=6-9a0049ca");
}

.dark img[src^="/v1/branding/logo/"],
.dark img[alt="BCDM Test"] {
  /* The alt text is branding.app_name — keep the two in step when the name changes. The
     src selector covers the same images while they are still plain URLs; Omnigent swaps
     some of them for blob: URLs, which is why both selectors are here. */
  filter: invert(1);
}

/* ── Copy ─────────────────────────────────────────────────────────────────────────────────
 * Two strings Omnigent hardcodes. Both selectors are unique in the 0.12.0 bundle, and both
 * fail soft: if a future build renames them, the stock heading size and attribution return.
 */

/* Home-screen heading ("What should we build?"), stock 1.5em / 2.15em above md. */
h1.text-\[1\.5em\],
h1.text-\[2\.15em\] {
  font-size: 20px;
}

/* "Powered by [mark] Omnigent" → "Powered by BCDM": keep the leading span, drop Omnigent's
   mark and name. powered_by in brand.toml decides whether the line shows at all. */
[data-testid="powered-by-omnigent"] > *:not(:first-child) {
  display: none;
}

[data-testid="powered-by-omnigent"]::after {
  content: "BCDM";
}

/* ── File rows: always show the download action ───────────────────────────────────────────
 * Omnigent renders a download button (and a copy-path button) on every file row of the Files
 * panel and the workspace-changes list, but hides them behind `opacity-0 group-hover:opacity-100`
 * and stacks them on top of the byte count with `absolute inset-0`. Nothing hints that the row
 * carries actions, so people read "no download icon" and ask for the file another way — and a
 * touch device never hovers at all.
 *
 * This lays the tray out inline next to the size (or the A/M/D status letter) instead of over
 * it, and stops the reveal-on-hover. Behaviour is untouched: same button, same handler.
 *
 * Keyed on the buttons' own `aria-label` / `data-testid`, which is the most stable handle the
 * bundle offers (class names are Tailwind, the chunk hash changes every release). Fail-soft: if
 * a future build renames them, the selectors stop matching and the stock hover reveal returns.
 * Drop this block once upstream shows the action by default.
 */

/* The w-14 box holding the size/status label and the action tray. */
span:has(> span > button[aria-label^="Download "]) {
  width: auto;
  gap: 0.375rem;
}

/* The tray itself, out of its `absolute inset-0` overlay and into the flow. */
span:has(> span > button[aria-label^="Download "]) > span:has(> button[aria-label^="Download "]) {
  position: static;
}

button[aria-label^="Download "],
button[data-testid="copy-path-button"] {
  opacity: 1;
}

/* The size / status label, which the stock rule blanks on hover to clear the way for the tray.
 * !important because `group-hover:invisible` outranks this selector on specificity. */
span:has(> span > button[aria-label^="Download "]) > span:first-child {
  visibility: visible !important;
}

/* ── Controls we do not offer ─────────────────────────────────────────────────────────────
 * The new-session git worktree/branch picker. Runners here work in their own HOME (/data),
 * not in a checkout anyone branches: the chip only ever offered to start the session in a
 * worktree, and its own copy says "leave blank to start directly in the working directory"
 * — which is exactly what an untouched picker already did. Hiding it therefore removes a
 * control, not a behaviour: every session starts in the working directory, as before.
 *
 * display:none also takes it out of the tab order and the accessibility tree, so it cannot
 * be reached by keyboard either. The in-session branch read-out (composer-git-branch) is
 * left alone: it reports state, it does not choose it.
 */

[data-testid="new-chat-landing-branch-chip"] {
  display: none;
}

/* "Connect your tools" pill (bcdm-connect-link.js, README §3i). Own class name, attached to <body>,
   so no upstream rename can strip it; discreet enough to ignore, visible enough to find once. */
#bcdm-connect-pill {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 2147483000;
  display: inline-block;
  padding: 7px 14px;
  border: 1px solid #c79449;
  border-radius: 999px;
  background: #fbf1e1;
  color: #7d5a20;
  font: 500 13px/1.2 "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}
#bcdm-connect-pill:hover { background: #c79449; color: #fff; }
html[data-theme="dark"] #bcdm-connect-pill,
.dark #bcdm-connect-pill { background: #3a2b12; color: #f3be6f; border-color: #7d5a20; }

/* Omnigent's own "Automations" sidebar row (BUG-23): a page nobody here uses. Our Jobs page
   (/connect/jobs, README §3o) is a separate row and stays. Keyed on the row's test id, the same
   stable handle bcdm-connect-link.js uses; display:none also removes it from the tab order.
   Fails soft: if a release renames the id, the row simply comes back. */
[data-testid="sidebar-primary-nav"] [data-testid="scheduled-tasks-nav"] {
  display: none;
}
