﻿@import url("https://fonts.googleapis.com/css2?family=Boldonse&display=swap");
/* ===== Global Styles & Reset ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Prevent horizontal overflow on all elements */
* {
  max-width: 100%;
}

html,
body {
  max-width: 100vw;
  overflow-x: hidden;
}

/* Ensure images and media are responsive */
img,
video,
canvas,
svg {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Ensure flexbox and grid items don't overflow */
.hero-buttons,
.social-links,
.about-stats,
.project-tech-mini,
.project-links-group {
  max-width: 100%;
}

:root {
  --primary-color: #6366f1;
  --secondary-color: #8b5cf6;
  --accent-color: #ec4899;
  --nav-active-color: #ff3b3b;
  --connector-color: #ff8a00;
  --connector-length: 56px;
  --dark-bg: #0f172a;
  --darker-bg: #020617;
  --card-bg: rgba(30, 41, 59, 0.7);
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --gradient-3: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --gradient-4: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);

  /* Enhanced easing functions for smooth animations */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out-quart: cubic-bezier(0.76, 0, 0.24, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);

  /* Performance optimization with better timing */
  --transition-fast: 0.3s var(--ease-smooth);
  --transition-normal: 0.5s var(--ease-out-quint);
  --transition-slow: 0.8s var(--ease-out-expo);
}

/* Light Theme */
[data-theme="light"] {
  --darker-bg: #f8fafc;
  --dark-bg: #e2e8f0;
  --card-bg: rgba(255, 255, 255, 0.6);
  --text-primary: #1e293b;
  --text-secondary: #475569;
}

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

/* ===== Loading Screen ===== */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--darker-bg);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.7s var(--ease-out-quint),
    transform 0.7s var(--ease-out-quint), visibility 0.7s;
}

.loading-screen.hidden {
  opacity: 0;
  transform: scale(1.05);
  visibility: hidden;
  pointer-events: none;
}

.loader {
  text-align: center;
}

.loader-circle {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1.2s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
  margin: 0 auto 20px;
}

.loader-text {
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 500;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== Theme Toggle Button ===== */

.theme-toggle {
  position: fixed;
  top: 30px;
  right: 30px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.03),
    rgba(255, 255, 255, 0.01)
  );
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  cursor: pointer;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  transition: transform 0.5s var(--ease-out-expo),
    box-shadow 0.5s var(--ease-out-expo), background 0.3s var(--ease-smooth);
  box-shadow: 0 6px 20px rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
}

.theme-toggle:hover {
  transform: translateY(-4px) scale(1.08) rotate(8deg);
  box-shadow: 0 16px 42px rgba(99, 102, 241, 0.4),
    0 8px 20px rgba(2, 6, 23, 0.7);
}

.theme-toggle:active {
  transform: scale(0.92);
  transition: transform 0.15s var(--ease-smooth);
}

.theme-toggle .fa-sun {
  display: none;
}

[data-theme="light"] .theme-toggle .fa-sun {
  display: block;
}

[data-theme="light"] .theme-toggle .fa-moon {
  display: none;
}

/* ===== Toast Notifications ===== */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 350px;
}

.toast {
  background: var(--card-bg);
  border-left: 4px solid var(--primary-color);
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideInRight 0.6s var(--ease-out-expo);
  backdrop-filter: blur(10px);
}

.toast.success {
  border-left-color: #10b981;
}

.toast.error {
  border-left-color: #ef4444;
}

.toast.warning {
  border-left-color: #f59e0b;
}

.toast.info {
  border-left-color: #3b82f6;
}

.toast-icon {
  font-size: 1.5rem;
}

.toast.success .toast-icon {
  color: #10b981;
}
.toast.error .toast-icon {
  color: #ef4444;
}
.toast.warning .toast-icon {
  color: #f59e0b;
}
.toast.info .toast-icon {
  color: #3b82f6;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.toast-message {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

.toast-close:hover {
  color: var(--text-primary);
}

@keyframes slideInRight {
  0% {
    transform: translateX(420px) scale(0.9);
    opacity: 0;
  }
  60% {
    transform: translateX(-10px) scale(1.02);
    opacity: 1;
  }
  100% {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

.toast.removing {
  animation: slideOutRight 0.5s var(--ease-in-out-quart) forwards;
}

@keyframes slideOutRight {
  0% {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateX(420px) scale(0.85);
    opacity: 0;
  }
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

/* ===== Scroll Snap (vertical) ===== */
/* Use mandatory snapping for a firm slide-like experience; change to 'proximity' for softer feel */
html,
body {
  /* make full-height so <main> can be the scrolling container */
  height: 100%;
  scroll-snap-type: none; /* disable root snapping - we'll use <main> */
  -webkit-scroll-snap-type: none;
}

/* Use the main element as the scroll container so sections (its direct
   children) snap correctly. This avoids issues when sections are nested
   inside another wrapper. */
main#main-content {
  height: 100vh;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  -webkit-scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch; /* smooth momentum on iOS */
}

/* Per-section snap alignment */
section {
  scroll-snap-align: start;
  -webkit-scroll-snap-align: start;
  scroll-snap-stop: always;
}

/* Respect users who prefer reduced motion: disable snapping and transitions */
@media (prefers-reduced-motion: reduce) {
  html,
  body {
    scroll-snap-type: none;
    -webkit-scroll-snap-type: none;
  }
  .section-item {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--darker-bg);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
  position: relative;
  opacity: 0;
  animation: fadeInBody 0.8s var(--ease-out-quint) 0.2s forwards;
}

@keyframes fadeInBody {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
  box-sizing: border-box;
}

/* ===== Animated Background ===== */
.animated-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
  background: var(--darker-bg);
}

.gradient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0;
  animation: float 25s infinite cubic-bezier(0.45, 0.05, 0.55, 0.95),
    fadeInOrb 2s ease-out 0.5s forwards;
}

@keyframes fadeInOrb {
  to {
    opacity: 0.5;
  }
}

.orb-1 {
  width: 500px;
  height: 500px;
  background: var(--gradient-1);
  top: -10%;
  left: -10%;
  animation-delay: 0s;
}

.orb-2 {
  width: 400px;
  height: 400px;
  background: var(--gradient-3);
  top: 50%;
  right: -10%;
  animation-delay: 1s;
}

.orb-3 {
  width: 450px;
  height: 450px;
  background: var(--gradient-2);
  bottom: -10%;
  left: 30%;
  animation-delay: 2s;
}

@keyframes float {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  25% {
    transform: translate(80px, -80px) scale(1.08);
  }
  50% {
    transform: translate(-60px, 90px) scale(0.92);
  }
  75% {
    transform: translate(40px, 50px) scale(1.05);
  }
}

/* ===== Side Navigation (nav-track) - appear from left on load ===== */
.side-nav {
  position: fixed;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  pointer-events: auto;
}

.nav-track {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  /* start hidden/shifted left */
  opacity: 0;
  transform: translateX(-50px) scale(0.9);
  transition: transform 0.9s var(--ease-out-expo), opacity 0.7s ease-out;
}

.nav-track.enter {
  opacity: 1;
  transform: translateX(0) scale(1);
}

.nav-node {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 2px solid var(--connector-color);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  opacity: 0;
  transform: translateX(-15px) scale(0.7);
  transition: transform 0.6s var(--ease-out-expo), opacity 0.5s ease-out,
    box-shadow 0.4s var(--ease-out-quint);
}

/* When track has the enter class, reveal nodes with small stagger */
.nav-track.enter .nav-node {
  opacity: 1;
  transform: translateX(0) scale(1);
}
.nav-track.enter .nav-node:nth-of-type(1) {
  transition-delay: 0.1s;
}
.nav-track.enter .nav-node:nth-of-type(2) {
  transition-delay: 0.2s;
}
.nav-track.enter .nav-node:nth-of-type(3) {
  transition-delay: 0.3s;
}
.nav-track.enter .nav-node:nth-of-type(4) {
  transition-delay: 0.4s;
}
.nav-track.enter .nav-node:nth-of-type(5) {
  transition-delay: 0.5s;
}

.nav-node:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

/* Connector styling uses --fill (existing logic), ensure it's visible after enter */
.nav-connector {
  width: 3px;
  height: var(--connector-length, 56px);
  background: linear-gradient(
    to bottom,
    transparent 0%,
    var(--connector-color) var(--fill, 0%)
  );
  border-radius: 4px;
  transition: background 0.3s ease, height 0.3s ease;
  opacity: 0.9;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .nav-track,
  .nav-node,
  .nav-connector {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
}

/* ===== Hero Section ===== */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  width: 100%;
  overflow-x: hidden;
}

.hero .container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: center;
  width: 100%;
}

