/* ==========================================================
   ITtest — ONBOARDING STYLES
   ITtest identity: BLACK/DARK + WHITE + BLUE/CYAN accent
   - FAQAT transform/opacity animatsiyalari (GPU friendly)
   - prefers-reduced-motion qo'llanadi
   - Desktop: robot chap tomonda + savol o'ngda (wide layout)
   - Mobile: app-like full width, sticky CTA, horizontal scroll YO'Q
   ========================================================== */

/* ---------- Overlay (full screen takeover) ---------- */
#onboardingRoot { display: none; }

#onboardingRoot.open {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: var(--bg);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  animation: obFadeIn .35s ease;
}

body.ob-lock { overflow: hidden; }

@keyframes obFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---------- Fon orb'lari (juda nozik) ---------- */
.ob-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.ob-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .16;
}

.ob-orb-1 {
  width: 420px; height: 420px;
  top: -140px; left: -120px;
  background: radial-gradient(circle, var(--primary), transparent 70%);
}

.ob-orb-2 {
  width: 360px; height: 360px;
  bottom: -120px; right: -100px;
  background: radial-gradient(circle, var(--secondary), transparent 70%);
}

.ob-orb-3 {
  width: 260px; height: 260px;
  top: 40%; left: 55%;
  background: radial-gradient(circle, var(--primary-hover), transparent 70%);
  opacity: .08;
}

/* ---------- Shell ---------- */
.ob-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 24px 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* ---------- Header ---------- */
.ob-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.ob-back {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform .15s ease;
}

.ob-back:hover { border-color: var(--border-focus); background: var(--card-hover); }
.ob-back:active { transform: scale(.96); }

.ob-logo {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ob-logo b { color: var(--secondary); font-weight: 800; }

.ob-step {
  margin-left: auto;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ob-skip {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), background var(--transition);
}

.ob-skip:hover { color: var(--text); background: var(--card); }

/* ---------- Progress ---------- */
.ob-progress {
  margin-top: 14px;
  height: 6px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  overflow: hidden;
}

.ob-progress-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  box-shadow: var(--glow-cyan);
  transition: width .45s var(--bounce);
}

/* ---------- Body: desktop split ---------- */
.ob-body {
  flex: 1;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 40px;
  align-items: center;
  padding: 28px 0 12px;
}

.ob-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.ob-mascot-host { --mascot-size: 150px; }

.ob-speech {
  position: relative;
  max-width: 250px;
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow-soft);
  overflow-wrap: break-word;
}

.ob-speech::before {
  content: '';
  position: absolute;
  top: -7px;
  left: 50%;
  width: 12px;
  height: 12px;
  transform: translateX(-50%) rotate(45deg);
  background: var(--card);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  border-radius: 3px 0 0 0;
}

/* ---------- Stage / Screen ---------- */
.ob-stage { min-width: 0; }

.ob-screen {
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: obIn .45s var(--bounce);
}

.ob-screen.ob-out {
  animation: obOut .4s ease forwards;
  pointer-events: none;
}

@keyframes obIn {
  from { opacity: 0; transform: translateX(26px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes obOut {
  to { opacity: 0; transform: translateX(-26px); }
}

.ob-mini-mascot {
  display: none;
  --mascot-size: 72px;
  justify-content: center;
}

.ob-title {
  font-size: clamp(22px, 3.4vw, 32px);
  font-weight: 800;
  line-height: 1.22;
  letter-spacing: -.02em;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
}

.ob-title--final { text-align: center; }

.ob-sub {
  font-size: 14.5px;
  color: var(--muted);
  line-height: 1.5;
  overflow-wrap: break-word;
}

.ob-title--final + .ob-sub { text-align: center; }

.ob-webnote {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary);
  background: var(--primary-soft);
  border: 1px solid var(--border-focus);
  border-radius: 10px;
  padding: 8px 12px;
  overflow-wrap: break-word;
}

/* ---------- Choice cards ---------- */
.ob-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.ob-choices--track,
.ob-choices--level { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.ob-choices--daily {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ob-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  box-sizing: border-box;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease, transform .15s ease;
}

.ob-choice:hover {
  border-color: var(--border-focus);
  background: var(--card-hover);
}

.ob-choice:active { transform: scale(.98); }

.ob-choice:focus-visible {
  outline: 2px solid var(--secondary);
  outline-offset: 2px;
}

.ob-choice.selected {
  border-color: var(--secondary);
  background: var(--primary-soft);
  box-shadow: var(--glow-cyan);
}

.ob-choice-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border-radius: 10px;
  background: var(--primary-soft);
  border: 1px solid var(--border);
}

.ob-choice-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ob-choice-text strong {
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: break-word;
}

.ob-choice-text small {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: break-word;
}

.ob-choice-check {
  flex-shrink: 0;
  margin-left: auto;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  opacity: 0;
  transform: scale(.5);
  transition: opacity .2s ease, transform .2s var(--bounce);
}

.ob-choice.selected .ob-choice-check {
  opacity: 1;
  transform: scale(1);
}

/* ---------- Summary (final) ---------- */
.ob-summary {
  margin: 14px auto 0;
  width: 100%;
  max-width: 380px;
  padding: 8px 18px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.ob-summary-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14.5px;
  font-weight: 600;
}

.ob-summary-row:last-child { border-bottom: none; }

.ob-summary-ico { flex-shrink: 0; font-size: 18px; }

.ob-summary-text {
  overflow-wrap: break-word;
  word-break: normal;
}

/* ---------- Footer / CTA ---------- */
.ob-footer {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 0 18px;
  background: linear-gradient(to top, var(--bg) 65%, transparent);
}

.ob-error {
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
  background: rgba(239, 68, 68, .1);
  border: 1px solid rgba(239, 68, 68, .3);
  border-radius: 10px;
  padding: 8px 14px;
  text-align: center;
}

.ob-cta {
  width: 100%;
  max-width: 420px;
  min-height: 48px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .2px;
  cursor: pointer;
  box-shadow: var(--glow);
  transition: transform .15s ease, box-shadow .2s ease, opacity .2s ease, filter .2s ease;
}

.ob-cta:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--glow-cyan);
  filter: brightness(1.06);
}

