/**
 * TheNuts.gg - Main Stylesheet
 *
 * ARCHITECTURE:
 * 1. CSS Variables (Design Tokens)
 * 2. Reset & Base Elements
 * 3. Typography (h1-h6, p, display sizes)
 * 4. Utility Classes
 * 5. Generic Component Patterns
 * 6. Layout Primitives
 * 7. Game-Specific Components
 *
 * PRINCIPLES:
 * - Semantic HTML first - style h1-h6, button, p properly
 * - Generic patterns not page-specific - `.card` not `.splash-card`
 * - Composition over custom classes - combine existing patterns
 * - Modifier classes for variation - `.display-1`, `.bright-text`
 */

/* ============================================================================
   1. CSS VARIABLES - Design Tokens
   ============================================================================ */

:root {
  /* Colors - Primary */
  --color-gold: #d4af37;
  --color-green-dark: #0d2818;
  --color-green-felt: #1a5f3f;
  --color-green-border: #2d5a3f;

  /* Colors - Feedback */
  --color-correct: #10b981;
  --color-wrong: #ef4444;

  /* Colors - Neutrals */
  --color-bg-dark: #0a0e1a;
  --color-text-primary: #fff;
  --color-text-secondary: #cbd5e1;
  --color-text-muted: #94a3b8;
  --color-text-faint: #64748b;

  /* Spacing */
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 40px;

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-gold: 0 4px 20px rgba(212, 175, 55, 0.4);
  --shadow-gold-lg: 0 8px 32px rgba(212, 175, 55, 0.3);
}

/* ============================================================================
   2. RESET & BASE ELEMENTS
   ============================================================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--color-bg-dark);
  color: var(--color-text-primary);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 6px;
}

#app {
  width: 100%;
  max-width: 375px;
  background: radial-gradient(ellipse at center, var(--color-green-felt) 0%, var(--color-green-dark) 100%);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
  border: 3px solid var(--color-green-border);
}

a {
  color: var(--color-gold);
  text-decoration: none;
  transition: opacity 0.2s;
}

a:hover {
  opacity: 0.8;
}

/* ============================================================================
   3. TYPOGRAPHY - Semantic HTML
   ============================================================================ */

/* Base heading styles */
h1, h2, h3, h4, h5, h6 {
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 1px;
}

h2 {
  font-size: 15px;
  font-weight: 800;
}

h3, h4 {
  font-size: 10px;
  margin-bottom: 3px;
}

h3 {
  font-weight: 700;
}

h4 {
  font-weight: 600;
  letter-spacing: 1px;
}

h5 {
  font-size: 9px;
  font-weight: 600;
  margin-bottom: 3px;
}

h6 {
  font-size: 9px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: none;
  letter-spacing: normal;
}

p {
  line-height: 1.5;
  color: var(--color-text-secondary);
}

/* Display sizes - For when h1-h6 aren't big enough */
.display-1 {
  font-size: 64px;
  font-weight: 900;
  letter-spacing: -2px;
  line-height: 1;
}

.display-2 {
  font-size: 48px;
  font-weight: 900;
  letter-spacing: 2px;
  line-height: 1.2;
}

.display-3 {
  font-size: 32px;
  font-weight: 900;
  line-height: 1.2;
}

/* Text size utilities (non-uppercase variants) */
.t2 {
  font-size: 15px;
  font-weight: 800;
  color: var(--color-text-muted);
  letter-spacing: 1.5px;
}

.t3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.t4 {
  font-size: 10px;
  font-weight: 500;
  color: var(--color-text-muted);
}

/* Subtitle pattern */
.subtitle {
  font-size: 16px;
  font-weight: 300;
  text-align: center;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: var(--space-lg);
}

/* ============================================================================
   4. UTILITY CLASSES
   ============================================================================ */

/* Color modifiers */
.bright-text {
  color: var(--color-gold);
}

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

.bonus {
  color: var(--color-correct);
  margin-left: 6px;
}

.penalty {
  color: var(--color-wrong);
  margin-left: 6px;
}

/* Alignment */
.center {
  text-align: center;
}

/* Feedback colors */
.feedback-correct,
.feedback-wrong {
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.feedback-correct {
  color: var(--color-correct) !important;
}

.feedback-wrong {
  color: var(--color-wrong) !important;
}

/* ============================================================================
   5. GENERIC COMPONENT PATTERNS
   ============================================================================ */

/* Buttons */
button {
  background: transparent;
  border: 1px solid var(--color-gold);
  color: var(--color-gold);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s;
  font-family: inherit;
}

button:hover {
  background: var(--color-gold);
  color: var(--color-bg-dark);
}

.cta-button {
  width: 100%;
  padding: 16px;
  background: var(--color-gold);
  border: none;
  border-radius: var(--radius-md);
  color: var(--color-bg-dark);
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow-gold);
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: var(--space-sm);
}

.cta-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(212, 175, 55, 0.5);
}

.cta-button:active {
  transform: translateY(0);
}

