/* ==========================================================================
   DOGE Cuts Impact Report - Telegram Mini App
   Dark theme | Government-blue + red warning accents
   Mobile-first | Space Grotesk + JetBrains Mono
   ========================================================================== */

/* ---------- CSS Custom Properties ---------- */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2236;
  --bg-card-hover: #1f2a42;

  --gov-blue: #1e40af;
  --gov-blue-light: #3b82f6;
  --gov-blue-glow: rgba(59, 130, 246, 0.25);

  --red-warning: #dc2626;
  --red-light: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.2);

  --yellow-caution: #f59e0b;
  --yellow-light: #fbbf24;

  --green-safe: #22c55e;
  --green-light: #4ade80;

  --orange-impact: #f97316;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --border-subtle: rgba(148, 163, 184, 0.1);
  --border-active: rgba(59, 130, 246, 0.4);

  --font-primary: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-primary);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  position: relative;
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
}

/* ---------- Screen System ---------- */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  min-height: 100vh;
  opacity: 0;
  visibility: hidden;
  transform: translateX(30px);
  transition: opacity var(--transition-slow), transform var(--transition-slow), visibility 0s linear var(--transition-slow);
  pointer-events: none;
}

.screen.active {
  position: relative;
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  transition: opacity var(--transition-slow), transform var(--transition-slow), visibility 0s linear 0s;
  pointer-events: auto;
}

.screen.exit-left {
  transform: translateX(-30px);
}

.screen-content {
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  max-width: 480px;
  margin: 0 auto;
}

/* ==========================================================================
   SCREEN 1: INTRO
   ========================================================================== */

.intro-header {
  text-align: center;
  padding-top: 20px;
}

.intro-icon-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}

.intro-icon {
  font-size: 3rem;
  display: inline-block;
  animation: iconFloat 3s ease-in-out infinite;
}

.intro-icon.scissors {
  animation-delay: 0.5s;
  animation-name: iconSnip;
}

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

@keyframes iconSnip {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}

.intro-title {
  font-family: var(--font-primary);
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.intro-title .subtitle {
  display: block;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--gov-blue-light);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-top: 4px;
}

.intro-tagline {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

/* Stats Banner */
.stats-banner {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.12), rgba(239, 68, 68, 0.06));
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}

.stats-banner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--red-warning), transparent);
}

.stat-number {
  font-family: var(--font-mono);
  font-size: 2.75rem;
  font-weight: 700;
  color: var(--red-light);
  line-height: 1;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Intro Details */
.intro-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 36px;
}

.detail-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  border: 1px solid var(--border-subtle);
  opacity: 0;
  transform: translateY(10px);
  animation: fadeSlideIn 0.5s ease forwards;
}

.detail-row:nth-child(1) { animation-delay: 0.3s; }
.detail-row:nth-child(2) { animation-delay: 0.5s; }
.detail-row:nth-child(3) { animation-delay: 0.7s; }

@keyframes fadeSlideIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.detail-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.detail-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

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

.cta-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--gov-blue), var(--gov-blue-light));
  color: white;
  font-family: var(--font-primary);
  font-size: 1.05rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px var(--gov-blue-glow);
}

.cta-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px var(--gov-blue-glow);
}

.cta-button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 12px var(--gov-blue-glow);
}

.cta-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.cta-button::after {
  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.6s ease;
}

.cta-button:hover:not(:disabled)::after {
  left: 100%;
}

.cta-arrow {
  font-size: 1.2rem;
  transition: transform var(--transition-fast);
}

.cta-button:hover:not(:disabled) .cta-arrow {
  transform: translateX(3px);
}

.secondary-button {
  display: block;
  width: 100%;
  padding: 14px 24px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: 1rem;
  font-weight: 600;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-base);
}

.secondary-button:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-active);
}

.back-link {
  display: block;
  width: 100%;
  padding: 12px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-primary);
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: color var(--transition-fast);
  text-align: center;
}

.back-link:hover {
  color: var(--text-secondary);
}

.share-btn {
  background: linear-gradient(135deg, var(--red-warning), var(--orange-impact));
  box-shadow: 0 4px 20px var(--red-glow);
}

.share-btn:hover:not(:disabled) {
  box-shadow: 0 6px 28px var(--red-glow);
}

/* ==========================================================================
   SCREEN 2: SERVICE SELECTION
   ========================================================================== */

.select-header {
  text-align: center;
  margin-bottom: 24px;
}

.select-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.select-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.selection-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 6px 16px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--gov-blue-light);
  font-weight: 600;
  transition: all var(--transition-base);
}

.selection-counter.has-selections {
  border-color: var(--gov-blue-light);
  background: rgba(59, 130, 246, 0.1);
}

/* Categories */
.categories-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 24px;
}

.category-section {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-card);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast);
}

.category-header:hover {
  background: var(--bg-card-hover);
}

.category-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.category-name {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  flex: 1;
}

.category-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-primary);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.category-chevron {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform var(--transition-base);
}

.category-section.expanded .category-chevron {
  transform: rotate(180deg);
}

.category-services {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-slow);
}

.category-section.expanded .category-services {
  max-height: 600px;
}

/* Service Toggle Item */
.service-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-top: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--transition-fast);
  user-select: none;
}

.service-item:hover {
  background: rgba(255, 255, 255, 0.02);
}

.service-item.selected {
  background: rgba(59, 130, 246, 0.06);
}

/* Custom Toggle */
.toggle-wrapper {
  flex-shrink: 0;
  margin-top: 2px;
}

.toggle-track {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--bg-primary);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-full);
  transition: all var(--transition-base);
}

.service-item.selected .toggle-track {
  background: var(--gov-blue);
  border-color: var(--gov-blue-light);
}

.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--transition-base);
}