.hero-content {
  /* start hidden; we'll add .enter when ready to animate */
  opacity: 0;
  transform: translateY(30px) scale(0.96);
  transition: transform 0.9s var(--ease-out-expo), opacity 0.7s ease-out,
    scale 0.9s var(--ease-out-expo);
}

.hero-content.enter {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* allow the section observer to reveal hero content as well */
section#home.in-view .hero-content {
  opacity: 1;
  transform: translateY(0) scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .hero-content {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
}

.wave {
  display: inline-block;
  animation: wave 2.5s cubic-bezier(0.36, 0, 0.66, -0.56) infinite;
  transform-origin: 70% 70%;
}

@keyframes wave {
  0%,
  100% {
    transform: rotate(0deg);
  }
  10% {
    transform: rotate(14deg);
  }
  20% {
    transform: rotate(-10deg);
  }
  30% {
    transform: rotate(14deg);
  }
  40% {
    transform: rotate(-6deg);
  }
  50% {
    transform: rotate(12deg);
  }
  60% {
    transform: rotate(0deg);
  }
}

.hero-title {
  font-size: 3rem;
  font-weight: bold;
  margin-bottom: 1rem;
  line-height: 1.2;
}

.gradient-text {
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.3rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  min-height: 2rem;
}

.hero-buttons {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
}

.btn {
  padding: 0.8rem 2rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.4s var(--ease-out-quint);
  display: inline-block;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  transform: translate(-50%, -50%);
  transition: width 0.6s var(--ease-out-expo), height 0.6s var(--ease-out-expo);
  pointer-events: none;
}

.btn:hover::before {
  width: 300px;
  height: 300px;
}

.btn-primary {
  background: var(--gradient-1);
  color: white;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 32px rgba(102, 126, 234, 0.5);
}

.btn-primary:active {
  transform: translateY(-1px) scale(0.98);
  transition: all 0.15s var(--ease-smooth);
}

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

.btn-secondary:hover {
  background: var(--primary-color);
  color: white;
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
}

.btn-secondary:active {
  transform: translateY(-1px) scale(0.98);
  transition: all 0.15s var(--ease-smooth);
}

.social-links {
  display: flex;
  gap: 1rem;
}

.social-icon {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 1.5rem;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

/* Ensure no stray underline/line or border appears under social icons */
.social-links,
.social-links a,
.social-icon {
  border: 0 !important;
  outline: none !important;
  text-decoration: none !important;
  box-shadow: none !important; /* remove any faint hairline from user agents */
  -webkit-tap-highlight-color: transparent;
}

.social-icon {
  transition: all 0.5s var(--ease-out-expo);
}

.social-icon:hover {
  background: var(--gradient-1);
  transform: translateY(-6px) rotate(8deg) scale(1.1);
  box-shadow: 0 12px 30px rgba(102, 126, 234, 0.4);
}

.social-icon:active {
  transform: translateY(-2px) scale(0.95);
  transition: all 0.15s var(--ease-smooth);
}

.hero-image {
  position: relative;
}

/* ===== Hero image: appear from the right on load ===== */
.hero-image {
  /* start slightly to the right and hidden */
  opacity: 0;
  transform: translateX(50px) scale(0.95);
  transition: transform 1s var(--ease-out-expo), opacity 0.8s ease-out 0.15s;
}

.hero-image.enter {
  opacity: 1;
  transform: translateX(0) scale(1);
}

/* Also allow the hero to animate when the section becomes active */
section#home.in-view .hero-image {
  opacity: 1;
  transform: translateX(0) scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .hero-image {
    transform: none !important;
    transition: none !important;
    opacity: 1 !important;
  }
}

.code-animation {
  position: relative;
  /* slightly reduced width for better balance in the hero */
  width: 100%;
  max-width: min(100%, 750px);
  height: 400px;
  background: var(--card-bg);
  border-radius: 20px;
  padding: 1rem;
  margin: 0 auto;
  backdrop-filter: blur(10px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  box-sizing: border-box;
}

.code-line {
  height: 20px;
  background: var(--gradient-1);
  margin: 1.5rem 0;
  border-radius: 10px;
  animation: codeLine 3s infinite ease-in-out;
  opacity: 0.6;
}

.code-line:nth-child(1) {
  width: 80%;
  animation-delay: 0s;
}
.code-line:nth-child(2) {
  width: 60%;
  animation-delay: 0.5s;
}
.code-line:nth-child(3) {
  width: 90%;
  animation-delay: 1s;
}
.code-line:nth-child(4) {
  width: 70%;
  animation-delay: 1.5s;
}

/* New code viewer styles */
.code-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.code-lang {
  font-weight: 700;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
}

.code-actions .code-copy {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.code-actions .code-copy:hover {
  color: var(--text-primary);
  transform: translateY(-2px);
}

.code-view {
  /* prevent accidental horizontal overflow (wrap long lines instead) */
  width: 100%;
  height: calc(100% - 44px);
  overflow-x: hidden; /* explicitly remove horizontal scrollbar */
  overflow-y: auto; /* keep vertical scrolling for long code */
  background: transparent !important;
  border-radius: 12px;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono",
    "Segoe UI Mono", monospace;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.45;
  box-sizing: border-box;
  /* make code-view visually transparent to show parent background */
  border: none !important;
  box-shadow: none !important;
  scroll-behavior: smooth;
}

.code-view code {
  /* allow long lines to wrap and break to avoid horizontal scroll */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: block;
}

.code-view.reveal {
  animation: fadeInUp 360ms ease both;
}

/* simple language tinting */
.code-view.language-html {
  color: #e6e6ff;
}
.code-view.language-css {
  color: #cfe6ff;
}
.code-view.language-js {
  color: #ffe6c7;
}

@keyframes codeLine {
  0%,
  100% {
    opacity: 0.3;
    transform: translateX(0);
  }
  50% {
    opacity: 0.8;
    transform: translateX(10px);
  }
}

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

/* ===== Section Styles ===== */
section {
  height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  position: relative;
}

/* ===== Scroll Snap ===== */
/* Enable vertical snap on the root scroll container (html/body). This
   makes each full-height <section> snap into place when scrolling. */
html,
body {
  /* mandatory gives a firm snap; change to 'proximity' if you prefer softer behavior */
  scroll-snap-type: y mandatory;
  -webkit-scroll-snap-type: y mandatory;
}

/* Each section should align to the start of the scrollport and always stop there */
section {
  scroll-snap-align: start;
  -webkit-scroll-snap-align: start;
  scroll-snap-stop: always;
}

/* Center the .container inside each section (vertical + horizontal centering) */
section > .container {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.section-title {
  font-size: 2.5rem;
  text-align: center;
  margin-bottom: 3rem;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== About Section ===== */
.about-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
  width: 100%;
  max-width: 100%;
}

.about-description {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.8;
}

/* About text entrance: top paragraph slides down, bottom paragraph slides up */
.about-text .about-description {
  opacity: 0;
  transform: translateY(20px);
  transition: transform 0.6s cubic-bezier(0.2, 0.9, 0.2, 1), opacity 0.42s ease;
}
.about-text .about-description:first-child {
  /* the top paragraph should come from above */
  transform: translateY(-20px);
}

section#about.in-view .about-text .about-description {
  opacity: 1;
  transform: translateY(0);
}

/* add a small stagger so the top paragraph appears slightly before the bottom */
section#about.in-view .about-text .about-description:first-child {
  transition-delay: 0.06s;
}
section#about.in-view .about-text .about-description:last-child {
  transition-delay: 0.18s;
}

@media (prefers-reduced-motion: reduce) {
  .about-text .about-description {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
}

.about-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

/* ===== Section enter/exit animations ===== */
/* Each direct child of a section will get .section-item class via JS */
.section-item {
  opacity: 0;
  transform: translateY(30px) scale(0.95);
  /* Use a CSS variable for stagger delay (set by JS). Falls back to 0ms. */
  transition: transform 0.8s var(--ease-out-expo), opacity 0.6s ease-out;
  transition-delay: var(--stagger, 0ms);
}

/* When a section becomes active, its items assemble into place */
section.in-view .section-item {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* When a section leaves, items fade/slide up and shrink slightly */
section.out-of-view .section-item {
  opacity: 0;
  transform: translateY(-25px) scale(0.96);
  transition: transform 0.6s var(--ease-in-out-quart), opacity 0.4s ease-in;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .section-item {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
}

.stat-card {
  background: var(--card-bg);
  padding: 2rem 1rem;
  border-radius: 15px;
  text-align: center;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.5s var(--ease-out-expo);
}

/* stat-card entrance: default hint for browsers and reduced-motion support */
.stat-card {
  will-change: transform, opacity;
}

/* If JS hasn't toggled inline styles yet, ensure stat-cards start slightly to the right */
@media (prefers-reduced-motion: no-preference) {
  .stat-card {
    opacity: 0;
    transform: translateX(40px) scale(0.9);
  }
}

@media (prefers-reduced-motion: reduce) {
  .stat-card {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
}

.stat-card:hover {
  transform: translateY(-12px) scale(1.05);
  box-shadow: 0 15px 40px rgba(102, 126, 234, 0.4);
}

.stat-card:active {
  transform: translateY(-6px) scale(1.02);
  transition: all 0.2s var(--ease-smooth);
}

.stat-card i {
  font-size: 2.5rem;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
}

.stat-number {
  font-size: 2rem;
  font-weight: bold;
  margin: 0.5rem 0;
}

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

/* ===== Projects Section - Expanding Cards ===== */
.projects {
  background: rgba(15, 23, 42, 0.3);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6rem 0;
  position: relative;
  width: 100%;
  overflow-x: hidden;
}

.projects .container {
  width: 100%;
  max-width: 1400px;
  box-sizing: border-box;
}

.expanding-cards {
  display: flex;
  width: 100%;
  max-width: 100%;
  height: 600px;
  min-height: 600px;
  gap: 15px;
  overflow: hidden;
  border-radius: 10px;
  box-sizing: border-box;
}

.project-option {
  position: relative;
  overflow: visible;
  margin: 0;
  background: var(--optionBackground);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  cursor: pointer;
  border-radius: 20px;
  transition: all 0.8s var(--ease-out-expo),
    box-shadow 0.6s var(--ease-out-quint);
  will-change: transform, opacity;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  outline: none;
  flex: 0 0 75px;
}

.project-option:focus-visible {
  border-color: var(--primary-color);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), 0 0 0 3px rgba(99, 102, 241, 0.3);
}

.project-option.active {
  /* expand active card to take remaining space */
  flex: 1 1 auto;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.6),
    0 10px 30px rgba(102, 126, 234, 0.2);
  cursor: default;
  transform: scale(1.01);
}

.project-option.active .project-shadow {
  box-shadow: inset 0 -180px 140px -90px rgba(0, 0, 0, 0.9);
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.95) 0%,
    rgba(0, 0, 0, 0.3) 50%,
    transparent 100%
  );
}

.project-option.active .project-label {
  /* inset the label so content stays clear of card edges and controls */
  bottom: 30px;
  left: 30px;
  right: 30px;
  padding: 0;
  width: auto;
}

.project-option.active .project-info {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0.3s;
}

/* When a card is in the process of closing, animate project-info back down
   before the card collapses. The JS will add/remove the `closing` class to
   allow this reverse animation to play smoothly. */
.project-option.closing .project-info {
  opacity: 0;
  transform: translateY(30px);
  /* start immediately when closing */
  transition: all 0.48s cubic-bezier(0.4, 0, 0.2, 1);
  transition-delay: 0s !important;
}

.project-option.active .project-main {
  font-size: 2.8rem;
  margin-bottom: 8px;
}

.project-shadow {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  top: 0;
  height: 100%;
  width: 100%;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.85) 0%,
    rgba(0, 0, 0, 0.2) 40%,
    transparent 70%
  );
  transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: inset 0 -80px 80px -40px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  /* ensure overlays respect parent rounding */
  border-radius: inherit;
}

