/**
 * Pixel Click Button System Stylesheet
 * General EduTech Centre Signature Micro-Interactions
 */

#fx-layer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 99999;
  overflow: hidden;
}

/* 1. Keycap Press on Buttons */
.fx-btn-pressable {
  transform-origin: center center;
  will-change: transform;
}
.fx-btn-down {
  transform: translateY(2px) scale(0.98) !important;
  transition: transform 90ms ease-out, box-shadow 90ms ease-out !important;
}
.fx-btn-spring {
  transform: translateY(0) scale(1.02) !important;
  transition: transform 140ms cubic-bezier(0.2, 0.8, 0.2, 1) !important;
}

/* 2. Hover 8-Bit Step Fill (Fine pointers only, never touch) */
@media (hover: hover) and (pointer: fine) {
  .btn-human.btn-brand,
  .btn-primary-action,
  .btn-primary,
  .btn-submit-action,
  .btn-ticket-submit,
  .form-submit-clean,
  [data-fx="primary"] {
    position: relative;
    overflow: hidden;
    z-index: 1;
  }

  .btn-human.btn-brand::before,
  .btn-primary-action::before,
  .btn-primary::before,
  .btn-submit-action::before,
  .btn-ticket-submit::before,
  .form-submit-clean::before,
  [data-fx="primary"]::before {
    content: '';
    position: absolute;
    inset: 0;
    background: #A3111F;
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 260ms steps(8, end);
    z-index: -1;
    pointer-events: none;
  }

  .btn-human.btn-brand:hover::before,
  .btn-primary-action:hover::before,
  .btn-primary:hover::before,
  .btn-submit-action:hover::before,
  .btn-ticket-submit:hover::before,
  .form-submit-clean:hover::before,
  [data-fx="primary"]:hover::before {
    transform: scaleX(1);
  }

  .btn-human.btn-quiet,
  .btn-secondary,
  .btn-ticket-download,
  .btn-copy-chip,
  [data-fx="secondary"] {
    position: relative;
    overflow: hidden;
    z-index: 1;
  }

  .btn-human.btn-quiet::before,
  .btn-secondary::before,
  .btn-ticket-download::before,
  .btn-copy-chip::before,
  [data-fx="secondary"]::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(18, 35, 74, 0.08);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 260ms steps(8, end);
    z-index: -1;
    pointer-events: none;
  }

  .btn-human.btn-quiet:hover::before,
  .btn-secondary:hover::before,
  .btn-ticket-download:hover::before,
  .btn-copy-chip:hover::before,
  [data-fx="secondary"]:hover::before {
    transform: scaleX(1);
  }
}

/* 3. Global Selection-Rectangle Focus Outline (2px sheet-green, 2px offset) */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--sheet-green, #1E7B4F) !important;
  outline-offset: 2px !important;
}

/* 4. Cell-Select Snap Rectangle */
.fx-snap-box {
  position: absolute;
  border: 2px solid var(--sheet-green, #1E7B4F);
  border-radius: 2px;
  pointer-events: none;
  box-sizing: border-box;
}

.fx-snap-handle {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 6px;
  height: 6px;
  background: var(--sheet-green, #1E7B4F);
  border: 1px solid #FFFFFF;
}

/* 5. Grid Ripple on Secondary Buttons */
.fx-grid-ripple {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: 
    linear-gradient(to right, rgba(18, 35, 74, 0.12) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(18, 35, 74, 0.12) 1px, transparent 1px);
  background-size: 8px 8px;
  border-radius: inherit;
  mask-image: radial-gradient(circle at var(--rx, 50%) var(--ry, 50%), black 0%, transparent 100%);
  -webkit-mask-image: radial-gradient(circle at var(--rx, 50%) var(--ry, 50%), black 0%, transparent 100%);
}

/* 6. WhatsApp Floating Bubble */
.fx-wa-bubble {
  position: absolute;
  width: 14px;
  height: 12px;
  border-radius: 6px;
  pointer-events: none;
  box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}
.fx-wa-bubble::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 3px;
  width: 4px;
  height: 4px;
  background: inherit;
  transform: rotate(45deg);
}

/* 7. Submit Button Spinner & Shake */
.fx-btn-submitting {
  pointer-events: none !important;
  opacity: 0.9 !important;
}
.fx-submit-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: fxSpin 600ms linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes fxSpin {
  to { transform: rotate(360deg); }
}

.fx-btn-error {
  animation: fxShake 240ms ease-in-out !important;
  outline: 2px solid var(--crimson, #BA2B3E) !important;
}
@keyframes fxShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* Reduced Motion Mode & Low Power */
@media (prefers-reduced-motion: reduce) {
  .fx-btn-down,
  .fx-btn-spring,
  .fx-btn-error,
  .btn-human.btn-brand::before,
  .btn-primary-action::before,
  .btn-primary::before,
  .btn-human.btn-quiet::before,
  .btn-secondary::before {
    transition: none !important;
    animation: none !important;
    transform: none !important;
  }
}

