/* ==========================================================================
   Fazil Məmmədzadə — Portfolio
   Design tokens, atmosphere, motion system, components
   ========================================================================== */

:root {
  --bg: #06090A;
  --bg-soft: #0F0A0A;
  --surface: #151010;
  --surface-2: #1D1616;
  --border: #2B2121;
  --text: #ECF1EC;
  --text-muted: #A39393;
  --text-dim: #6E5E5E;

  --accent: #E53935;
  --accent-bright: #FF6B6B;
  --accent-dim: #3A1010;
  --accent-warm: #E8A15C;
  --accent-warm-dim: #3A2A16;

  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  --ease-out: cubic-bezier(0.16, 0.84, 0.44, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --radius: 14px;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #F6F8F6;
  --bg-soft: #EFF3EF;
  --surface: #FFFFFF;
  --surface-2: #F1F5F2;
  --border: #DBE4DD;
  --text: #140E0E;
  --text-muted: #655656;
  --text-dim: #968A8A;

  --accent: #C62828;
  --accent-bright: #D32F2F;
  --accent-dim: #FDE7E7;
  --accent-warm: #B9722E;
  --accent-warm-dim: #F5E7D5;
  color-scheme: light;
}

* { scrollbar-color: var(--accent-dim) var(--bg); box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  transition: background-color .4s ease, color .4s ease;
  overflow-x: hidden;
  cursor: none;
}
/* Force the custom cursor everywhere — links, buttons, inputs, textareas —
   overriding browser default cursors (pointer/text/etc). */
body, body a, body button, body input, body textarea, body select, body label,
body *, body *::before, body *::after {
  cursor: none !important;
}
@media (hover: none), (pointer: coarse) {
  body, body a, body button, body input, body textarea, body select, body label, body * {
    cursor: auto !important;
  }
}

.font-display { font-family: var(--font-display); }
.font-mono { font-family: var(--font-mono); }

::selection { background: var(--accent); color: #1A0505; }

a, button { -webkit-tap-highlight-color: transparent; }

/* ==========================================================================
   Ambient background layers: grid, blobs, noise
   ========================================================================== */

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, color-mix(in srgb, var(--border) 55%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--border) 55%, transparent) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(ellipse 80% 55% at 50% 0%, black 10%, transparent 75%);
  mask-image: radial-gradient(ellipse 80% 55% at 50% 0%, black 10%, transparent 75%);
  opacity: .5;
}

.bg-noise {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: .035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

.blob {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  border-radius: 50%;
  filter: blur(90px);
  will-change: transform;
  transition: transform 1.2s var(--ease-out);
}
.blob-a { width: 46vw; height: 46vw; top: -14vw; left: -10vw; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 30%, transparent), transparent 70%); }
.blob-b { width: 38vw; height: 38vw; top: 12vw; right: -12vw; background: radial-gradient(circle, color-mix(in srgb, var(--accent-warm) 20%, transparent), transparent 70%); }
.blob-c { width: 30vw; height: 30vw; bottom: -10vw; left: 30vw; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%); }

main, header, footer { position: relative; z-index: 2; }

/* ==========================================================================
   Custom cursor — dual-tone, interpolated, reactive
   ========================================================================== */

.cursor-dot, .cursor-ring, .cursor-glow {
  position: fixed; top: 0; left: 0; pointer-events: none; z-index: 9999;
  transform: translate(-50%, -50%);
  will-change: transform;
}
.cursor-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-bright);
  transition: opacity .2s ease, width .2s var(--ease-spring), height .2s var(--ease-spring);
}
.cursor-ring {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--accent-bright) 70%, transparent);
  transition: width .25s var(--ease-spring), height .25s var(--ease-spring), border-color .25s ease, opacity .25s ease;
}
.cursor-glow {
  width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent-warm) 16%, transparent), transparent 70%);
  opacity: 0; transition: opacity .3s ease;
}
body.cursor-active .cursor-glow { opacity: 1; }
.cursor-ring.is-hover { width: 56px; height: 56px; border-color: var(--accent-warm); background: color-mix(in srgb, var(--accent-warm) 8%, transparent); }
.cursor-dot.is-hover { opacity: 0; }
.cursor-ring.is-down { width: 26px; height: 26px; }
@media (hover: none), (pointer: coarse) {
  .cursor-dot, .cursor-ring, .cursor-glow { display: none; }
}

/* ==========================================================================
   Motion: reveal, stagger, headline chars
   ========================================================================== */

