/* TrojanVoice Design System - CSS Framework */

/* ========================================
   DESIGN TOKENS & CSS VARIABLES
   ======================================== */

:root {
  /* Happenstance AI Inspired Color Palette */
  --tv-background: hsl(60, 33.2%, 98.2%);     /* Warm off-white background */
  --tv-foreground: hsl(240, 10%, 3.9%);       /* Deep charcoal text */
  --tv-primary: hsl(142.1, 76.2%, 36.3%);     /* Fresh green accent */
  --tv-primary-blue: hsl(217, 76.2%, 36.3%);  /* Fresh blue accent - same intensity as green */
  --tv-secondary: hsl(60, 17.2%, 94.3%);      /* Light neutral */
  
  /* Legacy color support */
  --tv-white: #ffffff;
  --tv-black: hsl(240, 10%, 3.9%);            /* Updated to foreground */
  --tv-gray-600: hsl(240, 5%, 34%);
  --tv-gray-500: hsl(240, 4%, 46%);
  --tv-gray-300: hsl(240, 5%, 84%);
  --tv-gray-100: hsl(240, 5%, 96%);
  --tv-gray-50: hsl(60, 17.2%, 94.3%);        /* Updated to secondary */
  
  /* Updated Accent Colors */
  --tv-teal-600: hsl(142.1, 76.2%, 36.3%);    /* Updated to primary green */
  --tv-teal-700: hsl(142.1, 76.2%, 30%);      /* Darker green */
  --tv-blue-600: hsl(217, 76.2%, 36.3%);      /* Primary blue */
  --tv-blue-700: hsl(217, 76.2%, 30%);        /* Darker blue */
  --tv-emerald-600: hsl(142.1, 76.2%, 36.3%); /* Same as primary */
  --tv-amber-600: hsl(43, 96%, 56%);
  --tv-red-600: hsl(0, 84%, 60%);
  --tv-purple-600: hsl(262, 83%, 58%);
  --tv-gray-800: hsl(240, 10%, 3.9%);         /* Updated to foreground */
  
  /* Rainbow Gradient Colors (preserved) */
  --tv-rainbow-red: #ff0000;
  --tv-rainbow-orange: #ff7f00;
  --tv-rainbow-yellow: #ffff00;
  --tv-rainbow-green: #00ff00;
  --tv-rainbow-blue: #0000ff;
  --tv-rainbow-violet: #8b00ff;
  
  /* Happenstance AI Font System */
  --tv-font-xs: 0.75rem;      /* 12px */
  --tv-font-sm: 0.875rem;     /* 14px */
  --tv-font-base: 1rem;       /* 16px */
  --tv-font-lg: 1.125rem;     /* 18px */
  --tv-font-xl: 1.25rem;      /* 20px */
  --tv-font-2xl: 1.5rem;      /* 24px */
  --tv-font-3xl: 1.875rem;    /* 30px */
  --tv-font-4xl: 2.25rem;     /* 36px */
  --tv-font-5xl: 3rem;        /* 48px */
  --tv-font-6xl: 3.75rem;     /* 60px */
  --tv-font-7xl: 4.5rem;      /* 72px */
  --tv-font-8xl: 6rem;        /* 96px */
  
  /* Font Weights (Happenstance AI system) */
  --tv-font-normal: 400;
  --tv-font-medium: 500;
  --tv-font-semibold: 600;
  --tv-font-bold: 700;
  --tv-font-extrabold: 800;
  
  /* Spacing System (4px base unit - consistent with Happenstance AI) */
  --tv-space-0: 0;
  --tv-space-px: 1px;
  --tv-space-0-5: 0.125rem;   /* 2px */
  --tv-space-1: 0.25rem;      /* 4px */
  --tv-space-1-5: 0.375rem;   /* 6px */
  --tv-space-2: 0.5rem;       /* 8px */
  --tv-space-2-5: 0.625rem;   /* 10px */
  --tv-space-3: 0.75rem;      /* 12px */
  --tv-space-3-5: 0.875rem;   /* 14px */
  --tv-space-4: 1rem;         /* 16px */
  --tv-space-5: 1.25rem;      /* 20px */
  --tv-space-6: 1.5rem;       /* 24px */
  --tv-space-7: 1.75rem;      /* 28px */
  --tv-space-8: 2rem;         /* 32px */
  --tv-space-9: 2.25rem;      /* 36px */
  --tv-space-10: 2.5rem;      /* 40px */
  --tv-space-11: 2.75rem;     /* 44px */
  --tv-space-12: 3rem;        /* 48px */
  --tv-space-14: 3.5rem;      /* 56px */
  --tv-space-16: 4rem;        /* 64px */
  --tv-space-20: 5rem;        /* 80px */
  --tv-space-24: 6rem;        /* 96px */
  --tv-space-28: 7rem;        /* 112px */
  --tv-space-32: 8rem;        /* 128px */
  
  /* Border Radius */
  --tv-radius-sm: 0.25rem;  /* 4px */
  --tv-radius: 0.5rem;      /* 8px */
  --tv-radius-lg: 0.75rem;  /* 12px */
  --tv-radius-xl: 1rem;     /* 16px */
  
  /* Shadows */
  --tv-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --tv-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --tv-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --tv-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --tv-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  /* Typography - Happenstance AI System Fonts */
  --tv-font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --tv-font-family-mono: ui-monospace, SFMono-Regular, "SF Mono", Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --tv-font-family-serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  
  /* Line Heights */
  --tv-leading-none: 1;
  --tv-leading-tight: 1.25;
  --tv-leading-snug: 1.375;
  --tv-leading-normal: 1.5;
  --tv-leading-relaxed: 1.625;
  --tv-leading-loose: 2;
  
  /* Animation Timing */
  --tv-duration-fast: 0.15s;
  --tv-duration-normal: 0.3s;
  --tv-duration-slow: 0.5s;
  --tv-rainbow-duration: 30s;
}

