.cards-container { /* Default Card Container Styling (Do not change) */
  background-color: var(--lightest-gray);
  border: 1px solid var(--light-gray);
  border-radius: var(--border-radius);
  box-shadow: inset -1px 1px 4px rgba(128, 128, 128, 0.25);
  display: block;
  max-height: 60vh;
  overflow-y: scroll;
  overflow-x: hidden;
  position: relative;
  padding: 0.5rem;
  width: 100%;

  &.blended {
    background-color: unset;
    border-left: unset;
    border-right: unset;
    border-radius: 0;
    box-shadow: unset;
    padding: 0.5rem 0;
  }

  /* RYAL-3125 */
  &.cards-container-clear {
    background-color: unset;
    border: unset;
    border-radius: 0;
    box-shadow: unset;
    padding: 0;
  }
  
  &.full {
    max-height: unset;
    overflow-y: unset;
  }

  .cards-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--container-s), 1fr));
    gap: 0.5rem;

    &.wrapper-one {
      grid-template-columns: 1fr;
    }

    &.wrapper-two {
      grid-template-columns: repeat(auto-fill, minmax(var(--container-sm), 1fr));
    }

    &.wrapper-full {
      width: 100%;
    }
  }
}

.cards__list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: fit-content;

  &.cards__list--md {
    overflow-y: auto;
    max-height: var(--container-m);
  }
  &.cards__list--md-scroll {
    overflow-y: scroll;
    max-height: var(--container-sm);
  }
}

.card, .nested-card { /* Default Card Styling (Do not change) */
  background-color: var(--off-white);
  border-radius: var(--border-radius);
  border: 1px solid var(--light-gray);
  box-shadow: 0.25rem 0.25rem 0.25rem rgba(226, 226, 226, 0.25);
  padding: calc(0.5rem - 1px) calc(1rem - 1px);
  display: inline-flex;
  flex-direction: column;
  gap: 1rem;
  min-width: var(--container-s);
  transition: 0.4s ease-in-out;
  width: 100%;

  &:not(&.card--no-hover):hover {
    background-color: var(--lightest-gray);
  }

  & > turbo-frame {
    display: inherit;
    flex-direction: inherit;
    gap: inherit;
    width: inherit;
  }

  &.card--borderless, &.blended {
    background-color: unset;
    border-radius: unset;
    box-shadow: unset;
    border: none;
    padding: 0;
  }

  &.selected , &[selected="true"] {
    box-shadow: inset -2px 4px 4px rgba(128, 128, 128, 0.25);
    border: 2px solid var(--theme-color-darker);
    padding: calc(0.5rem - 2px) calc(1rem - 2px);
  }

  .card__notice {
    background-color: var(--light-gray);
    border-radius: var(--border-radius);
    padding: 0.5rem;

    .card_notice-reason p {
      display: inline;
    }
  }

  .card__header {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;

    &.card__header--horizontal {
      flex-direction: row;
      gap: 0.5rem;
    }

    .card__title-wrapper {
      display: flex;
      flex: 1;
      gap: 0.25rem;
      flex-direction: row;
    }

    .heading {
      display: flex;
      flex: 1;
      flex-direction: column;
      gap: 0;
      justify-content: center;

      &.heading--start {
        justify-content: flex-start;
      }
    }

    .card__subtitle {/* Move to global card class when updated */
      color: var(--gray-700);
    }

    .card__actions {
      border-top: unset;
      margin-top: 0;
      padding-top: 0;
      width: fit-content;
    }
  }

  .card-header { /* Default Card Header Styling (Do not change) */
    align-items: flex-start;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0.25rem;
    width: 100%;

    &.card-header-row {
      align-items: center;
      flex-direction: row;
    }

    &:has(.right-action-bar) {
      flex-direction: row;
    }

    .inline-header { /* when .heading-wrapper needs to be wrapped (Usually when there is an adjacent image) */
      width: inherit;
    }

    .heading-wrapper {
      flex: 1;

      .header-subtitle {
        width: fit-content;
      }
    }

    & > turbo-frame {
      align-items: inherit;
      display: inherit;
      flex-direction: inherit;
      width: inherit;
    }
  }

  .card__actions {
    margin-top: auto;
  }

  .card-actions, .card__actions {
    align-items: center;
    border-top: 1px solid var(--light-gray);
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 0.5rem;
    padding-top: 0.5rem;
    width: 100%;

    &:has(> :only-child) {
      justify-content: flex-end;
    }
  }

  /* Collapsible Cards (Used with card_selector_controller.js) */
  &:has(section.collapsible-section) {
    cursor: pointer;

    section.collapsible-section {
      padding: 0 1rem;
      width: 100%;

      & > :first-child {
        margin-top: 0.5rem
      }

      & > :last-child {
        margin-bottom: 0.5rem
      }
    }

    .toggle-icon {
      transition: 0.4s ease-in-out;
    }

    &:not([open]) {
      .toggle-icon {
        transform: initial;
      }

      section.collapsible-section {
        display: none;
      }
    }

    &[open] {
      .toggle-icon {
        transform: rotate(180deg);
      }

      section.collapsible-section {
        display: inline-flex;
      }
    }
  }
}

.nested-card {
  /* Collapsible Nested Cards (Used with nested_card_selector_controller.js) */
  &:has(section.nested-collapsible-section) {
    cursor: pointer;

    section.nested-collapsible-section {
      padding: 0 1rem;
      width: 100%;

      & > :first-child {
        margin-top: 0.5rem
      }

      & > :last-child {
        margin-bottom: 0.5rem
      }
    }

    .toggle-icon {
      transition: 0.4s ease-in-out;
    }

    &:not([open]) {
      .toggle-icon {
        transform: initial;
      }

      section.nested-collapsible-section {
        display: none;
      }
    }

    &[open] {
      .toggle-icon {
        transform: rotate(180deg);
      }

      section.nested-collapsible-section {
        display: inline-flex;
      }
    }
  }
}

.collapse-section {
  .list-collapsible-item {
    width: 100%;

    .list-collapsible-header {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      width: 100%;
    }
  }

  .toggle-icon {
    transition: 0.4s ease-in-out;
  }

  &[closed] {
    .toggle-icon {
      transition: 0.4s ease-in-out;
      transform: initial !important;
    }
  }

  &:not([closed]) {
    .toggle-icon {
      transform: rotate(180deg);
    }

    .list-collapsible-section {
      opacity: 1;
      transition: 0.4s ease-in-out, max-height 0.4s, visibility 0.1s;
    }
  }

  &[closed] .list-collapsible-section {
    opacity: 0;
    max-height: 0;
    visibility: collapse;
    transition: max-height 0.4s, visibility 0.1s;
  }


  /* Individual styling */
  &#options-collapsible-list {
    .list-collapsible-section .explanation-wrapper {
      padding: 1rem 0 1rem 1rem;
    }
  }
}

.cards {
  --gap-between-cards: 0.5rem;
  --column-count: 1;
  --card-width: calc((100% - (var(--gap-between-cards) * (var(--column-count) - 1))) / var(--column-count));
  display: flex;
  flex-direction: column;
  flex-flow: row;
  flex-wrap: wrap;
  gap: var(--gap-between-cards);

  &.cards--2-col {
    --column-count: 2;
  }

  &.cards--3-col {
    --column-count: 3;
  }

  &.cards--4-col {
    --column-count: 4;
  }

  .card {
    flex: 1 0 var(--card-width);
    max-width: var(--card-width);
    min-width: var(--card-width);
  }
}