.ob-cta:active:not(:disabled) { transform: scale(.98); }

.ob-cta:focus-visible {
  outline: 2px solid var(--secondary-hover);
  outline-offset: 2px;
}

.ob-cta:disabled {
  opacity: .45;
  cursor: not-allowed;
  box-shadow: none;
}

/* ==========================================================
   MOBILE — desktopning siqilgan nusxasi EMAS, alohida app-like layout
   ========================================================== */
@media (max-width: 767px) {
  .ob-shell {
    max-width: 100%;
    padding: 14px 16px 0;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .ob-header { gap: 10px; }
  .ob-back { width: 40px; height: 40px; }
  .ob-logo { font-size: 15px; }
  .ob-skip { font-size: 12px; padding: 6px 8px; }

  .ob-body {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 16px 0 8px;
    align-items: start;
  }

  /* Desktop robot panel yashirinadi — mini robot ekranda chiqadi */
  .ob-side { display: none; }

  .ob-mini-mascot { display: flex; }

  .ob-screen {
    gap: 8px;
    animation-name: obInMobile;
  }

  .ob-screen.ob-out { animation-name: obOutMobile; }

  .ob-title { font-size: 21px; }
  .ob-sub { font-size: 13.5px; }

  /* 320px / 360px — 1 ustun; card width 100% */
  .ob-choices,
  .ob-choices--track,
  .ob-choices--level,
  .ob-choices--daily {
    grid-template-columns: 1fr;
  }

  .ob-choice { min-height: 50px; }

  /* 390px+ — kalta kartalar (daily/reason) 2 ustunga sig'adi */
  @media (min-width: 390px) {
    .ob-choices--daily,
    .ob-choices--reason {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  /* 430px+ — track/level ham 2 ustun bo'lmaydi (matn uzun) — 1 ustun qoladi */

  .ob-footer {
    padding: 12px 0 calc(14px + env(safe-area-inset-bottom));
  }

  .ob-cta { max-width: 100%; min-height: 50px; }
}

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

@keyframes obOutMobile {
  to { opacity: 0; transform: translateY(-20px); }
}

/* ==========================================================
   KATTA DESKTOP (1600px+) — keng ekran balansi
   ========================================================== */
@media (min-width: 1600px) {
  .ob-shell { max-width: 1200px; }
  .ob-mascot-host { --mascot-size: 170px; }
}

/* Baholangan holda kichik desktop (768–1024px) — side torayadi */
@media (min-width: 768px) and (max-width: 1024px) {
  .ob-body { grid-template-columns: 240px 1fr; gap: 28px; }
  .ob-mascot-host { --mascot-size: 120px; }
  .ob-choices--daily { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ==========================================================
   ACCESSIBILITY — prefers-reduced-motion
   ========================================================== */
@media (prefers-reduced-motion: reduce) {
  #onboardingRoot.open,
  .ob-screen,
  .ob-screen.ob-out,
  .ob-progress-fill,
  .ob-choice-check,
  .ob-choice,
  .ob-back,
  .ob-cta,
  .ob-choice.selected .ob-choice-check {
    animation: none !important;
    transition: none !important;
  }
}


