/* =========================
   1. Root & Variables
========================= */
:root {
  --bg: #000000;
  --text: #ffffff;
  --accent: #60a5fa;
  --card-bg: rgba(255, 255, 255, 0.03);
  --card-border: rgba(255, 255, 255, 0.1);
  --transition-smooth: 0.3s cubic-bezier(.2,.8,.2,1);
  --header-height: 4.5rem;
  color-scheme: dark; 
}

:root.light-mode {
  --bg: #ffffff;
  --text: #111827;
  --accent: #2563eb;
  --card-bg: #ffffff;
  --card-border: rgba(0, 0, 0, 0.08);
  color-scheme: light;
}

/* =========================
   2. Global Reset
========================= */
*, *::before, *::after { box-sizing: border-box; }

html {
  scrollbar-gutter: stable;
  height: 100%;
  background-color: var(--bg);
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  line-height: 1.6;
  margin: 0;
  padding: var(--header-height) 0 0 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; transition: var(--transition-smooth); }
a:visited { color: inherit; }

/* 1. Default (Dark Mode) - Hard-coded blue */
.social-button {
  color: #60a5fa !important; 
  border: 1.5px solid #60a5fa !important;
}

.social-button.btn-primary {
  background-color: #60a5fa !important;
  color: #ffffff !important;
}

/* 2. Light Mode Override - Hard-coded darker blue */
body.light-mode .social-button {
  color: #2563eb !important;
  border-color: #2563eb !important;
}

body.light-mode .social-button.btn-primary {
  background-color: #2563eb !important;
  color: #ffffff !important;
}

ul, ol { list-style: none; padding: 0; margin: 0; }

/* REVISED BUTTON LINE */
button { background: none; border: none; padding: 0; cursor: pointer; font-family: inherit; color: inherit; }

.container { width: 92%; max-width: 1200px; margin: 0 auto; }

/* Theme Transition Lock */
body:not(.transitions-enabled), body:not(.transitions-enabled) * { transition: none !important; }
body.transitions-enabled { transition: background-color 0.3s ease, color 0.3s ease; }

/* =========================
   3. Header & Navigation 
========================= */
#site-header {
  position: fixed; top: 0; left: 0; width: 100%; height: var(--header-height);
  z-index: 100; background: rgba(0, 0, 0, 0.9); backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--card-border);
  display: flex; align-items: center;
  transition: transform 0.4s cubic-bezier(.2,.8,.2,1); 
  transform: translateY(0);
  will-change: transform; 
}

#site-header.header-hidden { transform: translateY(-110%) !important; }
#site-header.header-visible { transform: translateY(0) !important; }

body.light-mode #site-header { background: rgba(255, 255, 255, 0.85); }

.site-header .container { 
  display: flex; justify-content: space-between; align-items: center; height: 100%; 
}

.site-title a {
  color: var(--accent) !important; font-weight: 700; font-size: 1.25rem;
  display: flex; align-items: center; height: 100%;
}

.menu-controls { display: flex; align-items: center; gap: 1rem; margin-left: auto; }
nav.menu { display: flex; align-items: center; }

body:not(.light-mode) .moon-icon, 
body.light-mode .sun-icon { display: none !important; }

/* Refined state for toggles */
.theme-toggle, .menu-toggle {
  display: flex; align-items: center; justify-content: center;
  /* Use a very faint border instead of transparent to prevent 'vanishing' */
  border: 1px solid var(--card-border); 
  border-radius: 0.4rem;
  padding: 0.4rem; min-width: 40px; height: 40px;
  color: var(--text); 
  transition: all 0.2s ease;
  background: transparent;
  cursor: pointer;
}

/* Prevent sticky focus highlights on mobile */
@media (hover: none) {
  .theme-toggle:focus, 
  .menu-toggle:focus {
    background: transparent !important;
    border-color: var(--card-border) !important;
    box-shadow: none !important;
  }
}

/* Keep the scale/feedback for taps on mobile (without the sticky blue ring) */
.theme-toggle:active, .menu-toggle:active {
  background: rgba(128, 128, 128, 0.2);
  transform: scale(0.95);
  transition: transform 0.1s ease; /* Faster feedback for touch */
}

/* Prevent the menu button from flashing when the menu is closing/navigating */
.menu-toggle:focus-visible {
  outline: none;
}

/* Specifically target the moment after a click */
.menu-toggle:not(:active):focus {
  background: transparent;
  border-color: var(--card-border);
}

/* Light mode adjustments */
body.light-mode .theme-toggle, 
body.light-mode .menu-toggle {
  border-color: rgba(0, 0, 0, 0.08);
}

