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

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

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

  /* Typography scale */
  --font-size-x-small: 0.75rem;
  --font-size-small: 1rem;
  --font-size-medium: 1.1rem;
  --font-size-large: 1.5rem;
  --font-size-x-large: 2.5rem;
  --font-size-xx-large: 3.5rem;

  /* Fluid font sizes */
  --font-size-fluid-small: clamp(0.75rem, 2vw, 1rem);
  --font-size-fluid-medium: clamp(1rem, 4vw, 1.5rem);
  --font-size-fluid-large: clamp(1.5rem, 6vw, 2rem);
  --font-size-fluid-x-large: clamp(2rem, 8vw, 3rem);

  /* 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 */
  --radius-none: 0;             /* no rounding */
  --radius-extra-small: 0.125rem; /* 2px */
  --radius-small: 0.25rem;     /* 4px - buttons, inputs */
  --radius-medium: 0.5rem;     /* 8px - cards, modals */
  --radius-large: 0.75rem;     /* 12px - larger cards */
  --radius-extra-large: 1.5rem; /* 24px - hero sections */
  --radius-xlarge: 1rem;       /* 16px - hero sections */
  --radius-round: 50%;         /* circular elements */
  --radius-pill: 9999px;       /* pill-shaped elements */

  /* Easing Functions */
  --ease-3: cubic-bezier(0.25, 0, 0.3, 1);
  --ease-out-3: cubic-bezier(0, 0, 0.3, 1);
  --ease-out-5: cubic-bezier(0, 0, 0, 1);
  --ease-in-out-3: cubic-bezier(0.35, 0, 0.35, 1);
  --ease-squish-2: cubic-bezier(0.5, -0.3, 0.1, 1.5);

  /* 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);
  }
}