/* Light preserves the existing site colors. Images and provider frames retain
   their own colors; only the surrounding site interface changes palette. */
:root {
  color-scheme: light;
  --color-background: #fff;
  --color-surface: #fff;
  --color-text: #222;
  --color-link: #5d93ff;
  --color-accent: #f7a046;
  --color-muted: #888;
  --color-border: rgb(230.35, 230.35, 230.35);
  --color-subtle: rgb(235.45, 235.45, 235.45);
  --color-disabled: rgb(159.8, 159.8, 159.8);
  --color-copyright: #222;
  --color-control-border: #bbb;
  --color-control-link: #254f9c;
  --color-control-hover: #f1f5ff;
  --color-control-rule: #ddd;
  --color-note: #555;
  --color-placeholder: #f7f8fa;
  --color-shadow: #00000014;
  --color-backdrop: #0009;
  --color-linktree: #07689f;
  --color-substack: rgb(234, 65, 11);
  --color-on-substack: #fff;
  --color-focus: #254f9c;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --color-background: #15191f;
  --color-surface: #1e252e;
  --color-text: #edf2f7;
  --color-link: #8db5ff;
  --color-accent: #ffc078;
  --color-muted: #b7c2cf;
  --color-border: #586575;
  --color-subtle: #586575;
  --color-disabled: #a3afbd;
  --color-copyright: #b7c2cf;
  --color-control-border: #8493a5;
  --color-control-link: #a9c7ff;
  --color-control-hover: #303c4c;
  --color-control-rule: #586575;
  --color-note: #b7c2cf;
  --color-placeholder: #242e3b;
  --color-shadow: #0006;
  --color-backdrop: #000b;
  --color-linktree: #a9c7ff;
  --color-substack: #ff9a73;
  --color-on-substack: #15191f;
  --color-focus: #a9c7ff;
}

:root[data-theme="high-contrast"] {
  color-scheme: dark;
  --color-background: #000;
  --color-surface: #000;
  --color-text: #fff;
  --color-link: #ff0;
  --color-accent: #0ff;
  --color-muted: #fff;
  --color-border: #fff;
  --color-subtle: #fff;
  --color-disabled: #ddd;
  --color-copyright: #fff;
  --color-control-border: #fff;
  --color-control-link: #ff0;
  --color-control-hover: #222;
  --color-control-rule: #fff;
  --color-note: #fff;
  --color-placeholder: #000;
  --color-shadow: transparent;
  --color-backdrop: #000c;
  --color-linktree: #ff0;
  --color-substack: #ff0;
  --color-on-substack: #000;
  --color-focus: #0ff;
  --yarl__color_button: #fff;
  --yarl__color_button_active: #0ff;
  --yarl__color_button_disabled: #ddd;
  --yarl__button_filter: none;
  --yarl__button_border: 1px solid #fff;
}

html {
  background: var(--color-background);
  color: var(--color-text);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--color-control-link);
  font: inherit;
  font-size: 0.875rem;
  line-height: 28px;
  cursor: pointer;
}

.theme-toggle [data-theme-label] {
  text-decoration: underline;
}

.theme-toggle-icon {
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
}

.theme-toggle[hidden],
.theme-toggle-icon[hidden] {
  display: none;
}

.theme-toggle:focus-visible,
:root:is([data-theme="dark"], [data-theme="high-contrast"])
  :is(a, button, input, textarea):focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
}

:root:is([data-theme="dark"], [data-theme="high-contrast"])
  .form
  :is(input[type="text"], input[type="email"], textarea) {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-control-border);
}

/* Inline links remain recognizable without relying on color alone. */
:root:is([data-theme="dark"], [data-theme="high-contrast"]) p a {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

/* Prism's existing light-theme code styling is retained. */
:root[data-theme="dark"] :is(code, pre)[class*="language-"] {
  color: #edf2f7;
}

:root[data-theme="dark"] :not(pre) > code[class*="language-"],
:root[data-theme="dark"] pre[class*="language-"] {
  background: #212936;
}

:root[data-theme="high-contrast"] :is(code, pre)[class*="language-"],
:root[data-theme="high-contrast"] .token {
  color: #fff;
  background: #000;
  text-shadow: none;
}

:root[data-theme="dark"] .token {
  color: #c7d8ff;
}

:root[data-theme="dark"]
  .token:is(.comment, .block-comment, .prolog, .doctype, .cdata) {
  color: #b7c2cf;
}

:root[data-theme="dark"] .token:is(.string, .char, .attr-value, .regex) {
  color: #a5e2b4;
}

:root[data-theme="dark"] .token:is(.number, .boolean, .function) {
  color: #ffc078;
}

:root[data-theme="high-contrast"] :not(pre) > code[class*="language-"],
:root[data-theme="high-contrast"] pre[class*="language-"] {
  outline: 1px solid #fff;
}

:root[data-theme="high-contrast"] .yarl__button:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
}
