/* ============================================
   JSONLab - Base Reset & Typography
   ============================================ */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 1rem;
}

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color var(--transition-base), color var(--transition-base);
  overflow-x: hidden;
}

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

button, input, optgroup, select, textarea {
  font-family: inherit;
  font-size: 100%;
  line-height: 1.65;
  color: inherit;
  margin: 0;
}

button, select {
  text-transform: none;
}

button, [type="button"], [type="reset"], [type="submit"] {
  -webkit-appearance: button;
  appearance: button;
  background: none;
  border: none;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--text-link-hover);
}

a:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

ul, ol {
  list-style: none;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -0.03em; }
h2 { font-size: clamp(1.5rem, 3.5vw, 2.125rem); letter-spacing: -0.02em; }
h3 { font-size: clamp(1.125rem, 2.5vw, 1.375rem); }
h4 { font-size: 1.0625rem; }
h5 { font-size: 0.9375rem; }
h6 { font-size: 0.8125rem; }

p {
  margin-bottom: var(--space-4);
  color: var(--text-secondary);
}

p:last-child { margin-bottom: 0; }

strong, b { font-weight: 600; }

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

code {
  background: var(--bg-tertiary);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}

pre {
  background: var(--bg-code);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  border: 1px solid var(--border-primary);
}

pre code {
  background: transparent;
  padding: 0;
  font-size: 0.8125rem;
  line-height: 1.65;
}

hr {
  border: none;
  border-top: 1px solid var(--border-primary);
  margin: var(--space-6) 0;
}

blockquote {
  border-left: 3px solid var(--brand-primary);
  padding-left: var(--space-4);
  margin: var(--space-4) 0;
  color: var(--text-secondary);
  font-style: italic;
}

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

th, td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-primary);
}

th {
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-secondary);
}

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

::selection {
  background: rgba(91,106,191,0.2);
  color: var(--text-primary);
}

/* Scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-secondary) transparent;
}

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

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

*::-webkit-scrollbar-thumb {
  background: var(--border-secondary);
  border-radius: var(--radius-full);
  border: 2px solid transparent;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--brand-primary);
  color: white;
  padding: var(--space-3) var(--space-4);
  border-radius: 0 0 var(--radius-md) 0;
  z-index: var(--z-toast);
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: 0;
  color: white;
}

/* Utility classes */
.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;
}

.text-gradient {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.mono { font-family: var(--font-mono); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.hidden { display: none !important; }
