/* ============================================================
   interactive.css — Cursor glow, scroll bar, magnetic,
                     tilt cards, typed text, glitch hover
   ============================================================ */

/* ── Cursor Glow ──────────────────────────────────────────── */
.cursor-glow {
  position: fixed;
  top: 0;
  left: 0;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease;
  transform: translate(-50%, -50%);
  background: var(--color-bg);
  mix-blend-mode: screen;
}

.cursor-glow.visible {
  opacity: 1;
}

@media (pointer: coarse) {
  .cursor-glow { display: none; }
}

/* ── Scroll Progress Bar ─────────────────────────────────── */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  z-index: 10001;
  background: var(--color-bg);
  transition: width 0.1s linear;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ── Loading Screen ──────────────────────────────────────── */
.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.loading-screen__spinner {
  width: 36px;
  height: 36px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Magnetic Buttons ────────────────────────────────────── */
.magnetic {
  will-change: transform;
  transition: transform 0.15s ease-out;
}

/* ── 3D Tilt Cards ───────────────────────────────────────── */
.tilt-card {
  will-change: transform;
  transform-style: preserve-3d;
  transition: transform 0.1s ease-out;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.tilt-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(
      circle at var(--glow-x, 50%) var(--glow-y, 0%),
      rgba(129, 140, 248, 0.18),
      transparent 46%
    ),
    linear-gradient(135deg, rgba(34, 211, 238, 0.08), transparent 62%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 0;
  border-radius: inherit;
}

.tilt-card:hover::before {
  opacity: 1;
}

.tilt-card > * {
  position: relative;
  z-index: 1;
}

@media (pointer: coarse) {
  .tilt-card::before { display: none; }
}

/* ── Typed Text Effect ───────────────────────────────────── */
.typed.typing::after {
  content: '|';
  display: inline-block;
  animation: blink 0.6s step-end infinite;
  color: var(--color-cyan);
  margin-left: 2px;
  font-weight: 300;
}

.typed-done::after {
  content: none;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ── Glitch Hover ────────────────────────────────────────── */
.glitch-hover {
  position: relative;
  cursor: default;
}

.glitch-hover.glitching {
  animation: glitchText 0.3s steps(2) forwards;
}

@keyframes glitchText {
  0% { text-shadow: 2px 0 var(--color-cyan), -2px 0 var(--color-accent); }
  20% { text-shadow: -2px 2px var(--color-emerald), 2px -2px var(--color-accent); }
  40% { text-shadow: 2px -2px var(--color-cyan), -2px 2px var(--color-emerald); }
  60% { text-shadow: -1px 0 var(--color-accent), 1px 0 var(--color-cyan); }
  80% { text-shadow: 1px 1px var(--color-emerald), -1px -1px var(--color-cyan); }
  100% { text-shadow: none; }
}

/* ── Rotating Questions ──────────────────────────────────── */
.hero__rotator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15em;
  font-size: 0.55em;
  font-weight: inherit;
  letter-spacing: -0.02em;
  margin: 0;
  min-height: 2.8em;
  padding: 0;
}

.hero__rotator-question {
  font-family: var(--font-mono);
  font-weight: inherit;
  position: relative;
  white-space: nowrap;
}

.hero__rotator-question.rotator-typing::after {
  content: '▎';
  display: inline;
  animation: blink 0.5s step-end infinite;
  margin-left: 1px;
}

.hero__rotator-answer {
  font-family: var(--font-mono);
  font-weight: inherit;
  white-space: nowrap;
  display: block;
  width: 100%;
  text-align: center;
}

/* ── Hero Lines stagger ──────────────────────────────────── */
.hero__line {
  display: block;
  opacity: 0;
  transform: translateY(20px);
  animation: heroLineIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.hero__line:nth-child(1) { animation-delay: 0.2s; }
.hero__line:nth-child(2) { animation-delay: 0.4s; }
.hero__line:nth-child(3) { animation-delay: 0.6s; }

@keyframes heroLineIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Reduced Motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .cursor-glow,
  .scroll-progress { display: none; }

  .hero__line {
    opacity: 1;
    transform: none;
    animation: none;
  }

  .tilt-card::before { display: none; }
  .glitch-hover.glitching { animation: none; }
  .typed.typing::after { animation: none; }
}

/* ── Light Mode Overrides ────────────────────────────────── */
[data-theme="light"] .cursor-glow {
  background: var(--color-bg);
}

[data-theme="light"] .loading-screen__spinner {
  border-color: rgba(0, 0, 0, 0.08);
  border-top-color: var(--color-accent);
}

[data-theme="light"] .tilt-card::before {
  background:
    radial-gradient(
      circle at var(--glow-x, 50%) var(--glow-y, 0%),
      rgba(79, 70, 229, 0.12),
      transparent 48%
    ),
    linear-gradient(135deg, rgba(34, 211, 238, 0.08), transparent 64%);
}
