/*
 * Promtek Mail — opt-out dark rendering for authored HTML messages.
 *
 * Roundcube's own chrome is already themed elsewhere. This layer is active
 * only inside an opened-message iframe, only in dark mode, and only while the
 * companion script applies the promtek-html-darkened state. Removing that
 * state exposes the sender's original HTML without rewriting it.
 */

html.iframe.dark-mode.promtek-html-darkened body.task-mail .message-htmlpart,
html.iframe.dark-mode.promtek-html-darkened body.task-mail .message-htmlpart * {
  color: var(--promtek-text) !important;
  background-color: var(--promtek-content) !important;
  border-color: var(--promtek-border) !important;
}

/* Keep links recognizable after authored foreground colours are neutralized. */
html.iframe.dark-mode.promtek-html-darkened body.task-mail .message-htmlpart a,
html.iframe.dark-mode.promtek-html-darkened body.task-mail .message-htmlpart a * {
  color: var(--promtek-link) !important;
}

html.iframe.dark-mode.promtek-html-darkened body.task-mail .message-htmlpart a:hover,
html.iframe.dark-mode.promtek-html-darkened body.task-mail .message-htmlpart a:hover * {
  color: var(--promtek-link-hover) !important;
}

/* Media pixels are never filtered or inverted. Transparent assets stay so. */
html.iframe.dark-mode.promtek-html-darkened body.task-mail .message-htmlpart img,
html.iframe.dark-mode.promtek-html-darkened body.task-mail .message-htmlpart picture,
html.iframe.dark-mode.promtek-html-darkened body.task-mail .message-htmlpart video,
html.iframe.dark-mode.promtek-html-darkened body.task-mail .message-htmlpart canvas,
html.iframe.dark-mode.promtek-html-darkened body.task-mail .message-htmlpart svg {
  background-color: transparent !important;
}

/* Quotes remain distinct without bringing back a bright rectangular canvas. */
html.iframe.dark-mode.promtek-html-darkened body.task-mail .message-htmlpart blockquote {
  background-color: var(--promtek-info-soft) !important;
  border-color: var(--promtek-border) !important;
}

/* A deliberately small, neutral escape hatch in Roundcube's metadata row. */
html.iframe.dark-mode body.task-mail #message-header .promtek-html-view-toggle {
  appearance: none;
  align-items: center;
  background-color: transparent !important;
  border: 1px solid var(--promtek-border) !important;
  border-radius: 999px;
  box-sizing: border-box;
  color: var(--promtek-muted) !important;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.25;
  margin: 0;
  padding: 0.12rem 0.5rem;
}

html.iframe.dark-mode body.task-mail #message-header .promtek-html-view-toggle:hover {
  background-color: var(--promtek-info-soft) !important;
  color: var(--promtek-text) !important;
}

html.iframe.dark-mode body.task-mail #message-header .promtek-html-view-toggle:focus-visible {
  background-color: var(--promtek-info-soft) !important;
  color: var(--promtek-text) !important;
  outline: 2px solid var(--promtek-accent);
  outline-offset: 2px;
}

@media print {
  html.iframe body.task-mail #message-header .promtek-html-view-toggle {
    display: none !important;
  }
}
