/* ==========================================================================
   MECAS Techsolutions - Base
   --------------------------------------------------------------------------
   Reset, element defaults, accessibility primitives. No component styling and
   no layout here. Loads after tokens.css and bootstrap-grid, before
   components.css.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Reset
   -------------------------------------------------------------------------- */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Anchor targets clear the sticky header instead of hiding under it. */
  scroll-padding-top: calc(var(--header-h) + var(--space-4));
}

@media (max-width: 991.98px) {
  html { scroll-padding-top: calc(var(--header-h-mobile) + var(--space-4)); }
}

body,
h1, h2, h3, h4, h5, h6,
p, figure, blockquote, dl, dd,
ul, ol { margin: 0; }

ul[class],
ol[class] {
  padding: 0;
  list-style: none;
}

body {
  min-height: 100vh;
  margin: 0;
  background-color: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Backstop against horizontal scroll. `clip` rather than `hidden` on purpose:
   `hidden` turns the body into a scroll container, which silently breaks
   position:sticky on the header. No `hidden` fallback is provided - layout
   rules must not overflow in the first place, and they are verified not to. */
@supports (overflow: clip) {
  body { overflow-x: clip; }
}

/* --------------------------------------------------------------------------
   2. Media
   -------------------------------------------------------------------------- */

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* No blanket `svg { fill: currentColor }` here. A CSS declaration beats the
   `fill="none"` presentation attribute on the tag, so a blanket rule silently
   floods every outline icon solid - which is exactly what happened to the
   button icons. Fill is set per component instead: outline icons declare
   `fill: none; stroke: currentColor`, solid glyphs declare `fill: currentColor`. */

/* Note: do NOT add `img[width][height] { height: auto }` here. Browsers already
   derive an aspect-ratio from the width/height attributes, so the rule buys
   nothing - and at specificity (0,2,1) it silently beats any single-class rule
   that sets an explicit height, which is how the header logo ended up
   rendering at its natural size. */

/* --------------------------------------------------------------------------
   3. Typography
   -------------------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--ink-heading);
  font-weight: var(--fw-bold);
  line-height: var(--lh-heading);
  letter-spacing: var(--ls-heading);
  /* Headings in this design are short and must not break mid-word. */
  overflow-wrap: break-word;
}

h1 { font-size: var(--fs-title); line-height: var(--lh-display); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-h4); }
h5, h6 { font-size: var(--fs-body); }

p { overflow-wrap: break-word; }

p + p { margin-top: var(--space-4); }

strong, b { font-weight: var(--fw-semibold); }

small { font-size: var(--fs-small); }

/* Body copy sits at a readable measure. Wide containers must not produce
   80-character-plus lines. */
.measure     { max-width: 62ch; }
.measure-sm  { max-width: 48ch; }

a {
  color: var(--color-action);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease);
}

a:hover { color: var(--color-action-hover); }

/* Links inside prose stay underlined. Navigation and buttons opt out. */
.prose a {
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

/* --------------------------------------------------------------------------
   4. Forms - normalisation only. Styling lives in components.css.
   -------------------------------------------------------------------------- */

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button { background: none; border: none; cursor: pointer; }

textarea { resize: vertical; }

/* --------------------------------------------------------------------------
   5. Accessibility
   -------------------------------------------------------------------------- */

/* Visible focus for keyboard users only. Mouse clicks do not draw a ring. */
:focus { outline: none; }

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Older browsers with no :focus-visible support still get a ring. */
@supports not selector(:focus-visible) {
  :focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
  }
}

.skip-link {
  position: absolute;
  top: 0;
  left: var(--space-4);
  z-index: var(--z-modal);
  padding: var(--space-3) var(--space-5);
  background: var(--navy-700);
  color: var(--ink-inverse);
  font-family: var(--font-heading);
  font-size: var(--fs-button);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-button);
  text-transform: uppercase;
  border-radius: 0 0 var(--radius) var(--radius);
  transform: translateY(-110%);
  transition: transform var(--duration) var(--ease);
}

.skip-link:focus-visible {
  transform: translateY(0);
  color: var(--ink-inverse);
}

/* Available to assistive technology, removed from the visual layout. */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --------------------------------------------------------------------------
   6. Selection and scrollbar
   -------------------------------------------------------------------------- */

::selection {
  background: var(--blue-100);
  color: var(--ink-heading);
}

/* --------------------------------------------------------------------------
   7. Print - the enquiry form and nav are not useful on paper.
   -------------------------------------------------------------------------- */

@media print {
  .site-header,
  .site-footer,
  .cta-band,
  .skip-link { display: none !important; }

  body { color: #000; background: #fff; }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
  }
}

/* --------------------------------------------------------------------------
   8. Utilities driven by main.js
   -------------------------------------------------------------------------- */

/* Scroll reveal. The hidden state keys off `reveal-ready`, which main.js sets
   only once it has actually started observing. If the script fails to load or
   throws, the class never lands and every section simply stays visible - the
   `js` class alone would have hidden content with nothing left to reveal it. */
.reveal-ready [data-reveal] {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 480ms var(--ease),
    transform 480ms var(--ease);
}

.reveal-ready [data-reveal].is-revealed {
  opacity: 1;
  transform: none;
}

/* Page must not scroll behind the open mobile nav panel. */
body.nav-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .reveal-ready [data-reveal] {
    opacity: 1;
    transform: none;
    transition: none;
  }
}
