/**
 * OS-level “High contrast” / forced-colors (e.g. Windows) makes the browser override
 * author colors so native-looking controls can hide or clash with portal themes.
 *
 * Opting the document out restores our CSS (including the in-portal **HC** theme).
 * This does **not** change the user’s Windows setting — only how this origin is painted.
 *
 * https://developer.mozilla.org/en-US/docs/Web/CSS/forced-color-adjust
 */
@media (forced-colors: active) {
  html {
    forced-color-adjust: none;
    -webkit-forced-color-adjust: none;
  }
}

/*
 * Native date/time/datetime controls: `color-scheme` + picker indicator so calendar
 * icons stay visible on dark portal themes (and stay correct on light themes).
 * Main shell uses `html.dark` / `:not(.dark)`; embedded tools use `html[data-theme=…]`.
 */
html.dark,
html.theme-qm,
html.theme-dark,
html.theme-dark-purple,
html.theme-dark-green,
html.theme-dark-pink,
html.theme-cyber,
html.theme-hc {
  color-scheme: dark;
}
/* Main portal shell only (no data-theme): light pages omit the `dark` class. */
html:not(.dark):not([data-theme]) {
  color-scheme: light;
}
html[data-theme="portal"],
html[data-theme="portal-dark"],
html[data-theme="portal-dark-green"],
html[data-theme="portal-dark-pink"],
html[data-theme="portal-purple"],
html[data-theme="portal-cyber"],
html[data-theme="portal-hc"] {
  color-scheme: dark;
}
html[data-theme^="portal-light"] {
  color-scheme: light;
}

/*
 * Date/time pickers: @tailwindcss/forms uses appearance:none — restore native control
 * and force a light glyph on dark UIs (see portal-native-inputs.css for the same
 * rules if this file is not loaded last).
 */
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"],
input[type="week"] {
  -webkit-appearance: auto !important;
  appearance: auto !important;
}

html:is([data-theme^="portal-light"])
  input:is([type="date"], [type="datetime-local"], [type="time"], [type="month"])::-webkit-calendar-picker-indicator,
html:not(.dark):not([data-theme])
  input:is([type="date"], [type="datetime-local"], [type="time"], [type="month"])::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.9;
  filter: none;
}

html:is(
    .dark,
    [data-theme="portal"],
    [data-theme="portal-dark"],
    [data-theme="portal-dark-green"],
    [data-theme="portal-dark-pink"],
    [data-theme="portal-purple"],
    [data-theme="portal-cyber"],
    [data-theme="portal-hc"]
  )
  input:is([type="date"], [type="datetime-local"], [type="time"], [type="month"])::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 1;
  filter: brightness(0) invert(1);
}

html:is(
    .dark,
    [data-theme="portal"],
    [data-theme="portal-dark"],
    [data-theme="portal-dark-green"],
    [data-theme="portal-dark-pink"],
    [data-theme="portal-purple"],
    [data-theme="portal-cyber"],
    [data-theme="portal-hc"]
  )
  input:is([type="date"], [type="datetime-local"], [type="time"], [type="month"])::-moz-calendar-picker-indicator {
  cursor: pointer;
  opacity: 1;
  filter: brightness(0) invert(1);
}
