/* ===========================
   Kannaki Labs — Design System
   Dark Premium Theme
   =========================== */

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

/* --- Custom Properties --- */
:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #111111;
  --bg-tertiary: #1a1a1a;
  --bg-card: rgba(40, 40, 40, 0.6);
  --bg-card-solid: #222222;
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.75);
  --text-muted: rgba(255, 255, 255, 0.5);
  --accent: #ffffff;
  --border: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.15);
  --gradient-metallic: linear-gradient(135deg, #333 0%, #888 40%, #fff 100%);
  --gradient-dark: linear-gradient(180deg, #1a1a1a 0%, #0a0a0a 100%);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 60px rgba(255, 255, 255, 0.03);
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --nav-height: 72px;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  line-height: 1.6;
}

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

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

/* --- Typography --- */
.heading-xl {
  font-size: clamp(3.5rem, 8vw, 7rem);
  font-weight: 300;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.heading-lg {
  font-size: clamp(2.5rem, 5vw, 5rem);
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.heading-md {
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.body-text {
  font-size: clamp(1rem, 1.2vw, 1.2rem);
  font-weight: 300;
  line-height: 1.7;
  color: var(--text-secondary);
}

.label-text {
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* --- Navigation --- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(1.5rem, 4vw, 4rem);
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

.navbar.scrolled {
  background: rgba(10, 10, 10, 0.95);
}

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

.nav-logo img {
  height: 40px;
  width: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.nav-logo span {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: clamp(1.5rem, 3vw, 2.5rem);
  list-style: none;
}

.nav-links a {
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-muted);
  transition: color 0.3s ease;
  position: relative;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--text-primary);
  transition: width 0.3s ease;
}

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

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

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

.hamburger span {
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  transition: var(--transition);
  display: block;
}

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

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

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

/* --- Sections --- */
section {
  min-height: 100vh;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
  padding: calc(var(--nav-height) + 2rem) clamp(1.5rem, 4vw, 4rem) 2rem;
}

.section-inner {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 4vw, 5rem);
  align-items: center;
}

.section-inner.reverse {
  direction: rtl;
}

.section-inner.reverse>* {
  direction: ltr;
}

/* --- Decorative Elements --- */
.three-dots {
  display: flex;
  gap: 8px;
  margin-bottom: 2rem;
}

.three-dots span {
  width: 10px;
  height: 10px;
  background: var(--text-primary);
  display: block;
}

.arrow-icon {
  font-size: 1.5rem;
  color: var(--text-muted);
  position: absolute;
  transition: var(--transition);
}

.arrow-icon.top-right {
  top: clamp(2rem, 4vw, 4rem);
  right: clamp(2rem, 4vw, 4rem);
}

.arrow-icon.bottom-right {
  bottom: clamp(2rem, 4vw, 4rem);
  right: clamp(2rem, 4vw, 4rem);
}

/* Dot Pattern */
.dot-pattern {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dot-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: 12px;
  width: 350px;
  height: 400px;
}

.dot-grid span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-primary);
  transition: opacity 0.5s ease;
}

/* --- Hero Section --- */
#hero {
  background: var(--bg-primary);
  padding-top: 0;
  min-height: 100vh;
}

#hero .section-inner {
  min-height: 100vh;
  padding-top: var(--nav-height);
}

.hero-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2rem 0;
}

.hero-title {
  font-size: clamp(4rem, 9vw, 8rem);
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.04em;
  margin-bottom: 2rem;
}

.hero-tagline {
  font-size: clamp(1rem, 1.3vw, 1.3rem);
  color: var(--text-muted);
  font-weight: 300;
  max-width: 500px;
  line-height: 1.6;
  margin-bottom: 1rem;
}

.hero-url {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 3rem;
  font-weight: 400;
}

.hero-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.hero-image-container {
  position: relative;
  width: 100%;
  max-width: 550px;
  aspect-ratio: 1;
}

.hero-image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  filter: grayscale(100%) contrast(1.1);
}

.hero-image-glow {
  position: absolute;
  inset: -20px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%);
  pointer-events: none;
}

/* --- About Section --- */
#about {
  background: var(--bg-tertiary);
}

.about-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(2rem, 4vw, 3.5rem);
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

.about-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-card), var(--shadow-glow);
  transform: translateY(-4px);
}

/* --- Vision Section --- */
#vision {
  background: var(--bg-secondary);
}

.geometric-shape {
  width: 100%;
  max-width: 450px;
  aspect-ratio: 0.85;
  position: relative;
  margin: 0 auto;
}

.shape-pentagon {
  width: 100%;
  height: 100%;
  clip-path: polygon(50% 0%, 100% 35%, 100% 100%, 0% 100%, 0% 35%);
  background: var(--gradient-metallic);
  position: relative;
  overflow: hidden;
}

