# Styling Guide

_Global fonts and responsive breakpoint system. For CMS/dashboard design tokens (colors, spacing, components), see [CMS_DESIGN_SYSTEM.md](./CMS_DESIGN_SYSTEM.md)._

This document outlines the global styling system for the AMSOIL Dealer Lead Pages application.

## Font Family System

### Inter Font (Global Default)

The application uses **Inter** as the primary font family, loaded via `next/font/google` for optimal performance.

#### Configuration

**Location:** `app/layout.tsx`

```typescript
import { Inter } from 'next/font/google';

const inter = Inter({
  subsets: ['latin'],
  display: 'swap',
  variable: '--font-inter',
});
```

#### Application

The font is applied globally via:

1. **CSS Variable:** `--font-inter` (available throughout the app)
2. **Body Class:** Applied to `<body className={inter.className}>`
3. **HTML Variable:** Applied to `<html className={inter.variable}>`

#### Usage

All text elements inherit Inter by default. No additional configuration is needed.

```tsx
// Inter is automatically applied
<p>This text uses Inter font</p>

// Or explicitly use the CSS variable
<div style={{ fontFamily: 'var(--font-inter)' }}>
  Custom styled text
</div>
```

---

## Responsive Breakpoints System

### Tailwind CSS Breakpoints

The application uses Tailwind CSS's standard breakpoint system for responsive design.

#### Standard Breakpoints

| Breakpoint       | Min Width | Device Target                    | Tailwind Prefix |
| ---------------- | --------- | -------------------------------- | --------------- |
| Mobile (default) | 0px       | Mobile portrait                  | _(no prefix)_   |
| `sm`             | 640px     | Mobile landscape                 | `sm:`           |
| `md`             | 768px     | Tablet portrait                  | `md:`           |
| `lg`             | 1024px    | Tablet landscape / Small desktop | `lg:`           |
| `xl`             | 1280px    | Desktop                          | `xl:`           |
| `2xl`            | 1536px    | Large desktop                    | `2xl:`          |

#### Configuration

**Location:** `tailwind.config.ts`

```typescript
theme: {
  extend: {
    screens: {
      // Standard Tailwind breakpoints (default)
      // 'sm': '640px',
      // 'md': '768px',
      // 'lg': '1024px',
      // 'xl': '1280px',
      // '2xl': '1536px',
    },
  },
}
```

#### Usage Examples

##### Mobile-First Approach (Recommended)

Tailwind uses a mobile-first approach. Styles apply to mobile by default, then override for larger screens.

```tsx
// Base styles apply to mobile, then override for larger screens
<div className="text-sm md:text-base lg:text-lg">
  Responsive text size
</div>

// Grid layout: 1 column on mobile, 2 on tablet, 4 on desktop
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
  <div>Card 1</div>
  <div>Card 2</div>
  <div>Card 3</div>
  <div>Card 4</div>
</div>

// Hidden on mobile, visible on tablet and up
<div className="hidden md:block">
  Desktop navigation
</div>

// Padding: small on mobile, medium on tablet, large on desktop
<section className="px-4 md:px-8 lg:px-12">
  Content
</section>
```

##### Flex Direction

```tsx
// Stack vertically on mobile, horizontal on desktop
<div className="flex flex-col lg:flex-row gap-4">
  <div>Sidebar</div>
  <div>Main content</div>
</div>
```

##### Container Widths

```tsx
// Full width on mobile, constrained on larger screens
<div className="w-full max-w-screen-sm md:max-w-screen-md lg:max-w-screen-lg mx-auto">
  Responsive container
</div>
```

---

## CSS Architecture

### File Structure

- **`app/globals.css`** - Global styles, Tailwind directives, CSS variables
- **`app/styles/registration-theme.css`** - Registration-specific theme styles
- **`app/layout.tsx`** - Font configuration and global layout

### Tailwind Configuration Files

- **`tailwind.config.ts`** - Tailwind configuration (theme, plugins, content paths)
- **`postcss.config.mjs`** - PostCSS configuration for Tailwind processing

---

## Custom CSS vs Tailwind

### When to Use Tailwind

Use Tailwind classes for:

