[data-smart-contrast="1"] {
  color: var(--smart-text, var(--text));
}

/*
  Runtime tone attributes are applied by smart_theme.rs.
  This layer defines adaptive tokens, while module CSS still owns structure.
*/
[data-smart-contrast="1"][data-tone="paper"] {
  --smart-heading: rgba(5, 58, 84, 0.997);
  --smart-text: rgba(8, 65, 93, 0.992);
  --smart-muted: rgba(29, 81, 108, 0.95);
  --smart-link: rgba(7, 89, 124, 0.99);
  --smart-chip-bg: rgba(13, 101, 136, 0.12);
  --smart-chip-border: rgba(12, 90, 124, 0.3);
  --smart-chip-text: rgba(7, 64, 91, 0.99);
}

[data-smart-contrast="1"][data-tone="ink"] {
  --smart-heading: rgba(246, 253, 255, 0.998);
  --smart-text: rgba(232, 246, 253, 0.986);
  --smart-muted: rgba(207, 232, 245, 0.94);
  --smart-link: rgba(216, 242, 255, 0.98);
  --smart-chip-bg: rgba(8, 69, 95, 0.78);
  --smart-chip-border: rgba(176, 228, 248, 0.42);
  --smart-chip-text: rgba(232, 247, 255, 0.99);
}

[data-smart-contrast="1"][data-tone="ink"][data-contrast-bias="critical"] {
  --smart-heading: rgba(248, 253, 255, 0.998);
  --smart-text: rgba(240, 250, 255, 0.995);
  --smart-muted: rgba(220, 241, 249, 0.978);
  --smart-chip-bg: rgba(7, 66, 92, 0.86);
  --smart-chip-border: rgba(193, 238, 254, 0.54);
  --smart-chip-text: rgba(239, 249, 255, 0.992);
}

[data-smart-contrast="1"][data-tone="paper"][data-contrast-bias="critical"] {
  --smart-heading: rgba(4, 54, 78, 0.999);
  --smart-text: rgba(7, 61, 88, 0.998);
  --smart-muted: rgba(26, 77, 102, 0.968);
  --smart-chip-bg: rgba(12, 93, 126, 0.2);
  --smart-chip-border: rgba(8, 79, 110, 0.42);
  --smart-chip-text: rgba(6, 61, 86, 0.99);
}

[data-smart-contrast="1"][data-contrast-bias="high"] {
  --smart-text: color-mix(in srgb, var(--smart-text) 88%, var(--smart-heading));
}

/*
  Modules that opt into palette lock should keep local intent and avoid
  aggressive global overpainting.
*/
[data-smart-palette-lock="1"] {
  --smart-heading: var(--module-heading, var(--smart-heading, var(--text-strong)));
  --smart-text: var(--module-text, var(--smart-text, var(--text)));
  --smart-muted: var(--module-muted, var(--smart-muted, var(--text-muted)));
  --smart-link: var(--module-link, var(--smart-link, var(--color-accent-2)));
  --smart-chip-bg: var(--module-chip-bg, var(--smart-chip-bg, rgba(16, 102, 138, 0.12)));
  --smart-chip-border: var(
    --module-chip-border,
    var(--smart-chip-border, rgba(12, 90, 124, 0.3))
  );
  --smart-chip-text: var(--module-chip-text, var(--smart-chip-text, var(--smart-heading)));
}

[data-smart-palette-lock="1"] :where(
    h1,
    h2,
    h3,
    h4,
    h5,
    h6,
    .showcase-title,
    .spotlight-title,
    .path-title,
    .constellation-card-title,
    .command-hero h1,
    .command-hero-manifesto-item h3,
    .command-hero-visual-frame h2,
    .command-hero-metric-value,
    .command-hero-signal-value,
    .command-hero-storyline-value
  ) {
  color: var(--smart-heading);
}

[data-smart-palette-lock="1"] :where(
    p,
    li,
    .lead,
    .showcase-body,
    .showcase-bullets,
    .path-subtitle,
    .path-bullets,
    .spotlight-body,
    .constellation-card-detail,
    .mega-link-desc,
    .command-hero-manifesto-item p,
    .command-hero-visual-frame p,
    .command-hero-proofline span
  ) {
  color: var(--smart-text);
}

[data-smart-palette-lock="1"] :where(
    .badge,
    .path-tag,
    .showcase-kicker,
    .spotlight-kicker,
    .command-hero-kicker,
    .command-hero-visual-topline,
    .command-hero-storyline-label,
    .command-hero-metric-label,
    .command-hero-signal-label
  ) {
  color: var(--smart-chip-text);
  border-color: var(--smart-chip-border);
  background: var(--smart-chip-bg);
}

/*
  Unlocked surfaces (fallback/default modules) get strong adaptive guarantees.
*/
[data-smart-contrast="1"]:not([data-smart-palette-lock="1"]) :where(
    h1,
    h2,
    h3,
    h4,
    h5,
    h6,
    .showcase-title,
    .spotlight-title,
    .path-title,
    .constellation-card-title,
    .mega-feature-title,
    .mega-link-title,
    .stat-value
  ) {
  color: var(--smart-heading) !important;
}

[data-smart-contrast="1"]:not([data-smart-palette-lock="1"]) :where(
    p,
    li,
    .lead,
    .showcase-body,
    .showcase-bullets,
    .path-subtitle,
    .path-bullets,
    .spotlight-body,
    .constellation-card-detail,
    .mega-feature-body,
    .mega-link-desc,
    .timeline-body,
    .timeline-title,
    .matrix-cell,
    .matrix-col,
    .matrix-row-title,
    .logo-pill-label,
    .stat-label
  ) {
  color: var(--smart-text) !important;
}

[data-smart-contrast="1"]:not([data-smart-palette-lock="1"]) :where(
    .badge,
    .path-tag,
    .showcase-kicker,
    .spotlight-kicker,
    .mega-title
  ) {
  color: var(--smart-chip-text) !important;
  border-color: var(--smart-chip-border);
  background: var(--smart-chip-bg);
}

[data-smart-contrast="1"] :where(
    .showcase-body,
    .spotlight-body,
    .path-subtitle,
    .path-bullets,
    .path-bullets li,
    .showcase-bullets,
    .showcase-bullets li
  ) {
  font-weight: 560;
}

[data-smart-contrast="1"] a {
  color: var(--smart-link, var(--color-accent-2));
}

[data-smart-contrast="1"] li::marker {
  color: var(--smart-link, var(--color-accent-2));
}

[data-smart-contrast="1"] .cta-primary {
  color: rgba(248, 254, 255, 0.99) !important;
}

[data-smart-contrast="1"] .cta-secondary {
  border-color: var(--smart-chip-border, rgba(12, 90, 124, 0.3));
  color: var(--smart-chip-text, var(--smart-heading)) !important;
}

[data-smart-contrast="1"][data-tone="ink"] .cta-secondary {
  background: rgba(9, 58, 82, 0.72);
}

[data-smart-contrast="1"][data-tone="paper"] .cta-secondary {
  background: rgba(245, 252, 255, 0.82);
}
