///
//  Copyright (c) 2023 GrowStocks
//
//  Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
//
//  The above copyright notice and this permission notice shall be included in all
//  copies or substantial portions of the Software.
//
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//  SOFTWARE.
///

@use '../kardia';
@use 'sass:map';

@use 'surface-base' as base;
@use 'surface-theme' as theme;

@mixin render(
  $color: (),
  $struct: (),
  $typography: (),
  $settings: ()
) {
  @include base.init() {
    @include kardia.color-bind('surface', (
      fill: kardia.theme-get(theme.$init-color, 'fill'),
      ink: kardia.theme-get(theme.$init-color, 'ink'),
      border: kardia.theme-get(theme.$init-color, 'border'),
    ));
    @include kardia.color-bind('surface-header', (
      fill: kardia.theme-get(theme.$init-color, 'fill', 'header'),
      ink: kardia.theme-get(theme.$init-color, 'ink', 'header'),
      border: kardia.theme-get(theme.$init-color, 'border', 'header'),
    ));
    @include kardia.color-bind('surface-footer', (
      fill: kardia.theme-get(theme.$init-color, 'fill', 'footer'),
      ink: kardia.theme-get(theme.$init-color, 'ink', 'footer'),
      border: kardia.theme-get(theme.$init-color, 'border', 'footer'),
    ));

    @include kardia.struct-bind('surface', (
      radius: kardia.theme-get(theme.$init-struct, 'radius'),
      padding: kardia.theme-get(theme.$init-struct, 'padding'),
    ));
    @include kardia.struct-bind('surface-header', (
      padding: kardia.theme-get(theme.$init-struct, 'padding'),
    ));
    @include kardia.struct-bind('surface-footer', (
      padding: kardia.theme-get(theme.$init-struct, 'padding'),
    ));

    @include kardia.typography-bind('surface', (
      family: kardia.theme-get(theme.$init-typography, 'family'),
      size: kardia.theme-get(theme.$init-typography, 'size'),
      weight: kardia.theme-get(theme.$init-typography, 'weight'),
      line-height: kardia.theme-get(theme.$init-typography, 'line-height'),
    ));
    @include kardia.typography-bind('surface-header', (
      family: kardia.theme-get(theme.$init-typography, 'family', 'header'),
      size: kardia.theme-get(theme.$init-typography, 'size', 'header'),
      weight: kardia.theme-get(theme.$init-typography, 'weight', 'header'),
      line-height: kardia.theme-get(theme.$init-typography, 'line-height', 'header'),
    ));
    @include kardia.typography-bind('surface-footer', (
      family: kardia.theme-get(theme.$init-typography, 'family', 'footer'),
      size: kardia.theme-get(theme.$init-typography, 'size', 'footer'),
      weight: kardia.theme-get(theme.$init-typography, 'weight', 'footer'),
      line-height: kardia.theme-get(theme.$init-typography, 'line-height', 'footer'),
    ));

    &:where(.is-raised) {
      @include kardia.struct-apply('surface', (
        shadow: 'xs'
      ));
    }
  }
}