/**
 * base.css — the element reset (r-39 f6).
 *
 * Replaces the "preflight" reset the Tailwind CDN script used to inject at
 * runtime, rule for rule, so dropping the script changes nothing on screen.
 * Only the two colour defaults moved onto tokens (default border colour,
 * placeholder colour).
 *
 * Load order matters: this file and layout.css are linked LAST in <head>,
 * where the CDN used to inject its <style>, so the cascade stays exactly as
 * it was (element rules here still lose to any class rule).
 *
 * Derived from Tailwind CSS v3 preflight (MIT, (c) Tailwind Labs), itself
 * based on modern-normalize.
 *
 * @see docs/architecture/ui-design-system.md §13 "Layout utilities and reset"
 */

*,
::before,
::after {
  box-sizing: border-box;
  border-width: 0;
  border-style: solid;
  border-color: var(--color-border);
}

html,
:host {
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
  font-family: var(--font-family-body);
  font-feature-settings: normal;
  font-variation-settings: normal;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  line-height: inherit;
}

hr {
  height: 0;
  color: inherit;
  border-top-width: 1px;
}

abbr:where([title]) {
  text-decoration: underline dotted;
}

h1, h2, h3, h4, h5, h6 {
  font-size: inherit;
  font-weight: inherit;
}

a {
  color: inherit;
  text-decoration: inherit;
}

b,
strong {
  font-weight: bolder;
}

code,
kbd,
samp,
pre {
  font-family: var(--font-family-code);
  font-feature-settings: normal;
  font-variation-settings: normal;
  font-size: 1em;
}

small {
  font-size: 80%;
}

sub,
sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sub { bottom: -0.25em; }
sup { top: -0.5em; }

table {
  text-indent: 0;
  border-color: inherit;
  border-collapse: collapse;
}

button,
input,
optgroup,
select,
textarea {
  font-family: inherit;
  font-feature-settings: inherit;
  font-variation-settings: inherit;
  font-size: 100%;
  font-weight: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  color: inherit;
  margin: 0;
  padding: 0;
}

button,
select {
  text-transform: none;
}

button,
input:where([type='button']),
input:where([type='reset']),
input:where([type='submit']) {
  -webkit-appearance: button;
  background-color: transparent;
  background-image: none;
}

:-moz-focusring { outline: auto; }
:-moz-ui-invalid { box-shadow: none; }

progress {
  vertical-align: baseline;
}

::-webkit-inner-spin-button,
::-webkit-outer-spin-button {
  height: auto;
}

[type='search'] {
  -webkit-appearance: textfield;
  outline-offset: -2px;
}

::-webkit-search-decoration {
  -webkit-appearance: none;
}

::-webkit-file-upload-button {
  -webkit-appearance: button;
  font: inherit;
}

summary {
  display: list-item;
}

blockquote, dl, dd, h1, h2, h3, h4, h5, h6, hr, figure, p, pre {
  margin: 0;
}

fieldset {
  margin: 0;
  padding: 0;
}

legend {
  padding: 0;
}

ol,
ul,
menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

dialog {
  padding: 0;
}

textarea {
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  opacity: 1;
  color: var(--color-text-secondary);
}

button,
[role='button'] {
  cursor: pointer;
}

:disabled {
  cursor: default;
}

img, svg, video, canvas, audio, iframe, embed, object {
  display: block;
  vertical-align: middle;
}

img,
video {
  max-width: 100%;
  height: auto;
}

[hidden]:where(:not([hidden='until-found'])) {
  display: none;
}

/* ── Scrollbars (b-157) ─────────────────────────────────────────────── */

/* RULE: every scrolling area has the app's thin accent scrollbar. It used to
   be a class added by hand, so a new area without it showed the browser's
   own light one on a dark theme. */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--color-accent);
  opacity: 0.4;
  border-radius: var(--radius-lg);
}

/* Firefox. Only there: in Chrome these would switch the rules above off. */
@supports not selector(::-webkit-scrollbar) {
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--color-accent) transparent;
  }
}

/* ── Theme finish (v0.105.0, ui-design-system.md §13 "Themes") ──────── */

/* A theme's focus halo (--shadow-glow, none by default) around a focused
   control, on top of its outline, which stays the real indicator. :where()
   keeps this at zero specificity, so a control that draws its own focus
   shadow (inputs, fields.css) keeps it. */
:where(:focus-visible) {
  box-shadow: var(--shadow-glow);
}

/* Theme switch (themes.js withViewTransition): a short cross-fade instead
   of a hard cut; skipped entirely when reduced motion is asked for. */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 160ms;
  animation-timing-function: ease-out;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none;
  }
}

/* No CSS colour transitions during a theme switch: body's 0.4s background
   and colour tween (shell.css) would otherwise keep running after the
   cross-fade. withViewTransition() sets the class for the switch only. */
.theme-switching,
.theme-switching * {
  transition: none !important;
}
