/* ==============================================
   New Pixel Button (global override per spec)
   Markup: <span class="btn-container"><button class="btn">REQUEST INFO</button></span>
   Works with <a class="btn"> as well
   ============================================== */

:root {
  --px: 3.5px; /* pixel size of the steps */
  --bg: #ffd400; /* base yellow */
  --bg-hi: #fff07a; /* top highlight yellow */
  --bg-lo: #ffc700; /* lower shade yellow */
  --shadow: #051b49; /* deep navy for drop */
  --shadow-rim: #0b2f77; /* tight bottom rim */
  --rim: #ffffff; /* white top rim */
  --text: #0e2a6e; /* dark text */
  --sky: #bfe5ff; /* light blue rim */
  --sky-height: 1.6; /* in px units */
  --sky-offset: 2; /* how far the external top band sits above */
}

/* Shadow wrapper renders the stepped navy shape under the button */
.btn-container {
  position: relative;
  display: inline-block;
}

.btn-container::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--shadow);
  transform: translateY(calc(1.5 * var(--px)));
  z-index: 0; /* below the button */
  clip-path: polygon(
    /* left stair up */ 0% 34%,
    calc(1 * var(--px)) 34%,
    calc(1 * var(--px)) 26%,
    calc(2 * var(--px)) 26%,
    calc(2 * var(--px)) 19%,
    calc(3 * var(--px)) 19%,
    calc(3 * var(--px)) 14%,
    calc(4 * var(--px)) 14%,
    calc(4 * var(--px)) 10%,
    calc(6 * var(--px)) 10%,
    /* top edge */ calc(100% - 6 * var(--px)) 10%,
    calc(100% - 4 * var(--px)) 10%,
    calc(100% - 4 * var(--px)) 14%,
    calc(100% - 3 * var(--px)) 14%,
    calc(100% - 3 * var(--px)) 19%,
    calc(100% - 2 * var(--px)) 19%,
    calc(100% - 2 * var(--px)) 26%,
    calc(100% - 1 * var(--px)) 26%,
    calc(100% - 1 * var(--px)) 34%,
    100% 34%,
    /* right stair down */ 100% 66%,
    calc(100% - 1 * var(--px)) 66%,
    calc(100% - 1 * var(--px)) 74%,
    calc(100% - 2 * var(--px)) 74%,
    calc(100% - 2 * var(--px)) 81%,
    calc(100% - 3 * var(--px)) 81%,
    calc(100% - 3 * var(--px)) 86%,
    calc(100% - 4 * var(--px)) 86%,
    calc(100% - 4 * var(--px)) 90%,
    calc(6 * var(--px)) 90%,
    /* bottom edge back to left stair */ calc(4 * var(--px)) 90%,
    calc(4 * var(--px)) 86%,
    calc(3 * var(--px)) 86%,
    calc(3 * var(--px)) 81%,
    calc(2 * var(--px)) 81%,
    calc(2 * var(--px)) 74%,
    calc(1 * var(--px)) 74%,
    calc(1 * var(--px)) 66%,
    0% 66%
  );
  pointer-events: none;
}