.project-label {
  display: flex;
  position: absolute;
  bottom: 0;
  left: 0;
  height: 100%;
  width: 100%;
  padding: 20px;
  align-items: flex-end;
  transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 2;
  border-radius: inherit;
}

/* Vertical title for collapsed (inactive) cards */
.project-option::before {
  content: attr(data-title);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-90deg);
  transform-origin: center;
  color: rgba(255, 255, 255, 0.95);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.6px;
  white-space: nowrap;
  text-shadow: 1px 1px 6px rgba(0, 0, 0, 0.7);
  z-index: 4;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.45s ease, transform 0.45s ease;
}

/* hide vertical title for active (expanded) card */
.project-option.active::before {
  opacity: 0;
  transform: translate(-50%, -50%) rotate(-90deg) scale(0.8);
  visibility: hidden;
}

/* make the icon circle remain visible for collapsed tabs near bottom */
.project-option:not(.active) .project-icon-wrapper {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 44px;
  max-width: 44px;
  height: 44px;
  font-size: 1.1rem;
  background: rgba(0, 0, 0, 0.35);
}

.project-icon-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 60px;
  max-width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  font-size: 1.8rem;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

.project-option.active .project-icon-wrapper {
  min-width: 80px;
  max-width: 80px;
  height: 80px;
  font-size: 2.2rem;
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1);
  animation: iconPulse 2s ease-in-out infinite;
}

@keyframes iconPulse {
  0%,
  100% {
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
  }
  50% {
    box-shadow: 0 8px 30px rgba(255, 255, 255, 0.2);
  }
}

.project-info {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-left: 20px;
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  max-width: calc(100% - 120px);
  flex: 1;
  overflow: hidden;
}

.project-main {
  color: white;
  font-size: 1.8rem;
  font-weight: 700;
  text-shadow: 2px 2px 15px rgba(0, 0, 0, 0.9), 0 0 30px rgba(0, 0, 0, 0.5);
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  line-height: 1.2;
  letter-spacing: -0.5px;
}

