/* Reusable button primitives. Section-specific treatments live in section CSS. */

@property --vl-button-border-progress {
  syntax: "<number>";
  inherits: false;
  initial-value: 1;
}

@property --vl-button-fill-progress {
  syntax: "<number>";
  inherits: true;
  initial-value: 1;
}

.button {
  --vl-button-bg: transparent;
  --vl-button-border-color: rgba(233, 29, 37, 0.92);
  --vl-button-hover-border-color: var(--vl-red-bright);
  --vl-button-color: #fff;
  --vl-button-border-progress: 1;
  --vl-button-border-layer-opacity: 0;
  --vl-button-border-draw-duration: 720ms;
  --vl-button-content-reveal-duration: 520ms;
  --vl-button-fill-reveal-duration: 680ms;
  --vl-button-fill-progress: 1;
  --vl-button-fill-origin: left center;
  --vl-button-fill-bg: var(--vl-red);
  --vl-button-fill-hover-bg: var(--vl-red-bright);
  --vl-button-shadow: 0 10px 28px rgba(233, 29, 37, 0.14);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 17px;
  min-height: 44px;
  overflow: hidden;
  border: 1px solid var(--vl-button-border-color);
  border-radius: var(--vl-button-radius);
  background: var(--vl-button-bg);
  color: var(--vl-button-color);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 1.15px;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: var(--vl-button-shadow);
  isolation: isolate;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, color 180ms ease;
}

.button::before {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--vl-button-fill-bg);
  content: "";
  transform: scaleX(var(--vl-button-fill-progress));
  transform-origin: var(--vl-button-fill-origin);
  transition: transform 220ms ease, background 180ms ease;
  will-change: transform;
}

.button::after {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  background:
    linear-gradient(var(--vl-button-border-draw-color, currentColor), var(--vl-button-border-draw-color, currentColor)) top left / 100% 1px no-repeat,
    linear-gradient(var(--vl-button-border-draw-color, currentColor), var(--vl-button-border-draw-color, currentColor)) top left / 1px 100% no-repeat,
    linear-gradient(var(--vl-button-border-draw-color, currentColor), var(--vl-button-border-draw-color, currentColor)) right bottom / 100% 1px no-repeat,
    linear-gradient(var(--vl-button-border-draw-color, currentColor), var(--vl-button-border-draw-color, currentColor)) right bottom / 1px 100% no-repeat;
  content: "";
  opacity: var(--vl-button-border-layer-opacity, 0);
  pointer-events: none;
}

.button > span,
.button > i,
.button > img {
  position: relative;
  z-index: 3;
}

.button i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  font-size: 14px;
}

.button:hover,
.button:focus-visible {
  border-color: var(--vl-button-hover-border-color);
  background: var(--vl-button-bg);
  outline: none;
  transform: translateY(-1px);
}

.button:hover::before,
.button:focus-visible::before {
  background: var(--vl-button-fill-hover-bg);
  transform: scaleX(1);
}

.button[data-button-sequence="true"] {
  --vl-button-border-draw-color: var(--vl-button-border-color);
  --vl-button-border-layer-opacity: 0;
  --vl-button-border-progress: 0;

  border-color: transparent;
}

.button[data-button-sequence="true"]::after {
  background-size: 0 1px, 1px 0, 0 1px, 1px 0;
}

.button[data-button-sequence="true"]:not(.button--outline-reveal):not(.button--light):not(.button--ghost):not(.is-button-revealed) {
  --vl-button-fill-progress: 0;
}

.button[data-button-sequence="true"].is-button-revealed::after {
  animation: vlButtonBorderDraw var(--vl-button-border-draw-duration) ease both;
}

.button[data-button-sequence="true"].is-button-revealed {
  --vl-button-border-layer-opacity: 1;
}

.button[data-button-sequence="true"]:not(.button--outline-reveal):not(.button--light):not(.button--ghost).is-button-revealed::before {
  animation: vlButtonFillAfterBorder var(--vl-button-fill-reveal-duration) ease calc(var(--vl-button-border-draw-duration) + var(--vl-button-content-reveal-duration)) both;
}

.button[data-button-sequence="true"] > span,
.button[data-button-sequence="true"] > i,
.button[data-button-sequence="true"] > img {
  clip-path: inset(0 100% 0 0);
  opacity: 0;
}

