/* ========================================
   Kinara Chamara — Advanced Portfolio
   Premium · Light/Dark · Responsive
======================================== */

:root {
  --bg: #f3f5fa;
  --bg-alt: #ffffff;
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-soft: #eef2ff;
  --accent-hover: #4338ca;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow: 0 8px 30px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.12);
  --radius: 16px;
  --radius-lg: 24px;
  --header-bg: rgba(243, 245, 250, 0.8);
  --success: #059669;
  --success-soft: #ecfdf5;
  --gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #a855f7 100%);
  --gradient-soft: linear-gradient(135deg, rgba(79,70,229,0.12), rgba(168,85,247,0.08));
}

[data-theme="dark"] {
  --bg: #070b14;
  --bg-alt: #111827;
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --muted: #64748b;
  --accent: #818cf8;
  --accent-2: #a78bfa;
  --accent-soft: #1e1b4b;
  --accent-hover: #a5b4fc;
  --border: #1e293b;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
  --header-bg: rgba(7, 11, 20, 0.85);
  --success: #34d399;
  --success-soft: #064e3b;
  --gradient: linear-gradient(135deg, #6366f1 0%, #a78bfa 50%, #c084fc 100%);
  --gradient-soft: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(192,132,252,0.08));
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background 0.35s ease, color 0.35s ease;
}

/* subtle background mesh */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(79, 70, 229, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(168, 85, 247, 0.06), transparent);
  pointer-events: none;
  z-index: 0;
}

[data-theme="dark"] body::before {
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(99, 102, 241, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(168, 85, 247, 0.08), transparent);
}

.wrap {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 0 24px 90px;
  position: relative;
  z-index: 1;
}

/* ---------- Header ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
  transition: background 0.35s, border-color 0.35s;
}

.header-inner {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.3px;
}

.logo-mark {
  width: 38px;
  height: 38px;
  background: var(--gradient);
  color: white;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
}

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav a {
  text-decoration: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 10px;
  transition: all 0.2s ease;
}

.nav a:hover {
  color: var(--text);
  background: var(--accent-soft);
}

.nav a.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--bg-alt);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 17px;
  display: grid;
  place-items: center;
  transition: all 0.2s ease;
  color: var(--text);
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.06);
}

.menu-btn {
  display: none;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 18px;
  place-items: center;
  color: var(--text);
}

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: 20px 0 40px;
  animation: fadeUp 0.6s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

.avatar-wrap {
  position: relative;
  width: 150px;
  height: 150px;
  margin: 0 auto 24px;
}

.avatar {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--bg-alt);
  box-shadow:
    0 0 0 1px var(--border),
    0 14px 40px rgba(15, 23, 42, 0.15);
  transition: border-color 0.3s;
}

[data-theme="dark"] .avatar {
  box-shadow:
    0 0 0 1px var(--border),
    0 14px 40px rgba(0, 0, 0, 0.5);
}

.avatar-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: var(--gradient);
  z-index: -1;
  opacity: 0.8;
  animation: pulse-ring 3.2s ease-in-out infinite;
}

@keyframes pulse-ring {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 0.95; transform: scale(1.03); }
}

.hero h1 {
  font-size: clamp(32px, 6vw, 48px);
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1.1;
  margin-bottom: 10px;
  background: linear-gradient(135deg, var(--text) 40%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-theme="dark"] .hero h1 {
  background: linear-gradient(135deg, #f8fafc 30%, #a5b4fc);
  -webkit-background-clip: text;
  background-clip: text;
}

.hero .badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}

[data-theme="dark"] .hero .badge {
  border-color: rgba(52, 211, 153, 0.25);
}

.hero .badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 28%, transparent);
  animation: blink 2s ease infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.hero .subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.hero .location {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 22px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.22s ease;
  border: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--gradient);
  color: white;
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(79, 70, 229, 0.45);
}

.btn-secondary {
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  transform: translateY(-2px);
}

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 36px;
  animation: fadeUp 0.6s 0.1s ease both;
}

.stat-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
}

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

.stat-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -1px;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

/* ---------- Sections ---------- */
.section {
  margin-bottom: 28px;
  animation: fadeUp 0.55s ease both;
}

.section:nth-child(3) { animation-delay: 0.12s; }
.section:nth-child(4) { animation-delay: 0.18s; }
.section:nth-child(5) { animation-delay: 0.24s; }
.section:nth-child(6) { animation-delay: 0.3s; }

.card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px;
  box-shadow: var(--shadow);
  transition: background 0.35s, border-color 0.35s, box-shadow 0.35s;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--accent);
  margin-bottom: 10px;
}

