# NovaPure – .htaccess
# Ensures correct MIME types, charset, and headers for all browsers and Cloudflare

# ──────────────────────────────────────────
# 1. MIME TYPES (critical for CSS/JS to load)
# ──────────────────────────────────────────
<IfModule mod_mime.c>
    AddType text/css;charset=UTF-8                 .css
    AddType application/javascript;charset=UTF-8   .js
    AddType text/html;charset=UTF-8                .html .htm
    AddType image/png                              .png
    AddType image/jpeg                             .jpg .jpeg
    AddType image/webp                             .webp
    AddType image/x-icon                           .ico
    AddType image/svg+xml                          .svg
    AddCharset UTF-8 .html .htm .css .js
</IfModule>

# ──────────────────────────────────────────
# 2. CHARSET (force UTF-8 everywhere)
# ──────────────────────────────────────────
<IfModule mod_charset.c>
    CharsetDefault UTF-8
    CharsetSourceEnc UTF-8
</IfModule>

AddDefaultCharset UTF-8

# ──────────────────────────────────────────
# 3. HEADERS (prevent caching of broken files)
# ──────────────────────────────────────────
<IfModule mod_headers.c>
    # Force browsers to always fetch CSS fresh on first load
    <FilesMatch "\.(css|js)$">
        Header set Cache-Control "public, max-age=3600"
    </FilesMatch>
    # HTML pages: no cache
    <FilesMatch "\.html?$">
        Header set Cache-Control "no-cache, no-store, must-revalidate"
        Header set Pragma "no-cache"
        Header set Expires "0"
    </FilesMatch>
    # Security headers
    Header set X-Content-Type-Options "nosniff"
    Header set X-Frame-Options "SAMEORIGIN"
    Header set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>

# ──────────────────────────────────────────
# 4. COMPRESSION (optional performance boost)
# ──────────────────────────────────────────
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/css application/javascript
</IfModule>

# ──────────────────────────────────────────
# 5. DIRECTORY INDEX
# ──────────────────────────────────────────
DirectoryIndex index.html

# ──────────────────────────────────────────
# 6. PREVENT ACCESS TO HIDDEN FILES
# ──────────────────────────────────────────
<FilesMatch "^\.">
    Order allow,deny
    Deny from all
</FilesMatch>
