/* base.css — reset, typography, focus ring, skip link, utilities, reduced-motion global rule.
   Load after tokens.css. Owner: Creative. Component styles live in components.css (Engineering). */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--nav-h) + var(--space-4));
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  font-weight: var(--fw-regular);
  font-feature-settings: "cv11", "ss01"; /* Inter Tight single-storey a, open digits */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

img, svg, video, canvas, picture { display: block; max-width: 100%; }
img, video { height: auto; }
img { font-style: italic; } /* alt text reads as text if the image fails */
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled, [aria-disabled="true"] { cursor: not-allowed; }
a { color: var(--accent); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
table { border-collapse: collapse; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }
hr { border: 0; border-top: var(--border-w) solid var(--border); margin: var(--space-6) 0; }
[hidden] { display: none !important; }
:where(h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd, ul, ol) { margin: 0; }
:where(ul, ol)[role="list"], :where(ul, ol).list-reset { list-style: none; padding: 0; }

/* ---------- typography ---------- */
:where(h1, h2, h3, h4) { font-weight: var(--fw-semibold); line-height: var(--lh-snug); letter-spacing: var(--tracking-heading); text-wrap: balance; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-base); }
p { max-width: var(--measure); text-wrap: pretty; }
small, .text-sm { font-size: var(--fs-sm); }
strong, b { font-weight: var(--fw-semibold); }
code, kbd, samp { font-family: var(--font-mono); font-size: 0.92em; }

.display { font-size: var(--fs-display); line-height: var(--lh-tight); letter-spacing: var(--tracking-display); font-weight: var(--fw-semibold); }
.lead { font-size: var(--fs-md); color: var(--text-2); }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.label { /* mono caps: stage names and field-set labels only */
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  line-height: 1.2;
}
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum", "cv11"; } /* money, dates, counts */

/* ---------- focus: one ring everywhere (3:1 against ground, accent-driven) ---------- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus { outline: none; }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: var(--ring-w) solid var(--focus);
  outline-offset: var(--ring-offset);
  border-radius: var(--radius-xs);
}
/* On accent-filled controls the ring flips to the text colour so it never vanishes into the fill. */
:where(.btn--primary, [data-on-accent]):focus-visible { outline-color: var(--text); box-shadow: 0 0 0 calc(var(--ring-offset) + var(--ring-w)) var(--bg); }
::selection { background: var(--accent-fill); color: var(--on-accent); }

/* ---------- skip link ---------- */
.skip-link {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-skip);
  padding: var(--space-3) var(--space-4);
  min-height: var(--tap);
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius-sm);
  font-weight: var(--fw-semibold);
  text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* ---------- utilities ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.container { width: min(100% - 2 * var(--gutter), var(--w-client)); margin-inline: auto; }
.container--app { width: min(100% - 2 * var(--gutter), var(--w-app)); margin-inline: auto; }
.container--invoice { width: min(100% - 2 * var(--gutter), var(--w-invoice)); margin-inline: auto; }
.stack > * + * { margin-top: var(--stack, var(--space-4)); }
.stack-2 { --stack: var(--space-2); } .stack-3 { --stack: var(--space-3); }
.stack-4 { --stack: var(--space-4); } .stack-6 { --stack: var(--space-6); } .stack-8 { --stack: var(--space-8); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap, var(--space-3)); }
.row { display: flex; align-items: center; gap: var(--gap, var(--space-3)); }
.row--between { justify-content: space-between; }
.hairline { border: var(--border-w) solid var(--border); }
.surface { background: var(--surface); border: var(--border-w) solid var(--border); border-radius: var(--radius-lg); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tap { min-height: var(--tap); min-width: var(--tap); }
.photo { filter: var(--photo-grade); } /* every photo gets the same warm grade */
.accent-text { color: var(--accent); }
.accent-fill { background: var(--accent-fill); color: var(--on-accent); }
.section { padding-block: var(--section-y); }

/* page grain (hero only; opt in with class="grain") */
.grain { position: relative; isolation: isolate; }
.grain::after {
  content: "";
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* Print: homeowners print the invoice. */
@media print {
  html { scroll-behavior: auto; }
  body { background: #fff; color: #000; }
  .no-print, .skip-link, nav { display: none !important; }
  a { color: inherit; }
}

/* ---------- reduced motion: global, last word ----------
   Components should not need their own opt-out. Scroll-scrubbed / auto-playing motion is also
   disabled in JS via matchMedia('(prefers-reduced-motion: reduce)') (see motion-spec.md). */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
}
/* Forced colours (Windows high contrast): keep borders and focus visible. */
@media (forced-colors: active) {
  :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 2px solid Highlight; }
  .surface, .hairline { border-color: CanvasText; }
}
