/* Modern D&D Character Creator Styles */
@import url('../css/shared-styles.css');

/* CSS Custom Properties */
:root {
  --primary: #8b5cf6;
  --primary-dark: #7c3aed;
  --secondary: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-accent: #f3f4f6;
  --bg-dark: #1f2937;
  
  --border: #e5e7eb;
  --border-focus: var(--primary);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
  :root {
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    
    --bg-primary: #1f2937;
    --bg-secondary: #111827;
    --bg-accent: #374151;
    --bg-dark: #000000;
    
    --border: #374151;
  }
}

/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  /* Background is handled by shared-styles.css */
  color: var(--text, #ffffff);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Background inherited from shared-styles.css */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease-out;
}

.loading-content {
  text-align: center;
  color: white;
}

.dice-loader {
  margin-bottom: var(--spacing-lg);
}

.dice {
  font-size: 4rem;
  animation: roll 2s infinite ease-in-out;
  display: inline-block;
}

@keyframes roll {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(90deg) scale(1.1); }
  50% { transform: rotate(180deg) scale(1); }
  75% { transform: rotate(270deg) scale(1.1); }
}

.loading-bar {
  width: 200px;
  height: 4px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  overflow: hidden;
  margin: var(--spacing-lg) auto 0;
}

.loading-progress {
  height: 100%;
  background: linear-gradient(90deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3);
  border-radius: 2px;
  animation: loading 3s infinite ease-in-out;
  background-size: 400% 400%;
}

@keyframes loading {
  0% { transform: translateX(-100%); background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { transform: translateX(100%); background-position: 0% 50%; }
}

/* App Container */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  padding: var(--spacing-md) 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--spacing-md);
}

.app-title {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.brand {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 0.875rem;
  color: var(--text-muted, #9ca3af);
  font-weight: 500;
}

.progress-container {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.progress-bar {
  width: 200px;
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-text {
  font-size: 0.875rem;
  color: var(--text-muted, #d1d5db);
  font-weight: 500;
  white-space: nowrap;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-lg) var(--spacing-lg);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  min-height: calc(100vh - 200px); /* Reserve space for header and footer */
  max-height: calc(100vh - 200px); /* Prevent taking more than needed */
}

.screen {
  width: 100%;
  max-width: 800px;
}

/* Welcome Screen */
.welcome-screen {
  text-align: center;
}

.welcome-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-xl);
  padding: var(--spacing-2xl);
  box-shadow: var(--shadow-xl);
}

.welcome-icon {
  font-size: 4rem;
  margin-bottom: var(--spacing-lg);
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-10px); }
  60% { transform: translateY(-5px); }
}

.welcome-card h2 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: var(--spacing-lg);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-card p {
  font-size: 1.125rem;
  color: var(--text-secondary, #d1d5db);
  margin-bottom: var(--spacing-xl);
  line-height: 1.7;
}

.feature-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-2xl);
}

.feature-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-weight: 500;
  color: var(--text-secondary, #d1d5db);
}

.feature-icon {
  font-size: 1.25rem;
}

/* Buttons */
.cta-button, .action-button {
  position: relative;
  padding: var(--spacing-md) var(--spacing-xl);
  border-radius: var(--radius-lg);
  font-weight: 600;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  text-decoration: none;
  overflow: hidden;
}

.cta-button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-size: 1.125rem;
  padding: var(--spacing-lg) var(--spacing-2xl);
  box-shadow: var(--shadow-lg);
}

.cta-button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
}

.button-glow {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  transition: left 0.5s ease;
}

.cta-button:hover .button-glow {
  left: 100%;
}

.action-button.primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.action-button.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary, #ffffff);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.action-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.action-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Question Screen */
.question-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.question-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-xl);
  padding: var(--spacing-2xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 700px;
}

.question-header {
  text-align: center;
  margin-bottom: var(--spacing-2xl);
}

.question-number {
  display: inline-block;
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.25rem;
  margin: 0 auto var(--spacing-lg);
}

.question-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary, #ffffff);
  line-height: 1.3;
}

.answers-container {
  margin-bottom: var(--spacing-2xl);
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 10px;
}

.answers-container::-webkit-scrollbar {
  width: 8px;
}

.answers-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.answers-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
}

.answers-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

.answer-option {
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-md);
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.answer-option:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.answer-option.selected {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.2), rgba(118, 75, 162, 0.2));
  border-color: #667eea;
  box-shadow: 0 0 0 1px #667eea;
}

.answer-option::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transition: left 0.5s ease;
}

.answer-option:hover::before {
  left: 100%;
}

