/**
 * ReplyBridge Knowledge Base - Foundation tokens and structural resets.
 * Defines the design tokens (colors, typography, radius) that components consume.
 */

.rb-knowledge-base-shell {
	--rb-kb-shell-gutter-desktop: 24px;
	--rb-kb-shell-gutter-tablet: 16px;
	--rb-kb-shell-gutter-mobile: 10px;
	--rb-kb-shell-gutter: var(--rb-kb-shell-gutter-desktop, 24px);
	background: var(--rb-kb-bg, transparent);
	padding: 0 0 64px;
	width: 100%;
}

@media (max-width: 1024px) {
	:where(.rb-knowledge-base-shell, .rb-kb-token-proxy) {
		--rb-kb-shell-gutter: var(--rb-kb-shell-gutter-tablet, 16px);
	}
}

@media (max-width: 640px) {
    :where(.rb-knowledge-base-shell, .rb-kb-token-proxy) {
        --rb-kb-shell-gutter: var(--rb-kb-shell-gutter-mobile, 10px);
    }
}

:where(.rb-knowledge-base, .rb-kb-token-proxy) {
	--rb-kb-shell-gutter-desktop: 24px;
	--rb-kb-shell-gutter-tablet: 16px;
	--rb-kb-shell-gutter-mobile: 10px;
	--rb-kb-shell-gutter: var(--rb-kb-shell-gutter-desktop, 24px);
	--rb-kb-primary: #2563eb;
	/* Fallback for older browsers; modern browsers override below using
	 * relative-color syntax so the on-primary always stays readable when
	 * the operator swaps --rb-kb-primary to a light color. */
	--rb-kb-on-primary: #ffffff;
	--rb-kb-accent: #7c3aed;
	--rb-kb-bg: transparent;
    --rb-kb-surface: #ffffff;
    --rb-kb-surface-alt: #eef2ff;
    --rb-kb-text: #0f172a;
    --rb-kb-grey: #475569;
    --rb-kb-border: #e2e8f0;
    --rb-kb-radius-rounded: 10px;
    --rb-kb-radius-soft: 6px;
    --rb-kb-radius-sharp: 0px;
    --rb-kb-radius: var(--rb-kb-radius-rounded);
    --rb-kb-hero-bg: var(--rb-kb-primary);
    --rb-kb-hero-text: #ffffff;
    --rb-kb-placeholder: rgba(255,255,255,0.75);
    --rb-kb-focus-ring-color: color-mix(in srgb, var(--rb-kb-primary) 35%, transparent);
    --rb-kb-focus-ring-soft: color-mix(in srgb, var(--rb-kb-primary) 15%, transparent);
    /* Muted = a soft tint of the primary, derived so it tracks the operator's
     * brand color automatically. Use for low-emphasis surfaces, hover halos,
     * and outline-style primary button fills. Distinct from --rb-kb-grey,
     * which is the literal neutral-grey body/secondary text color. */
    --rb-kb-muted: color-mix(in srgb, var(--rb-kb-primary) 14%, var(--rb-kb-surface) 86%);
    --rb-kb-muted-strong: color-mix(in srgb, var(--rb-kb-primary) 22%, var(--rb-kb-surface) 78%);
    --rb-kb-surface-hover: color-mix(in srgb, var(--rb-kb-surface) 94%, var(--rb-kb-primary) 6%);
    --rb-kb-surface-active: color-mix(in srgb, var(--rb-kb-surface) 88%, var(--rb-kb-primary) 12%);
    --rb-kb-interactive-text: var(--rb-kb-primary);
    --rb-kb-interactive-border: color-mix(in srgb, var(--rb-kb-border) 80%, var(--rb-kb-primary) 20%);
    --rb-kb-interactive-row-hover-bg: color-mix(in srgb, var(--rb-kb-surface) 96%, var(--rb-kb-primary) 4%);
    --rb-kb-interactive-row-open-bg: color-mix(in srgb, var(--rb-kb-surface) 90%, var(--rb-kb-primary) 10%);
    --rb-kb-interactive-button-hover-bg: color-mix(in srgb, var(--rb-kb-primary) 85%, var(--rb-kb-surface) 15%);
    --rb-kb-search-submit-hover-bg: color-mix(in srgb, var(--rb-kb-interactive-text) 8%, transparent);
    --rb-kb-search-submit-active-bg: color-mix(in srgb, var(--rb-kb-interactive-text) 12%, transparent);
    --rb-kb-search-submit-solid-hover-bg: color-mix(in srgb, var(--rb-kb-interactive-text) 90%, var(--rb-kb-surface) 10%);
    --rb-kb-search-submit-solid-active-bg: color-mix(in srgb, var(--rb-kb-interactive-text) 80%, var(--rb-kb-surface) 20%);
    --rb-kb-card-hover-translate: -4px;
    --rb-kb-card-hover-shadow: 0 20px 40px rgba(15, 23, 42, 0.14);
    --rb-kb-font-family: var(--replybridge-font, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
    --rb-kb-font-size-base: 1rem;
    --rb-kb-font-size-body: 1rem;
    --rb-kb-font-size-h1: clamp(1.8rem, 2.8vw, 2.6rem);
    --rb-kb-font-size-h2: clamp(1.35rem, 2.2vw, 1.8rem);
    --rb-kb-font-size-h3: 1.15rem;
    --rb-kb-font-size-h4: 1rem;
}

/* Auto-contrast on-primary using OKLCH relative color syntax. When the
 * operator picks a light primary in the form builder, white text would
 * vanish on the submit button; this swaps to black on light primaries
 * and white on dark ones. Falls back to the static #ffffff above in
 * browsers that don't yet support relative-color syntax. */
@supports (color: oklch(from white l c h)) {
    :where(.rb-knowledge-base, .rb-kb-token-proxy) {
        --rb-kb-on-primary: oklch(from var(--rb-kb-primary) clamp(0, (0.65 - l) * 1000, 1) 0 0);
    }
}

.rb-knowledge-base {
	max-width: 1200px;
	margin: 0 auto;
	width: 100%;
	padding: 0 var(--rb-kb-shell-gutter, 24px);
	background: var(--rb-kb-bg);
	font-family: var(--rb-kb-font-family);
	color: var(--rb-kb-text);
	display: flex;
	flex-direction: column;
    gap: 36px;
    line-height: 1.6;
	font-size: var(--rb-kb-font-size-base);
	box-sizing: border-box;
}

.rb-kb-token-proxy {
	display: contents;
}

.rb-knowledge-base[data-rb-kb-interactions="minimal"] {
    --rb-kb-card-hover-translate: 0px;
    --rb-kb-card-hover-shadow: 0 12px 35px rgba(15, 23, 42, 0.08);
    --rb-kb-interactive-row-hover-bg: color-mix(in srgb, var(--rb-kb-surface) 98%, var(--rb-kb-primary) 2%);
    --rb-kb-interactive-row-open-bg: color-mix(in srgb, var(--rb-kb-surface) 94%, var(--rb-kb-primary) 6%);
    --rb-kb-search-submit-hover-bg: color-mix(in srgb, var(--rb-kb-interactive-text) 4%, transparent);
    --rb-kb-search-submit-active-bg: color-mix(in srgb, var(--rb-kb-interactive-text) 8%, transparent);
    --rb-kb-search-submit-solid-hover-bg: color-mix(in srgb, var(--rb-kb-interactive-text) 80%, var(--rb-kb-surface) 20%);
    --rb-kb-search-submit-solid-active-bg: color-mix(in srgb, var(--rb-kb-interactive-text) 70%, var(--rb-kb-surface) 30%);
}

.rb-kb-font-system {
    --rb-kb-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.rb-kb-font-theme {
    --rb-kb-font-family: var(--replybridge-font, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
}

.rb-kb-font-serif {
    --rb-kb-font-family: 'Georgia', 'Times New Roman', serif;
}

.rb-kb-font-mono {
    --rb-kb-font-family: 'SFMono-Regular', 'Courier New', monospace;
}

.rb-kb-type-standard {
    --rb-kb-font-size-base: 1rem;
    --rb-kb-font-size-body: 1rem;
    --rb-kb-font-size-h1: clamp(1.8rem, 2.8vw, 2.6rem);
    --rb-kb-font-size-h2: clamp(1.35rem, 2.2vw, 1.8rem);
    --rb-kb-font-size-h3: 1.15rem;
    --rb-kb-font-size-h4: 1rem;
}

.rb-kb-type-compact {
    --rb-kb-font-size-base: 0.94rem;
    --rb-kb-font-size-body: 0.94rem;
    --rb-kb-font-size-h1: clamp(1.65rem, 2.3vw, 2.2rem);
    --rb-kb-font-size-h2: clamp(1.2rem, 1.8vw, 1.5rem);
    --rb-kb-font-size-h3: 1.05rem;
    --rb-kb-font-size-h4: 0.95rem;
}

.rb-kb-type-prominent {
    --rb-kb-font-size-base: 1.08rem;
    --rb-kb-font-size-body: 1.08rem;
    --rb-kb-font-size-h1: clamp(2.1rem, 3.2vw, 3rem);
    --rb-kb-font-size-h2: clamp(1.5rem, 2.4vw, 2.1rem);
    --rb-kb-font-size-h3: 1.3rem;
    --rb-kb-font-size-h4: 1.1rem;
}

.rb-kb-shape-rounded {
    --rb-kb-radius: var(--rb-kb-radius-rounded);
}

.rb-kb-shape-soft {
    --rb-kb-radius: var(--rb-kb-radius-soft);
}

.rb-kb-shape-sharp {
    --rb-kb-radius: var(--rb-kb-radius-sharp);
}

.rb-knowledge-base h1,
.rb-knowledge-base h2,
.rb-knowledge-base h3,
.rb-knowledge-base h4 {
    font-family: var(--rb-kb-font-family);
    color: var(--rb-kb-text);
    line-height: 1.25;
    font-weight: 600;
    margin: 0 0 0.65em;
}

.rb-knowledge-base h1 {
    font-size: var(--rb-kb-font-size-h1);
}

.rb-knowledge-base h2 {
    font-size: var(--rb-kb-font-size-h2);
}

.rb-knowledge-base h3 {
    font-size: var(--rb-kb-font-size-h3);
}

.rb-knowledge-base h4 {
    font-size: var(--rb-kb-font-size-h4);
}

.rb-knowledge-base input,
.rb-knowledge-base button,
.rb-knowledge-base textarea {
    font-family: var(--rb-kb-font-family);
}

.rb-kb-palette-emerald {
    --rb-kb-primary: #059669;
    --rb-kb-accent: #10b981;
    --rb-kb-surface-alt: #d1fae5;
    --rb-kb-grey: #065f46;
    --rb-kb-border: #bbf7d0;
}

.rb-kb-palette-sunset {
    --rb-kb-primary: #fb7185;
    --rb-kb-accent: #f97316;
    --rb-kb-surface-alt: #ffe4e6;
    --rb-kb-grey: #7c2d12;
    --rb-kb-border: #fed7aa;
}

.rb-kb-palette-steel {
	--rb-kb-primary: #3b82f6;
	--rb-kb-accent: #60a5fa;
	--rb-kb-bg: #0f172a;
	--rb-kb-surface: #1f2937;
	--rb-kb-surface-alt: #111827;
	--rb-kb-text: #f8fafc;
	--rb-kb-grey: #cbd5f5;
	--rb-kb-border: rgba(255,255,255,0.15);
	--rb-kb-hero-bg: #1f2b3f;
	--rb-kb-hero-text: #e2e8f0;
	--rb-kb-placeholder: rgba(226,232,240,0.8);
}

.rb-kb-shell--palette-steel {
	background-color: #0f172a;
}

.rb-kb-active .has-global-padding {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

.rb-kb-active .wp-block-group {
    margin-block-start: 0 !important;
    margin-block-end: 0 !important;
}

.rb-kb-active .is-layout-constrained .rb-knowledge-base-shell,
.rb-kb-active .is-layout-constrained > .rb-knowledge-base-shell {
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100%;
}

#rb-kb-minimal-header,
#rb-kb-minimal-footer {
    background: #fff;
    padding: 18px 20px;
    border-bottom: 1px solid var(--rb-kb-border);
}

#rb-kb-minimal-headerimg {
    max-width: 1100px;
    margin: 0 auto;
}

.rb-kb-minimal-brand {
    display: inline-block;
    font-size: 22px;
    font-weight: 600;
    text-decoration: none;
    color: var(--rb-kb-text);
}

.rb-kb-minimal-description {
    font-size: 13px;
    color: var(--rb-kb-grey);
    margin-top: 4px;
}

#rb-kb-minimal-footer {
    border-top: 1px solid var(--rb-kb-border);
    border-bottom: 0;
    margin-top: 40px;
    text-align: center;
}

:where(.entry-content, .wp-block-post-content) > .rb-knowledge-base-shell {
    margin-top: 0;
    margin-bottom: 0;
}

:where(.entry-content, .wp-block-post-content) > .rb-kb-shell--hero-flush {
    margin-top: calc(var(--wp--style--root--padding-top, 0px) * -1);
    padding-top: 0;
}
