/* ============================================================
 * Pollard Catalyst · Design System
 * One product, one identity.
 * Loaded LAST — overrides all page-specific styles.
 * ============================================================ */

:root,
html,
body {
  /* ── Color tokens ── */
  --pds-bg:            #0a0a0c;
  --pds-bg-2:          #101013;
  --pds-bg-3:          #16161b;
  --pds-bg-elevated:   #1a1a20;
  --pds-line:          rgba(255,255,255,0.07);
  --pds-line-2:        rgba(255,255,255,0.12);
  --pds-line-strong:   rgba(255,255,255,0.22);

  --pds-ink:           #e9e9ea;
  --pds-ink-2:         rgba(255,255,255,0.62);
  --pds-dim:           rgba(255,255,255,0.42);
  --pds-faint:         rgba(255,255,255,0.22);

  --pds-gold:          #c9a662;
  --pds-gold-bright:   #e3bf78;
  --pds-gold-dim:      #8a7847;
  --pds-gold-tint:     rgba(201,166,98,0.10);
  --pds-gold-tint-2:   rgba(201,166,98,0.18);
  --pds-gold-border:   rgba(201,166,98,0.32);

  --pds-pollard-navy:  #1a2540;
  --pds-pollard-navy-2:#283758;
  --pds-pollard-navy-3:#3c4a73;

  --pds-live:          #86efac;
  --pds-live-tint:     rgba(134,239,172,0.10);
  --pds-warn:          #ffb88a;
  --pds-warn-tint:     rgba(255,184,138,0.10);
  --pds-err:           #f87171;

  /* ── Typography ── */
  --pds-display:       'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --pds-body:          'Inter', system-ui, -apple-system, sans-serif;
  --pds-mono:          'IBM Plex Mono', 'SF Mono', Menlo, monospace;

  /* ── Radii / spacing ── */
  --pds-r-sm:          6px;
  --pds-r-md:          10px;
  --pds-r-lg:          14px;
  --pds-r-xl:          18px;
  --pds-r-pill:        99px;

  /* ── Legacy var remap (forces existing pages onto Pollard palette) ── */
  --bg: var(--pds-bg);
  --bg-2: var(--pds-bg-2);
  --bg-3: var(--pds-bg-3);
  --ink: var(--pds-ink);
  --ink-2: var(--pds-ink-2);
  --dim: var(--pds-dim);
  --line: var(--pds-line);
  --line-2: var(--pds-line-2);
  --gold: var(--pds-gold);
  --accent: var(--pds-gold);
  --display: var(--pds-display);
  --body: var(--pds-body);
  --mono: var(--pds-mono);
  /* Kobow Enterprise leftovers: */
  --kb-bg: var(--pds-bg);
  --kb-bg-2: var(--pds-bg-2);
  --kb-bg-3: var(--pds-bg-3);
  --kb-ink: var(--pds-ink);
  --kb-accent: var(--pds-gold);
  --kb-line: var(--pds-line);
  --kb-mono: var(--pds-mono);
  --kb-display: var(--pds-display);
  /* Odd leftovers: */
  --odd-bg: var(--pds-bg);
  --odd-ink: var(--pds-ink);
  --odd-accent: var(--pds-gold);
  /* Pollard system-wide: */
  --kbw-paper: var(--pds-bg);
  --kbw-ink: var(--pds-ink);
  --kbw-accent: var(--pds-gold);
  --kbw-line: var(--pds-line);
  --kbw-card: var(--pds-bg-2);
  --kbw-muted: var(--pds-dim);
  --kbw-muted-2: var(--pds-ink-2);
  --kbw-mono: var(--pds-mono);
  --kbw-display: var(--pds-display);
  --kbw-body: var(--pds-body);
  --kbw-radius: var(--pds-r-md);
  --kbw-soft: var(--pds-gold-tint);
  --kbw-success: var(--pds-live);
  --pbc-navy: var(--pds-pollard-navy);
}

/* When Pollard mode is on, override masters
   When black-mode is on, stay dark (it already is) */
html.preload-pollard,
html.preload-pollard body,
html.pollard-mode,
html.pollard-mode body,
body.pollard-mode {
  background: var(--pds-bg) !important;
  color: var(--pds-ink) !important;
}

/* ============================================================
 * Base resets
 * ============================================================ */
html, body {
  background: var(--pds-bg);
  color: var(--pds-ink);
  font-family: var(--pds-body);
  -webkit-font-smoothing: antialiased;
}

