/* ============================================
   Philip Muriuki — Portfolio
   Vanilla CSS • Dark-first theme
   ============================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Fira+Code:wght@400;500&display=swap');

/* ----- Theme Tokens ----- */
:root {
  /* Dark (default) */
  --bg-primary: #0a0a1a;
  --bg-secondary: #12122a;
  --bg-tertiary: #1a1a3e;
  --text-primary: #e4e4ef;
  --text-secondary: #8888a0;
  --accent: #00d4aa;
  --accent-hover: #00f0c0;
  --accent-glow: rgba(0, 212, 170, 0.25);
  --card-bg: #1a1a3e;
  --card-border: rgba(255, 255, 255, 0.06);
  --nav-bg: rgba(10, 10, 26, 0.85);
  --nav-shadow: 0 2px 20px rgba(0, 0, 0, 0.4);
  --input-bg: #12122a;
  --input-border: rgba(255, 255, 255, 0.1);
  --tag-bg: rgba(0, 212, 170, 0.12);
  --tag-text: #00d4aa;
  --divider: rgba(255, 255, 255, 0.06);
  --toast-bg: #1a1a3e;

  /* Geometry */
  --max-width: 1200px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 50px;
  --section-pad: 100px 0;

  /* Timing */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --speed: 0.3s;
}

[data-theme="light"] {
  --bg-primary: #f5f5f7;
  --bg-secondary: #ffffff;
  --bg-tertiary: #eaeaef;
  --text-primary: #1a1a2e;
  --text-secondary: #555570;
  --accent: #00b894;
  --accent-hover: #00a884;
  --accent-glow: rgba(0, 184, 148, 0.18);
  --card-bg: #ffffff;
  --card-border: rgba(0, 0, 0, 0.08);
  --nav-bg: rgba(245, 245, 247, 0.92);
  --nav-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
  --input-bg: #f0f0f5;
  --input-border: rgba(0, 0, 0, 0.1);
  --tag-bg: rgba(0, 184, 148, 0.1);
  --tag-text: #00896e;
  --divider: rgba(0, 0, 0, 0.06);
  --toast-bg: #ffffff;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
}

img {
  max-width: 100%;
  display: block;
}

button {
  cursor: pointer;
  font-family: inherit;
}

/* ----- Utility ----- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

.section-header {
  text-align: center;
  margin-bottom: 60px;
}

.section-header h2 {
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 12px;
  position: relative;
  display: inline-block;
}

.section-header h2::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 3px;
  background: var(--accent);
  border-radius: 4px;
}

.section-header p {
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto;
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 0.95rem;
  font-weight: 600;
  transition: all var(--speed) var(--ease);
}

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

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 30px var(--accent-glow);
  transform: translateY(-2px);
}

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

.btn-secondary:hover {
  background: var(--accent);
  color: #0a0a1a;
  transform: translateY(-2px);
}

/* ============================================
   NAVBAR
   ============================================ */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: box-shadow var(--speed) var(--ease), background var(--speed) var(--ease);
}

.navbar.scrolled {
  box-shadow: var(--nav-shadow);
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
}

.nav-logo {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.nav-logo span {
  color: var(--accent);
}

.nav-links {
  display: flex;
  gap: 32px;
}

.nav-links a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  position: relative;
  transition: color var(--speed) var(--ease);
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width var(--speed) var(--ease);
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text-primary);
}

.nav-links a.active::after,
.nav-links a:hover::after {
  width: 100%;
}

/* Right controls */
.nav-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Theme Switch */
.theme-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.theme-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  position: relative;
  width: 60px;
  height: 30px;
  background: var(--bg-tertiary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
  transition: background var(--speed) var(--ease), border-color var(--speed) var(--ease);
}

.switch-track:hover {
  border-color: var(--accent);
}

.switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: var(--accent);
  border-radius: 50%;
  transition: transform var(--speed) var(--ease), background var(--speed) var(--ease);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  z-index: 2;
}

/* When checkbox is checked (light mode) — knob slides right */
.theme-switch input:checked~.switch-track .switch-knob {
  transform: translateX(29px);
}

.switch-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  z-index: 1;
  transition: color var(--speed) var(--ease), opacity var(--speed) var(--ease);
}

