@layer reset, base, theme, components, utilities;

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

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

  /* Remove default margin and padding */
  body,
  h1,
  h2,
  h3,
  h4,
  p,
  figure,
  blockquote,
  dl,
  dd {
    margin: 0;
    padding: 0;
  }

  /* Remove list styles on ul, ol elements */
  ul,
  ol {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  /* Set core body defaults */
  body {
    min-block-size: 100vh;
    text-rendering: optimizeSpeed;
    line-height: 1.5;
  }

  /* Make images easy to work with */
  img,
  picture {
    max-inline-size: 100%;
    block-size: auto;
    display: block;
  }

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

  /* Remove all animations, transitions and smooth scroll 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;
    }
  }
}

@layer base {
  :root {
    /* Color Tokens - Tier 1 */
    --color-bg-dark: #06070d;
    --color-bg-light: #0d0f1a;
    --color-cyan: #00f2fe;
    --color-cyan-glow: rgba(0, 242, 254, 0.15);
    --color-purple: #a855f7;
    --color-purple-glow: rgba(168, 85, 247, 0.15);
    --color-blue: #3b82f6;
    --color-blue-glow: rgba(59, 130, 246, 0.15);
    --color-green: #10b981;
    --color-yellow: #f59e0b;
    --color-red: #ef4444;
    
    --color-white: #ffffff;
    --color-gray-100: #f8fafc;
    --color-gray-200: #e2e8f0;
    --color-gray-300: #cbd5e1;
    --color-gray-400: #94a3b8;
    --color-gray-600: #475569;
    --color-gray-800: #1e293b;
    --color-gray-900: #0f172a;

    /* Semantic Tokens - Tier 2 */
    --theme-bg: var(--color-bg-dark);
    --theme-bg-alt: var(--color-bg-light);
    --theme-surface: rgba(15, 18, 32, 0.65);
    --theme-surface-hover: rgba(22, 26, 46, 0.8);
    --theme-border: rgba(255, 255, 255, 0.06);
    --theme-border-hover: rgba(255, 255, 255, 0.12);
    
    --text-primary: var(--color-gray-100);
    --text-secondary: var(--color-gray-400);
    --text-muted: #64748b;
    
    --font-sans: 'Inter', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
    --font-mono: 'Fira Code', 'Courier New', monospace;

    /* Spacing & Sizes - Tier 3 */
    --container-width: 1200px;
    --header-height: 80px;
    --border-radius-sm: 8px;
    --border-radius-md: 16px;
    --border-radius-lg: 24px;
    
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  }

  html {
    scroll-behavior: smooth;
    scroll-padding-top: var(--header-height);
    background-color: var(--theme-bg);
    color: var(--text-primary);
    font-family: var(--font-sans);
    overflow-x: hidden;
  }

  body {
    background-image: 
      radial-gradient(circle at 10% 20%, rgba(168, 85, 247, 0.05) 0%, transparent 40%),
      radial-gradient(circle at 90% 80%, rgba(0, 242, 254, 0.05) 0%, transparent 40%);
    background-attachment: fixed;
    font-size: 1rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
  }

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

  ::-webkit-scrollbar-track {
    background: var(--theme-bg);
  }

  ::-webkit-scrollbar-thumb {
    background: var(--color-gray-800);
    border-radius: 5px;
    border: 2px solid var(--theme-bg);
    transition: var(--transition-fast);
  }

  ::-webkit-scrollbar-thumb:hover {
    background: var(--color-gray-600);
  }

  /* Selection styling */
  ::selection {
    background-color: rgba(0, 242, 254, 0.3);
    color: var(--color-white);
  }

  /* Core Layout Classes */
  .container {
    width: 100%;
    max-width: var(--container-width);
    margin-inline: auto;
    padding-inline: 24px;
  }

  /* Grid helper */
  .grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: 32px;
  }

  .grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: 32px;
  }

  .grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    gap: 24px;
  }
}
