/* ============================================
   VinylWave Design System
   Brand: Riff & Ritual
   Version: 1.0.0
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  /* Core palette */
  --vinyl-black: #1a1612;
  --vinyl-dark: #0f0d0b;
  --vinyl-charcoal: #2a2621;
  --vinyl-gray: #3a3530;
  --lime-primary: #BFFF00;
  --lime-secondary: #A3D900;
  --lime-tertiary: #8ABF00;
  --orange-vintage: #FF8C42;
  --gold-retro: #FFD700;

  /* Text */
  --text-white: #F5F5F5;
  --text-primary: #E8E8E8;
  --text-secondary: #B8B8B8;
  --text-tertiary: #808080;

  /* Typography */
  --font-poster: 'Bebas Neue', 'Oswald', 'Impact', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Courier Prime', 'Courier New', monospace;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-24: 96px;

  /* Radius */
  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);
  --shadow-lime: 0 0 20px rgba(191, 255, 0, 0.15);
  --shadow-lime-strong: 0 0 30px rgba(191, 255, 0, 0.25);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;

  /* Z-index scale */
  --z-base: 1;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--vinyl-black);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
}

/* --- Vinyl Noise Texture Overlay --- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  background-repeat: repeat;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

/* --- Keyframe Animations --- */
@keyframes vinyl-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes groove-ripple {
  0% {
    box-shadow: 0 0 0 0 rgba(191, 255, 0, 0.3);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(191, 255, 0, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(191, 255, 0, 0);
  }
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 12px rgba(191, 255, 0, 0.2);
  }
  50% {
    box-shadow: 0 0 24px rgba(191, 255, 0, 0.4);
  }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes checkmark-draw {
  0% { stroke-dashoffset: 48; }
  100% { stroke-dashoffset: 0; }
}

@keyframes checkmark-circle {
  0% { stroke-dashoffset: 240; }
  100% { stroke-dashoffset: 0; }
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-poster);
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.1;
  color: var(--text-white);
}

h1 {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  letter-spacing: 0.06em;
}

h2 {
  font-size: clamp(1.75rem, 4vw, 3rem);
  letter-spacing: 0.05em;
}

h3 {
  font-size: clamp(1.25rem, 3vw, 2rem);
  letter-spacing: 0.04em;
}

h4 {
  font-size: 1.25rem;
}

h5 {
  font-size: 1rem;
}

h6 {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

p {
  margin-bottom: var(--space-4);
  color: var(--text-secondary);
}

a {
  color: var(--lime-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--lime-secondary);
}

a:focus-visible {
  outline: 2px solid var(--lime-primary);
  outline-offset: 2px;
  border-radius: 2px;
}

strong {
  color: var(--text-white);
  font-weight: 600;
}

small {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

code, .mono {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-poster);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  line-height: 1.4;
  position: relative;
  overflow: hidden;
}

.btn:focus-visible {
  outline: 2px solid var(--lime-primary);
  outline-offset: 2px;
  box-shadow: var(--shadow-lime);
}

.btn-primary {
  background: var(--lime-primary);
  color: var(--vinyl-dark);
  border-color: var(--lime-primary);
}

.btn-primary:hover {
  background: var(--lime-secondary);
  border-color: var(--lime-secondary);
  box-shadow: var(--shadow-lime);
  transform: translateY(-1px);
}

.btn-primary:active {
  background: var(--lime-tertiary);
  transform: translateY(0);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--vinyl-gray);
}

.btn-secondary:hover {
  border-color: var(--lime-primary);
  color: var(--lime-primary);
  background: rgba(191, 255, 0, 0.05);
}

.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border-color: transparent;
  padding: var(--space-2) var(--space-4);
}

.btn-ghost:hover {
  color: var(--lime-primary);
  background: rgba(191, 255, 0, 0.05);
}

