// -----------------------------------------------------------------------------
// Scope constructor
// -----------------------------------------------------------------------------

/// Set namespace for scopes
/// @public

$bem-scope-namespace: 's';

/// Initializes a new scope object
/// @private
/// @param {String} $scope  - Name for the new scope
/// @returns The final selector for the new scope object

@function _scope($scope) {

    // Log new block
    $new-scope: _bem-log-scope($scope);

    // Error checks
    $outside-check: _should-not-be-called-within('block', 'scope');

    // Return false in case error throwing is disabled
    @if $outside-check == false {
        @return false;
    }

    $namespace: if($bem-use-namespaces, $bem-scope-namespace + '-', '');
    $selector: '.' + $namespace + $scope;

    $set-current: set-current-context('scope', $scope, $selector);

    @return $selector;
}

@mixin scope($scope) {

    @at-root #{_scope($scope)} {
        @content;
    }

    $unset-current: unset-current-context('scope');
}