.sun-icon {
  color: #f9ca24;
  opacity: 0.45;
}

.moon-icon {
  color: #a29bfe;
  opacity: 0.45;
}

/* Highlight the active icon */
[data-theme="dark"] .moon-icon {
  opacity: 1;
  color: #dfe6e9;
}

[data-theme="light"] .sun-icon {
  opacity: 1;
  color: #f39c12;
}

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.hamburger span {
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all var(--speed) var(--ease);
}

.hamburger.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
}

.hamburger.active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ============================================
   HERO
   ============================================ */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  overflow: hidden;
}

/* Animated background */
.hero-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--bg-primary) 0%, #0f0f2d 50%, #0a1628 100%);
  z-index: 0;
}

.hero-bg .shape {
  position: absolute;
  border-radius: 50%;
  opacity: .08;
  animation: float 20s infinite ease-in-out;
}

.hero-bg .shape:nth-child(1) {
  width: 600px;
  height: 600px;
  background: var(--accent);
  top: -200px;
  right: -100px;
  animation-delay: 0s;
}

.hero-bg .shape:nth-child(2) {
  width: 400px;
  height: 400px;
  background: #6c5ce7;
  bottom: -100px;
  left: -100px;
  animation-delay: -7s;
}

.hero-bg .shape:nth-child(3) {
  width: 300px;
  height: 300px;
  background: #0984e3;
  top: 50%;
  left: 60%;
  animation-delay: -14s;
}

@keyframes float {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  33% {
    transform: translate(30px, -50px) scale(1.05);
  }

  66% {
    transform: translate(-20px, 30px) scale(0.95);
  }
}

[data-theme="light"] .hero-bg {
  background: linear-gradient(135deg, #f5f5f7 0%, #e8e8f0 50%, #dfe6ed 100%);
}

[data-theme="light"] .hero-bg .shape {
  opacity: .06;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 720px;
}

.hero-greeting {
  font-size: 1.1rem;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hero h1 {
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 16px;
}

.hero-tagline {
  font-size: 1.15rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-family: 'Fira Code', monospace;
  min-height: 1.5em;
}

.hero-tagline .cursor {
  display: inline-block;
  width: 2px;
  height: 1.2em;
  background: var(--accent);
  margin-left: 2px;
  animation: blink .8s step-end infinite;
  vertical-align: text-bottom;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.hero-description {
  color: var(--text-secondary);
  font-size: 1rem;
  max-width: 560px;
  margin-bottom: 36px;
  line-height: 1.8;
}

.hero-buttons {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

/* ============================================
   PROJECTS
   ============================================ */
.projects {
  padding: var(--section-pad);
  background: var(--bg-secondary);
}

.filter-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 48px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 10px 24px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all var(--speed) var(--ease);
}

.filter-btn:hover,
.filter-btn.active {
  background: var(--accent);
  color: #0a0a1a;
  border-color: var(--accent);
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.project-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 32px;
  transition: all var(--speed) var(--ease);
  display: flex;
  flex-direction: column;
}

.project-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 40px var(--accent-glow);
  border-color: rgba(0, 212, 170, 0.2);
}

.project-card .card-icon {
  margin-bottom: 16px;
  color: var(--accent);
  line-height: 0;
}

.project-card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 10px;
}

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

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.project-tags span {
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: var(--radius-pill);
}

.project-links {
  display: flex;
  gap: 16px;
  margin-top: auto;
}

.project-links a {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color var(--speed) var(--ease);
}

.project-links a:hover {
  color: var(--accent);
}

/* ============================================
   SKILLS
   ============================================ */
.skills {
  padding: var(--section-pad);
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
}

.skill-category h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.skill-category h3 span.cat-icon {
  display: inline-flex;
  align-items: center;
  color: var(--accent);
}

.skill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.skill-badge {
  padding: 8px 18px;
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--bg-tertiary);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  transition: all var(--speed) var(--ease);
}

.skill-badge:hover {
  background: var(--accent);
  color: #0a0a1a;
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

/* ============================================
   ABOUT
   ============================================ */
.about {
  padding: var(--section-pad);
  background: var(--bg-secondary);
}

.about-content {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 60px;
  align-items: center;
}

.about-image-wrapper {
  position: relative;
}

.about-image {
  width: 280px;
  height: 280px;
  border-radius: var(--radius);
  background: var(--bg-tertiary);
  overflow: hidden;
  position: relative;
}

.about-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.about-image::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), #6c5ce7);
  z-index: -1;
}

