/*
 * Platform typography/contrast guardrails.
 *
 * Scope is opt-in via .efh-contrast on each app root. Text inherits the
 * surface foreground instead of being forced to a light gray or dark color
 * that can disappear against the current background.
 */

.efh-contrast {
  color: #0f172a;
  font-weight: 500;
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
}

/* Body copy must inherit the active surface color. This overrides older base
 * typography that forced paragraphs to slate-900 even inside dark panels. */
.efh-contrast :is(p, li, label, td, th, dd, dt, blockquote, figcaption) {
  color: inherit;
  text-underline-offset: 0.16em;
}

.efh-contrast :is(.bg-white, .bg-slate-50, .bg-gray-50) :is(.text-slate-400, .text-gray-400) {
  color: #475569 !important;
}

.efh-contrast :is(.bg-white, .bg-slate-50, .bg-gray-50) :is(.text-slate-500, .text-gray-500) {
  color: #334155 !important;
}

.efh-contrast :is(.bg-white, .bg-slate-50, .bg-gray-50) :is(.text-slate-600, .text-gray-600) {
  color: #334155 !important;
}

.efh-contrast :is(input, textarea, select)::-moz-placeholder {
  color: #475569;
  opacity: 1;
}

.efh-contrast :is(input, textarea, select)::placeholder {
  color: #475569;
  opacity: 1;
}

/* Production body copy should never render as a thin/light weight. */
.efh-contrast .font-light {
  font-weight: 500 !important;
}

.efh-contrast :is(p, li, label, td, th, dd, dt):not(.font-bold):not(.font-semibold):not(.font-black) {
  font-weight: 500;
}

/* Dark surfaces must never inherit the root dark foreground. */
.efh-contrast
  :is(
    .bg-black,
    .bg-slate-950,
    .bg-slate-900,
    .bg-slate-800,
    .bg-gray-950,
    .bg-gray-900,
    .bg-zinc-950,
    .bg-zinc-900,
    .bg-brand-blue-700,
    .bg-brand-blue-800,
    .bg-brand-blue-900,
    .bg-brand-red-700,
    .bg-brand-red-800,
    .bg-brand-red-900
  ) {
  color: #f8fafc;
}

.efh-contrast
  :is(
    .bg-black,
    .bg-slate-950,
    .bg-slate-900,
    .bg-slate-800,
    .bg-gray-950,
    .bg-gray-900,
    .bg-zinc-950,
    .bg-zinc-900,
    .bg-brand-blue-700,
    .bg-brand-blue-800,
    .bg-brand-blue-900,
    .bg-brand-red-700,
    .bg-brand-red-800,
    .bg-brand-red-900
  )
  :is(.text-slate-300, .text-gray-300, .text-zinc-300) {
  color: #f1f5f9 !important;
}

.efh-contrast
  :is(
    .bg-black,
    .bg-slate-950,
    .bg-slate-900,
    .bg-slate-800,
    .bg-gray-950,
    .bg-gray-900,
    .bg-zinc-950,
    .bg-zinc-900,
    .bg-brand-blue-700,
    .bg-brand-blue-800,
    .bg-brand-blue-900,
    .bg-brand-red-700,
    .bg-brand-red-800,
    .bg-brand-red-900
  )
  :is(.text-slate-400, .text-gray-400, .text-zinc-400) {
  color: #e2e8f0 !important;
}

/* Correct dark utility text applied directly to a dark panel or one of its
 * immediate children. Nested light cards keep their own dark foreground. */
.efh-contrast
  :is(
    .bg-black,
    .bg-slate-950,
    .bg-slate-900,
    .bg-slate-800,
    .bg-gray-950,
    .bg-gray-900,
    .bg-zinc-950,
    .bg-zinc-900,
    .bg-brand-blue-700,
    .bg-brand-blue-800,
    .bg-brand-blue-900,
    .bg-brand-red-700,
    .bg-brand-red-800,
    .bg-brand-red-900
  ):is(
    .text-slate-500,
    .text-slate-600,
    .text-slate-700,
    .text-slate-800,
    .text-gray-500,
    .text-gray-600,
    .text-gray-700,
    .text-gray-800,
    .text-zinc-500,
    .text-zinc-600,
    .text-zinc-700,
    .text-zinc-800
  ),
.efh-contrast
  :is(
    .bg-black,
    .bg-slate-950,
    .bg-slate-900,
    .bg-slate-800,
    .bg-gray-950,
    .bg-gray-900,
    .bg-zinc-950,
    .bg-zinc-900,
    .bg-brand-blue-700,
    .bg-brand-blue-800,
    .bg-brand-blue-900,
    .bg-brand-red-700,
    .bg-brand-red-800,
    .bg-brand-red-900
  )
  > :is(
    .text-slate-500,
    .text-slate-600,
    .text-slate-700,
    .text-slate-800,
    .text-gray-500,
    .text-gray-600,
    .text-gray-700,
    .text-gray-800,
    .text-zinc-500,
    .text-zinc-600,
    .text-zinc-700,
    .text-zinc-800
  ) {
  color: #f1f5f9 !important;
}

.efh-contrast
  :is(
    .bg-black,
    .bg-slate-950,
    .bg-slate-900,
    .bg-slate-800,
    .bg-gray-950,
    .bg-gray-900,
    .bg-zinc-950,
    .bg-zinc-900,
    .bg-brand-blue-700,
    .bg-brand-blue-800,
    .bg-brand-blue-900,
    .bg-brand-red-700,
    .bg-brand-red-800,
    .bg-brand-red-900
  )
  .text-white {
  color: #ffffff !important;
}

/* Restore dark text whenever a light card is nested inside a dark section. */
.efh-contrast :is(.bg-white, .bg-slate-50, .bg-gray-50) {
  color: #0f172a;
}

