/* ============================================================
   Professional enhancements — animations, preloader, polish
   ============================================================ */

:root {
  --code-font: "JetBrains Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
  --pro-accent: #19a7ff;
  --pro-accent-2: #14b87d;
  --pro-accent-3: #f6c34a;
  --pro-radius: 18px;
  --pro-shadow: 0 24px 60px rgba(3, 10, 24, 0.28);
  --pro-glow: 0 0 40px rgba(25, 167, 255, 0.22);
  --pro-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

body.preloader-active {
  overflow: hidden;
}

/* Scroll progress */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 10025;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.06);
}

.scroll-progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--pro-accent), var(--pro-accent-2), var(--pro-accent-3));
  box-shadow: 0 0 12px rgba(25, 167, 255, 0.55);
  transition: width 0.12s linear;
}

/* Header toggle — always right */
.header-toggle,
.header .header-toggle {
  left: auto !important;
  right: 16px !important;
}

@media (max-width: 767px) {
  .header-toggle,
  .header .header-toggle {
    right: 12px !important;
  }
}

/* ============================================================
   Site preloader — code hand + typing keyboard
   ============================================================ */
#preloader.site-preloader {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(25, 167, 255, 0.14), transparent 55%),
    radial-gradient(ellipse 60% 50% at 80% 100%, rgba(20, 184, 125, 0.1), transparent 50%),
    linear-gradient(165deg, #060b14 0%, #0a1220 45%, #0d1828 100%);
  transition: opacity 0.65s var(--pro-ease), visibility 0.65s;
}

#preloader.site-preloader::before {
  display: none;
}

#preloader.site-preloader.preloader-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader-inner {
  position: relative;
  width: min(92vw, 420px);
  text-align: center;
  font-family: var(--code-font);
}

.preloader-grid {
  position: absolute;
  inset: -40% -20%;
  background-image:
    linear-gradient(rgba(25, 167, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(25, 167, 255, 0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 72%);
  animation: gridDrift 12s linear infinite;
  pointer-events: none;
}

@keyframes gridDrift {
  0% { transform: translateY(0); }
  100% { transform: translateY(28px); }
}

.preloader-scene {
  position: relative;
  z-index: 2;
  padding: 1.5rem 0 1rem;
}

/* Typing hand (finger tap animation) — scoped to preloader */
#preloader {
  --loader-bg: #0d1828;
  --loader-fg: #e8f2ff;
  --loader-nail: #19a7ff;
}

.typing-hand-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
  min-height: 90px;
}

#preloader .loading.typing-hand {
  position: relative;
  left: auto;
  top: auto;
  margin: 0 auto;
  width: 112px;
  height: 70px;
}

#preloader .loading.typing-hand::before,
#preloader .loading.typing-hand::after {
  display: table;
  content: "";
}

#preloader .loading.typing-hand::after {
  clear: both;
}

#preloader .loading .finger {
  float: left;
  margin: 0 2px 0 0;
  width: 20px;
  height: 100%;
}

#preloader .loading .finger-1 {
  animation: finger-1-animation 2s infinite ease-out;
}

#preloader .loading .finger-2 {
  animation: finger-2-animation 2s infinite ease-out;
}

#preloader .loading .finger-3 {
  animation: finger-3-animation 2s infinite ease-out;
}

#preloader .loading .finger-4 {
  animation: finger-4-animation 2s infinite ease-out;
}

#preloader .loading .finger-item {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 6px 6px 8px 8px;
  background-clip: padding-box;
  background: var(--loader-fg);
  box-shadow: 0 4px 14px rgba(25, 167, 255, 0.15);
}

#preloader .loading .finger-item span {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: auto;
  padding: 5px 5px 0;
}

#preloader .loading .finger-item span::before,
#preloader .loading .finger-item span::after {
  content: "";
  position: relative;
  display: block;
  margin: 0 0 2px;
  width: 100%;
  height: 2px;
  background: var(--loader-bg);
  border-radius: 1px;
}

#preloader .loading .finger-item i {
  position: absolute;
  left: 3px;
  bottom: 3px;
  width: 14px;
  height: 14px;
  border-radius: 10px 10px 7px 7px;
  background-clip: padding-box;
  background: linear-gradient(145deg, var(--loader-nail), #1479db);
  box-shadow: 0 0 8px rgba(25, 167, 255, 0.45);
}

