/*!
 * CheckrideReady Base Layer
 * =========================
 * Modern reset, semantic element defaults, typography defaults, focus
 * rings, reduced-motion handling, selection/scrollbar styling.
 * Requires tokens.css to be loaded first. See README.md for load order.
 */

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

* {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: dark; /* fixes native form controls, scrollbars, date pickers */
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  min-height: 100dvh; /* never 100vh: avoids the iOS Safari viewport jump */
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

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

img,
video {
  height: auto;
}

img:not([alt]) {
  outline: 3px solid var(--red); /* loud, deliberate: catches a missing alt in review */
}

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

button {
  background: none;
  border: none;
  cursor: pointer;
  touch-action: manipulation; /* removes the 300ms double-tap-zoom delay */
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* =========================================================================
   TYPOGRAPHY DEFAULTS
   ========================================================================= */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-bright);
  line-height: 1.15;
  letter-spacing: -0.01em;
  text-wrap: balance; /* prevents orphaned single words on the last line */
}

h1 {
  font-size: var(--text-display);
  line-height: 1.05;
  letter-spacing: -0.02em;
}
h2 {
  font-size: var(--text-4xl);
}
h3 {
  font-size: var(--text-3xl);
}
h4 {
  font-size: var(--text-2xl);
}
h5 {
  font-size: var(--text-xl);
}
h6 {
  font-size: var(--text-lg);
}

p {
  max-width: 65ch; /* readable measure; components that need full-bleed text override this */
  text-wrap: pretty;
}

small {
  font-size: var(--text-sm);
  color: var(--text-dim);
}

strong,
b {
  font-weight: 600;
}

code,
kbd,
pre,
samp {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* Numeric data (stats, scores, timers) should never jitter as digits change
   width -- this is a cockpit-style tool with a lot of live numbers. */
.tabular-nums,
[data-numeric] {
  font-variant-numeric: tabular-nums;
}

/* =========================================================================
   FOCUS-VISIBLE
   Every interactive element gets a visible, high-contrast keyboard focus
   ring. Never suppressed without a same-strength replacement.
   ========================================================================= */
:focus {
  outline: none; /* replaced below by :focus-visible, never left bare */
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* Compound controls (a labeled checkbox row, a search field with a button
   inside it) get one ring around the whole group instead of a ring per
   child, so keyboard focus reads as one hit target. */
.focus-group:focus-within {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* =========================================================================
   SELECTION
   ========================================================================= */
::selection {
  background: var(--amber-dim);
  color: var(--text-bright);
}

::-moz-selection {
  background: var(--amber-dim);
  color: var(--text-bright);
}

/* =========================================================================
   SCROLLBARS
   ========================================================================= */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-2);
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
  background-clip: content-box;
}

/* =========================================================================
   REDUCED MOTION
   Global backstop. Individual components in components.css still scope
   their own transitions, but this guarantees nothing in base.css ever
   animates for a user who has asked for reduced motion, even if a future
   edit forgets to wrap it locally.
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* =========================================================================
   UTILITIES relied on by every page
   ========================================================================= */
.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;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: var(--z-toast);
  background: var(--amber);
  color: var(--text-on-accent);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm);
  transition: top var(--duration-base) var(--ease-out);
}

.skip-link:focus-visible {
  top: var(--space-4);
  outline: 2px solid var(--text-on-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .skip-link {
    transition: none;
  }
}
