# Canonical host + HTTPS (mirrors the redirect in next.config.ts, which
# only applies on the Vercel build — static hosting needs its own rule).
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.techdirectsupport\.com\.au$ [NC]
RewriteRule ^ https://techdirectsupport.com.au%{REQUEST_URI} [L,R=301]

# Security headers (mirrors headers() in next.config.ts, which only applies on Vercel).
<IfModule mod_headers.c>
  Header always set X-Content-Type-Options "nosniff"
  Header always set X-Frame-Options "SAMEORIGIN"
  Header always set Referrer-Policy "strict-origin-when-cross-origin"
  Header always set Permissions-Policy "camera=(), microphone=(), geolocation=(), payment=()"
  Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"
  Header always set Cross-Origin-Opener-Policy "same-origin"
  # Report-Only first: review the browser console for 1-2 weeks, then rename to
  # Content-Security-Policy. 'unsafe-inline' is needed by the Next.js static export's inline scripts.
  Header always set Content-Security-Policy-Report-Only "default-src 'self'; script-src 'self' 'unsafe-inline' https://www.googletagmanager.com https://www.google-analytics.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data: https:; font-src 'self' https://fonts.gstatic.com data:; connect-src 'self' https://tds-website-xi.vercel.app https://*.google-analytics.com https://*.googletagmanager.com https://*.doubleclick.net; frame-src https://www.google.com https://calendar.google.com https://calendar.app.google; frame-ancestors 'self'; base-uri 'self'; form-action 'self'; object-src 'none'; upgrade-insecure-requests"
</IfModule>

# Don't list directory contents or expose dotfiles.
Options -Indexes
<FilesMatch "^\.(?!well-known)">
  Require all denied
</FilesMatch>

# Custom 404 page (generated by `next build` with output: "export")
ErrorDocument 404 /404.html
