/* PowerFlo site appearance — visitor preference only. No Global Styles mutation. */
html.pf-site-dark,
html.pf-site-dark body {
  --wp--preset--color--base: #1a1a1a;
  --wp--preset--color--contrast: #f4f4f4;
  background: #1a1a1a;
  color: #f4f4f4;
  color-scheme: dark;
}

html.pf-site-dark body,
html.pf-site-dark .wp-site-blocks,
html.pf-site-dark header.wp-block-template-part,
html.pf-site-dark footer.wp-block-template-part,
html.pf-site-dark main {
  background-color: #1a1a1a;
  color: #f4f4f4;
}

html.pf-site-dark header.wp-block-template-part a,
html.pf-site-dark footer.wp-block-template-part a,
html.pf-site-dark .wp-block-site-title a,
html.pf-site-dark .wp-block-navigation a {
  color: #f4f4f4;
}

/* Outline buttons are ordinary WordPress blocks, so they do not inherit the
 * PowerFlo shell link rule above. Keep their text and border synchronized with
 * the dark-site foreground without changing their light-mode appearance. */
html.pf-site-dark .wp-block-button.is-style-outline .wp-block-button__link {
  color: #f4f4f4 !important;
  border-color: #f4f4f4 !important;
}

/* Only PowerFlo-managed line art is inverted. Editorial photographs and other
 * site media retain their original color. */
html.pf-site-dark img[data-powerflo-managed-image="1"],
html.pf-site-dark .pf-reference-image,
html.pf-site-dark .pf-pose-card-image,
html.pf-site-dark .pf-featured-class-image,
html.pf-site-dark .pf-row-pose-visual img {
  filter: invert(1);
}

/* Rails and RSS decks are self-contained light surfaces. Theme switching changes
 * the page around them, not the cards themselves. This keeps the established
 * light-gray card language and avoids low-contrast white-on-light copy. */
html.pf-site-dark :where(
  .pfh-pose-of-day,
  .pfh-daily-pose-signup,
  .pfh-rss-card,
  .pfdir-card,
  .pf-account-panel,
  .pf-featured-class-card,
  .pf-program-card,
  .pf-explore-gear-card,
  .pf-professional-rail-card,
  .pf-professional-cta-card
) {
  /* These components are intentionally self-contained light surfaces. Reset
   * the WordPress theme tokens here as well as PowerFlo's own rail variables
   * so Global Styles cannot turn individual headings/links white in Moon mode. */
  --wp--preset--color--base: #fafaf8;
  --wp--preset--color--contrast: #111111;
  --pf-classes-line: #ddd8d6;
  --pf-classes-muted: #6b6363;
  --pf-classes-panel: #fbfaf8;
  --pf-rail-panel: #fafaf8;
  --pf-rail-line: rgba(17,17,17,.34);
  color: #111;
  color-scheme: light;
}

/* Keep all ordinary copy inside self-contained light cards in the established
 * light-card palette. Opacity rules on muted labels/excerpts still work; only
 * the inherited foreground token is pinned back to dark ink. */
html.pf-site-dark :where(
  .pfh-pose-of-day,
  .pfh-daily-pose-signup,
  .pfh-rss-card,
  .pfdir-card,
  .pf-account-panel,
  .pf-featured-class-card,
  .pf-program-card,
  .pf-explore-gear-card,
  .pf-professional-rail-card,
  .pf-professional-cta-card
) :where(h1,h2,h3,h4,h5,h6,p,a,span,label,strong,small,button,input,select,textarea) {
  color: #111 !important;
}

/* A managed pose image inside one of those light cards remains the original
 * dark-on-light artwork. Only pose imagery sitting directly on the dark site
 * canvas is inverted to white. */
html.pf-site-dark :where(
  .pfh-pose-of-day,
  .pfh-daily-pose-signup,
  .pfh-rss-card,
  .pfdir-card,
  .pf-account-panel,
  .pf-featured-class-card,
  .pf-program-card,
  .pf-explore-gear-card,
  .pf-professional-rail-card,
  .pf-professional-cta-card
) img {
  filter: none !important;
  mix-blend-mode: normal !important;
}

/* Current logo export may still contain an opaque white field. The source file
 * is not modified; this makes black artwork white and lets the inverted black
 * field disappear into the dark canvas. */
html.pf-site-dark .wp-block-site-logo img,
html.pf-site-dark img.custom-logo {
  filter: invert(1);
  mix-blend-mode: screen;
}

.pf-site-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 58px;
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1;
  cursor: pointer;
}
.pf-site-theme-toggle .pf-site-theme-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  opacity: .38;
}
.pf-site-theme-toggle[data-theme="light"] .pf-site-theme-sun,
.pf-site-theme-toggle[data-theme="dark"] .pf-site-theme-moon {
  opacity: 1;
}
.pf-site-theme-toggle:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