/* ========================================
   RAINBOW GRADIENT ANIMATIONS
   ======================================== */

@keyframes rainbow-flow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes rainbow-pulse {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

@keyframes rainbow-rotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ========================================
   BASE GRADIENT FRAME SYSTEM
   ======================================== */

.tv-gradient-frame {
  position: relative;
  overflow: hidden;
  border-radius: var(--tv-radius);
}

.tv-gradient-frame::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    -45deg,
    var(--tv-rainbow-red) 0%,
    var(--tv-rainbow-orange) 16.66%,
    var(--tv-rainbow-yellow) 33.33%,
    var(--tv-rainbow-green) 50%,
    var(--tv-rainbow-blue) 66.66%,
    var(--tv-rainbow-violet) 83.33%,
    var(--tv-rainbow-red) 100%
  );
  background-size: 300% 300%;
  animation: rainbow-flow var(--tv-rainbow-duration) linear infinite;
  z-index: -1;
}

.tv-gradient-frame-content {
  position: relative;
  background: var(--tv-white);
  margin: 1px;
  border-radius: calc(var(--tv-radius) - 1px);
  z-index: 1;
}

/* ========================================
   GRADIENT FRAME VARIATIONS
   ======================================== */

/* Subtle Mode - Default for Professional Context */
.tv-gradient-frame-subtle {
  --tv-rainbow-duration: 30s;
}

.tv-gradient-frame-subtle::before {
  opacity: 0.8;
}

.tv-gradient-frame-subtle .tv-gradient-frame-content {
  margin: 1px;
}

/* Emphasis Mode - Important Elements */
.tv-gradient-frame-emphasis {
  --tv-rainbow-duration: 20s;
  border-radius: var(--tv-radius-lg);
}

.tv-gradient-frame-emphasis::before {
  opacity: 0.9;
}

.tv-gradient-frame-emphasis .tv-gradient-frame-content {
  margin: 2px;
  border-radius: calc(var(--tv-radius-lg) - 2px);
}

/* Hero Mode - Landing/Welcome Sections */
.tv-gradient-frame-hero {
  --tv-rainbow-duration: 15s;
  border-radius: var(--tv-radius-xl);
}

.tv-gradient-frame-hero::before {
  opacity: 1;
  background-size: 400% 400%;
}

