/* ================================
   portfolio.css — Samirbek Jabborov's Kreativ Portfolio
   Structure:
   0) Reset & tokens
   1) Layout & typography
   2) Components (navbar, buttons, cards, monogram, demo, icons)
   3) Sections (hero, skills, projects, demo, contact, footer)
   4) Utilities & animations
   5) Responsive
================================ */

/* ---------- 0) RESET & TOKENS ---------- */
:root {
  /* Colors (light) */
  --bg: #f7f8fb;
  --surface: #ffffff;
  --card: #ffffff;
  --muted: #f1f3f9;
  --text: #0e1320;
  --text-muted: #515a78;
  --primary: #2952ff;
  --primary-600: #1e44f5;
  --primary-700: #1435da;
  --border: #e6e9f2;
  --accent: #0ea5e9;
  --success: #2ecc71;
  --danger: #ff6b6b;
  --warning: #ffd166;

  /* Shadows & radii */
  --radius: 18px;
  --radius-sm: 14px;
  --shadow-1: 0 8px 22px rgba(0,0,0,.1);
  --shadow-2: 0 14px 36px rgba(0,0,0,.15);

  /* Sizing */
  --container: 1240px;
  --pad-x: 28px;

  /* Typography */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial;
  --font-logo: "Space Grotesk", sans-serif;
  --h1: clamp(36px, 5.5vw, 60px);
  --h2: clamp(28px, 4vw, 40px);
  --h3: clamp(22px, 3vw, 28px);
  --text-base: 16px;
  --text-sm: 14px;
}

/* Dark mode */
html.dark {
  --bg: #0b0c10;
  --surface: #111218;
  --card: #141621;
  --muted: #1a1d2a;
  --text: #e6e8ef;
  --text-muted: #a8afc7;
  --primary: #6aa3ff;
  --primary-600: #4f8fff;
  --primary-700: #3a79ef;
  --border: #25293a;
  --accent: #9de2ff;
}

/* Modern reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  background: radial-gradient(1300px 900px at 90% -5%, rgba(106,163,255,.15), transparent 60%),
              radial-gradient(1000px 700px at -5% 20%, rgba(14,165,233,.15), transparent 60%),
              var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
ul { margin: 0; padding: 0; list-style: none; }

/* Containers */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--pad-x);
}

/* ---------- 1) LAYOUT & TYPOGRAPHY ---------- */
h1, h2, h3 {
  margin: 0 0 16px;
  font-weight: 800;
  letter-spacing: -.03em;
}
h1 { font-size: var(--h1); line-height: 1.1; }
h2 { font-size: var(--h2); line-height: 1.15; }
h3 { font-size: var(--h3); line-height: 1.2; }
p { margin: 0; color: var(--text); }
.muted { color: var(--text-muted); }

.section {
  padding: 120px 0;
}
.section h2 {
  position: relative;
  padding-bottom: 16px;
}
.section h2::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 90px; height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--primary) 12%, transparent);
}

/* ---------- 2) COMPONENTS ---------- */

/* Navbar */
.navbar {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(1.6) blur(16px);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-bottom: 1px solid var(--border);
}
.navbar .container {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 88px;
}
.logo {
  font-family: var(--font-logo);
  font-weight: 700;
  font-size: 26px;
  display: flex; align-items: center; gap: 10px;
}
.monogram {
  font-size: 32px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: pulse 3s ease-in-out infinite;
}
.nav-links {
  display: flex; gap: 32px;
}
.nav-links a {
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  transition: all .35s ease;
}
.nav-links a:hover {
  color: var(--text);
  background: var(--muted);
  transform: translateY(-3px);
}
.nav-actions { display: flex; gap: 14px; align-items: center; }
.nav-actions button {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow-1);
  transition: all .35s ease;
}
.nav-actions button:hover { transform: translateY(-3px); background: var(--muted); border-color: var(--accent); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 10px;
  padding: 16px 24px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-weight: 700;
  transition: all .35s ease;
  box-shadow: var(--shadow-1);
}
.btn:hover { transform: translateY(-3px); background: var(--muted); border-color: var(--accent); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn.primary {
  background: linear-gradient(180deg, var(--primary), var(--primary-700));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 14px 32px color-mix(in srgb, var(--primary) 35%, transparent);
}
.btn.primary:hover { filter: brightness(1.08); transform: translateY(-3px); }
.btn.outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn.small { padding: 12px 18px; font-size: var(--text-sm); }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  transition: transform .4s ease, box-shadow .4s ease;
}
.card:hover { transform: translateY(-6px) rotateX(2deg) rotateY(2deg); box-shadow: var(--shadow-2); }

/* Links group */
.link-row {
  display: flex; flex-wrap: wrap; gap: 16px;
}
.link-row a {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  transition: all .35s ease;
}
.link-row a:hover { background: var(--muted); color: var(--text); transform: translateY(-3px); }

