/* ==========================================================================
   PORTFOLIO DESIGN SYSTEM & GLOBAL STYLES
   Independent Freelance Software Engineer Portfolio
   ========================================================================== */

/* --- Google Fonts is loaded via preconnected <link> in HTML <head> for fast, pop-free rendering --- */

:root {
  --font-display-tech: 'Space Grotesk', -apple-system, sans-serif;
  /* Light Theme (Default Editorial Palette) */
  --bg-primary: #f8f7f4;
  --bg-surface: #ffffff;
  --bg-surface-subtle: #f2f0ea;
  --bg-surface-elevated: #ffffff;
  --bg-inverted: #121316;
  --bg-inverted-surface: #1a1c22;
  
    --text-primary: #111215;
  --text-secondary: #4b4f58;
  --text-muted: #747882;
  --text-inverted: #f4f4f6;
  --text-inverted-muted: #9fa2ad;

  /* Orange & Black Brand Colors (FiveNeurals Theme) */
  --accent-primary: #fa902a;
  --accent-primary-hover: #e04b00;
  --accent-subtle: rgba(255, 85, 0, 0.09);
  --accent-border: rgba(255, 85, 0, 0.3);
  
  --accent-emerald: #10b981;
  --accent-emerald-subtle: #ecfdf5;
  --accent-amber: #f59e0b;
  --accent-amber-subtle: #fffbeb;

  --border-subtle: #e6e8ec;
  --border-medium: #d4d7de;
  --border-strong: #1b1c20;
  --border-inverted: #2d3039;

  /* Typography */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: 'DM Serif Display', Georgia, serif;
  --font-mono: 'JetBrains Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(18, 20, 24, 0.04);
  --shadow-md: 0 4px 16px -2px rgba(18, 20, 24, 0.06), 0 2px 6px -1px rgba(18, 20, 24, 0.03);
  --shadow-lg: 0 16px 36px -4px rgba(18, 20, 24, 0.08), 0 6px 12px -2px rgba(18, 20, 24, 0.04);
  --shadow-elevated: 0 24px 50px -8px rgba(18, 20, 24, 0.12);

  /* Layout & Spacing */
  --container-max: 1280px;
  --container-narrow: 840px;
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 32px;
  --radius-full: 9999px;

  --header-height: 80px;
  --transition-fast: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-smooth: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Dark Theme Overrides --- */
[data-theme="dark"] {
  --bg-primary: #0b0c0e;
  --bg-surface: #121317;
  --bg-surface-subtle: #191b22;
  --bg-surface-elevated: #1f222b;
  --bg-inverted: #f8f7f4;
  --bg-inverted-surface: #ffffff;
  
  --text-primary: #f2f3f5;
  --text-secondary: #a3a6b3;
  --text-muted: #717482;
  --text-inverted: #14161a;
  --text-inverted-muted: #52555e;

  /* Orange & Black Brand in Dark Mode */
  --accent-primary: #ff6822;
  --accent-primary-hover: #ff7d3d;
  --accent-subtle: rgba(255, 104, 34, 0.16);
  --accent-border: rgba(255, 104, 34, 0.4);

  --accent-emerald: #10b981;
  --accent-emerald-subtle: rgba(16, 185, 129, 0.12);
  --accent-amber: #f59e0b;
  --accent-amber-subtle: rgba(245, 158, 11, 0.12);

  --border-subtle: #20222a;
  --border-medium: #2e313c;
  --border-strong: #ff6822;
  --border-inverted: #eae8e1;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 36px -4px rgba(0, 0, 0, 0.5);
  --shadow-elevated: 0 24px 50px -8px rgba(0, 0, 0, 0.6);
}

/* --- Reset & Global Baseline --- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.65;
  letter-spacing: -0.011em;
  animation: pageEnter 0.35s ease-out;
  transition: opacity 0.22s ease-out,
              background-color var(--transition-smooth),
              color var(--transition-smooth);
  overflow-x: hidden;
}

@keyframes pageEnter {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

body.page-leaving {
  opacity: 0;
  pointer-events: none;
}

::selection {
  background-color: var(--accent-subtle);
  color: var(--accent-primary);
}

/* --- Typography System --- */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.18;
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.font-serif {
  font-family: var(--font-serif) !important;
  font-weight: 400;
  letter-spacing: -0.015em;
}

.font-mono {
  font-family: var(--font-mono) !important;
  letter-spacing: -0.02em;
}

.font-sans {
  font-family: var(--font-sans) !important;
}

.display-title-xl {
  font-family: var(--font-serif);
  font-size: clamp(2.75rem, 5.5vw + 0.5rem, 5.25rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.display-title-lg {
  font-family: var(--font-serif);
  font-size: clamp(2.25rem, 4.2vw, 3.8rem);
  line-height: 1.1;
  letter-spacing: -0.025em;
}

.display-title-md {
  font-family: var(--font-serif);
  font-size: clamp(1.85rem, 3vw, 2.75rem);
  line-height: 1.18;
  letter-spacing: -0.02em;
}

.section-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-primary);
  margin-bottom: 0.75rem;
}

.section-eyebrow::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 2px;
  background-color: currentColor;
  border-radius: var(--radius-full);
}

p.lead-editorial {
  font-size: clamp(1.15rem, 1.4vw, 1.35rem);
  line-height: 1.6;
  color: var(--text-secondary);
  font-weight: 400;
  max-width: 42ch;
}