.btn-orange {
  background: var(--orange-vintage);
  color: var(--vinyl-dark);
  border-color: var(--orange-vintage);
}

.btn-orange:hover {
  background: #ff9f5f;
  border-color: #ff9f5f;
  box-shadow: 0 0 20px rgba(255, 140, 66, 0.2);
  transform: translateY(-1px);
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: 1.125rem;
  border-radius: var(--radius-lg);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-full);
}

.btn-icon.btn-sm {
  width: 32px;
  height: 32px;
}

.btn-icon.btn-lg {
  width: 48px;
  height: 48px;
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* --- Cards --- */
.card {
  background: var(--vinyl-charcoal);
  border: 1px solid var(--vinyl-gray);
  border-radius: var(--radius);
  padding: var(--space-6);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-radial-gradient(
    circle at center,
    transparent 0px,
    transparent 8px,
    rgba(191, 255, 0, 0.02) 8px,
    rgba(191, 255, 0, 0.02) 9px
  );
  opacity: 0;
  transition: opacity var(--transition-base);
  pointer-events: none;
}

.card:hover {
  border-color: rgba(191, 255, 0, 0.3);
  box-shadow: var(--shadow-lime);
  transform: translateY(-2px);
}

.card:hover::before {
  opacity: 1;
}

.card-flat {
  border: none;
  box-shadow: none;
}

.card-flat:hover {
  transform: none;
  box-shadow: none;
}

/* --- Forms & Inputs --- */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--vinyl-dark);
  border: 1px solid var(--vinyl-gray);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  appearance: none;
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: var(--text-tertiary);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--lime-primary);
  box-shadow: 0 0 0 3px rgba(191, 255, 0, 0.15);
}

.form-input::placeholder {
  color: var(--text-tertiary);
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23808080' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  padding-right: var(--space-10);
  cursor: pointer;
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

/* --- Navigation --- */
.nav {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.nav-link {
  font-family: var(--font-poster);
  font-size: 0.9375rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  text-decoration: none;
  padding: var(--space-2) var(--space-1);
  position: relative;
  transition: color var(--transition-fast);
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--lime-primary);
  transition: width var(--transition-base);
}

.nav-link:hover,
.nav-link.active {
  color: var(--lime-primary);
}

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

.nav-link:focus-visible {
  outline: 2px solid var(--lime-primary);
  outline-offset: 4px;
  border-radius: 2px;
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  line-height: 1.6;
}

.badge-lime {
  background: rgba(191, 255, 0, 0.12);
  color: var(--lime-primary);
  border: 1px solid rgba(191, 255, 0, 0.2);
}

.badge-orange {
  background: rgba(255, 140, 66, 0.12);
  color: var(--orange-vintage);
  border: 1px solid rgba(255, 140, 66, 0.2);
}

.badge-gold {
  background: rgba(255, 215, 0, 0.12);
  color: var(--gold-retro);
  border: 1px solid rgba(255, 215, 0, 0.2);
}

.badge-gray {
  background: rgba(128, 128, 128, 0.12);
  color: var(--text-secondary);
  border: 1px solid rgba(128, 128, 128, 0.2);
}

.badge-solid {
  background: var(--lime-primary);
  color: var(--vinyl-dark);
  border: none;
  font-weight: 600;
}

/* --- Tables --- */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  border: 1px solid var(--vinyl-gray);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

thead {
  background: var(--vinyl-charcoal);
}

th {
  font-family: var(--font-poster);
  font-size: 0.8125rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--lime-primary);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  white-space: nowrap;
  border-bottom: 2px solid var(--vinyl-gray);
}

td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid rgba(58, 53, 48, 0.5);
  color: var(--text-secondary);
}

tbody tr {
  transition: background var(--transition-fast);
}

tbody tr:hover {
  background: rgba(191, 255, 0, 0.03);
}

tbody tr:last-child td {
  border-bottom: none;
}

