/**
 * ALFARI 6.28.1 – Automatic dark-surface contrast guard
 * Presentation only. No business/training logic.
 *
 * Runtime marks actual rendered surfaces as either
 * `.alfari-auto-dark-surface` or `.alfari-auto-light-surface`.
 * This layer is intentionally loaded last so dark plugin surfaces cannot
 * inherit older public-page rules that force charcoal text everywhere.
 */
:root{
  --alfari-dark-surface-text:#ffffff;
  --alfari-dark-surface-soft:#e7ece8;
  --alfari-dark-surface-muted:#d0d8d2;
  --alfari-dark-surface-link:#b7e35d;
  --alfari-light-surface-text:#1f2328;
  --alfari-light-surface-soft:#4b5563;
}

body:not(.alfari-app-mode) .alfari-auto-dark-surface{
  color:var(--alfari-dark-surface-soft)!important;
  -webkit-text-fill-color:var(--alfari-dark-surface-soft)!important;
}
body:not(.alfari-app-mode) .alfari-auto-dark-surface :where(
  h1,h2,h3,h4,h5,h6,strong,b,label,legend,summary,
  [class*="title"],[class*="heading"],[class*="headline"]
){
  color:var(--alfari-dark-surface-text)!important;
  -webkit-text-fill-color:var(--alfari-dark-surface-text)!important;
  opacity:1!important;
  text-shadow:none!important;
}
body:not(.alfari-app-mode) .alfari-auto-dark-surface :where(
  p,li,dd,dt,small,caption,figcaption,
  [class*="description"],[class*="subtitle"],[class*="lead"],[class*="meta"]
){
  color:var(--alfari-dark-surface-soft)!important;
  -webkit-text-fill-color:var(--alfari-dark-surface-soft)!important;
  opacity:1!important;
}
body:not(.alfari-app-mode) .alfari-auto-dark-surface :where(
  a:not(.button):not([class*="button"]):not([class*="btn"])
){
  color:var(--alfari-dark-surface-link)!important;
  -webkit-text-fill-color:var(--alfari-dark-surface-link)!important;
}

/* A light child card/input/button inside a dark panel owns its own contrast. */
body:not(.alfari-app-mode) .alfari-auto-light-surface{
  color:var(--alfari-light-surface-text)!important;
  -webkit-text-fill-color:var(--alfari-light-surface-text)!important;
}
body:not(.alfari-app-mode) .alfari-auto-light-surface :where(
  h1,h2,h3,h4,h5,h6,strong,b,label,legend,summary,
  [class*="title"],[class*="heading"],[class*="headline"]
){
  color:var(--alfari-light-surface-text)!important;
  -webkit-text-fill-color:var(--alfari-light-surface-text)!important;
  opacity:1!important;
}
body:not(.alfari-app-mode) .alfari-auto-light-surface :where(
  p,li,dd,dt,small,caption,figcaption,
  [class*="description"],[class*="subtitle"],[class*="lead"],[class*="meta"]
){
  color:var(--alfari-light-surface-soft)!important;
  -webkit-text-fill-color:var(--alfari-light-surface-soft)!important;
  opacity:1!important;
}
body:not(.alfari-app-mode) .alfari-auto-light-surface :where(
  a:not(.button):not([class*="button"]):not([class*="btn"])
){
  color:#5f8f22!important;
  -webkit-text-fill-color:#5f8f22!important;
}

/* Form controls must always follow their own rendered surface. */
body:not(.alfari-app-mode) :where(input,select,textarea).alfari-auto-light-surface{
  color:#1f2328!important;
  -webkit-text-fill-color:#1f2328!important;
}
body:not(.alfari-app-mode) :where(input,select,textarea).alfari-auto-dark-surface{
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
}

/* Kostenlose Tools: override the historical blanket charcoal typography only
   when the runtime has verified that the rendered plugin surface is dark. */
body:not(.alfari-app-mode) .alfari-tools-page .alfari-auto-dark-surface :where(
  h1,h2,h3,h4,h5,h6,strong,b,label,legend,summary
){
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
}
body:not(.alfari-app-mode) .alfari-tools-page .alfari-auto-dark-surface :where(
  p,li,dd,dt,small,caption,figcaption,span:not([class*="icon"])
){
  color:#e7ece8!important;
  -webkit-text-fill-color:#e7ece8!important;
}
body:not(.alfari-app-mode) .alfari-tools-page .alfari-auto-light-surface :where(
  h1,h2,h3,h4,h5,h6,strong,b,label,legend,summary,span:not([class*="icon"])
){
  color:#1f2328!important;
  -webkit-text-fill-color:#1f2328!important;
}
body:not(.alfari-app-mode) .alfari-tools-page .alfari-auto-light-surface :where(
  p,li,dd,dt,small,caption,figcaption
){
  color:#4b5563!important;
  -webkit-text-fill-color:#4b5563!important;
}

/* Explicit author/plugin dark-surface markers also receive the same contract,
   even before JS classification is complete. */
body:not(.alfari-app-mode) :where(
  [data-theme="dark"],
  [data-color-scheme="dark"],
  .is-dark,
  .theme-dark,
  .dark-surface,
  [class*="dark-panel"],
  [class*="dark-card"],
  [class*="dark-hero"]
){
  color:var(--alfari-dark-surface-soft)!important;
}
body:not(.alfari-app-mode) :where(
  [data-theme="dark"],
  [data-color-scheme="dark"],
  .is-dark,
  .theme-dark,
  .dark-surface,
  [class*="dark-panel"],
  [class*="dark-card"],
  [class*="dark-hero"]
) :where(h1,h2,h3,h4,h5,h6,strong,b,label,legend,summary){
  color:#fff!important;
  -webkit-text-fill-color:#fff!important;
}
body:not(.alfari-app-mode) :where(
  [data-theme="dark"],
  [data-color-scheme="dark"],
  .is-dark,
  .theme-dark,
  .dark-surface,
  [class*="dark-panel"],
  [class*="dark-card"],
  [class*="dark-hero"]
) :where(p,li,dd,dt,small,caption,figcaption){
  color:#e7ece8!important;
  -webkit-text-fill-color:#e7ece8!important;
}

/* 6.28.4 – DARK-SURFACE-TEXT-WHITE-001
   User-facing typography on dark surfaces is white. Brand green remains for controls/background accents. */
.alfari-dark-surface,
.alfari-dark-surface :is(h1,h2,h3,h4,h5,h6,p,span,strong,small,label,legend),
[data-alfari-dark-surface],
[data-alfari-dark-surface] :is(h1,h2,h3,h4,h5,h6,p,span,strong,small,label,legend),
.alfari-app-header,
.alfari-app-header :is(h1,h2,h3,p,span,strong,small,label),
.alfari-trainer-hero,
.alfari-trainer-hero :is(h1,h2,h3,p,span,strong,small,label) {
  color:#fff !important;
}