/* external light-blue top band, matching the pill steps */
.btn-container::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #e7eef8;
  transform: translateY(calc(-0.4 * var(--sky-offset) * var(--px)));
  z-index: 0; /* behind the button; only the protruding top area shows */
  clip-path: polygon(
    /* left stair up */ 0% 34%,
    calc(1 * var(--px)) 34%,
    calc(1 * var(--px)) 26%,
    calc(2 * var(--px)) 26%,
    calc(2 * var(--px)) 19%,
    calc(3 * var(--px)) 19%,
    calc(3 * var(--px)) 14%,
    calc(4 * var(--px)) 14%,
    calc(4 * var(--px)) 10%,
    calc(6 * var(--px)) 10%,
    /* top edge */ calc(100% - 6 * var(--px)) 10%,
    calc(100% - 4 * var(--px)) 10%,
    calc(100% - 4 * var(--px)) 14%,
    calc(100% - 3 * var(--px)) 14%,
    calc(100% - 3 * var(--px)) 19%,
    calc(100% - 2 * var(--px)) 19%,
    calc(100% - 2 * var(--px)) 26%,
    calc(100% - 1 * var(--px)) 26%,
    calc(100% - 1 * var(--px)) 34%,
    100% 34%,
    /* right stair down */ 100% 66%,
    calc(100% - 1 * var(--px)) 66%,
    calc(100% - 1 * var(--px)) 74%,
    calc(100% - 2 * var(--px)) 74%,
    calc(100% - 2 * var(--px)) 81%,
    calc(100% - 3 * var(--px)) 81%,
    calc(100% - 3 * var(--px)) 86%,
    calc(100% - 4 * var(--px)) 86%,
    calc(100% - 4 * var(--px)) 90%,
    calc(6 * var(--px)) 90%,
    /* bottom edge back to left stair */ calc(4 * var(--px)) 90%,
    calc(4 * var(--px)) 86%,
    calc(3 * var(--px)) 86%,
    calc(3 * var(--px)) 81%,
    calc(2 * var(--px)) 81%,
    calc(2 * var(--px)) 74%,
    calc(1 * var(--px)) 74%,
    calc(1 * var(--px)) 66%,
    0% 66%
  );
  pointer-events: none;
}

/* Accessibility: Screen reader only class */
.btn-container .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
  clip-path: inset(50%);
}

/* Button text - visible to all users */
.btn-container .btn .btn-text {
  position: relative;
  z-index: 2;
}

/* Apply core pixel styles only to the 8-bit block buttons */
.btn-container .btn,
.wp-block-button .wp-block-button__link {
  position: relative;
  display: inline-block;
  padding: calc(5 * var(--px)) calc(7 * var(--px));
  font-size: 16px;
  color: var(--text) !important;
  transition: transform 0.08s ease-out; /* subtler press-down animation */
  background: var(--bg) !important;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border: 0 !important;
  border-radius: 0 !important;
  text-decoration: none !important;
  cursor: pointer;
  /* tight bottom rim inside the shape */
  box-shadow: inset 0 calc(-2 * var(--px)) 0 0 var(--shadow-rim);
  isolation: isolate;
  z-index: 1; /* above the wrapper shadow */
  /* Ensure sufficient touch target size (WCAG 2.5.5) */
  min-width: 44px;
  min-height: 44px;
  clip-path: polygon(
    /* left stair up */ 0% 34%,
    calc(1 * var(--px)) 34%,
    calc(1 * var(--px)) 26%,
    calc(2 * var(--px)) 26%,
    calc(2 * var(--px)) 19%,
    calc(3 * var(--px)) 19%,
    calc(3 * var(--px)) 14%,
    calc(4 * var(--px)) 14%,
    calc(4 * var(--px)) 10%,
    calc(6 * var(--px)) 10%,
    /* top edge */ calc(100% - 6 * var(--px)) 10%,
    calc(100% - 4 * var(--px)) 10%,
    calc(100% - 4 * var(--px)) 14%,
    calc(100% - 3 * var(--px)) 14%,
    calc(100% - 3 * var(--px)) 19%,
    calc(100% - 2 * var(--px)) 19%,
    calc(100% - 2 * var(--px)) 26%,
    calc(100% - 1 * var(--px)) 26%,
    calc(100% - 1 * var(--px)) 34%,
    100% 34%,
    /* right stair down */ 100% 66%,
    calc(100% - 1 * var(--px)) 66%,
    calc(100% - 1 * var(--px)) 74%,
    calc(100% - 2 * var(--px)) 74%,
    calc(100% - 2 * var(--px)) 81%,
    calc(100% - 3 * var(--px)) 81%,
    calc(100% - 3 * var(--px)) 86%,
    calc(100% - 4 * var(--px)) 86%,
    calc(100% - 4 * var(--px)) 90%,
    calc(6 * var(--px)) 90%,
    /* bottom edge back to left stair */ calc(4 * var(--px)) 90%,
    calc(4 * var(--px)) 86%,
    calc(3 * var(--px)) 86%,
    calc(3 * var(--px)) 81%,
    calc(2 * var(--px)) 81%,
    calc(2 * var(--px)) 74%,
    calc(1 * var(--px)) 74%,
    calc(1 * var(--px)) 66%,
    0% 66%
  );
}

