/* ==========================================================================
   base.css — Tokens, board finishes, KiCad layer states, reset & typography
   ========================================================================== */

:root,
html[data-board="green"] {
  /* 8px spatial rhythm */
  --s1: 4px;
  --s2: 8px;
  --s3: 16px;
  --s4: 24px;
  --s5: 32px;
  --s6: 48px;
  --s7: 64px;
  --s8: 96px;
  --wrap: 1240px;
  --gutter: clamp(16px, 4vw, 48px);

  /* Fonts */
  --f-sans: 'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --f-disp: 'Big Shoulders Display', Impact, sans-serif;
  --f-stencil: 'Big Shoulders Stencil Display', 'Big Shoulders Display', sans-serif;
  --f-mono: 'Martian Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Classic ENIG Green Solder Mask */
  --bg: #0c3b2b;
  --bg-elev: #104936;
  --bg-deep: #07261b;
  --bg-card: rgba(7, 34, 24, 0.78);
  --trace-under: #17654a;
  --silk: #eef3e6;
  --silk-dim: #b6c9bc;
  --silk-faint: rgba(238, 243, 230, 0.2);
  --silk-rule: rgba(238, 243, 230, 0.14);

  /* Exposed ENIG Gold & Copper */
  --gold: #e6c274;
  --gold-hi: #f8dfa1;
  --gold-lo: #9b7830;
  --copper: #d98850;

  /* Epoxy IC body (always dark thermoset resin) */
  --ic: #131615;
  --ic-elev: #1b201e;
  --ic-edge: #2c3330;
  --ic-ink: #eef3e6;
  --ic-dim: #9aa89f;

  /* Status LEDs */
  --led-ok: #5be38b;
  --led-warn: #f4bf4f;
  --led-hot: #ff6b4a;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-snap: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html[data-board="black"] {
  --bg: #141619;
  --bg-elev: #1c1f24;
  --bg-deep: #0b0d0f;
  --bg-card: rgba(12, 14, 17, 0.82);
  --trace-under: #262b33;
  --silk: #f2f4f7;
  --silk-dim: #a3acb8;
  --silk-faint: rgba(242, 244, 247, 0.18);
  --silk-rule: rgba(242, 244, 247, 0.12);
}

html[data-board="blue"] {
  --bg: #0f3178;
  --bg-elev: #153e96;
  --bg-deep: #081d4a;
  --bg-card: rgba(8, 26, 68, 0.8);
  --trace-under: #2152ba;
  --silk: #f0f5ff;
  --silk-dim: #b3c5ea;
  --silk-faint: rgba(240, 245, 255, 0.2);
  --silk-rule: rgba(240, 245, 255, 0.14);
}

html[data-board="red"] {
  --bg: #6b1616;
  --bg-elev: #821c1c;
  --bg-deep: #430c0c;
  --bg-card: rgba(62, 11, 11, 0.8);
  --trace-under: #9e2929;
  --silk: #fff4f2;
  --silk-dim: #e4bbb6;
  --silk-faint: rgba(255, 244, 242, 0.2);
  --silk-rule: rgba(255, 244, 242, 0.14);
}

html[data-board="white"] {
  --bg: #e6e3d8;
  --bg-elev: #efede4;
  --bg-deep: #d3cfc2;
  --bg-card: rgba(255, 253, 247, 0.86);
  --trace-under: #cfc8b6;
  --silk: #161917;
  --silk-dim: #4a504c;
  --silk-faint: rgba(22, 25, 23, 0.2);
  --silk-rule: rgba(22, 25, 23, 0.13);
  --gold: #a97718;
  --gold-hi: #cf9830;
  --gold-lo: #6e4c0b;
}

/* Raw FR-4 fiberglass substrate when F.Mask (solder mask) is unchecked */
html.no-mask {
  --bg: #7c5f28;
  --bg-elev: #8d6d30;
  --bg-deep: #584219;
  --bg-card: rgba(54, 40, 14, 0.82);
  --trace-under: #d49040;
  --silk: #fff8e8;
  --silk-dim: #e5d2ab;
  --silk-faint: rgba(255, 248, 232, 0.24);
  --silk-rule: rgba(255, 248, 232, 0.16);
  --gold: #f0b860;
}

/* KiCad Layer Toggles */
html.hide-copper .bus,
html.hide-copper .chip-pin,
html.hide-copper .via-pad,
html.hide-copper .gold-pad,
html.hide-copper .edge-finger-pad {
  opacity: 0.07 !important;
  transition: opacity 0.25s ease;
}

html.hide-silk .silk,
html.hide-silk .sec-head .ref,
html.hide-silk .sec-head .idx {
  opacity: 0.08 !important;
  transition: opacity 0.25s ease;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
  -webkit-text-size-adjust: 100%;
  background-color: var(--bg-deep);
  color: var(--silk);
  font-family: var(--f-sans);
  font-size: 16px;
  line-height: 1.6;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--silk);
  overflow-x: clip;
  transition: background-color 0.3s ease, color 0.3s ease;
}

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

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

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

p,
h1,
h2,
h3,
h4,
dl,
dd,
figure,
pre {
  margin: 0;
}

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

/* Accessibility & Skip Link */
.skip {
  position: fixed;
  top: -100px;
  left: var(--s3);
  z-index: 9999;
  padding: var(--s2) var(--s3);
  background: var(--gold);
  color: #111;
  font-family: var(--f-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 4px;
  transition: top 0.2s ease;
}

.skip:focus {
  top: var(--s3);
  outline: 2px solid var(--silk);
  outline-offset: 2px;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

::selection {
  background: var(--gold);
  color: #121514;
}

/* Layout container */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--gutter);
  position: relative;
  z-index: 2;
}

/* Silkscreen monospace utility labels */
.label {
  font-family: var(--f-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.4;
}

.dim {
  color: var(--silk-dim);
}

/* Scroll reveal states (24fps stepped progressive enhancement) */
html.js [data-reveal].will-reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s steps(12, end), transform 0.5s steps(12, end);
}

html.js [data-reveal].is-in {
  opacity: 1;
  transform: translateY(0);
}

/* Reduced Motion overrides */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html.js [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
  }
}

html[data-motion="off"] {
  scroll-behavior: auto;
}

html[data-motion="off"] *,
html[data-motion="off"] *::before,
html[data-motion="off"] *::after {
  animation-play-state: paused !important;
  transition-duration: 0.01ms !important;
}

html[data-motion="off"] [data-reveal] {
  opacity: 1 !important;
  transform: none !important;
}
