/* ==========================================================================
   CSS CUSTOM PROPERTIES (DESIGN TOKENS)
   ========================================================================== */

:root {
  /* Brand Colors */
  --color-brand-primary: #1976D2;
  --color-brand-primary-hover: #0056CC;
  --color-brand-primary-light: rgba(0, 122, 255, 0.1);
  
  /* Text Colors */
  --color-text-primary: #131415;
  --color-text-secondary: #63707B;
  --color-text-subdued: #8B8B8B;
  --color-text-brand: #1976D2;
  --color-text-on-brand: #FFFFFF;
  --color-text-on-dark: #FFFFFF;
  
  /* Status Colors */
  --color-winner-green: #22C55E;
  --color-winner-green-hover: #16A34A;
  --color-winner-green-light: rgba(34, 197, 94, 0.1);
  --color-not-winner-gray: #6B7280;
  --color-not-winner-gray-hover: #4B5563;
  --color-not-winner-gray-light: rgba(107, 114, 128, 0.1);
  
  /* Background Colors */
  --color-bg-primary: #FFFFFF;
  --color-bg-secondary: #F8F9FA;
  --color-bg-dark: #000000;
  --color-bg-brand: #007AFF;
  --color-bg-overlay: rgba(0, 0, 0, 0.08);
  
  /* Border Colors */
  --color-border-default: #E7EDF2;
  --color-border-subtle: #F1F3F4;
  --color-border-brand: #007AFF;
  --color-border-interactive: #333;
  
  /* Progress Colors */
  --color-progress-active: #1976D2;
  --color-progress-inactive: #D7DEE1;
  --color-progress-shimmer: rgba(255, 255, 255, 0.6);
  
  /* Typography */
  --font-family-primary: "Proxima Nova", -apple-system, BlinkMacSystemFont, "Segoe UI", roboto, sans-serif;
  --font-family-system: -apple-system, BlinkMacSystemFont, "Segoe UI", roboto, sans-serif;
  
  /* Text Sizes */
  --text-display-size: 2rem;
  --text-display-weight: 600;
  --text-display-line-height: 1.2;
  --text-header-01-size: 16px;
  --text-header-01-weight: 700;
  --text-header-01-line-height: 24px;
  --text-header-02-size: 1.1rem;
  --text-header-02-weight: 500;
  --text-header-02-line-height: 1.4;
  --text-body-01-size: 14px;
  --text-body-01-weight: 400;
  --text-body-01-line-height: 20px;
  --text-body-02-size: 14px;
  --text-body-02-weight: 400;
  --text-body-02-line-height: 20px;
  --text-emphasis-01-size: 0.9rem;
  --text-emphasis-01-weight: 500;
  --text-emphasis-01-line-height: 1.4;
  --text-emphasis-02-size: 14px;
  --text-emphasis-02-weight: 700;
  --text-emphasis-02-line-height: 20px;
  
  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 20px;
  --spacing-2xl: 24px;
  --spacing-3xl: 32px;
  --spacing-4xl: 40px;
  --spacing-5xl: 48px;
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  
  /* Shadows */
  --shadow-sm: 0px 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0px 2px 4px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0px 4px 8px rgba(0, 0, 0, 0.12);
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.2s ease;
  --transition-slow: 0.3s ease;
  
  /* Z-Index */
  --z-base: 0;
  --z-overlay: 10;
  --z-modal: 20;
  --z-tooltip: 30;
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */

* {
  box-sizing: border-box;
}

*:focus-visible {
  outline: 2px solid var(--color-brand-primary);
  outline-offset: 2px;
}

*:focus:not(:focus-visible) {
  outline: none;
}

body {
  margin: 0;
  padding: 0;
  min-width: 320px;
  min-height: 100vh;
  font-family: var(--font-family-system);
  color: var(--color-text-primary);
  background: var(--color-bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

#root {
  width: 100%;
  margin: 0;
  padding: 0;
}

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

.app {
  min-height: 100vh;
  background: var(--color-bg-dark);
  padding: var(--spacing-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.app-title {
  text-align: center;
  color: var(--color-text-on-dark);
  margin-bottom: var(--spacing-xl);
  font-family: var(--font-family-system);
  font-size: var(--text-display-size);
  font-weight: var(--text-display-weight);
  line-height: var(--text-display-line-height);
}

/* ==========================================================================
   STATE SELECTOR
   ========================================================================== */

.state-selector {
  margin-bottom: var(--spacing-4xl);
  text-align: center;
}

.state-selector h2 {
  color: var(--color-text-subdued);
  font-family: var(--font-family-system);
  font-size: var(--text-header-02-size);
  font-weight: var(--text-header-02-weight);
  line-height: var(--text-header-02-line-height);
  margin-bottom: var(--spacing-lg);
}

.state-buttons {
  display: flex;
  gap: var(--spacing-md);
  justify-content: center;
  flex-wrap: wrap;
}

.state-buttons button {
  background: transparent;
  border: 1px solid var(--color-border-interactive);
  color: var(--color-text-subdued);
  padding: var(--spacing-md) var(--spacing-xl);
  border-radius: var(--radius-md);
  font-family: var(--font-family-system);
  font-size: var(--text-emphasis-01-size);
  font-weight: var(--text-emphasis-01-weight);
  cursor: pointer;
  transition: all var(--transition-normal);
  min-width: 140px;
}

.state-buttons button:hover {
  border-color: var(--color-border-brand);
  color: var(--color-text-on-dark);
  background: var(--color-brand-primary-light);
}

.state-buttons button.active {
  background: var(--color-bg-brand);
  border-color: var(--color-border-brand);
  color: var(--color-text-on-brand);
}

.state-buttons button.active:hover {
  background: var(--color-brand-primary-hover);
  border-color: var(--color-brand-primary-hover);
}

.state-buttons button:focus-visible {
  outline: 2px solid var(--color-brand-primary);
  outline-offset: 2px;
}

/* ==========================================================================
   ORDER CARD COMPONENT
   ========================================================================== */

.order-card {
  display: flex;
  flex-direction: column;
  width: 343px;
  background: var(--color-bg-primary);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-lg);
  margin: var(--spacing-xl) auto;
  overflow: hidden;
  font-family: var(--font-family-primary);
}

.order-card:focus-within {
  box-shadow: var(--shadow-lg);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: var(--spacing-md) var(--spacing-lg) var(--spacing-sm);
}

.lottery-name {
  margin: 0;
  color: var(--color-text-brand);
  font-family: var(--font-family-primary);
  font-size: var(--text-header-01-size);
  font-style: normal;
  font-weight: var(--text-header-01-weight);
  line-height: var(--text-header-01-line-height);
}

.order-id {
  font-size: var(--text-body-02-size);
  color: var(--color-text-secondary);
  font-weight: var(--text-body-02-weight);
}

.order-details {
  padding: 0 var(--spacing-lg) var(--spacing-md);
}

.detail-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-xs);
}

.detail-row:last-child {
  margin-bottom: 0;
}

.label {
  color: var(--color-text-secondary);
  font-family: var(--font-family-primary);
  font-size: var(--text-body-02-size);
  font-style: normal;
  font-weight: var(--text-body-02-weight);
  line-height: var(--text-body-02-line-height);
}

.value {
  color: var(--color-text-primary);
  font-family: var(--font-family-primary);
  font-size: var(--text-body-02-size);
  font-style: normal;
  font-weight: var(--text-body-02-weight);
  line-height: var(--text-body-02-line-height);
}

.plays {
  font-size: var(--text-body-02-size);
  color: var(--color-text-subdued);
  font-weight: var(--text-body-02-weight);
}

/* ==========================================================================
   STATUS SECTION
   ========================================================================== */

.status-section {
  padding: var(--spacing-md) var(--spacing-lg) var(--spacing-lg);
  border-top: 1px solid var(--color-border-default);
  border-bottom: 1px solid var(--color-border-default);
}

.status-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.status-icon svg {
  transition: transform var(--transition-normal);
}

.status-icon svg[data-state="getting_results"] {
  animation: sparkle 2s ease-in-out infinite;
}

.status-text {
  color: var(--color-text-brand);
  font-family: var(--font-family-primary);
  font-size: var(--text-emphasis-02-size);
  font-style: normal;
  font-weight: var(--text-emphasis-02-weight);
  line-height: var(--text-emphasis-02-line-height);
}

.status-text.won {
  color: #1b9e7a;
  font-weight: 600;
}

.status-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-sm);
}