/* Press down animation */
.btn-container .btn:active,
.wp-block-button .wp-block-button__link:active {
  transform: translateY(calc(1 * var(--px)));
}

/* Accessibility: Enhanced focus states (WCAG 2.4.7) */
.btn-container .btn:focus {
  outline: 3px solid #ffdc00;
  outline-offset: 3px;
  /* High contrast focus indicator */
  box-shadow:
    inset 0 calc(-2 * var(--px)) 0 0 var(--shadow-rim),
    0 0 0 3px rgba(255, 220, 0, 0.5),
    0 0 0 5px rgba(0, 51, 160, 0.3);
}

.btn-container .btn:focus:not(:focus-visible) {
  outline: none;
  box-shadow: inset 0 calc(-2 * var(--px)) 0 0 var(--shadow-rim);
}

.btn-container .btn:focus-visible {
  outline: 3px solid #ffdc00;
  outline-offset: 3px;
  box-shadow:
    inset 0 calc(-2 * var(--px)) 0 0 var(--shadow-rim),
    0 0 0 3px rgba(255, 220, 0, 0.5),
    0 0 0 5px rgba(0, 51, 160, 0.3);
}

/* Fallback drop shadow for core Button (no wrapper) */
.wp-block-button .wp-block-button__link::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--shadow);
  transform: translateY(calc(1.5 * var(--px)));
  z-index: 0;
  clip-path: inherit;
}

/* Avoid double-shadow when inside wrapper */
.btn-container .btn::before,
.btn-container .wp-block-button__link::before {
  content: none;
}

/* Allow ::before for sky button border */
.btn-container .btn.sky::before,
.btn-container .wp-block-button__link.sky::before,
.wp-block-button .wp-block-button__link.sky::before {
  content: "";
}

/* thin white top highlight */
.btn-container .btn::after,
.wp-block-button .wp-block-button__link::after {
  content: "";
  position: absolute;
  left: calc(-2 * var(--px));
  right: calc(-2 * var(--px));
  top: calc(-3 * var(--px));
  height: calc(1.2 * var(--px));
  background: var(--rim);
  border-radius: 0;
  opacity: 0.98;
  z-index: 1;
}

/* optional: crisp "pixel" text vibe */
.btn-container .btn,
.wp-block-button .wp-block-button__link {
  text-shadow: 0 0 0 currentColor;
}

/* Disable legacy layers from old implementation (keep .hover for stripe effect) */
.btn-highlight,
.btn-shadow {
  display: none !important;
}

/* =============================
   Star effect for goldenrod buttons
   ============================= */
.star-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(14 * var(--px));
  height: calc(14 * var(--px));
  z-index: 0;
  opacity: 1;
  filter: drop-shadow(0 calc(0.6 * var(--px)) 0 var(--shadow));
  pointer-events: none;
}

.star-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  opacity: 1;
  transition: opacity 0.3s ease;
  z-index: 0;
}

.star-container .spark {
  position: absolute;
  width: calc(3.4 * var(--px));
  height: calc(3.4 * var(--px));
  opacity: 0;
  transition: opacity 0.3s ease;
  transform-origin: center center;
  z-index: 0;
}

.star-container .spark-1 {
  top: calc(-0.6 * var(--px));
  left: calc(-0.6 * var(--px));
  transform: rotate(0deg) !important;
}