.about-image .placeholder-avatar {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
}

.about-text h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.about-text p {
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.8;
}

.about-stats {
  display: flex;
  gap: 40px;
  margin-bottom: 32px;
}

.stat-item .stat-number {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent);
}

.stat-item .stat-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* ============================================
   CONTACT
   ============================================ */
.contact {
  padding: var(--section-pad);
}

.contact-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
}

.contact-info h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.contact-info p {
  color: var(--text-secondary);
  margin-bottom: 32px;
  line-height: 1.8;
}

.contact-details {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform var(--speed) var(--ease);
}

a.contact-item:hover {
  transform: translateX(6px);
}

a.contact-item:hover .icon-circle {
  background: var(--accent);
  color: #0a0a1a;
}

.contact-item .icon-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
  transition: all var(--speed) var(--ease);
}

.contact-item span {
  color: var(--text-secondary);
  font-size: 0.92rem;
}

/* Contact form */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.form-group {
  position: relative;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 16px 20px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border var(--speed) var(--ease);
  outline: none;
}

.form-group textarea {
  min-height: 150px;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent);
}

.form-group label {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: all var(--speed) var(--ease);
  pointer-events: none;
  background: var(--input-bg);
  padding: 0 4px;
}

.form-group textarea~label {
  top: 20px;
  transform: none;
}

.form-group input:focus~label,
.form-group input:not(:placeholder-shown)~label {
  top: 0;
  transform: translateY(-50%);
  font-size: 0.75rem;
  color: var(--accent);
}

.form-group textarea:focus~label,
.form-group textarea:not(:placeholder-shown)~label {
  top: 0;
  transform: translateY(-50%);
  font-size: 0.75rem;
  color: var(--accent);
}

.form-error {
  color: #ff6b6b;
  font-size: 0.78rem;
  margin-top: 6px;
  display: none;
}

.form-group.error .form-error {
  display: block;
}

.form-group.error input,
.form-group.error textarea {
  border-color: #ff6b6b;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 40px;
  right: 40px;
  background: var(--toast-bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--accent);
  font-weight: 500;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  transform: translateY(120px);
  opacity: 0;
  transition: all var(--speed) var(--ease);
  z-index: 2000;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
  padding: 40px 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--divider);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.footer p {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.footer-github {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  transition: color var(--speed) var(--ease);
}

.footer-github:hover {
  color: var(--accent);
}

.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: #0a0a1a;
  border: none;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
  transition: all var(--speed) var(--ease);
  z-index: 900;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover {
  box-shadow: 0 4px 20px var(--accent-glow);
  transform: translateY(-3px);
}

/* ============================================
   SCROLL REVEAL
   ============================================ */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width:1024px) {
  .projects-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .skills-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width:768px) {
  .hamburger {
    display: flex;
  }

  .nav-links {
    position: fixed;
    top: 70px;
    left: 0;
    width: 100%;
    background: var(--nav-bg);
    backdrop-filter: blur(16px);
    flex-direction: column;
    align-items: center;
    padding: 32px 0;
    gap: 24px;
    transform: translateY(-120%);
    transition: transform var(--speed) var(--ease);
  }

  .nav-links.open {
    transform: translateY(0);
  }

  .about-content {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .about-image-wrapper {
    margin: 0 auto;
  }

  .about-stats {
    justify-content: center;
  }

  .contact-wrapper {
    grid-template-columns: 1fr;
  }

  .projects-grid {
    grid-template-columns: 1fr;
  }

  .skills-grid {
    grid-template-columns: 1fr;
  }

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

  .hero-buttons {
    justify-content: center;
  }

  .hero-content {
    text-align: center;
  }

  .hero-description {
    margin: 0 auto 36px;
  }
}

@media (max-width:480px) {
  .section-header h2 {
    font-size: 1.6rem;
  }

  :root {
    --section-pad: 60px 0;
  }

  .btn {
    padding: 12px 24px;
    font-size: 0.85rem;
  }

  .project-card {
    padding: 24px;
  }
}