body { font-size: 14px; line-height: 1.55; }

/* Headings use display font */
h1, h2, h3, h4, .pds-display {
  font-family: var(--pds-display);
  font-style: italic;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--pds-ink);
}
h1 { color: var(--pds-ink); }
h2 { color: var(--pds-gold); }
h3 { color: var(--pds-gold); }
h4 { color: var(--pds-ink-2); }

/* Common eyebrow / kicker */
.eyebrow, .kicker, .badge, [class*="-eyebrow"], [class*="-kicker"],
.section-eyebrow, .sec-eyebrow {
  font-family: var(--pds-mono);
  font-size: 10px !important;
  letter-spacing: 0.24em !important;
  text-transform: uppercase !important;
  color: var(--pds-gold) !important;
}

/* ============================================================
 * Backgrounds — force dark Pollard on common containers
 * ============================================================ */
[class*="-wrap"][style*="background:#fff"],
[class*="-wrap"][style*="background:#ffffff"],
[style*="background:#fff;"],
[style*="background:#ffffff;"],
[style*="background-color:#fff;"],
.wrap, main, .container, .page, .panel,
.stage, .surface, .canvas {
  background: var(--pds-bg);
  color: var(--pds-ink);
}

/* Cards & panels (cover most patterns) */
.card, .cell, .panel, .item, .tile, .deliverable,
.cell.live, .cell.playbook-only,
.kpi, .ws-card, .stat, .stat-box,
[class$="-card"], [class$="-panel"], [class$="-tile"],
[class*="card-"][class*="-item"] {
  background: var(--pds-bg-2) !important;
  border: 1px solid var(--pds-line) !important;
  color: var(--pds-ink);
  border-radius: var(--pds-r-md);
}

/* Buttons */
button, .btn,
a.btn, a.button, button.button {
  font-family: var(--pds-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  border-radius: var(--pds-r-sm);
  cursor: pointer;
}
.btn-primary, .button-primary, button.primary, a.primary {
  background: var(--pds-gold) !important;
  color: #0a0a0c !important;
  border: 1px solid var(--pds-gold) !important;
}
.btn-primary:hover, .button-primary:hover, button.primary:hover {
  background: var(--pds-gold-bright) !important;
  border-color: var(--pds-gold-bright) !important;
}
.btn-ghost, .button-ghost, .button-secondary, button.secondary {
  background: transparent !important;
  color: var(--pds-ink) !important;
  border: 1px solid var(--pds-line-2) !important;
}
.btn-ghost:hover {
  border-color: var(--pds-gold) !important;
  color: var(--pds-gold) !important;
}

/* Pills / badges / tags */
.pill, .tag, .chip, .badge:not([class*="brand"]),
.rs-pill, [class$="-pill"], [class$="-chip"], [class$="-tag"] {
  font-family: var(--pds-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  background: var(--pds-bg-3);
  border: 1px solid var(--pds-line-2);
  color: var(--pds-ink-2);
  border-radius: var(--pds-r-pill);
}
.pill.live, .tag.live, .chip.live,
.rs-pill.live {
  color: var(--pds-live) !important;
  border-color: rgba(134,239,172,0.32) !important;
  background: var(--pds-live-tint) !important;
}
.pill.active, .pill.gold, .chip.active,
.rs-pill.active {
  color: var(--pds-gold) !important;
  border-color: var(--pds-gold-border) !important;
  background: var(--pds-gold-tint) !important;
}

/* Links */
a {
  color: var(--pds-gold);
  text-decoration: none;
}
a:hover {
  color: var(--pds-gold-bright);
}

/* ============================================================
 * Override "Kobow Enterprise" orange (#f97316) → gold
 * ============================================================ */
[style*="#f97316"],
[style*="rgb(249,115,22)"],
[style*="rgb(249, 115, 22)"] {
  color: var(--pds-gold) !important;
}
[style*="background:#f97316"],
[style*="background-color:#f97316"] {
  background: var(--pds-gold) !important;
  color: #0a0a0c !important;
}
.h1 .accent, .accent, .a, h1 .a, h1 .accent {
  color: var(--pds-gold) !important;
}

/* Override harsh white-bg sections that leaked */
[style*="background:#ffffff"][style*="color:#"],
[style*="background:#fafafa"],
[style*="background:#f4f4f5"],
[style*="background:white"] {
  background: var(--pds-bg-2) !important;
  color: var(--pds-ink) !important;
}

/* ============================================================
 * Form inputs unified
 * ============================================================ */
input[type="text"], input[type="search"], input[type="email"], input[type="url"],
textarea, select {
  background: var(--pds-bg) !important;
  border: 1px solid var(--pds-line-2) !important;
  color: var(--pds-ink) !important;
  border-radius: var(--pds-r-sm);
  font-family: var(--pds-body);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--pds-gold) !important;
  outline: none;
}

/* ============================================================
 * Scrollbars (subtle)
 * ============================================================ */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--pds-line-strong); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: var(--pds-ink-2); }
