/*
 * TSP Section Context v1.5.1
 * Local palettes map directly to canonical density tokens from 02-tokens.css.
 * Density consumes only semantic roles.
 */

/* ==========================================================================
   LOCAL PALETTE TRANSLATOR
   ========================================================================== */

.pal-home {
	--anchor-deep: var(--home-d8);
	--anchor-core: var(--home-d7);
	--anchor-threshold: var(--home-d6);
	--surface-rich: var(--home-d5);
	--surface-main: var(--home-d4);
	--surface-bridge: var(--home-d3);
	--surface-soft: var(--home-d2);
	--surface-air: var(--home-d1);
}

.pal-physics {
	--anchor-deep: var(--physics-d8);
	--anchor-core: var(--physics-d7);
	--anchor-threshold: var(--physics-d6);
	--surface-rich: var(--physics-d5);
	--surface-main: var(--physics-d4);
	--surface-bridge: var(--physics-d3);
	--surface-soft: var(--physics-d2);
	--surface-air: var(--physics-d1);
}

.pal-soul {
	--anchor-deep: var(--soul-d8);
	--anchor-core: var(--soul-d7);
	--anchor-threshold: var(--soul-d6);
	--surface-rich: var(--soul-d5);
	--surface-main: var(--soul-d4);
	--surface-bridge: var(--soul-d3);
	--surface-soft: var(--soul-d2);
	--surface-air: var(--soul-d1);
}

.pal-enav {
	--anchor-deep: var(--enav-d8);
	--anchor-core: var(--enav-d7);
	--anchor-threshold: var(--enav-d6);
	--surface-rich: var(--enav-d5);
	--surface-main: var(--enav-d4);
	--surface-bridge: var(--enav-d3);
	--surface-soft: var(--enav-d2);
	--surface-air: var(--enav-d1);
}

.pal-play {
	--anchor-deep: var(--play-d8);
	--anchor-core: var(--play-d7);
	--anchor-threshold: var(--play-d6);
	--surface-rich: var(--play-d5);
	--surface-main: var(--play-d4);
	--surface-bridge: var(--play-d3);
	--surface-soft: var(--play-d2);
	--surface-air: var(--play-d1);
}

.pal-utility {
	--anchor-deep: var(--utility-d8);
	--anchor-core: var(--utility-d7);
	--anchor-threshold: var(--utility-d6);
	--surface-rich: var(--utility-d5);
	--surface-main: var(--utility-d4);
	--surface-bridge: var(--utility-d3);
	--surface-soft: var(--utility-d2);
	--surface-air: var(--utility-d1);
}

.pal-neutral {
	--anchor-deep: var(--realm-neutral-d8);
	--anchor-core: var(--realm-neutral-d7);
	--anchor-threshold: var(--realm-neutral-d6);
	--surface-rich: var(--realm-neutral-d5);
	--surface-main: var(--realm-neutral-d4);
	--surface-bridge: var(--realm-neutral-d3);
	--surface-soft: var(--realm-neutral-d2);
	--surface-air: var(--realm-neutral-d1);
}

.pal-be {
	--anchor-deep: var(--realm-be-d8);
	--anchor-core: var(--realm-be-d7);
	--anchor-threshold: var(--realm-be-d6);
	--surface-rich: var(--realm-be-d5);
	--surface-main: var(--realm-be-d4);
	--surface-bridge: var(--realm-be-d3);
	--surface-soft: var(--realm-be-d2);
	--surface-air: var(--realm-be-d1);
}

.pal-feel {
	--anchor-deep: var(--realm-feel-d8);
	--anchor-core: var(--realm-feel-d7);
	--anchor-threshold: var(--realm-feel-d6);
	--surface-rich: var(--realm-feel-d5);
	--surface-main: var(--realm-feel-d4);
	--surface-bridge: var(--realm-feel-d3);
	--surface-soft: var(--realm-feel-d2);
	--surface-air: var(--realm-feel-d1);
}

.pal-see {
	--anchor-deep: var(--realm-see-d8);
	--anchor-core: var(--realm-see-d7);
	--anchor-threshold: var(--realm-see-d6);
	--surface-rich: var(--realm-see-d5);
	--surface-main: var(--realm-see-d4);
	--surface-bridge: var(--realm-see-d3);
	--surface-soft: var(--realm-see-d2);
	--surface-air: var(--realm-see-d1);
}

