/* =========================================================
   AlkindiX — Elevated Minimal CSS
   Sophisticated animations & micro-interactions
========================================================= */

/* RESET */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

/* THEME */
:root {
  --bg: #0b0b0b;
  --text: #e7e7e7;
  --muted: #9a9a9a;
  --accent: #ffffff;
  --line: rgba(255,255,255,0.1);
  --card: #111;
  --radius: 10px;
}

/* BASE */
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", sans-serif;
  line-height: 1.65;
  padding-top: 90px;
  position: relative;
  opacity: 0;
  transition: opacity 0.6s ease;
}

body.loaded {
  opacity: 1;
}

/* Subtle grid background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: -1;
  opacity: 0.5;
}

.container {
  width: min(1100px, 92%);
  margin-inline: auto;
}

/* =========================================================
   TYPOGRAPHY
========================================================= */

h1, h2, h3 {
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--accent);
}

h1 { 
  font-size: clamp(2.4rem, 6vw, 3.6rem); 
  margin-bottom: 1rem; 
}

h2 { 
  font-size: clamp(1.8rem, 4vw, 2.4rem); 
  margin-bottom: 1rem; 
}

h3 { 
  font-size: 1.25rem; 
  margin-bottom: .75rem; 
}

p {
  font-size: 1rem;
  opacity: 0.85;
  max-width: 720px;
  margin-bottom: 1.3rem;
}

.muted { 
  color: var(--muted); 
}

.section-title {
  margin-bottom: 3rem;
  text-align: center;
}

/* =========================================================
   LINKS
========================================================= */

a {
  color: var(--accent);
  text-decoration: none;
  transition: .2s ease;
}
a:hover { 
  opacity: .8; 
}

/* =========================================================
   HEADER
========================================================= */

.nav {
  position: fixed;
  top: 0; 
  left: 0; 
  right: 0;
  z-index: 9999;
  background: rgba(15,15,15,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
              background 0.3s ease,
              backdrop-filter 0.3s ease;
}

.nav.scrolled {
  background: rgba(15,15,15,0.95);
  backdrop-filter: blur(20px);
}

.nav.hidden {
  transform: translateY(-100%);
}

.nav__inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 64px;
  padding: 0.75rem 0;
}

.brand {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent);
}

/* Nav links */
.nav__links {
  display: flex;
  gap: 2rem;
}

.nav__links a {
  color: var(--text);
  font-size: 0.95rem;
  opacity: .85;
  position: relative;
  transition: opacity 0.3s ease;
}

.nav__links a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--accent);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav__links a:hover,
.nav__links a.active { 
  opacity: 1; 
}

.nav__links a.active::after {
  width: 100%;
}

/* Mobile toggle */
.nav__toggle {
  display: none;
  border: none;
  background: transparent;
  cursor: pointer;
}

.nav__toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  margin: 4px 0;
  transition: all 0.3s ease;
}

.nav__toggle.active span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.nav__toggle.active span:nth-child(2) {
  opacity: 0;
}

.nav__toggle.active span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* =========================================================
   HERO
========================================================= */
.hero {
  text-align: center;
  padding: 120px 0 90px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
}

.hero__wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
  will-change: transform, opacity;
}

.hero__h1 {
  background: linear-gradient(135deg, #ffffff 0%, #c0c0c0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  background-size: 200% 200%;
  animation: gradientShift 3s ease infinite;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.hero__sub {
  color: var(--muted);
  font-size: 1.05rem;
  margin-top: 1rem;
  line-height: 1.7;
  max-width: 100%;
}

/* =========================================================
   SECTIONS
========================================================= */
.section {
  padding: 6rem 0;
}

/* =========================================================
   SCROLL REVEAL ANIMATIONS
========================================================= */
.reveal-element {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-element.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* =========================================================
   CARD
========================================================= */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 2rem;
  border-radius: var(--radius);
  margin-bottom: 2rem;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  border-color: rgba(255,255,255,0.2);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

.card p:last-child { 
  margin-bottom: 0; 
}

.card--row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
}

/* =========================================================
   PROJECTS
========================================================= */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 2rem;
  margin-top: 3rem;
}

.project-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2.5rem;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  will-change: transform;
}