*::-webkit-scrollbar-track { background: var(--pds-bg); }

/* ============================================================
 * Tables
 * ============================================================ */
table { border-collapse: collapse; color: var(--pds-ink); }
th, td { border-bottom: 1px solid var(--pds-line); padding: 9px 12px; }
th {
  font-family: var(--pds-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--pds-dim);
}

/* ============================================================
 * Selection
 * ============================================================ */
::selection { background: var(--pds-gold-tint-2); color: var(--pds-gold-bright); }

/* ============================================================
 * Cleanup: hide any leftover Kobow Enterprise topbar / nav inside iframe
 * (already done in pollard-theme.js but belt-and-suspenders)
 * ============================================================ */
.kobow-enterprise-topbar, .ke-topbar, .ke-nav {
  display: none !important;
}

/* ============================================================
 * iframe-fit
 * ============================================================ */
html.preload-pollard { background: var(--pds-bg) !important; }

/* ============================================================
 * FORCE Pollard dark theme — ignore OS dark/light mode
 * Ignore user-agent dark preference. Ignore localStorage toggle.
 * The demo decides the look, not the OS.
 * ============================================================ */
:root, html, body {
  color-scheme: dark !important;
}
html.preload-pollard, html.pollard-mode, html.black-mode,
body.pollard-mode, body.black-mode {
  background: var(--pds-bg) !important;
  color: var(--pds-ink) !important;
}
@media (prefers-color-scheme: light), (prefers-color-scheme: no-preference) {
  html, body,
  html.preload-pollard, html.pollard-mode, body.pollard-mode {
    background: var(--pds-bg) !important;
    color: var(--pds-ink) !important;
  }
  h1 { color: var(--pds-ink) !important; }
  h2, h3 { color: var(--pds-gold) !important; }
  .card, .cell, .panel { background: var(--pds-bg-2) !important; }
}

/* Kill the Pollard/Black toggle entirely — single look, no user choice */
.pbc-theme-toggle, #pbc-theme-toggle-std, .pbc-theme-toggle-std {
  display: none !important;
}

/* Forbid any inline body bg from overriding */
body[style*='background:#fff'],
body[style*='background:#ffffff'],
body[style*='background:white'],
body[style*='background: #fff'],
body[style*='background-color:#fff'] {
  background: var(--pds-bg) !important;
}

/* Inputs/textarea bg in light contexts */
input, textarea, select {
  background-color: var(--pds-bg-2) !important;
  color: var(--pds-ink) !important;
}

/* ============================================================
 * STRONG OVERRIDES · catch white-bg leaks specifically
 * ============================================================ */
.odd-hero, .odd-card, .odd-accountiner, .odd-container,
section.odd-hero, .hero, section.hero,
[class*="hero"][class*="odd"],
.gallery, .pollard-mode .odd-hero, .pollard-mode .odd-card,
section[style*="background"] {
  background: var(--pds-bg-2) !important;
  color: var(--pds-ink) !important;
  border-color: var(--pds-line) !important;
}
.odd-hero { background: var(--pds-bg) !important; }
.odd-hero h1 { color: var(--pds-ink) !important; }
.odd-hero .lede, .odd-hero p { color: var(--pds-ink-2) !important; }
.odd-hero .badge {
  background: var(--pds-gold-tint) !important;
  color: var(--pds-gold) !important;
  border: 1px solid var(--pds-gold-border) !important;
}

/* E-tab gallery cards (white outer + inner) */
.gallery, .gallery-card, .gallery-item,
.theme-row, .theme-block, .theme-card,
[id*="gallery"], [class*="gallery"],
.grid > div, .matrix > .cell {
  background: var(--pds-bg-2) !important;
  border-color: var(--pds-line) !important;
}

