/* ==========================================================================
   Design Tokens & CSS Variables
   ========================================================================== */
:root {
  /* Color Palette - Light Mode */
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent-color: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: #e0e7ff;
  --border-color: #e2e8f0;

  /* Typography */
  --font-sans:
    "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  --font-mono: "JetBrains Mono", Fira Code, monospace;

  /* Layout & Spacing */
  --max-width: 1080px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* Elevation & Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md:
    0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-hover:
    0 12px 20px -3px rgba(79, 70, 229, 0.12), 0 4px 6px -4px rgba(0, 0, 0, 0.05);

  --transition-fast: 0.2s ease;
}

/* Dark Mode Preference Override */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #0f172a;
    --bg-surface: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --accent-color: #6366f1;
    --accent-hover: #818cf8;
    --accent-light: #312e81;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 12px 20px -3px rgba(99, 102, 241, 0.25);
  }
}

/* ==========================================================================
   Reset & Base Styles
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding: 1rem 1rem;
}

/* Container */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
}

/* ==========================================================================
   Hero Section
   ========================================================================== */
.hero {
  padding: 3rem 1rem 3rem;
  text-align: center;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--accent-color);
  font-weight: 600;
  margin-bottom: 1rem;
}

.hero-bio {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 680px;
  margin-bottom: 1.5rem;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.social-links {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  justify-content: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all var(--transition-fast);
  min-height: 44px; /* Touch target accessibility */
  gap: 0.5rem;
}

.btn-icon {
  width: 1.25em;
  height: 1.25em;
}

.btn-primary {
  background-color: var(--accent-color);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-outline {
  background-color: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-outline:hover {
  background-color: var(--bg-surface);
  border-color: var(--accent-color);
  color: var(--accent-color);
}

/* ==========================================================================
   HR
   ========================================================================== */
hr {
  border: 0;
  height: 1px;
  background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgb(255, 255, 255), rgb(255, 255, 255), rgba(0, 0, 0, 0));
  margin: 1rem auto;
  width: 100%;
}


/* ==========================================================================
   Card Grid & Responsive Card Layout
   ========================================================================== */
.projects-grid {
  display: grid;
  /* Auto-fit creates responsive columns based on screen width. 
     Cards will never be smaller than 300px wide. */
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 4rem;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.project-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    border-color var(--transition-fast);
}

.project-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent-color);
}

/* Strict Image Wrapper */
.card-image-wrapper {
  width: 100%;
  height: 100%;
  max-height: 100px;
  max-width: 160px;
  background: transparent;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}

.card-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  width: auto;
  height: auto;
}

.card-image.contain {
  object-fit: contain; /* Scales the entire image to fit INSIDE the 200px box */
  padding: 1.5rem; /* Keeps it away from the absolute edges */
  width: auto; /* Allows natural width scaling based on height */
}

/* Inner content wrapper */
.card-content {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.card-header {
  margin-bottom: 1rem;
}

.card-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  background-color: var(--accent-light);
  color: var(--accent-color);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.project-card h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.project-card p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.card-footer {
  margin-top: auto;
}

.card-footer .btn {
  width: 100%;
}

/* ==========================================================================
   About & Contact Section
   ========================================================================== */
.about-section {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  max-width: 1200px;
  margin: 4rem auto;
  
}

.about-section p {
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

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

/* ==========================================================================
   Footer
   ========================================================================== */
footer {
  text-align: center;
  padding: 2rem 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */
@media (max-width: 640px) {
  body {
    padding: 1rem 0.5rem;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .hero-subtitle {
    font-size: 1.1rem;
  }

  .projects-grid {
    grid-template-columns: 1fr; /* Full width cards on small screens */
  }

  .social-links {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}
