#!/bin/bash

# Download Work Sans font files locally
# This script downloads the Work Sans font family and creates local CSS

FONT_DIR="src/assets/fonts"
CSS_FILE="src/assets/styles/fonts.css"

# Create fonts directory
mkdir -p "$FONT_DIR"

# Download Work Sans font files
echo "Downloading Work Sans font files..."

# Regular weights (300, 400, 500, 600, 700)
curl -o "$FONT_DIR/WorkSans-Light.ttf" "https://fonts.gstatic.com/s/worksans/v23/QGY_z_wNahGAdqQ43RhVcIgYT2Xz5u32KxfXNig.ttf"
curl -o "$FONT_DIR/WorkSans-Regular.ttf" "https://fonts.gstatic.com/s/worksans/v23/QGY_z_wNahGAdqQ43RhVcIgYT2Xz5u32K0nXNig.ttf"
curl -o "$FONT_DIR/WorkSans-Medium.ttf" "https://fonts.gstatic.com/s/worksans/v23/QGY_z_wNahGAdqQ43RhVcIgYT2Xz5u32K3vXNig.ttf"
curl -o "$FONT_DIR/WorkSans-SemiBold.ttf" "https://fonts.gstatic.com/s/worksans/v23/QGY_z_wNahGAdqQ43RhVcIgYT2Xz5u32K5fQNig.ttf"
curl -o "$FONT_DIR/WorkSans-Bold.ttf" "https://fonts.gstatic.com/s/worksans/v23/QGY_z_wNahGAdqQ43RhVcIgYT2Xz5u32K67QNig.ttf"

# Italic weights (300, 400, 500, 600, 700)
curl -o "$FONT_DIR/WorkSans-LightItalic.ttf" "https://fonts.gstatic.com/s/worksans/v23/QGY9z_wNahGAdqQ43Rh_ebrnlwyYfEPxPoGUgGsJow.ttf"
curl -o "$FONT_DIR/WorkSans-Italic.ttf" "https://fonts.gstatic.com/s/worksans/v23/QGY9z_wNahGAdqQ43Rh_ebrnlwyYfEPxPoGU3msJow.ttf"
curl -o "$FONT_DIR/WorkSans-MediumItalic.ttf" "https://fonts.gstatic.com/s/worksans/v23/QGY9z_wNahGAdqQ43Rh_ebrnlwyYfEPxPoGU7GsJow.ttf"
curl -o "$FONT_DIR/WorkSans-SemiBoldItalic.ttf" "https://fonts.gstatic.com/s/worksans/v23/QGY9z_wNahGAdqQ43Rh_ebrnlwyYfEPxPoGUAGwJow.ttf"
curl -o "$FONT_DIR/WorkSans-BoldItalic.ttf" "https://fonts.gstatic.com/s/worksans/v23/QGY9z_wNahGAdqQ43Rh_ebrnlwyYfEPxPoGUOWwJow.ttf"

echo "Font files downloaded to $FONT_DIR"

# Create local CSS file
cat > "$CSS_FILE" << 'EOF'
/* Work Sans font family - locally hosted */

@font-face {
  font-family: 'Work Sans';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('../fonts/WorkSans-Light.ttf') format('truetype');
}

@font-face {
  font-family: 'Work Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/WorkSans-Regular.ttf') format('truetype');
}

@font-face {
  font-family: 'Work Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/WorkSans-Medium.ttf') format('truetype');
}

@font-face {
  font-family: 'Work Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/WorkSans-SemiBold.ttf') format('truetype');
}

@font-face {
  font-family: 'Work Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/WorkSans-Bold.ttf') format('truetype');
}

@font-face {
  font-family: 'Work Sans';
  font-style: italic;
  font-weight: 300;
  font-display: swap;
  src: url('../fonts/WorkSans-LightItalic.ttf') format('truetype');
}

@font-face {
  font-family: 'Work Sans';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/WorkSans-Italic.ttf') format('truetype');
}

@font-face {
  font-family: 'Work Sans';
  font-style: italic;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/WorkSans-MediumItalic.ttf') format('truetype');
}

@font-face {
  font-family: 'Work Sans';
  font-style: italic;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/WorkSans-SemiBoldItalic.ttf') format('truetype');
}

@font-face {
  font-family: 'Work Sans';
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/WorkSans-BoldItalic.ttf') format('truetype');
}
EOF

echo "Local font CSS created at $CSS_FILE"
echo "Don't forget to update tailwind.css to import this file instead of Google Fonts!" 