.pal-do {
	--anchor-deep: var(--realm-do-d8);
	--anchor-core: var(--realm-do-d7);
	--anchor-threshold: var(--realm-do-d6);
	--surface-rich: var(--realm-do-d5);
	--surface-main: var(--realm-do-d4);
	--surface-bridge: var(--realm-do-d3);
	--surface-soft: var(--realm-do-d2);
	--surface-air: var(--realm-do-d1);
}

.pal-peach {
	--anchor-deep: var(--expr-peach-d8);
	--anchor-core: var(--expr-peach-d7);
	--anchor-threshold: var(--expr-peach-d6);
	--surface-rich: var(--expr-peach-d5);
	--surface-main: var(--expr-peach-d4);
	--surface-bridge: var(--expr-peach-d3);
	--surface-soft: var(--expr-peach-d2);
	--surface-air: var(--expr-peach-d1);
}

.pal-mauve {
	--anchor-deep: var(--expr-mauve-d8);
	--anchor-core: var(--expr-mauve-d7);
	--anchor-threshold: var(--expr-mauve-d6);
	--surface-rich: var(--expr-mauve-d5);
	--surface-main: var(--expr-mauve-d4);
	--surface-bridge: var(--expr-mauve-d3);
	--surface-soft: var(--expr-mauve-d2);
	--surface-air: var(--expr-mauve-d1);
}

.pal-honey {
	--anchor-deep: var(--expr-honey-d8);
	--anchor-core: var(--expr-honey-d7);
	--anchor-threshold: var(--expr-honey-d6);
	--surface-rich: var(--expr-honey-d5);
	--surface-main: var(--expr-honey-d4);
	--surface-bridge: var(--expr-honey-d3);
	--surface-soft: var(--expr-honey-d2);
	--surface-air: var(--expr-honey-d1);
}

.pal-periwinkle {
	--anchor-deep: var(--expr-periwinkle-d8);
	--anchor-core: var(--expr-periwinkle-d7);
	--anchor-threshold: var(--expr-periwinkle-d6);
	--surface-rich: var(--expr-periwinkle-d5);
	--surface-main: var(--expr-periwinkle-d4);
	--surface-bridge: var(--expr-periwinkle-d3);
	--surface-soft: var(--expr-periwinkle-d2);
	--surface-air: var(--expr-periwinkle-d1);
}

.pal-terra {
	--anchor-deep: var(--expr-terra-d8);
	--anchor-core: var(--expr-terra-d7);
	--anchor-threshold: var(--expr-terra-d6);
	--surface-rich: var(--expr-terra-d5);
	--surface-main: var(--expr-terra-d4);
	--surface-bridge: var(--expr-terra-d3);
	--surface-soft: var(--expr-terra-d2);
	--surface-air: var(--expr-terra-d1);
}

.pal-olive {
	--anchor-deep: var(--expr-olive-d8);
	--anchor-core: var(--expr-olive-d7);
	--anchor-threshold: var(--expr-olive-d6);
	--surface-rich: var(--expr-olive-d5);
	--surface-main: var(--expr-olive-d4);
	--surface-bridge: var(--expr-olive-d3);
	--surface-soft: var(--expr-olive-d2);
	--surface-air: var(--expr-olive-d1);
}

/* Author-facing density set.
   Inherit = no class = page Air / reading context.
   d-2 and d-5 use primary ink.
   d-7 uses inverse ink automatically. */

.d-2 {
	--section-background: var(--surface-soft);
	--section-ink: var(--ink-primary);
	--section-link: var(--accent);
	--section-divider: var(--surface-main);
	background: var(--section-background) !important;
	color: var(--section-ink);
}

.d-5 {
	--section-background: var(--surface-rich);
	--section-ink: var(--ink-primary);
	--section-link: var(--accent);
	--section-divider: var(--surface-main);
	background: var(--section-background) !important;
	color: var(--section-ink);
}

.d-7 {
	--section-background: var(--anchor-core);
	--section-ink: var(--ink-inverse);
	--section-link: var(--ink-inverse);
	--section-divider: var(--anchor-threshold);
	background: var(--section-background) !important;
	color: var(--section-ink);
}

/* Text inherits the density-owned ink. Voice utilities change font family,
   never the colour contract. Explicit editor colour choices remain explicit. */
.d-2 :where(h1,h2,h3,h4,h5,h6,p,li,blockquote),
.d-5 :where(h1,h2,h3,h4,h5,h6,p,li,blockquote),
.d-7 :where(h1,h2,h3,h4,h5,h6,p,li,blockquote) {
	color: inherit;
}

