/* ==========================================================================
   The Auto Lab — Base
   Reset, typography, layout primitives, utilities
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
  font-weight: 400;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse 80% 40% at 50% 0%, rgba(139, 197, 63, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse 60% 30% at 100% 100%, rgba(139, 197, 63, 0.03) 0%, transparent 60%);
  background-attachment: fixed;
}

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

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

button { background: none; border: 0; padding: 0; cursor: pointer; color: inherit; }

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

/* Subtle film grain on entire page (performance-friendly, no animation) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: var(--z-behind);
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.6 0'/></filter><rect width='200' height='200' filter='url(%23n)'/></svg>");
  background-size: 200px 200px;
}

/* --------- Typography --------- */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--lh-snug);
  letter-spacing: var(--tracking-tight);
  color: var(--text);
}

h1 { font-size: var(--fs-h1); line-height: var(--lh-tight); font-weight: 700; }
h2 { font-size: var(--fs-h2); line-height: var(--lh-tight); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-h4); }

p { margin: 0; color: var(--text-dim); }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--fs-eyebrow);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}
.eyebrow::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px 1px var(--accent-glow);
  flex-shrink: 0;
}

.chrome-text {
  background: var(--grad-chrome);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 20px rgba(201, 201, 206, 0.2));
}

.accent-text { color: var(--accent); }

/* --------- Layout --------- */
.container      { width: var(--container); margin-inline: auto; }
.container-wide { width: var(--container-wide); margin-inline: auto; }
.container-read { width: var(--container-read); margin-inline: auto; }

section {
  padding-block: var(--section-y);
  position: relative;
}

/* --------- Utilities --------- */
.hairline      { box-shadow: var(--shadow-inset); }
.hairline-strong { box-shadow: var(--shadow-inset-2); }
.elev          { box-shadow: var(--shadow-elev); }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* --------- Buttons (primary CTA components) --------- */
.btn {
  --btn-py: 14px;
  --btn-px: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: var(--btn-py) var(--btn-px);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  border-radius: var(--r-pill);
  transition: transform var(--d-ui) var(--ease-out),
              background var(--d-ui) var(--ease-out),
              box-shadow var(--d-ui) var(--ease-out),
              color var(--d-ui) var(--ease-out),
              border-color var(--d-ui) var(--ease-out);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  position: relative;
  isolation: isolate;
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.btn:active { transform: scale(0.97); }

/* Primary: accent fill, chrome text on dark accent */
.btn-primary {
  background: var(--accent);
  color: #0A1104;
  box-shadow: 0 1px 0 0 rgba(255,255,255,0.25) inset, 0 -1px 0 0 rgba(0,0,0,0.25) inset, 0 10px 30px -10px rgba(139,197,63,0.4);
}
.btn-primary:hover {
  background: var(--accent-hot);
  box-shadow: var(--glow-accent-lg), 0 1px 0 0 rgba(255,255,255,0.3) inset;
  transform: translateY(-1px);
}

/* Secondary: chrome outline */
.btn-secondary {
  background: transparent;
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border-emphasis);
}
.btn-secondary:hover {
  background: rgba(255,255,255,0.04);
  box-shadow: inset 0 0 0 1px var(--chrome-300);
  transform: translateY(-1px);
}

/* Tertiary / text button */
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  padding: 10px 16px;
}
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,0.04); }

.btn-icon { width: 16px; height: 16px; transition: transform var(--d-ui) var(--ease-out); }
.btn:hover .btn-icon { transform: translateX(2px); }

/* --------- Cards --------- */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-inset), var(--shadow-soft);
  transition: box-shadow var(--d-ui) var(--ease-out), transform var(--d-ui) var(--ease-out), background var(--d-ui) var(--ease-out);
}
.card:hover {
  box-shadow: var(--shadow-inset-2), var(--shadow-elev);
}

/* --------- Scroll reveal (always-visible baseline + optional entrance flash) ---------
 * Elements are always visible. When the IntersectionObserver adds
 * [data-reveal].is-visible during a real scroll, a brief CSS animation plays.
 * No blank page risk for no-JS, crawlers, or full-page screenshots.
 */
[data-reveal] {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: no-preference) {
  [data-reveal].is-visible {
    animation: revealIn var(--d-reveal) var(--ease-spring) both;
  }
}
@keyframes revealIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --------- Accessibility: Skip link --------- */
.skip-link {
  position: absolute; top: -100px; left: 12px;
  background: var(--accent); color: #0A1104;
  padding: 10px 16px; border-radius: var(--r-sm);
  font-weight: 600; z-index: var(--z-toast);
  transition: top var(--d-ui) var(--ease-out);
}
.skip-link:focus { top: 12px; outline: none; }

/* --------- Selection --------- */
::selection {
  background: var(--accent);
  color: #0A1104;
}

/* --------- Scrollbar (subtle, on-brand) --------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: var(--chrome-700);
  border-radius: var(--r-pill);
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--chrome-500); }
