/* ============ ONBOARDING OVERLAY — Warm 3-Step Flow ============ */

.onboarding-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #FFF8F0 0%, #FFF1E0 35%, #FFE8CC 70%, #FFDDB8 100%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeIn 0.4s ease;
  overflow: hidden;
  font-family: 'Noto Sans Tamil', sans-serif;
}
.onboarding-overlay.hiding {
  animation: fadeOut 0.35s ease forwards;
  pointer-events: none;
}

/* Help button — sits in the game header, outside onboarding */
.help-btn {
  background: none;
  border: 1.5px solid var(--border);
  color: var(--text-dim);
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-family: 'Noto Sans Tamil', sans-serif;
  font-size: 15px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  z-index: 50;
  position: relative;
}
.help-btn:hover { background: var(--surface-hover); color: var(--accent); border-color: var(--accent); }

/* ============ HEADER ============ */
.ob-header {
  width: 100%;
  max-width: 500px;
  padding: 16px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}
.ob-logo {
  font-size: 26px;
  font-weight: 800;
  color: #2C1810;
  letter-spacing: -0.5px;
}
.ob-tagline {
  font-size: 12px;
  color: #9B8570;
  margin-left: 10px;
  font-weight: 500;
}
.ob-close {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: 1.5px solid #E0D0C0;
  color: #A89070;
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.ob-close:hover {
  background: rgba(0,0,0,0.05);
  color: #2C1810;
  border-color: #B8A088;
}

/* ============ STEP CONTAINER & TRANSITIONS ============ */
.step-container {
  flex: 1;
  width: 100%;
  max-width: 500px;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0 20px;
}
.step-container.exit-left .step.active {
  animation: slideExitLeft 0.3s ease forwards;
}
.step-container.exit-right .step.active {
  animation: slideExitRight 0.3s ease forwards;
}
.step-container.enter .step.active {
  animation: slideEnter 0.3s ease forwards;
}

.step {
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 10px 0 20px;
  min-height: 100%;
}
.step.active {
  display: flex;
}

/* ============ PROGRESS DOTS ============ */
.progress {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  flex-shrink: 0;
}
.pdot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #E0D0C0;
  transition: all 0.4s ease;
}
.pdot.active {
  background: #B8860B;
  width: 28px;
  border-radius: 4px;
}
.pdot.done {
  background: #D4A853;
}

/* ============ NAVIGATION ============ */
.nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 8px 20px 6px;
  width: 100%;
  max-width: 500px;
  flex-shrink: 0;
}
.btn-back, .btn-next {
  font-family: 'Noto Sans Tamil', sans-serif;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 28px;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-back {
  background: transparent;
  color: #6B5040;
  border: 1.5px solid #D4C4B0;
}
.btn-back:hover { background: rgba(0,0,0,0.04); }
.btn-next {
  background: #2C1810;
  color: #FFF3E6;
}
.btn-next:hover { background: #3D2A1E; }
.btn-back.hidden, .btn-next.hidden {
  visibility: hidden;
  pointer-events: none;
}

/* Skip link */
.skip-wrap {
  text-align: center;
  padding: 4px 0 12px;
  flex-shrink: 0;
}
.btn-skip {
  background: none;
  border: none;
  color: #B8A088;
  font-family: 'Noto Sans Tamil', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 4px 8px;
}
.btn-skip:hover { color: #6B5040; }
.skip-wrap.hidden { display: none; }

/* ============ STEP 0: WELCOME / HOW TO ============ */
.welcome-icon {
  font-size: 52px;
  margin-top: 20px;
  opacity: 0;
}
.step.animate .welcome-icon {
  animation: fadeSlideUp 0.5s ease 0.1s forwards;
}
.welcome-title {
  font-size: 32px;
  font-weight: 800;
  color: #2C1810;
  margin: 8px 0 4px;
  opacity: 0;
}
.step.animate .welcome-title {
  animation: fadeSlideUp 0.5s ease 0.2s forwards;
}
.welcome-sub {
  font-size: 15px;
  color: #6B5040;
  text-align: center;
  line-height: 1.6;
  margin: 0 0 24px;
  opacity: 0;
}
.step.animate .welcome-sub {
  animation: fadeSlideUp 0.5s ease 0.35s forwards;
}

.howto-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 340px;
}
.howto-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255,255,255,0.6);
  border-radius: 14px;
  padding: 14px 16px;
  border: 1px solid #F0E0D0;
  opacity: 0;
}
.step.animate .howto-item:nth-child(1) { animation: fadeSlideUp 0.5s ease 0.45s forwards; }
.step.animate .howto-item:nth-child(2) { animation: fadeSlideUp 0.5s ease 0.55s forwards; }
.step.animate .howto-item:nth-child(3) { animation: fadeSlideUp 0.5s ease 0.65s forwards; }

