/* Memory Typing Game - Styles */
/* Minimalist Apple/Monkeytype inspired design */

.page-memory {
  min-height: 100vh;
  padding: 12px;
  background: transparent;
  color: var(--t-text-primary, #f8fafc);
  font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

[data-theme="light"] .page-memory {
  background: transparent;
  color: #0f172a;
}

.memory-container {
  width: 100%;
  max-width: 900px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Header */
.memory-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 4px;
}

.memory-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--t-text-primary, #f8fafc);
}

.memory-subtitle {
  font-size: 14px;
  color: var(--t-text-secondary, #94a3b8);
  margin: 0 0 6px;
}

[data-theme="light"] .memory-subtitle {
  color: #475569;
}

.memory-desc {
  font-size: 13px;
  color: var(--t-text-muted, #94a3b8);
  margin: 0;
}

[data-theme="light"] .memory-desc {
  color: #64748b;
}

/* Type Selector */
.memory-type-selector {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 10px;
  flex-wrap: wrap;
}

.memory-type-btn {
  min-height: 36px;
  padding: 8px 14px;
  background: var(--t-surface, rgba(255,255,255,0.05));
  border: 1px solid var(--t-border, rgba(255,255,255,0.15));
  border-radius: 10px;
  color: var(--t-text-secondary, #e5e7eb);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

[data-theme="light"] .memory-type-btn {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.1);
  color: #475569;
}

.memory-type-btn:hover {
  border-color: #38bdf8;
  color: #38bdf8;
}

.memory-type-btn.active {
  background: #38bdf8;
  border-color: #38bdf8;
  color: #ffffff;
}

/* Mode Selector */
.memory-mode-selector {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 8px;
  flex-wrap: wrap;
}

.memory-mode-btn {
  min-height: 40px;
  padding: 9px 16px;
  background: var(--t-surface, rgba(255,255,255,0.05));
  border: 1px solid var(--t-border, rgba(255,255,255,0.15));
  border-radius: 10px;
  color: var(--t-text-secondary, #e5e7eb);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

[data-theme="light"] .memory-mode-btn {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.1);
  color: #475569;
}

.memory-mode-btn:hover {
  border-color: #38bdf8;
  color: #38bdf8;
}

.memory-mode-btn.active {
  background: #38bdf8;
  border-color: #38bdf8;
  color: #ffffff;
}

.memory-romaji-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  margin-bottom: 2px;
  min-width: 0;
  width: auto;
  padding-inline: 18px;
  white-space: nowrap;
}

/* Settings Panel */
.memory-settings {
  margin-bottom: 32px;
  border: 1px solid var(--t-border, rgba(255,255,255,0.1));
  border-radius: 16px;
  overflow: hidden;
}

[data-theme="light"] .memory-settings {
  border-color: rgba(0,0,0,0.1);
}

.memory-settings-toggle {
  width: 100%;
  padding: 16px 20px;
  background: var(--t-surface, rgba(255,255,255,0.03));
  border: none;
  color: var(--t-text-primary, #f8fafc);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s ease;
}

[data-theme="light"] .memory-settings-toggle {
  background: #ffffff;
  color: #0f172a;
}

.memory-settings-toggle:hover {
  background: var(--t-surface-hover, rgba(255,255,255,0.06));
}

[data-theme="light"] .memory-settings-toggle:hover {
  background: #f8fafc;
}

.memory-settings-content {
  padding: 20px;
  background: var(--t-surface, rgba(255,255,255,0.02));
  display: flex;
  flex-direction: column;
  gap: 20px;
}

[data-theme="light"] .memory-settings-content {
  background: #ffffff;
}

.memory-settings-content.hidden {
  display: none;
}

.memory-setting {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.memory-setting label {
  font-size: 13px;
  font-weight: 500;
  color: var(--t-text-secondary, #e5e7eb);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

[data-theme="light"] .memory-setting label {
  color: #475569;
}

.memory-setting.checkbox label {
  text-transform: none;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.memory-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #38bdf8;
  cursor: pointer;
}

/* Segmented Control */
.memory-segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--t-surface, rgba(255,255,255,0.05));
  border-radius: 10px;
}

[data-theme="light"] .memory-segmented {
  background: rgba(0,0,0,0.04);
}

.memory-segment {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--t-text-muted, #bdbedb);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.15s ease;
}

[data-theme="light"] .memory-segment {
  color: #64748b;
}

.memory-segment:hover {
  color: var(--t-text-primary, #f8fafc);
}

[data-theme="light"] .memory-segment:hover {
  color: #0f172a;
}

.memory-segment.active {
  background: #38bdf8;
  color: #ffffff;
}

/* Slider */
.memory-slider {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--t-surface, rgba(255,255,255,0.1));
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

[data-theme="light"] .memory-slider {
  background: rgba(0,0,0,0.1);
}

.memory-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: #38bdf8;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.memory-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.memory-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: #38bdf8;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* Game Area */
.memory-game-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px;
  background: var(--t-surface, rgba(255,255,255,0.03));
  border-radius: 16px;
  border: 1px solid var(--t-border, rgba(255,255,255,0.08));
}

[data-theme="light"] .memory-game-area {
  background: #ffffff;
  border-color: rgba(0,0,0,0.08);
}

.memory-state-badge {
  padding: 6px 16px;
  background: rgba(56,189,248,0.15);
  color: #38bdf8;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: 20px;
  border: 1px solid rgba(56,189,248,0.3);
}

.memory-text-display {
  width: 100%;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 24px;
  background: rgba(28,28,27,0.52);
  border-radius: 14px;
  border: 1px solid var(--t-border, rgba(255,255,255,0.08));
  transition: all 0.3s ease;
}

[data-theme="light"] .memory-text-display {
  background: #ffffff;
  border-color: rgba(0,0,0,0.08);
}

.memory-text-display[contenteditable="true"] {
  outline: none;
  cursor: text;
  gap: 0;
  justify-content: flex-start;
  align-items: flex-start;
  text-align: left;
  padding: 18px 22px;
  font-size: 22px;
  line-height: 1.5;
  color: var(--t-text-primary, #f8fafc);
}

.memory-text-display[contenteditable="true"]:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56,189,248,0.15);
}

[data-theme="light"] .memory-text-display[contenteditable="true"] {
  color: #0f172a;
}

.memory-preview-text {
  font-size: 24px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--t-text-primary, #f8fafc);
  max-width: 720px;
  animation: fadeIn 0.3s ease;
}

.memory-preview-romaji {
  margin-top: 10px;
  font-size: 16px;
  line-height: 1.4;
  letter-spacing: 0.04em;
  color: var(--t-text-muted, #94a3b8);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  text-align: center;
  word-break: break-word;
}

[data-theme="light"] .memory-preview-text {
  color: #0f172a;
}

[data-theme="light"] .memory-preview-romaji {
  color: #64748b;
}

.memory-placeholder {
  font-size: 18px;
  color: var(--t-text-muted, #bdbedb);
}

[data-theme="light"] .memory-placeholder {
  color: #94a3b8;
}

.memory-placeholder.typing {
  animation: pulse 1.5s ease infinite;
}

.memory-hint {
  font-size: 14px;
  color: var(--t-text-muted, #bdbedb);
  font-style: italic;
}

[data-theme="light"] .memory-hint {
  color: #94a3b8;
}

.memory-timer {
  font-size: 40px;
  font-weight: 700;
  color: #38bdf8;
  font-variant-numeric: tabular-nums;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Input */
.memory-input-wrap {
  width: 100%;
  max-width: 600px;
}

.memory-input-wrap.hidden {
  display: none;
}

.memory-input {
  width: 100%;
  padding: 16px 20px;
  font-size: 20px;
  background: var(--t-surface, rgba(255,255,255,0.03));
  border: 2px solid var(--t-border, rgba(255,255,255,0.1));
  border-radius: 12px;
  color: var(--t-text-primary, #f8fafc);
  outline: none;
  transition: all 0.2s ease;
}

[data-theme="light"] .memory-input {
  background: #ffffff;
  border-color: rgba(0,0,0,0.1);
  color: #0f172a;
}

.memory-input:focus {
  border-color: #38bdf8;
  background: var(--t-surface-hover, rgba(255,255,255,0.05));
}

[data-theme="light"] .memory-input:focus {
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(56,189,248,0.15);
}

.memory-input::placeholder {
  color: var(--t-text-muted, #64748b);
}

/* Buttons */
.memory-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.memory-results-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.memory-results-modal.hidden {
  display: none;
}

.memory-results-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.6);
  backdrop-filter: blur(4px);
}

.memory-results-modal-content {
  position: relative;
  width: min(860px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  overflow-x: hidden;
  background: #0f172a;
  border: 1px solid var(--t-border, rgba(255,255,255,0.1));
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(2, 8, 23, 0.45);
  padding: 20px;
}

.memory-results-modal-content::-webkit-scrollbar {
  width: 8px;
}

.memory-results-modal-content::-webkit-scrollbar-track {
  background: transparent;
}

.memory-results-modal-content::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 8px;
}

[data-theme="light"] .memory-results-modal-content::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.3);
}

[data-theme="light"] .memory-results-modal-content {
  background: #ffffff;
  border-color: rgba(0,0,0,0.1);
}

.memory-results-modal-actions {
  margin-top: 18px;
  display: flex;
  justify-content: center;
  gap: 12px;
}

.memory-btn,
a.memory-btn {
  min-height: 44px;
  padding: 10px 24px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.memory-btn.primary {
  background: #38bdf8;
  color: #ffffff;
  border-color: #38bdf8;
}

.memory-btn.primary:hover {
  background: #0ea5e9;
  border-color: #0ea5e9;
  transform: translateY(-1px);
}

.memory-btn.secondary {
  background: transparent;
  color: var(--t-text-secondary, #e5e7eb);
  border-color: var(--t-border, rgba(255,255,255,0.2));
}

[data-theme="light"] .memory-btn.secondary {
  color: #475569;
  border-color: rgba(0,0,0,0.15);
}

.memory-btn.secondary:hover {
  border-color: #38bdf8;
  color: #38bdf8;
}

/* Stats Area */
.memory-stats {
  margin-top: 0;
  width: 100%;
  padding: 32px;
  background: var(--t-surface, rgba(255,255,255,0.02));
  border-radius: 20px;
  border: 1px solid var(--t-border, rgba(255,255,255,0.08));
  animation: slideUp 0.4s ease;
}

[data-theme="light"] .memory-stats {
  background: #ffffff;
  border-color: rgba(0,0,0,0.08);
}

.memory-stats.hidden {
  display: none;
}

.memory-stats.memory-stats-inline {
  margin-top: 0;
  width: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  animation: none;
}

[data-theme="light"] .memory-stats.memory-stats-inline {
  background: transparent;
  border-color: rgba(0,0,0,0.08);
}

.memory-message {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 14px;
}

.memory-message.perfect {
  background: rgba(34,197,94,0.15);
  color: #22c55e;
}

.memory-message.good {
  background: rgba(56,189,248,0.15);
  color: #0ea5e9;
}

.memory-message.weak {
  background: rgba(248,113,113,0.15);
  color: #f87171;
}

.memory-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.memory-stat-card {
  text-align: center;
  padding: 12px 10px;
  background: var(--t-surface, rgba(255,255,255,0.03));
  border-radius: 10px;
  border: 1px solid var(--t-border, rgba(255,255,255,0.06));
}

[data-theme="light"] .memory-stat-card {
  background: #f8fafc;
  border-color: rgba(0,0,0,0.06);
}

.memory-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: #38bdf8;
  margin-bottom: 4px;
}

.memory-stat-label {
  font-size: 12px;
  color: var(--t-text-muted, #bdbedb);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

[data-theme="light"] .memory-stat-label {
  color: #64748b;
}

/* Diff View */
.memory-diff-wrap {
  width: 100%;
  max-width: 100%;
  text-align: left;
}

.memory-diff-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--t-text-muted, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 16px 0 8px;
}

.memory-diff-text {
  font-size: 18px;
  line-height: 2;
  word-break: break-all;
  padding: 20px;
  background: var(--t-surface, rgba(255,255,255,0.03));
  border-radius: 12px;
}

[data-theme="light"] .memory-diff-text {
  background: #f8fafc;
}

.memory-original-text {
  font-size: 15px;
  line-height: 1.6;
  word-break: break-all;
  padding: 14px;
  background: rgba(15,23,42,0.45);
  border-radius: 10px;
  color: var(--t-text-primary, #f8fafc);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  white-space: pre-wrap;
}

[data-theme="light"] .memory-original-text {
  background: #f8fafc;
  color: #0f172a;
}

.memory-diff-char {
  display: inline-block;
  width: 20px;
  text-align: center;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.memory-diff-char.correct {
  color: #22c55e;
}

.memory-diff-char.wrong {
  color: #f87171;
  background: rgba(248,113,113,0.15);
  border-radius: 3px;
}

.memory-diff-char.missing {
  color: var(--t-text-muted, #64748b);
  opacity: 0.5;
}

.memory-typed-text {
  font-size: 15px;
  line-height: 1.6;
  color: var(--t-text-secondary, #e5e7eb);
  padding: 14px;
  background: rgba(15,23,42,0.45);
  border-radius: 10px;
  border-left: 3px solid #38bdf8;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  white-space: pre-wrap;
  word-break: break-all;
}

[data-theme="light"] .memory-typed-text {
  color: #475569;
  background: #f8fafc;
}

/* Notification */
.memory-notification {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 24px;
  background: #38bdf8;
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(56,189,248,0.3);
  animation: slideUp 0.3s ease;
  z-index: 1000;
}

.memory-notification.fade-out {
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
  transition: all 0.3s ease;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* Responsive */
@media (max-width: 640px) {
  .page-memory {
    padding: 12px;
  }
  
  .memory-title {
    font-size: 20px;
  }
  
  .memory-preview-text {
    font-size: 19px;
  }

  .memory-preview-romaji {
    font-size: 14px;
  }
  
  .memory-timer {
    font-size: 32px;
  }
  
  .memory-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  
  .memory-stat-card {
    padding: 12px 8px;
  }
  
  .memory-stat-value {
    font-size: 22px;
  }
  
  .memory-stat-label {
    font-size: 10px;
  }
  
  .memory-actions {
    flex-direction: column;
    width: 100%;
  }
  
  .memory-btn,
  a.memory-btn {
    width: 100%;
    justify-content: center;
  }
}

/* Focus states for accessibility */
.memory-btn:focus-visible,
a.memory-btn:focus-visible,
.memory-segment:focus-visible,
.memory-settings-toggle:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.memory-input:focus-visible {
  outline: none;
  border-color: #38bdf8;
}
