/* ==========================================================================
   Reset — Modern, accessibility-conscious
   Adapted from Andy Bell's modern CSS reset, with editorial refinements.
   ========================================================================== */

/* Use a more intuitive box-sizing model */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Remove default margins; rely on token-driven spacing */
* {
  margin: 0;
  padding: 0;
}

/* HTML & body defaults */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  hanging-punctuation: first last;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern", "liga", "clig", "calt";
  font-variant-ligatures: common-ligatures contextual;
}

/* Honour reduced motion */
@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;
  }
}

/* Set shorter line heights on headings and interactive elements */
h1,
h2,
h3,
h4,
h5,
h6,
button,
input,
label {
  line-height: 1.1;
}

/* Balance text wrapping on headings (Chrome 114+, Firefox 121+) */
h1,
h2,
h3,
h4 {
  text-wrap: balance;
}

/* Prose paragraphs — pretty wrap */
p,
li,
figcaption {
  text-wrap: pretty;
}

/* Inherit fonts on form controls */
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

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

/* Images, video, canvas — responsive defaults */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

img {
  font-style: italic;       /* alt text shown italicised when image fails */
  background-repeat: no-repeat;
  background-size: cover;
  shape-margin: 1rem;
}

/* Remove list styles on lists used as components */
ul[role="list"],
ol[role="list"] {
  list-style: none;
}

/* Anchor defaults — preserved at colour level via tokens */
a {
  color: inherit;
  text-decoration: none;
}

/* Anchors that aren't classed should still be readable */
a:not([class]) {
  text-decoration-skip-ink: auto;
  text-underline-offset: 0.2em;
}

/* Focus-visible — accessibility, editorial register */
:focus-visible {
  outline: 2px solid var(--colour-ochre);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Make sure textareas without a rows attribute aren't tiny */
textarea:not([rows]) {
  min-height: 10em;
}

/* Anything that has been anchored to should have extra scroll margin */
:target {
  scroll-margin-block: 5ex;
}

/* Skip-to-content link — visually hidden until focused */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-3);
  z-index: var(--z-modal);
  padding: var(--space-2) var(--space-4);
  background: var(--colour-ink);
  color: var(--colour-parchment);
  font-family: var(--font-body);
  font-size: var(--type-sm);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  transition: top var(--motion-fast) var(--ease-out);
}

.skip-link:focus {
  top: var(--space-3);
}

/* Visually hidden — accessible for screen readers */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Selection — ochre on parchment */
::selection {
  background: var(--colour-ochre);
  color: var(--colour-parchment);
}

/* Scrollbar — restrained */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--colour-mute);
  border: 3px solid var(--colour-parchment);
  border-radius: var(--radius-md);
}

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