.howto-icon {
  font-size: 24px;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}
.howto-text {
  font-size: 14px;
  color: #2C1810;
  font-weight: 500;
  line-height: 1.5;
}

/* ============ STEP 1: INTERACTIVE DEMO ============ */
.demo-title {
  font-size: 22px;
  font-weight: 700;
  color: #2C1810;
  margin: 12px 0 4px;
  text-align: center;
}
.demo-subtitle {
  font-size: 14px;
  color: #6B5040;
  text-align: center;
  margin: 0 0 16px;
}

.demo-solved-area {
  width: 100%;
  max-width: 360px;
}
.demo-solved {
  border-radius: 12px;
  padding: 10px 14px;
  text-align: center;
  margin-bottom: 8px;
  opacity: 0;
  transform: scale(0.8);
}
.demo-solved.revealing {
  animation: demoGroupPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.ds-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.ds-words {
  font-size: 15px;
  font-weight: 500;
  color: #2C1810;
}

.demo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}
.demo-cell {
  background: #FFFBF5;
  border: 1.5px solid #E8DDD0;
  border-radius: 12px;
  padding: 12px 4px;
  text-align: center;
  font-family: 'Noto Sans Tamil', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #2C1810;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.3;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
  opacity: 0;
  animation: demoCellFadeIn 0.3s ease forwards;
}
.demo-cell:nth-child(1) { animation-delay: 0.05s; }
.demo-cell:nth-child(2) { animation-delay: 0.1s; }
.demo-cell:nth-child(3) { animation-delay: 0.15s; }
.demo-cell:nth-child(4) { animation-delay: 0.2s; }
.demo-cell:nth-child(5) { animation-delay: 0.25s; }
.demo-cell:nth-child(6) { animation-delay: 0.3s; }
.demo-cell:nth-child(7) { animation-delay: 0.35s; }
.demo-cell:nth-child(8) { animation-delay: 0.4s; }

.demo-cell:hover {
  background: #FFF5E0;
  border-color: #D4C4B0;
}
.demo-cell.selected {
  background: #FFF5E0;
  border-color: #B8860B;
  color: #B8860B;
  transform: scale(0.94);
  box-shadow: 0 0 0 2px rgba(184,134,11,0.15);
}
.demo-cell.shake {
  animation: shake 0.5s ease-in-out;
}

/* Check button */
.demo-check {
  display: block;
  margin: 14px auto 0;
  font-family: 'Noto Sans Tamil', sans-serif;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 32px;
  border-radius: 50px;
  border: none;
  background: #E8DDD0;
  color: #9B8570;
  cursor: default;
  transition: all 0.3s cubic-bezier(0.34, 1.2, 0.64, 1);
}
.demo-check.ready {
  background: #2C1810;
  color: #FFF3E6;
  cursor: pointer;
  transform: scale(1.05);
}
.demo-check.ready:hover {
  background: #3D2A1E;
}