/* Paper hub specific (had jurisdictional matrix) */
.matrix .cell {
  background: var(--pds-bg-2) !important;
  border: 1px solid var(--pds-line) !important;
  color: var(--pds-ink) !important;
}
.matrix .cell.soon {
  background: var(--pds-bg-3) !important;
  color: var(--pds-ink-2) !important;
  opacity: 0.6;
}
.matrix .cell h3 {
  color: var(--pds-gold) !important;
}
.matrix .cell p {
  color: var(--pds-ink-2) !important;
}

/* Force ALL section-h to gold-italic */
.section-h, h2.section-h {
  color: var(--pds-gold) !important;
  font-family: var(--pds-display) !important;
  font-style: italic !important;
}

/* Catch ANY .stage, .surface, page wrap */
.stage, .surface, .page, main.odd-accountiner, .odd-accountiner,
.wrap.stage {
  background: var(--pds-bg) !important;
  color: var(--pds-ink) !important;
}

/* Subnav (.psn) — hide because we have workspace subnav in shell.
   But for direct (non-shell) views, style it Pollard. */
nav.psn:not(:has(html.shell-active *)) {
  background: var(--pds-bg-2) !important;
  border-color: var(--pds-line) !important;
}
nav.psn a { color: var(--pds-ink-2) !important; }
nav.psn a.active, nav.psn a.psn-prod { color: var(--pds-gold) !important; }

/* Any inline white bg div */
div[style*="background:#fff"],
div[style*="background: #fff"],
div[style*="background-color:#fff"],
div[style*="background-color: #fff"],
div[style*="background:white"] {
  background: var(--pds-bg-2) !important;
  color: var(--pds-ink) !important;
}

/* The 'preload-pollard' light mode the original Pollard theme used — kill */
html.preload-pollard,
html.preload-pollard body,
.preload-pollard .odd-hero,
.preload-pollard .odd-card {
  background: var(--pds-bg) !important;
  color: var(--pds-ink) !important;
}

/* ============================================================
 * POLLARD-DELIVERY-CANARY: v4 — 2026-06-03 (both trees hardened · server-strip · headers · shield)
 * Source: ENFORCEMENT_CARD.md — Game Asset Delivery Rules v1.0
 * AIDA Tier 2 — Primarily Human
 * Principle: Deliver outputs. Hide engine. No prompts, no params,
 * no iteration history, no tool names visible to client.
 * ============================================================ */

/* ── HIDE: Prompt UI elements ── */
[class*="prompt"]:not([class*="prompts-no-prompt"]),
[id*="prompt"],
.master-prompt, .system-prompt, .raw-prompt,
.prompt-textarea, .prompt-history, .prompt-display,
.prompt-panel, .prompt-view, .prompt-text,
.prompt-builder, .prompt-token, .prompt-queue,
textarea[placeholder*="prompt" i],
textarea[placeholder*="describe" i],
pre.prompt, code.prompt,
[data-prompt], [data-raw-prompt], [data-system-prompt] {
  display: none !important;
}

/* ── HIDE: Iteration history / version tree ── */
.iteration-history, .version-tree, .gen-history,
.regen-queue, .iteration-card, .version-card,
[class*="-v15"], [class*="-v43"], [class*="-v3"][class*="master"],
[class*="refgen"], [class*="themed_reskin"],
[class*="iteration"]:not(.iteration-locked),
.draft-list, .draft-history, .draft-queue,
.history-card, .history-row, .history-list {
  display: none !important;
}

/* ── HIDE: Tool / model parameter UI ── */
.model-param, .gen-param, .model-select, .provider-select,
.param-row, .param-group, .param-builder,
.dropdown-mood, .dropdown-palette, .dropdown-weather,
.dropdown-style, .dropdown-element,
select[name*="model" i], select[name*="provider" i],
select[name*="quality" i], select[name*="cfg" i],
input[name*="seed" i], input[name*="cfg" i],
input[name*="guidance" i],
.cost-display, .cost-counter, .credits-counter,
[class*="mood-lighting"], [class*="palette-season"],
[class*="weather-sky"], [class*="style-texture"],
[class*="element-tweak"] {
  display: none !important;
}

/* ── HIDE: Tool name leaks if any slip through ── */
.tool-name, .vendor-name, .model-name, .provider-name,
[data-tool], [data-vendor], [data-model] {
  display: none !important;
}

/* ── HIDE: Debug / internal markers ── */
[data-debug], [data-internal], [data-engineer],
.debug-panel, .debug-row, .internal-only, .engineer-view,
[class*="-bak"], .backup-notice {
  display: none !important;
}

