/**
 * Next Move — Core Stylesheet
 *
 * Design tokens and base styles for the decision training platform.
 * Optimized for correctional tablets (7-10 inch screens).
 * WCAG 2.1 AA compliant contrast ratios.
 *
 * Color palette:
 *   --brand:      #00c896 (primary accent)
 *   --bg-dark:    #1a1a2e (page background)
 *   --bg-card:    #16213e (card/panel background)
 *   --text:       #e0e0e0 (primary text)
 *   --text-muted: #9e9e9e (secondary text)
 *   --danger:     #ef5350 (stress high, crisis)
 *   --warning:    #ffb74d (stress moderate, demo)
 *   --success:    #66bb6a (completed, granted)
 */

/* ============================================================
   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: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================================ */

:root {
  /* Brand */
  --brand: #00c896;
  --brand-hover: #00a67d;
  --brand-light: rgba(0, 200, 150, 0.15);
  --brand-text: #00c896;

  /* Backgrounds */
  --bg-dark: #1a1a2e;
  --bg-card: #16213e;
  --bg-input: rgba(255, 255, 255, 0.05);
  --bg-overlay: rgba(0, 0, 0, 0.6);

  /* Text */
  --text: #e0e0e0;
  --text-muted: #9e9e9e;
  --text-bright: #ffffff;

  /* Borders */
  --border: rgba(255, 255, 255, 0.1);
  --border-focus: var(--brand);

  /* Status colors */
  --danger: #ef5350;
  --danger-bg: rgba(239, 83, 80, 0.15);
  --warning: #ffb74d;
  --warning-bg: rgba(255, 183, 77, 0.15);
  --success: #66bb6a;
  --success-bg: rgba(102, 187, 106, 0.15);

  /* Spacing scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  /* Border radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --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);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;

  /* Typography */
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;
}

/* ============================================================
   ACCESSIBILITY
   ============================================================ */

.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--brand);
  color: var(--text-bright);
  padding: var(--space-sm) var(--space-md);
  z-index: 1000;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
  top: 0;
}

/* Focus ring for keyboard users */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

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

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 100dvh;
  padding: var(--space-md);
}

/* ============================================================
   LOADING SCREEN
   ============================================================ */

.loading-screen {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.brand-text {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--brand);
  margin-bottom: var(--space-sm);
}

.loading-text {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-lg);
  border: none;
  border-radius: var(--radius-lg);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  line-height: 1.5;
  min-height: 44px; /* WCAG touch target */
  min-width: 44px;
}

.btn-primary {
  background: var(--brand);
  color: var(--text-bright);
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--brand-hover);
}

.btn-primary:disabled {
  background: var(--bg-input);
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
  border-color: var(--brand);
  color: var(--brand-text);
}

.btn-full {
  width: 100%;
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  border: 1px solid var(--border);
}

.card-header {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: var(--space-sm);
}

.card-body {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  line-height: 1.6;
}

/* ============================================================
   STRESS METER
   ============================================================ */

.stress-meter {
  width: 100%;
  height: 8px;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.stress-meter-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-normal), background-color var(--transition-normal);
}

.stress-low { background: var(--success); }
.stress-moderate { background: var(--warning); }
.stress-high { background: var(--danger); }

/* ============================================================
   LANGUAGE SELECTOR (Disclaimer Screen)
   ============================================================ */

.lang-selector {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.lang-btn {
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 44px;
}

.lang-btn.active,
.lang-btn:hover {
  background: var(--brand-light);
  border-color: var(--brand);
  color: var(--brand-text);
}

/* ============================================================
   STATUS BADGES
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-brand { background: var(--brand-light); color: var(--brand-text); }

/* ============================================================
   WHAT-IF & REPLAY SYSTEM
   ============================================================ */

:root {
  --replay-accent: #7C3AED;
  --replay-light: rgba(124, 58, 237, 0.15);
  --replay-border: rgba(124, 58, 237, 0.3);
}

.whatif-screen {
  padding-bottom: var(--space-2xl);
}

/* Grade circle animation */
.whatif-screen .grade-circle {
  animation: gradeReveal 0.6s ease-out;
}

@keyframes gradeReveal {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* Replay mode header indicator */
.replay-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  background: var(--replay-light);
  color: var(--replay-accent);
  font-size: var(--font-size-xs);
  font-weight: 600;
}

/* Replay button styling */
.btn-replay {
  background: var(--replay-accent);
  color: var(--text-bright);
  border: none;
}

.btn-replay:hover,
.btn-replay:focus-visible {
  background: #6D28D9;
}

/* What-If comparison highlight */
.whatif-changed {
  background: var(--replay-light);
  border-left: 3px solid var(--replay-accent);
  padding-left: var(--space-sm);
}

/* ============================================================
   RESPONSIVE: TABLET OPTIMIZATION (768px-1024px)
   ============================================================ */

@media (min-width: 768px) {
  .screen {
    max-width: 720px;
    margin: 0 auto;
    padding: var(--space-xl);
  }

  .btn {
    font-size: var(--font-size-base);
    padding: var(--space-md) var(--space-xl);
  }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
