/* ==========================================================================
   TUOIL — base: reset, document typography, layout primitives
   ========================================================================== */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

/* Lenis drives the scroll; the native smooth behaviour must not fight it. */
html.lenis,
html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

body {
  margin: 0;
  background-color: var(--c-cream);
  color: var(--c-ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Scroll lock for the slide-out menu. The compensation value is written by
   JS so the page does not jump when the scrollbar disappears. */
body.is-locked {
  overflow: hidden;
  padding-right: var(--scrollbar-width, 0px);
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-heading);
  letter-spacing: var(--ls-heading);
  text-wrap: balance;
  overflow-wrap: break-word; /* a long chemical name on a phone */
}

h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-h4); font-family: var(--font-body); }

p { margin: 0 0 var(--sp-2); }
p:last-child { margin-bottom: 0; }

a {
  color: inherit;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  text-underline-offset: 0.18em;
  transition: color var(--dur-fast) var(--ease-out),
              text-decoration-color var(--dur-fast) var(--ease-out);
}

img, video, svg { display: block; max-width: 100%; }
img, video { height: auto; }

ul, ol { margin: 0; padding: 0; }
li { list-style: none; }

button { font: inherit; color: inherit; }

table { border-collapse: collapse; width: 100%; }

address { font-style: normal; }

/* --- Focus ---------------------------------------------------------------
   Always visible, never removed. Two-tone so it survives on cream, on the
   olive panel and on photography alike. */
:focus-visible {
  outline: 2px solid var(--c-ink);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}
.is-dark :focus-visible,
[data-theme='dark'] :focus-visible {
  outline-color: var(--c-on-dark);
}

/* --- Layout primitives ---------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

.section { padding-block: var(--section-pad); }

/* Anchored sections must clear the fixed header when jumped to. */
:target { scroll-margin-top: 112px; }

.section__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}

.section__title { max-width: 22ch; }

.section__intro {
  max-width: 56ch;
  font-size: var(--fs-lead);
  color: var(--c-muted);
}

/* --- Helpers -------------------------------------------------------------- */
.u-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: var(--sp-1);
  left: var(--sp-1);
  z-index: var(--z-skip);
  padding: var(--sp-1) var(--sp-2);
  background: var(--c-base);
  color: var(--c-on-dark);
  font-size: var(--fs-small);
  transform: translateY(-200%);
  transition: transform var(--dur-fast) var(--ease-out);
}
.skip-link:focus-visible { transform: translateY(0); }

/* --- Motion preference ----------------------------------------------------
   One switch. Decorative and automatic motion stops, elements sit at their
   final state, parallax and video autoplay are disabled in JS. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }

  [data-animate] {
    opacity: 1 !important;
    transform: none !important;
  }
}