/* ==========================================================================
   PROGRESS BAR
   ========================================================================== */

.progress-bar {
  display: flex;
  gap: var(--spacing-xs);
  height: var(--spacing-xs);
  position: relative;
  overflow: hidden;
}

.progress-bar:before {
  content: "";
  position: absolute;
  top: 0;
  left: -50px;
  height: 100%;
  width: 50px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    rgba(255, 255, 255, 0.15) 25%, 
    rgba(255, 255, 255, 0.4) 50%, 
    rgba(255, 255, 255, 0.15) 75%, 
    transparent 100%);
  border-radius: var(--radius-sm);
  pointer-events: none;
  z-index: var(--z-overlay);
  display: none;
}

.progress-bar[data-progress="33"]:before {
  display: block;
  animation: sheen-33 2.5s infinite ease-in-out;
}

.progress-bar[data-progress="66"]:before {
  display: block;
  animation: sheen-66 2.5s infinite ease-in-out;
}

.progress-bar[data-progress="100"]:before {
  display: block;
  animation: sheen-100 2.5s infinite ease-in-out;
}

.progress-container {
  display: flex;
  gap: var(--spacing-xs);
  height: var(--spacing-xs);
  position: relative;
}

.progress-segment {
  flex: 1;
  background: var(--color-progress-inactive);
  border-radius: var(--radius-sm);
}