.shape-pentagon::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(0, 0, 0, 0.6) 100%);
}

/* --- Mission Section --- */
#mission {
  background: var(--bg-secondary);
}

.shape-beam {
  width: 100%;
  max-width: 500px;
  height: 300px;
  margin: 0 auto;
  position: relative;
  transform: perspective(800px) rotateY(-15deg) rotateX(5deg);
}

.beam-face {
  position: absolute;
  background: var(--gradient-metallic);
}

.beam-top {
  width: 100%;
  height: 100%;
  clip-path: polygon(20% 0%, 100% 30%, 80% 100%, 0% 70%);
  background: linear-gradient(135deg, #222 0%, #666 30%, #aaa 60%, #fff 100%);
}

.beam-top::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(255, 255, 255, 0.3) 100%);
}

/* --- Research Section --- */
#research {
  background: linear-gradient(180deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%);
}

#research .section-inner {
  align-items: center;
}

.research-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  justify-content: center;
}

.research-card {
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: clamp(1rem, 1.8vw, 1.5rem) clamp(1.25rem, 2.5vw, 2rem);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.research-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 0;
  background: var(--text-primary);
  transition: height 0.5s ease;
}

.research-card:hover::before {
  height: 100%;
}

.research-card:hover {
  border-color: var(--border-light);
  transform: translateX(8px);
  background: rgba(40, 40, 40, 0.8);
}

.research-card h3 {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  letter-spacing: 0.01em;
}

.research-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.55;
  font-weight: 300;
}

/* --- Work / Research Graph Section --- */
#work {
  background: var(--bg-primary);
  position: relative;
}

#work .section-inner {
  align-items: center;
}

#work::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(30, 30, 30, 0.5) 0%, transparent 50%),
    repeating-linear-gradient(0deg,
      transparent,
      transparent 80px,
      rgba(255, 255, 255, 0.01) 80px,
      rgba(255, 255, 255, 0.01) 81px);
  pointer-events: none;
}

/* Work section grid: graph gets more space */
#work .section-inner {
  grid-template-columns: 1.5fr 1fr;
}

/* Research Line Graph */
.graph-container {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(1rem, 2vw, 2rem);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow-card);
}

/* Work info right column */
.work-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.work-info .heading-xl {
  margin-top: 1rem;
  margin-bottom: 0.75rem;
}

.work-info .body-text {
  margin-bottom: 1.5rem;
}

.graph-container svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Line animation */
.graph-line {
  transition: points 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Data point dots */
.graph-dot {
  transition: cy 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.4s ease;
}

/* Pulse ring on current data point */
.pulse-dot {
  transition: cy 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94), cx 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.6s ease;
}

@keyframes pulseDot {

  0%,
  100% {
    r: 7;
    opacity: 0.6;
  }

  50% {
    r: 12;
    opacity: 0;
  }
}

.pulse-dot.animated {
  animation: pulseDot 2s ease-in-out infinite;
}

/* Legend */
.graph-legend {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.legend-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.legend-color {
  width: 12px;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
  margin-top: 7px;
}

.legend-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.legend-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.legend-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
  font-weight: 300;
}

/* --- Contact Section --- */
#contact {
  background: var(--bg-tertiary);
  min-height: 60vh;
  margin-top: 2rem;
  z-index: 1;
  position: relative;
}

#contact .section-inner {
  grid-template-columns: 1fr;
  text-align: center;
  justify-items: center;
}

.contact-content {
  max-width: 600px;
}

.contact-links {
  display: flex;
  gap: 2rem;
  margin-top: 2.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.contact-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition);
  backdrop-filter: blur(10px);
}

.contact-link:hover {
  border-color: var(--border-light);
  transform: translateY(-3px);
  background: rgba(50, 50, 50, 0.6);
}

.contact-link svg {
  width: 20px;
  height: 20px;
  fill: var(--text-primary);
}

.contact-link span {
  font-size: 0.95rem;
  font-weight: 400;
}