.service-item.selected .toggle-knob {
  left: 22px;
  background: white;
}

.service-info {
  flex: 1;
  min-width: 0;
}

.service-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.3;
}

.service-status-preview {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.status-cut {
  color: var(--red-light);
  background: rgba(239, 68, 68, 0.12);
}

.status-degraded {
  color: var(--yellow-light);
  background: rgba(251, 191, 36, 0.12);
}

.status-safe {
  color: var(--green-light);
  background: rgba(74, 222, 128, 0.12);
}

.service-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

/* Select Footer */
.select-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  position: sticky;
  bottom: 0;
  background: linear-gradient(transparent, var(--bg-primary) 20%);
  padding-bottom: 8px;
}

/* ==========================================================================
   SCREEN 3: RESULTS
   ========================================================================== */

.results-header {
  text-align: center;
  margin-bottom: 28px;
}

/* Score Ring */
.score-ring {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 0 auto 20px;
}

.score-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.score-track {
  fill: none;
  stroke: var(--bg-card);
  stroke-width: 8;
}

.score-fill {
  fill: none;
  stroke: var(--gov-blue-light);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.5s ease;
}

.score-value {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.score-value #score-number {
  font-family: var(--font-mono);
  font-size: 2.75rem;
  font-weight: 700;
  line-height: 1;
  display: block;
}

.score-max {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Score color variants */
.score-ring.level-low .score-fill { stroke: var(--green-safe); }
.score-ring.level-low #score-number { color: var(--green-light); }

.score-ring.level-med .score-fill { stroke: var(--yellow-caution); }
.score-ring.level-med #score-number { color: var(--yellow-light); }

.score-ring.level-high .score-fill { stroke: var(--orange-impact); }
.score-ring.level-high #score-number { color: var(--orange-impact); }

.score-ring.level-crit .score-fill { stroke: var(--red-warning); }
.score-ring.level-crit #score-number { color: var(--red-light); }

.results-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.impact-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.impact-badge.level-low {
  background: rgba(34, 197, 94, 0.12);
  color: var(--green-light);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.impact-badge.level-med {
  background: rgba(245, 158, 11, 0.12);
  color: var(--yellow-light);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.impact-badge.level-high {
  background: rgba(249, 115, 22, 0.12);
  color: var(--orange-impact);
  border: 1px solid rgba(249, 115, 22, 0.25);
}

.impact-badge.level-crit {
  background: rgba(220, 38, 38, 0.12);
  color: var(--red-light);
  border: 1px solid rgba(220, 38, 38, 0.25);
}

/* Results Summary */
.results-summary {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 24px;
  text-align: center;
}

.summary-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.summary-text strong {
  color: var(--text-primary);
  font-weight: 700;
}

/* Results Breakdown */
.results-breakdown {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 28px;
}

.result-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  border-left: 3px solid transparent;
  opacity: 0;
  transform: translateY(10px);
  animation: cardReveal 0.4s ease forwards;
}

.result-card:nth-child(1) { animation-delay: 0.1s; }
.result-card:nth-child(2) { animation-delay: 0.18s; }
.result-card:nth-child(3) { animation-delay: 0.26s; }
.result-card:nth-child(4) { animation-delay: 0.34s; }
.result-card:nth-child(5) { animation-delay: 0.42s; }
.result-card:nth-child(6) { animation-delay: 0.50s; }
.result-card:nth-child(7) { animation-delay: 0.58s; }
.result-card:nth-child(8) { animation-delay: 0.66s; }
.result-card:nth-child(9) { animation-delay: 0.74s; }
.result-card:nth-child(10) { animation-delay: 0.82s; }
.result-card:nth-child(11) { animation-delay: 0.90s; }
.result-card:nth-child(12) { animation-delay: 0.98s; }
.result-card:nth-child(13) { animation-delay: 1.06s; }
.result-card:nth-child(14) { animation-delay: 1.14s; }
.result-card:nth-child(15) { animation-delay: 1.22s; }
.result-card:nth-child(16) { animation-delay: 1.30s; }
.result-card:nth-child(17) { animation-delay: 1.38s; }
.result-card:nth-child(18) { animation-delay: 1.46s; }

@keyframes cardReveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-card.status-cut {
  border-left-color: var(--red-warning);
}

.result-card.status-degraded {
  border-left-color: var(--yellow-caution);
}

.result-card.status-safe {
  border-left-color: var(--green-safe);
}

.result-status-dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
}

.result-card.status-cut .result-status-dot { background: var(--red-light); box-shadow: 0 0 8px var(--red-glow); }
.result-card.status-degraded .result-status-dot { background: var(--yellow-light); box-shadow: 0 0 8px rgba(251, 191, 36, 0.3); }
.result-card.status-safe .result-status-dot { background: var(--green-light); box-shadow: 0 0 8px rgba(74, 222, 128, 0.3); }

.result-card-info {
  flex: 1;
  min-width: 0;
}

.result-card-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.result-card-status {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.result-card.status-cut .result-card-status { color: var(--red-light); }
.result-card.status-degraded .result-card-status { color: var(--yellow-light); }
.result-card.status-safe .result-card-status { color: var(--green-light); }

.result-card-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Results Footer */
.results-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ==========================================================================
   SCROLL & UTILITY
   ========================================================================== */

::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 2px;
}

/* Pulse animation for stat counter */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.stats-banner.counting .stat-number {
  animation: pulse 0.1s ease;
}

/* Responsive */
@media (max-width: 360px) {
  .intro-title { font-size: 1.85rem; }
  .stat-number { font-size: 2.25rem; }
  .screen-content { padding-left: 16px; padding-right: 16px; }
}

@media (min-width: 481px) {
  .screen-content {
    padding-left: 32px;
    padding-right: 32px;
  }
}
