/* ============================================================
   VIWANDA AUTOMOTIVE - Base
   Reset, typography, layout primitives, utilities.
   Loads after tokens.css. Reads tokens only - never a raw ramp value.
   ============================================================ */

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

/* Any class that sets its own display beats the browser's [hidden] rule -
   same specificity, author stylesheet wins - so an element marked hidden
   could still be on screen. The quote form's Previous step button was,
   on step one, where there is nothing to go back to. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;   /* sticky header clearance for #anchors */
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }
ul[class], ol[class] { list-style: none; margin: 0; padding: 0; }

img, picture, video, canvas, svg { display: block; max-width: 100%; }
img, video { height: auto; }

input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }

table { border-collapse: collapse; }

/* ---------- headings ---------- */
/* Restrained, not bold. The display face carries size and spacing, not
   weight: nothing above 500, so headings read as considered rather than
   shouted, and the photographs stay the loudest thing on the page. */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-variation-settings: "wght" 450, "wdth" 100;
  font-weight: 450;
  line-height: var(--lh-tight);
  letter-spacing: var(--tr-display);
  text-wrap: balance;
}
h5, h6 {
  font-family: var(--font-display);
  font-variation-settings: "wght" 500, "wdth" 100;
  font-weight: 500;
  line-height: var(--lh-snug);
  letter-spacing: var(--tr-tight);
}
h1 { font-size: var(--step-6); }
h2 { font-size: var(--step-4); }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); }
h5 { font-size: var(--step-0); }
h6 { font-size: var(--step--1); }

/* ---------- text ---------- */
p { text-wrap: pretty; }
p + p { margin-top: var(--sp-4); }

a {
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
  transition: color var(--dur-1) var(--ease),
              text-decoration-color var(--dur-1) var(--ease);
}
a:hover { color: var(--accent-2); text-decoration-color: currentColor; }

strong, b { font-weight: 500; color: var(--text); }
em, i { font-style: italic; }
small { font-size: var(--step--1); }

hr {
  border: 0;
  height: var(--hairline);
  background: var(--border);
  margin: var(--sp-6) 0;
}

code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 0.92em;
  letter-spacing: var(--tr-mono);
}

::selection { background: var(--accent); color: var(--on-accent); }

/* ---------- focus ----------
   Never remove the ring without replacing it. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}
:focus:not(:focus-visible) { outline: none; }

/* ---------- layout primitives ---------- */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.wrap--narrow { max-width: 860px; }

.section { padding-block: var(--section-y); }
.section--sunk { background: var(--bg-sunk); }
.section--ruled { border-top: var(--hairline) solid var(--border); }

/* vertical rhythm without margin collapse */
.stack { display: flex; flex-direction: column; }
.stack > * + * { margin-top: var(--flow, var(--sp-4)); }
.stack--tight  { --flow: var(--sp-2); }
.stack--loose  { --flow: var(--sp-6); }

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap, var(--sp-3));
  align-items: center;
}

.grid {
  display: grid;
  gap: var(--gap, var(--sp-5));
  grid-template-columns: repeat(auto-fit, minmax(min(var(--col, 260px), 100%), 1fr));
}

/* anything holding running text, code or a table in a flex/grid track */
.min0 { min-width: 0; }

/* Off-screen sections cost nothing until they scroll in.
   The placeholder height matters more than it looks. A section that really
   stands 4300px tall but is guessed at 600px makes the page jump ~3700px the
   moment it renders, which on a phone reads as the scroll fighting your
   thumb. `auto` remembers the real height after the first render, so the
   guess only has to be close for the FIRST pass down the page.

   Measured, not guessed: each section carries its own real height at a
   phone width and a desktop width, written onto it by
   tools/qa/cv-measure.js  ->  style="--cv-sm:1746px;--cv-lg:2930px".
   This used to be a list of rules by section id, which covered only the
   sections that had ids and went stale with every layout change - the
   services page had none, and jumped on every first scroll. */
.cv-auto {
  content-visibility: auto;
  contain-intrinsic-size: auto var(--cv-lg, 900px);
}
@media (max-width: 760px) {
  .cv-auto { contain-intrinsic-size: auto var(--cv-sm, var(--cv-lg, 900px)); }
}

/* ---------- type utilities ---------- */
.lede {
  font-size: var(--step-1);
  line-height: var(--lh-body);
  color: var(--text-2);
  max-width: var(--maxw-text);
}
.prose { max-width: var(--maxw-text); }

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tr-mono);
}
/* the job-card register: section numerals, codes, hours, torque */
.label {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.num { font-variant-numeric: tabular-nums; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.eyebrow::after {
  content: "";
  flex: 1;
  height: var(--hairline);
  background: var(--border);
}
.eyebrow b { color: var(--accent); font-weight: 500; }

.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.text-accent { color: var(--accent); }
.text-signal { color: var(--signal); }

/* the standing bilingual lockup */
.sw {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: var(--tr-tight);
}

/* ---------- a11y ---------- */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: calc(-1 * var(--sp-10));
  z-index: var(--z-modal);
  background: var(--surface);
  color: var(--text);
  border: var(--hairline) solid var(--border-2);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  transition: top var(--dur-2) var(--ease);
}
.skip-link:focus-visible { top: var(--sp-4); }

/* ---------- reveal + failsafe ----------
   [data-anim] starts hidden and motion.js adds .in per element as it
   scrolls into view. Three ways it can end up visible anyway:

     1. no JS at all        -> html never gets .js-anim    -> visible
     2. motion.js never ran -> partials.js' 2.5s timer adds
                               .anim-failsafe              -> visible
     3. reduced motion      -> visible, no transform

   Without this a single dropped request over metered 3G leaves a blank
   page, which is a real failure mode in this market, not a theoretical one. */
[data-anim] {
  opacity: 0;
  transition: opacity var(--dur-3) var(--ease-out),
              transform var(--dur-3) var(--ease-out);
  will-change: opacity, transform;
}
[data-anim="up"]    { transform: translateY(18px); }
[data-anim="left"]  { transform: translateX(-18px); }
[data-anim="right"] { transform: translateX(18px); }
[data-anim="scale"] { transform: scale(.97); }
[data-anim].in { opacity: 1; transform: none; }

html:not(.js-anim) [data-anim],
html.anim-failsafe [data-anim] {
  opacity: 1;
  transform: none;
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  [data-anim] { opacity: 1 !important; transform: none !important; transition: none !important; }
}

/* ---------- print ----------
   A quote or job card printed from the site should be ink on paper. */
@media print {
  :root {
    --bg: #FFFFFF; --bg-sunk: #FFFFFF; --surface: #FFFFFF;
    --surface-2: #FFFFFF; --surface-3: #FFFFFF;
    --text: #000000; --text-2: #333333; --text-3: #555555;
    --border: #BBBBBB; --border-2: #999999;
    --accent: #000000; --accent-2: #000000; --signal: #000000;
    --shadow-1: none; --shadow-2: none; --shadow-3: none;
    color-scheme: light;
  }
  /* body already paints from --bg / --text, so the tokens above are enough */
  .site-header, .site-footer, .skip-link, [data-noprint] { display: none !important; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; }
}