.d-2 a,
.d-5 a {
	color: var(--section-link);
}

.d-7 a {
	color: var(--section-link);
	text-decoration-color: currentColor;
}

.tsp-section-class-preview {
	margin-top: 16px;
	padding-top: 12px;
	border-top: 1px solid #dcdcde;
}

.tsp-section-class-preview code {
	display: block;
	margin-top: 7px;
	padding: 8px;
	white-space: normal;
	word-break: break-word;
	background: #f6f7f7;
	border: 1px solid #dcdcde;
	border-radius: 3px;
}


/* Density selections are intentional author overrides.
   These selectors ensure WordPress/Kadence container backgrounds do not
   suppress the selected TSP surface. */
:is(
	.wp-block-group,
	.wp-block-columns,
	.wp-block-column,
	.wp-block-cover,
	.wp-block-kadence-rowlayout,
	.wp-block-kadence-column,
	.wp-block-kadence-section
).d-2 {
	background: var(--surface-soft) !important;
}

:is(
	.wp-block-group,
	.wp-block-columns,
	.wp-block-column,
	.wp-block-cover,
	.wp-block-kadence-rowlayout,
	.wp-block-kadence-column,
	.wp-block-kadence-section
).d-5 {
	background: var(--surface-rich) !important;
}

:is(
	.wp-block-group,
	.wp-block-columns,
	.wp-block-column,
	.wp-block-cover,
	.wp-block-kadence-rowlayout,
	.wp-block-kadence-column,
	.wp-block-kadence-section
).d-7 {
	background: var(--anchor-core) !important;
}


/* v1.2.2: force the selected density through common inner wrappers and
   ensure inherited text follows the section ink unless the author has
   explicitly chosen a WordPress text colour. */

.d-2,
.d-2 > .kt-inside-inner-col,
.d-2 > .kt-row-column-wrap,
.d-2 > .wp-block-cover__inner-container {
	background-color: var(--surface-soft) !important;
	color: var(--ink-primary) !important;
}

.d-5,
.d-5 > .kt-inside-inner-col,
.d-5 > .kt-row-column-wrap,
.d-5 > .wp-block-cover__inner-container {
	background-color: var(--surface-rich) !important;
	color: var(--ink-primary) !important;
}

.d-7,
.d-7 > .kt-inside-inner-col,
.d-7 > .kt-row-column-wrap,
.d-7 > .wp-block-cover__inner-container {
	background-color: var(--anchor-core) !important;
	color: var(--ink-inverse) !important;
}

.d-2 :where(h1,h2,h3,h4,h5,h6,p,li,blockquote,span):not(.has-text-color),
.d-5 :where(h1,h2,h3,h4,h5,h6,p,li,blockquote,span):not(.has-text-color) {
	color: var(--ink-primary) !important;
}

.d-7 :where(h1,h2,h3,h4,h5,h6,p,li,blockquote,span):not(.has-text-color) {
	color: var(--ink-inverse) !important;
}


/* v1.4.2 Gutenberg-safe density transport classes.
   The UI still exposes canonical Air / d-2 / d-5 / d-7 language. */
.tsp-density-soft {
	--section-background: var(--surface-soft);
	--section-ink: var(--ink-primary);
	--section-link: var(--accent);
	background: var(--surface-soft) !important;
	color: var(--ink-primary) !important;
}

.tsp-density-rich {
	--section-background: var(--surface-rich);
	--section-ink: var(--ink-primary);
	--section-link: var(--accent);
	background: var(--surface-rich) !important;
	color: var(--ink-primary) !important;
}

.tsp-density-core {
	--section-background: var(--anchor-core);
	--section-ink: var(--ink-inverse);
	--section-link: var(--ink-inverse);
	background: var(--anchor-core) !important;
	color: var(--ink-inverse) !important;
}

.tsp-density-soft :where(h1,h2,h3,h4,h5,h6,p,li,blockquote,span):not(.has-text-color),
.tsp-density-rich :where(h1,h2,h3,h4,h5,h6,p,li,blockquote,span):not(.has-text-color) {
	color: var(--ink-primary) !important;
}

.tsp-density-core :where(h1,h2,h3,h4,h5,h6,p,li,blockquote,span):not(.has-text-color) {
	color: var(--ink-inverse) !important;
}
