/* ==========================================================================
   Base: reset, browser surfaces, layout primitives
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--color-text-subtle) var(--color-bg);
  scroll-behavior: smooth;   /* in-page links (the footer's "back to top") glide instead of jumping */
}

body {
  margin: 0;
  background: var(--color-surface);   /* every page is white; the warm tones live in the bands (sand scale, tokens.css) */
  color: var(--color-text);
  font: var(--fw-regular) var(--fs-base) / var(--lh-body) var(--font-family);
  caret-color: var(--color-accent);
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
address { font-style: normal; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }

::selection { background: var(--color-accent); color: var(--color-white); }
:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-offset); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0s !important; }
  html { scroll-behavior: auto; }
}

/* ---- Container ---- */
.container {
  width: min(var(--container-max), 100% - var(--container-gutter) * 2);
  margin-inline: auto;
}

/* ---- Media: every image lives in one of these ----
   The wrapper owns width + aspect-ratio; the image just fills it.
   Usage: <div class="media media--square"><img ...></div>            */
.media {
  position: relative;
  display: block;   /* also on <a> and <span> wrappers */
  overflow: hidden;
  aspect-ratio: var(--ratio, 1);
  border-radius: var(--media-radius, var(--radius-md));
  background: var(--color-placeholder);
}
.media > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--focus, 50% 50%);
  transition: transform var(--duration-slow) var(--ease-out), filter var(--duration-base) var(--ease-out);
}
.media--square { --ratio: 1; }
.media--portrait { --ratio: 4 / 5; }
.media--landscape { --ratio: 5 / 4; }
.media--wide { --ratio: 16 / 9; }
.media--hero { --ratio: 21 / 10; }   /* matches the 3105×1470 banner photos */
.media--fill { aspect-ratio: auto; height: 100%; }   /* when a grid cell sets the size */
.media--flat { --media-radius: 0; }
.media--lg { --media-radius: var(--radius-lg); }
.media--sm { --media-radius: var(--radius-sm); }

/* Skeleton: a light sweeps across the wrapper until its image has loaded, then fades away.
   main.js marks the wrapper .is-loaded (one listener for the whole page, so every image,
   including ones added later, gets it with nothing to add in the markup). Only under
   html.has-js: without scripts the wrapper keeps its plain placeholder colour. */
.has-js .media::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(100deg, transparent 30%, var(--skeleton-shine) 50%, transparent 70%) var(--color-placeholder);
  background-size: 250% 100%;
  animation: skeleton-sweep var(--duration-skeleton) linear infinite;
  transition: opacity var(--duration-base) var(--ease-out);
  pointer-events: none;
}
.has-js .media.is-loaded::before { opacity: 0; animation: none; }
@keyframes skeleton-sweep { from { background-position: 100% 0; } to { background-position: -150% 0; } }
.has-js[dir="rtl"] .media::before { animation-direction: reverse; }   /* the light follows the reading direction */

/* Fields on touch screens: iPhone and iPad zoom the whole page into a field whose text is under
   16px, so on touch screens every field is at least 16px (!important: it must beat each
   component's own size, e.g. the header search). Mouse screens keep the design's sizes. */
@media (pointer: coarse) {
  input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="submit"], [type="button"]),
  select,
  textarea { font-size: max(16px, 1em) !important; }
}

/* Hover zoom, opt-in on the clickable parent */
.zoom:hover .media > img { transform: scale(var(--zoom-scale)); }

/* ---- Icons (SVG sprite: assets/sprite.svg) ---- */
.icon {
  width: var(--icon-size);
  height: var(--icon-size);
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: var(--icon-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon--sm { --icon-size: var(--icon-size-sm); }
.icon--lg { --icon-size: 30px; }
/* The sprite arrow points right (→). In RTL it means "back", and .icon--flip turns it into "forward".
   In LTR the meanings swap, so a plain arrow is mirrored and a flipped one is left as drawn. */
.icon--flip { transform: scaleX(-1); }
.icon--arrow:dir(ltr) { transform: scaleX(-1); }
.icon--arrow.icon--flip:dir(ltr) { transform: none; }

/* ---- Utilities ---- */
.num { font-variant-numeric: tabular-nums; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
