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

:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --bg: #ffffff;
  --bg-alt: #f8fafc;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --card-bg: #ffffff;
  --radius: 0.75rem;
  --header-gradient: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  --footer-bg: #1e293b;
  --footer-text: rgba(255, 255, 255, 0.55);
  --tag-bg: #eff6ff;
  --tag-color: #2563eb;
  --btn-secondary-hover: #eff6ff;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-alt: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --card-bg: #1e293b;
  --header-gradient: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  --footer-bg: #020617;
  --footer-text: rgba(255, 255, 255, 0.4);
  --tag-bg: #1e3a8a33;
  --tag-color: #93c5fd;
  --btn-secondary-hover: #1e3a8a33;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f172a;
    --bg-alt: #1e293b;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
    --card-bg: #1e293b;
    --header-gradient: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    --footer-bg: #020617;
    --footer-text: rgba(255, 255, 255, 0.4);
    --tag-bg: #1e3a8a33;
    --tag-color: #93c5fd;
    --btn-secondary-hover: #1e3a8a33;
  }
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  font-size: 1rem;
  transition: background 0.2s, color 0.2s;
}

/* === Layout === */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* === Header === */
header {
  background: var(--header-gradient);
  color: #fff;
  padding: 5rem 0 4rem;
  text-align: center;
  position: relative;
}

header h1 {
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 0.5rem;
}

.tagline {
  font-size: 1.1rem;
  opacity: 0.85;
  margin-bottom: 2rem;
  letter-spacing: 0.5px;
}

nav {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
}

nav a {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  letter-spacing: 0.3px;
  transition: color 0.2s;
}

nav a:hover {
  color: #ffffff;
  text-decoration: underline;
}

/* === Theme Toggle === */
.theme-toggle {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.2s;
  font-family: inherit;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.25);
}

.theme-toggle .icon {
  font-size: 1rem;
  line-height: 1;
}

/* === Sections === */
.section {
  padding: 5rem 0;
  background: var(--bg);
  transition: background 0.2s;
}

.section.alt {
  background: var(--bg-alt);
}

.section h2 {
  font-size: 1.9rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--text);
}

.section p {
  color: var(--text-muted);
  max-width: 640px;
  margin-bottom: 1rem;
  font-size: 1.05rem;
}

/* === Skills Grid === */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.25rem;
  margin-top: 2rem;
}

.skill-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  text-align: center;
  transition: box-shadow 0.2s, transform 0.2s, background 0.2s, border-color 0.2s;
}

.skill-card:hover {
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.12);
  transform: translateY(-2px);
}

.skill-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.75rem;
}

.skill-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.skill-card p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
}

/* === Projects Grid === */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-top: 2rem;
}

.project-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  transition: box-shadow 0.2s, transform 0.2s, background 0.2s, border-color 0.2s;
}

.project-card:hover {
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.12);
  transform: translateY(-2px);
}

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

.project-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.tag {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--tag-color);
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 500;
  margin-right: 0.35rem;
  transition: background 0.2s, color 0.2s;
}

/* === Contact === */
.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.5rem;
}

.contact-btn {
  display: inline-block;
  padding: 0.75rem 1.75rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: background 0.2s, color 0.2s, transform 0.15s;
  background: var(--primary);
  color: #fff;
}

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

.contact-btn.secondary {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.contact-btn.secondary:hover {
  background: var(--btn-secondary-hover);
}

/* === Skill Modal === */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2rem 1.75rem;
  max-width: 480px;
  width: 100%;
  position: relative;
  animation: modal-in 0.15s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.modal-card h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.25rem;
}

.modal-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.modal-card ul li {
  color: var(--text-muted);
  font-size: 0.92rem;
  padding-left: 1.1rem;
  position: relative;
  line-height: 1.5;
}

.modal-card ul li::before {
  content: '·';
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 700;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}

.modal-close:hover {
  color: var(--text);
  background: var(--border);
}

/* Clickable skill cards */
.skill-card[data-skill] {
  cursor: pointer;
}

.skill-card[data-skill]::after {
  content: 'details →';
  display: block;
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--primary);
  opacity: 0.6;
  transition: opacity 0.15s;
}

.skill-card[data-skill]:hover::after {
  opacity: 1;
}

/* Tag links (project cards) */
.tag-link {
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}

.tag-link:hover {
  background: var(--primary);
  color: #fff;
}

/* === Footer === */
footer {
  background: var(--footer-bg);
  color: var(--footer-text);
  text-align: center;
  padding: 2rem 0;
  font-size: 0.875rem;
  transition: background 0.2s;
}

/* === Responsive === */
@media (max-width: 600px) {
  header {
    padding: 3.5rem 0 3rem;
  }

  .section {
    padding: 3.5rem 0;
  }

  nav {
    gap: 1.25rem;
  }

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

  .contact-btn {
    text-align: center;
  }

  .theme-toggle {
    top: 0.85rem;
    right: 0.85rem;
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
  }
}
