/* Modern CSS Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html {
  color-scheme: light dark;
}

body {
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden; /* Prevent horizontal scrolling from matrix effect */
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

/* CSS Custom Properties (Variables) */
:root {
  /* Color System */
  --color-primary: oklch(55% 0.15 250);
  --color-primary-hover: oklch(50% 0.18 250);
  --color-secondary: oklch(70% 0.05 280);
  --color-secondary-hover: oklch(65% 0.08 280);
  
  --color-surface: oklch(98% 0.02 280);
  --color-surface-variant: oklch(95% 0.02 280);
  --color-background: oklch(99% 0.01 280);
  
  --color-text-primary: oklch(20% 0.02 280);
  --color-text-secondary: oklch(50% 0.02 280);
  --color-text-tertiary: oklch(65% 0.02 280);
  
  --color-border: oklch(90% 0.02 280);
  --color-border-hover: oklch(80% 0.03 280);
  
  --color-success: oklch(65% 0.15 140);
  --color-shadow: oklch(20% 0.02 280 / 0.1);
  
  /* Matrix Theme Colors */
  --matrix-green: #00ff41;
  --matrix-dark-green: #008f11;
  --matrix-bg: #000;
  
  /* Typography Scale */
  --font-family-base: 'Inter', system-ui, -apple-system, sans-serif;
  --font-size-xs: clamp(0.75rem, 0.5vi + 0.65rem, 0.8rem);
  --font-size-sm: clamp(0.875rem, 0.8vi + 0.75rem, 0.95rem);
  --font-size-base: clamp(1rem, 1vi + 0.85rem, 1.1rem);
  --font-size-lg: clamp(1.125rem, 1.2vi + 0.95rem, 1.3rem);
  --font-size-xl: clamp(1.25rem, 1.5vi + 1.05rem, 1.5rem);
  --font-size-2xl: clamp(1.5rem, 2vi + 1.2rem, 1.8rem);
  
  /* Spacing Scale */
  --space-xs: clamp(0.25rem, 0.5vi + 0.2rem, 0.5rem);
  --space-sm: clamp(0.5rem, 1vi + 0.4rem, 0.75rem);
  --space-md: clamp(0.75rem, 1.5vi + 0.6rem, 1rem);
  --space-lg: clamp(1rem, 2vi + 0.8rem, 1.5rem);
  --space-xl: clamp(1.5rem, 3vi + 1.2rem, 2rem);
  --space-2xl: clamp(2rem, 4vi + 1.6rem, 3rem);
  
  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 var(--color-shadow);
  --shadow-md: 0 4px 6px -1px var(--color-shadow), 0 2px 4px -1px oklch(20% 0.02 280 / 0.06);
  --shadow-lg: 0 10px 15px -3px var(--color-shadow), 0 4px 6px -2px oklch(20% 0.02 280 / 0.05);
  --shadow-xl: 0 20px 25px -5px var(--color-shadow), 0 10px 10px -5px oklch(20% 0.02 280 / 0.04);
  
  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
  :root {
    --color-surface: oklch(15% 0.02 280);
    --color-surface-variant: oklch(18% 0.02 280);
    --color-background: oklch(12% 0.01 280);
    
    --color-text-primary: oklch(95% 0.02 280);
    --color-text-secondary: oklch(75% 0.02 280);
    --color-text-tertiary: oklch(60% 0.02 280);
    
    --color-border: oklch(25% 0.02 280);
    --color-border-hover: oklch(35% 0.03 280);
    
    --color-shadow: oklch(5% 0.02 280 / 0.3);
  }
}

/* Base Styles */
body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--color-text-primary);
  background: var(--color-background);
  font-feature-settings: 'rlig' 1, 'calt' 1;
}

.container {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: var(--space-lg);
  position: relative;
  z-index: 1;
}

/* Profile Card */
.profile-card {
  container-type: inline-size;
  container-name: profile-card;
  
  position: relative;
  width: 100%;
  max-width: 32rem; /* Increased from 24rem to 32rem */
  background: var(--color-surface);
  border: 1px solid var(--matrix-green);
  border-radius: var(--radius-2xl);
  box-shadow: 
    var(--shadow-xl),
    0 0 20px rgba(0, 255, 65, 0.3),
    inset 0 1px 0 rgba(0, 255, 65, 0.1);
  overflow: hidden;
  transition: all var(--transition-normal);
  backdrop-filter: blur(10px);
  
  &:hover {
    transform: translateY(-0.25rem);
    box-shadow: 
      var(--shadow-xl),
      0 0 30px rgba(0, 255, 65, 0.5),
      0 0 0 1px var(--matrix-green),
      inset 0 1px 0 rgba(0, 255, 65, 0.2);
  }
}

