@import 'tailwindcss';

@theme {
  --color-*: initial;
}

@variant dark (&:where(.dark, .dark *));

@layer base {
  :root {
    /* Light mode colors */
    --bg-primary: 250 250 250;
    --bg-secondary: 240 240 243;
    --bg-tertiary: 228 228 231;
    --text-primary: 24 24 27;
    --text-secondary: 63 63 70;
    --text-muted: 113 113 122;
    --border-primary: 212 212 216;
    --border-subtle: 228 228 231;

    /* Desaturated cyberpunk for light mode - darker for readability */
    --neon-pink: #7a3d52;
    --neon-cyan: #2d5a63;
    --neon-purple: #5a4670;
    --neon-magenta: #7a3d6b;
  }

  .dark {
    /* Dark mode colors - INDUSTRIAL */
    --bg-primary: 24 24 27;
    --bg-secondary: 15 23 42;
    --bg-tertiary: 30 41 59;
    --text-primary: 241 245 249;
    --text-secondary: 203 213 225;
    --text-muted: 100 116 139;
    --border-primary: 71 85 105;
    --border-subtle: 30 41 59;

    /* Desaturated cyberpunk for dark mode */
    --neon-pink: #8a5568;
    --neon-cyan: #4d7580;
    --neon-purple: #6a5685;
    --neon-magenta: #8a5579;
  }
}