.progress-segment.active {
  background: var(--color-progress-active);
}

/* ==========================================================================
   SPARKLE ANIMATIONS
   ========================================================================== */

.sparkle-icon #sparkle-top {
  animation: sparkle-scale-1 2s ease-in-out infinite;
  transform-origin: 11.75px 4.25px;
}

.sparkle-icon #sparkle-center {
  animation: sparkle-scale-2 2s ease-in-out infinite;
  transform-origin: 6.47px 7.97px;
}

.sparkle-icon #sparkle-bottom {
  animation: sparkle-scale-3 2s ease-in-out infinite;
  transform-origin: 11.75px 11.75px;
}

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

.action-buttons {
  display: flex;
  height: 52px;
}

.action-btn {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  background: transparent;
  border: none;
  color: var(--color-text-brand);
  font-family: var(--font-family-primary);
  font-size: var(--text-body-02-size);
  font-weight: var(--text-emphasis-02-weight);
  cursor: pointer;
  transition: background-color var(--transition-normal);
}

.action-btn:hover {
  background: var(--color-bg-overlay);
}

.action-btn:active {
  background: #1565c014;
}

.action-btn:focus-visible {
  outline: 2px solid var(--color-brand-primary);
  outline-offset: 2px;
}

.button-divider {
  width: 1px;
  background: var(--color-border-default);
}

/* ==========================================================================
   TYPOGRAPHY UTILITY CLASSES
   ========================================================================== */

.text-display {
  font-family: var(--font-family-system);
  font-size: var(--text-display-size);
  font-weight: var(--text-display-weight);
  line-height: var(--text-display-line-height);
}

.text-header-01 {
  font-family: var(--font-family-primary);
  font-size: var(--text-header-01-size);
  font-style: normal;
  font-weight: var(--text-header-01-weight);
  line-height: var(--text-header-01-line-height);
}

.text-header-02 {
  font-family: var(--font-family-system);
  font-size: var(--text-header-02-size);
  font-weight: var(--text-header-02-weight);
  line-height: var(--text-header-02-line-height);
}

.text-body-01 {
  font-family: var(--font-family-primary);
  font-size: var(--text-body-01-size);
  font-style: normal;
  font-weight: var(--text-body-01-weight);
  line-height: var(--text-body-01-line-height);
}

.text-body-02 {
  font-family: var(--font-family-primary);
  font-size: var(--text-body-02-size);
  font-style: normal;
  font-weight: var(--text-body-02-weight);
  line-height: var(--text-body-02-line-height);
}

