$cssPath = "site\assets\style.css"
$css = Get-Content $cssPath -Raw

# The @media (max-width: 760px) block is missing its closing brace.
# Let's find the end of the mobile nav block and add it.

$endOfMobileNav = "(?s)/\* Blog Icon \*/.*?a:nth-child\(3\)::before\s*\{.*?\n\s*\}"
$match = [regex]::Match($css, $endOfMobileNav)

if ($match.Success) {
    # If the closing brace is already there, we might not need to add it, but let's check.
    $indexAfterMatch = $match.Index + $match.Length
    $nextChars = $css.Substring($indexAfterMatch, 20)
    
    if ($nextChars -notmatch '\}') {
        # The closing brace is missing! Let's inject it!
        $css = $css.Insert($indexAfterMatch, "`n  }`n")
        Set-Content -Path $cssPath -Value $css -Encoding UTF8
        Write-Host "Fixed the missing media query closing brace!"
    } else {
        Write-Host "Closing brace seems to exist."
    }
} else {
    Write-Host "Could not find Blog Icon CSS block."
}