/* ── HIDE: Quick-Pick / preset chip rows that reveal prompt scaffolding ── */
.quick-pick-bucket, .preset-chip-row[data-prompt-fragment],
.bucket-row, .bucket-token,
.token-builder, .token-row, .token-chip {
  display: none !important;
}

/* ── HIDE: Animation engine vendor leaks (Runway/Seedance/Kling etc.) ── */
.vendor-runway, .vendor-seedance, .vendor-kling,
.vendor-elevenlabs, .vendor-anijam, .vendor-veo,
.engine-runway, .engine-seedance, .engine-kling {
  display: none !important;
}

/* ── HIDE: Cost / billing / API-key UI ── */
.api-key-row, .api-key-card, .key-input, .secret-input,
.billing-counter, .billing-panel, .api-usage,
.credit-balance, .credit-spent, .quota-row {
  display: none !important;
}

/* ── HIDE: Generic 'show prompt', 'show params', 'show history' toggles ── */
button[aria-label*="prompt" i],
button[title*="prompt" i],
button[title*="raw" i],
button[title*="history" i],
button[title*="params" i],
.toggle-prompt, .toggle-raw, .toggle-history, .toggle-params {
  display: none !important;
}

/* ── HIDE: Provider/model badges (gpt-image-2, Imagen, Midjourney etc.) ── */
.badge-gpt, .badge-imagen, .badge-midjourney, .badge-firefly,
.badge-runway, .badge-seedance, .badge-elevenlabs,
[class*="badge"][class*="-image-"],
[class*="badge"][class*="-gen-"] {
  display: none !important;
}


/* ============================================================
 * POLLARD-DELIVERY-CANARY: v5 — 2026-06-04 (NUCLEAR contrast)
 * Force-readable rules · no white-on-white EVER
 * ============================================================ */

/* Any element styled with white-ish background → force dark + light text */
[style*='background:#fff'],
[style*='background: #fff'],
[style*='background-color:#fff'],
[style*='background-color: #fff'],
[style*='background:white'],
[style*='background: white'],
[style*='background-color:white'],
[style*='background-color: white'],
[style*='background:#FFF'],
[style*='background:#ffffff'],
[style*='background: #ffffff'],
[style*='background-color:#ffffff'],
[style*='background-color: #ffffff'],
[style*='background:#fafafa'],
[style*='background:#fcfcfc'],
[style*='background:#f9f9f9'],
[style*='background:#f5f5f5'],
[style*='background:#f4f4f5'],
[style*='background:#e8e8e8'],
[style*='background:#eee'],
[style*='background:#f0f0f0'],
[bgcolor='#fff'],
[bgcolor='#ffffff'],
[bgcolor='white'] {
  background: var(--pds-bg-2) !important;
  color: var(--pds-ink) !important;
}

/* Light text on light bg fix · any [style*='color:#fff'] inside light containers */
[style*='color:#fff'][style*='background:#fff'],
[style*='color:white'][style*='background:white'],
[style*='color:#fff'][style*='background:white'],
[style*='color:white'][style*='background:#fff'] {
  background: var(--pds-bg-2) !important;
  color: var(--pds-ink) !important;
}

/* Common card/callout classes that have been white before */
.callout, .note, .info-box, .alert, .banner-info, .source-card, .meta-card,
.source-box, .citation, .quote-box, .official-source, .data-card,
[class*='callout'], [class*='source-box'], [class*='citation'], [class*='data-box'] {
  background: var(--pds-bg-2) !important;
  color: var(--pds-ink) !important;
  border: 1px solid var(--pds-line) !important;
}

/* Force black text → readable */
[style*='color:#000'],
[style*='color: #000'],
[style*='color:black'],
[style*='color: black'],
[style*='color:#0a0a0a'],
[style*='color:#111'],
[style*='color:#222'],
[style*='color:#333'] {
  color: var(--pds-ink) !important;
}
/* But only if on dark bg — if explicitly on a light bg, lift to gold */
[style*='color:#000'][style*='background:#fff'],
[style*='color:black'][style*='background:white'] {
  color: var(--pds-gold) !important;
}

/* Universal: ANY p, span, div, td that's still failing contrast → force fallback */
.pollard-fix-contrast,
[data-fix-contrast] {
  color: var(--pds-ink) !important;
  background: var(--pds-bg-2) !important;
}
