/* Base reset & foundational element styles */

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

* {
  margin: 0;
}

html {
  color-scheme: dark light;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Safety net against horizontal scroll/bleed from any single component's
     transient state (an off-screen pre-reveal translateX, a decorative
     glow's soft blur edge, etc.) — clip only the X axis so vertical
     scrolling is completely unaffected; overflow-y computes to auto here
     (the spec's paired-axis conversion), which behaves identically to the
     page's normal scroll for a non-hidden axis. */
  overflow-x: clip;
}

body {
  min-height: 100svh;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--color-text);
  background: var(--color-bg);
  font-weight: var(--fw-regular);
  transition: background-color var(--duration-base) var(--ease-out), color var(--duration-base) var(--ease-out);
}

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

img {
  border-style: none;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

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

a {
  color: inherit;
  text-decoration: none;
  text-decoration-thickness: from-font;
}

/* Inline links within body copy keep an underline — colour alone isn't a
   sufficient link affordance for accessibility (WCAG 1.4.1). Nav links,
   buttons, and cards are unambiguous from context/styling and stay plain. */
.legal-content a,
.checkbox-field a,
p a {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  line-height: var(--lh-tight);
  font-weight: var(--fw-semibold);
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

ul, ol {
  list-style: none;
  padding: 0;
}

table {
  border-collapse: collapse;
  width: 100%;
}

@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;
    scroll-behavior: auto !important;
  }
}

::selection {
  background: var(--color-accent-blue);
  color: #ffffff;
}

::-webkit-scrollbar {
  width: 12px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--color-border-strong);
  border-radius: var(--radius-full);
  border: 3px solid var(--color-bg);
}

:focus-visible {
  outline: 3px solid var(--color-accent-blue-strong);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: fixed;
  top: -100%;
  left: var(--space-sm);
  z-index: var(--z-skip-link);
  background: var(--color-accent-blue);
  color: #ffffff;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-weight: var(--fw-semibold);
  transition: top var(--duration-fast) var(--ease-out);
}

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

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Full-page loader (see partials/loader.php) --- */

.site-loader {
  position: fixed;
  inset: 0;
  z-index: var(--z-skip-link);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  transition: opacity var(--duration-slow) var(--ease-out), visibility var(--duration-slow) var(--ease-out);
}

.site-loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.site-loader__ring {
  position: absolute;
  width: 6.5rem;
  height: 6.5rem;
  border-radius: 50%;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent-blue);
  border-right-color: var(--color-accent-cyan);
  animation: site-loader-spin 1s linear infinite;
}

.site-loader__mark {
  width: 3.25rem;
  height: auto;
  animation:
    site-loader-enter 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both,
    site-loader-pulse 1.8s ease-in-out 0.6s infinite;
}

@keyframes site-loader-spin {
  to { transform: rotate(360deg); }
}

@keyframes site-loader-enter {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes site-loader-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.9); opacity: 0.8; }
}

@media (prefers-reduced-motion: reduce) {
  .site-loader__ring { animation: none; }
  .site-loader__mark { animation: site-loader-enter 0.3s ease-out both; }
}

/* --- Custom animated cursor (see js/cursor.js) ---
   Only ever active once cursor.js has confirmed a fine pointer AND no
   prefers-reduced-motion — .has-custom-cursor is added at that point, so
   the cursor:none rule below can never fire on a touch device or leave a
   visitor with no cursor at all if JS fails to load. */
.cursor-dot,
.cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  /* Above the full-page nav panel (calc(--z-toast + 10/15/20), see
     layout.css) — a cursor that vanishes behind the menu the moment it
     opens defeats the point of it. */
  z-index: calc(var(--z-toast) + 50);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out), width var(--duration-fast) var(--ease-out), height var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
}

.cursor-dot {
  width: 0.5rem;
  height: 0.5rem;
  margin: -0.25rem;
  border-radius: 50%;
  background: var(--color-accent-blue);
}

.cursor-ring {
  width: 2rem;
  height: 2rem;
  margin: -1rem;
  border-radius: 50%;
  border: 1.5px solid var(--color-accent-blue);
}

.cursor-ring.is-hover {
  width: 3.25rem;
  height: 3.25rem;
  margin: -1.625rem;
  border-color: var(--color-accent-cyan);
  background: color-mix(in srgb, var(--color-accent-blue) 12%, transparent);
}

.cursor-ring.is-active {
  width: 1.5rem;
  height: 1.5rem;
  margin: -0.75rem;
}

.has-custom-cursor,
.has-custom-cursor * {
  cursor: none !important;
}
