@layer reset, base, theme, components, utilities;

@layer reset {
  /* Box-sizing, margins, list styles reset, default focus states, scroll padding */
  *, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }
  
  html {
    scroll-behavior: smooth;
    scroll-padding-top: 5rem;
  }
  
  body {
    -webkit-font-smoothing: antialiased;
    line-height: 1.6;
    overflow-x: hidden;
  }

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

  a {
    color: inherit;
    text-decoration: none;
    transition: color 0.25s ease;
  }

  button, input, select, textarea {
    font: inherit;
    background: none;
    border: none;
    outline: none;
    color: inherit;
  }

  ul, ol {
    list-style: none;
  }
}

@layer base {
  :root {
    /* Fonts */
    --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Outfit', var(--font-sans);

    /* HSL Colors - Futuristic Cyber Dark theme */
    --color-bg-h: 240;
    --color-bg-s: 24%;
    --color-bg-l: 5%; /* Deep dark space bg */
    --color-bg: hsl(var(--color-bg-h), var(--color-bg-s), var(--color-bg-l));

    --color-surface-h: 240;
    --color-surface-s: 18%;
    --color-surface-l: 9%;
    --color-surface: hsl(var(--color-surface-h), var(--color-surface-s), var(--color-surface-l));
    
    --color-surface-hover: hsl(var(--color-surface-h), var(--color-surface-s), 14%);
    
    --color-text-primary: hsl(0, 0%, 96%);
    --color-text-secondary: hsl(240, 8%, 72%);
    --color-text-muted: hsl(240, 6%, 48%);

    /* Neon Accent Tones */
    --color-teal-h: 174;
    --color-teal-s: 90%;
    --color-teal-l: 45%;
    --color-teal: hsl(var(--color-teal-h), var(--color-teal-s), var(--color-teal-l));
    --color-teal-glow: hsla(var(--color-teal-h), var(--color-teal-s), var(--color-teal-l), 0.15);
    
    --color-purple-h: 268;
    --color-purple-s: 85%;
    --color-purple-l: 58%;
    --color-purple: hsl(var(--color-purple-h), var(--color-purple-s), var(--color-purple-l));
    --color-purple-glow: hsla(var(--color-purple-h), var(--color-purple-s), var(--color-purple-l), 0.15);

    --color-orange-h: 22;
    --color-orange-s: 95%;
    --color-orange-l: 52%;
    --color-orange: hsl(var(--color-orange-h), var(--color-orange-s), var(--color-orange-l));
    --color-orange-glow: hsla(var(--color-orange-h), var(--color-orange-s), var(--color-orange-l), 0.15);

    /* Glassmorphism system */
    --glass-bg: rgba(8, 8, 12, 0.45);
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-border-hover: rgba(255, 255, 255, 0.12);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    --glass-blur: blur(14px);

    /* Selection Colors */
    --color-selection-bg: hsla(var(--color-teal-h), var(--color-teal-s), var(--color-teal-l), 0.3);
    --color-selection-text: #ffffff;
  }

  body {
    background-color: var(--color-bg);
    color: var(--color-text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    position: relative;
  }

  /* Custom Selection styling */
  ::selection {
    background-color: var(--color-selection-bg);
    color: var(--color-selection-text);
  }

  /* Custom Scrollbars */
  ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
  }

  ::-webkit-scrollbar-track {
    background: var(--color-bg);
  }

  ::-webkit-scrollbar-thumb {
    background: var(--color-surface);
    border: 2px solid var(--color-bg);
    border-radius: 5px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
  }

  /* Accessibility Outline styles */
  :focus-visible {
    outline: 2px solid var(--color-teal);
    outline-offset: 4px;
  }
}