.answer-option {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.answer-checkbox {
  font-size: 1.5rem;
  color: #667eea;
  font-weight: bold;
  min-width: 24px;
}

.answer-text {
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text-primary, #ffffff);
  position: relative;
  z-index: 1;
  flex: 1;
}

/* Hide answers during transition to prevent flashing */
.answers-container.transitioning {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease-out;
}

.question-actions {
  display: flex;
  justify-content: space-between;
  gap: var(--spacing-md);
}

/* Fix scrollbar flickering */
.main-content {
  overflow: hidden; /* Prevent temporary scrollbars */
}

.screen {
  overflow-y: auto; /* Allow scrolling within screens if needed */
  max-height: 100%;
}

/* Progress bar style score items */
.score-item-bar {
  margin-bottom: var(--spacing-md);
}

.score-bar-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 0.875rem;
}

.attribute-name {
  color: var(--text-primary, #ffffff);
  font-weight: 500;
}

.attribute-score {
  color: var(--text-muted, #d1d5db);
  font-weight: 600;
  font-family: monospace;
}

.score-bar-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s ease-out;
  animation: fillBar 1s ease-out;
}

.score-bar-fill.positive {
  background: linear-gradient(90deg, #10b981, #34d399);
}

.score-bar-fill.negative {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

@keyframes fillBar {
  from { width: 0% !important; }
}

/* Compact score sections */
.score-section {
  margin-bottom: var(--spacing-xl);
}

.score-section h4 {
  font-size: 1.125rem;
  margin-bottom: var(--spacing-md);
  color: var(--text-primary, #ffffff);
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
}

/* Results Screen */
.results-container {
  text-align: center;
}

.results-header {
  margin-bottom: var(--spacing-2xl);
}

.results-icon {
  font-size: 4rem;
  margin-bottom: var(--spacing-lg);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.results-header h2 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: var(--spacing-md);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.character-reveal {
  margin-bottom: var(--spacing-2xl);
}

.character-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-xl);
  padding: var(--spacing-2xl);
  box-shadow: var(--shadow-xl);
  animation: slideIn 0.8s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.character-portrait {
  margin-bottom: var(--spacing-xl);
}

.character-avatar {
  width: 120px;
  height: 120px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  margin: 0 auto;
  box-shadow: var(--shadow-xl);
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

.character-race {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary, #ffffff);
  margin-bottom: var(--spacing-sm);
}

.character-class {
  font-size: 1.5rem;
  font-weight: 600;
  color: #667eea;
  margin-bottom: var(--spacing-lg);
}

.character-description {
  font-size: 1.125rem;
  color: var(--text-secondary, #d1d5db);
  line-height: 1.7;
}

.detailed-results {
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl);
  margin-bottom: var(--spacing-2xl);
  text-align: left;
}

.detailed-results h3 {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: var(--spacing-lg);
  color: var(--text-primary, #ffffff);
}

.score-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--spacing-lg);
}

.score-item {
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  padding: var(--spacing-md);
  border-left: 4px solid #667eea;
}

.score-label {
  font-weight: 600;
  color: var(--text-primary, #ffffff);
  margin-bottom: var(--spacing-xs);
}

.score-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: #667eea;
}

.results-actions {
  display: flex;
  justify-content: center;
  gap: var(--spacing-lg);
  flex-wrap: wrap;
}

/* Footer */
.app-footer {
  background: rgba(0, 0, 0, 0.3);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: var(--spacing-md) 0;
  margin-top: auto;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  color: var(--text-muted, #9ca3af);
}

.footer-brand {
  font-weight: 600;
}

/* Responsive Design */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    text-align: center;
  }
  
  .progress-container {
    order: -1;
  }
  
  .main-content {
    padding: var(--spacing-lg) var(--spacing-md);
  }
  
  .welcome-card {
    padding: var(--spacing-xl);
  }
  
  .welcome-card h2 {
    font-size: 2rem;
  }
  
  .question-card {
    padding: var(--spacing-xl);
  }
  
  .question-title {
    font-size: 1.5rem;
  }
  
  .question-actions {
    flex-direction: column;
  }
  
  .character-card {
    padding: var(--spacing-xl);
  }
  
  .results-header h2 {
    font-size: 2rem;
  }
  
  .character-race {
    font-size: 1.75rem;
  }
  
  .results-actions {
    flex-direction: column;
    align-items: center;
  }
  
  .action-button {
    width: 100%;
    max-width: 300px;
  }
  
  .footer-content {
    flex-direction: column;
    gap: var(--spacing-xs);
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles for keyboard navigation */
.cta-button:focus,
.action-button:focus,
.answer-option:focus {
  outline: 2px solid #667eea;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --primary: #0000ff;
    --bg-primary: #ffffff;
    --text-primary: #000000;
    --border: #000000;
  }
}