/* Dark mode changes the main catalog canvas, not the self-contained rail cards. */
html.pf-site-dark :where(.pf-classes-catalog, .powerflo-pose-browser) {
  --pf-classes-line: #444;
  --pf-classes-muted: #bdbdbd;
  --pf-classes-panel: #202020;
  --pf-classes-card-shadow: none;
}

/* v1.8.161 — dark-mode containment audit.
 * Moon mode changes the site shell. Any PowerFlo component that deliberately
 * remains a light surface owns its own light Base/Contrast values and dark ink.
 * This prevents the site-wide WordPress contrast token from leaking white text
 * into a white card. Keep this list aligned with component CSS when adding a
 * new intentionally-light surface. */
html.pf-site-dark :where(
  .pf-atha-panel,
  .pf-player-gate,
  .pf-access-lock,
  .pf-auth-dialog-panel,
  .pf-getting-started-account-panel,
  .pf-account-cta,
  .pf-account-panel,
  .pf-professional-membership-card,
  .pf-professional-auth-gate,
  .pf-featured-class-card,
  .pf-program-card,
  .pf-explore-gear-card,
  .pf-professional-rail-card,
  .pf-professional-cta-card,
  .pfh-pose-of-day,
  .pfh-daily-pose-signup,
  .pfh-rss-card,
  .pfh-component-placeholder,
  .pfdir-card,
  .pfdir-tool-card,
  .pfdir-billboard,
  .pfdir-code-card,
  .pfdir-private-identity,
  .pfdir-profile-switcher a,
  .pfdir-notice,
  .pfdir-update,
  .pfdir-update-empty,
  .pfdir-credential-manage-card
) {
  --wp--preset--color--base: #fafaf8;
  --wp--preset--color--contrast: #111111;
  color: #111 !important;
  color-scheme: light;
}

html.pf-site-dark :where(
  .pf-atha-panel,
  .pf-player-gate,
  .pf-access-lock,
  .pf-auth-dialog-panel,
  .pf-getting-started-account-panel,
  .pf-account-cta,
  .pf-account-panel,
  .pf-professional-membership-card,
  .pf-professional-auth-gate,
  .pf-featured-class-card,
  .pf-program-card,
  .pf-explore-gear-card,
  .pf-professional-rail-card,
  .pf-professional-cta-card,
  .pfh-pose-of-day,
  .pfh-daily-pose-signup,
  .pfh-rss-card,
  .pfh-component-placeholder,
  .pfdir-card,
  .pfdir-tool-card,
  .pfdir-billboard,
  .pfdir-code-card,
  .pfdir-private-identity,
  .pfdir-profile-switcher a,
  .pfdir-notice,
  .pfdir-update,
  .pfdir-update-empty,
  .pfdir-credential-manage-card
) :where(h1,h2,h3,h4,h5,h6,p,a,span,label,strong,small) {
  color: #111 !important;
}

/* Form controls that remain white must own dark control text as well. */
html.pf-site-dark :where(
  .pf-atha-panel,
  .pf-auth-dialog-panel,
  .pf-getting-started-account-panel,
  .pf-account-panel,
  .pf-professional-form,
  .pfdir-inline-form,
  .pfdir-publish-form,
  .pfdir-profile-form,
  .pfdir-claim-form,
  .pfdir-credential-upload,
  .pfdir-schedule-form,
  .pfdir-zip-search,
  .pfh-signup-form
) :where(input,select,textarea,button) {
  --wp--preset--color--base: #ffffff;
  --wp--preset--color--contrast: #111111;
  color: #111 !important;
  color-scheme: light;
}

/* Filled PowerFlo primary actions deliberately remain white-on-black. */
html.pf-site-dark :where(
  .pf-atha-panel,
  .pf-player-gate,
  .pf-access-lock,
  .pf-auth-dialog-panel,
  .pf-getting-started-account-panel,
  .pf-account-cta,
  .pf-professional-membership-card,
  .pf-professional-auth-gate
) .pf-atha-primary {
  color: #fff !important;
}

/* Authoring/tutorial applications are intentionally self-contained light work
 * surfaces. Moon mode darkens the surrounding site shell, not these tools. */
html.pf-site-dark .pf-class-creator {
  --wp--preset--color--base: #fafaf8;
  --wp--preset--color--contrast: #111111;
  background: #fafaf8;
  color: #111 !important;
  color-scheme: light;
}

/* Managed pose line art inside a light application surface stays dark-on-light;
 * do not apply the site-canvas inversion used by the public Pose Library. */
html.pf-site-dark :where(.pf-class-creator, .pf-tutorial-player) :where(
  img[data-powerflo-managed-image="1"],
  .pf-reference-image,
  .pf-pose-card-image,
  .pf-row-pose-visual img
) {
  filter: none !important;
  mix-blend-mode: normal !important;
}

/* Professional onboarding submits a filled primary action; restore its intended
 * white-on-black label after the light-control containment rule above. */
html.pf-site-dark .pf-professional-form .pf-atha-primary {
  color: #fff !important;
}