/* Card Header */
.card-header {
  position: relative;
  height: 8rem;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.card-background {
  position: absolute;
  inset: 0;
  background: 
    linear-gradient(135deg, var(--matrix-green), var(--matrix-dark-green)),
    linear-gradient(45deg, transparent 30%, rgba(0, 255, 65, 0.1) 70%),
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 255, 65, 0.03) 2px, rgba(0, 255, 65, 0.03) 4px);
  background-size: 100% 100%, 20px 20px, 4px 4px;
  animation: matrix-bg-pulse 3s ease-in-out infinite alternate;
}

@keyframes matrix-bg-pulse {
  0% { opacity: 0.8; }
  100% { opacity: 1; }
}

.avatar-container {
  position: relative;
  z-index: 2;
}

.avatar {
  width: 5rem;
  height: 5rem;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid var(--color-surface);
  object-fit: cover;
  transition: transform var(--transition-normal);
  
  .profile-card:hover & {
    transform: scale(1.05);
  }
}

.status-indicator {
  position: absolute;
  bottom: 0.25rem;
  right: 0.25rem;
  width: 1rem;
  height: 1rem;
  background: var(--color-success);
  border: 2px solid var(--color-surface);
  border-radius: 50%;
  
  &::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    background: var(--color-success);
    animation: ping 2s cubic-bezier(0, 0, 0.2, 1) infinite;
  }
}

@keyframes ping {
  75%, 100% {
    transform: scale(2);
    opacity: 0;
  }
}

/* Card Content */
.card-content {
  padding: var(--space-xl);
  display: grid;
  gap: var(--space-lg);
}

/* Profile Info */
.profile-info {
  text-align: center;
  
  .name {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: var(--space-xs);
  }
  
  .title {
    font-size: var(--font-size-base);
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-sm);
  }
  
  .location {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    font-size: var(--font-size-sm);
    color: var(--color-text-tertiary);
  }
}

.location-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

/* Bio */
.bio {
  p {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    text-align: center;
    line-height: 1.6;
  }
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  padding: var(--space-lg) 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.stat-item {
  text-align: center;
  
  .stat-value {
    display: block;
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: var(--color-text-primary);
    line-height: 1.2;
  }
  
  .stat-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
  }
}

/* Social Links */
.social-links {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
}

.social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-md);
  color: var(--color-text-tertiary);
  background: var(--color-surface-variant);
  border: 1px solid var(--color-border);
  text-decoration: none;
  transition: all var(--transition-fast);
  cursor: pointer; /* Explicitly ensure pointer cursor */
  position: relative; /* Ensure proper stacking */
  z-index: 1; /* Ensure links are clickable */
  
  svg {
    width: 1.25rem;
    height: 1.25rem;
    pointer-events: none; /* Allow clicks to pass through SVG to the link */
  }
  
  &:hover {
    color: var(--color-primary);
    background: var(--color-surface);
    border-color: var(--color-primary);
    transform: translateY(-1px);
  }
  
  &:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
  }
}

/* Action Buttons */
.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  
  &:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
  }
  
  &:disabled {
    opacity: 0.6;
    cursor: not-allowed;
  }
}

.btn-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
  
  &:hover:not(:disabled) {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
  }
  
  &:active {
    transform: translateY(0);
  }
}

.btn-secondary {
  background: var(--color-surface-variant);
  color: var(--color-text-primary);
  border-color: var(--color-border);
  
  &:hover:not(:disabled) {
    background: var(--color-surface);
    border-color: var(--color-border-hover);
    transform: translateY(-1px);
  }
  
  &:active {
    transform: translateY(0);
  }
}

/* Resume Download Section */
.resume-section {
  display: flex;
  justify-content: center;
  padding: var(--space-md) 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.resume-download {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--color-surface-variant);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--color-text-primary);
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 280px;
  
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
      transparent, 
      oklch(100% 0 0 / 0.1), 
      transparent
    );
    transition: left var(--transition-slow);
  }
  
  &:hover {
    background: var(--color-surface);
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    
    &::before {
      left: 100%;
    }
    
    .download-indicator {
      transform: translateY(2px);
      color: var(--color-primary);
    }
    
    .resume-title {
      color: var(--color-primary);
    }
  }
  
  &:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
  }
  
  &:active {
    transform: translateY(0);
  }
}