.reveal {
  opacity: 0;
  transform: translateY(28px);
  filter: blur(6px);
  transition: opacity .8s var(--ease-out), transform .8s var(--ease-out), filter .8s var(--ease-out);
  transition-delay: calc(var(--reveal-delay, 0) * 1ms);
}
.reveal.visible { opacity: 1; transform: translateY(0); filter: blur(0); }

.char {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.5em) rotate(4deg);
  filter: blur(4px);
  animation: charIn .7s var(--ease-out) forwards;
  animation-delay: calc(var(--i, 0) * 32ms);
}
@keyframes charIn { to { opacity: 1; transform: translateY(0) rotate(0); filter: blur(0); } }

/* ==========================================================================
   Nav
   ========================================================================== */

.nav-link {
  position: relative;
  color: var(--text-muted);
  padding: 4px 1px;
  transition: color .3s ease, transform .3s var(--ease-spring);
}
.nav-link::before {
  content: '';
  position: absolute; left: 50%; bottom: -12px; width: 4px; height: 4px;
  background: var(--accent-bright);
  border-radius: 50%;
  transform: translate(-50%, 6px) scale(0);
  opacity: 0;
  transition: transform .35s var(--ease-spring), opacity .25s ease;
}
.nav-link::after {
  content: '';
  position: absolute; left: 50%; right: 50%; bottom: -4px; height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent-bright) 70%, transparent);
  transition: left .35s var(--ease-out), right .35s var(--ease-out);
}
.nav-link:hover, .nav-link.active { color: var(--text); transform: translateY(-1px); }
.nav-link.active::after, .nav-link:hover::after { left: 0; right: 0; }
.nav-link.active::before, .nav-link:hover::before { transform: translate(-50%, 0) scale(1); opacity: 1; }

#scrollProgress {
  position: fixed; top: 0; left: 0; height: 2px; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright), var(--accent-warm));
  z-index: 60; transition: width .1s linear;
}

/* ==========================================================================
   Terminal
   ========================================================================== */

.term-window {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 40px 100px -40px rgba(0,0,0,.65), inset 0 1px 0 color-mix(in srgb, white 4%, transparent);
  position: relative;
  overflow: hidden;
}
.term-window::before {
  content: '';
  position: absolute; inset: -1px;
  background: conic-gradient(from var(--angle, 0deg), transparent 0deg, color-mix(in srgb, var(--accent-bright) 45%, transparent) 40deg, transparent 90deg);
  z-index: -1;
  animation: rotateBorder 6s linear infinite;
  opacity: .5;
}
@keyframes rotateBorder { to { --angle: 360deg; } }
@property --angle { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

html[data-theme="light"] .term-window { box-shadow: 0 30px 80px -40px rgba(198,40,40,.2); }
.term-line { white-space: pre; }
.caret { display: inline-block; width: 7px; height: 15px; background: var(--accent-bright); animation: blink 1s steps(1) infinite; vertical-align: -2px; }
@keyframes blink { 50% { opacity: 0; } }

/* ==========================================================================
   Cards, tilt, magnetic
   ========================================================================== */

.eyebrow::before { content: '— '; color: var(--accent-bright); }

.tilt-card {
  transition: transform .25s var(--ease-out), border-color .3s ease, box-shadow .3s ease;
  transform-style: preserve-3d;
  will-change: transform;
  position: relative;
  overflow: hidden;
}
.tilt-card:hover {
  border-color: var(--accent);
  box-shadow: 0 24px 60px -30px rgba(229,57,53,.35);
}
.tilt-card::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(180px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--accent-bright) 12%, transparent), transparent 70%);
  opacity: 0;
  transition: opacity .35s ease;
  pointer-events: none;
}
.tilt-card:hover::before { opacity: 1; }

/* Focus cards — number badge animates in and reacts on hover */
#focusGrid .tilt-card .focus-num {
  display: inline-block;
  transition: transform .45s var(--ease-spring), color .3s ease;
}
#focusGrid .tilt-card:hover .focus-num {
  transform: scale(1.35) rotate(-8deg) translateX(2px);
  color: var(--accent-warm);
}
#focusGrid .tilt-card h3 {
  transition: transform .3s var(--ease-out), color .3s ease;
}
#focusGrid .tilt-card:hover h3 {
  transform: translateX(4px);
}

.magnetic { display: inline-flex; will-change: transform; }
.magnetic > * { display: inline-flex; transition: transform .15s var(--ease-out); }

.glass {
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
}

#backToTop { opacity: 0; pointer-events: none; transition: opacity .3s ease, transform .3s var(--ease-spring); }
#backToTop.show { opacity: 1; pointer-events: auto; }

