@use "../../tokens/variables";

/* Patterns - Interaction - Scrollable Area */
////
/// @group Patterns-Scrollable_Area
/// Patterns - Interaction - Scrollable Area

/* $4.3.13 - Patterns - Interaction - ScrollableArea */
.scrollable-area {
	&-content {
		--scrollable-area-height: auto;
		--scrollable-area-width: 100%;

		height: var(--scrollable-area-height);
		width: var(--scrollable-area-width);

		&.horizontal-scroll,
		&.vertical-scroll {
			.osui {
				&-deprecated.carousel,
				&-carousel {
					.list.list-group {
						overflow-x: initial;
						overflow-y: initial;
					}
				}
			}
		}

		&.none {
			-ms-overflow-style: none; /* IE and Edge */
			scrollbar-width: none; /* Firefox */

			&:hover {
				cursor: default;
			}

			&::-webkit-scrollbar {
				display: none;
			}
		}

		&.horizontal-scroll {
			/// Lay the content out on a single line. Without it the children wrap to the
			/// container width, nothing overflows on the inline axis and `overflow-x: auto`
			/// has nothing to scroll. Previously inherited from the deprecated
			/// `.horizontal-scroll` pattern, dropped with `10-deprecated/`.
			white-space: nowrap;

			&,
			.list.list-group {
				overflow-x: auto;
				overflow-y: hidden;
			}

			// Service Studio Preview
			& {
				-servicestudio-min-height: 80px;
				-servicestudio-white-space: normal;
			}

			> *:not(table),
			> .list > * {
				display: inline-block;
				/// Promotes each item to its own layer, keeping the scroll smooth on touch
				/// devices. Z-axis only, so it is RTL-safe.
				transform: translateZ(0);
			}

			> :not(:first-child),
			> .list > :not(:first-child) {
				margin-inline-start: variables.$token-scale-400;
			}
		}

		&.vertical-scroll {
			&,
			.list.list-group {
				overflow-x: hidden;
				overflow-y: auto;
			}
		}

		&.compact {
			&.horizontal-scroll,
			&.vertical-scroll {
				&::-webkit-scrollbar {
					width: 8px;
					height: 8px;
				}

				&::-webkit-scrollbar-track,
				&::-webkit-scrollbar-thumb,
				&:hover::-webkit-scrollbar-track {
					background-color: transparent;
				}

				&:hover::-webkit-scrollbar-thumb {
					background-color: rgba(173, 181, 189, 0.5);
					border-radius: variables.$token-scale-150;
				}

				&::-webkit-scrollbar-thumb:hover {
					background-color: rgba(106, 113, 120, 0.5);
					border-radius: variables.$token-scale-150;
				}
			}
		}
	}
}

[data-block='Interaction.ScrollableArea'] {
	&::-webkit-scrollbar {
		width: 8px;
		height: 8px;
	}

	&::-webkit-scrollbar-track,
	&::-webkit-scrollbar-thumb,
	&:hover::-webkit-scrollbar-track {
		background-color: transparent;
	}

	&:hover::-webkit-scrollbar-thumb {
		background-color: rgba(173, 181, 189, 0.5);
		border-radius: variables.$token-scale-150;
	}

	&::-webkit-scrollbar-thumb:hover {
		background-color: rgba(106, 113, 120, 0.5);
		border-radius: variables.$token-scale-150;
	}
}
