// Copyright 2015 Palantir Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0.

@import "./card-variables";

/*
Cards

Markup:
<div class="#{$ns}-card {{.modifier}}">
  We build products that make people better at their most important work.
</div>

.#{$ns}-elevation-0 - Ground floor. This level provides just a gentle border shadow.
.#{$ns}-elevation-1 - First. Subtle drop shadow intended for static containers.
.#{$ns}-elevation-2 - Second. An even stronger shadow, moving on up.
.#{$ns}-elevation-3 - Third. For containers overlaying content temporarily.
.#{$ns}-elevation-4 - Fourth. The strongest shadow, usually for overlay containers on top of backdrops.
.#{$ns}-interactive - On hover, increase elevation and use pointer cursor.

Styleguide card
*/

.#{$ns}-card {
  background-color: $card-background-color;
  border-radius: $pt-border-radius;
  box-shadow: $pt-elevation-shadow-0;
  padding: $card-padding;
  transition: transform ($pt-transition-duration * 2) $pt-transition-ease,
              box-shadow ($pt-transition-duration * 2) $pt-transition-ease;

  &.#{$ns}-dark,
  .#{$ns}-dark & {
    background-color: $dark-card-background-color;
    box-shadow: $pt-dark-elevation-shadow-0;
  }

  // High contrast mode hides box-shadows, so we need to use a border instead
  @media (forced-colors: active) and (prefers-color-scheme: dark) {
    border: 1px solid $pt-high-contrast-mode-border-color;
    box-shadow: none;
  }
}

@for $index from 1 through length($elevation-shadows) {
  .#{$ns}-elevation-#{$index - 1} {
    box-shadow: nth($elevation-shadows, $index);

    &.#{$ns}-dark,
    .#{$ns}-dark & {
      box-shadow: nth($dark-elevation-shadows, $index);
    }

    @media (forced-colors: active) and (prefers-color-scheme: dark) {
      border: 1px solid $pt-high-contrast-mode-border-color;
    }
  }
}

.#{$ns}-card.#{$ns}-compact {
  padding: $card-padding-compact;
}

.#{$ns}-card.#{$ns}-interactive {
  &:hover {
    box-shadow: $pt-elevation-shadow-3;
    cursor: pointer;

    &.#{$ns}-dark,
    .#{$ns}-dark & {
      box-shadow: $pt-dark-elevation-shadow-3;
    }
  }

  &.#{$ns}-selected {
    box-shadow: 0 0 0 3px rgba($blue4, 0.2), 0 0 0 1px $blue4;

    &.#{$ns}-dark,
    .#{$ns}-dark & {
      box-shadow: 0 0 0 3px rgba($blue5, 0.4), 0 0 0 1px $blue5;
    }
  }

  &:active {
    box-shadow: $pt-elevation-shadow-1;
    transition-duration: 0;

    &.#{$ns}-dark,
    .#{$ns}-dark & {
      box-shadow: $pt-dark-elevation-shadow-1;
    }
  }
}