.card-hover { transition: transform .35s var(--ease-out), border-color .3s ease, box-shadow .3s ease; }
.card-hover:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 20px 45px -25px rgba(229,57,53,.3); }

/* Skill chips — perfectly uniform, no hierarchy */
.skill-chip {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  transition: color .25s ease, border-color .25s ease, transform .25s var(--ease-spring), background .25s ease;
}
.skill-chip:hover {
  color: var(--accent-bright);
  border-color: var(--accent);
  transform: translateY(-2px);
  background: var(--accent-dim);
}

/* Workflow step numbers */
.step-num {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent-bright);
  border: 1px solid var(--border);
  background: var(--accent-dim);
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  position: relative;
  transform: scale(0) rotate(-50deg);
  opacity: 0;
  transition: transform .6s var(--ease-spring), opacity .4s ease, background .3s ease, color .3s ease, border-color .3s ease, box-shadow .35s ease;
}
#workflowList .reveal.visible .step-num {
  transform: scale(1) rotate(0deg);
  opacity: 1;
  animation: stepPulse 2.6s ease-in-out .6s infinite;
}
@keyframes stepPulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-bright) 35%, transparent); }
  50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent-bright) 0%, transparent); }
}
#workflowList .flex.gap-5:hover .step-num {
  background: var(--accent);
  color: #1A0505;
  border-color: var(--accent);
  transform: scale(1.15) rotate(6deg);
}

.step-line {
  background: linear-gradient(to bottom, var(--border), transparent);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform .9s var(--ease-out);
  transition-delay: .25s;
}
#workflowList .reveal.visible .step-line { transform: scaleY(1); }

#workflowList .flex.gap-5 h4 {
  transition: color .3s ease, transform .3s var(--ease-out);
}
#workflowList .flex.gap-5:hover h4 {
  color: var(--accent-bright);
  transform: translateX(4px);
}

@media (prefers-reduced-motion: reduce) {
  *, .char, .reveal, .term-window::before {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

canvas#netCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ==========================================================================
   Certificates — Alibeg Begow inspired, matched to existing design language
   ========================================================================== */

#certificatesGrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
  align-items: stretch;
}
@media (max-width: 1023px) {
  #certificatesGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 639px) {
  #certificatesGrid { grid-template-columns: 1fr; }
}

.cert-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  cursor: none;
  transition:
    transform 400ms var(--ease-out),
    border-color 400ms var(--ease-out),
    box-shadow 400ms var(--ease-out);
  will-change: transform, box-shadow;
}
.cert-card:hover {
  transform: translateY(-6px);
  border-color: var(--accent);
  box-shadow:
   0 28px 70px -30px rgba(229, 57, 53, 0.35),
    0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
}
@media (hover: none), (pointer: coarse) {
  .cert-card { cursor: pointer; }
}

.cert-card__media {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}
.cert-card__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0.75rem;
  /* default — calm, almost grayscale, no purple */
  filter:
    grayscale(0.95)
    saturate(0.35)
    brightness(0.9)
    contrast(0.92);
  transform: scale(1);
  transition:
    filter 400ms var(--ease-out),
    transform 400ms var(--ease-out);
  will-change: filter, transform;
}
.cert-card:hover .cert-card__img {
  /* hover — full color, purple Udemy logo emerges */
  filter:
    grayscale(0)
    saturate(1)
    brightness(1)
    contrast(1);
  transform: scale(1.015);
}

.cert-card__body {
  padding: 1.1rem 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 1;
}
.cert-card__provider {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-bright);
  transition: color 350ms var(--ease-out);
}
.cert-card__provider::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-bright);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-bright) 18%, transparent);
  transition: box-shadow 350ms var(--ease-out);
}
.cert-card:hover .cert-card__provider::before {
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent-bright) 28%, transparent);
}

.cert-card__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.98rem;
  line-height: 1.35;
  color: var(--text);
  letter-spacing: -0.005em;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 350ms var(--ease-out);
}

.cert-card__desc {
  font-size: 0.825rem;
  line-height: 1.55;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cert-card__date {
  margin-top: auto;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: color 350ms var(--ease-out), border-color 350ms var(--ease-out);
}
.cert-card:hover .cert-card__date { color: var(--text-muted); }
.cert-card__date svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  color: var(--accent-bright);
  opacity: 0.8;
  transition: opacity 350ms var(--ease-out);
}
.cert-card:hover .cert-card__date svg { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .cert-card,
  .cert-card__img,
  .cert-card__provider,
  .cert-card__provider::before,
  .cert-card__title,
  .cert-card__date,
  .cert-card__date svg {
    transition-duration: 0.001ms !important;
  }
}