@layer utilities {
  /* Scrollbar hiding utility */
  .scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  .scrollbar-hide::-webkit-scrollbar {
    display: none;
  }

  /* Industrial/Terminal aesthetic utilities */
  .grid-bg {
    background-image:
      linear-gradient(rgba(100, 116, 139, 0.1) 1px, transparent 1px),
      linear-gradient(90deg, rgba(100, 116, 139, 0.1) 1px, transparent 1px);
    background-size: 20px 20px;
  }

  /* Noise texture */
  .noise-bg {
    background-image: url('/noise.svg');
    opacity: 0.03;
    pointer-events: none;
  }

  /* Scanline effect */
  .scanline {
    background: linear-gradient(0deg, transparent 0%, rgba(6, 182, 212, 0.1) 50%, transparent 100%);
    background-size: 100% 3px;
    pointer-events: none;
  }

  .scanline::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
      to bottom,
      transparent 0%,
      rgba(6, 182, 212, 0.05) 50%,
      transparent 100%
    );
    animation: scanline 8s linear infinite;
    pointer-events: none;
  }

  /* CRT screen curvature effect */
  .crt-effect {
    animation: flicker 0.15s infinite;
  }

  /* Glitch text effect */
  .glitch-text {
    position: relative;
  }

  .glitch-text::before,
  .glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
  }

  .glitch-text.active::before {
    color: #06b6d4;
    animation: glitch-1 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
    transform: translate(-2px, -2px);
    opacity: 0.8;
  }

  .glitch-text.active::after {
    color: #10b981;
    animation: glitch-2 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
    transform: translate(2px, 2px);
    opacity: 0.8;
  }

  /* Consolidated keyframes to avoid duplication */
  @keyframes glitch-1 {
    0%,
    100% {
      clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
      transform: translate(0);
    }
    20% {
      clip-path: polygon(0 15%, 100% 15%, 100% 65%, 0 65%);
    }
    40% {
      clip-path: polygon(0 30%, 100% 30%, 100% 70%, 0 70%);
    }
    60% {
      clip-path: polygon(0 5%, 100% 5%, 100% 60%, 0 60%);
    }
    80% {
      clip-path: polygon(0 25%, 100% 25%, 100% 40%, 0 40%);
    }
  }

  @keyframes glitch-2 {
    0%,
    100% {
      clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
      transform: translate(0);
    }
    20% {
      clip-path: polygon(0 70%, 100% 70%, 100% 95%, 0 95%);
    }
    40% {
      clip-path: polygon(0 40%, 100% 40%, 100% 85%, 0 85%);
    }
    60% {
      clip-path: polygon(0 60%, 100% 60%, 100% 100%, 0 100%);
    }
    80% {
      clip-path: polygon(0 50%, 100% 50%, 100% 90%, 0 90%);
    }
  }

  /* Grayscale filter with instant toggle */
  .grayscale {
    filter: grayscale(100%);
  }

  .grayscale-0 {
    filter: grayscale(0%);
  }

  /* Cyberpunk Glitch Effect for Button */
  .glitch-btn {
    position: relative;
    animation: glitch 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  }

  .glitch-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
  }

  .glitch-layer:first-of-type {
    animation: glitch-1 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
    color: rgb(6 182 212); /* cyan-500 */
    transform: translate(-2px, 0);
    clip-path: polygon(0 0, 100% 0, 100% 35%, 0 35%);
  }

  .glitch-layer:last-of-type {
    animation: glitch-2 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
    color: rgb(16 185 129); /* emerald-500 */
    transform: translate(2px, 0);
    clip-path: polygon(0 65%, 100% 65%, 100% 100%, 0 100%);
  }

  /* Border Pulse Animation */
  .border-pulse {
    animation: pulse-border 2s ease-in-out infinite;
  }

  /* Screen Flicker Effect */
  body.screen-flicker {
    animation: flicker 150ms ease-in-out;
  }

  body.screen-flicker::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(6, 182, 212, 0.1);
    pointer-events: none;
    z-index: 9999;
    animation: flicker 150ms ease-in-out;
  }

  /* CRT Noise Texture */
  @supports (filter: url('#noise')) {
    .noise-bg {
      filter: url('#noise');
    }
  }

  /* SCP-style subtle flicker hover */
  @keyframes scp-flicker {
    0%,
    100% {
      border-color: rgb(71 85 105);
      box-shadow: 0 0 0 rgba(90, 139, 149, 0);
      transform: translate(0, 0);
    }
    20% {
      border-color: var(--neon-cyan);
      box-shadow: 0 0 3px rgba(90, 139, 149, 0.3);
      transform: translate(-0.5px, 0);
    }
    40% {
      border-color: rgb(71 85 105);
      box-shadow: 0 0 0 rgba(90, 139, 149, 0);
      transform: translate(0, 0);
    }
    60% {
      border-color: var(--neon-cyan);
      box-shadow: 0 0 2px rgba(90, 139, 149, 0.2);
      transform: translate(0.5px, 0);
    }
  }

  .cyber-glitch-hover {
    transition: all 0.15s ease;
    position: relative;
  }

  .cyber-glitch-hover:hover {
    animation: scp-flicker 150ms ease-in-out 3;
    border-color: var(--neon-cyan) !important;
    box-shadow:
      0 1px 4px rgba(90, 139, 149, 0.15),
      inset 0 0 8px rgba(90, 139, 149, 0.05);
  }

  /* Navbar hide on scroll */
  .navbar-hidden {
    transform: translateY(-100%);
    transition: transform 0.3s ease-in-out;
  }

  .navbar-visible {
    transform: translateY(0);
    transition: transform 0.3s ease-in-out;
  }

  /* Cyberpunk neon glow on focus - 80s style */
  .cyber-focus:focus {
    outline: none;
    box-shadow:
      0 0 10px var(--neon-cyan),
      0 0 20px rgba(0, 255, 255, 0.5),
      inset 0 0 10px rgba(0, 255, 255, 0.1);
    border-color: var(--neon-cyan);
  }

  .cyber-focus-pink:focus {
    outline: none;
    box-shadow:
      0 0 10px var(--neon-pink),
      0 0 20px rgba(255, 0, 128, 0.5),
      inset 0 0 10px rgba(255, 0, 128, 0.1);
    border-color: var(--neon-pink);
  }

  /* Cyberpunk Prose Styling */
  .cyberpunk-prose {
    color: rgb(212 212 216);
  }

  .cyberpunk-prose h1,
  .cyberpunk-prose h2,
  .cyberpunk-prose h3 {
    color: var(--neon-cyan);
    font-family: var(--font-jetbrains-mono);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: -0.025em;
  }

  .cyberpunk-prose h1 {
    font-size: 2.25rem;
    margin-bottom: 2rem;
    margin-top: 3rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--neon-cyan);
  }

  .cyberpunk-prose h2 {
    font-size: 1.875rem;
    margin-bottom: 1.5rem;
    margin-top: 2.5rem;
  }

  .cyberpunk-prose h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    margin-top: 2rem;
  }

  .cyberpunk-prose p {
    color: rgb(212 212 216);
    line-height: 1.625;
    margin-bottom: 1.5rem;
    font-size: 1.125rem;
  }

  .cyberpunk-prose a {
    color: var(--neon-magenta);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
  }

  .cyberpunk-prose a:hover {
    color: var(--neon-pink);
  }

  .cyberpunk-prose ul,
  .cyberpunk-prose ol {
    color: rgb(212 212 216);
    padding-left: 1.5rem;
    margin-bottom: 1.5rem;
  }

  .cyberpunk-prose ul > * + *,
  .cyberpunk-prose ol > * + * {
    margin-top: 0.5rem;
  }

  .cyberpunk-prose li {
    font-size: 1.125rem;
  }

  .cyberpunk-prose blockquote {
    border-left: 4px solid var(--neon-magenta);
    padding-left: 1.5rem;
    font-style: italic;
    color: rgb(161 161 170);
    background-color: #000;
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 2rem;
    position: relative;
    box-shadow:
      -4px 0 15px rgba(155, 90, 142, 0.3),
      inset 0 0 20px rgba(155, 90, 142, 0.05);
  }

  .cyberpunk-prose blockquote::before {
    content: '"';
    position: absolute;
    top: -0.5rem;
    left: 0.5rem;
    font-size: 3.75rem;
    color: var(--neon-magenta);
    opacity: 0.3;
    font-family: monospace;
  }

  .cyberpunk-prose code {
    color: var(--neon-cyan);
    background-color: #000;
    padding: 0.125rem 0.5rem;
    font-size: 0.875rem;
    font-family: monospace;
    border: 2px solid var(--neon-cyan);
    box-shadow: 0 0 8px rgba(90, 139, 149, 0.3);
    text-shadow: 0 0 6px rgba(90, 139, 149, 0.6);
  }

  .cyberpunk-prose pre {
    background-color: #000;
    border: 4px solid var(--neon-purple);
    padding: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 2rem;
    overflow-x: auto;
    box-shadow:
      0 0 25px rgba(123, 101, 147, 0.6),
      inset 0 0 25px rgba(123, 101, 147, 0.1);
  }

  .cyberpunk-prose pre code {
    background-color: transparent;
    border: 0;
    padding: 0;
  }

  .cyberpunk-prose img {
    margin-top: 2rem;
    margin-bottom: 2rem;
    border: 4px solid var(--neon-pink);
    box-shadow: 0 0 20px rgba(155, 90, 110, 0.5);
  }

  .cyberpunk-prose hr {
    border-color: rgb(39 39 42);
    border-top-width: 2px;
    margin-top: 3rem;
    margin-bottom: 3rem;
  }
}
