/* ==========================================================================
   Base — reset, typographic defaults, accessibility floor
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ivory);
  font-family: var(--sans);
  font-size: var(--t-base);
  line-height: var(--lh-body);
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-weight: 700;
  line-height: var(--lh-snug);
  letter-spacing: var(--track-snug);
  margin: 0;
  text-wrap: balance;
  /* Long unbreakable product names ("CapitaStar@Work") would otherwise push
     the page wider than a 320px viewport. */
  overflow-wrap: break-word;
}

p { margin: 0; }
a { color: inherit; }

img, svg, video {
  display: block;
  max-width: 100%;
  height: auto;
}

ul, ol { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; }

/* Visible focus everywhere, but only for keyboard users. */
:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection {
  background: var(--amber);
  color: var(--canvas);
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  top: var(--s-2);
  left: var(--s-2);
  z-index: 100;
  padding: var(--s-2) var(--s-3);
  background: var(--ivory);
  color: var(--canvas);
  font-size: var(--t-sm);
  font-weight: 600;
  border-radius: var(--r-pill);
  text-decoration: none;
  transform: translateY(-180%);
  transition: transform 0.2s var(--ease);
}
.skip-link:focus { transform: translateY(0); }

/* Anchor jumps (#work, #services, #contact) have to clear the sticky
   masthead, or the heading they land on sits behind it. */
main[id], section[id], article[id] { scroll-margin-top: var(--anchor-offset); }

/* Reduced motion, tier two.
   The token overrides in tokens.css have already collapsed every reveal to a
   short cross-fade with no travel. All that is left globally is the scroll
   behaviour; the genuinely vestibular pieces - looping ambience, parallax,
   the marquee - are switched off in a `reduce` block next to each component,
   so it stays obvious which rule turns which effect off.

   Note what is deliberately NOT here: the old blanket `*` rule that killed
   every transition on the site. It also flattened hover and focus feedback,
   which made the interface feel broken rather than calm. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ==========================================================================
   Cross-page transitions
   ==========================================================================
   Turns a nine-page static site into something that feels continuous. Pure
   progressive enhancement: browsers without the View Transition API simply
   navigate as they always did. Deliberately NOT paired with a JavaScript
   fade-out fallback - that would delay every click by the animation, and
   strand anyone on a blank page if the navigation stalled. */

@view-transition { navigate: auto; }

::view-transition-old(root) {
  animation: page-out 180ms var(--ease) both;
}
::view-transition-new(root) {
  animation: page-in 340ms var(--ease-out) both;
}
@keyframes page-out { to { opacity: 0; } }
@keyframes page-in { from { opacity: 0; transform: translateY(10px); } }

/* The wordmark is the one fixed point between pages, so it stays put rather
   than cross-fading with everything else. */
.wordmark { view-transition-name: wordmark; }

/* The artwork a work card grows into. The name is put on the card's image by
   site.js at the moment of the click, so only ever one pair is matched. */
.cs-figure--lead img { view-transition-name: work-shot; }

::view-transition-group(work-shot) {
  animation-duration: 460ms;
  animation-timing-function: var(--ease-out);
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-new(root) { animation: page-in-still 140ms linear both; }
  @keyframes page-in-still { from { opacity: 0; } }
}