/* Form Elements */
input[type="text"],
input[type="email"],
input[type="password"] {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(212, 175, 55, 0.3);
  color: var(--color-text-primary);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  transition: all 0.2s;
  width: 100%;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--color-gold);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.2);
}

input[type="text"]::placeholder,
input[type="email"]::placeholder,
input[type="password"]::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-right: 10px;
  cursor: pointer;
  accent-color: var(--color-gold);
}

label {
  color: var(--color-text-secondary);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

/* Card Pattern */
.card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.card p {
  margin: 0;
  font-size: 15px;
  color: var(--color-text-secondary);
}

.card-feature {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: var(--radius-md);
  transition: all 0.2s;
}

.card-feature:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(212, 175, 55, 0.4);
}

.card-feature p {
  margin: 0;
  color: var(--color-text-secondary);
}

/* Score Display Pattern */
.score-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-lg);
  background: rgba(212, 175, 55, 0.05);
  border: 2px solid var(--color-gold);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-gold-lg);
}

/* Result List Pattern */
.result-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.result-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: var(--space-md);
  align-items: center;
  padding: var(--space-md);
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: all 0.2s;
}

.result-item--success {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.05);
}

.result-item--error {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.05);
}

/* Status Badge */
.status-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  color: var(--color-text-primary);
}

.status-badge--success {
  background: var(--color-correct);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.status-badge--error {
  background: var(--color-wrong);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* Code Preview / Share Box */
.code-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--color-text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

/* Info Card Pattern */
.info-card {
  background: rgba(0,0,0,0.2);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255,255,255,0.05);
}

/* Highlight Card (for interactive selections) */
.highlight-card {
  position: relative;
  padding: 0;
  background: rgba(255,255,255,0.03);
  border: 2px solid rgba(212, 175, 55, 0.3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  justify-self: center;
  width: 104px;
  height: 120px;
}

.highlight-card:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(212, 175, 55, 0.5);
}

.highlight-card-bright {
  border-color: var(--color-gold);
  background: rgba(212, 175, 55, 0.1);
  box-shadow: var(--shadow-gold);
}

/* Answer Feedback States */
.correct-answer,
.wrong-answer {
  border-color: currentColor !important;
}

.correct-answer {
  --answer-color: 16, 185, 129;
  color: rgb(var(--answer-color));
  background: rgba(var(--answer-color), 0.2);
  box-shadow: 0 0 20px rgba(var(--answer-color), 0.4);
}

.wrong-answer {
  --answer-color: 239, 68, 68;
  color: rgb(var(--answer-color));
  background: rgba(var(--answer-color), 0.2);
  box-shadow: 0 0 20px rgba(var(--answer-color), 0.4);
}

/* Badge base styles for answer feedback */
.correct-answer::before,
.wrong-answer::before {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 900;
  z-index: 40;
}

.correct-answer::before {
  content: '✓';
  background: var(--color-correct);
  color: var(--color-text-primary);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.5);
}

.wrong-answer::before {
  content: '✗';
  background: var(--color-wrong);
  color: var(--color-text-primary);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.5);
}

/* ============================================================================
   6. LAYOUT PRIMITIVES
   ============================================================================ */

/* Page centered - for splash, post-game */
.page-centered {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-2xl) 20px;
  text-align: center;
}

/* Hero section */
.hero {
  max-width: 500px;
  margin-bottom: 60px;
}

/* Narrow content container */
.content-narrow {
  max-width: 500px;
  width: 100%;
}

/* Standard container */
.container {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: 20px var(--space-md);
}

/* Stack layout - vertical spacing */
.stack {
  display: flex;
  flex-direction: column;
}

.stack > * + * {
  margin-top: var(--space-lg);
}

/* Feature list */
.feature-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: var(--space-2xl);
  text-align: left;
}

/* ============================================================================
   7. GAME-SPECIFIC COMPONENTS
   ============================================================================ */

/* Felt (poker table surface) */
.felt {
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Cards container - centers card display */
.cards-container {
  display: flex;
  justify-content: center;
  gap: 8px;
}

/* Flop cards container */
.flop-header {
  display: flex;
  position: relative;
  justify-content: center;
  height: 64px;
  align-items: center;
}

/* Hand selection - Flexible for 2-8 hands */
.options-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 100%;
}

.option-cards {
  display: flex;
  justify-content: center;
  gap: 8px;
}

/* Breakdown layouts */
.breakdown-stagger {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.breakdown-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.breakdown-col.left {
  align-items: flex-end;
}

.breakdown-col.right {
  align-items: flex-start;
}

.breakdown-row {
  width: 100%;
}

.breakdown-row-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.breakdown-cards {
  display: flex;
  position: relative;
  height: 38px;
}

/* Date row - date centered, button on right */
.date-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
}

.date-row h2 {
  grid-column: 2;
  text-align: center;
}

.date-row .help-button {
  grid-column: 3;
  justify-self: end;
}

