/* OMFC International | base.css: reset, focus styles, themes, layout grid, type utilities,
   text and scroll reveals, reduced motion. */


/* === 1. Reset =========================================================== */

/* Width and height include padding and border, which makes sizing predictable */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;

  /* Dark behind everything, so overscroll "bounce" never flashes white */
  background: var(--graphite);

  /* In-page links stop below the fixed header instead of underneath it */
  scroll-padding-top: calc(var(--header-h) + var(--header-top) * 2);

  /* Never scroll sideways, even when something (like the enquiry stamp) pokes past the edge.
     Set on html as well for phones; hidden is the fallback where clip is unsupported. */
  overflow-x: hidden;
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100vh;

  /* clip (unlike hidden) creates no scroll container, so position: sticky keeps working */
  overflow-x: clip;

  background: var(--stone);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: 400;
  font-stretch: 100%;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Media elements behave like blocks and never overflow their container */
img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

/* Remove default margins; spacing is set per component */
h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd,
ol,
ul {
  margin: 0;
}

/* Lists are used for structure; bullets and numbers are added in CSS where needed */
ol,
ul {
  padding: 0;
  list-style: none;
}

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

/* Form controls inherit the page typography */
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
}

/* The hidden attribute always wins, even over display rules on components */
[hidden] {
  display: none !important;
}

::selection {
  background: var(--hivis);
  color: var(--ink);
}


/* === 2. Focus styles: none for mouse clicks, always visible for keyboard focus === */

:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--hivis);
  outline-offset: 3px;
}

/* Hi-vis is not visible enough on light backgrounds, so use ink there */
[data-theme="light"] :focus-visible,
.enquire :focus-visible,
.case :focus-visible {
  outline-color: var(--ink);
}


/* === 3. Scrollbar (mouse and trackpad only) ============================= */

@media (pointer: fine) {
  /* Firefox */
  html {
    scrollbar-width: thin;
    scrollbar-color: var(--steel) var(--graphite);
  }

  /* Chrome, Edge and Safari */
  ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
  }

  ::-webkit-scrollbar-track {
    background: var(--graphite);
  }

  ::-webkit-scrollbar-thumb {
    background: var(--graphite-3);
    border: 3px solid var(--graphite);
  }

  ::-webkit-scrollbar-thumb:hover {
    background: var(--steel);
  }
}


/* === 4. Themes: data-theme="dark" or "light" sets text colour, --line and --muted === */

[data-theme="dark"] {
  --line: var(--line-on-dark);
  --muted: var(--muted-on-dark);
  color: var(--bone);
}

[data-theme="light"] {
  --line: var(--line-on-light);
  --muted: var(--muted-on-light);
  color: var(--ink);
}


/* === 5. Layout grid: 12 columns, 8 below 1024px, 4 below 768px ========== */

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--gutter);
  width: 100%;
  max-width: calc(var(--max) + var(--margin) * 2);
  margin-inline: auto;
  padding-inline: var(--margin);
}

@media (max-width: 1023px) {
  .grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}


/* === 6. Type utilities ================================================== */

/* Small monospaced uppercase label, like the annotations on a drawing */
.label {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
}

/* Photograph captions and other small print */
.caption {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: var(--muted);
}

/* Visually hidden, but still read by screen readers */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Invisible scroll target (used by #top) */
.anchor {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
}


/* === 7. Skip link: hidden above the screen until focused ================ */

.skip-link {
  position: fixed;
  z-index: calc(var(--z-cursor) + 1);
  top: var(--s-3);
  left: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--hivis);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  transform: translateY(-160%);
  transition: transform var(--dur-2) var(--ease-out);
}

.skip-link:focus-visible {
  transform: none;
  outline-color: var(--ink);
}


/* === 8. Text link: underline draws in on hover (a background image, so it wraps with the text) === */

.text-link {
  position: relative;
  display: inline-block;
  padding-bottom: 0.1em;
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-size: 0% 1px;
  background-position: 100% 100%;
  transition: background-size var(--dur-3) var(--ease-out);
}

.text-link:hover,
.text-link:focus-visible {
  background-size: 100% 1px;
  background-position: 0% 100%;
}


/* === 9. Split-line reveals: splitLines() in ui.js wraps each line of [data-split] in a mask === */

.split-line {
  display: block;
  overflow: clip;

  /* Room for descenders (g, j, p, q, y) inside the mask */
  padding-bottom: 0.08em;
  margin-bottom: -0.08em;
}

.split-line > span {
  display: inline-block;
  will-change: auto;
}

/* Words never break inside themselves while lines are measured (e.g. "fire-rated") */
.split-w {
  white-space: nowrap;
}

/* Hide the text until it has been split, so it never flashes unstyled */
.js [data-split]:not(.is-split) {
  visibility: hidden;
}


/* === 10. Scroll reveals: [data-reveal] gets .is-in when in view (ui.js); --delay staggers siblings === */

/* Default: fade and rise */
.js [data-reveal] {
  transition:
    opacity var(--dur-4) var(--ease-out),
    transform var(--dur-4) var(--ease-out);
  transition-delay: var(--delay, 0s);
}

.js [data-reveal]:not(.is-in) {
  opacity: 0;
  transform: translateY(1.25rem);
}

/* data-reveal="unit": a photograph lowered into its frame from the top */
.js [data-reveal="unit"] {
  clip-path: inset(0 0 0 0);
  transition: clip-path 1.2s var(--ease-in-out);
}

.js [data-reveal="unit"]:not(.is-in) {
  opacity: 1;
  transform: none;
  clip-path: inset(100% 0 0 0);
}

.js [data-reveal="unit"] img {
  transition: transform 1.6s var(--ease-out);
}

.js [data-reveal="unit"]:not(.is-in) img {
  transform: scale(1.14) translateY(4%);
}


/* === 11. Reduced motion: instant transitions and no reveals (JavaScript checks motionOK()) === */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .js [data-reveal]:not(.is-in),
  .js [data-reveal="unit"]:not(.is-in) {
    opacity: 1;
    transform: none;
    clip-path: none;
  }
}
