/**
 * Base Styles
 * ===========
 * CSS reset and foundational typography
 * Built on design tokens from variables.css
 */

/* ─────────────────────────────────────────────────────────────
 * CSS RESET - Modern minimal reset
 * ───────────────────────────────────────────────────────────── */

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

/* Remove default margin and padding */
* {
  margin: 0;
  padding: 0;
}

/* Prevent font size inflation */
html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}

/* Set core root defaults */
html:focus-within {
  scroll-behavior: smooth;
}

/* Set core body defaults */
body {
  min-height: 100vh;
  font-family: var(--font-family);
  font-size: var(--text-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Remove list styles on ul, ol elements with a list role */
ul[role='list'],
ol[role='list'] {
  list-style: none;
}

/* A elements that don't have a class get default styles */
a:not([class]) {
  text-decoration-skip-ink: auto;
  color: currentColor;
}

/* Make images easier to work with */
img,
picture,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Inherit fonts for inputs and buttons */
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

/* Avoid text overflows */
h1, h2, h3, h4, h5, h6,
p {
  overflow-wrap: break-word;
}

/* Remove all animations and transitions for people that prefer not to see them */
@media (prefers-reduced-motion: reduce) {
  html:focus-within {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ─────────────────────────────────────────────────────────────
 * TYPOGRAPHY - Headings
 * ───────────────────────────────────────────────────────────── */

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

h1 {
  font-size: var(--text-4xl);
  letter-spacing: -0.025em;
}

h2 {
  font-size: var(--text-3xl);
  letter-spacing: -0.02em;
}

h3 {
  font-size: var(--text-2xl);
  letter-spacing: -0.015em;
}

h4 {
  font-size: var(--text-xl);
}

h5 {
  font-size: var(--text-lg);
}

h6 {
  font-size: var(--text-base);
  font-weight: var(--font-weight-medium);
}

/* ─────────────────────────────────────────────────────────────
 * TYPOGRAPHY - Body Text
 * ───────────────────────────────────────────────────────────── */

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

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

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

strong, b {
  font-weight: var(--font-weight-semibold);
}

em, i {
  font-style: italic;
}

/* ─────────────────────────────────────────────────────────────
 * LINKS
 * ───────────────────────────────────────────────────────────── */

a {
  color: var(--color-secondary);
  text-decoration: none;
  transition: var(--transition-colors);
}

a:hover {
  color: var(--color-secondary-dark);
  text-decoration: underline;
}

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

a:active {
  color: var(--color-secondary-dark);
}

/* ─────────────────────────────────────────────────────────────
 * BUTTON RESET
 * ───────────────────────────────────────────────────────────── */

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

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

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

/* ─────────────────────────────────────────────────────────────
 * LISTS
 * ───────────────────────────────────────────────────────────── */

ul, ol {
  padding-left: var(--space-6);
  margin-bottom: var(--space-4);
}

ul:last-child,
ol:last-child {
  margin-bottom: 0;
}

li {
  margin-bottom: var(--space-2);
}

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

/* Nested lists */
ul ul, ul ol,
ol ul, ol ol {
  margin-top: var(--space-2);
  margin-bottom: 0;
}

/* ─────────────────────────────────────────────────────────────
 * CODE & PREFORMATTED TEXT
 * ───────────────────────────────────────────────────────────── */

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

code {
  background-color: var(--gray-100);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

pre {
  background-color: var(--gray-100);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

pre code {
  background: none;
  padding: 0;
}

/* ─────────────────────────────────────────────────────────────
 * BLOCKQUOTE
 * ───────────────────────────────────────────────────────────── */

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

/* ─────────────────────────────────────────────────────────────
 * HORIZONTAL RULE
 * ───────────────────────────────────────────────────────────── */

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

/* ─────────────────────────────────────────────────────────────
 * TABLES
 * ───────────────────────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-4);
}

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

th {
  font-weight: var(--font-weight-semibold);
  background-color: var(--gray-50);
}

/* ─────────────────────────────────────────────────────────────
 * FORM ELEMENTS - Basic Resets
 * ───────────────────────────────────────────────────────────── */

input,
textarea,
select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: var(--color-bg);
  transition: var(--transition-colors), border-color var(--transition-fast);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.15);
}

input::placeholder,
textarea::placeholder {
  color: var(--color-text-muted);
}

label {
  display: block;
  font-weight: var(--font-weight-medium);
  margin-bottom: var(--space-2);
}

/* ─────────────────────────────────────────────────────────────
 * SELECTION
 * ───────────────────────────────────────────────────────────── */

::selection {
  background-color: var(--color-secondary);
  color: var(--color-text-inverse);
}

/* ─────────────────────────────────────────────────────────────
 * FOCUS VISIBLE
 * ───────────────────────────────────────────────────────────── */

:focus:not(:focus-visible) {
  outline: none;
}

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