/* Desktop Navigation */
@media (min-width: 769px) {
  .menu-list { display: flex; align-items: center; gap: 2rem; margin-right: 2rem; height: 100%; }
  .menu-list li { display: flex; align-items: center; height: 100%; }
  
  .menu-list a { 
    position: relative; 
    opacity: 0.7; 
    transition: var(--transition-smooth);
    display: inline-flex; 
    align-items: center; 
    height: var(--header-height);
  }

  .menu-list a:hover, 
  .menu-list a.current { 
    opacity: 1; 
    color: var(--accent) !important; 
  }

  /* Fixed: Single, consistent underline logic for the active page */
  .menu-list a.current::after {
    content: ''; 
    position: absolute; 
    bottom: 20px; 
    left: 0;
    width: 100%; 
    height: 2px; 
    background: var(--accent);
    transition: width 0.3s ease;
  }
}

/* The Icon Container */
.hamburger-icon {
  width: 20px;
  height: 14px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* The three bars */
.hamburger-icon span {
  display: block;
  width: 100%;
  height: 2px;
  background-color: var(--text);
  transition: all 0.3s ease-in-out;
  transform-origin: center;
}

/* Morphing into the X */
body.menu-open .hamburger-icon span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

body.menu-open .hamburger-icon span:nth-child(2) {
  opacity: 0; /* Hide the middle bar */
}

body.menu-open .hamburger-icon span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* =========================
   4. Components & Layouts
========================= */
main.container { padding: 3rem 0; }

.social-links { display: flex; flex-wrap: wrap; margin-top: 2rem; gap: 12px; row-gap: 16px; }
.social-button {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 0.7rem 1.2rem; border-radius: 0.4rem;
  border: 1.5px solid var(--accent); color: var(--accent);
  font-weight: 500; transition: all 0.3s;
}

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

.project-grid ul { 
  display: grid; 
  /* minmax ensures they don't get too skinny before jumping to 1 column */
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); 
  gap: 2.5rem; 
}

.project-item { 
  background: var(--card-bg); 
  border: 1px solid var(--card-border); 
  border-radius: 0.8rem; 
  overflow: hidden; 
  display: flex;
  flex-direction: column; /* Ensure content stacks vertically */
  transition: 
    transform 0.4s cubic-bezier(0.2, 1, 0.2, 1), 
    box-shadow 0.4s cubic-bezier(0.2, 1, 0.2, 1), 
    border-color 0.3s ease, 
    background 0.3s ease;
  height: 100%; /* Makes all cards in a row the same height */
}

.project-thumb {
  width: 100%;
  aspect-ratio: 16 / 9; /* Standard widescreen ratio */
  object-fit: cover; 
  display: block; 
  border-bottom: 1px solid var(--card-border);
  /* Fix: Prevents the image from stretching if the card gets taller */
  align-self: flex-start; 
}

.project-content {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.project-item h3, .project-description, .project-tags { padding: 0 1.5rem; }
.project-item h3 { 
  margin: 1.5rem 0 0.5rem 0; 
  font-size: 1.4rem; 
  color: var(--accent); /* Changed from default text color to blue */
  transition: var(--transition-smooth);
}
.project-item a h3 {
  color: var(--accent);
}
.project-item a:visited h3 {
  color: var(--accent);
}
.project-description { margin-bottom: 1.5rem; opacity: 0.8; flex-grow: 1; }
.project-tags { padding-bottom: 1.5rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* Combined Tag Styling for Projects and About Page */
.tag, .project-tag, .skill-tags .tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 2rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  background: rgba(128, 128, 128, 0.1);
  color: var(--accent);
  border: 1px solid var(--card-border);
}

/* Restore Spacing for About Page */
.skills-section {
  margin-bottom: 3rem; /* Space below the skills grid */
}

.skill-category h3 {
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.button-group {
  display: flex;
  gap: 1rem;
  margin-top: 2rem; /* Space above the "View Work" buttons */
  flex-wrap: wrap;
}

/* =========================
   Hover & Mouse-Only Logic
========================= */
@media (hover: hover) {
  /* 1. Header Toggles */
  .theme-toggle:hover, .menu-toggle:hover {
    background: var(--card-bg);
    border-color: var(--accent);
    box-shadow: 0 0 12px rgba(96, 165, 250, 0.2);
  }

  /* 2. Light Mode Toggle Overrides */
  body.light-mode .theme-toggle:hover, 
  body.light-mode .menu-toggle:hover {
    background: rgba(0, 0, 0, 0.03);
    border-color: var(--accent);
  }

  /* 3. Project Cards */
  .project-item:hover {
    transform: translateY(-8px);
    border-color: var(--accent);
    box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.5);
    background: rgba(255, 255, 255, 0.06);
  }

  .project-item:hover .project-thumb {
    filter: brightness(1.1);
  }

  /* 4. Light Mode Card Shadow Adjustment */
  body.light-mode .project-item:hover {
    background: #ffffff;
    box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.1);
  }

  /* 5. Social & Action Buttons */
  .social-button:hover { 
    transform: translateY(-2px); 
    filter: brightness(1.1); /* Matches the project title "glow" logic */
    box-shadow: 0 5px 15px rgba(96, 165, 250, 0.2); /* Adds a subtle blue shadow */
  }

   .project-item:hover h3 {
    text-decoration: underline; /* Classic link indicator */
    filter: brightness(1.2); /* Makes the blue glow slightly on hover */
  }

   .site-footer a:hover { 
  text-decoration: underline; 
  filter: brightness(1.2); /* Consistent with project titles */
  opacity: 1; /* Keep it fully opaque so it's easy to read */
}

   body.light-mode .project-item:hover h3,
   body.light-mode .social-button:hover,
   body.light-mode .site-footer a:hover {
  filter: brightness(0.85); /* Makes the blue slightly darker/richer for better contrast on white */
}
}