.tv-gradient-frame-hero .tv-gradient-frame-content {
  margin: 3px;
  border-radius: calc(var(--tv-radius-xl) - 3px);
}

/* ========================================
   LOADING ANIMATIONS
   ======================================== */

.tv-loading-spinner {
  position: relative;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-block;
  background: conic-gradient(
    var(--tv-rainbow-red),
    var(--tv-rainbow-orange),
    var(--tv-rainbow-yellow),
    var(--tv-rainbow-green),
    var(--tv-rainbow-blue),
    var(--tv-rainbow-violet),
    var(--tv-rainbow-red)
  );
  animation: rainbow-rotate 1s linear infinite;
}

.tv-loading-spinner::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  right: 2px;
  bottom: 2px;
  background: var(--tv-white);
  border-radius: 50%;
}

.tv-loading-pulse {
  background: linear-gradient(
    90deg,
    var(--tv-rainbow-red),
    var(--tv-rainbow-orange),
    var(--tv-rainbow-yellow),
    var(--tv-rainbow-green),
    var(--tv-rainbow-blue),
    var(--tv-rainbow-violet)
  );
  background-size: 200% 100%;
  animation: rainbow-flow 2s ease-in-out infinite;
  border-radius: var(--tv-radius);
  height: 4px;
  overflow: hidden;
}

.tv-loading-text {
  background: linear-gradient(
    90deg,
    var(--tv-gray-300),
    var(--tv-gray-100),
    var(--tv-gray-300)
  );
  background-size: 200% 100%;
  animation: rainbow-flow 1.5s ease-in-out infinite;
  border-radius: var(--tv-radius-sm);
  height: 1rem;
  margin: var(--tv-space-1) 0;
}

/* Intensive loading state for gradient frames */
.tv-gradient-frame-loading::before {
  opacity: 1 !important;
  background-size: 400% 400% !important;
}

/* Pulsing animation for loading state */
@keyframes tv-loading-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.02);
    opacity: 1;
  }
}

/* ========================================
   HAPPENSTANCE AI INSPIRED TYPOGRAPHY SYSTEM
   ======================================== */

/* Base body text with Happenstance AI colors */
body {
  font-family: var(--tv-font-family);
  background-color: var(--tv-background);
  color: var(--tv-foreground);
  line-height: var(--tv-leading-normal);
}

/* Hero text - Large display text */
.tv-text-hero {
  font-size: var(--tv-font-4xl);    /* 36px */
  font-weight: var(--tv-font-bold);
  line-height: var(--tv-leading-tight);
  color: var(--tv-foreground);
  margin-bottom: var(--tv-space-6);
  font-family: var(--tv-font-family);
}

/* Main headings */
.tv-text-heading {
  font-size: var(--tv-font-3xl);   /* 30px */
  font-weight: var(--tv-font-semibold);
  line-height: var(--tv-leading-tight);
  color: var(--tv-foreground);
  margin-bottom: var(--tv-space-4);
  font-family: var(--tv-font-family);
}

/* Subheadings */
.tv-text-subheading {
  font-size: var(--tv-font-xl);    /* 20px */
  font-weight: var(--tv-font-medium);
  line-height: var(--tv-leading-snug);
  color: var(--tv-foreground);
  margin-bottom: var(--tv-space-3);
  font-family: var(--tv-font-family);
}

/* Body text */
.tv-text-body {
  font-size: var(--tv-font-base);  /* 16px */
  font-weight: var(--tv-font-normal);
  line-height: var(--tv-leading-relaxed);
  color: var(--tv-foreground);
  font-family: var(--tv-font-family);
}

/* Large body text */
.tv-text-lg {
  font-size: var(--tv-font-lg);    /* 18px */
  font-weight: var(--tv-font-normal);
  line-height: var(--tv-leading-relaxed);
  color: var(--tv-foreground);
  font-family: var(--tv-font-family);
}

/* Small text */
.tv-text-small {
  font-size: var(--tv-font-sm);    /* 14px */
  font-weight: var(--tv-font-normal);
  line-height: var(--tv-leading-normal);
  color: var(--tv-gray-500);
  font-family: var(--tv-font-family);
}

