/* =========================
   Design Tokens & Variables
   ========================= */
:root {
  /* DARK MODE (Default) */
  --bg: #0f1115;
  --card: #161a22;
  --text: #e6e7eb;
  --muted: #a7adbb;
  --accent: #7aa2f7;
  --border: #262b36;
  
  /* UX Variables */
  --nav-bg: rgba(22, 26, 34, 0.85);
  --shadow-color: rgba(0, 0, 0, 0.5);
  --hero-gradient: radial-gradient(circle at 20% 20%, rgba(122,162,247,0.15), transparent 40%),
                   radial-gradient(circle at 80% 80%, rgba(122,162,247,0.08), transparent 40%);
  --heading-gradient: linear-gradient(to right, #fff, #a7adbb);
}

/* LIGHT MODE OVERRIDES */
body.light-mode {
  --bg: #ffffff;
  --card: #ffffff;      /* Clean white card */
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;    /* Slightly darker blue for readability on white */
  --border: #e5e7eb;
  
  /* UX Variables Swapped */
  --nav-bg: rgba(255, 255, 255, 0.85); /* White frosted glass */
  --shadow-color: rgba(0, 0, 0, 0.1);  /* Much softer shadow */
  
  /* Hero Gradient: Made slightly stronger so it shows up on white */
  --hero-gradient: radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.15), transparent 40%),
                   radial-gradient(circle at 80% 80%, rgba(59, 130, 246, 0.1), transparent 40%);
                   
  --heading-gradient: linear-gradient(to right, #111827, #4b5563);
}

/* =========================
   Reset / Base
   ========================= */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  line-height: 1.55;
  padding-top: 64px;
  transition: background 0.3s ease, color 0.3s ease; /* Smooth toggle */
}

a { color: inherit; text-decoration: none; transition: color 0.2s;}
a:hover { color: var(--accent); }

/* =========================
   Navbar
   ========================= */
#navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: var(--nav-bg); /* Uses variable now */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s ease, border-color 0.3s ease;
}

#navbar ul {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  justify-content: center;
  list-style: none;
  margin: 0;
  padding: 1rem;
}

#navbar .nav-link {
  font-weight: 600;
  padding: 0.5rem;
  color: var(--text); /* Ensures text flips color automatically */
}

#theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  transition: all 0.2s;
}

#theme-toggle:hover {
  background: var(--border);
}

/* =========================
   Hero Section
   ========================= */
#welcome-section {
  min-height: 90vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: var(--hero-gradient); /* Uses variable now */
}

#welcome-section h1 {
  font-size: clamp(2.5rem, 5vw, 4rem);
  margin: 0;
  background: var(--heading-gradient); /* Uses variable now */
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  padding-bottom: 10px; /* Prevents gradient clipping */
}

#welcome-section p {
  color: var(--muted);
  font-size: 1.25rem;
  margin-top: 1rem;
}

/* =========================
   Projects Grid
   ========================= */
#projects {
    padding: 4rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

#projects h2 {
  text-align: center;
  font-size: 2rem;
  margin-bottom: 3rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
  color: var(--text);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

.project-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  display: flex;
  flex-direction: column;
}

.project-tile:hover {
  transform: translateY(-5px);
  /* Use the shadow variable for softer light-mode shadows */
  box-shadow: 0 10px 30px var(--shadow-color); 
  border-color: var(--accent);
}

.project-tile img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-bottom: 1px solid var(--border);
  /* Optional: slightly dim images in dark mode to reduce glare, full brightness in light */
  filter: brightness(0.9); 
  transition: filter 0.3s;
}
body.light-mode .project-tile img {
    filter: brightness(1);
}

.tile-content {
    padding: 1.5rem;
}

.tile-title {
  font-weight: 700;
  font-size: 1.2rem;
  margin: 0 0 0.5rem 0;
  color: var(--text); /* Changed from accent to text for better readability */
}

/* Optional: Keep title blue only on hover or leave as accent if you prefer */
.project-tile:hover .tile-title {
    color: var(--accent);
}

.tile-desc {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

/* =========================
   Contact & Footer
   ========================= */
#contact {
  text-align: center;
  padding: 6rem 1rem;
  /* Use a subtle gradient fade based on card color */
  background: linear-gradient(to top, var(--card), transparent); 
}

.social-icons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 2rem;
}

.social-icons a {
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-weight: 600;
    color: var(--text);
    background: var(--card); /* Adds structure in light mode */
}

.social-icons a:hover {
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 4px 12px var(--shadow-color);
}

footer {
  text-align: center;
  padding: 2rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
  background: var(--bg);
}

/* Mobile Tweak */
@media (max-width: 600px) {
  #navbar ul { flex-wrap: wrap; justify-content: center; }
  h1 { font-size: 2rem; }
}
