/* ==========================================================================
   Interaction layer: page transitions, hover choreography, code window
   ========================================================================== */

/* ---- Page entrance: two glowing doors part, content rises behind them ---- */
html::before,
html::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  height: 50.5%;
  z-index: 9990;
  pointer-events: none;
  background:
    repeating-linear-gradient(90deg, rgba(139, 92, 255, 0.16) 0 1px, transparent 1px 25%),
    linear-gradient(to bottom, rgba(139, 92, 255, 0) 80%, rgba(139, 92, 255, 0.5)),
    linear-gradient(118deg, rgba(139, 92, 255, 0.24), rgba(53, 224, 255, 0.10) 46%, rgba(255, 117, 181, 0.16)),
    #08080f;
  will-change: transform;
}

html::before {
  top: 0;
  border-bottom: 1px solid rgba(139, 92, 255, 0.75);
  animation: doorTop 0.74s cubic-bezier(0.83, 0, 0.17, 1) 0.05s both;
}

html::after {
  bottom: 0;
  border-top: 1px solid rgba(53, 224, 255, 0.6);
  background:
    repeating-linear-gradient(90deg, rgba(53, 224, 255, 0.14) 0 1px, transparent 1px 25%),
    linear-gradient(to top, rgba(53, 224, 255, 0) 80%, rgba(53, 224, 255, 0.45)),
    linear-gradient(118deg, rgba(139, 92, 255, 0.24), rgba(53, 224, 255, 0.10) 46%, rgba(255, 117, 181, 0.16)),
    #08080f;
  animation: doorBottom 0.74s cubic-bezier(0.83, 0, 0.17, 1) 0.05s both;
}

/* the seam lights up as the panels start to part, instead of being at full
   brightness on the very first frame */
@keyframes doorTop {
  0% { transform: translateY(0); filter: brightness(0.18); }
  45% { filter: brightness(1); }
  100% { transform: translateY(-100.6%); }
}

@keyframes doorBottom {
  0% { transform: translateY(0); filter: brightness(0.18); }
  45% { filter: brightness(1); }
  100% { transform: translateY(100.6%); }
}

main { animation: contentOpen 0.8s cubic-bezier(0.19, 1, 0.22, 1) 0.32s both; }

@keyframes contentOpen {
  from { opacity: 0; transform: translateY(30px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

/* Hero lines wipe up from their own baseline */
.hero-title .line {
  animation: lineWipe 1.1s cubic-bezier(0.19, 1, 0.22, 1) both;
}

.hero-title .line:nth-child(1) { animation-delay: 0.5s; }
.hero-title .line:nth-child(2) { animation-delay: 0.6s; }

@keyframes lineWipe {
  from { opacity: 0; transform: translateY(0.45em) skewY(2.5deg); clip-path: inset(0 0 100% 0); }
  to { opacity: 1; transform: none; clip-path: inset(-25% 0 -25% 0); }
}

.hero-label,
.hero-tagline,
.type-line,
.hero-actions {
  animation: riseIn 0.95s cubic-bezier(0.19, 1, 0.22, 1) both;
}

.hero-label { animation-delay: 0.42s; }
.hero-tagline { animation-delay: 0.68s; }
.type-line { animation-delay: 0.78s; }
.hero-actions { animation-delay: 0.86s; }

.page-head-inner > *,
.contact-copy > * { animation: riseIn 0.95s cubic-bezier(0.19, 1, 0.22, 1) both; }

.page-head-inner > *:nth-child(1),
.contact-copy > *:nth-child(1) { animation-delay: 0.38s; }

.page-head-inner > *:nth-child(2),
.contact-copy > *:nth-child(2) { animation-delay: 0.46s; }

.page-head-inner > *:nth-child(3),
.contact-copy > *:nth-child(3) { animation-delay: 0.54s; }

@keyframes riseIn {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}

/* Hero code lines type themselves in */
.code-line:nth-child(1) { animation-delay: 0.05s; }
.code-line:nth-child(2) { animation-delay: 0.1s; }
.code-line:nth-child(3) { animation-delay: 0.15s; }
.code-line:nth-child(4) { animation-delay: 0.2s; }
.code-line:nth-child(5) { animation-delay: 0.25s; }
.code-line:nth-child(6) { animation-delay: 0.3s; }
.code-line:nth-child(7) { animation-delay: 0.35s; }
.code-line:nth-child(8) { animation-delay: 0.4s; }
.code-line:nth-child(9) { animation-delay: 0.45s; }
.code-line:nth-child(10) { animation-delay: 0.5s; }
.code-line:nth-child(11) { animation-delay: 0.55s; }
.code-line:nth-child(12) { animation-delay: 0.6s; }
.code-line:nth-child(13) { animation-delay: 0.65s; }

/* ---- Page exit: four pillars rise while the laser cuts across them ----
   Both start on the same frame, so the pillars appear to tear the laser
   open as they come up instead of waiting for it to finish. */
.page-curtain {
  position: fixed;
  inset: 0;
  z-index: 9995;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  pointer-events: none;
  overflow: hidden;
}

/* the beam: full width, through the middle of the screen */
.page-curtain::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 3px;
  margin-top: -1.5px;
  z-index: 2;
  background: linear-gradient(90deg,
    transparent,
    rgba(139, 92, 255, 0.9) 14%,
    rgba(53, 224, 255, 1) 36%,
    #ffffff 50%,
    rgba(255, 117, 181, 1) 64%,
    rgba(139, 92, 255, 0.9) 86%,
    transparent);
  box-shadow:
    0 0 12px rgba(255, 255, 255, 0.6),
    0 0 34px rgba(53, 224, 255, 0.6),
    0 0 90px 10px rgba(139, 92, 255, 0.45);
  transform: scaleX(0);
  transform-origin: left;
  opacity: 0;
  transition: transform 0.26s cubic-bezier(0.65, 0, 0.35, 1);
}

/* the beam blooms in as it starts to cut instead of snapping on */
.page-curtain.is-out::before {
  transform: scaleX(1);
  animation: laserIn 0.22s ease-out both;
}

@keyframes laserIn {
  0% { opacity: 0; filter: blur(9px); }
  100% { opacity: 1; filter: blur(0); }
}

.page-curtain .pillar {
  position: relative;
  transform: translateY(101%);
  background: linear-gradient(180deg, #0b0c18, #0a0a14 60%, #0d0d1e);
  border-left: 1px solid rgba(139, 92, 255, 0.22);
  transition: transform 0.4s cubic-bezier(0.76, 0, 0.24, 1);
}

/* every pillar carries its own cutting edge */
.page-curtain .pillar::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, rgba(139, 92, 255, 1), rgba(255, 255, 255, 0.85) 50%, rgba(53, 224, 255, 1));
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.35), 0 0 34px rgba(53, 224, 255, 0.55);
}