.resume-icon {
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  color: var(--color-primary);
  background: oklch(from var(--color-primary) l c h / 0.1);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
}

.resume-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.125rem;
}

.resume-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text-primary);
  transition: color var(--transition-fast);
}

.resume-subtitle {
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
  font-weight: 400;
}

.download-indicator {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  color: var(--color-text-tertiary);
  transition: all var(--transition-fast);
}

/* Matrix Background Effect */
.matrix-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  background: #000;
  overflow: hidden;
}

.matrix-bg::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(ellipse at center, rgba(0, 255, 65, 0.15) 0%, rgba(0, 0, 0, 0.95) 70%),
    linear-gradient(180deg, rgba(0, 255, 65, 0.1) 0%, rgba(0, 0, 0, 0.9) 100%);
  pointer-events: none;
}

.matrix-rain {
  position: absolute;
  top: -100%;
  color: #00ff41;
  font-family: 'Courier New', monospace;
  font-size: 16px;
  line-height: 16px;
  white-space: pre;
  animation: matrix-fall linear infinite;
  text-shadow: 0 0 8px #00ff41;
  opacity: 0.9;
  pointer-events: none;
}

.matrix-rain:nth-child(odd) {
  color: #008f11;
  opacity: 0.7;
  font-size: 14px;
}

.matrix-rain:nth-child(3n) {
  color: #00ff41;
  opacity: 1;
  text-shadow: 0 0 15px #00ff41, 0 0 25px #00ff41;
  font-size: 18px;
}

.matrix-rain:nth-child(4n) {
  color: #00cc33;
  opacity: 0.8;
  font-size: 15px;
}

@keyframes matrix-fall {
  0% {
    transform: translateY(-100vh);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(100vh);
    opacity: 0;
  }
}

/* Matrix Characters Animation */
@keyframes matrix-flicker {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

.matrix-rain:nth-child(even) {
  animation-delay: -2s;
}

.matrix-rain:nth-child(3n) {
  animation-delay: -4s;
}

.matrix-rain:nth-child(4n) {
  animation-delay: -6s;
}

.matrix-rain:nth-child(5n) {
  animation-delay: -1s;
}

/* Container Queries for True Responsive Design */
@container profile-card (max-width: 300px) {
  .profile-info .name {
    font-size: var(--font-size-lg);
  }
  
  .stats-grid {
    gap: var(--space-sm);
  }
  
  .stat-item .stat-value {
    font-size: var(--font-size-base);
  }
  
  .action-buttons {
    grid-template-columns: 1fr;
  }
  
  .resume-download {
    padding: var(--space-sm) var(--space-md);
    gap: var(--space-sm);
  }
  
  .resume-icon {
    width: 1.5rem;
    height: 1.5rem;
  }
  
  .resume-title {
    font-size: var(--font-size-sm);
  }
}

@container profile-card (min-width: 400px) {
  .card-content {
    padding: var(--space-2xl);
  }
  
  .card-header {
    height: 10rem;
  }
  
  .avatar {
    width: 6rem;
    height: 6rem;
  }
  
  .profile-info .name {
    font-size: var(--font-size-2xl);
  }
  
  .resume-download {
    padding: var(--space-lg) var(--space-xl);
    gap: var(--space-lg);
  }
  
  .resume-icon {
    width: 2.25rem;
    height: 2.25rem;
  }
}

/* Traditional Media Queries as Fallback */
@media (max-width: 375px) {
  .container {
    padding: var(--space-md);
  }
  
  .profile-card {
    max-width: 100%;
  }
}

@media (min-width: 768px) {
  .container {
    padding: var(--space-2xl);
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .status-indicator::before {
    animation: none;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  :root {
    --color-border: currentColor;
    --shadow-md: 0 0 0 1px currentColor;
    --shadow-lg: 0 0 0 1px currentColor;
    --shadow-xl: 0 0 0 2px currentColor;
  }
}

/* Print Styles */
@media print {
  .profile-card {
    box-shadow: none;
    border: 2px solid var(--color-text-primary);
    break-inside: avoid;
    page-break-inside: avoid;
  }
  
  .card-background {
    background: var(--color-text-tertiary) !important;
  }
  
  .btn,
  .social-links {
    display: none;
  }
}
