/* =============================================
   components.css — modals, toast, chart, misc
   iOS 26 Liquid Glass edition
   ============================================= */

/* ========== MODAL OVERLAY ========== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(5,3,12,0.55);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  z-index: 100;
  display: flex; align-items: flex-end;
  transition: opacity 0.3s ease, backdrop-filter 0.3s ease;
}
.modal-overlay.hidden { opacity: 0; pointer-events: none; }

.modal-sheet {
  width: 100%;
  border-radius: 32px 32px 0 0;
  padding: 16px 20px calc(var(--safe-bottom) + 24px);
  background: rgba(14,10,26,0.92);
  backdrop-filter: blur(40px) saturate(200%);
  -webkit-backdrop-filter: blur(40px) saturate(200%);
  border-top: 1px solid rgba(255,255,255,0.14);
  /* Specular rim on top edge */
  box-shadow:
    0 -1px 0 rgba(255,255,255,0.18),
    0 -24px 60px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.1);
  max-height: 90vh;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  transform: translateY(0);
  transition: transform 0.38s cubic-bezier(0.32,0.72,0,1);
  position: relative;
}
.modal-overlay.hidden .modal-sheet { transform: translateY(100%); }

/* Sheet shimmer bar */
.modal-handle {
  width: 40px; height: 4px;
  background: rgba(255,255,255,0.18);
  border-radius: 2px;
  margin: 0 auto 22px;
  position: relative;
  overflow: hidden;
}
.modal-handle::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
  animation: handleShimmer 2.5s ease-in-out infinite;
}
@keyframes handleShimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(200%);  }
}

.modal-title {
  font-family: var(--font-display);
  font-size: 21px; font-weight: 700; letter-spacing: -0.5px;
  margin-bottom: 20px;
}

/* ========== ADD QUESTION MODAL ========== */
.answer-inputs  { display: flex; flex-direction: column; gap: 8px; }
.answer-input-row { display: flex; align-items: center; gap: 10px; }

.answer-indicator {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  flex-shrink: 0; cursor: pointer;
  transition: all 0.22s var(--spring-bounce);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
}
.answer-indicator.correct {
  background: var(--accent3); border-color: var(--accent3);
  color: #06200f; font-weight: 800;
  box-shadow: 0 0 10px rgba(95,255,176,0.4);
  transform: scale(1.1);
}

.btn-modal-save {
  width: 100%; padding: 17px;
  border-radius: var(--radius-lg); border: none;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  color: white; font-size: 16px; font-weight: 700;
  cursor: pointer; margin-top: 20px;
  box-shadow: 0 8px 28px rgba(124,108,255,0.3), inset 0 1px 0 rgba(255,255,255,0.3);
  transition: all 0.22s var(--spring-bounce);
  position: relative; overflow: hidden;
}
.btn-modal-save::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 60%);
  pointer-events: none;
}
.btn-modal-save:active { transform: scale(0.97); }

/* ========== FEEDBACK TOAST — iOS 26 pill style ========== */
.feedback-toast {
  position: fixed;
  top: calc(var(--safe-top) + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(-70px) scale(0.85);
  background: rgba(16,12,30,0.88);
  backdrop-filter: blur(24px) saturate(200%);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 24px;
  padding: 11px 22px;
  font-size: 14px; font-weight: 600;
  z-index: 200;
  opacity: 0;
  transition:
    opacity  0.35s var(--spring-bounce),
    transform 0.35s var(--spring-bounce);
  pointer-events: none;
  white-space: nowrap;
  box-shadow:
    0 4px 24px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.15),
    0 1px 0 rgba(0,0,0,0.2);
}
.feedback-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}
.feedback-toast.correct {
  color: var(--accent3);
  border-color: rgba(95,255,176,0.28);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4), 0 0 20px rgba(95,255,176,0.12), inset 0 1px 0 rgba(255,255,255,0.15);
}
.feedback-toast.wrong {
  color: var(--accent-danger);
  border-color: rgba(255,94,126,0.28);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4), 0 0 20px rgba(255,94,126,0.12), inset 0 1px 0 rgba(255,255,255,0.15);
}

/* ========== SOUND TOGGLE BUTTON ========== */
.sound-btn { position: relative; overflow: hidden; }
.sound-btn.muted {
  background: rgba(255,94,126,0.12) !important;
  border-color: rgba(255,94,126,0.28) !important;
  color: var(--accent-danger) !important;
}
.sound-btn::after {
  content: '';
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  opacity: 0; transform: scale(0);
  transition: all 0.4s ease;
}
.sound-btn.ping::after { opacity: 1; transform: scale(2.8); transition: none; }

/* ========== MASTERY PROGRESS CHART ========== */
.mastery-chart-wrap {
  border-radius: var(--radius-md);
  padding: 18px 16px 14px;
  margin-bottom: 14px;
}
.mastery-chart-title {
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 14px; letter-spacing: -0.1px;
  display: flex; align-items: center; justify-content: space-between;
}
.mastery-chart-title span { color: var(--accent3); font-size: 12px; }