#preloader .loading .finger-item i::before {
  content: attr(data-code);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--code-font);
  font-size: 7px;
  font-weight: 700;
  font-style: normal;
  color: #fff;
  line-height: 1;
}

#preloader .loading .finger-1 .finger-item i::before { content: "<"; }
#preloader .loading .finger-2 .finger-item i::before { content: "{"; }
#preloader .loading .finger-3 .finger-item i::before { content: ";"; }
#preloader .loading .finger-4 .finger-item i::before { content: "/"; }

#preloader .loading .last-finger {
  position: relative;
  float: left;
  width: 24px;
  height: 100%;
  overflow: hidden;
}

#preloader .loading .last-finger-item {
  position: absolute;
  right: 0;
  top: 32px;
  width: 110px;
  height: 20px;
  border-radius: 0 5px 14px 0;
  background: var(--loader-fg);
  background-clip: padding-box;
  box-shadow: 0 4px 14px rgba(25, 167, 255, 0.12);
  animation: finger-5-animation 2s infinite linear;
}

#preloader .loading .last-finger-item i {
  position: absolute;
  left: 0;
  top: -8px;
  width: 22px;
  height: 8px;
  background: var(--loader-fg);
  overflow: hidden;
}

#preloader .loading .last-finger-item i::before {
  content: "=>";
  position: absolute;
  left: 4px;
  top: -2px;
  font-family: var(--code-font);
  font-size: 6px;
  font-weight: 700;
  font-style: normal;
  color: var(--loader-nail);
  z-index: 2;
}

#preloader .loading .last-finger-item i::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 34px;
  height: 20px;
  border-radius: 0 0 15px 15px;
  background: var(--loader-bg);
}

@keyframes finger-1-animation {
  0%, 20% { padding: 12px 0 5px; }
  29%, 35% { padding: 4px 0 24px; }
  41%, 100% { padding: 12px 0 5px; }
}

@keyframes finger-2-animation {
  0%, 24% { padding: 6px 0 2px; }
  33%, 39% { padding: 2px 0 16px; }
  45%, 100% { padding: 6px 0 2px; }
}

@keyframes finger-3-animation {
  0%, 28% { padding: 0; }
  37%, 43% { padding: 0 0 12px; }
  49%, 100% { padding: 0; }
}

@keyframes finger-4-animation {
  0%, 32% { padding: 8px 0 3px; }
  41%, 47% { padding: 4px 0 20px; }
  53%, 100% { padding: 8px 0 3px; }
}

@keyframes finger-5-animation {
  0%, 34% {
    top: 32px;
    right: 0;
    border-radius: 0 5px 14px 0;
    transform: rotate(0deg);
  }
  43%, 50% {
    top: 20px;
    right: 2px;
    border-radius: 0 8px 20px 0;
    transform: rotate(-12deg);
  }
  60%, 100% {
    top: 32px;
    right: 0;
    border-radius: 0 5px 14px 0;
    transform: rotate(0deg);
  }
}

.preloader-typed {
  margin: 0 auto 1rem;
  max-width: 340px;
  min-height: 1.4rem;
  padding: 0 12px;
  text-align: left;
  font-family: var(--code-font);
  font-size: 0.72rem;
  color: rgba(200, 220, 255, 0.85);
}

.preloader-typed .preloader-cursor {
  display: inline-block;
  margin-left: 2px;
  color: var(--pro-accent);
  animation: cursorBlink 0.9s step-end infinite;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Coding keyboard */
.code-keyboard {
  width: min(100%, 340px);
  margin: 0 auto;
  padding: 14px 16px 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(14, 24, 40, 0.98), rgba(8, 14, 24, 0.98));
  border: 1px solid rgba(130, 193, 255, 0.18);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.code-keyboard__row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  margin-bottom: 5px;
}

.code-keyboard__row:last-child {
  margin-bottom: 0;
}

.code-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 32px;
  padding: 0 8px;
  font-size: 0.58rem;
  font-weight: 600;
  color: rgba(220, 235, 255, 0.75);
  background: linear-gradient(180deg, #1a2a42 0%, #121e30 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  box-shadow: 0 3px 0 #060a12, 0 4px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.08s, box-shadow 0.08s, background 0.08s;
}

.code-key--wide {
  min-width: 52px;
}

.code-key--space {
  min-width: 120px;
}