.project-sub {
  color: rgba(255, 255, 255, 0.95);
  font-size: 1.05rem;
  text-shadow: 1px 1px 8px rgba(0, 0, 0, 0.9);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-option.active .project-sub {
  -webkit-line-clamp: 5;
  line-clamp: 5;
}

.project-tech-mini {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.project-tech-mini span {
  background: rgba(99, 102, 241, 0.85);
  backdrop-filter: blur(10px);
  color: white;
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: all 0.4s var(--ease-out-quint);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.project-tech-mini span:hover {
  background: rgba(99, 102, 241, 1);
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.7);
}

.project-links-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.project-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: white;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 12px 26px;
  background: rgba(99, 102, 241, 0.9);
  backdrop-filter: blur(10px);
  border-radius: 30px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  transition: all 0.5s var(--ease-out-expo);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: hidden;
}

.project-link-btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.7s var(--ease-out-expo), height 0.7s var(--ease-out-expo);
  pointer-events: none;
}

.project-link-btn:hover::before {
  width: 320px;
  height: 320px;
}

.project-link-btn:hover {
  background: rgba(99, 102, 241, 1);
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 8px 30px rgba(99, 102, 241, 0.7);
  border-color: rgba(255, 255, 255, 0.7);
}

.project-link-btn:active {
  transform: translateY(-1px) scale(0.98);
  transition: all 0.15s var(--ease-smooth);
}

.project-link-btn i {
  position: relative;
  z-index: 1;
}

.project-link-btn-secondary {
  background: rgba(139, 92, 246, 0.9);
}

.project-link-btn-secondary:hover {
  background: rgba(139, 92, 246, 1);
  box-shadow: 0 6px 25px rgba(139, 92, 246, 0.6);
}

/* ===== Skills Section (3D Card Stack) ===== */
.skills {
  padding: 4rem 0;
  background: linear-gradient(
    180deg,
    rgba(15, 23, 42, 0.15),
    rgba(15, 23, 42, 0.08)
  );
}

.skills-carousel {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px 20px;
  box-sizing: border-box;
  overflow-x: hidden;
}

.carousel-track {
  position: relative;
  width: 100%;
  max-width: 450px;
  height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 2000px;
  overflow: visible;
}

/* 3D Card Stack */
.card {
  position: absolute;
  width: 100%;
  max-width: 400px;
  height: 480px;
  /* Glassmorphism for dark theme: translucent surface + blur */
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.04),
    rgba(255, 255, 255, 0.02)
  );
  border-radius: 18px;
  padding: 34px 28px;
  box-shadow: 0 12px 30px rgba(2, 6, 23, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
  transform-origin: center center;
  transition: all 0.8s var(--ease-out-expo), opacity 0.6s ease-out,
    transform 0.8s var(--ease-out-expo);
  will-change: transform, opacity;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
}

/* Skill icon at top of card */
.card::before {
  content: attr(data-icon);
  font-size: 4rem;
  margin-bottom: 10px;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.1));
}

/* Light theme card adjustments */
[data-theme="light"] .card {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.9),
    rgba(255, 255, 255, 0.8)
  );
  color: var(--text-primary);
  border: 1px solid rgba(16, 24, 40, 0.06);
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.06);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.card h3 {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
}

.card p {
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 1rem;
  text-align: center;
  margin: 0;
  flex-grow: 1;
}

/* Ensure paragraph text becomes dark in light theme */
[data-theme="light"] .card p {
  color: rgba(17, 24, 39, 0.85);
}

/* Active card - front and center */
.card.active {
  transform: translateZ(0px) translateX(0) translateY(0) scale(1.02)
    rotateY(0deg);
  z-index: 50;
  opacity: 1;
  filter: blur(0px) brightness(1);
  box-shadow: 0 4px 40px rgba(102, 126, 234, 0.3), 0 5px 10px rgba(0, 0, 0, 0.4);
}

/* Previous card - to the left */
.card.prev {
  transform: translateX(-320px) translateZ(-180px) translateY(10px) scale(0.72)
    rotateY(18deg);
  z-index: 30;
  opacity: 0.65;
  filter: blur(2px) brightness(0.7);
}

/* Next card - to the right */
.card.next {
  transform: translateX(320px) translateZ(-150px) translateY(10px) scale(0.72)
    rotateY(-18deg);
  z-index: 30;
  opacity: 0.55;
  filter: blur(2px) brightness(0.7);
}

/* Far left - hidden behind previous */
.card.far-left {
  transform: translateX(-550px) translateZ(-300px) translateY(20px) scale(0.45)
    rotateY(35deg);
  z-index: 10;
  opacity: 0.15;
  filter: blur(6px) brightness(0.6);
  pointer-events: none;
}

/* Far right - hidden behind next */
.card.far-right {
  transform: translateX(550px) translateZ(-300px) translateY(20px) scale(0.45)
    rotateY(-35deg);
  z-index: 10;
  opacity: 0.15;
  filter: blur(6px) brightness(0.6);
  pointer-events: none;
}

/* Hover effect on non-active cards */
.card:not(.active):hover {
  transform: translateX(calc(var(--tx, 0) * 1px))
    translateZ(calc(var(--tz, -120) * 1px))
    translateY(calc(var(--ty, 15) * 1px - 10px)) scale(0.88)
    rotateY(calc(var(--ry, 0) * 1deg));
  opacity: 0.9;
  box-shadow: 0 15px 40px rgba(99, 102, 241, 0.2), 0 6px 18px rgba(0, 0, 0, 0.4);
  transition: all 0.5s var(--ease-out-quint);
}

/* Skill level indicator */
.card[data-level]::after {
  content: attr(data-level);
  top: 20px;
  right: 20px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== Contact Section ===== */
.contact {
  background: rgba(15, 23, 42, 0.3);
}

.contact-content {
  max-width: 800px;
  margin: 0 auto;
}

.contact-text {
  font-size: 1.2rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 3rem;
  line-height: 1.8;
}

/* Contact section: animated entrances for title, board, form and info */
.section-title {
  /* ensure titles generally animate from above when entering */
  opacity: 1; /* keep default elsewhere; specific section rules below will control contact */
}

/* Contact-specific initial states */
#contact .section-title {
  opacity: 0;
  transform: translateY(-30px) scale(0.95);
  transition: transform 0.8s var(--ease-out-expo), opacity 0.6s ease-out;
}
#contact .section-title.enter,
section#contact.in-view .section-title {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.contact-canvas-wrapper {
  opacity: 0;
  transform: translateX(50px) scale(0.95);
  transition: transform 0.9s var(--ease-out-expo), opacity 0.7s ease-out 0.1s;
  will-change: transform, opacity;
  position: relative;
  width: 100%;
  height: 500px;
  background: var(--card-bg);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
  /* spacing below the canvas so textarea/info don't stick to it */
  margin-bottom: 1.5rem;
}

.contact-canvas-wrapper.enter,
section#contact.in-view .contact-canvas-wrapper {
  opacity: 1;
  transform: translateX(0) scale(1);
}

.contact-canvas-wrapper canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
}

.contact-textarea-wrapper {
  opacity: 0;
  transform: translateX(-50px) scale(0.95);
  transition: transform 0.9s var(--ease-out-expo), opacity 0.7s ease-out 0.15s;
  will-change: transform, opacity;
  position: relative;
  width: 100%;
  height: auto;
  min-height: 88px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 20px;
  overflow: hidden;
  padding: 8px;
  margin-bottom: 1.25rem;
}

.contact-textarea-wrapper.enter,
section#contact.in-view .contact-textarea-wrapper {
  opacity: 1;
  transform: translateX(0) scale(1);
}

.contact-textarea-wrapper > div {
  width: 100%;
  height: 100%;
}

.contact-textarea-wrapper textarea {
  width: 100%;
  height: 100%;
  padding: 1rem 1.25rem;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  resize: none;
  transition: all 0.3s ease;
}

