/* Base Styles
 * ==========================================================================
 * Foundation styles for the entire application
 */

/* Root Typography
 * -------------------------------------------------------------------------- */

:root {
  /* Base font size - 18px for better readability */
  font-size: 16px;

  /* Typography scale - Named system mapping to Open Props */
  --font-size-x-small: var(--font-size-0); /* 0.75rem / 13.5px */
  --font-size-small: var(--font-size-1); /* 1rem / 18px */
  --font-size-medium: var(--font-size-2); /* 1.1rem / 19.8px */
  --font-size-large: var(--font-size-4); /* 1.5rem / 27px */
  --font-size-x-large: var(--font-size-6); /* 2.5rem / 45px */
  --font-size-xx-large: var(--font-size-8); /* 3.5rem / 63px */

  /* Fluid font sizes mapping to Open Props fluid scales */
  --font-size-fluid-small: var(--font-size-fluid-0); /* fluid 0.75rem - 1rem */
  --font-size-fluid-medium: var(--font-size-fluid-1); /* fluid 1rem - 1.5rem */
  --font-size-fluid-large: var(--font-size-fluid-2); /* fluid 1.5rem - 2.5rem */
  --font-size-fluid-x-large: var(--font-size-fluid-3); /* fluid 2rem - 3.5rem */

  /* Line heights */
  --line-height-tight: 1.25;
  --line-height-base: 1.6;
  --line-height-relaxed: 1.75;

  /* Font families */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-serif: Georgia, Cambria, "Times New Roman", Times, serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;

  /* Border Radius Scale (inspired by Open Props) */
  --radius-small: 0.25rem;    /* 4.5px - buttons, inputs */
  --radius-medium: 0.5rem;     /* 9px - cards, modals */
  --radius-large: 0.75rem;     /* 13.5px - larger cards */
  --radius-xlarge: 1rem;       /* 18px - hero sections */
  --radius-round: 50%;         /* circular elements */
  --radius-pill: 9999px;       /* pill-shaped elements */

  /* Spacing Scale (inspired by Open Props) */
  --space-1: 0.25rem;          /* 4.5px */
  --space-2: 0.5rem;           /* 9px */
  --space-3: 0.75rem;          /* 13.5px */
  --space-4: 1rem;             /* 18px */
  --space-5: 1.5rem;           /* 27px */
  --space-6: 2rem;             /* 36px */
  --space-7: 3rem;             /* 54px */
  --space-8: 4rem;             /* 72px */
  --space-9: 6rem;             /* 108px */
}

/* Base Document Styles
 * -------------------------------------------------------------------------- */

html {
  /* Smooth scrolling */
  scroll-behavior: smooth;

  /* Prevent font size adjustments in iOS */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;

  /* Better text rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  /* Base typography */
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  font-weight: 400;

  /* Colors from our design system */
  background: var(--color-bg--canvas);
  color: var(--color-ink--canvas);

  /* Reset margins */
  margin: 0;
  padding: 0;

  /* Minimum height */
  min-height: 100vh;
}

/* Typography Elements
 * -------------------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 600;
  line-height: var(--line-height-tight);
}

/* Visual heading size classes */
.h1 {
  font-size: var(--font-size-xx-large);
  font-weight: 700;
}

.h2 {
  font-size: var(--font-size-x-large);
}

.h3 {
  font-size: var(--font-size-large);
}

.h4 {
  font-size: var(--font-size-medium);
}

.h5 {
  font-size: var(--font-size-small);
}

.h6 {
  font-size: var(--font-size-x-small);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

p {
  margin: 0 0 1rem;
}

/* Links
 * -------------------------------------------------------------------------- */

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 200ms ease;
}

a:hover {
  text-decoration: underline;
}

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

/* Lists
 * -------------------------------------------------------------------------- */

ul, ol {
  margin: 0 0 1rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.25rem;
}

/* Code
 * -------------------------------------------------------------------------- */

code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 0.875em; /* Slightly smaller than body text */
}

code {
  padding: 0.125rem 0.25rem;
  background: oklch(from var(--color-bg--surface) l c h / 0.5);
  border-radius: 0.25rem;
}

pre {
  display: block;
  padding: 1rem;
  margin: 0 0 1rem;
  overflow-x: auto;
  background: var(--color-bg--surface);
  border-radius: 0.5rem;
}

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

/* Forms
 * -------------------------------------------------------------------------- */

input, textarea, select, button {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

/* Tables
 * -------------------------------------------------------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

th, td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border--light);
}

th {
  font-weight: 600;
}

/* Horizontal Rule
 * -------------------------------------------------------------------------- */

hr {
  border: none;
  border-top: 1px solid var(--color-border--light);
  margin: 2rem 0;
}

/* Images
 * -------------------------------------------------------------------------- */

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

/* Selection
 * -------------------------------------------------------------------------- */

::selection {
  background: oklch(from var(--color-primary) l c h / 0.2);
  color: var(--color-ink--canvas);
}

/* Focus visible only for keyboard navigation
 * -------------------------------------------------------------------------- */

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

/* Responsive Typography
 * -------------------------------------------------------------------------- */

@media (max-width: 40em) {
  :root {
    font-size: 16px; /* Slightly smaller on mobile for better content density */
  }

  h1 {
    font-size: var(--font-size-3xl);
  }

  h2 {
    font-size: var(--font-size-2xl);
  }

  h3 {
    font-size: var(--font-size-xl);
  }
}