:host(:not(:is([hydrated], .hydrated))) {
  @apply not-hydrated;
}


mds-button {
  &:not(:is([hydrated], .hydrated)) {
    @apply not-hydrated;
  }
}


/**
 * @prop --mds-horizontal-scroll-behavior: Sets the scroll-behavior animation
 * @prop --mds-horizontal-scroll-controls-margin: Public. Sets how far the back and forward controls sit outside the area of the slotted elements, 48px by default; `0px` keeps them on its edges
 * @prop --mds-horizontal-scroll-dot-area-background: Sets the dot container area color
 * @prop --mds-horizontal-scroll-dot-background: Sets the navigation dot color
 * @prop --mds-horizontal-scroll-dot-max-width: Sets the navigation dot max-width, if you want to avoid is scales in proportion of the container
 * @prop --mds-horizontal-scroll-max-width: Public. Sets the max-width of the slotted elements container, to keep layout limited as the rest of the sections
 * @prop --mds-horizontal-scroll-scrollbar-margin: Sets the margin of the browser scroll bar (if supported)
 * @prop --mds-horizontal-scroll-scrollbar-radius: Sets the border-radius of the browser scroll bar (if supported)
 * @prop --mds-horizontal-scroll-scrollbar-size: Sets the height and width of the browser scroll bar (if supported)
 * @prop --mds-horizontal-scroll-scrollbar-thumb-background: Sets the background-color of the browser scroll bar thumb (if supported)
 * @prop --mds-horizontal-scroll-scrollbar-track-background: Sets the background-color of the browser scroll bar track (if supported)
 */

/* ❌ Not supported: 'auto' is not a <length>

@property --mds-horizontal-scroll-dot-max-width {
  inherits: false;
  initial-value: auto;
  syntax: "<custom-ident>";
}
*/

:host {
  --mds-horizontal-scroll-behavior: smooth;
  --mds-horizontal-scroll-dots-gap: --spacing(100);
  --mds-horizontal-scroll-dot-size: --spacing(200);
  --mds-horizontal-scroll-dot-max-width: auto;
  --mds-horizontal-scroll-dot-background: rgb(var(--magma-surface-overlay, var(--surface-neutral-overlay, 255 255 255)));
  --mds-horizontal-scroll-dot-area-background: rgb(var(--magma-wash-strong, var(--tone-neutral-08, 208 208 208)));
  --mds-horizontal-scroll-contents-padding: --spacing(600);
  --mds-horizontal-scroll-contents-scroll-padding: 0 --spacing(600);
  --mds-horizontal-scroll-controls-margin: --spacing(1200);
  --mds-horizontal-scroll-gap: --spacing(600);
  --mds-horizontal-scroll-max-width: var(--breakpoint-wide, 1280px);
  --mds-horizontal-scroll-scrollbar-margin: 0;
  --mds-horizontal-scroll-scrollbar-radius: 0;
  --mds-horizontal-scroll-scrollbar-size: --spacing(200);
  --mds-horizontal-scroll-scrollbar-thumb-background: rgb(var(--magma-surface-inverse, var(--tone-neutral-02, 42 42 42)) / 0.3);
  --mds-horizontal-scroll-scrollbar-track-background: rgb(var(--magma-wash-base, var(--tone-neutral-09, 225 225 225)));

  /* private custom props, DO NOT OVERRIDE from outside */
  --max-width: var(--mds-horizontal-scroll-max-width, var(--breakpoint-wide, 1280px));
  --scroll-margin: calc(
    ((100svw - var(--max-width)) / 2) + (var(--mds-horizontal-scroll-controls-margin, --spacing(1200)) * 2)
  );

  align-items: center;
  container-name: mds-horizontal-scroll;
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  width: 100%;
}

/* Animation preference: scroll-behavior is a keyword, so its reduced-motion state
 * is handled here, cross-browser, via @media following the OS preference. */

@media (prefers-reduced-motion: reduce) {
  :host {
    --mds-horizontal-scroll-behavior: auto;
  }
}

.navigation {
  border-radius: var(--magma-radius-full, var(--radius-full, 1000px));
  display: none;
  padding: 0;
  position: absolute;
  top: 50%;
  transform: translate(0, -50%);
  transition-duration: var(--duration-200, 200ms);
  transition-property: opacity, scale, transform;
}

.contents {
  box-sizing: border-box;
  display: flex;
  gap: var(--mds-horizontal-scroll-gap, --spacing(600));
  overflow: auto;
  padding-bottom: var(--mds-horizontal-scroll-contents-padding, --spacing(600));
  padding-top: var(--mds-horizontal-scroll-contents-padding, --spacing(600));
  position: relative;
  scroll-behavior: var(--mds-horizontal-scroll-behavior, smooth);
  scroll-padding: var(--mds-horizontal-scroll-contents-scroll-padding, 0 --spacing(600));
  scroll-snap-type: x mandatory;
  width: 100%;
}

/*
.contents::after {
--width: calc(var(--scroll-margin) - var(--mds-horizontal-scroll-gap));
--position: calc(var(--scroll-margin) - var(--mds-horizontal-scroll-gap) - var(--mds-horizontal-scroll-controls-margin) + 48px);

background-color: rgb(255 0 255 / 0.1);
content: "";
display: flex;
height: 100%;
left: clamp(1px, var(--width), var(--width));
pointer-events: none;
position: fixed;
right: clamp(calc(var(--mds-horizontal-scroll-gap) / 2), var(--position), var(--position));
}
*/

.contents > ::slotted(*) {
  flex-basis: 0;
  flex-grow: 0;
  flex-shrink: 0;
  scroll-margin: 0 var(--scroll-margin);
}