.code-key.is-pressed {
  transform: translateY(3px);
  box-shadow: 0 0 0 #060a12, 0 1px 4px rgba(0, 0, 0, 0.4);
  background: linear-gradient(180deg, #2d5080 0%, #1e3558 100%);
  color: #fff;
  border-color: rgba(25, 167, 255, 0.5);
}

.preloader-meta {
  position: relative;
  z-index: 2;
  margin-top: 1.35rem;
}

.preloader-meta__label {
  margin: 0 0 0.65rem;
  font-family: var(--heading-font, "Poppins", sans-serif);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(200, 220, 255, 0.65);
}

.preloader-meta__label span {
  color: var(--pro-accent);
}

.preloader-bar {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.preloader-bar__fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pro-accent), var(--pro-accent-2));
  box-shadow: 0 0 16px rgba(25, 167, 255, 0.5);
  animation: preloaderProgress 2.4s var(--pro-ease) forwards;
}

@keyframes preloaderProgress {
  0% { width: 0%; }
  40% { width: 52%; }
  75% { width: 86%; }
  100% { width: 100%; }
}

/* ============================================================
   Global polish & motion
   ============================================================ */
body.site-ready .main {
  animation: mainReveal 0.9s var(--pro-ease) both;
}

@keyframes mainReveal {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero {
  isolation: isolate;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 50% at 20% 20%, rgba(25, 167, 255, 0.12), transparent 50%),
    radial-gradient(ellipse 50% 40% at 85% 80%, rgba(20, 184, 125, 0.08), transparent 45%);
  animation: heroShimmer 8s ease-in-out infinite alternate;
}

@keyframes heroShimmer {
  0% { opacity: 0.7; }
  100% { opacity: 1; }
}

.hero .container h1 {
  background: linear-gradient(135deg, #ffffff 0%, #b8d9ff 55%, #19a7ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: titleGlow 4s ease-in-out infinite alternate;
}

@keyframes titleGlow {
  0% { filter: drop-shadow(0 0 0 transparent); }
  100% { filter: drop-shadow(0 0 24px rgba(25, 167, 255, 0.25)); }
}

.hero .container p {
  animation: fadeUp 0.8s var(--pro-ease) 0.2s both;
}

.hero .container h1 {
  animation: fadeUp 0.8s var(--pro-ease) both;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-title h2 {
  position: relative;
  display: inline-block;
}

.section-title h2::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  width: 4px;
  height: 70%;
  transform: translateY(-50%);
  border-radius: 4px;
  background: linear-gradient(180deg, var(--pro-accent), var(--pro-accent-2));
  opacity: 0;
  animation: barIn 0.6s var(--pro-ease) 0.3s forwards;
}

@keyframes barIn {
  to { opacity: 1; left: -16px; }
}

.navmenu a {
  position: relative;
  overflow: hidden;
}

.navmenu a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 8px;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--pro-accent), var(--pro-accent-2));
  transition: width 0.35s var(--pro-ease);
  border-radius: 2px;
}

.navmenu a:hover::after,
.navmenu a.active::after {
  width: calc(100% - 28px);
}

.about .content,
.services .service-item,
.projects .project-item,
.blogs .blog-item,
.certificates .certificate-item,
.skill-card,
.contact .info-wrap,
.contact .php-email-form {
  transition:
    transform 0.45s var(--pro-ease),
    box-shadow 0.45s var(--pro-ease),
    border-color 0.35s ease !important;
}

.reveal-on-scroll {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 0.7s var(--pro-ease),
    transform 0.7s var(--pro-ease);
}

.reveal-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.scroll-top {
  border-radius: 14px !important;
  transition: all 0.4s var(--pro-ease) !important;
}

.scroll-top.active {
  animation: bounceIn 0.5s var(--pro-ease);
}

@keyframes bounceIn {
  0% { transform: scale(0.6); opacity: 0; }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

.header-toggle,
.header .header-toggle {
  border-radius: 14px !important;
  backdrop-filter: blur(12px);
}

@media (prefers-reduced-motion: reduce) {
  #preloader .loading .finger,
  #preloader .loading .last-finger-item,
  .code-key,
  .preloader-cursor,
  .preloader-grid,
  .hero::after,
  .hero .container h1,
  .reveal-on-scroll,
  body.site-ready .main {
    animation: none !important;
    transition: none !important;
  }

  .reveal-on-scroll {
    opacity: 1;
    transform: none;
  }
}
