/*
 * Mamore UI v2 — base layer.
 *
 * Loaded FIRST, before tokens, before app.css. It is deliberately low
 * specificity and deliberately quiet: it normalises the box model, the default
 * type and the focus ring, and nothing else. Components are not defined here.
 *
 * Load order in the shell:
 *   fonts.css -> fontawesome.css -> base.css -> typography.css -> app.css
 *   -> tokens.css -> themes/*.css -> layout.css -> components.css
 *   -> utilities.css
 *
 * base.css comes before app.css so that legacy rules (which are mostly
 * class-qualified, e.g. ".topbar h1") still win over the element defaults set
 * here. Nothing in this file is allowed to depend on a custom property, or it
 * would be unresolved at this point in the cascade -- every colour below is a
 * literal that the theme layer later replaces.
 */

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

html {
  /* Smooth scrolling is opt-in via the utility, not global: an operations tool
     should not hijack scroll position, and it is a vestibular trigger. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  /* Background is set by app.css today and moves to --bg-app once the shell is
     rebuilt (Phase 07). Kept here only for the reset guarantee. */
  line-height: 1.5;
  /* Long words (plate numbers, long references, French compounds) must wrap
     rather than force a horizontal scrollbar. */
  overflow-wrap: break-word;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }
ul[class], ol[class] { margin: 0; padding: 0; list-style: none; }
img, picture, svg, video { display: block; max-width: 100%; }
svg { height: auto; }

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }
button:disabled, input:disabled, select:disabled, textarea:disabled {
  cursor: not-allowed;
}

/* Respect the reduced-motion preference globally. app.css already carries an
   equivalent rule for its own transitions; this one covers the new layers. */
@media (prefers-reduced-motion: reduce) {
  html:focus-within { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --------------------------------------------------------------- focus ring
 * One focus ring for the whole product. Visible, offset, and it uses
 * --border-focus so it is theme-aware (a light-blue ring that vanishes on a
 * dark background is the classic dark-mode focus bug).
 *
 * :focus-visible rather than :focus, so a mouse click does not leave a ring
 * behind but a keyboard user always gets one. */
:focus-visible {
  outline: 2px solid var(--border-focus, #0a429a);
  outline-offset: 2px;
  border-radius: var(--radius-xs, 4px);
}

/* app.css ships its own focus rule on button/input/a; this is the v2 standard
   and it wins because it is loaded later and applies to everything. */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--border-focus, #0a429a);
  outline-offset: 2px;
}

/* A skip link that stays out of the way until it is focused. app.css defines
   .skip-link too; this is the token-based version and is loaded after it. */
.skip-link {
  position: fixed;
  top: -100px;
  left: var(--space-4, 16px);
  z-index: var(--z-toast, 90);
  padding: var(--space-3, 12px) var(--space-4, 16px);
  color: var(--text-inverse, #fff);
  background: var(--brand-primary, #012f6c);
  border-radius: var(--radius-button, 10px);
  transition: top var(--dur-base, 180ms) var(--ease-out, ease);
}

.skip-link:focus { top: var(--space-4, 16px); }

/* Visually hidden, still announced. Used for table action headers and for the
   textual summaries that back every chart. */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* [hidden] must beat any display rule a component sets, otherwise a component
   that is toggled off stays visible. */
[hidden] { display: none !important; }