.contact-textarea-wrapper textarea:focus {
  outline: none;
}

.contact-info {
  opacity: 0;
  transform: translateY(40px) scale(0.96);
  transition: transform 0.9s var(--ease-out-expo), opacity 0.7s ease-out 0.2s;
  will-change: transform, opacity;
  grid-column: 1 / -1;
}

.contact-info.enter,
section#contact.in-view .contact-info {
  opacity: 1;
  transform: translateY(0) scale(1);
}

@media (prefers-reduced-motion: reduce) {
  #contact .section-title,
  .contact-canvas-wrapper,
  .contact-textarea-wrapper,
  .contact-info {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
}

.contact-methods {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
}

.contact-method {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
  background: var(--card-bg);
  border-radius: 15px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.5s var(--ease-out-expo);
}

.contact-method:hover {
  transform: translateY(-8px) scale(1.03);
  box-shadow: 0 15px 35px rgba(102, 126, 234, 0.4);
  border-color: var(--primary-color);
}

.contact-method:active {
  transform: translateY(-4px) scale(1.01);
  transition: all 0.2s var(--ease-smooth);
}

.contact-method i {
  font-size: 2rem;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.contact-method h4 {
  margin-bottom: 0.3rem;
}

.contact-method p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ===== Vertical Side Navigation ===== */
.side-nav {
  position: fixed;
  left: 3rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  z-index: 980;
  pointer-events: none;
}

.side-nav .emblem {
  pointer-events: auto;
  font-size: 0.75rem;
  letter-spacing: 0.4em;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  color: var(--secondary-color);
}

.nav-track {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 1.5rem 1rem;
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  position: relative;
}

.nav-connector {
  width: 2px;
  height: var(--connector-length);
  /* keep a faint base line, visible fill is handled by ::before */
  background: linear-gradient(
    180deg,
    rgba(99, 102, 241, 0.08),
    rgba(236, 72, 153, 0.03)
  );
  transition: opacity 0.3s ease;
  opacity: 0.6;
  margin: 0.35rem 0;
  position: relative;
  overflow: hidden;
}

.nav-connector.active {
  opacity: 1;
}

.nav-connector::before {
  /* animated fill that grows from top to bottom */
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: var(--fill, 0%);
  background: linear-gradient(
    180deg,
    rgba(255, 59, 59, 0.95),
    rgba(255, 138, 0, 0.6)
  );
  transition: height 450ms cubic-bezier(0.22, 0.9, 0.31, 1);
}
/* connector fill is controlled by --fill; .active class is kept for backwards compatibility but does not directly set ::before height */

.nav-node {
  position: relative;
  width: 18px; /* hit area preserved for accessibility */
  height: 18px;
  border-radius: 999px;
  /* reserve border space to avoid layout shift when toggling active state */
  box-sizing: border-box;
  border: 2px solid transparent;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}

.nav-node::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 20px);
  top: 50%;
  /* keep the label on a single line and slightly closer to the node when hidden */
  transform: translateY(-50%) translateX(-8px);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-size: 0.72rem;
  /* reduce letter-spacing so multi-word labels like "О себе" keep clear word gaps */
  letter-spacing: 0.12em;
  white-space: nowrap;
  text-transform: uppercase;
  background: rgba(15, 23, 42, 0.8);
  color: rgba(226, 232, 240, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.nav-node:hover::after,
.nav-node.active::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.nav-node::before {
  /* the visible dot for both inactive and active states */
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  transition: transform 0.25s ease, background 0.25s ease, width 0.25s ease,
    height 0.25s ease;
  transform: scale(1);
}

.nav-node.active {
  /* when active, show the ring and subtle background */
  border-color: rgba(255, 59, 59, 0.9);
  background: rgba(255, 59, 59, 0.06);
  transform: scale(1.12);
}
.nav-node.active::before {
  transform: scale(1.8);
  background: var(--nav-active-color);
}

/* ===== Scroll to Top Button ===== */
.scroll-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 52px;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.04),
    rgba(255, 255, 255, 0.02)
  );
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  font-size: 1.25rem;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.8);
  transition: transform 0.5s var(--ease-out-expo), opacity 0.4s ease,
    visibility 0.4s, box-shadow 0.4s var(--ease-out-quint);
  z-index: 999;
  box-shadow: 0 8px 30px rgba(2, 6, 23, 0.6);
  backdrop-filter: blur(8px) saturate(120%);
  -webkit-backdrop-filter: blur(8px) saturate(120%);
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.scroll-to-top:hover {
  transform: translateY(-8px) scale(1.1);
  box-shadow: 0 18px 50px rgba(99, 102, 241, 0.4),
    0 8px 24px rgba(2, 6, 23, 0.7);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0.04)
  );
}

.scroll-to-top:active {
  transform: translateY(-4px) scale(0.95);
  transition: all 0.15s var(--ease-smooth);
}

/* Respect theme: make glass lighter in light theme */
[data-theme="light"] .scroll-to-top {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.03),
    rgba(255, 255, 255, 0.01)
  );
  border: 1px solid rgba(17, 24, 39, 0.06);
  color: var(--text-primary);
  box-shadow: 0 6px 18px rgba(17, 24, 39, 0.06);
}

