/* Default look. Hosts override by restating a rule in their own stylesheet,
 * which loads after this one.
 *
 * Colour tokens first, then reset and .prose. color-scheme is set on :root /
 * [data-theme] so UA surfaces (scrollbars, form controls) follow the palette.
 * ThemeScript in components.templ sets the matching data-theme and
 * color-scheme attributes before this file arrives.
 */
:root {
  --color-bg: #0a0a0a;
  --color-bg-secondary: #111111;
  --color-text: #e5e5e5;
  --color-text-secondary: #a3a3a3;
  --color-text-muted: #737373;
  --color-border: #262626;
  --color-bg-elevated: #1a1a1a;
  --color-accent: #fb923c;
  --color-accent-hover: #fdba74;
  --color-accent-glow: rgba(244, 63, 94, 0.25);
  --gradient-accent: linear-gradient(135deg, #fb923c 0%, #f43f5e 100%);
  --surface-accent: linear-gradient(rgba(251, 146, 60, 0.13), rgba(251, 146, 60, 0.13));
  --surface-accent-strong: linear-gradient(rgba(251, 146, 60, 0.2), rgba(251, 146, 60, 0.2));
  --shadow-glow: 0 0 30px var(--color-accent-glow);

  --tag-lang: #fdba74;
  --tag-lang-bg: rgba(251, 146, 60, 0.16);
  --tag-lang-br: rgba(251, 146, 60, 0.45);
  --tag-gfx: #f472b6;
  --tag-gfx-bg: rgba(244, 114, 182, 0.16);
  --tag-gfx-br: rgba(244, 114, 182, 0.45);
  --tag-infra: #5eead4;
  --tag-infra-bg: rgba(45, 212, 191, 0.16);
  --tag-infra-br: rgba(45, 212, 191, 0.45);
  --tag-web: #c4b5fd;
  --tag-web-bg: rgba(167, 139, 250, 0.16);
  --tag-web-br: rgba(167, 139, 250, 0.45);

  color-scheme: dark;
}

[data-theme="light"] {
  --color-bg: #ffffff;
  --color-bg-secondary: #f5f5f5;
  --color-text: #171717;
  --color-text-secondary: #525252;
  --color-text-muted: #a3a3a3;
  --color-border: #e5e5e5;
  --color-bg-elevated: #fafafa;
  --color-accent: #c2410c;
  --color-accent-hover: #9a3412;
  --color-accent-glow: rgba(190, 18, 60, 0.18);
  --gradient-accent: linear-gradient(135deg, #cf4409 0%, #e11d48 100%);
  --surface-accent: linear-gradient(rgba(194, 65, 12, 0.07), rgba(194, 65, 12, 0.07));
  --surface-accent-strong: linear-gradient(rgba(194, 65, 12, 0.12), rgba(194, 65, 12, 0.12));
  --shadow-glow: 0 0 30px var(--color-accent-glow);

  --tag-lang: #9a3412;
  --tag-lang-bg: rgba(194, 65, 12, 0.10);
  --tag-lang-br: rgba(194, 65, 12, 0.38);
  --tag-gfx: #9d174d;
  --tag-gfx-bg: rgba(219, 39, 119, 0.10);
  --tag-gfx-br: rgba(219, 39, 119, 0.38);
  --tag-infra: #115e59;
  --tag-infra-bg: rgba(13, 148, 136, 0.10);
  --tag-infra-br: rgba(13, 148, 136, 0.38);
  --tag-web: #5b21b6;
  --tag-web-bg: rgba(124, 58, 237, 0.10);
  --tag-web-br: rgba(124, 58, 237, 0.38);

  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--color-bg);
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

a {
  color: var(--color-accent);
}

a:hover {
  color: var(--color-accent-hover);
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Default toggle. Hosts restyle .theme-toggle and/or pass children to
 * ThemeToggle (any non-span child hides these labels). Visibility of
 * .theme-toggle-dark / .theme-toggle-light follows data-theme. */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  line-height: 1;
  cursor: pointer;
  color: var(--color-text);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 0.25rem;
  padding: 0.35rem 0.6rem;
}

.theme-toggle:hover {
  border-color: var(--color-text-secondary);
}

.theme-toggle-light {
  display: none;
}

[data-theme="light"] .theme-toggle-dark {
  display: none;
}

[data-theme="light"] .theme-toggle-light {
  display: initial;
}

.theme-toggle:has(> :not(span)) > span.theme-toggle-dark,
.theme-toggle:has(> :not(span)) > span.theme-toggle-light {
  display: none;
}

/* Prose — markdown body */

.prose {
  max-width: 65ch;
  font-size: 1.125rem;
  line-height: 1.7;
}

.prose h2,
.prose h3 {
  font-weight: 700;
  line-height: 1.25;
  color: var(--color-text);
  scroll-margin-top: 8rem;
}

.prose h2 {
  font-size: 1.75rem;
  letter-spacing: -0.01em;
  margin: 3rem 0 1.25rem;
}

.prose h2:first-child {
  margin-top: 0;
}

.prose h3 {
  font-size: 1.25rem;
  margin: 2rem 0 1rem;
}

.prose p,
.prose ul,
.prose ol {
  margin-bottom: 1.5rem;
  color: var(--color-text-secondary);
}

.prose ul,
.prose ol {
  padding-left: 1.25rem;
}

.prose li {
  margin-bottom: 0.5rem;
}

.prose li:last-child {
  margin-bottom: 0;
}

.prose a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.prose strong {
  font-weight: 600;
  color: var(--color-text);
}

.prose code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--color-bg-secondary);
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
}

.prose pre {
  background: var(--color-bg-secondary);
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 2rem 0;
}

.prose pre code {
  background: none;
  padding: 0;
}

/* Token colours are in highlight.css; this is the block surface. Hosts override. */
.prose pre.chroma {
  background: var(--color-bg-secondary);
}

.prose figure {
  margin: 2rem 0;
}

.prose img,
.prose svg {
  display: block;
  max-width: 100%;
  height: auto;
}