.text-emphasis-01 {
  font-family: var(--font-family-system);
  font-size: var(--text-emphasis-01-size);
  font-weight: var(--text-emphasis-01-weight);
  line-height: var(--text-emphasis-01-line-height);
}

.text-emphasis-02 {
  font-family: var(--font-family-primary);
  font-size: var(--text-emphasis-02-size);
  font-style: normal;
  font-weight: var(--text-emphasis-02-weight);
  line-height: var(--text-emphasis-02-line-height);
}

/* ==========================================================================
   COLOR UTILITY CLASSES
   ========================================================================== */

.color-text-primary {
  color: var(--color-text-primary);
}

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

.color-text-subdued {
  color: var(--color-text-subdued);
}

.color-text-brand {
  color: var(--color-text-brand);
}

.color-text-on-brand {
  color: var(--color-text-on-brand);
}

.color-text-on-dark {
  color: var(--color-text-on-dark);
}

.color-bg-primary {
  background-color: var(--color-bg-primary);
}

.color-bg-secondary {
  background-color: var(--color-bg-secondary);
}

.color-bg-dark {
  background-color: var(--color-bg-dark);
}

.color-bg-brand {
  background-color: var(--color-bg-brand);
}

/* ==========================================================================
   SPACING UTILITY CLASSES
   ========================================================================== */

.p-xs { padding: var(--spacing-xs); }
.p-sm { padding: var(--spacing-sm); }
.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }
.p-xl { padding: var(--spacing-xl); }

.m-xs { margin: var(--spacing-xs); }
.m-sm { margin: var(--spacing-sm); }
.m-md { margin: var(--spacing-md); }
.m-lg { margin: var(--spacing-lg); }
.m-xl { margin: var(--spacing-xl); }

/* ==========================================================================
   LAYOUT UTILITY CLASSES
   ========================================================================== */

.flex { display: flex; }
.flex-column { flex-direction: column; }
.flex-center { justify-content: center; align-items: center; }
.flex-between { justify-content: space-between; }
.flex-gap-sm { gap: var(--spacing-sm); }
.flex-gap-md { gap: var(--spacing-md); }
.flex-gap-lg { gap: var(--spacing-lg); }

.border-radius-sm { border-radius: var(--radius-sm); }
.border-radius-md { border-radius: var(--radius-md); }
.border-radius-lg { border-radius: var(--radius-lg); }

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

.transition-fast { transition: all var(--transition-fast); }
.transition-normal { transition: all var(--transition-normal); }
.transition-slow { transition: all var(--transition-slow); }

/* ==========================================================================
   BUTTON COMPONENTS
   ========================================================================== */

.btn {
  display: flex;
  justify-content: center;
  align-items: center;
  border: none;
  cursor: pointer;
  font-family: var(--font-family-primary);
  font-weight: var(--text-emphasis-02-weight);
  transition: all var(--transition-normal);
  border-radius: var(--radius-md);
}

.btn-primary {
  background: var(--color-bg-brand);
  color: var(--color-text-on-brand);
  padding: var(--spacing-md) var(--spacing-xl);
}

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

.btn-secondary {
  background: transparent;
  color: var(--color-text-brand);
  border: 1px solid var(--color-border-interactive);
  padding: var(--spacing-md) var(--spacing-xl);
}

.btn-secondary:hover {
  border-color: var(--color-border-brand);
  background: var(--color-brand-primary-light);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-brand);
  padding: var(--spacing-md) var(--spacing-xl);
}

.btn-ghost:hover {
  background: var(--color-bg-overlay);
}

/* ==========================================================================
   CARD COMPONENTS
   ========================================================================== */

.card {
  background: var(--color-bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.card-body {
  padding: var(--spacing-lg);
}

.card-footer {
  padding: var(--spacing-md) var(--spacing-lg);
  border-top: 1px solid var(--color-border-default);
}

/* ==========================================================================
   ICON COMPONENTS
   ========================================================================== */

.icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-normal);
}

.icon-sm { width: 12px; height: 12px; }
.icon-md { width: 16px; height: 16px; }
.icon-lg { width: 20px; height: 20px; }

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

/* ==========================================================================
   DEVELOPMENT UTILITIES
   ========================================================================== */