- Layout (flex, grid, spacing)
- Responsive design (breakpoint prefixes)
- Common utilities (colors, typography, shadows)
- Rapid prototyping

```tsx
<button className="px-4 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600">Click me</button>
```

### When to Use Custom CSS

Use custom CSS for:

- Complex animations
- Gradient backgrounds with specific designs
- Component-specific styles that don't map to Tailwind utilities
- Existing styled components (landing page, registration flow)

```css
.hero-content {
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 32px;
  backdrop-filter: blur(12px);
}
```

---

## Best Practices

### 1. Prefer Tailwind for New Components

For new components, use Tailwind classes where possible for consistency and maintainability.

```tsx
// Good
<div className="flex flex-col gap-4 p-6 bg-slate-800 rounded-xl">
  <h2 className="text-2xl font-bold">Title</h2>
  <p className="text-slate-300">Description</p>
</div>

// Avoid (unless complex styling needed)
<div className="custom-card">
  <h2 className="custom-title">Title</h2>
  <p className="custom-description">Description</p>
</div>
```

### 2. Mobile-First Responsive Design

Always design for mobile first, then add breakpoints for larger screens.

```tsx
// Good - Mobile first
<div className="text-base lg:text-lg">Content</div>

// Avoid - Desktop first (requires more overrides)
<div className="text-lg sm:text-base">Content</div>
```

### 3. Use Semantic Breakpoints

Choose breakpoints based on content needs, not specific devices.

```tsx
// Good - Based on layout needs
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3">

// Avoid - Device-specific thinking
<div className="grid grid-cols-1 iphone:grid-cols-2 desktop:grid-cols-3">
```

### 4. Consistent Spacing

Use Tailwind's spacing scale for consistency.

```tsx
// Good - Consistent spacing scale
<div className="p-4 md:p-6 lg:p-8">

// Avoid - Arbitrary values (unless necessary)
<div className="p-[17px] md:p-[23px]">
```

---

## Migration Notes

### Existing Styles

The landing page (`index.html`) and registration pages use custom CSS. These can remain as-is or be gradually migrated to Tailwind as needed.

### Font Migration

The font system now uses:

- **`next/font/google`** for optimized font loading
- **CSS variable** `--font-inter` for flexible usage
- **Global application** via layout.tsx

Old references to `font-family: 'Inter'` in CSS will still work but now fallback to the optimized next/font version.

---

## Quick Reference

### Common Responsive Patterns

```tsx
// Responsive grid
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">

// Responsive text
<h1 className="text-2xl md:text-3xl lg:text-4xl">

// Responsive spacing
<section className="py-8 md:py-12 lg:py-16">

// Responsive flex direction
<div className="flex flex-col md:flex-row">

// Hide/show at breakpoints
<div className="block md:hidden">Mobile only</div>
<div className="hidden md:block">Desktop only</div>

// Responsive container
<div className="container mx-auto px-4 md:px-6 lg:px-8">
```

### Font Usage

```tsx
// Default (automatic)
<p>Uses Inter font automatically</p>

// Explicit CSS variable
<span style={{ fontFamily: 'var(--font-inter)' }}>Inter font</span>

// Tailwind class
<p className="font-sans">Uses Inter via Tailwind</p>
```

---

## Troubleshooting

### Font Not Loading

1. Verify `app/layout.tsx` imports and applies Inter correctly
2. Check that `--font-inter` CSS variable is present in browser DevTools
3. Ensure `globals.css` is imported in `layout.tsx`

### Tailwind Classes Not Working

1. Verify `tailwind.config.ts` includes correct content paths
2. Check that `@tailwind` directives are in `globals.css`
3. Restart the dev server after config changes
4. Clear `.next` cache: `rm -rf .next`

### Breakpoints Not Triggering

1. Ensure mobile-first approach (base styles, then larger breakpoints)
2. Check browser width in DevTools
3. Verify Tailwind config has correct breakpoint values
4. Use browser DevTools to inspect computed styles

---

## Resources

- [Tailwind CSS Documentation](https://tailwindcss.com/docs)
- [Next.js Font Optimization](https://nextjs.org/docs/pages/building-your-application/optimizing/fonts)
- [Responsive Design Best Practices](https://tailwindcss.com/docs/responsive-design)
