/* ============================================
   COMPONENTS.CSS — Unified Component Library
   Owner: Tier-3 Implementer (T#2 eady3fb5)
   Date: 2026-05-15
   Spec: docs/DESIGN_SPECS_PRODUCTION_GRADE_2026-05-15.md
         #D3 buttons + modal + form-field
         #D5 spinner + loading state
         #D6 error state
         #D7 footer compliance
         #D8 cookie banner anim
         #D9 page reveal stagger
         #D10 status badge
         #D11 color contrast
         #D12 mobile-first global
   ============================================ */

/* ──────────────────────────────────────────────
   #D3 — BUTTONS (unified)
   WCAG 2.5.5 tap target 44x44 + Share Tech Mono uppercase
   ────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 12px 24px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), box-shadow var(--transition),
              transform var(--transition);
  background: transparent;
  color: var(--text-primary);
  text-decoration: none;
  box-sizing: border-box;
}

.btn-primary {
  background: var(--neon-cyan);
  color: var(--bg-primary);
  font-weight: 700;
  box-shadow: 0 0 0 0 rgba(6, 182, 212, 0);
}

.btn-primary:hover {
  background: #0891b2;
  box-shadow: 0 0 24px 0 rgba(6, 182, 212, 0.4);
  transform: translateY(-1px);
  color: var(--bg-primary);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:focus-visible {
  outline: 2px solid var(--neon-purple);
  outline-offset: 2px;
}

/* TASK 5.2 (2026-05-15) — custom crosshair cursor on primary actions.
   24×24 SVG, cyan stroke, hotspot 12,12 (centre). Desktop only — `pointer: coarse`
   (touch) keeps the default pointer so mobile users get the OS-native tap affordance. */
@media (pointer: fine) {
  .btn-primary {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2306b6d4' stroke-width='1.4' stroke-linecap='round'><circle cx='12' cy='12' r='8' opacity='0.85'/><line x1='12' y1='1' x2='12' y2='6'/><line x1='12' y1='18' x2='12' y2='23'/><line x1='1' y1='12' x2='6' y2='12'/><line x1='18' y1='12' x2='23' y2='12'/><circle cx='12' cy='12' r='1.4' fill='%2306b6d4'/></svg>") 12 12, pointer;
  }
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border-glow);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: var(--neon-purple);
  color: var(--text-primary);
}

.btn-secondary:focus-visible {
  outline: 2px solid var(--neon-cyan);
  outline-offset: 2px;
}

/* ──────────────────────────────────────────────
   #D3 — MODAL (unified replacement for per-page custom modals)
   ────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 9000;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal__panel {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 32px;
  max-width: 480px;
  width: calc(100% - 32px);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(139, 92, 246, 0.1);
}

.modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1;
  transition: color var(--transition), border-color var(--transition);
}

.modal__close:hover {
  color: var(--neon-cyan);
  border-color: var(--neon-cyan);
}

.modal__close:focus-visible {
  outline: 2px solid var(--neon-cyan);
  outline-offset: 2px;
}

/* ──────────────────────────────────────────────
   #D4 — FORM FIELD (unified)
   font-size 16px MIN per iOS auto-zoom prevent (FIX R2)
   ────────────────────────────────────────────── */

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-field__label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.form-field__input,
.form-field__select,
.form-field__textarea {
  font-family: var(--font-body);
  font-size: 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 12px 14px;
  min-height: 44px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  box-sizing: border-box;
}

.form-field__textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
}

.form-field__input:focus,
.form-field__select:focus,
.form-field__textarea:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

.form-field__input[aria-invalid="true"],
.form-field__select[aria-invalid="true"],
.form-field__textarea[aria-invalid="true"] {
  border-color: var(--neon-magenta);
}

.form-field__input::placeholder,
.form-field__textarea::placeholder {
  color: var(--text-muted);
}

.form-field__error {
  color: var(--neon-magenta);
  font-size: 12px;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-field__error::before {
  content: '!';
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--neon-magenta);
  color: var(--bg-primary);
  font-weight: 700;
  text-align: center;
  line-height: 16px;
  font-size: 10px;
  flex-shrink: 0;
}

/* Form checkbox */
.form-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 44px;
  padding: 8px 0;
  cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-glow);
  border-radius: 3px;
  background: var(--bg-input);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  margin-top: 2px;
}

.form-checkbox input[type="checkbox"]:checked {
  background: var(--neon-cyan);
  border-color: var(--neon-cyan);
}

.form-checkbox input[type="checkbox"]:checked::after {
  content: '\2713';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--bg-primary);
  font-size: 14px;
  font-weight: 700;
}

.form-checkbox input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--neon-cyan);
  outline-offset: 2px;
}

.form-checkbox__label {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.form-checkbox__label a {
  color: var(--neon-cyan);
  text-decoration: underline;
}

.form-checkbox__label a:hover {
  color: var(--neon-purple);
}

/* ──────────────────────────────────────────────
   #D5 — SPINNER + LOADING STATE
   ────────────────────────────────────────────── */

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-color);
  border-top-color: var(--neon-cyan);
  border-radius: 50%;
  animation: spinner-rotate 0.8s linear infinite;
  margin: 0 auto;
}

.spinner--small {
  width: 24px;
  height: 24px;
  border-width: 2px;
}