.spacer {
  --width: calc(var(--scroll-margin) - var(--mds-horizontal-scroll-gap, --spacing(600)));

  content: '';
  display: block;
  flex-basis: 0;
  flex-grow: 0;
  flex-shrink: 0;
  min-width: clamp(1px, var(--width), var(--width));
  scroll-margin: 0 var(--scroll-margin);
}

@container (max-width: 1024px) {
  :host {
    --scroll-margin: var(--mds-horizontal-scroll-contents-scroll-padding, 0 --spacing(600));
  }

  .contents {
    scroll-padding: var(--mds-horizontal-scroll-contents-scroll-padding, 0 --spacing(600));
  }

  .contents > ::slotted(*) {
    scroll-margin: 0 var(--mds-horizontal-scroll-contents-scroll-padding, 0 --spacing(600));
  }
}

.navigation--back {
  --position: calc(
    var(--scroll-margin) - var(--mds-horizontal-scroll-gap, --spacing(600)) -
      var(--mds-horizontal-scroll-controls-margin, --spacing(1200))
  );

  left: clamp(calc(var(--mds-horizontal-scroll-gap, --spacing(600)) / 2), var(--position), var(--position));
}

.navigation--forward {
  --position: calc(
    var(--scroll-margin) - var(--mds-horizontal-scroll-gap, --spacing(600)) -
      var(--mds-horizontal-scroll-controls-margin, --spacing(1200))
  );

  right: clamp(calc(var(--mds-horizontal-scroll-gap, --spacing(600)) / 2), var(--position), var(--position));
}

.navigation--disabled {
  opacity: 0;
  pointer-events: none;
  transform: translate(0, -50%) scale(0.5);
}

:host([controls='all']) .navigation {
  display: flex;
}

:host([controls='tv']) .navigation {
  @apply tv:flex;
}

:host([controls='xlarge']) .navigation {
  @apply xlarge:flex;
}

:host([controls='large']) .navigation {
  @apply large:flex;
}

:host([controls='wide']) .navigation {
  @apply wide:flex;
}

:host([controls='desktop']) .navigation {
  @apply desktop:flex;
}

:host([controls='tablet']) .navigation {
  @apply tablet:flex;
}

.dot-navigation {
  align-self: center;
  background-color: var(--mds-horizontal-scroll-dot-area-background, rgb(var(--magma-wash-strong, var(--tone-neutral-08, 208 208 208))));
  border-radius: var(--magma-radius-full, var(--radius-full, 1000px));
  display: none;
  gap: var(--mds-horizontal-scroll-dots-gap, --spacing(100));
  justify-content: start;
  margin: 0 auto var(--mds-horizontal-scroll-contents-padding, --spacing(600)) auto;
  max-width: --spacing(4000);
  padding: --spacing(50);
  width: 100%;
}

:host([navigation='position']) .dot-navigation {
  display: inline-flex;
}

.dot {
  background-color: var(--mds-horizontal-scroll-dot-background, rgb(var(--magma-surface-overlay, var(--surface-neutral-overlay, 255 255 255))));
  border-radius: var(--magma-radius-full, var(--radius-full, 1000px));
  height: var(--mds-horizontal-scroll-dot-size, --spacing(200));
  max-width: var(--mds-horizontal-scroll-dot-max-width);
  min-width: var(--mds-horizontal-scroll-dot-size, --spacing(200));
  transition-duration: var(--duration-300, 300ms);
  transition-property: width;
  transition-timing-function: var(--ease-out-expo, cubic-bezier(0.19, 1, 0.22, 1));
  width: calc(var(--mds-horizontal-scroll-dot-size, --spacing(200)) * 2);
}

:host(:not([navigation='scrollbar'])) .contents {
  @apply hide-scrollbar;
}

:host([navigation='scrollbar']) .contents::-webkit-scrollbar {
  height: var(--mds-horizontal-scroll-scrollbar-size, --spacing(200));
  width: var(--mds-horizontal-scroll-scrollbar-size, --spacing(200));
}

:host([navigation='scrollbar']) .contents::-webkit-scrollbar-track {
  background-color: var(--mds-horizontal-scroll-scrollbar-track-background, rgb(var(--magma-wash-base, var(--tone-neutral-09, 225 225 225))));
  border-radius: var(--mds-horizontal-scroll-scrollbar-radius, 0);
  margin-block: var(--mds-horizontal-scroll-scrollbar-margin, 0);
  margin-inline: var(--mds-horizontal-scroll-scrollbar-margin, 0);
}

:host([navigation='scrollbar']) .contents::-webkit-scrollbar-thumb {
  background-color: var(--mds-horizontal-scroll-scrollbar-thumb-background, rgb(var(--magma-surface-inverse, var(--tone-neutral-02, 42 42 42)) / 0.3));
  border-radius: var(--mds-horizontal-scroll-scrollbar-radius, 0);
}

@supports (scrollbar-color: transparent transparent) {
  .contents {
    scrollbar-color: var(--mds-horizontal-scroll-scrollbar-thumb-background, rgb(var(--magma-surface-inverse, var(--tone-neutral-02, 42 42 42)) / 0.3))
      var(--mds-horizontal-scroll-scrollbar-track-background, rgb(var(--magma-wash-base, var(--tone-neutral-09, 225 225 225))));
    scrollbar-width: thin;
  }
}

:host([snap='start']) .contents > ::slotted(*) {
  scroll-snap-align: start;
}

:host([snap='center']) .contents > ::slotted(*) {
  scroll-snap-align: center;
}

:host([snap='end']) .contents > ::slotted(*) {
  scroll-snap-align: end;
}