@layer theme {
  /* Layout constraints and global background assets */
  .container {
    width: 100%;
    max-width: 1200px;
    margin-inline: auto;
    padding-inline: 1.5rem;
  }

  /* Ambient background glows */
  .ambient-glows {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
  }

  .glow-1 {
    position: absolute;
    width: 50vw;
    height: 50vw;
    top: -10vw;
    right: -10vw;
    background: radial-gradient(circle, rgba(138, 43, 226, 0.15) 0%, transparent 70%);
    filter: blur(100px);
  }

  .glow-2 {
    position: absolute;
    width: 45vw;
    height: 45vw;
    bottom: -15vw;
    left: -10vw;
    background: radial-gradient(circle, rgba(0, 206, 209, 0.12) 0%, transparent 70%);
    filter: blur(100px);
  }

  /* Typography scales */
  h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.02em;
    color: var(--color-text-primary);
  }

  .text-gradient-purple {
    background: linear-gradient(135deg, #a78bfa 0%, #ec4899 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  .text-gradient-teal {
    background: linear-gradient(135deg, #2dd4bf 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }
}

@layer components {
  /* Premium Glass Cards */
  .glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
    transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  .glass-card:hover {
    border-color: var(--glass-border-hover);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.6), 0 0 15px 1px rgba(255, 255, 255, 0.02);
  }

  /* Interactive Buttons */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    min-block-size: 44px; /* Touch target size rule */
    transition: transform 0.2s ease, background 0.25s ease, box-shadow 0.25s ease;
  }

  .btn-primary {
    background: var(--color-teal);
    color: #ffffff;
    box-shadow: 0 4px 14px 0 var(--color-teal-glow);
  }

  .btn-primary:hover {
    background: hsl(var(--color-teal-h), var(--color-teal-s), 50%);
    box-shadow: 0 6px 20px 0 hsla(var(--color-teal-h), var(--color-teal-s), var(--color-teal-l), 0.35);
    transform: translateY(-2px);
  }

  .btn-primary:active {
    transform: translateY(0);
  }

  .btn-outline {
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--color-text-primary);
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: var(--glass-blur);
  }

  .btn-outline:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
  }

  /* Header & Navigation */
  .site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(8, 8, 12, 0.7);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--glass-border);
    padding-block: 1rem;
    transition: padding 0.3s ease;
  }

  .site-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .site-logo {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #ffffff;
  }

  .site-logo span {
    color: var(--color-teal);
  }

  .nav-menu {
    display: flex;
    gap: 1.5rem;
  }

  .nav-link {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    position: relative;
    padding-block: 0.25rem;
  }

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

  .nav-link::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0;
    height: 2px;
    background: var(--color-teal);
    transition: width 0.25s ease;
  }

  .nav-link:hover::after {
    width: 100%;
  }

  /* Hero Section */
  .hero-section {
    padding-block: clamp(4rem, 10vw, 8rem) clamp(3rem, 7vw, 6rem);
    text-align: center;
    position: relative;
  }

  .hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 99px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-teal);
    background: var(--color-teal-glow);
    border: 1px solid rgba(0, 206, 209, 0.25);
    margin-bottom: 1.5rem;
  }

  .hero-title {
    font-size: clamp(2.5rem, 6vw + 0.5rem, 4.5rem);
    max-width: 900px;
    margin-inline: auto;
    margin-bottom: 1.5rem;
    line-height: 1.15;
  }

  .hero-subtitle {
    font-size: clamp(1rem, 2.5vw + 0.5rem, 1.25rem);
    color: var(--color-text-secondary);
    max-width: 650px;
    margin-inline: auto;
    margin-bottom: 2.5rem;
    text-wrap: pretty;
  }

  .hero-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
  }

  /* Stats Section */
  .stats-section {
    padding-block: 2rem;
    border-block: 1px solid var(--glass-border);
    margin-bottom: 4rem;
  }

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

  .stat-card h3 {
    font-size: 2.5rem;
    font-family: var(--font-display);
    color: var(--color-teal);
    margin-bottom: 0.25rem;
  }

  .stat-card p {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  /* Projects Filter Tab UI */
  .projects-section {
    padding-block: 3rem;
  }

  .section-header {
    text-align: center;
    margin-bottom: 3rem;
  }

  .section-title {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    margin-bottom: 0.75rem;
  }

  .section-subtitle {
    color: var(--color-text-secondary);
    font-size: 1rem;
    max-width: 500px;
    margin-inline: auto;
  }

  .filter-tabs {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
    flex-wrap: wrap;
  }

  .filter-tab {
    padding: 0.5rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 99px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--color-text-secondary);
    min-block-size: 40px;
    transition: all 0.25s ease;
  }

  .filter-tab:hover {
    color: var(--color-text-primary);
    background: rgba(255, 255, 255, 0.08);
  }

  .filter-tab.active {
    background: var(--color-teal);
    border-color: var(--color-teal);
    color: #ffffff;
    box-shadow: 0 4px 12px 0 var(--color-teal-glow);
  }

  /* Project Grid Layout */
  .projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
  }

  /* Project Card */
  .project-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
    transform-style: preserve-3d;
    perspective: 1000px;
  }

  .project-card-image-wrapper {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border-bottom: 1px solid var(--glass-border);
  }

  .project-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
  }

  .project-card:hover .project-card-image {
    transform: scale(1.05);
  }

  .project-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    border-radius: 99px;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    z-index: 2;
  }

  .badge-crm {
    background: rgba(138, 43, 226, 0.25);
    border: 1px solid rgba(138, 43, 226, 0.4);
    color: #c084fc;
  }

  .badge-sports {
    background: rgba(249, 115, 22, 0.2);
    border: 1px solid rgba(249, 115, 22, 0.35);
    color: #fdba74;
  }

  .badge-team {
    background: rgba(0, 206, 209, 0.2);
    border: 1px solid rgba(0, 206, 209, 0.35);
    color: #2dd4bf;
  }

  .project-card-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
  }

  .project-title {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #ffffff;
  }

  .project-title i {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    transition: color 0.25s ease, transform 0.25s ease;
  }

  .project-card:hover .project-title i {
    color: var(--color-teal);
    transform: translate(2px, -2px);
  }

  .project-desc {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin-bottom: 1.5rem;
    flex-grow: 1;
    text-wrap: pretty;
  }

  .project-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
  }

  .project-tag {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.2rem 0.5rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    color: var(--color-text-secondary);
  }

  .project-link {
    align-self: flex-start;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-teal);
    display: flex;
    align-items: center;
    gap: 0.3rem;
  }

  .project-link:hover {
    color: hsl(var(--color-teal-h), var(--color-teal-s), 55%);
  }

  /* Skills & Tech Section */
  .skills-section {
    padding-block: 4rem;
  }

  .skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
  }

  .skill-card {
    padding: 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .skill-icon-wrapper {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--color-teal);
    margin-bottom: 1.25rem;
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.02);
  }

  .skill-card h4 {
    font-size: 1.15rem;
    margin-bottom: 0.75rem;
  }

  .skill-card p {
    font-size: 0.88rem;
    color: var(--color-text-secondary);
    text-wrap: pretty;
  }

  /* Contact / Footer Banner */
  .footer-banner {
    padding: 4rem 2rem;
    text-align: center;
    margin-block: 4rem;
    background: radial-gradient(circle at center, rgba(138, 43, 226, 0.07) 0%, transparent 80%), var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
  }

  .footer-banner h2 {
    font-size: 2.25rem;
    margin-bottom: 1rem;
  }

  .footer-banner p {
    color: var(--color-text-secondary);
    max-width: 500px;
    margin-inline: auto;
    margin-bottom: 2rem;
  }

  /* Site Footer */
  .site-footer {
    border-top: 1px solid var(--glass-border);
    padding-block: 2.5rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.9rem;
  }

  .site-footer p {
    margin-bottom: 0.5rem;
  }

  .site-footer a {
    color: var(--color-text-secondary);
  }

  .site-footer a:hover {
    color: var(--color-teal);
  }
}

@layer utilities {
  /* Utility and scroll animation behavior */
  .text-center { text-align: center; }
  .mt-1 { margin-top: 1rem; }
  .mt-2 { margin-top: 2rem; }
  
  .hide-card {
    display: none !important;
  }

  .show-card {
    animation: scaleUp 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  }

  @keyframes scaleUp {
    from {
      opacity: 0;
      transform: scale(0.92) translateY(10px);
    }
    to {
      opacity: 1;
      transform: scale(1) translateY(0);
    }
  }

  /* Optimize offscreen rendering with content-visibility */
  .optimize-render {
    content-visibility: auto;
    contain-intrinsic-size: auto 600px;
  }

  /* Starfield element container */
  .starfield-bg {
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
  }

  /* Touch screens optimization: larger tap targets */
  @media (pointer: coarse) {
    .btn, .filter-tab {
      min-block-size: 48px;
    }
    .nav-link {
      padding-block: 0.5rem;
    }
  }

  /* Media query for mobile responsive design */
  @media (max-width: 768px) {
    .nav-menu {
      display: none; /* simple responsive header for demo, or dropdown */
    }
    .hero-actions {
      flex-direction: column;
      align-items: stretch;
    }
    .btn {
      width: 100%;
    }
  }
}