.section h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-bottom: 16px;
  color: var(--text);
}

.about-text {
  color: var(--text-secondary);
  font-size: 15.5px;
  line-height: 1.8;
}

.about-text p + p {
  margin-top: 12px;
}

/* Skills */
.skills-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 26px;
}

.skill-group h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 999px;
  transition: all 0.15s ease;
}

.tag:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* Projects */
.projects-grid {
  display: grid;
  gap: 14px;
}

.project-card {
  display: flex;
  gap: 18px;
  padding: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  text-decoration: none;
  color: inherit;
  transition: all 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
  overflow: hidden;
}

.project-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--gradient-soft);
  opacity: 0;
  transition: opacity 0.28s;
}

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

.project-card:hover::before {
  opacity: 1;
}

.project-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--gradient);
  color: white;
  display: grid;
  place-items: center;
  font-size: 24px;
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.35);
  position: relative;
  z-index: 1;
}

.project-body {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.project-body h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
  letter-spacing: -0.3px;
}

.project-body p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 10px;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.project-tags span {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--muted);
}

.project-card:hover .project-tags span {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  color: var(--accent);
}

.project-arrow {
  align-self: center;
  font-size: 20px;
  color: var(--muted);
  transition: transform 0.2s, color 0.2s;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.project-card:hover .project-arrow {
  transform: translateX(4px);
  color: var(--accent);
}

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

.contact-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: all 0.2s ease;
}

.contact-item:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.contact-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 20px;
  flex-shrink: 0;
}

.contact-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
  font-weight: 500;
}

.contact-item a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
}

.contact-item a:hover {
  text-decoration: underline;
}

.contact-item span.value {
  font-weight: 600;
  color: var(--text);
  font-size: 15px;
}

/* Page header */
.page-header {
  text-align: center;
  padding: 16px 0 32px;
  animation: fadeUp 0.5s ease both;
}

.page-header h1 {
  font-size: clamp(28px, 5vw, 38px);
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 10px;
}

.page-header p {
  color: var(--muted);
  font-size: 16px;
  max-width: 460px;
  margin: 0 auto;
}

/* CTA band */
.cta-band {
  background: var(--gradient);
  border-radius: var(--radius-lg);
  padding: 36px 28px;
  text-align: center;
  color: white;
  box-shadow: 0 12px 40px rgba(79, 70, 229, 0.3);
  margin-bottom: 8px;
}

.cta-band h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  color: white;
  letter-spacing: -0.4px;
}

.cta-band p {
  opacity: 0.9;
  font-size: 15px;
  margin-bottom: 18px;
}

.cta-band .btn {
  background: white;
  color: #4f46e5;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.cta-band .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}

/* Footer */
.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 36px 0 12px;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .menu-btn {
    display: grid;
  }

  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-alt);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 12px 16px 16px;
    gap: 4px;
    box-shadow: var(--shadow);
  }

  .nav.open {
    display: flex;
  }

  .nav a {
    padding: 12px 14px;
    width: 100%;
  }

  .header-inner {
    position: relative;
    flex-wrap: nowrap;
  }

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

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

  .card {
    padding: 22px 18px;
  }

  .avatar-wrap,
  .avatar {
    width: 128px;
    height: 128px;
  }

  .project-card {
    flex-direction: column;
    gap: 14px;
  }

  .project-arrow {
    display: none;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    justify-content: center;
  }
}

@media (min-width: 721px) and (max-width: 900px) {
  .stats {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---------- Timeline ---------- */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  padding-left: 8px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  display: flex;
  gap: 18px;
  padding: 14px 0;
  position: relative;
}

.timeline-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gradient);
  border: 3px solid var(--bg-alt);
  box-shadow: 0 0 0 2px var(--accent);
  flex-shrink: 0;
  margin-top: 4px;
  z-index: 1;
}

.timeline-body h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 2px;
  color: var(--text);
}

.timeline-meta {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 6px;
}

.timeline-body p:last-child {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ---------- Goals ---------- */
.goals-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.goal-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 16px;
  transition: all 0.22s ease;
}

.goal-item:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-2px);
}

.goal-icon {
  font-size: 28px;
  margin-bottom: 10px;
}

.goal-item h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}

.goal-item p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* ---------- Social ---------- */
.social-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.social-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
}

.social-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-2px);
}

.social-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}

.social-card strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.social-card small {
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .goals-grid {
    grid-template-columns: 1fr;
  }
  .social-grid {
    grid-template-columns: 1fr;
  }
}
