/*--------------------------------------------------------------
# Interactions
# Smooth scroll, custom cursor, card spotlight + tilt, hero parallax.
# The effects are switched on by js/interactions.js (desktop pointers only,
# and never when the visitor prefers reduced motion).
--------------------------------------------------------------*/

/* Lenis drives the scrolling, so native smooth scrolling must be off */
html.lenis {
  scroll-behavior: auto !important;
}

/*--------------------------------------------------------------
# Typed caret
# Drawn inside the typed span so it sits where the next letter
# appears, for Arabic (RTL) and Latin (LTR) words alike.
--------------------------------------------------------------*/
.hero .hero-title .typed::after {
  content: "";
  display: inline-block;
  width: 3px;
  height: 0.85em;
  margin-inline-start: 6px;
  vertical-align: -0.05em;
  border-radius: 2px;
  background: currentColor;
  animation: typed-caret 1s steps(1) infinite;
}

@keyframes typed-caret {
  50% {
    opacity: 0;
  }
}

/*--------------------------------------------------------------
# Custom cursor
--------------------------------------------------------------*/
html.has-fx-cursor,
html.has-fx-cursor * {
  cursor: none !important;
}

html.has-fx-cursor input,
html.has-fx-cursor textarea,
html.has-fx-cursor select,
html.has-fx-cursor [contenteditable="true"] {
  cursor: auto !important;
}

.fx-cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2147483000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.fx-cursor.is-visible {
  opacity: 1;
}

.fx-cursor-ring,
.fx-cursor-dot {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
}

.fx-cursor-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-color);
  translate: -50% -50%;
  transition: opacity 0.2s ease;
}

.fx-cursor-ring-inner {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1.5px solid color-mix(in srgb, var(--accent-color), transparent 40%);
  border-radius: 50%;
  background-color: transparent;
  translate: -50% -50%;
  transition:
    width 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    height 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    background-color 0.3s ease,
    border-color 0.3s ease,
    scale 0.2s ease;
}

.fx-cursor-label {
  color: var(--contrast-color);
  font-family: var(--default-font);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.fx-cursor.is-link .fx-cursor-ring-inner {
  width: 58px;
  height: 58px;
  border-color: var(--accent-color);
  background-color: color-mix(in srgb, var(--accent-color), transparent 88%);
}

.fx-cursor.is-view .fx-cursor-ring-inner,
.fx-cursor.is-drag .fx-cursor-ring-inner {
  width: 86px;
  height: 86px;
  border-color: transparent;
  background-color: var(--accent-color);
}

.fx-cursor.is-view .fx-cursor-label,
.fx-cursor.is-drag .fx-cursor-label {
  opacity: 1;
}

.fx-cursor.is-link .fx-cursor-dot,
.fx-cursor.is-view .fx-cursor-dot,
.fx-cursor.is-drag .fx-cursor-dot {
  opacity: 0;
}

.fx-cursor.is-down .fx-cursor-ring-inner {
  scale: 0.85;
}

/* Over accent-coloured areas ([data-cursor-contrast]) the cursor turns white */
.fx-cursor.is-contrast .fx-cursor-dot {
  background: #ffffff;
}

.fx-cursor.is-contrast .fx-cursor-ring-inner {
  border-color: rgba(255, 255, 255, 0.7);
}

.fx-cursor.is-contrast.is-link .fx-cursor-ring-inner {
  border-color: #ffffff;
  background-color: rgba(255, 255, 255, 0.16);
}

/*--------------------------------------------------------------
# Card spotlight + tilt
--------------------------------------------------------------*/
[data-spotlight] {
  position: relative;
  isolation: isolate;
}

/* Glow that follows the pointer, under the card content */
.fx-spotlight {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  background: radial-gradient(420px circle at var(--fx-x, 50%) var(--fx-y, 50%),
      color-mix(in srgb, var(--accent-color), transparent 86%),
      transparent 45%);
}

/* Border highlight near the pointer */
.fx-spotlight::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  background: radial-gradient(260px circle at var(--fx-x, 50%) var(--fx-y, 50%),
      color-mix(in srgb, var(--accent-color), transparent 30%),
      transparent 60%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
}

[data-spotlight].is-lit > .fx-spotlight {
  opacity: 1;
}

/* Project images: a soft light glare over the whole image */
[data-spotlight="glare"] > .fx-spotlight {
  z-index: auto;
  mix-blend-mode: soft-light;
  background: radial-gradient(380px circle at var(--fx-x, 50%) var(--fx-y, 50%),
      rgba(255, 255, 255, 0.35),
      transparent 60%);
}

[data-spotlight="glare"] > .fx-spotlight::before {
  display: none;
}

/* The tilt is smoothed in JS, so transform must not be transitioned */
:is(.services, .skills, .resume, .portfolio) [data-tilt] {
  transition-property: translate, box-shadow, border-color, background-color, color, opacity;
}

[data-tilt].is-tilting {
  will-change: transform;
}

/* Experience cards fill their (animated) grid cell */
.resume [data-tilt] {
  height: 100%;
}

/* Whole project card opens the project page; the overlay icons stay clickable */
.portfolio .portfolio-entry .entry-card-link {
  position: absolute;
  inset: 0;
}

.portfolio .portfolio-entry .entry-image .entry-overlay {
  pointer-events: none;
}

.portfolio .portfolio-entry .entry-image .entry-overlay a,
.portfolio .portfolio-entry .entry-image .entry-overlay .entry-links > * {
  pointer-events: auto;
}

.portfolio .portfolio-entry .entry-image > span {
  pointer-events: none;
}

/*--------------------------------------------------------------
# Hero parallax glow
--------------------------------------------------------------*/
.hero .hero-glow {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  width: 720px;
  height: 720px;
  margin: -360px 0 0 -360px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent-color), transparent 82%) 0%, transparent 65%);
}

.hero.is-lit .hero-glow {
  opacity: 1;
  will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
  .hero .hero-title .typed::after {
    animation: none;
  }
}