/* Contact icons */
.contact-links .icon {
  font-size: 1.4em;
  color: var(--primary);
  transition: transform .3s ease, color .3s ease;
}
.contact-links a:hover .icon {
  transform: scale(1.2);
  color: var(--accent);
}

/* Project card images */
.project-card img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-radius: var(--radius) var(--radius) 0 0;
  margin-bottom: 18px;
  transition: transform .4s ease;
}
.project-card:hover img { transform: scale(1.05); }

/* Demo container */
.demo-container {
  margin-top: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-1);
}
#algorithm-canvas {
  width: 100%;
  max-width: 600px;
  height: 400px;
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.demo-controls {
  margin-top: 16px;
  display: flex; gap: 16px; flex-wrap: wrap;
}
.demo-controls select {
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-sm);
}

/* ---------- 3) SECTIONS ---------- */

/* Hero */
.hero {
  padding: 140px 0 100px;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: radial-gradient(circle at 90% 10%, rgba(106,163,255,.18), transparent 60%),
              radial-gradient(circle at -10% 25%, rgba(14,165,233,.18), transparent 60%);
  z-index: -1;
}
.hero-content {
  display: grid;
  grid-template-columns: 1.5fr .5fr;
  gap: 56px;
  align-items: center;
}
.hero-text p { max-width: 680px; }
.hero-text .bio { margin-top: 20px; font-size: 1.2em; }
.hero-buttons { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 28px; }
.hero-avatar { display: grid; place-items: center; }
.avatar {
  width: 260px; height: 260px;
  border-radius: 40px;
  border: 3px solid var(--border);
  background:
    conic-gradient(from 180deg at 50% 50%, color-mix(in srgb, var(--accent) 25%, transparent), transparent 60%),
    radial-gradient(300px 220px at 120% 0%, color-mix(in srgb, var(--primary) 30%, transparent), transparent 60%),
    var(--muted);
  color: #fff;
  font-family: var(--font-logo);
  font-size: 72px; font-weight: 700; letter-spacing: .07em;
  display: grid; place-items: center;
  box-shadow: var(--shadow-2);
  animation: floaty 4s ease-in-out infinite;
}

/* About */
#about .card { padding: 32px; }
#about .link-row { margin-top: 28px; }

/* Skills */
#skills { background: var(--muted); }
#skills .skills-list {
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
}
#skills .skills-list li {
  padding: 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow-1);
  transition: transform .4s ease, box-shadow .4s ease;
}
#skills .skills-list li:hover { transform: translateY(-4px) rotateX(2deg); box-shadow: var(--shadow-2); }

/* Projects */
#projects .projects-grid {
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 28px;
}
.project-card {
  padding: 28px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  perspective: 1000px;
}
.project-card h3 { margin-bottom: 12px; }
.project-card p { margin-bottom: 20px; }
.project-card .link-row { margin-top: 16px; }

/* Demo */
#demo { background: var(--muted); }
#demo .demo-container { transition: transform .4s ease, box-shadow .4s ease; }
#demo .demo-container:hover { transform: translateY(-6px); box-shadow: var(--shadow-2); }

/* Contact */
#contact { background: var(--muted); }
#contact .contact-links {
  margin: 28px 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}
#contact .contact-links a {
  padding: 18px;
  border-radius: var(--radius-sm);
  justify-content: center;
}
#contact form {
  max-width: 760px;
  margin: 28px auto 0;
  display: grid;
  gap: 20px;
}
#contact label {
  font-weight: 600;
  color: var(--text-muted);
}
#contact input, #contact textarea {
  padding: 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-base);
}
#contact textarea { resize: vertical; min-height: 180px; }
#contact button { margin-top: 14px; }

/* Footer */
.footer {
  padding: 40px 0;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
}
.footer p { font-size: var(--text-sm); }

/* ---------- 4) UTILITIES & ANIMATIONS ---------- */
.hidden { display: none !important; }
.center { display: grid; place-items: center; }

@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

html { scroll-behavior: smooth; }
:focus-visible {
  outline: 4px solid var(--accent);
  outline-offset: 4px;
  border-radius: 12px;
}

/* ---------- 5) RESPONSIVE ---------- */
@media (min-width: 768px) {
  .nav-links { display: flex; }
  .section { padding: 140px 0; }
}
@media (max-width: 991px) {
  .hero-content { grid-template-columns: 1fr; }
  .hero { padding: 120px 0 80px; }
  .avatar { width: 220px; height: 220px; font-size: 64px; }
}
@media (max-width: 767px) {
  .navbar .container { min-height: 80px; }
  .nav-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 80px; left: 0; right: 0;
    background: var(--surface);
    padding: 28px;
    border-bottom: 1px solid var(--border);
  }
  .nav-links.show { display: flex; }
  #menu-toggle { display: block; }
  .btn { padding: 14px 20px; }
  #skills .skills-list { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  #projects .projects-grid { grid-template-columns: 1fr; }
  #contact .contact-links { grid-template-columns: 1fr; }
  .project-card img { height: 200px; }
  #algorithm-canvas { height: 300px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}