.page-curtain .pillar:nth-child(2) { transition-delay: 0.04s; }
.page-curtain .pillar:nth-child(3) { transition-delay: 0.07s; }
.page-curtain .pillar:nth-child(4) { transition-delay: 0.1s; }

.page-curtain.is-out .pillar { transform: translateY(0); }

/* ---- Bottom bloom: lit by the laser, then a slow five-second fade ---- */
.scene-bloom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 320px;
  z-index: 9992;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.15s cubic-bezier(0.4, 0, 0.2, 1);
  background:
    radial-gradient(62% 130% at 50% 128%, rgba(139, 92, 255, 0.34), rgba(255, 117, 181, 0.12) 52%, transparent 78%),
    radial-gradient(38% 96% at 84% 136%, rgba(53, 224, 255, 0.16), transparent 74%);
}

.scene-bloom.is-on {
  opacity: 0.9;
  transition: opacity 0.26s ease-out;
}

.scene-bloom.is-fading { opacity: 0; transition: opacity 5s cubic-bezier(0.4, 0, 0.2, 1); }
.scene-bloom.is-instant { transition: none; }

/* ---- Scroll reveal: a slight shear-lift instead of a plain fade ---- */
.reveal {
  opacity: 0;
  transform: translateY(34px) skewY(0.85deg);
  transform-origin: left center;
  transition: opacity 0.6s var(--ease), transform 0.95s cubic-bezier(0.19, 1, 0.22, 1);
}

.reveal.visible { opacity: 1; transform: none; }

/* ---- Buttons ---- */
.btn-primary {
  background-image: linear-gradient(115deg,
    var(--violet) 0%, var(--cyan) 34%, var(--pink) 54%, var(--cyan) 74%, var(--violet) 100%);
  background-size: 260% 100%;
  background-position: 0% 50%;
  transition: background-position 0.9s var(--ease), transform 0.3s var(--ease), box-shadow 0.35s var(--ease);
}

.btn-primary:hover { background-position: 100% 50%; }
.btn:active { transform: translateY(-1px) scale(0.982); }
.btn svg { transition: transform 0.38s var(--ease); }
.btn:hover svg { transform: translateX(4px); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.06); }

/* ---- Nav (desktop): one underline only, smooth CTA hover ---- */
@media (min-width: 821px) {
  .nav-links a:not(.nav-cta) { position: relative; }

  .nav-links a:not(.nav-cta)::before {
    content: "";
    position: absolute;
    left: 15px;
    right: 15px;
    bottom: 6px;
    height: 1px;
    background: var(--grad);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.38s var(--ease);
  }

  .nav-links a.active::before { display: none; }
  .nav-links a:not(.nav-cta):not(.active):hover::before { transform: scaleX(1); }

  .nav-links a.nav-cta {
    transition: background 0.4s var(--ease), border-color 0.4s var(--ease),
                color 0.4s var(--ease), box-shadow 0.4s var(--ease);
  }

  .nav-links a.nav-cta:hover {
    background: rgba(139, 92, 255, 0.16);
    color: var(--text);
    border-color: rgba(139, 92, 255, 0.55);
    box-shadow: 0 12px 28px -18px rgba(139, 92, 255, 0.9);
  }
}

