/* ============================================================
   Base Styles — Reset, Typography, Global Elements
   ============================================================ */

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

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

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  transition: background-color var(--transition-base), color var(--transition-base);
}

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

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

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

ul, ol {
  list-style: none;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
}

h1 {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-6);
}

h2 {
  font-size: var(--text-2xl);
  margin-top: var(--space-12);
  margin-bottom: var(--space-4);
}

h3 {
  font-size: var(--text-xl);
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
}

h4 {
  font-size: var(--text-lg);
  margin-top: var(--space-6);
  margin-bottom: var(--space-2);
}

/* ---- Article Content ---- */
.article-content p {
  margin-bottom: var(--space-paragraph);
  line-height: var(--leading-normal);
}

.article-content ul,
.article-content ol {
  margin-bottom: var(--space-paragraph);
  padding-left: var(--space-6);
}

.article-content ul {
  list-style: disc;
}

.article-content ol {
  list-style: decimal;
}

.article-content li {
  margin-bottom: var(--space-2);
  line-height: var(--leading-normal);
}

.article-content li::marker {
  color: var(--color-text-tertiary);
}

.article-content blockquote {
  border-left: 3px solid var(--color-brand);
  padding: var(--space-4) var(--space-6);
  margin-bottom: var(--space-paragraph);
  background: var(--color-bg-secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--color-text-secondary);
}

.article-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.15em 0.4em;
  background: var(--color-code-bg);
  border-radius: 4px;
  color: var(--color-brand);
}

.article-content pre {
  margin-bottom: var(--space-paragraph);
  padding: var(--space-4);
  background: var(--color-code-bg);
  border-radius: var(--radius-md);
  overflow-x: auto;
  border: 1px solid var(--color-border-light);
}

.article-content pre code {
  padding: 0;
  background: none;
  color: var(--color-text);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.article-content img {
  margin: var(--space-6) 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.article-content hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-section) 0;
}

.article-content table {
  width: 100%;
  margin-bottom: var(--space-paragraph);
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.article-content th,
.article-content td {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  text-align: left;
}

.article-content th {
  background: var(--color-bg-secondary);
  font-weight: var(--weight-semibold);
}

.article-content a {
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--color-brand-subtle);
}

.article-content a:hover {
  text-decoration-color: var(--color-brand);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

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

/* ---- Selection ---- */
::selection {
  background: var(--color-brand-subtle);
  color: var(--color-text);
}

/* ---- Focus ---- */
:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---- Skip Link ---- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: var(--space-2);
  z-index: var(--z-tooltip);
  padding: var(--space-2) var(--space-4);
  background: var(--color-brand);
  color: white;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

.skip-link:focus {
  left: var(--space-4);
}