.star-container .spark-2 {
  top: calc(-0.6 * var(--px));
  right: calc(-0.6 * var(--px));
  transform: rotate(90deg) scaleX(-1) !important;
}

.star-container .spark-3 {
  bottom: calc(0.6 * var(--px));
  right: calc(-1.7 * var(--px));
  transform: rotate(0deg) scaleX(-1) !important;
}

.star-container .spark-4 {
  bottom: calc(0.6 * var(--px));
  left: calc(-1.7 * var(--px));
  transform: rotate(90deg) !important;
}

@keyframes starGroupAppear {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
  35% {
    opacity: 1;
    transform: translate(-50%, calc(-9 * var(--px)));
  }
  65% {
    opacity: 1;
    transform: translate(-50%, calc(-18 * var(--px)));
  }
  80% {
    opacity: 1;
    transform: translate(-50%, calc(-22 * var(--px)));
  }
  100% {
    opacity: 1;
    transform: translate(-50%, calc(-24 * var(--px)));
  }
}

@keyframes showSparks {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* Trigger star animation only when goldenrod button is clicked */
.btn-container:has(.btn.goldenrod.clicked) .star-container {
  animation: starGroupAppear 0.2s ease-out forwards;
}

.btn-container:has(.btn.goldenrod.clicked) .star-container .spark {
  animation: showSparks 0.2s ease-in-out forwards;
  animation-delay: 0.3s;
}
/* ==============================================
     Hover stripe effect (uses existing .hover > span markup)
     ============================================== */
.btn-container .btn .hover {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 0; /* above background, below text/white rim */
  overflow: hidden;
  border-radius: 0;
  clip-path: inherit; /* exactly match button shape to cover full area */
  pointer-events: none;
}

.btn-container .btn .hover span {
  position: relative;
  display: block;
  left: -15px;
  height: 15px;
  width: 0;
  content: "";
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.25); /* subtle base sheen */
  mix-blend-mode: screen;
}

.btn-container .btn .hover span:after {
  position: absolute;
  display: block;
  right: -10px;
  width: 10px;
  height: 10px;
  background: #fff;
  content: "";
}

.btn-container .btn .hover span:nth-child(odd):after {
  background: rgba(0, 0, 0, 0.4); /* slightly stronger contrast */
}

.btn-container .btn .hover span:first-child {
  left: -75px;
  transition: all 0.3s steps(8);
}
.btn-container .btn .hover span:nth-child(2) {
  left: -45px;
  transition: all 0.325s steps(8);
}
.btn-container .btn .hover span:nth-child(3) {
  left: -55px;
  transition: all 0.35s steps(8);
}
.btn-container .btn .hover span:nth-child(4) {
  transition: all 0.4s steps(8);
}
.btn-container .btn .hover span:nth-child(5) {
  left: -25px;
  transition: all 0.375s steps(8);
}

.btn-container .btn:hover .hover span:first-child,
.btn-container .btn:focus .hover span:first-child {
  width: calc(100% + 76px);
}
.btn-container .btn:hover .hover span:nth-child(2),
.btn-container .btn:focus .hover span:nth-child(2) {
  width: calc(100% + 46px);
}
.btn-container .btn:hover .hover span:nth-child(3),
.btn-container .btn:focus .hover span:nth-child(3) {
  width: calc(100% + 56px);
}
.btn-container .btn:hover .hover span:nth-child(4),
.btn-container .btn:focus .hover span:nth-child(4) {
  width: calc(100% + 16px);
}
.btn-container .btn:hover .hover span:nth-child(5),
.btn-container .btn:focus .hover span:nth-child(5) {
  width: calc(100% + 26px);
}

@keyframes whiteBlack {
  0%,
  24% {
    background: #fff;
  }
  25%,
  49% {
    background: rgba(0, 0, 0, 0.35);
  }
  50%,
  74% {
    background: #fff;
  }
  75%,
  100% {
    background: rgba(0, 0, 0, 0.35);
  }
}

