/*--/------*/
/* --{{ FLIP CARDS }}-- */
/*--/------*/
.flipCards {
  .tiles-wrap {
    gap: 20px;
  }

  .module-tile {
    &::before {
      padding-top: 147.78%;
    }

    .tile-flip-box-wrap {
      padding: var(--spacer-xs);
      overflow: visible;
    }

    p {
      color: black;
    }

    .tile-front,
    .tile-back {
      position: absolute;
      top: 0;
      left: 0;
      border-radius: var(--spacer-xs);

      .tile-inner {
        box-sizing: border-box;
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
      }
    }
  }

  .module-tile .tile-back .tile-inner,
  .BackTileEffect .tile-front .tile-inner {
    padding: var(--spacer-s);
    border: var(--border-medium) solid var(--blue);
  }

  .module-tile .tile-front {
    h3 {
      position: relative;
      display: inline-block;
      z-index: 1;
    }

    a.tile-flip-back-button {
      border-color: transparent var(--theme-card-color) var(--theme-card-color) transparent;
    }
  }

  /* Hoist accent onto the tile so front + back corners share it
     (back is .ui.white and otherwise inherits :root --theme-card-color: #fff) */
  .module-tile:has(.tile-front.blue)  { --theme-card-color: var(--yellow); }
  .module-tile:has(.tile-front.yellow) { --theme-card-color: var(--blue); }
  .module-tile:has(.tile-front.green) { --theme-card-color: var(--purple); }
  .module-tile:has(.tile-front.purple) { --theme-card-color: var(--green); }

  .module-tile .tile-front:is(.blue, .green, .purple) {
    --tb_pr_color: var(--white) !important;

    &,
    & * {
      color: var(--white) !important;
    }
  }

  .action-button {
    position: absolute;
    left: 0;
    right: 0;
    margin: auto;
    width: 80%;
    bottom: var(--spacer-s);
    background: var(--blue);
    color: white;

    &:hover {
      background: var(--orange);
    }

    span {
      display: none;
    }
  }
}

/* Tablet: grid layout  2 columns */
@media (max-width: 1024px) {
  .flipCards .tiles-wrap {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
  }

  .flipCards .module-tile {
    width: auto;
    scroll-snap-align: unset;
  }
}

/* Mobile: horizontal scroll-snap carousel layout */
@media (max-width: 768px) {
  .titleIcon > .row_inner:has(.flipCards) {
    max-width: 100%;
  }

  .flipCards {
    .tiles-wrap {
      display: flex;
      flex-direction: row;
      overflow-x: auto;
      scroll-snap-type: x mandatory;
      scroll-behavior: smooth;
      -webkit-overflow-scrolling: touch;
      gap: 15px;
      padding: 20px;
      width: 100%;
      box-sizing: border-box;

      .module-tile {
        flex: 0 0 85%;
        width: 85%;
        scroll-snap-align: center;
        position: relative;
      }
    }

    .tiles-wrap::-webkit-scrollbar {
      display: none !important;
    }

    /* Whole card is tappable. Themify's touch CSS draws arrow glyphs with
       ::before/::after at left/top — those jump to the top-left if the <a>
       is stretched. Suppress them; paint BR fold + chevron on the face. */
    .module-tile {
      .tile-front,
      .tile-back {
        a.tile-flip-back-button {
          position: absolute !important;
          inset: 0 !important;
          width: auto !important;
          height: auto !important;
          border: none !important;
          background: transparent !important;
          z-index: 5;
          display: block !important;

          &::before,
          &::after {
            content: none !important;
            display: none !important;
            border: none !important;
          }
        }

        /* Accent fold (cutout) — bottom right */
        &::after {
          content: "";
          position: absolute;
          right: 0;
          bottom: 0;
          width: 0;
          height: 0;
          border-style: solid;
          border-width: 20px;
          border-color: transparent var(--theme-card-color, var(--blue))
            var(--theme-card-color, var(--blue)) transparent;
          pointer-events: none;
          z-index: 6;
        }

        /* White chevron centred in the BR fold */
        &::before {
          content: "";
          position: absolute;
          right: 8px;
          bottom: 9px;
          width: 8px;
          height: 8px;
          box-sizing: border-box;
          border: 1px solid var(--white, #fff);
          border-bottom: 0;
          border-left: 0;
          transform: rotate(-45deg);
          transform-origin: center;
          pointer-events: none;
          z-index: 7;
        }
      }
    }
  }
}