/* Add this to Section 4 of your CSS */
.contact {
  max-width: 700px;
  margin: 4rem 0; /* Adds breathing room below the header */
}

.contact h1 {
  font-size: 3rem;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

/* =========================
   5. Mobile Adjustments
========================= */
.profile { 
  border-radius: 50%; 
  border: 3px solid var(--accent); 
  padding: 5px; 
  object-fit: cover;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1); /* Adds depth */
}

@media (max-width: 768px) {
  /* Morphing Icon Positioning */
  .menu-toggle { z-index: 1100; position: relative; }

  /* Glassmorphism Menu */
  .menu-list {
    position: fixed; inset: 0; width: 100vw; height: 100vh; 
    background: rgba(0, 0, 0, 0.85); 
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    display: flex; flex-direction: column; justify-content: center; align-items: center; 
    gap: 1.5rem; z-index: 1000; opacity: 0; visibility: hidden; 
    transition: all 0.4s cubic-bezier(.2,.8,.2,1);
  }

  body.menu-open .menu-list { opacity: 1; visibility: visible; }

  .menu-list a {
    font-size: 2.5rem; font-weight: 700; letter-spacing: -0.02em;
    padding: 0.8rem 2rem; border-radius: 50px; transition: all 0.3s ease;
  }

  /* Active Pill (Unified Rule) */
  .menu-list a.current {
    color: var(--accent) !important;
    background: rgba(96, 165, 250, 0.1);
  }

  /* Link Animation Stagger */
  .menu-list li { opacity: 0; transform: translateY(20px); transition: all 0.4s ease; }
  body.menu-open .menu-list li { opacity: 1; transform: translateY(0); }
  body.menu-open .menu-list li:nth-child(1) { transition-delay: 0.1s; }
  body.menu-open .menu-list li:nth-child(2) { transition-delay: 0.15s; }
  body.menu-open .menu-list li:nth-child(3) { transition-delay: 0.2s; }

  /* --- LIGHT MODE MOBILE OVERRIDES --- */
  body.light-mode .menu-list { background: rgba(255, 255, 255, 0.95); }
  
  body.light-mode .menu-list a { color: #111827; }

  body.light-mode .menu-list a.current {
    background: rgba(37, 99, 235, 0.1); /* Darker blue for light mode */
  }

  body.light-mode .hamburger-icon span { background-color: #111827; }

   /* Override the desktop 16:9 with your preferred 4:3 for mobile */
  .project-thumb {
    aspect-ratio: 4 / 3;
  }

   .project-item h3 {
    margin-top: 1rem;
    font-size: 1.25rem; /* Slightly smaller title for mobile */
    padding: 0 1rem;
  }

  .project-description {
    padding: 0 1rem;
    font-size: 0.95rem;
    margin-bottom: 1rem;
  }

  .project-tags { 
  padding: 0 1rem 1.5rem 1rem; 
  display: flex; 
  flex-wrap: wrap; 
  gap: 0.5rem; /* Clean spacing between tags */
}

   .tag, .project-tag, .skill-tags .tag {
    margin-bottom: 0; /* Let 'gap' do the work */
    margin-right: 0;
  }

   .contact h1 {
    font-size: 2.25rem;
  }
   
}

@media (min-width: 769px) {
  .menu-toggle, .menu-close { display: none; }
  .intro-block { display: flex; align-items: center; gap: 3rem; }
  .profile { width: 12rem; height: 12rem; }
}

/* =========================
   6. Footer & Animations
========================= */
.site-footer { padding: 3rem 0; border-top: 1px solid var(--card-border); text-align: center; margin-top: auto; }
.site-footer a { margin: 0 1rem; color: var(--accent); font-weight: 500; transition: opacity 0.3s; }

.fade-up { opacity: 0; transform: translateY(20px); transition: all 0.4s ease-out; }
.fade-up.active { opacity: 1; transform: translateY(0); }
