/**
 * css/lens-affordance.css
 * F-102 v2 — Premium "another way to see this" affordance
 * Appears on quiz, flashcard, and learn-mode completion screens
 * when a student meets the struggle threshold and the
 * ff-f102-reexplanation-lenses flag is enabled.
 *
 * Design reference: tools/test-pages/lens-ai-affordance-design.html
 * Aesthetic anchor: PrepWiseVault/06-Guides/F-102-v2-aesthetic-anchor.md
 */

/* ─── Breathing glow keyframe ────────────────────────────────────── */
@keyframes lens-breathe {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);
    border-color: rgba(139, 92, 246, 0.35);
  }
  50% {
    box-shadow: 0 0 24px 4px rgba(139, 92, 246, 0.22);
    border-color: rgba(139, 92, 246, 0.55);
  }
}

/* ─── Main card ───────────────────────────────────────────────────── */
.lens-affordance {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  margin: 0 0 28px;
  border: 1.5px solid rgba(139, 92, 246, 0.35);
  /* Mesh gradient bleeds through glass (dark default) */
  background: linear-gradient(
    135deg,
    rgba(139, 92, 246, 0.18) 0%,
    rgba(59, 130, 246, 0.12) 50%,
    rgba(139, 92, 246, 0.08) 100%
  );
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: lens-breathe 3s ease-in-out infinite;
}

/* Radial mesh gradient layer behind the glass (decorative) */
.lens-affordance::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(139, 92, 246, 0.28) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 30%, rgba(59, 130, 246, 0.20) 0%, transparent 55%);
  pointer-events: none;
  z-index: 0;
}

/* Light mode — reduce opacity of mesh so it doesn't overpower */
[data-theme="light"] .lens-affordance {
  background: linear-gradient(
    135deg,
    rgba(139, 92, 246, 0.10) 0%,
    rgba(59, 130, 246, 0.06) 50%,
    rgba(139, 92, 246, 0.04) 100%
  );
  border-color: rgba(139, 92, 246, 0.30);
}

/* Disable breathing glow when prefers-reduced-motion is set (AC13) */
@media (prefers-reduced-motion: reduce) {
  .lens-affordance {
    animation: none;
  }
}

/* ─── Inner content wrapper (above the ::before mesh layer) ──────── */
.lens-affordance-inner {
  position: relative;
  z-index: 1;
  padding: 22px 20px 18px;
}

/* ─── Dismiss button ─────────────────────────────────────────────── */
.lens-dismiss {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  z-index: 2;
  transition: background 0.15s;
  /* Ensure 44px minimum touch target via pseudo-element */
  padding: 0;
}

.lens-dismiss::after {
  content: '';
  position: absolute;
  inset: -8px; /* expand tap area to 44px without changing visual size */
}

.lens-dismiss:hover {
  background: rgba(255, 255, 255, 0.15);
}

[data-theme="light"] .lens-dismiss {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.10);
}

[data-theme="light"] .lens-dismiss:hover {
  background: rgba(0, 0, 0, 0.10);
}

/* ─── Header row (sparkle icon + copy) ──────────────────────────── */
.lens-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  /* leave room for dismiss button on right */
  padding-right: 32px;
}

.lens-sparkle {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #8b5cf6, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The sparkle SVG must stay white regardless of the light-mode
   mega-selector (body.light-mode div { color !important }).
   We set fill via JS after insertion — this is the CSS baseline. */
.lens-sparkle svg {
  width: 20px;
  height: 20px;
  color: white;
  fill: none;
  stroke: white;
}

/* ─── Copy ───────────────────────────────────────────────────────── */
.lens-headline {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.lens-subtext {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ─── CTA row ────────────────────────────────────────────────────── */
.lens-ctas {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Primary CTA — gradient pill, minimum 44px height */
.lens-cta-primary {
  flex: 1;
  min-width: 120px;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 12px;
  background: linear-gradient(135deg, #8b5cf6, #3b82f6);
  color: white;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-align: center;
  transition: opacity 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
}

.lens-cta-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.lens-cta-primary:active {
  transform: scale(0.98);
}

.lens-cta-primary svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Secondary CTA — ghost, minimum 44px height */
.lens-cta-secondary {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  font-family: inherit;
}

.lens-cta-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

[data-theme="light"] .lens-cta-secondary {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .lens-cta-secondary:hover {
  background: rgba(0, 0, 0, 0.08);
}

/* ─── Reduced-motion: keep layout, kill animation only ───────────── */
@media (prefers-reduced-motion: reduce) {
  .lens-cta-primary,
  .lens-cta-secondary,
  .lens-dismiss {
    transition: none;
  }

  .lens-cta-primary:hover {
    transform: none;
  }
}