/* Success message */
.demo-success-msg {
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: #2E7D32;
  margin-top: 12px;
  opacity: 0;
}
.demo-success-msg.visible {
  animation: fadeSlideUp 0.4s ease forwards;
}

/* Hint */
.demo-hint {
  text-align: center;
  font-size: 13px;
  color: #B8A088;
  margin-top: 12px;
  transition: opacity 0.3s;
}
.demo-hint.hidden {
  opacity: 0;
}

/* ============ STEP 2: READY ============ */
.ready-icon {
  font-size: 52px;
  margin-top: 30px;
  opacity: 0;
}
.step.animate .ready-icon {
  animation: fadeSlideUp 0.5s ease 0.1s forwards;
}
.ready-title {
  font-size: 32px;
  font-weight: 800;
  color: #2C1810;
  margin: 8px 0 8px;
  opacity: 0;
}
.step.animate .ready-title {
  animation: fadeSlideUp 0.5s ease 0.2s forwards;
}
.ready-desc {
  font-size: 15px;
  color: #6B5040;
  text-align: center;
  line-height: 1.6;
  margin: 0 0 24px;
  opacity: 0;
}
.step.animate .ready-desc {
  animation: fadeSlideUp 0.5s ease 0.3s forwards;
}

.ready-mistakes {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  margin-bottom: 28px;
  opacity: 0;
}
.step.animate .ready-mistakes {
  animation: fadeSlideUp 0.5s ease 0.4s forwards;
}
.ready-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #D4A853;
}
.ready-mistakes-label {
  font-size: 13px;
  color: #9B8570;
  margin-left: 4px;
}

.ready-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  opacity: 0;
}
.step.animate .ready-actions {
  animation: fadeSlideUp 0.5s ease 0.5s forwards;
}
.btn-start {
  font-family: 'Noto Sans Tamil', sans-serif;
  font-size: 18px;
  font-weight: 700;
  padding: 14px 48px;
  border-radius: 50px;
  border: none;
  background: #2C1810;
  color: #FFF3E6;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-start:hover { background: #3D2A1E; transform: scale(1.03); }
.btn-start:active { transform: scale(0.97); }
.btn-review {
  font-family: 'Noto Sans Tamil', sans-serif;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 20px;
  border-radius: 50px;
  border: 1.5px solid #D4C4B0;
  background: transparent;
  color: #6B5040;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-review:hover { background: rgba(0,0,0,0.04); }

/* ============ ONBOARDING KEYFRAMES ============ */
/* fadeIn, shake, toastIn, toastOut already exist in style.css — not redefined here */

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes demoGroupPop {
  0% { opacity: 0; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes demoCellFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideExitLeft {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(-40px); }
}
@keyframes slideExitRight {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}
@keyframes slideEnter {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 380px) {
  .demo-cell { font-size: 12px; padding: 10px 3px; min-height: 42px; }
  .ob-logo { font-size: 22px; }
  .welcome-title, .ready-title { font-size: 26px; }
  .welcome-icon, .ready-icon { font-size: 42px; }
  .btn-start { font-size: 16px; padding: 12px 40px; }
  .howto-item { padding: 10px 12px; }
  .howto-text { font-size: 13px; }
}
@media (min-width: 500px) {
  .demo-cell { font-size: 16px; padding: 14px 6px; min-height: 54px; }
}

/* ============ REDUCED MOTION ============ */
@media (prefers-reduced-motion: reduce) {
  .onboarding-overlay,
  .step,
  .step.active,
  .demo-cell,
  .demo-solved,
  .demo-check,
  .demo-success-msg,
  .welcome-icon,
  .welcome-title,
  .welcome-sub,
  .howto-item,
  .ready-icon,
  .ready-title,
  .ready-desc,
  .ready-mistakes,
  .ready-actions,
  .step-container.exit-left .step.active,
  .step-container.exit-right .step.active,
  .step-container.enter .step.active {
    animation-duration: 0.01ms !important;
    animation-delay: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
