/* Base styles - typography and base elements */
@layer base {
  body {
    /* Use system font stack for instant rendering (no font loading CLS) */
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--color-text);
    background-color: var(--color-bg);
    font-size: 1rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Sticky footer layout */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
  }

  /* Typography scale with better rhythm */
  h1, h2, h3, h4, h5, h6 {
    line-height: 1.25;
    font-weight: 600;
    color: var(--color-text);
    letter-spacing: -0.02em;
    margin-bottom: var(--space-md);
  }

  h1 {
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.03em;
  }
  h2 { font-size: 1.75rem; }
  h3 { font-size: 1.375rem; }
  h4 { font-size: 1.125rem; }
  h5 { font-size: 1rem; }
  h6 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
  }

  p {
    margin-block: var(--space-md);
    line-height: 1.7;
  }

  /* Better link styling */
  a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-fast);
  }

  a:hover {
    color: var(--color-primary-dark);
  }

  /* Small/muted text */
  small, .text-small {
    font-size: 0.875rem;
    color: var(--color-text-muted);
  }

  /* Strong emphasis */
  strong, b {
    font-weight: 600;
  }

  /* Container - responsive layout wrapper */
  .container {
    container-type: inline-size;
    width: 100%;
    max-width: 1200px;
    margin-inline: auto;
    padding-inline: var(--space-lg);
  }

  @media (min-width: 768px) {
    .container {
      padding-inline: var(--space-xl);
    }
  }

  @media (min-width: 1024px) {
    .container {
      padding-inline: var(--space-2xl);
    }
  }

  /* Main content area */
  main {
    flex: 1;
    padding-block: var(--space-xl);
    /* Offset for fixed header */
    margin-top: var(--header-height);
  }

  /* Remove padding and margin for landing page (landing handles its own offset) */
  main:has(.landing) {
    padding-block: 0;
    margin-top: 0;
  }

  @media (min-width: 768px) {
    main {
      padding-block: var(--space-2xl);
    }

    main:has(.landing) {
      padding-block: 0;
    }
  }

  /* Focus states for accessibility with smooth transition */
  :focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
    transition: outline-offset var(--duration-fast) var(--ease-out);
  }

  /* Page content fade-in animation (opacity only to avoid CLS) */
  @keyframes fadeIn {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }

  /* Apply subtle fade-in to main content */
  main {
    animation: fadeIn var(--duration-slow) var(--ease-out) both;
  }

  /* Selection styling */
  ::selection {
    background-color: var(--color-primary);
    color: white;
  }

  /* Horizontal rule */
  hr {
    border: none;
    height: 1px;
    background-color: var(--color-border);
    margin-block: var(--space-xl);
  }

  /* Code styling */
  code {
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
    font-size: 0.875em;
    background-color: var(--color-bg-muted);
    padding: 0.125em 0.375em;
    border-radius: var(--radius-sm);
    color: var(--color-primary-dark);
  }
}