.button[data-button-sequence="true"].is-button-revealed > span,
.button[data-button-sequence="true"].is-button-revealed > i,
.button[data-button-sequence="true"].is-button-revealed > img {
  animation: vlButtonContentReveal var(--vl-button-content-reveal-duration) ease var(--vl-button-border-draw-duration) both;
}

.button--fill-rtl {
  --vl-button-fill-origin: right center;
}

.button--xsmall {
  min-width: 128px;
  min-height: 36px;
  gap: 14px;
  padding-inline: 18px 12px;
}

.button--small {
  min-width: 153px;
  min-height: 42px;
  gap: 24px;
  padding-inline: 22px 14px;
}

.button--medium {
  min-width: 218px;
  min-height: 44px;
  gap: 17px;
  padding-inline: 23px 21px;
}

.button--large {
  min-width: 260px;
  min-height: 52px;
  gap: 22px;
  padding-inline: 28px 22px;
}

.button--xlarge {
  min-width: 312px;
  min-height: 60px;
  gap: 26px;
  padding-inline: 34px 28px;
}

.button--block {
  width: 100%;
}

.button--primary {
  --vl-button-shadow: 0 10px 28px rgba(233, 29, 37, 0.2);
}

.button--ghost {
  width: 235px;
  min-width: 235px;
  padding: 0 17px 0 21px;
  --vl-button-bg: rgba(0, 0, 0, 0.16);
  --vl-button-border-color: var(--vl-border);
  --vl-button-hover-border-color: #fff;
  --vl-button-fill-bg: rgba(255, 255, 255, 0.08);
  --vl-button-fill-hover-bg: rgba(255, 255, 255, 0.12);
  --vl-button-fill-progress: 0;
}

.button--ghost:hover,
.button--ghost:focus-visible {
  --vl-button-bg: rgba(0, 0, 0, 0.16);
}

.button--outline-reveal {
  --vl-button-border-color: var(--vl-red-bright);
  --vl-button-hover-border-color: var(--vl-red-bright);
  --vl-button-bg: transparent;
  --vl-button-fill-bg: rgba(233, 29, 37, 0.82);
  --vl-button-fill-hover-bg: var(--vl-red-bright);
  --vl-button-fill-progress: 0;
  --vl-button-shadow: 0 0 24px rgba(233, 29, 37, 0.16);
}

.button--outline-reveal:hover,
.button--outline-reveal:focus-visible {
  --vl-button-bg: transparent;
}

.button--outline-reveal:hover::before,
.button--outline-reveal:focus-visible::before {
  transform: scaleX(1);
}

@keyframes vlButtonBorderDraw {
  from {
    background-size: 0 1px, 1px 0, 0 1px, 1px 0;
  }

  to {
    background-size: 100% 1px, 1px 100%, 100% 1px, 1px 100%;
  }
}

@keyframes vlButtonFillAfterBorder {
  from {
    transform: scaleX(0);
  }

  to {
    transform: scaleX(1);
  }
}

@keyframes vlButtonContentReveal {
  from {
    clip-path: inset(0 100% 0 0);
    opacity: 0;
  }

  to {
    clip-path: inset(0 0 0 0);
    opacity: 1;
  }
}

.button--light {
  --vl-button-bg: rgba(255, 255, 255, 0.86);
  --vl-button-border-color: #090a0d;
  --vl-button-color: #090a0d;
  --vl-button-fill-progress: 0;
  --vl-button-shadow: 0 18px 46px rgba(0, 0, 0, 0.08);
}

.button--light:hover,
.button--light:focus-visible {
  --vl-button-color: #fff;
}

.button--icon {
  width: 55px;
  min-width: 55px;
  min-height: 55px;
  padding: 0;
  cursor: pointer;
}

.button--icon:disabled {
  cursor: default;
  opacity: 0.35;
  transform: none;
}

.button--icon:disabled::before {
  transform: scaleX(var(--vl-button-fill-progress));
}

@media (max-width: 560px) {
  .button,
    .button--xsmall,
    .button--primary,
    .button--ghost,
    .button--small,
    .button--medium,
    .button--large,
    .button--xlarge,
    .button--outline-reveal {
      width: 100%;
      min-width: 0;
    }
}