/* Extra small text */
.tv-text-xs {
  font-size: var(--tv-font-xs);    /* 12px */
  font-weight: var(--tv-font-normal);
  line-height: var(--tv-leading-normal);
  color: var(--tv-gray-500);
  font-family: var(--tv-font-family);
}

/* Monospace text */
.tv-text-mono {
  font-family: var(--tv-font-family-mono);
  font-size: var(--tv-font-sm);
  color: var(--tv-gray-500);
  line-height: var(--tv-leading-normal);
}

/* Additional Happenstance AI typography classes */
.tv-text-2xl {
  font-size: var(--tv-font-2xl);   /* 24px */
  font-weight: var(--tv-font-semibold);
  line-height: var(--tv-leading-tight);
  color: var(--tv-foreground);
}

.tv-text-5xl {
  font-size: var(--tv-font-5xl);   /* 48px */
  font-weight: var(--tv-font-bold);
  line-height: var(--tv-leading-none);
  color: var(--tv-foreground);
}

/* Font weight utilities */
.tv-font-normal { font-weight: var(--tv-font-normal); }
.tv-font-medium { font-weight: var(--tv-font-medium); }
.tv-font-semibold { font-weight: var(--tv-font-semibold); }
.tv-font-bold { font-weight: var(--tv-font-bold); }
.tv-font-extrabold { font-weight: var(--tv-font-extrabold); }

/* Text color utilities */
.tv-text-foreground { color: var(--tv-foreground); }
.tv-text-primary { color: var(--tv-primary); }
.tv-text-muted { color: var(--tv-gray-500); }

/* ========================================
   BUTTON SYSTEM
   ======================================== */

.tv-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--tv-space-2);
  padding: var(--tv-space-3) var(--tv-space-6);
  border: 1px solid transparent;
  border-radius: var(--tv-radius);
  font-family: var(--tv-font-family);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--tv-duration-fast) ease;
  position: relative;
  overflow: hidden;
}

.tv-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.tv-button-primary {
  background-color: var(--tv-primary);
  color: var(--tv-white);
  border-color: var(--tv-primary);
}

.tv-button-primary:hover:not(:disabled) {
  background-color: var(--tv-teal-700);
  border-color: var(--tv-teal-700);
  transform: translateY(-1px);
  box-shadow: var(--tv-shadow-md);
}

.tv-button-success {
  background-color: var(--tv-primary);
  color: var(--tv-white);
  border-color: var(--tv-primary);
}

.tv-button-success:hover:not(:disabled) {
  background-color: var(--tv-teal-700);
  border-color: var(--tv-teal-700);
  transform: translateY(-1px);
  box-shadow: var(--tv-shadow-md);
}

.tv-button-blue {
  background-color: var(--tv-blue-600);
  color: var(--tv-white);
  border-color: var(--tv-blue-600);
}

.tv-button-blue:hover:not(:disabled) {
  background-color: var(--tv-blue-700);
  border-color: var(--tv-blue-700);
  transform: translateY(-1px);
  box-shadow: var(--tv-shadow-md);
}

.tv-button-outline {
  background-color: transparent;
  color: var(--tv-gray-600);
  border-color: var(--tv-gray-300);
}

.tv-button-outline:hover:not(:disabled) {
  background-color: var(--tv-gray-50);
  border-color: var(--tv-gray-500);
  transform: translateY(-1px);
  box-shadow: var(--tv-shadow);
}

.tv-button-lg {
  padding: var(--tv-space-4) var(--tv-space-8);
  font-size: 1.125rem;
}

.tv-button-sm {
  padding: var(--tv-space-2) var(--tv-space-4);
  font-size: 0.875rem;
}

/* ========================================
   FORM COMPONENTS
   ======================================== */

.tv-form-group {
  margin-bottom: var(--tv-space-6);
}

.tv-form-label {
  display: block;
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--tv-foreground);
  margin-bottom: var(--tv-space-2);
}

.tv-form-input,
.tv-form-textarea {
  display: block;
  width: 100%;
  padding: var(--tv-space-3) var(--tv-space-4);
  border: 1px solid var(--tv-gray-300);
  border-radius: var(--tv-radius);
  font-family: var(--tv-font-family);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--tv-foreground);
  background-color: var(--tv-white);
  transition: all var(--tv-duration-fast) ease;
}