.chart-bars {
  display: flex; align-items: flex-end; gap: 5px; height: 80px;
}
.chart-col {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 4px; height: 100%; justify-content: flex-end;
}
.chart-bar-track {
  width: 100%; background: rgba(255,255,255,0.05);
  border-radius: 6px 6px 4px 4px; height: 100%;
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.chart-bar-fill {
  width: 100%; border-radius: 5px 5px 3px 3px;
  transition: height 0.75s var(--spring-smooth);
}
.chart-bar-fill.level-0 { background: rgba(255,255,255,0.08); }
.chart-bar-fill.level-1 { background: linear-gradient(180deg, #ff9a5e, #cc5500); }
.chart-bar-fill.level-2 { background: linear-gradient(180deg, #ff9a5e, #cc5500); }
.chart-bar-fill.level-3 { background: linear-gradient(180deg, #ffce5e, #cc9900); }
.chart-bar-fill.level-4 { background: linear-gradient(180deg, #5eb8ff, #2266cc); }
.chart-bar-fill.level-5 {
  background: linear-gradient(180deg, #5fffb0, #1fcc66);
  box-shadow: 0 0 12px rgba(95,255,176,0.35);
}
.chart-label {
  font-size: 9px; color: var(--text-tertiary); text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%; padding: 0 1px;
}
.chart-legend {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.legend-item {
  display: flex; align-items: center; gap: 4px;
  font-size: 10px; color: var(--text-tertiary);
}
.legend-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.chart-empty { text-align: center; padding: 20px; color: var(--text-tertiary); font-size: 13px; }

/* ========== HIDDEN QUESTION TOGGLE ========== */
.question-item.is-hidden { opacity: 0.44; }
.question-item.is-hidden .question-item-text {
  text-decoration: line-through; color: var(--text-tertiary);
}
.question-hide-btn {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.11);
  color: var(--text-tertiary); font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: all 0.2s var(--spring-bounce); margin-right: 4px;
}
.question-hide-btn:active { background: rgba(255,255,255,0.14); }
.question-item.is-hidden .question-hide-btn {
  background: rgba(255,184,94,0.12); border-color: rgba(255,184,94,0.25);
  color: var(--accent-warm);
}
.hidden-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(255,184,94,0.12); border: 1px solid rgba(255,184,94,0.25);
  border-radius: 8px; padding: 2px 8px;
  font-size: 11px; font-weight: 600; color: var(--accent-warm);
  margin-left: 6px; vertical-align: middle;
}

/* ========== ANSWER COUNT STEPPER ========== */
.answer-count-row {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
}
.answer-count-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--text-tertiary); flex: 1;
}
.stepper {
  display: flex; align-items: center;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.13);
  border-radius: 14px; overflow: hidden;
}
.stepper-btn {
  width: 38px; height: 38px; border: none; background: transparent;
  color: var(--text-primary); font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease;
}
.stepper-btn:active { background: rgba(255,255,255,0.12); }
.stepper-btn:disabled { opacity: 0.28; cursor: default; }
.stepper-val {
  min-width: 30px; text-align: center;
  font-size: 16px; font-weight: 700; color: var(--text-primary);
}

/* ========== WRITTEN QUESTION ========== */
.question-type-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(124,108,255,0.12); border: 1px solid rgba(124,108,255,0.22);
  border-radius: 8px; padding: 2px 8px;
  font-size: 11px; font-weight: 600; color: var(--accent1);
  margin-left: 6px; vertical-align: middle;
}
.question-type-badge.written {
  background: rgba(198,110,255,0.12); border-color: rgba(198,110,255,0.25); color: var(--accent2);
}

.written-answer-zone { display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; }
.written-input-wrap {
  border-radius: var(--radius-md); padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.written-input {
  width: 100%;
  background: rgba(255,255,255,0.06); border: 1.5px solid rgba(255,255,255,0.14);
  border-radius: var(--radius-sm); padding: 15px 16px;
  color: var(--text-primary); font-size: 17px; font-family: var(--font-body);
  -webkit-user-select: text; user-select: text;
  outline: none; -webkit-appearance: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  text-align: center; letter-spacing: 0.5px;
}
.written-input:focus {
  border-color: rgba(124,108,255,0.55);
  box-shadow: 0 0 0 3px rgba(124,108,255,0.12);
}
.written-input::placeholder { color: var(--text-tertiary); }
.btn-submit-written {
  width: 100%; padding: 15px; border-radius: var(--radius-md); border: none;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  color: white; font-size: 16px; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 20px rgba(124,108,255,0.28);
  transition: all 0.2s var(--spring-bounce);
}
.btn-submit-written:active { transform: scale(0.97); }

/* ========== RESET STATS BUTTON ========== */
.btn-reset-stats {
  width: 100%; padding: 14px; border-radius: var(--radius-md);
  border: 1px solid rgba(255,184,94,0.24); background: rgba(255,184,94,0.06);
  color: var(--accent-warm); font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--spring-bounce);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-bottom: 14px;
}
.btn-reset-stats:active { background: rgba(255,184,94,0.14); transform: scale(0.98); }

/* ========== PARTICLE CANVAS (mastery burst) ========== */
#particle-canvas {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 300;
  opacity: 1;
}

/* ========== STREAK BADGE on home ========== */
.streak-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(255,215,0,0.12); border: 1px solid rgba(255,215,0,0.28);
  border-radius: 14px; padding: 5px 12px;
  font-size: 13px; font-weight: 700; color: var(--accent-gold);
  margin-top: 10px;
  animation: streakPulse 2.5s ease-in-out infinite;
}
@keyframes streakPulse {
  0%,100% { box-shadow: none; }
  50%     { box-shadow: 0 0 14px rgba(255,215,0,0.3); }
}

/* ========== MISC ========== */
.btn-danger {
  background: rgba(255,94,126,0.12); border: 1px solid rgba(255,94,126,0.24);
  color: var(--accent-danger); border-radius: var(--radius-sm);
  padding: 8px 14px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all 0.15s ease;
}
.btn-danger:active { background: rgba(255,94,126,0.22); }