/* ===== Mobile Navigation Animation ===== */
@keyframes navLinkFade {
  from {
    opacity: 0;
    transform: translateX(50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ===== Utility Classes ===== */
.text-gradient {
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.glass-wrap {
  position: absolute;
  inset: 0; /* fill the hero area */
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none; /* decorative */
  z-index: 0;
  overflow: hidden; /* prevent overflow on small screens */
  padding: 0 10px; /* add padding to prevent edge cutoff */
  touch-action: none; /* prevent any touch interactions */
  user-select: none; /* prevent text selection */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.glass-title {
  font-family: "Boldonse", system-ui;
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: clamp(-8px, -0.5vw, -4px); /* responsive letter-spacing */
  /* slightly reduced: smaller on all viewports so it doesn't dominate */
  font-size: clamp(40px, 12vw, 150px); /* reduced from 50px/15vw for mobile */
  position: relative;
  z-index: 0; /* sit behind hero content */
  color: rgba(255, 255, 255, 0.06); /* faint background word */
  -webkit-text-fill-color: rgba(255, 255, 255, 0.06);
  background-image: none;
  mix-blend-mode: normal;
  user-select: none;
  pointer-events: none;
  text-transform: uppercase;
  white-space: nowrap; /* prevent wrapping */
  max-width: 100%; /* constrain to container */
  transform-origin: center center;
  text-align: center; /* ensure centered alignment */
  width: fit-content; /* prevent taking full width */
  margin: 0 auto; /* center horizontally */
}

/* soft colored glow behind the letters */
.glass-title::after {
  /* very subtle soft glow behind letters to give depth */
  content: "";
  position: absolute;
  inset: -6px -12px -18px -12px;
  background: radial-gradient(
    closest-side at 50% 50%,
    rgba(255, 255, 255, 0.02),
    transparent 20%
  );
  filter: blur(30px);
  z-index: -1;
  pointer-events: none;
}

/* faint grain for organic look (on wrapper) */
.glass-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(
    rgba(255, 255, 255, 0.02) 1px,
    transparent 1px
  );
  background-size: 3px 3px;
  opacity: 0.6;
  mix-blend-mode: screen;
  pointer-events: none;
}

/* Light theme: make the decorative background title visible on light backgrounds */
[data-theme="light"] .glass-title {
  color: rgba(17, 24, 39, 0.08);
  -webkit-text-fill-color: rgba(17, 24, 39, 0.08);
}

[data-theme="light"] .glass-title::after {
  background: radial-gradient(
    closest-side at 50% 50%,
    rgba(17, 24, 39, 0.02),
    transparent 20%
  );
}

[data-theme="light"] .glass-wrap::after {
  /* reduce light grain so it doesn't wash out text */
  background-image: radial-gradient(
    rgba(17, 24, 39, 0.01) 1px,
    transparent 1px
  );
  mix-blend-mode: multiply;
}

/* ===== Performance Optimizations ===== */
/* Only use will-change during animations, not statically */
.gradient-orb {
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Optimize animations for better performance */
@media (prefers-reduced-motion: no-preference) {
  .card:hover,
  .project-option:hover {
    will-change: transform;
  }

  .card:not(:hover),
  .project-option:not(:hover) {
    will-change: auto;
  }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.key {
  /* reduced to be less overpowering */
  font-size: 10vw;
  display: inline-block;
  letter-spacing: -0.8vw;
  transition: transform 0.2s, background-color 0.15s, color 0.15s;
}

@keyframes pressDown1 {
  30%,
  40%,
  100% {
    transform: translateY(0);
  }
  35% {
    transform: translateY(10px);
  }
}

@keyframes pressDown2 {
  70%,
  80%,
  100% {
    transform: translateY(0);
  }
  75% {
    transform: translateY(10px);
  }
}

@keyframes pressDown3 {
  30%,
  40%,
  100% {
    transform: translateY(0);
  }
  35% {
    transform: translateY(10px);
  }
}

@keyframes pressDown4 {
  40%,
  50%,
  100% {
    transform: translateY(0);
  }
  45% {
    transform: translateY(10px);
  }
}

@keyframes pressDown5 {
  20%,
  30%,
  100% {
    transform: translateY(0);
  }
  25% {
    transform: translateY(10px);
  }
}

@keyframes pressDown6 {
  60%,
  70%,
  100% {
    transform: translateY(0);
  }
  65% {
    transform: translateY(10px);
  }
}

@keyframes pressDown7 {
  10%,
  20%,
  100% {
    transform: translateY(0);
  }
  15% {
    transform: translateY(10px);
  }
}

@keyframes pressDown8 {
  35%,
  45%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(10px);
  }
}

@keyframes pressDown9 {
  20%,
  30%,
  100% {
    transform: translateY(0);
  }
  25% {
    transform: translateY(10px);
  }
}

.key:nth-child(1) {
  animation: pressDown1 2s infinite;
}

.key:nth-child(2) {
  animation: pressDown2 3s infinite;
}

.key:nth-child(3) {
  animation: pressDown3 4s infinite;
}

.key:nth-child(4) {
  animation: pressDown4 2.5s infinite;
}

.key:nth-child(5) {
  animation: pressDown5 2.5s infinite;
}

.key:nth-child(6) {
  animation: pressDown6 3.5s infinite;
}

.key:nth-child(7) {
  animation: pressDown7 2.2s infinite;
}

.key:nth-child(8) {
  animation: pressDown8 3.2s infinite;
}

.key:nth-child(9) {
  animation: pressDown9 2.5s infinite;
}

/* utility class to force a single key press visual (overrides running animation briefly) */
.key-press {
  transform: translateY(10px);
  transition: transform 0.12s ease;
}

/* ===== Typewriter Effect ===== */
.typewriter-text {
  position: relative;
  display: inline-block;
  font-family: "Courier New", Courier, monospace;
}

.typewriter-content {
  display: inline;
}

.typewriter-cursor {
  display: inline-block;
  animation: blink 1s step-end infinite;
  font-weight: 100;
  font-size: 1.2em;
  margin-left: 2px;
}

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

.typewriter-text.typing-complete .typewriter-cursor {
  animation: none;
  opacity: 0;
}

/* Contact Section Typewriter */
.contact .typewriter-text {
  font-family: inherit;
  font-size: 1.1rem;
  line-height: 1.8;
}

/* Code Animation Typewriter */
.code-view.typing code {
  display: inline;
}

.code-view.typing::after {
  content: "|";
  display: inline-block;
  animation: blink 1s step-end infinite;
  margin-left: 2px;
  color: var(--primary-color);
}

/* --- Custom thin scrollbar (WebKit browsers + Firefox) --- */
/* Apply thin scrollbar globally and provide nicer thumb styling */
html {
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent; /* Firefox thumb + track */
}

/* WebKit-based browsers */
html::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

html::-webkit-scrollbar-track {
  background: transparent;
}

html::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  border: 2px solid transparent; /* keep thumb from covering content when semi-transparent */
  background-clip: padding-box;
}

html::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* Ensure important scrollable containers look consistent */
.board-list,
.container,
pre,
.code-view {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

.board-list::-webkit-scrollbar,
.container::-webkit-scrollbar,
pre::-webkit-scrollbar,
.code-view::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.board-list::-webkit-scrollbar-thumb,
.container::-webkit-scrollbar-thumb,
pre::-webkit-scrollbar-thumb,
.code-view::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* Light theme overrides */
[data-theme="light"] {
  scrollbar-color: rgba(17, 24, 39, 0.12) transparent;
}

[data-theme="light"]::-webkit-scrollbar-thumb,
[data-theme="light"] .board-list::-webkit-scrollbar-thumb,
[data-theme="light"] .container::-webkit-scrollbar-thumb,
[data-theme="light"] pre::-webkit-scrollbar-thumb,
[data-theme="light"] .code-view::-webkit-scrollbar-thumb {
  background: rgba(17, 24, 39, 0.08);
}

/* Accessibility: increase hit-target on hover/focus for users who need it */
@media (hover: hover) {
  html::-webkit-scrollbar-thumb:hover {
    width: 10px;
  }
}

/* ===== RESPONSIVE DESIGN - TABLET & MOBILE ===== */
/* Tablet (portrait and landscape) */
@media (max-width: 1024px) {
  :root {
    --connector-length: 48px;
  }

  /* Fix overflow by making container fully responsive */
  * {
    max-width: 100%;
  }

  .container {
    max-width: 100%;
    padding: 0 24px;
    width: 100%;
    box-sizing: border-box;
  }

  body {
    overflow-x: hidden !important;
    width: 100%;
    max-width: 100vw;
  }

  html {
    overflow-x: hidden !important;
    width: 100%;
    max-width: 100vw;
  }

  section {
    overflow-x: hidden !important;
    width: 100%;
  }

  .hero,
  .about,
  .projects,
  .skills,
  .contact {
    overflow-x: hidden !important;
    width: 100%;
  }

  /* Theme Toggle - smaller and better positioned */
  .theme-toggle {
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    font-size: 1rem;
  }

  /* Side Navigation - hide on tablet/mobile to prevent overflow */
  .side-nav {
    display: none;
  }

  /* Hero Section - stack vertically */
  .hero .container {
    grid-template-columns: 1fr;
    gap: 2rem;
    padding: 2rem 24px;
  }

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

  .hero-subtitle {
    font-size: 1.1rem;
  }

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

  .btn {
    padding: 0.7rem 1.5rem;
    font-size: 0.95rem;
  }

  .social-links {
    justify-content: center;
  }

  .social-icon {
    width: 45px;
    height: 45px;
    font-size: 1.3rem;
  }

  /* Hero Image/Code Animation */
  .hero-image {
    order: -1;
  }

  .code-animation {
    width: 100%;
    height: 320px;
    max-width: 100%;
  }

  /* About Section */
  .about-content {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .about-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .stat-card {
    padding: 1.5rem 1rem;
  }

  .section-title {
    font-size: 2rem;
    margin-bottom: 2rem;
  }

  /* Projects Section - Expanding Cards */
  .expanding-cards {
    flex-direction: column;
    height: auto;
    min-height: 500px;
    gap: 12px;
  }

  .project-option {
    flex: 0 0 80px;
    width: 100%;
  }

  .project-option.active {
    flex: 0 0 400px;
  }

  .project-option::before {
    transform: translate(-50%, -50%) rotate(0deg);
    font-size: 0.85rem;
  }

  .project-option.active::before {
    transform: translate(-50%, -50%) rotate(0deg) scale(0.8);
  }

  /* Skills Carousel */
  .skills-carousel {
    padding: 20px 10px;
  }

  .carousel-track {
    max-width: 100%;
    height: 450px;
  }

  .card {
    max-width: 90%;
    height: 420px;
    padding: 28px 24px;
  }

  .card::before {
    font-size: 3.5rem;
  }

  .card h3 {
    font-size: 1.8rem;
  }

  .card p {
    font-size: 0.95rem;
  }

  /* Adjust card positions for tablet */
  .card.prev {
    transform: translateX(-200px) translateZ(-120px) translateY(8px) scale(0.75)
      rotateY(15deg);
  }

  .card.next {
    transform: translateX(200px) translateZ(-120px) translateY(8px) scale(0.75)
      rotateY(-15deg);
  }

  .card.far-left,
  .card.far-right {
    opacity: 0;
    pointer-events: none;
  }

  /* Toast Notifications */
  .toast-container {
    top: 70px;
    right: 10px;
    left: 10px;
    max-width: 100%;
  }

  /* Gradient Orbs - smaller on tablet */
  .orb-1,
  .orb-2,
  .orb-3 {
    width: 350px;
    height: 350px;
  }
}

/* Mobile (large phones) */
@media (max-width: 768px) {
  :root {
    --connector-length: 40px;
  }

  .container {
    padding: 0 16px;
    max-width: 100%;
    width: 100%;
  }

  /* Ensure no horizontal overflow */
  * {
    max-width: 100%;
  }

  html,
  body {
    overflow-x: hidden !important;
    width: 100%;
    max-width: 100vw;
    position: relative;
  }

  section {
    overflow-x: hidden !important;
    width: 100%;
    max-width: 100vw;
  }

  .hero,
  .about,
  .projects,
  .skills,
  .contact {
    overflow-x: hidden !important;
    width: 100%;
    max-width: 100vw;
  }

  /* Theme Toggle */
  .theme-toggle {
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    font-size: 0.95rem;
  }

  /* Hero Section */
  .hero {
    min-height: 100vh;
    padding: 80px 0 40px;
  }

  .hero .container {
    gap: 1.5rem;
    padding: 1.5rem 16px;
  }

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

  .hero-title {
    font-size: 1.8rem;
    line-height: 1.3;
  }

  .hero-subtitle {
    font-size: 1rem;
  }

  .hero-buttons {
    flex-direction: column;
    gap: 0.8rem;
    width: 100%;
  }

  .btn {
    width: 100%;
    padding: 0.8rem 1.2rem;
    text-align: center;
    justify-content: center;
  }

  .social-links {
    gap: 0.8rem;
  }

  .social-icon {
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
  }

  /* Hero Image/Code Animation */
  .code-animation {
    height: 280px;
  }

  .code-line {
    height: 16px;
    margin: 1.2rem 0;
  }

  /* Section Titles */
  .section-title {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
  }

  /* About Section */
  .about-description {
    font-size: 1rem;
    margin-bottom: 1.2rem;
  }

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

  .stat-card {
    padding: 1.5rem 1rem;
  }

  .stat-card i {
    font-size: 2rem;
  }

  .stat-number {
    font-size: 1.8rem;
  }

  .stat-label {
    font-size: 0.85rem;
  }

  /* Projects Section */
  .projects {
    padding: 4rem 0;
  }

  .expanding-cards {
    min-height: 400px;
  }

  .project-option {
    flex: 0 0 70px;
  }

  .project-option.active {
    flex: 0 0 380px;
  }

  .project-option::before {
    font-size: 0.8rem;
    letter-spacing: 0.4px;
  }

  .project-option.active .project-label {
    bottom: 20px;
    left: 20px;
    right: 20px;
  }

  .project-icon-wrapper {
    min-width: 50px;
    max-width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }

  .project-option.active .project-icon-wrapper {
    min-width: 70px;
    max-width: 70px;
    height: 70px;
    font-size: 2rem;
  }

  .project-option:not(.active) .project-icon-wrapper {
    min-width: 38px;
    max-width: 38px;
    height: 38px;
    font-size: 1rem;
    bottom: 10px;
  }

  .project-info {
    margin-left: 15px;
    gap: 8px;
    max-width: calc(100% - 100px);
  }

  .project-main {
    font-size: 1.5rem;
  }

  .project-option.active .project-main {
    font-size: 2rem;
  }

  .project-sub {
    font-size: 0.9rem;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  .project-option.active .project-sub {
    -webkit-line-clamp: 4;
    line-clamp: 4;
  }

  .project-tech-mini {
    gap: 6px;
    margin-top: 6px;
  }

  .project-tech-mini span {
    padding: 5px 12px;
    font-size: 0.75rem;
  }

  .project-links-group {
    gap: 8px;
    margin-top: 8px;
  }

  .project-link-btn {
    padding: 10px 20px;
    font-size: 0.85rem;
    gap: 6px;
  }

  /* Skills Section */
  .skills-carousel {
    flex-direction: column;
    gap: 15px;
    padding: 20px 10px;
  }

  .carousel-track {
    height: 420px;
    max-width: 75%;
  }

  .card {
    max-width: 95%;
    height: 400px;
    padding: 24px 20px;
  }

  .card::before {
    font-size: 3rem;
    margin-bottom: 8px;
  }

  .card h3 {
    font-size: 1.6rem;
  }

  .card p {
    font-size: 0.9rem;
  }

  /* Simplify 3D transforms for mobile */
  .card.active {
    transform: translateZ(0) scale(1);
  }

  .card.prev {
    transform: translateX(-120px) translateZ(-80px) scale(0.7) rotateY(10deg);
    opacity: 0.5;
  }

  .card.next {
    transform: translateX(120px) translateZ(-80px) scale(0.7) rotateY(-10deg);
    opacity: 0.5;
  }

  .card.far-left,
  .card.far-right {
    transform: scale(0.3);
    opacity: 0;
  }

  /* Carousel Controls */
  .carousel-btn {
    width: 45px;
    height: 45px;
    font-size: 1.2rem;
  }

  /* Toast Notifications */
  .toast {
    padding: 12px 16px;
    font-size: 0.9rem;
  }

  .toast-icon {
    font-size: 1.3rem;
  }

  .toast-title {
    font-size: 0.9rem;
  }

  .toast-message {
    font-size: 0.85rem;
  }

  /* Gradient Orbs - smaller on mobile */
  .orb-1 {
    width: 300px;
    height: 300px;
  }

  .orb-2 {
    width: 250px;
    height: 250px;
  }

  .orb-3 {
    width: 280px;
    height: 280px;
  }

  /* Code Toolbar */
  .code-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .code-actions {
    gap: 8px;
  }

  /* Key Animation */
  .key {
    font-size: 12vw;
    letter-spacing: -1vw;
  }

  /* Glass Wrap - reduce size on mobile */
  .glass-wrap {
    padding: 0 8px;
  }

  .glass-title {
    font-size: clamp(35px, 10vw, 120px);
    letter-spacing: clamp(-10px, -0.8vw, -3px);
  }
}

@media (max-width: 600px) {
  .stat-card {
    display: grid;
    grid-template-columns: 56px 1fr;
    grid-template-rows: auto auto;
    gap: 6px 12px;
    align-items: center;
    padding: 1rem 0.8rem;
    text-align: right; /* make right column content right-aligned */
  }

  .stat-card i {
    grid-column: 1;
    grid-row: 1 / span 2; /* span both rows vertically */
    justify-self: center;
    align-self: center;
    font-size: 2rem;
    margin-bottom: 0;
  }

  .stat-number {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: start;
    font-size: 1.6rem;
    margin: 0;
  }

  .stat-label {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
    align-self: end;
    font-size: 0.85rem;
    margin: 0;
    color: var(--text-secondary);
  }

  /* Shift the collapsed icon to the left edge on phones */
  .project-option:not(.active) .project-icon-wrapper {
    left: 12px !important;
    transform: none !important;
    bottom: 12px !important;
  }

  /* Add left padding to label area so text doesn't overlap the icon */
  .project-option .project-label {
    padding-left: 70px;
  }

  .contact-canvas-wrapper {
    height: 240px; /* reduce from 500px to better fit phones */
    border-radius: 12px;
    margin-bottom: 1rem;
    transform: none !important; /* avoid off-screen transforms during entrance */
  }

  .contact-canvas-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover; /* if applicable for canvas drawing scaling */
  }

  .contact-text {
    font-size: 1rem; /* slightly smaller on phones */
    line-height: 1.6;
    margin-bottom: 2rem;
  }

  .contact-methods {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    align-items: stretch;
  }

  /* Make first two items share a row */
  .contact-methods > .contact-method:nth-child(1),
  .contact-methods > .contact-method:nth-child(2) {
    flex: 1 1 48%;
    max-width: 48%;
  }

  /* Make the third item span full width and distribute its inner content evenly */
  .contact-methods > .contact-method:nth-child(3) {
    flex-basis: 100%;
    max-width: 100%;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
  }

  /* Glass Wrap - further reduce on small screens */
  .glass-wrap {
    padding: 0 5px;
  }

  .glass-title {
    font-size: clamp(30px, 9vw, 90px);
    letter-spacing: clamp(-12px, -1vw, -2px);
    transform: scale(0.75);
  }
}

/* Mobile (small phones) */
@media (max-width: 480px) {
  .container {
    padding: 0 12px;
  }

  /* Theme Toggle */
  .theme-toggle {
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
  }

  /* Hero Section */
  .hero-title {
    font-size: 1.6rem;
  }

  .hero-subtitle {
    font-size: 0.95rem;
  }

  .btn {
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
  }

  .social-icon {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }

  /* Code Animation */
  .code-animation {
    height: 240px;
    padding: 0.8rem;
  }

  .code-line {
    height: 14px;
    margin: 1rem 0;
  }

  /* Section Titles */
  .section-title {
    font-size: 1.6rem;
    margin-bottom: 1.2rem;
  }

  /* About Section */
  .about-description {
    font-size: 0.95rem;
  }

  .stat-card {
    padding: 1.2rem 0.8rem;
  }

  .stat-card i {
    font-size: 1.8rem;
  }

  .stat-number {
    font-size: 1.6rem;
  }

  .stat-label {
    font-size: 0.8rem;
  }

  /* Projects Section */
  .project-option {
    flex: 0 0 60px;
  }

  .project-option.active {
    flex: 0 0 350px;
  }

  .project-option::before {
    font-size: 0.75rem;
  }

  .project-option.active .project-label {
    bottom: 16px;
    left: 16px;
    right: 16px;
  }

  .project-icon-wrapper {
    min-width: 44px;
    max-width: 44px;
    height: 44px;
    font-size: 1.3rem;
  }

  .project-option.active .project-icon-wrapper {
    min-width: 60px;
    max-width: 60px;
    height: 60px;
    font-size: 1.8rem;
  }

  .project-option:not(.active) .project-icon-wrapper {
    min-width: 34px;
    max-width: 34px;
    height: 34px;
    font-size: 0.9rem;
    bottom: 8px;
  }

  .project-info {
    margin-left: 12px;
    max-width: calc(100% - 80px);
  }

  .project-main {
    font-size: 1.3rem;
  }

  .project-option.active .project-main {
    font-size: 1.7rem;
  }

  .project-sub {
    font-size: 0.85rem;
  }

  .project-tech-mini span {
    padding: 4px 10px;
    font-size: 0.7rem;
  }

  .project-link-btn {
    padding: 8px 16px;
    font-size: 0.8rem;
  }

  /* Skills Section */
  .carousel-track {
    height: 380px;
  }

  .card {
    max-width: 100%;
    height: 360px;
    padding: 20px 16px;
  }

  .card::before {
    font-size: 2.5rem;
  }

  .card h3 {
    font-size: 1.4rem;
  }

  .card p {
    font-size: 0.85rem;
    line-height: 1.6;
  }

  /* Further simplify card transforms */
  .card.prev {
    transform: translateX(-175px) scale(0.65) rotateY(30deg);
  }

  .card.next {
    transform: translateX(175px) scale(0.65) rotateY(-30deg);
  }

  /* Carousel Controls */
  .carousel-btn {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }

  /* Toast */
  .toast-container {
    top: 60px;
  }

  /* Gradient Orbs - even smaller */
  .orb-1 {
    width: 250px;
    height: 250px;
  }

  .orb-2 {
    width: 200px;
    height: 200px;
  }

  .orb-3 {
    width: 230px;
    height: 230px;
  }

  /* Key Animation */
  .key {
    font-size: 14vw;
    letter-spacing: -1.2vw;
  }

  /* Glass Wrap - smallest screens */
  .glass-wrap {
    padding: 0 4px;
  }

  .glass-title {
    font-size: clamp(25px, 8vw, 90px);
    letter-spacing: clamp(-14px, -1.2vw, -2px);
    transform: scale(0.85); /* slight scale down */
  }
}

/* Extra small devices (very small phones) */
@media (max-width: 375px) {
  .hero-title {
    font-size: 1.4rem;
  }

  .section-title {
    font-size: 1.4rem;
  }

  .card {
    height: 340px;
  }

  .project-option.active {
    flex: 0 0 320px;
  }

  /* Glass Wrap - extra small screens */
  .glass-wrap {
    padding: 0 2px;
  }

  .glass-title {
    font-size: clamp(22px, 7vw, 80px);
    letter-spacing: clamp(-16px, -1.5vw, -1.5px);
    transform: scale(0.9);
  }
}

/* Landscape mode adjustments for mobile */
@media (max-width: 926px) and (orientation: landscape) {
  .hero {
    min-height: auto;
    padding: 60px 0 40px;
  }

  section {
    min-height: 100vh;
    height: auto;
  }

  .expanding-cards {
    flex-direction: row;
    height: 400px;
  }

  .project-option {
    flex: 0 0 60px;
  }

  .project-option.active {
    flex: 1 1 auto;
  }

  .carousel-track {
    height: 380px;
  }

  .card {
    height: 350px;
  }

  /* Glass Wrap - scale down in landscape mode */
  .glass-wrap {
    padding: 0 15px;
  }

  .glass-title {
    font-size: clamp(30px, 8vh, 100px); /* use vh instead of vw for landscape */
    letter-spacing: clamp(-10px, -0.8vh, -2px);
    transform: scale(0.85);
  }
}

/* Ultra-narrow screens (Galaxy Fold, etc.) */
@media (max-width: 320px) {
  .glass-wrap {
    padding: 0 2px;
  }

  .glass-title {
    font-size: clamp(18px, 6vw, 70px);
    letter-spacing: clamp(-18px, -2vw, -1px);
    transform: scale(0.85);
  }

  .hero-title {
    font-size: 1.25rem;
  }

  .hero-subtitle {
    font-size: 0.85rem;
  }
}
