/*
 Alevio custom utilities
 - .gradient-cutout: text acts as a mask revealing a background gradient
 - .gradient-cutout--{theme}: optional variants via CSS vars
*/

/* Base background used by the cutout; overridable via CSS variables */
:root {
  /* Using the theme image: assets/img/gradient.jpg */
  --alevio-gradient: url("../img/gradient.jpg");
  --alevio-gradient-size: 200% 200%; /* upscale so shifting reveals variation */
  --alevio-gradient-attachment: fixed; /* allow a fixed viewport background effect */
  --alevio-gradient-anim-duration: 12s;
}

/* Utility: gradient background + text cutout using background-clip/text-fill-color */
.gradient-cutout {
  position: relative;
  display: inline-block;
  background-image: var(--alevio-gradient);
  /* Use the viewport cover background for cutout */
  background-size: var(--alevio-gradient-size);;
  background-attachment: var(--alevio-gradient-attachment);
  background-attachment: fixed;
  background-position: top left;
  background-repeat: no-repeat;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
          color: transparent;
  /* Static when using the viewport-fixed background */
  animation: none;
}

/* Block display helper if used on full-width elements */
.gradient-cutout.is-block,
.wp-block-heading .gradient-cutout,
.wp-block-paragraph .gradient-cutout {
  display: block;
}

/* Optional: allow the whole block to be transformed by style selection (no inner span required) */
.is-style-gradient-cutout {
  background-image: var(--alevio-gradient);
  background-size: var(--alevio-gradient-size);;
  background-attachment: var(--alevio-gradient-attachment);
  background-position: top left;
  background-repeat: no-repeat;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
          color: transparent;
  animation: none;
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .gradient-cutout,
  .is-style-gradient-cutout {
    animation: none;
  }
}

/* Gradient Shadow button style */
/* Gradient Shadow button style (pseudo-element lives on the container so link background remains editable) */
.wp-block-button.gradient-shadow,
.wp-block-button.is-style-gradient-shadow {
  position: relative;
  display: inline-block;
}

.wp-block-button.gradient-shadow::after,
.wp-block-button.is-style-gradient-shadow::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 6px;
  width: calc(100%);
  height: calc(100%);
  background-image: var(--alevio-gradient);
  background-size: var(--alevio-gradient-size);
  background-attachment: var(--alevio-gradient-attachment);
  background-position: top left;
  background-repeat: no-repeat;
  opacity: 1;
  z-index: 0; /* sits behind the link */
  border-radius: inherit;
  transition: left .18s ease, top .18s ease, opacity .18s ease;
  pointer-events: none;
}

/* Ensure the link itself sits above the pseudo-element and can still have a background color */
.wp-block-button .wp-block-button__link {
  position: relative;
  z-index: 1;
  overflow: visible;
}

.wp-block-button.gradient-shadow:hover::after,
.wp-block-button.is-style-gradient-shadow:hover::after,
.wp-block-button.gradient-shadow:focus::after,
.wp-block-button.is-style-gradient-shadow:focus::after {
  left: 2px;
  top: 2px;
  width: calc(100% - 2px);
  height: calc(100% - 2px);
  opacity: 0.28;
}

@media (prefers-reduced-motion: reduce) {
  .wp-block-button.gradient-shadow::after,
  .wp-block-button.is-style-gradient-shadow::after {
    transition: none;
    left: 4px;
    top: 4px;
  }
}

/* Mobile & old-browsers fallback: fixed backgrounds are expensive and sometimes unsupported on mobile, disable on small screens */
@media (max-width: 768px) {
  :root {
    --alevio-gradient-attachment: scroll;
  }
  .gradient-cutout,
  .is-style-gradient-cutout,
  .wp-block-button.gradient-shadow::after,
  .wp-block-button.is-style-gradient-shadow::after {
    background-attachment: scroll;
  }
}

/* Coherent Buttons block spacing: reduce the default gap to 8px so it matches adjacent-button spacing */
.wp-block-buttons {
  gap: 32px;
}

/* Text only button style: removes background and border so the link reads like plain text */
.wp-block-button.text-only,
.wp-block-button.is-style-text-only {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.wp-block-button.text-only .wp-block-button__link,
.wp-block-button.is-style-text-only .wp-block-button__link {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: inherit; /* inherit surrounding text color unless the user sets a custom color */
  text-decoration: none; /* underline is provided by the ::after element */
  transition: opacity .18s ease, color .18s ease; /* match nav fade behavior */
}

.wp-block-button.text-only .wp-block-button__link:hover,
.wp-block-button.is-style-text-only .wp-block-button__link:hover,
.wp-block-button.text-only .wp-block-button__link:focus,
.wp-block-button.is-style-text-only .wp-block-button__link:focus {
  opacity: 0.6; /* mirror nav link hover opacity */
}

/* Progressive underline (nav-like) for text-only buttons */
.wp-block-button.text-only .wp-block-button__link,
.wp-block-button.is-style-text-only .wp-block-button__link {
  position: relative;
  display: inline-block;
  text-decoration: none; /* ensure no native underline */
  /* spacing is provided by margin from --primarybtnpadding */
}

.wp-block-button.text-only .wp-block-button__link::after,
.wp-block-button.is-style-text-only .wp-block-button__link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 0;
  height: 2px;
  bottom: -0.12em; /* position slightly below the text baseline */
  background-color: var(--hovercolor, currentColor);
  transition: width 0.28s ease;
  pointer-events: none;
}

.wp-block-button.text-only .wp-block-button__link:hover::after,
.wp-block-button.is-style-text-only .wp-block-button__link:hover::after,
.wp-block-button.text-only .wp-block-button__link:focus::after,
.wp-block-button.is-style-text-only .wp-block-button__link:focus::after {
  width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  .wp-block-button.text-only .wp-block-button__link::after,
  .wp-block-button.is-style-text-only .wp-block-button__link::after {
    transition: none;
  }
}
