/*! unbloated | Copyright (C) 2026 Jorge Martinez | LGPL-3.0-only */
:root {
  --unbloat-color-text: #000000;
  --unbloat-color-surface: #ffffff;
  --unbloat-color-surface-muted: #ededed;
  --unbloat-color-canvas: #dddddd;
  --unbloat-color-muted: #555555;
  --unbloat-color-border: #000000;
  --unbloat-color-shadow: #bbbbbb;
  --unbloat-color-inverse-text: #ffffff;
  --unbloat-color-inverse-surface: #000000;
  --unbloat-font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
  --unbloat-font-size: 1rem;
  --unbloat-line-height-body: 1.6;
  --unbloat-line-height-heading: 1.2;
  --unbloat-heading-size-1: 2rem;
  --unbloat-heading-size-2: 1.5rem;
  --unbloat-heading-size-3: 1.3rem;
  --unbloat-heading-size-4: 1.17rem;
  --unbloat-heading-size-5: 1.1rem;
  --unbloat-heading-size-6: 1rem;
  --unbloat-space-1: 0.25rem;
  --unbloat-space-2: 0.5rem;
  --unbloat-space-3: 1rem;
  --unbloat-space-4: 1.5rem;
  --unbloat-space-5: 2rem;
  --unbloat-border-width: 1px;
  --unbloat-border-radius: 0;
  --unbloat-shadow-offset: 2px;
  --unbloat-focus-width: 2px;
  --unbloat-focus-offset: 3px;
}

/* SPDX-License-Identifier: LGPL-3.0-only */
/* Semantic element styles. Load tokens.css first, or use the complete stylesheet.
 * :where() keeps specificity low so a consuming adapter can override these rules.
 * Layout widths and platform-specific selectors belong to the consuming site.
 */
/* Root typography and grayscale surfaces; controls share the same accent color. */
:where(html) {
  color-scheme: light;
  font-family: var(--unbloat-font-family);
  font-size: 100%;
  line-height: var(--unbloat-line-height-body);
  color: var(--unbloat-color-text);
  background: var(--unbloat-color-surface);
  accent-color: var(--unbloat-color-text);
}

/* Include pseudo-elements in the box model and square-corner rule. */
:where(*, *::before, *::after) {
  box-sizing: border-box;
  border-radius: var(--unbloat-border-radius);
}

:where(body) {
  margin: 0;
  font-size: var(--unbloat-font-size);
}

/* Heading sizes, block spacing, and word wrapping come from the token schema. */
:where(h1, h2, h3, h4, h5, h6) {
  line-height: var(--unbloat-line-height-heading);
  margin-block: var(--unbloat-space-4) var(--unbloat-space-2);
  overflow-wrap: anywhere;
}

:where(h1) {
  font-size: var(--unbloat-heading-size-1);
}
:where(h2) {
  font-size: var(--unbloat-heading-size-2);
}
:where(h3) {
  font-size: var(--unbloat-heading-size-3);
}
:where(h4) {
  font-size: var(--unbloat-heading-size-4);
}
:where(h5) {
  font-size: var(--unbloat-heading-size-5);
}
:where(h6) {
  font-size: var(--unbloat-heading-size-6);
}

:where(p, ul, ol, dl, pre, blockquote, figure, table) {
  margin-block: 0 var(--unbloat-space-3);
}

/* Keep links identifiable without color and retain visible keyboard focus. */
:where(a) {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  overflow-wrap: anywhere;
}

:where(a:hover) {
  text-decoration-thickness: 2px;
}

:where(:focus-visible) {
  outline: var(--unbloat-focus-width) solid currentColor;
  outline-offset: var(--unbloat-focus-offset);
}

/* Native form controls retain their semantics; adapters own labels and layout. */
:where(button, input, select, textarea) {
  font: inherit;
  color: inherit;
  background: var(--unbloat-color-surface);
  border: var(--unbloat-border-width) solid var(--unbloat-color-border);
  padding: var(--unbloat-space-2);
  max-width: 100%;
}

:where(
  button,
  input[type="button"],
  input[type="submit"],
  input[type="reset"]
) {
  cursor: pointer;
  padding-inline: var(--unbloat-space-3);
}

:where(button:hover:enabled, input[type="submit"]:hover:enabled) {
  color: var(--unbloat-color-inverse-text);
  background: var(--unbloat-color-inverse-surface);
}

:where(:disabled) {
  cursor: not-allowed;
  opacity: 0.6;
}
:where(input::placeholder, textarea::placeholder, figcaption, small) {
  color: var(--unbloat-color-muted);
}
:where(textarea) {
  resize: vertical;
}
/* Square selection controls use an inset border to show the checked state. */
:where(input[type="checkbox"], input[type="radio"]) {
  appearance: none;
  inline-size: 1em;
  block-size: 1em;
  padding: 0;
  vertical-align: middle;
}