.btn-container .btn:hover .hover span:first-child:after,
.btn-container .btn:focus .hover span:first-child:after {
  animation: whiteBlack 0.3s 0s 1;
}
.btn-container .btn:hover .hover span:nth-child(2):after,
.btn-container .btn:focus .hover span:nth-child(2):after {
  animation: whiteBlack 0.3s 0.06s 1 reverse backwards;
}
.btn-container .btn:hover .hover span:nth-child(3):after,
.btn-container .btn:focus .hover span:nth-child(3):after {
  animation: whiteBlack 0.3s 0.05s 1 forwards;
}
.btn-container .btn:hover .hover span:nth-child(4):after,
.btn-container .btn:focus .hover span:nth-child(4):after {
  animation: whiteBlack 0.3s 0s 1 reverse backwards;
}
.btn-container .btn:hover .hover span:nth-child(5):after,
.btn-container .btn:focus .hover span:nth-child(5):after {
  animation: whiteBlack 0.3s 0.07s 1 forwards;
}
/* ==============================================
   Color Variations (set per-button custom props)
   Classes expected from PHP map: sunset, river-green, wildcat-blue, goldenrod, sky
   ============================================== */
/* Sunset */
.btn-container .btn.sunset,
.btn-container .btn.orange,
.wp-block-button .wp-block-button__link.sunset,
.wp-block-button .wp-block-button__link.orange {
  --bg: #ffa360;
  --bg-hi: #ffb27f;
  --bg-lo: #d67a3d;
  --text: #1b365d;
}

/* River Green */
.btn-container .btn.river-green,
.btn-container .btn.green,
.btn-container .btn.turquoise,
.wp-block-button .wp-block-button__link.river-green,
.wp-block-button .wp-block-button__link.green,
.wp-block-button .wp-block-button__link.turquoise {
  --bg: #4cbcc0;
  --bg-hi: #7ed0d3;
  --bg-lo: #3a9a9d;
  --text: #1b365d;
}
/* ==============================================
   Button Alignment Utilities
   ============================================== */
.text-start {
  text-align: left !important;
}

.text-center {
  text-align: center !important;
}

.text-end {
  text-align: right !important;
}

/* Wildcat Blue */
.btn-container .btn.wildcat-blue,
.btn-container .btn.blue,
.wp-block-button .wp-block-button__link.wildcat-blue,
.wp-block-button .wp-block-button__link.blue {
  --bg: #0033a0;
  --bg-hi: #1e4db6;
  --bg-lo: #001f60;
  --text: #ffffff;
}

/* Goldenrod */
.btn-container .btn.goldenrod,
.btn-container .btn.yellow,
.wp-block-button .wp-block-button__link.goldenrod,
.wp-block-button .wp-block-button__link.yellow {
  --bg: #ffdc00;
  --bg-hi: #fff07a;
  --bg-lo: #ffc700;
  --text: #1b365d;
}

/* Transparent (legacy Clear option) */
.btn-container .btn.transparent,
.wp-block-button .wp-block-button__link.transparent {
  --bg: transparent;
  --bg-hi: #7ed0d3;
  --bg-lo: #3a9a9d;
  --text: #1b365d;
  background: transparent !important;
  box-shadow: none !important;
}

/* Hide shadow wrapper for transparent buttons */
.btn-container:has(.btn.transparent)::before,
.btn-container:has(.btn.transparent)::after {
  display: none;
}

/* ==============================================
   Link-style Variant (no border)
   - Per-button option via ACF toggle
   - Looks like a standard text link, underlines on hover/focus-visible
   ============================================== */
.btn-container.is-link::before,
.btn-container.is-link::after {
  display: none !important;
}

