@use '../../styles/abstract/base' as base;
@use '../../styles/abstract/variables' as v;
@use '../../styles/abstract/mixins' as m;
@use '../../styles/abstract/theme' as t;

$component: '#{base.$prefix}-carousel';


.#{$component} {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;

&__scroller {
position: relative;
width: 100%;
height: 100%;
overflow-x: auto;
overflow-y: hidden;
overscroll-behavior-x: contain;
scrollbar-width: none;
cursor: grab;

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

&--snap &__scroller {
scroll-snap-type: x mandatory;
}

&--snap.#{$component}--vertical &__scroller {
scroll-snap-type: y mandatory;
}

&[data-settling] &__scroller {
scroll-snap-type: none;
}

&[data-dragging] &__scroller {
cursor: grabbing;
}

&--vertical &__scroller {
overflow-x: hidden;
overflow-y: auto;
overscroll-behavior-x: auto;
overscroll-behavior-y: contain;
}

&__track {
position: relative;
height: 100%;
}

&--vertical &__track {
width: 100%;
}

&__snap {
position: absolute;
top: 0;
left: 0;
width: 1px;
height: 1px;
scroll-snap-align: start;
pointer-events: none;
}

&__item {
position: absolute;
top: 0;
left: 0;
height: 100%;
overflow: hidden;
border-radius: var(--#{base.$prefix}-carousel-corner, #{v.shape('extra-large')});
background-color: t.color('surface-container');
will-change: transform, clip-path;
user-select: none;

&:focus,
&:focus-visible {
outline: none;
}

&:focus-visible::after {
content: '';
position: absolute;
inset: var(--#{base.$prefix}-carousel-inset, 0);
border: 3px solid t.color('secondary');
border-radius: inherit;
pointer-events: none;
}
}

&--vertical &__item {
width: 100%;
height: auto;
}

&__image {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
pointer-events: none;
}

&__content {
position: absolute;
inset: auto 0 0 0;
padding: 16px;
color: #fff;
background: linear-gradient(to top, t.alpha('scrim', 0.6), transparent);
opacity: var(--#{base.$prefix}-carousel-fade, 1);
pointer-events: none;

> * {
pointer-events: auto;
}
}

&__title {
@include m.typography('title-medium');
@include m.truncate;
}

&__description {
@include m.typography('body-medium');
margin-top: 4px;
@include m.truncate;
}

&__button {
display: inline-block;
margin-top: 12px;
border-radius: v.shape('extra-small');
color: inherit;
text-decoration: none;
@include m.typography('label-large');

&:focus { outline: none; }

&:focus-visible {
outline: 3px solid t.color('secondary');
outline-offset: 2px;
box-shadow: 0 0 0 6px t.color('surface');
}
}

@media (prefers-reduced-motion: reduce) {
&__scroller {
scroll-behavior: auto;
}
}
}