/* --- Chart Containers --- */
.chart-container {
  background: var(--vinyl-charcoal);
  border: 1px solid var(--vinyl-gray);
  border-radius: var(--radius);
  padding: var(--space-6);
  position: relative;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.chart-title {
  font-family: var(--font-poster);
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.chart-value {
  font-family: var(--font-poster);
  font-size: 2rem;
  color: var(--lime-primary);
  line-height: 1;
}

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

::-webkit-scrollbar-track {
  background: var(--vinyl-dark);
}

::-webkit-scrollbar-thumb {
  background: var(--vinyl-gray);
  border-radius: 3px;
}

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

/* --- Selection --- */
::selection {
  background: rgba(191, 255, 0, 0.25);
  color: var(--text-white);
}

/* --- Focus visible global --- */
:focus-visible {
  outline: 2px solid var(--lime-primary);
  outline-offset: 2px;
}

/* --- Responsive Breakpoints --- */

/* Tablet: 768px */
@media (max-width: 768px) {
  :root {
    --space-6: 20px;
    --space-8: 24px;
    --space-12: 32px;
    --space-16: 48px;
    --space-24: 64px;
  }

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

  h2 {
    font-size: clamp(1.5rem, 6vw, 2.25rem);
  }

  .card {
    padding: var(--space-4);
  }
}

/* Mobile: 480px */
@media (max-width: 480px) {
  :root {
    --space-6: 16px;
    --space-8: 20px;
    --space-12: 24px;
    --space-16: 32px;
    --space-24: 48px;
  }

  body {
    font-size: 0.9375rem;
  }

  .btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: 1rem;
  }
}

/* --- Reduced Motion --- */
@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;
  }

  .card:hover {
    transform: none;
  }

  .btn-primary:hover,
  .btn-orange:hover {
    transform: none;
  }
}

/* --- Utility: Vinyl disc --- */
.vinyl-disc {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    var(--vinyl-dark) 0deg,
    var(--vinyl-charcoal) 30deg,
    var(--vinyl-dark) 60deg,
    var(--vinyl-charcoal) 90deg,
    var(--vinyl-dark) 120deg,
    var(--vinyl-charcoal) 150deg,
    var(--vinyl-dark) 180deg,
    var(--vinyl-charcoal) 210deg,
    var(--vinyl-dark) 240deg,
    var(--vinyl-charcoal) 270deg,
    var(--vinyl-dark) 300deg,
    var(--vinyl-charcoal) 330deg,
    var(--vinyl-dark) 360deg
  );
  position: relative;
  box-shadow:
    inset 0 0 30px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(0, 0, 0, 0.3);
}

.vinyl-disc::before {
  content: '';
  position: absolute;
  inset: 30%;
  border-radius: 50%;
  background: var(--vinyl-dark);
  border: 2px solid var(--vinyl-gray);
}

.vinyl-disc::after {
  content: '';
  position: absolute;
  inset: 44%;
  border-radius: 50%;
  background: var(--lime-primary);
  box-shadow: 0 0 10px rgba(191, 255, 0, 0.3);
}

.vinyl-disc .groove {
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  border: 1px solid rgba(191, 255, 0, 0.05);
}

.vinyl-disc .groove:nth-child(2) { inset: 12%; }
.vinyl-disc .groove:nth-child(3) { inset: 16%; }
.vinyl-disc .groove:nth-child(4) { inset: 20%; }
.vinyl-disc .groove:nth-child(5) { inset: 24%; }

/* --- Utility: Groove pattern background --- */
.groove-pattern {
  background-image: repeating-radial-gradient(
    circle at center,
    transparent 0px,
    transparent 24px,
    rgba(191, 255, 0, 0.02) 24px,
    rgba(191, 255, 0, 0.02) 25px
  );
}

/* --- Utility: Lime glow text --- */
.glow-text {
  text-shadow: 0 0 20px rgba(191, 255, 0, 0.3);
}
