8 – How can I add external CSS using hook_css_alter?

I want to load an external CSS file using the hook_css_alter (so I can change the style dynamically based on domain name), but when I try to add items to $css, it often gives

Exception: Invalid CSS asset type. in DrupalCoreAssetCssCollectionRenderer->render() (line 72 of core/lib/Drupal/Core/Asset/CssCollectionRenderer.php).

(and warnings: Undefined index: media Undefined index: browsers)

function mymodule_css_alter(&$css, DrupalCoreAssetAttachedAssetsInterface $assets)
{
    $nodeID = 3; // Pretend this dynamically changes
    $node = Node::load($nodeID);
    if ($node) {
        $css("nodeplain/{$node->nid(0)->value}/css") = (
            'type' => 'file', // I think this line needs to change?
            'group' => CSS_AGGREGATE_DEFAULT,
            'weight' => 0,
            'media' => 'all',
            'browsers' => (),
            'preprocess' => false,
            'data' => "/nodeplain/{$node->nid(0)->value}/css",
            'version' => $node->revision_default(0)->value,
        );
    }
}