.project-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.project-card:hover {
  border-color: rgba(255,255,255,0.25);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

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

.project-card h3 {
  margin-bottom: 0.75rem;
  font-size: 1.35rem;
  transition: color 0.3s ease;
}

.project-card:hover h3 {
  color: var(--accent);
}

.project-card p {
  margin-bottom: 1.5rem;
  max-width: 100%;
}

.project-card__content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.project-card .btn {
  margin-top: auto;
}

/* =========================================================
   BUTTONS
========================================================= */
.btn {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  background: var(--accent);
  color: #000;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(0,0,0,0.1);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s ease, height 0.6s ease;
}

.btn:hover::before {
  width: 300px;
  height: 300px;
}

.btn:hover { 
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(255,255,255,0.15);
}

.btn--pill {
  border-radius: 30px;
}

.btn--secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--line);
}

.btn--secondary::before {
  background: rgba(255,255,255,0.05);
}

.btn--secondary:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.3);
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.btn-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.contact__actions {
  display: flex;
  gap: 1rem;
  flex-shrink: 0;
}

/* =========================================================
   CURSOR TRAIL (Desktop Only)
========================================================= */
@media (min-width: 769px) {
  .cursor-trail {
    width: 40px;
    height: 40px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    position: fixed;
    pointer-events: none;
    z-index: 10000;
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease, border-color 0.3s ease;
    mix-blend-mode: difference;
  }

  .cursor-trail--hover {
    width: 60px;
    height: 60px;
    border-color: rgba(255,255,255,0.6);
  }
}

/* =========================================================
   SCROLL PROGRESS INDICATOR
========================================================= */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent) 0%, rgba(255,255,255,0.5) 100%);
  z-index: 10001;
  transition: width 0.1s ease;
  box-shadow: 0 0 10px rgba(255,255,255,0.5);
}

/* =========================================================
   FOOTER
========================================================= */
.footer {
  padding: 3rem 0;
  border-top: 1px solid var(--line);
}

.footer__inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer__links {
  display: flex;
  gap: 1.5rem;
}

.footer__links a {
  font-size: 0.9rem;
  opacity: 0.75;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.footer__links a:hover {
  opacity: 1;
  transform: translateY(-2px);
}

.to-top {
  opacity: .75;
  font-size: 1.2rem;
  transition: all 0.3s ease;
}

.to-top:hover { 
  opacity: 1;
  transform: translateY(-3px);
}

/* =========================================================
   ACCESSIBILITY - KEYBOARD NAVIGATION
========================================================= */
.keyboard-nav *:focus {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

body:not(.keyboard-nav) *:focus {
  outline: none;
}

/* =========================================================
   EASTER EGG - MATRIX MODE
========================================================= */
@keyframes matrixRain {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(100vh); }
}

body.matrix-mode {
  animation: matrixPulse 0.1s infinite;
}

@keyframes matrixPulse {
  0%, 100% { filter: hue-rotate(0deg); }
  50% { filter: hue-rotate(90deg); }
}

body.matrix-mode::before {
  background-color: #003300;
  opacity: 0.1;
}

/* =========================================================
   RESPONSIVE
========================================================= */
@media (max-width: 768px) {

  body {
    padding-top: 70px;
  }

  .nav__links {
    position: absolute;
    top: 64px;
    right: 0;
    left: 0;
    padding: 1.5rem;
    flex-direction: column;
    gap: 1.25rem;
    background: rgba(15,15,15,0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
    display: none;
  }
  
  .nav__links.active { 
    display: flex; 
  }

  .nav__toggle { 
    display: block; 
  }

  .section { 
    padding: 4rem 0; 
  }

  .hero {
    padding: 80px 0 60px;
    min-height: 50vh;
  }

  .section-title {
    margin-bottom: 2rem;
  }

  .project-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .card--row {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .contact__actions {
    width: 100%;
    flex-direction: column;
  }
  
  .contact__actions .btn {
    width: 100%;
  }

  .footer__inner {
    flex-direction: column;
    gap: 1.5rem;
    text-align: center;
  }

  .footer__links {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  /* Disable complex animations on mobile */
  .project-card {
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
  }
  
  .project-card:hover {
    transform: none !important;
  }
}

@media (max-width: 480px) {
  .container {
    width: 90%;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  .card, .project-card {
    padding: 1.5rem;
  }

  .hero__sub {
    font-size: 1rem;
  }
}

/* =========================================================
   REDUCED MOTION PREFERENCE
========================================================= */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  html {
    scroll-behavior: auto;
  }
  
  .reveal-element {
    opacity: 1;
    transform: none;
  }
  
  .hero__wrap {
    transform: none !important;
    opacity: 1 !important;
  }
}