@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  /* ===== Light mode (default) ===== */
  :root {
    --ink-950: 255 255 255;
    --ink-900: 249 250 251;
    --ink-800: 243 244 246;
    --ink-700: 229 231 235;
    --ink-600: 209 213 219;
    --ink-500: 156 163 175;
    --ink-400: 107 114 128;
    --ink-300: 75 85 99;
    --ink-200: 55 65 81;
    --ink-100: 31 41 55;
    --ink-50:  17 24 39;

    --accent: 180 83 9;
    --accent-light: 217 119 6;
    --accent-dark: 146 64 14;
  }

  /* ===== Dark mode ===== */
  .dark {
    --ink-950: 8 8 12;
    --ink-900: 17 17 23;
    --ink-800: 26 26 35;
    --ink-700: 34 34 48;
    --ink-600: 42 42 56;
    --ink-500: 63 63 80;
    --ink-400: 92 92 110;
    --ink-300: 152 152 168;
    --ink-200: 192 192 204;
    --ink-100: 237 237 240;
    --ink-50:  248 248 250;

    --accent: 217 119 6;
    --accent-light: 245 158 11;
    --accent-dark: 180 83 9;
  }

  html {
    scroll-behavior: smooth;
  }

  body {
    @apply bg-ink-950 text-ink-100 font-sans antialiased;
    background-image:
      radial-gradient(ellipse 80% 50% at 50% -20%, rgb(var(--accent) / 0.04), transparent);
  }

  ::selection {
    @apply bg-accent/30;
    color: rgb(var(--ink-50));
  }
}

/* Scroll-triggered reveal */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered children animation */
.stagger > * {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.stagger.visible > *:nth-child(1) { transition-delay: 0.05s; opacity: 1; transform: translateY(0); }
.stagger.visible > *:nth-child(2) { transition-delay: 0.1s; opacity: 1; transform: translateY(0); }
.stagger.visible > *:nth-child(3) { transition-delay: 0.15s; opacity: 1; transform: translateY(0); }
.stagger.visible > *:nth-child(4) { transition-delay: 0.2s; opacity: 1; transform: translateY(0); }
.stagger.visible > *:nth-child(5) { transition-delay: 0.25s; opacity: 1; transform: translateY(0); }
.stagger.visible > *:nth-child(6) { transition-delay: 0.3s; opacity: 1; transform: translateY(0); }

/* Timeline */
.timeline-line {
  @apply absolute left-0 top-0 bottom-0 w-px;
  background: linear-gradient(to bottom, rgb(var(--accent)) 0%, rgb(var(--ink-600)) 40%, transparent 100%);
}

.timeline-item {
  @apply relative pl-8;
}

.timeline-item::before {
  content: '';
  @apply absolute w-2.5 h-2.5 rounded-full -left-[5px] top-2;
  border: 2px solid rgb(var(--accent));
  background: rgb(var(--ink-950));
  box-shadow: 0 0 8px rgb(var(--accent) / 0.3);
}

.timeline-item:first-child::before {
  background: rgb(var(--accent));
  box-shadow: 0 0 12px rgb(var(--accent) / 0.5);
}

.dark .timeline-item::before {
  box-shadow: 0 0 8px rgb(var(--accent) / 0.4);
}

.dark .timeline-item:first-child::before {
  box-shadow: 0 0 12px rgb(var(--accent) / 0.6);
}

/* Vulnerability accordion */
.vuln-details {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.3s ease-out,
              padding 0.3s ease-out;
}

.vuln-details.expanded {
  max-height: 250px;
  opacity: 1;
  padding: 1rem 1.25rem;
}

/* Grain texture overlay */
.grain::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.02;
  pointer-events: none;
  z-index: 9999;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.dark .grain::after {
  opacity: 0.012;
}

/* Card hover effect */
.card-hover {
  @apply transition-all duration-300;
}

.card-hover:hover {
  @apply border-ink-500 bg-ink-800/80;
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgb(0 0 0 / 0.06);
}

.dark .card-hover:hover {
  box-shadow: 0 8px 32px rgb(0 0 0 / 0.3);
}

/* Locale switcher buttons */
.locale-btn {
  @apply px-3 py-1.5 rounded-md text-sm font-medium transition-all duration-200
         text-ink-300 hover:text-ink-100 border border-transparent hover:border-ink-600;
}

.locale-btn.active {
  @apply text-accent border-accent/40 bg-accent/10;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: rgb(var(--ink-950));
}

::-webkit-scrollbar-thumb {
  background: rgb(var(--ink-600));
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgb(var(--ink-500));
}

/* Mobile */
@media (max-width: 640px) {
  .vuln-details.expanded {
    max-height: 400px;
  }

  .vuln-type-badge {
    display: none;
  }

  .vuln-component {
    display: none;
  }
}
