/* ==========================================================================
   Ahmed Hani Galal — Portfolio
   Design tokens
   ========================================================================== */

:root {
  /* Brand */
  --primary: #3B82F6;
  --primary-2: #2563EB;
  --cyan: #22D3EE;

  /* Dark theme (default) */
  --bg: #0F172A;
  --bg-elev-1: #131E33;
  --bg-elev-2: #172236;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-hover: rgba(255, 255, 255, 0.075);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #E9EEF7;
  --text-dim: #9FB0C9;
  --text-faint: #64748B;
  --grid-line: rgba(148, 163, 184, 0.07);
  --code-color: rgba(148, 197, 255, 0.10);
  --shadow-color: 220 60% 3%;
  --scrim: rgba(5, 10, 20, 0.55);

  /* Type */
  --font-display: 'Manrope', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;

  /* Scale */
  --fs-2xs: 0.6875rem;
  --fs-xs: 0.8125rem;
  --fs-sm: 0.9375rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;
  --fs-3xl: 2.25rem;
  --fs-4xl: 3rem;
  --fs-5xl: 4rem;

  /* Radii */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-full: 999px;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 0.18s;
  --dur-med: 0.4s;
  --dur-slow: 0.8s;

  /* Layout */
  --container: 1180px;
  --nav-h: 76px;

  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #F8FAFC;
  --bg-elev-1: #FFFFFF;
  --bg-elev-2: #F1F5F9;
  --surface: rgba(15, 23, 42, 0.035);
  --surface-hover: rgba(15, 23, 42, 0.06);
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text: #0F172A;
  --text-dim: #475569;
  --text-faint: #94A3B8;
  --grid-line: rgba(15, 23, 42, 0.055);
  --code-color: rgba(37, 99, 235, 0.06);
  --shadow-color: 220 40% 60%;
  --scrim: rgba(241, 245, 249, 0.6);
  color-scheme: light;
}

/* ==========================================================================
   Reset
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--dur-med) var(--ease-out), color var(--dur-med) var(--ease-out);
  overflow-x: hidden;
}

h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; line-height: 1.15; letter-spacing: -0.02em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 4px;
}

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

::selection { background: var(--primary); color: #fff; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ==========================================================================
   Typography helpers
   ========================================================================== */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 600;
}

.eyebrow::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.18);
}

.section-head {
  max-width: 640px;
  margin-bottom: 56px;
}

.section-head h2 {
  font-size: clamp(1.8rem, 3.4vw, var(--fs-3xl));
  margin-top: 14px;
  font-weight: 800;
}

.section-head p {
  margin-top: 14px;
  color: var(--text-dim);
  font-size: var(--fs-lg);
  line-height: 1.65;
}

section {
  position: relative;
  padding: 120px 0;
}

@media (max-width: 780px) {
  section { padding: 80px 0; }
}

.section-alt {
  background: var(--bg-elev-1);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 26px;
  border-radius: var(--r-full);
  font-weight: 600;
  font-size: var(--fs-sm);
  border: 1px solid transparent;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
  white-space: nowrap;
}

.btn svg { width: 17px; height: 17px; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 8px 24px -8px rgba(37, 99, 235, 0.55);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 32px -8px rgba(37, 99, 235, 0.7); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  backdrop-filter: blur(12px);
}
.btn-ghost:hover { background: var(--surface-hover); border-color: var(--border-strong); transform: translateY(-2px); }

.btn-sm { padding: 9px 16px; font-size: var(--fs-xs); }

/* ==========================================================================
   Navigation
   ========================================================================== */

.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  transition: background var(--dur-med) var(--ease-out), border-color var(--dur-med) var(--ease-out), box-shadow var(--dur-med) var(--ease-out), height var(--dur-med) var(--ease-out);
  border-bottom: 1px solid transparent;
}

.navbar.scrolled {
  height: 66px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 30px -10px hsl(var(--shadow-color) / 0.4);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.nav-logo {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--fs-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.01em;
}

.nav-logo .bracket { color: var(--primary); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-links a {
  position: relative;
  padding: 9px 16px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-dim);
  transition: color var(--dur-fast), background var(--dur-fast);
}

.nav-links a:hover { color: var(--text); background: var(--surface); }

.nav-links a.active { color: var(--text); }

.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: 3px; left: 16px; right: 16px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--primary), var(--cyan));
}

.nav-actions { display: flex; align-items: center; gap: 10px; }

.theme-toggle, .menu-toggle {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: background var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
}
.theme-toggle:hover, .menu-toggle:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.theme-toggle svg, .menu-toggle svg { width: 18px; height: 18px; }

.theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }

.menu-toggle { display: none; }

.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2.5px;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--cyan));
  z-index: 101;
  transition: width 0.1s linear;
}

/* Mobile nav */
@media (max-width: 900px) {
  .nav-links { 
    position: fixed;
    top: var(--nav-h); left: 0; right: 0;
    flex-direction: column;
    align-items: stretch;
    background: color-mix(in srgb, var(--bg) 96%, transparent);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 10px 24px 20px;
    gap: 2px;
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: transform var(--dur-med) var(--ease-out), opacity var(--dur-med) var(--ease-out);
  }
  .nav-links.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .nav-links a { padding: 13px 14px; border-radius: var(--r-md); }
  .nav-links a.active::after { display: none; }
  .nav-links a.active { background: var(--surface); }
  .menu-toggle { display: flex; }
}

/* ==========================================================================
   Utility: reveal-on-scroll
   ========================================================================== */

.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}
.reveal.in { opacity: 1; transform: translateY(0); }
.reveal-delay-1 { transition-delay: 0.08s; }
.reveal-delay-2 { transition-delay: 0.16s; }
.reveal-delay-3 { transition-delay: 0.24s; }
.reveal-delay-4 { transition-delay: 0.32s; }

/* ==========================================================================
   Card base (glassmorphism)
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform var(--dur-med) var(--ease-out), border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out), box-shadow var(--dur-med) var(--ease-out);
}

.card:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  background: var(--surface-hover);
  box-shadow: 0 20px 50px -20px hsl(var(--shadow-color) / 0.5);
}

/* Back to top */
.back-to-top {
  position: fixed;
  bottom: 28px; right: 28px;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px -6px rgba(37, 99, 235, 0.6);
  border: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity var(--dur-fast), transform var(--dur-fast), visibility var(--dur-fast);
  z-index: 90;
}
.back-to-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top svg { width: 20px; height: 20px; }
.back-to-top:hover { transform: translateY(-3px); }
