/*
 * RhythmWords v2 — style.css
 * Phase: E2.3 UI port (single-file partition per OQ-E2.3-1 default)
 * SPEC: 30_KNOWLEDGE/strategy/rhythmwords_v2_spec_v1.md §3.5 + §8
 * Source: ported from apps/rhythmwords/index.html (v1) lines 8-260
 * Additions: v2-NEW state divs (S-LOADING / S-LOAD-ERROR / S-QUOTA-BLOCKED) per SPEC §3.3
 */

/* ---------- Arcade back-button (preserved verbatim from v1 line 9-31) ---------- */
.arcade-back-btn {
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 99999;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid rgba(255, 107, 53, 0.4);
  color: #333;
  padding: 8px 14px;
  border-radius: 20px;
  text-decoration: none;
  font-family: sans-serif;
  font-size: 0.9rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.arcade-back-btn:active {
  transform: scale(0.95);
}

/* ---------- Reset (v1 line 33-37) ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ---------- Body / page chrome (v1 line 39-47) ---------- */
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ---------- Container (v1 line 49-56) ---------- */
.container {
  background: white;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  padding: 40px;
  max-width: 600px;
  width: 100%;
}

/* ---------- Header (v1 line 58-67) ---------- */
.header {
  text-align: center;
  margin-bottom: 30px;
}

.header h1 {
  font-size: 28px;
  color: #333;
  margin-bottom: 10px;
}

.lab-badge {
  font-size: 12px;
  color: #999;
  font-weight: normal;
  margin-left: 8px;
}

/* ---------- Auth slot (E2.5 F-19; EduAuth.renderAuthUI target) ---------- */
.auth-container {
  margin-top: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 32px;
}

/* ---------- Word display panel (v1 line 69-100) ---------- */
.word-display {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 15px;
  padding: 30px;
  margin-bottom: 30px;
  text-align: center;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.word-english {
  font-size: 48px;
  font-weight: bold;
  margin-bottom: 15px;
  letter-spacing: 2px;
}

.word-chinese {
  font-size: 24px;
  margin-bottom: 10px;
  opacity: 0.95;
}

.word-pos {
  font-size: 14px;
  opacity: 0.8;
  font-style: italic;
}

/* ---------- Counter (v1 line 102-108) ---------- */
.counter {
  text-align: center;
  color: #667eea;
  font-weight: 600;
  margin-bottom: 20px;
  font-size: 14px;
}

/* ---------- Controls section (v1 line 110-126) ---------- */
.controls-section {
  margin-bottom: 30px;
}

.control-group {
  margin-bottom: 20px;
}

.control-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  color: #333;
  font-size: 14px;
  font-weight: 600;
}

/* ---------- Form controls (v1 line 128-174) ---------- */
select,
input[type="range"] {
  width: 100%;
  padding: 10px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.3s ease;
}

select {
  cursor: pointer;
  background-color: #f8f8f8;
}

select:hover,
select:focus {
  border-color: #667eea;
  outline: none;
  background-color: #fff;
}

input[type="range"] {
  padding: 0;
  cursor: pointer;
  height: 6px;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #667eea;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #667eea;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

/* ---------- Buttons (v1 line 176-222) ---------- */
.buttons-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.buttons-row.full {
  grid-template-columns: 1fr;
}

button {
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.play-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 15px 30px;
  font-size: 18px;
  grid-column: 1 / -1;
}

.play-btn:hover:not(:disabled) {
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
  transform: translateY(-2px);
}

.nav-btn {
  background: #f0f0f0;
  color: #333;
}

.nav-btn:hover:not(:disabled) {
  background: #e0e0e0;
  transform: translateY(-2px);
}

.category-select {
  width: 100%;
  margin-bottom: 20px;
}

/* ---------- Info box (v1 line 229-241) ---------- */
.info-box {
  background: #f0f4ff;
  border-left: 4px solid #667eea;
  padding: 15px;
  border-radius: 8px;
  font-size: 13px;
  color: #555;
  margin-top: 20px;
}

.info-box strong {
  color: #333;
}

/* ---------- v2-NEW state surfaces (per SPEC §3.3 + §3.5) ---------- */

/* hidden by default; script.js toggles via .visible class */
.state-overlay {
  display: none;
}

.state-overlay.visible {
  display: block;
}

/* S-LOADING — spinner + label (per SPEC §3.3 row 2) */
.loading-state {
  background: #f0f4ff;
  border: 1px dashed #667eea;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  text-align: center;
  color: #555;
  font-size: 14px;
}

.loading-state .spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 3px solid rgba(102, 126, 234, 0.25);
  border-top-color: #667eea;
  border-radius: 50%;
  animation: rw-spin 0.9s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

@keyframes rw-spin {
  to { transform: rotate(360deg); }
}

/* S-LOAD-ERROR — red banner (per SPEC §3.3 row 3, §8.4 fallback) */
.load-error-state {
  background: #fff3f3;
  border: 1px solid #f5c2c2;
  border-left: 4px solid #d9534f;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
  color: #842029;
  font-size: 14px;
}

.load-error-state strong {
  color: #842029;
}

/* S-QUOTA-BLOCKED — yellow banner (per SPEC §3.3 row last + §6 quota model) */
.quota-blocked-state {
  background: #fff8e1;
  border: 1px solid #ffe0a3;
  border-left: 4px solid #f0ad4e;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
  color: #6b4f12;
  font-size: 14px;
}

.quota-blocked-state strong {
  color: #6b4f12;
}

/* ---------- Module-load diagnostic strip (kept for E2.3 dev-debug; hidden in production via .hidden) ---------- */
.module-status {
  font-family: monospace;
  font-size: 11px;
  color: #666;
  background: #fafafa;
  padding: 8px;
  border-radius: 4px;
  margin-top: 16px;
}

.hidden {
  display: none;
}

/* ---------- Responsive (v1 line 243-258) ---------- */
@media (max-width: 600px) {
  .container {
    padding: 20px;
  }

  .word-english {
    font-size: 36px;
  }

  .buttons-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .header h1 {
    font-size: 24px;
  }
}