.component-boundary {
  border: 2px dashed rgba(0, 122, 255, 0.3);
  padding: var(--spacing-sm);
  margin: var(--spacing-sm);
}

.placeholder {
  background: var(--color-bg-secondary);
  color: var(--color-text-secondary);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  text-align: center;
  font-style: italic;
}

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

@keyframes sheen-33 {
  0% { left: -50px; }
  to { left: calc(33.33% - 8px); }
}

@keyframes sheen-66 {
  0% { left: -50px; }
  to { left: calc(66.67% - 4px); }
}

@keyframes sheen-100 {
  0% { left: -50px; }
  to { left: calc(100% + 25px); }
}

@keyframes sparkle-scale-1 {
  0%, to { transform: scale(1); }
  30% { transform: scale(1.25); }
}

@keyframes sparkle-scale-2 {
  0%, to { transform: scale(1); }
  50% { transform: scale(1.25); }
}

@keyframes sparkle-scale-3 {
  0%, to { transform: scale(1); }
  70% { transform: scale(1.25); }
}

@keyframes shimmer {
  0% { left: -100%; }
  to { left: 100%; }
}

@keyframes sparkle {
  0%, to { 
    transform: scale(1) rotate(0);
    opacity: 1;
  }
  50% { 
    transform: scale(1.1) rotate(180deg);
    opacity: 0.8;
  }
}

@keyframes fadeIn {
  0% { 
    opacity: 0;
    transform: translateY(10px);
  }
  to { 
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  0% { 
    transform: translate(-100%);
    opacity: 0;
  }
  to { 
    transform: translate(0);
    opacity: 1;
  }
}

.animate-shimmer { animation: shimmer 2s infinite; }
.animate-sparkle { animation: sparkle 2s ease-in-out infinite; }
.animate-fadeIn { animation: fadeIn 0.3s ease-out; }
.animate-slideIn { animation: slideIn 0.4s ease-out; }

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

@media (max-width: 480px) {
  :root {
    --text-display-size: 1.5rem;
    --spacing-lg: 12px;
    --spacing-xl: 16px;
  }
  
  .app {
    padding: var(--spacing-md);
  }
  
  .app-title {
    font-size: var(--text-display-size);
    margin-bottom: var(--spacing-lg);
  }
  
  .state-selector {
    margin-bottom: var(--spacing-2xl);
  }
  
  .state-buttons {
    flex-direction: column;
    gap: var(--spacing-sm);
  }
  
  .state-buttons button {
    min-width: auto;
    width: 100%;
  }
  
  .order-card {
    width: calc(100% - calc(var(--spacing-lg) * 2));
    margin: var(--spacing-lg);
  }
  
  .card-header {
    padding: var(--spacing-sm) var(--spacing-md) var(--spacing-xs);
  }
  
  .order-details {
    padding: 0 var(--spacing-md) var(--spacing-sm);
  }
  
  .status-section {
    padding: var(--spacing-sm) var(--spacing-md) var(--spacing-md);
  }
  
  .card {
    margin: var(--spacing-md);
    width: calc(100% - calc(var(--spacing-md) * 2));
  }
}

/* ==========================================================================
   ACCESSIBILITY MEDIA QUERIES
   ========================================================================== */

@media (prefers-contrast: high) {
  :root {
    --color-border-default: #000000;
    --color-text-secondary: #000000;
  }
  
  .progress-segment.active {
    background: #000;
  }
  
  .status-text,
  .lottery-name {
    color: #000;
  }
  
  .app-title {
    color: #fff;
  }
  
  .state-buttons button {
    border-color: #fff;
    color: #fff;
  }
  
  .state-buttons button.active {
    background: #fff;
    color: #000;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .status-icon svg,
  .progress-bar:before,
  .action-btn {
    animation: none !important;
    transition: none !important;
  }
  
  .state-buttons button {
    transition: none !important;
  }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 12pt;
    line-height: 1.4;
  }
  
  .app {
    background: #fff;
    color: #000;
  }
  
  .order-card {
    box-shadow: none;
    border: 1px solid var(--color-border-default);
  }
  
  .action-buttons,
  .state-selector {
    display: none;
  }
  
  .no-print {
    display: none !important;
  }
  
  .print-only {
    display: block !important;
  }
} 