///
//  Copyright (c) 2022 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';

@mixin init() {
  .gs-item-card {
    display: flex;
    flex-flow: column nowrap;
    @include kardia.struct-apply('item-card', (
      width: 100%,
      height: auto,
      radius: inherit,
    ));
    @content;

    .gs-item-card__header {
      display: grid;
      grid-template-columns: 32px 1fr 32px;
      @include kardia.color-apply('item-card', kardia.$color-inherit-template);
      @include kardia.struct-apply('item-card', (
        padding: inherit,
        gap: inherit,
      ));
      border-radius: kardia.key-get('item-card-radius') kardia.key-get('item-card-radius') 0 0;

      &:only-child {
        border-radius: kardia.key-get('item-card-radius');
      }

      .gs-item-card__sprite {
        @include kardia.sprite-styles();
      }

      .gs-item-card__mast {
        display: flex;
        flex-flow: column nowrap;

        .gs-item-card__title {
          @include kardia.typography-apply('item-card-title', kardia.$type-inherit-template);
        }

        .gs-item-card__subtitle {
          @include kardia.typography-apply('item-card-subtitle', kardia.$type-inherit-template);
        }
      }

      .gs-item-card__menu {
        &.is-open {
          .gs-item-card__menu-overlay {
            display: block;
          }
        }

        .gs-item-card__menu-overlay {
          display: none;
          position: fixed;
          top: 0;
          left: 0;
          right: 0;
          bottom: 0;
          z-index: 80;
        }

        .gs-list {
          z-index: 90;
        }
      }
    }

    .gs-item-card__footer {
      @include kardia.struct-apply('item-card-footer', kardia.$struct-inherit-template);
      border-radius: 0 0 kardia.key-get('item-card-radius') kardia.key-get('item-card-radius');
      @include kardia.typography-apply('item-card-footer', kardia.$type-inherit-template);
    }
  }
}