.date-row h2 {
  margin: 0;
}

/* Help button */
.help-button {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid rgba(212, 175, 55, 0.25);
  color: rgba(212, 175, 55, 0.6);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
  line-height: 1;
}

.help-button:hover {
  background: rgba(212, 175, 55, 0.25);
  border-color: var(--color-gold);
}

/* Help icon */
.help-icon {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--color-gold);
  cursor: pointer;
  transition: all 0.2s;
}

.help-icon:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--color-gold);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.open {
  display: flex;
}

.modal-content {
  background: var(--color-bg-dark);
  border: 2px solid var(--color-gold);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: transparent;
  border: none;
  color: var(--color-gold);
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.modal-close:hover {
  transform: scale(1.2);
  background: transparent;
  color: var(--color-gold);
}

.modal h2 {
  margin-bottom: var(--space-lg);
}

.modal-section {
  margin-bottom: var(--space-lg);
}

.modal-section:last-child {
  margin-bottom: 0;
}

/* ============================================================================
   PAGE-SPECIFIC ADJUSTMENTS
   (Use sparingly - prefer generic patterns above)
   ============================================================================ */

/* Page wrapper for non-centered pages */
.page {
  /* No min-height - let content determine height */
}

.page-content {
  flex: 1;
}

/* Account page sections */
.profile-section,
.preferences-section,
.danger-zone {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: var(--space-lg);
}

.profile-section h2,
.preferences-section h2,
.danger-zone h2 {
  margin-bottom: var(--space-md);
  color: var(--color-gold);
}

.danger-zone {
  border-color: rgba(239, 68, 68, 0.3);
}

.danger-zone h2 {
  color: var(--color-wrong);
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.preference-item {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.preference-item:last-child {
  border-bottom: none;
}

/* ============================================================================
   Post-Game Round Results - Two Column Layout
   ============================================================================ */

.rounds-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.rounds-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rounds-col.left {
  align-items: flex-end;
}

.rounds-col.right {
  align-items: flex-start;
}

.round-result {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  padding: 8px;
}

.round-result.correct {
  background: rgba(16, 185, 129, 0.15);
}

.round-result.wrong {
  background: rgba(239, 68, 68, 0.15);
}

.round-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.round-number {
  font-size: 9px;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
}

.your-choice {
  display: flex;
  gap: 3px;
  align-items: center;
}

.round-points {
  font-size: 14px;
  font-weight: 800;
}

.round-result.correct .round-points {
  color: var(--color-correct);
}

.round-result.wrong .round-points {
  color: var(--color-wrong);
}

.pocket-card {
  width: 20px;
  height: 28px;
  background: white;
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.pocket-card.red {
  color: #dc2626;
}

.pocket-card.black {
  color: #0f172a;
}

.pocket-card .suit {
  font-size: 8px;
  line-height: 1;
}

.ranking-text {
  font-size: 9px;
  color: var(--color-text-muted);
  font-weight: 600;
  text-transform: lowercase;
}

.round-result.correct .ranking-text {
  color: var(--color-correct);
}

.round-result.wrong .ranking-text {
  color: var(--color-wrong);
}

/* ============================================================================
   Game Page - Hand Equity & Draw Name
   ============================================================================ */

/* Hand title (pocket name) - absolute at top */
.highlight-card h4 {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  line-height: 16px;
  margin: 0;
  padding: 2px 0;
  z-index: 30;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  background: #173e2a94;
  text-align: center;
}

/* Cards container - absolute centered */
.highlight-card .option-cards {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
}

/* Draw name - absolute, bottom third, above progress bar */
.hand-draw-name {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  line-height: 14px;
  font-size: 11px;
  padding: 2px 0;
  color: var(--color-text-secondary);
  font-weight: 600;
  z-index: 30;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  background: #173e2a94;
  text-align: center;
}

/* Equity display (progress bar) - absolute at bottom */
.hand-equity {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
}

.hand-equity .rank-emoji {
  font-size: 24px;
}

/* ============================================================================
   Splash Page - Starfield Landing
   ============================================================================ */

/* Content overlay positioned over starfield */
.content-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 40px 0;
  padding-bottom: max(40px, env(safe-area-inset-bottom));
  z-index: 100;
  pointer-events: none;
  overflow: hidden;
}

.content-overlay > * {
  pointer-events: auto;
}

/* Login button positioning */
.login-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
}

/* Logo styling with animated gradient */
.logo {
  font-size: 72px;
  font-weight: 900;
  background: linear-gradient(135deg, #d4af37 0%, #ffd700 50%, #d4af37 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s ease-in-out infinite;
  letter-spacing: 8px;
  text-align: center;
  margin-bottom: 20px;
  filter: drop-shadow(0 0 30px rgba(212, 175, 55, 0.6));
}

@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* Starfield container - positions the starfield background */
#starfield {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
}

/* Responsive */
@media (max-width: 768px) {
  .logo { font-size: 48px; letter-spacing: 4px; }
}