@keyframes spinner-rotate {
  to { transform: rotate(360deg); }
}

.loading-state {
  display: grid;
  place-items: center;
  gap: 16px;
  padding: 64px 24px;
  text-align: center;
}

.loading-state__text {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
  letter-spacing: 1px;
}

@media (prefers-reduced-motion: reduce) {
  .spinner,
  .spinner--small {
    animation-duration: 1.6s;
  }
}

/* ──────────────────────────────────────────────
   #D6 — ERROR STATE COMPONENT
   ────────────────────────────────────────────── */

.error-state {
  display: grid;
  place-items: center;
  gap: 16px;
  padding: 48px 24px;
  text-align: center;
}

.error-state__icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(236, 72, 153, 0.1);
  border: 2px solid var(--neon-magenta);
  color: var(--neon-magenta);
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.error-state__title {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--text-primary);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.error-state__message {
  color: var(--text-secondary);
  max-width: 400px;
  font-size: 15px;
  line-height: 1.6;
}

.error-state__action {
  margin-top: 8px;
}

/* ──────────────────────────────────────────────
   #D10 — STATUS BADGE (unified)
   ────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 16px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge--success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--neon-green);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge--info {
  background: rgba(6, 182, 212, 0.15);
  color: var(--neon-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.badge--warning {
  background: rgba(236, 72, 153, 0.15);
  color: var(--neon-magenta);
  border: 1px solid rgba(236, 72, 153, 0.3);
}

.badge--neutral {
  background: rgba(139, 92, 246, 0.15);
  color: var(--neon-purple);
  border: 1px solid rgba(139, 92, 246, 0.3);
}

/* ──────────────────────────────────────────────
   #D7 — FOOTER COMPLIANCE (full styling)
   Note: more specific than legacy style.css declarations,
   ordered AFTER style.css so cascade wins.
   ────────────────────────────────────────────── */

.footer-compliance {
  margin-top: 64px;
  padding: 32px 20px 24px;
  background: linear-gradient(180deg, transparent 0%, rgba(10, 10, 15, 0.4) 100%);
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.footer-compliance .footer-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.footer-compliance .footer-links a {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  transition: color var(--transition);
  text-decoration: none;
}

.footer-compliance .footer-links a:hover,
.footer-compliance .footer-links a:focus-visible {
  color: var(--neon-cyan);
}

.footer-compliance .footer-copyright {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 720px;
  margin: 0 auto;
  font-style: normal;
}

@media (max-width: 480px) {
  .footer-compliance {
    padding: 24px 16px 20px;
  }
  .footer-compliance .footer-links {
    gap: 12px;
  }
  .footer-compliance .footer-links a {
    font-size: 11px;
  }
  .footer-compliance .footer-copyright {
    font-size: 10px;
  }
}

/* ──────────────────────────────────────────────
   #D9 — PAGE REVEAL STAGGER (CSS-only)
   Apply class .page-reveal to a container; first 5 children stagger in.
   ────────────────────────────────────────────── */

.page-reveal > * {
  opacity: 0;
  animation: page-reveal 0.6s ease-out forwards;
}

.page-reveal > *:nth-child(1) { animation-delay: 0ms; }
.page-reveal > *:nth-child(2) { animation-delay: 80ms; }
.page-reveal > *:nth-child(3) { animation-delay: 160ms; }
.page-reveal > *:nth-child(4) { animation-delay: 240ms; }
.page-reveal > *:nth-child(5) { animation-delay: 320ms; }

@keyframes page-reveal {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .page-reveal > * {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* ──────────────────────────────────────────────
   #D2 — PAGE-LEVEL AMBIENT BACKGROUND (DRY clone of .offer-bg structure)
   Reusable on pay-balance.html, invoice-data.html, etc.
   ────────────────────────────────────────────── */

.page-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.page-bg-grid {
  position: absolute;
  inset: -50%;
  background-image:
    radial-gradient(circle, rgba(139, 92, 246, 0.035) 1px, transparent 1px);
  background-size: 32px 32px;
  animation: page-bg-grid-drift 60s linear infinite;
}

@keyframes page-bg-grid-drift {
  from { transform: translate(0, 0); }
  to   { transform: translate(32px, 32px); }
}

.page-bg-glow {
  position: absolute;
  top: -30%;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 600px;
  background: radial-gradient(ellipse, rgba(6, 182, 212, 0.06) 0%, transparent 70%);
  filter: blur(40px);
}

@media (prefers-reduced-motion: reduce) {
  .page-bg-grid {
    animation: none;
  }
}

/* Page brand strip (clone of .offer-brand) */
.page-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 24px;
  font-family: var(--font-display);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 4px;
  color: rgba(228, 228, 231, 0.35);
  text-transform: uppercase;
}

.page-brand-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--neon-cyan);
  box-shadow: 0 0 8px var(--neon-cyan);
  animation: page-brand-dot-pulse 3s ease-in-out infinite;
}

@keyframes page-brand-dot-pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.3); }
}

@media (prefers-reduced-motion: reduce) {
  .page-brand-dot {
    animation: none;
  }
}

/* Page container (clone of .offer-container) */
.page-container {
  position: relative;
  z-index: 1;
  max-width: 580px;
  width: 100%;
  margin: 0 auto;
  padding: 48px 20px;
}