/* ---- Mobile sheet: the links arrive one after another ---- */
@media (max-width: 820px) {
  .nav-links.open li { animation: menuItem 0.5s cubic-bezier(0.19, 1, 0.22, 1) both; }
  .nav-links.open li:nth-child(1) { animation-delay: 0.05s; }
  .nav-links.open li:nth-child(2) { animation-delay: 0.1s; }
  .nav-links.open li:nth-child(3) { animation-delay: 0.15s; }
  .nav-links.open li:nth-child(4) { animation-delay: 0.2s; }
}

@keyframes menuItem {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

/* ---- Touch: hover effects replaced by press feedback ---- */
@media (hover: none) {
  .btn:active { transform: scale(0.97); }
  .project-card:active { border-color: rgba(139, 92, 255, 0.6); transform: translateY(-2px); }
  .code-line:active { background: rgba(139, 92, 255, 0.16); }
  .chip:active,
  .filter-btn:active { background: rgba(139, 92, 255, 0.18); color: var(--text); }
  .contact-item:active { border-color: rgba(139, 92, 255, 0.6); background: rgba(139, 92, 255, 0.08); }
  .contact-arrow { border-color: rgba(139, 92, 255, 0.45); color: var(--text); }
  .nav-links a:active { background: rgba(255, 255, 255, 0.06); }
}

/* ---- Soft light that follows the pointer, behind every section ---- */
.pointer-glow {
  position: fixed;
  top: 0;
  left: 0;
  width: 680px;
  height: 680px;
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
  opacity: 0;
  filter: blur(40px);
  background: radial-gradient(circle,
    rgba(139, 92, 255, 0.2),
    rgba(53, 224, 255, 0.09) 45%,
    transparent 72%);
  transition: opacity 0.8s var(--ease);
  will-change: transform;
}

/* ---- Logo mark: shine sweep + one full turn ---- */
.nav-mark {
  position: relative;
  overflow: hidden;
  transition: transform 0.85s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.5s var(--ease);
}

.nav-mark::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -60%;
  width: 45%;
  height: 200%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.9), transparent);
  transform: rotate(16deg) translateX(-160%);
  transition: transform 1.15s var(--ease);
  pointer-events: none;
}

.nav-logo:hover .nav-mark {
  transform: rotateY(360deg);
  box-shadow: 0 14px 34px -10px rgba(139, 92, 255, 0.95);
}

.nav-logo:hover .nav-mark::after { transform: rotate(16deg) translateX(420%); }

@keyframes markSpin {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(360deg); }
}

@keyframes markSweep {
  0% { transform: rotate(16deg) translateX(-160%); }
  100% { transform: rotate(16deg) translateX(420%); }
}

.nav-mark.is-spinning { animation: markSpin 0.95s cubic-bezier(0.22, 1, 0.36, 1); }
.nav-mark.is-spinning::after { animation: markSweep 1.15s var(--ease); }

/* ---- CTA band: its glow tightens, the band lifts, a sheen crosses it ---- */
.cta-band::before,
.cta-band::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: 0;
}

.cta-band::before {
  inset: -22%;
  background:
    radial-gradient(closest-side at 26% 30%, rgba(139, 92, 255, 0.20), transparent 74%),
    radial-gradient(closest-side at 76% 72%, rgba(53, 224, 255, 0.14), transparent 74%);
  transition: transform 0.7s var(--ease);
}

.cta-band::after {
  top: -60%;
  bottom: -60%;
  left: 0;
  width: 34%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  transform: translateX(-170%) rotate(8deg);
  transition: transform 1.1s var(--ease);
}

.cta-band > * { position: relative; z-index: 1; }

/* window controls draw their glyphs while the window is hovered or awake */
.code-card:hover .code-dot::after,
.code-card.is-live .code-dot::after { opacity: 1; }

/* the tap state lives here so it still beats the flat mobile card rules */
.code-card.is-live {
  transform: perspective(900px) rotateY(5deg) rotateX(-4deg) translateY(-14px) scale(1.02);
  border-color: rgba(139, 92, 255, 0.45);
  box-shadow: 0 60px 120px -45px rgba(139, 92, 255, 0.6);
}

.cta-band {
  transition: transform 0.5s var(--ease), box-shadow 0.5s var(--ease);
}

@media (hover: hover) {
  .cta-band:hover::before { transform: scale(0.8); }
  .cta-band:hover::after { transform: translateX(430%) rotate(8deg); }

  .cta-band:hover {
    transform: translateY(-6px);
    box-shadow: 0 40px 90px -60px rgba(139, 92, 255, 0.95);
  }
}

@media (prefers-reduced-motion: reduce) {
  main { animation: none; }
  .pointer-glow, .scene-bloom, .page-curtain { display: none; }
  .code-line { animation: none; }
  .btn-primary { background-position: 0% 50%; }
}