.tv-form-input:focus,
.tv-form-textarea:focus {
  outline: none;
  border-color: var(--tv-primary);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

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

.tv-form-hint {
  font-size: 0.875rem;
  color: var(--tv-gray-500);
  margin-top: var(--tv-space-1);
  margin-bottom: var(--tv-space-2);
}

/* ========================================
   ALERT/MESSAGE COMPONENTS
   ======================================== */

.tv-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--tv-space-3);
  padding: var(--tv-space-4);
  border: 1px solid transparent;
  border-radius: var(--tv-radius);
  margin-bottom: var(--tv-space-4);
}

.tv-alert-success {
  background-color: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.tv-alert-warning {
  background-color: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.tv-alert-error {
  background-color: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.tv-alert-info {
  background-color: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

/* ========================================
   LAYOUT UTILITIES
   ======================================== */

.tv-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 var(--tv-space-6);
}

.tv-section {
  padding: var(--tv-space-12) 0;
}

.tv-card {
  background: var(--tv-white);
  border: 1px solid var(--tv-gray-300);
  border-radius: var(--tv-radius-lg);
  box-shadow: var(--tv-shadow-sm);
  overflow: hidden;
}

.tv-card-header {
  padding: var(--tv-space-6);
  border-bottom: 1px solid var(--tv-gray-300);
  background: var(--tv-gray-50);
}

.tv-card-body {
  padding: var(--tv-space-6);
}

.tv-card-footer {
  padding: var(--tv-space-6);
  border-top: 1px solid var(--tv-gray-300);
  background: var(--tv-gray-50);
}

/* ========================================
   RESPONSIVE UTILITIES
   ======================================== */

@media (max-width: 768px) {
  .tv-container {
    padding: 0 var(--tv-space-4);
  }
  
  .tv-text-hero {
    font-size: 2rem;
  }
  
  .tv-text-heading {
    font-size: 1.5rem;
  }
  
  .tv-button-lg {
    padding: var(--tv-space-3) var(--tv-space-6);
    font-size: 1rem;
  }
  
  .tv-gradient-frame-hero .tv-gradient-frame-content {
    margin: 2px;
  }
  
  .tv-gradient-frame-emphasis .tv-gradient-frame-content {
    margin: 1px;
  }
}

/* ========================================
   ACCESSIBILITY & MOTION PREFERENCES
   ======================================== */

@media (prefers-reduced-motion: reduce) {
  .tv-gradient-frame::before,
  .tv-loading-spinner,
  .tv-loading-pulse,
  .tv-loading-text {
    animation: none;
  }
  
  .tv-button {
    transition: none;
  }
  
  .tv-button:hover:not(:disabled) {
    transform: none;
  }
}

/* ========================================
   FOCUS INDICATORS
   ======================================== */

.tv-button:focus-visible {
  outline: 2px solid var(--tv-primary);
  outline-offset: 2px;
}

/* ========================================
   LOGO & BRANDING
   ======================================== */

.tv-logo {
  height: 40px;
  width: auto;
  display: inline-block;
}

.tv-logo-lg {
  height: 60px;
}

.tv-logo-sm {
  height: 32px;
}

/* ========================================
   QUESTION SECTION STYLING
   ======================================== */

.tv-questions-frame {
  background: var(--tv-white);
  border-left: 4px solid var(--tv-primary);
  padding: var(--tv-space-6);
  margin-bottom: var(--tv-space-8);
  border-radius: 0 var(--tv-radius-lg) var(--tv-radius-lg) 0;
  box-shadow: var(--tv-shadow-sm);
}

.tv-question-item {
  margin-bottom: var(--tv-space-4);
  font-weight: 500;
  color: var(--tv-foreground);
}

.tv-question-item:last-child {
  margin-bottom: 0;
}

.tv-questions-note {
  margin-top: var(--tv-space-4);
  padding-top: var(--tv-space-4);
  border-top: 1px solid var(--tv-gray-300);
  font-style: italic;
  color: var(--tv-gray-600);
}