.btn-container.is-link .btn.is-link {
  /* Remove the 8-bit “button” chrome */
  padding: 0.25rem 0;
  min-width: 0;
  min-height: auto;
  background: transparent !important;
  box-shadow: none !important;
  clip-path: none !important;
  text-shadow: none;
  text-transform: none;
  letter-spacing: normal;
  font-size: inherit;
  line-height: inherit;
  /* Link-style text color */
  --text: #1b365d;
}

.btn-container.is-link .btn.is-link::after {
  content: none !important; /* remove the white top rim */
}

.btn-container.is-link .btn.is-link:active {
  transform: none;
}

.btn-container.is-link .btn.is-link:hover,
.btn-container.is-link .btn.is-link:focus-visible {
  text-decoration: none !important;
}

/* Keep a strong keyboard focus indicator */
.btn-container.is-link .btn.is-link:focus-visible {
  outline: 3px solid #ffdc00;
  outline-offset: 2px;
}

.btn-container.is-link .btn.is-link:focus:not(:focus-visible) {
  outline: none;
}

/* Sky */
.btn-container .btn.sky,
.wp-block-button .wp-block-button__link.sky {
  --bg: #c7e2ff;
  --bg-hi: #d9ecff;
  --bg-lo: #b0d5ff;
  --text: #1b365d;
  --shadow: #001f60; /* dark blue shadow */
  --shadow-rim: #001f60; /* dark blue bottom rim */
  background: var(--bg) !important;
  /* Keep the inset shadow for bottom rim */
  box-shadow: inset 0 calc(-2 * var(--px)) 0 0 var(--shadow-rim) !important;
  position: relative;
}

/* Override shadow for sky button container to use dark blue and adjust side width */
.btn-container:has(.btn.sky)::before {
  background: #001f60;
  left: calc(-0.3 * var(--px));
  right: calc(-0.3 * var(--px));
  width: calc(100% + 0.6 * var(--px));
}

/* Override external top band for sky button to dark blue */
.btn-container:has(.btn.sky)::after {
  background: #001f60;
  left: calc(-0.3 * var(--px));
  right: calc(-0.3 * var(--px));
  width: calc(100% + 0.6 * var(--px));
}

/* White */
.btn-container .btn.white,
.wp-block-button .wp-block-button__link.white {
  --bg: #ffffff;
  --bg-hi: #ffffff;
  --bg-lo: #f0f0f0;
  --text: #1b365d;
  --shadow: #001f60; /* dark blue shadow */
  --shadow-rim: #001f60; /* dark blue bottom rim */
  background: var(--bg) !important;
  /* Keep the inset shadow for bottom rim */
  box-shadow: inset 0 calc(-2 * var(--px)) 0 0 var(--shadow-rim) !important;
  position: relative;
}

/* Override shadow for white button container to use dark blue and adjust side width */
.btn-container:has(.btn.white)::before {
  background: #001f60;
  left: calc(-0.3 * var(--px));
  right: calc(-0.3 * var(--px));
  width: calc(100% + 0.6 * var(--px));
}

/* Override external top band for white button to dark blue */
.btn-container:has(.btn.white)::after {
  background: #001f60;
  left: calc(-0.3 * var(--px));
  right: calc(-0.3 * var(--px));
  width: calc(100% + 0.6 * var(--px));
}
/* Reduced motion support (WCAG 2.3.3) */
@media (prefers-reduced-motion: reduce) {
  .btn-container .btn,
  .wp-block-button .wp-block-button__link {
    transition: none !important;
    animation: none !important;
  }

  .btn-container .btn .hover span,
  .btn-container .btn .hover span:after {
    transition: none !important;
    animation: none !important;
  }

  .star-container,
  .star-container .spark {
    animation: none !important;
    transition: none !important;
  }

  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support (WCAG 1.4.11) */
@media (prefers-contrast: high) {
  .btn-container .btn:focus {
    outline: 3px solid;
    outline-offset: 3px;
    border: 2px solid;
  }

  .btn-container .btn {
    border: 2px solid currentColor;
  }
}