/* --- Footer --- */
.footer {
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  padding: 2rem clamp(1.5rem, 4vw, 4rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.footer-left img {
  height: 28px;
  width: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.footer-left span {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.footer-right {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* --- Animations --- */
.fade-in {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

.fade-in-left {
  opacity: 0;
  transform: translateX(-50px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.fade-in-left.visible {
  opacity: 1;
  transform: translateX(0);
}

.fade-in-right {
  opacity: 0;
  transform: translateX(50px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.fade-in-right.visible {
  opacity: 1;
  transform: translateX(0);
}

.scale-in {
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.scale-in.visible {
  opacity: 1;
  transform: scale(1);
}

/* Stagger delays */
.delay-1 {
  transition-delay: 0.1s;
}

.delay-2 {
  transition-delay: 0.2s;
}

.delay-3 {
  transition-delay: 0.3s;
}

.delay-4 {
  transition-delay: 0.4s;
}

.delay-5 {
  transition-delay: 0.5s;
}

/* --- Dot pattern animation --- */
@keyframes dotFade {

  0%,
  100% {
    opacity: 0.2;
  }

  50% {
    opacity: 1;
  }
}

.dot-grid span {
  animation: dotFade 3s ease-in-out infinite;
}

.dot-grid span:nth-child(odd) {
  animation-delay: 0.5s;
}

.dot-grid span:nth-child(3n) {
  animation-delay: 1s;
}

.dot-grid span:nth-child(5n) {
  animation-delay: 1.5s;
}

/* Pulse glow for hero image */
@keyframes pulseGlow {

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

  50% {
    opacity: 0.5;
    transform: scale(1.02);
  }
}

.hero-image-glow {
  animation: pulseGlow 4s ease-in-out infinite;
}

/* Floating animation for shapes */
@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-15px);
  }
}

.geometric-shape {
  animation: float 6s ease-in-out infinite;
}

/* --- Mobile Navigation Overlay --- */
.mobile-nav {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.98);
  backdrop-filter: blur(30px);
  z-index: 999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.mobile-nav.active {
  opacity: 1;
  pointer-events: all;
}

.mobile-nav a {
  font-size: 2rem;
  font-weight: 300;
  color: var(--text-secondary);
  transition: color 0.3s ease;
}

.mobile-nav a:hover {
  color: var(--text-primary);
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  section {
    min-height: auto;
    align-items: flex-start;
  }

  .section-inner {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .section-inner.reverse {
    direction: ltr;
  }

  .hero-title {
    font-size: clamp(3rem, 10vw, 5rem);
  }

  /* === Text first, animations second for ALL sections === */

  .dot-pattern {
    order: 2;
    display: flex;
    justify-content: center;
  }

  .vision-text {
    order: 1;
  }

  .geometric-shape {
    order: 2;
    max-width: 220px;
    margin: 0 auto;
  }

  .mission-text {
    order: 1;
  }

  .shape-beam-wrap {
    order: 2;
    display: flex;
    justify-content: center;
  }

  .shape-beam {
    max-width: 250px;
    height: 160px;
  }

  .research-heading {
    order: 1;
  }

  .research-cards {
    order: 2;
  }

  .research-heading .three-dots {
    justify-content: flex-start !important;
  }

  .research-heading h2 {
    text-align: left !important;
  }

  .research-heading .hero-url {
    text-align: left !important;
  }

  /* Work section: force single column on mobile */
  #work .section-inner {
    grid-template-columns: 1fr;
  }

  .work-info {
    order: 1;
    text-align: left;
  }

  .graph-container {
    order: 2;
  }

  .graph-legend {
    flex-direction: column;
    gap: 0.75rem;
  }

  .dot-grid {
    width: 200px;
    height: 220px;
  }
}

@media (max-width: 768px) {
  :root {
    --nav-height: 64px;
  }

  .nav-links {
    display: none;
  }

  .hamburger {
    display: flex;
  }

  .mobile-nav {
    display: flex;
  }

  section {
    min-height: auto;
    align-items: flex-start;
    padding: calc(var(--nav-height) + 2rem) 1.25rem 2rem;
  }

  .section-inner {
    gap: 1.5rem;
  }

  #hero {
    min-height: auto;
    padding-top: calc(var(--nav-height) + 3rem);
    padding-bottom: 3rem;
  }

  #hero .section-inner {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .hero-visual {
    order: -1;
  }

  .hero-image-container {
    max-width: 220px;
  }

  .geometric-shape {
    max-width: 200px;
  }

  .shape-beam {
    max-width: 220px;
    height: 150px;
  }

  .arrow-icon {
    display: none;
  }

  .hero-title {
    font-size: clamp(2.5rem, 12vw, 4rem);
  }

  .heading-xl {
    font-size: clamp(2.5rem, 10vw, 4rem);
  }

  .heading-lg {
    font-size: clamp(2rem, 8vw, 3rem);
  }

  .research-cards {
    gap: 1rem;
  }

  .graph-container {
    padding: 1rem;
  }

  .graph-legend {
    gap: 0.75rem;
  }

  .legend-desc {
    display: none;
  }

  .contact-links {
    flex-direction: column;
    align-items: center;
  }

  .footer {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .dot-grid {
    width: 200px;
    height: 220px;
    gap: 8px;
  }

  .dot-grid span {
    width: 7px;
    height: 7px;
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: 2.5rem;
  }

  .heading-xl {
    font-size: 2.5rem;
  }

  .graph-container {
    padding: 0.75rem;
    border-radius: var(--radius-md);
  }

  .graph-legend {
    gap: 0.5rem;
  }
}

/* --- Utility --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}