:where(input[type="checkbox"]:checked, input[type="radio"]:checked) {
  background: var(--unbloat-color-text);
  box-shadow: inset 0 0 0 2px var(--unbloat-color-surface);
}

/* A mixed checkbox has a horizontal mark distinct from the filled check. */
:where(input[type="checkbox"]:indeterminate) {
  background: linear-gradient(currentColor, currentColor) center / 65% 2px
    no-repeat;
  box-shadow: none;
}

@media (forced-colors: active) {
  :where(input[type="checkbox"], input[type="radio"]) {
    appearance: auto;
  }
}

/* Code shares the monospace stack; long preformatted lines scroll horizontally. */
:where(code, kbd, samp, pre) {
  font-family: var(--unbloat-font-family);
}

:where(code, kbd, samp) {
  background: var(--unbloat-color-surface-muted);
  padding: 0 var(--unbloat-space-1);
}

:where(pre) {
  background: var(--unbloat-color-surface-muted);
  padding: var(--unbloat-space-3);
  overflow-x: auto;
  border: var(--unbloat-border-width) solid var(--unbloat-color-border);
}

/* Avoid nested padding and surfaces inside a preformatted block. */
:where(pre code) {
  padding: 0;
  background: transparent;
}
/* Logical edges follow the writing direction for quotations and separators. */
:where(blockquote) {
  margin-inline: 0;
  border-inline-start: 3px solid var(--unbloat-color-border);
  padding-inline-start: var(--unbloat-space-3);
}
/* Media fits its container without imposing a document or figure width. */
:where(img, video, svg) {
  max-width: 100%;
  height: auto;
}
:where(figure) {
  margin-inline: 0;
}
/* Semantic tables use collapsed borders and a muted surface for header cells. */
:where(table) {
  border-collapse: collapse;
  text-align: start;
}
:where(th, td) {
  border: var(--unbloat-border-width) solid var(--unbloat-color-border);
  padding: var(--unbloat-space-2);
}
:where(th) {
  background: var(--unbloat-color-surface-muted);
}
:where(hr) {
  border: 0;
  border-block-start: var(--unbloat-border-width) solid
    var(--unbloat-color-border);
  margin-block: var(--unbloat-space-4);
}
:where(summary) {
  cursor: pointer;
}

/* Preserve visible selection with system colors in forced-color environments. */
@media (forced-colors: active) {
  :where(:focus-visible) {
    outline-color: Highlight;
  }
  :where(input[type="checkbox"]:checked, input[type="radio"]:checked) {
    background: Highlight;
    border-color: Highlight;
    forced-color-adjust: none;
  }
}

/* SPDX-License-Identifier: LGPL-3.0-only */
/* Optional appearance classes. Load tokens.css before this file. Components
 * supply surfaces and spacing; adapters supply layout and interaction behavior.
 */
/* Panels and callouts share the same bordered surface and inner spacing. */
:where(.unbloat-panel, .unbloat-callout) {
  padding: var(--unbloat-space-3);
  color: var(--unbloat-color-text);
  background: var(--unbloat-color-surface);
  border: var(--unbloat-border-width) solid var(--unbloat-color-border);
}

/* Panels, buttons, and tags use a hard shadow; callouts do not. */
:where(.unbloat-panel, .unbloat-button, .unbloat-tag) {
  box-shadow: var(--unbloat-shadow-offset) var(--unbloat-shadow-offset) 0
    var(--unbloat-color-shadow);
}

/* Use button for actions, anchor for navigation, and span for static tags. */
:where(.unbloat-button, .unbloat-tag) {
  display: inline-block;
  font: inherit;
  color: var(--unbloat-color-text);
  background: var(--unbloat-color-surface);
  border: var(--unbloat-border-width) solid var(--unbloat-color-border);
  padding: var(--unbloat-space-1) var(--unbloat-space-2);
  text-decoration: none;
}

/* Enabled button hover, linked tags, and selected tabs use inverse colors. */
:where(
  .unbloat-button:hover,
  a.unbloat-tag:hover,
  .unbloat-tabs [aria-selected="true"]
) {
  color: var(--unbloat-color-inverse-text);
  background: var(--unbloat-color-inverse-surface);
}

:where(.unbloat-button:disabled) {
  color: var(--unbloat-color-muted);
  background: var(--unbloat-color-surface-muted);
}

/* Wrapping tab layout only; the consumer manages ARIA state, focus, and panels. */
:where(.unbloat-tabs) {
  display: flex;
  flex-wrap: wrap;
  gap: var(--unbloat-space-2);
}

/* The thicker logical leading edge distinguishes a callout from a panel. */
:where(.unbloat-callout) {
  border-inline-start-width: 3px;
}
/* Invert the current surface. Nested elements with explicit colors need overrides. */
:where(.unbloat-inverse) {
  color: var(--unbloat-color-inverse-text);
  background: var(--unbloat-color-inverse-surface);
}