/* --- Container Overrides --- */
.container-editorial {
  width: 100%;
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: clamp(1.25rem, 3vw, 2.5rem);
  padding-right: clamp(1.25rem, 3vw, 2.5rem);
}

.container-narrow {
  width: 100%;
  max-width: var(--container-narrow);
  margin-left: auto;
  margin-right: auto;
  padding-left: clamp(1.25rem, 3vw, 2.5rem);
  padding-right: clamp(1.25rem, 3vw, 2.5rem);
}

.section-spacing {
  padding-top: clamp(3rem, 5vw, 5rem);
  padding-bottom: clamp(3rem, 5vw, 5rem);
}

.section-spacing-sm {
  padding-top: clamp(2rem, 3.5vw, 3.5rem);
  padding-bottom: clamp(2rem, 3.5vw, 3.5rem);
}

/* --- Header / Navigation Bar --- */
.site-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1050;
  background-color: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

[data-theme="dark"] .site-header {
  background-color: rgba(11, 12, 15, 0.96);
  border-bottom-color: var(--border-subtle);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.header-inner {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
}

.brand-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.82rem;
  letter-spacing: -0.02em;
  transition: transform var(--transition-fast);
}

[data-theme="dark"] .brand-icon {
  background: transparent;
  border: none;
  box-shadow: none;
}

.brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: transform var(--transition-fast), filter var(--transition-fast);
}

.brand-mark:hover .brand-icon img {
  transform: scale(1.08) rotate(4deg);
  filter: drop-shadow(0 3px 6px rgba(255, 85, 0, 0.35));
}

.brand-name {
  display: flex;
  flex-direction: column;
}

.brand-name-main {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
}

.brand-name-sub {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Nav links */
.site-nav {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.nav-link-custom {
  position: relative;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.4rem 0;
  transition: color var(--transition-fast);
}

.nav-link-custom::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--accent-primary);
  border-radius: var(--radius-full);
  transition: width var(--transition-smooth);
}

.nav-link-custom:hover {
  color: var(--text-primary);
}

.nav-link-custom:hover::after,
.nav-link-custom.active::after {
  width: 100%;
}

.nav-link-custom.active {
  color: var(--text-primary);
  font-weight: 600;
}

/* Availability Badge */
.availability-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.status-indicator {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
}

.status-indicator.pulse::after {
  content: "";
  position: absolute;
  top: -3px;
  left: -3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background-color: var(--accent-emerald);
  opacity: 0.4;
  animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.6); opacity: 0.8; }
  50% { transform: scale(1.4); opacity: 0; }
  100% { transform: scale(0.6); opacity: 0; }
}

/* Theme Toggle Button */
.theme-toggle-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.theme-toggle-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

/* Mobile Nav Toggle */
.mobile-nav-toggle {
  display: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
}

@media (max-width: 991.98px) {
  .site-nav {
    display: none;
  }
  .mobile-nav-toggle {
    display: flex;
  }
}

/* Mobile Offcanvas Drawer */
.mobile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(360px, 85vw);
  height: 100vh;
  background-color: var(--bg-surface);
  z-index: 1100;
  box-shadow: var(--shadow-elevated);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform var(--transition-smooth), visibility var(--transition-smooth);
}

.mobile-drawer.open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.mobile-drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(18, 20, 24, 0.45);
  backdrop-filter: blur(4px);
  z-index: 1090;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-smooth);
}

.mobile-drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.mobile-drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 2rem;
}

.mobile-drawer-nav .nav-link-custom {
  font-size: 1.25rem;
  font-weight: 600;
}

/* Dark terminal preview containers must never inherit light-mode text-muted */
.project-media-preview .text-muted,
.bg-dark .text-muted,
.project-media-preview span.text-muted {
  color: #b4bccb !important;
  opacity: 1 !important;
}

/* ==========================================================================
   SMOOTH TRANSITIONS & REVEAL SYSTEM
   ========================================================================== */

/* --- Smooth Theme Switch Transition Class --- */
html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
  transition: background-color 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              color 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
  transition-delay: 0s !important;
}

/* --- Scroll Reveal Animations --- */
.reveal-on-scroll {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.65s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.65s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

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

.reveal-fade {
  opacity: 0;
  transition: opacity 0.65s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity;
}

.reveal-fade.is-visible {
  opacity: 1;
}

.reveal-scale {
  opacity: 0;
  transform: scale(0.96) translateY(12px);
  transition: opacity 0.65s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.65s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

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

/* Staggered Delay Utilities */
.delay-1 { transition-delay: 0.06s !important; }
.delay-2 { transition-delay: 0.12s !important; }
.delay-3 { transition-delay: 0.18s !important; }
.delay-4 { transition-delay: 0.24s !important; }
.delay-5 { transition-delay: 0.30s !important; }
.delay-6 { transition-delay: 0.36s !important; }

/* Theme toggle icon interactive motion */
.theme-toggle-btn i {
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.theme-toggle-btn:active i {
  transform: rotate(90deg) scale(0.85);
}

/* Reduced Motion Preference */
@media (prefers-reduced-motion: reduce) {
  body {
    animation: none !important;
    transition: none !important;
  }
  .reveal-on-scroll,
  .reveal-fade,
  .reveal-scale {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  html.theme-transitioning,
  html.theme-transitioning * {
    transition: none !important;
  }
}



