/* BilimWay komponentlari — design/reference/bundle.css dan ko'chirilgan (public/js/bw.js bilan birga).
   Farqi: shriftlar o'z serverimizdan (fonts.css), progress yaltirashi tokendan. Har bir rang, burchak va oraliq — tokens.css dan. */
/* BilimWay components — every colour, radius and space is a token from tokens.json */
.bw-icon, .bw-glyph { flex: none; display: block; }

/* Button: solid fill + 4px bottom edge that collapses on press */
.bw-btn {
  font-family: var(--font-display); font-weight: 700; font-size: 16px; line-height: 20px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 48px; padding: 12px var(--space-5); border: 2px solid transparent; border-radius: var(--radius-lg);
  cursor: pointer; transition: transform .08s ease, box-shadow .08s ease, background-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.bw-btn--lg { min-height: 56px; font-size: 17px; padding: 14px var(--space-6); }
.bw-btn--block { display: flex; width: 100%; }
.bw-btn:focus-visible { outline: 3px solid var(--brand-700); outline-offset: 3px; }
.bw-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: none; }
.bw-btn--primary { background: var(--brand-600); color: var(--on-brand); box-shadow: 0 4px 0 var(--brand-edge); }
.bw-btn--primary:hover:not(:disabled) { filter: brightness(1.06); }
.bw-btn--secondary { background: var(--surface-0); color: var(--brand-700); border-color: var(--line); box-shadow: 0 4px 0 var(--line); }
.bw-btn--secondary:hover:not(:disabled) { background: var(--surface-100); }
.bw-btn--ghost { background: transparent; color: var(--brand-700); }
.bw-btn--ghost:hover:not(:disabled) { background: var(--brand-50); }
.bw-btn--danger { background: var(--danger); color: var(--on-danger); box-shadow: 0 4px 0 var(--danger-edge); }
.bw-btn:disabled { background: var(--surface-100); color: var(--ink-muted); border-color: transparent; box-shadow: none; cursor: not-allowed; }

/* Progress bar */
.bw-pbar { position: relative; height: 14px; border-radius: var(--radius-pill); background: var(--surface-100); overflow: hidden; }
.bw-pbar__fill { position: relative; height: 100%; border-radius: var(--radius-pill); background: var(--brand-500); transition: width .4s cubic-bezier(.3,1.3,.5,1); min-width: 14px; }
.bw-pbar__fill::after { content: ''; position: absolute; left: 8px; right: 8px; top: 3px; height: 4px; border-radius: var(--radius-pill); background: color-mix(in srgb, var(--surface-0) 35%, transparent); }

/* Progress ring */
.bw-ring { position: relative; display: inline-grid; place-items: center; }
.bw-ring svg { position: absolute; inset: 0; }
.bw-ring__track { fill: none; stroke: var(--surface-100); }
.bw-ring__fill { fill: none; stroke: var(--brand-500); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.bw-ring__center { position: relative; display: flex; flex-direction: column; align-items: center; }
.bw-ring__value { font-family: var(--font-display); font-weight: 800; font-size: 26px; line-height: 30px; color: var(--ink); }
.bw-ring__label { font-family: var(--font-body); font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-muted); }

/* Answer option */
.bw-opt {
  display: flex; align-items: center; gap: var(--space-3); width: 100%; text-align: left;
  padding: var(--space-3) var(--space-4); min-height: 60px;
  background: var(--surface-0); color: var(--ink);
  border: 2px solid var(--line-strong); border-radius: var(--radius-lg); box-shadow: 0 3px 0 var(--line-strong);
  font-family: var(--font-body); cursor: pointer; transition: transform .08s ease, box-shadow .08s ease;
}
.bw-opt:hover:not(:disabled) { background: var(--surface-100); }
.bw-opt:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
.bw-opt:focus-visible { outline: 3px solid var(--brand-700); outline-offset: 2px; }
.bw-opt__mark { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-sm); border: 2px solid var(--line); color: var(--ink-muted); font: 700 13px/1 var(--font-body); }
.bw-opt__text { display: flex; flex-direction: column; }
.bw-opt__label { font-size: 17px; line-height: 24px; font-weight: 600; }
.bw-opt__sub { font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.bw-opt--selected { background: var(--surface-100); border-color: var(--ink); box-shadow: 0 3px 0 var(--ink); color: var(--ink); }
.bw-opt--correct { background: var(--success-50); border-color: var(--success-500); box-shadow: 0 3px 0 var(--success-500); color: var(--success-700); }
.bw-opt--selected .bw-opt__mark { background: var(--ink); border-color: var(--ink); color: var(--surface-0); }
.bw-opt--correct .bw-opt__mark { background: var(--success-700); border-color: var(--success-700); color: var(--on-success); }
.bw-opt--wrong { background: var(--danger-50); border-color: var(--danger); box-shadow: 0 3px 0 var(--danger); color: var(--danger); }
.bw-opt--wrong .bw-opt__mark { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.bw-opt--correct .bw-opt__sub, .bw-opt--selected .bw-opt__sub, .bw-opt--wrong .bw-opt__sub { color: inherit; }

/* Letter tiles (harfma-harf) */
.bw-tiles { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: center; }
.bw-tile {
  display: grid; place-items: center; width: 44px; height: 52px;
  border: 2px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface-0);
  box-shadow: 0 3px 0 var(--line-strong);
  font: 800 24px/1 var(--font-display); color: var(--ink); text-transform: lowercase;
}
.bw-tile--current { border-color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.bw-tiles--correct .bw-tile { background: var(--success-50); border-color: var(--success-500); box-shadow: 0 3px 0 var(--success-500); color: var(--success-700); }
.bw-tiles--wrong .bw-tile--filled { background: var(--danger-50); border-color: var(--danger); box-shadow: 0 3px 0 var(--danger); color: var(--danger); }

/* Feedback sheet */
.bw-sheet { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-5); border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
.bw-sheet--correct { background: var(--success-50); }
.bw-sheet--wrong { background: var(--danger-50); }
.bw-sheet__body { display: flex; align-items: center; gap: var(--space-3); }
.bw-sheet__title { display: flex; align-items: center; gap: var(--space-2); font: 800 22px/28px var(--font-display); letter-spacing: -0.3px; }
.bw-sheet--correct .bw-sheet__title { color: var(--success-700); }
.bw-sheet--wrong .bw-sheet__title { color: var(--danger); }
.bw-sheet__detail { font: 400 16px/24px var(--font-body); color: var(--ink); margin-top: 2px; }

/* Stat pill */
.bw-stat { display: inline-flex; align-items: center; gap: 6px; padding: 6px var(--space-3) 6px 10px; border-radius: var(--radius-pill); background: var(--surface-0); border: 2px solid var(--line); }
.bw-stat__icon { color: var(--brand-500); }
.bw-stat__value { font: 800 18px/22px var(--font-display); color: var(--ink); }
.bw-stat__label { font: 500 13px/16px var(--font-body); color: var(--ink-muted); }

/* Lesson card */
.bw-lesson {
  display: flex; align-items: center; gap: var(--space-4); width: 100%; text-align: left;
  padding: var(--space-4); background: var(--surface-0); color: var(--ink);
  border: 2px solid var(--line); border-radius: var(--radius-xl); box-shadow: 0 3px 0 var(--line);
  cursor: pointer; font-family: var(--font-body); transition: transform .08s ease, box-shadow .08s ease;
}
.bw-lesson:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
.bw-lesson:focus-visible { outline: 3px solid var(--brand-700); outline-offset: 2px; }
.bw-lesson__icon { flex: none; display: grid; place-items: center; width: 52px; height: 52px; border-radius: var(--radius-lg); background: var(--brand-50); color: var(--brand-700); }
.bw-lesson--done .bw-lesson__icon { background: var(--success-50); color: var(--success-700); }
.bw-lesson--locked { cursor: not-allowed; box-shadow: none; }
.bw-lesson--locked .bw-lesson__icon { background: var(--surface-100); color: var(--ink-muted); }
.bw-lesson--locked .bw-lesson__title { color: var(--ink-muted); }
.bw-lesson__text { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bw-lesson__title { font: 700 18px/24px var(--font-display); }
.bw-lesson__sub { font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.bw-lesson__text .bw-pbar { height: 10px; margin-top: 4px; }
.bw-lesson__text .bw-pbar__fill::after { display: none; }
.bw-lesson__go { color: var(--brand-700); }

/* Chip */
.bw-chip { display: inline-flex; align-items: center; gap: var(--space-1); padding: 3px 10px; border-radius: var(--radius-sm); font: 600 13px/18px var(--font-body); }
.bw-chip--neutral { background: var(--surface-100); color: var(--ink); }
.bw-chip--brand { background: var(--brand-50); color: var(--brand-700); }
.bw-chip--new { background: var(--brand-600); color: var(--on-brand); }

/* Tutor chat */
.bw-chat { display: flex; flex-direction: column; background: var(--surface-50); border: 2px solid var(--line); border-radius: var(--radius-xl); overflow: hidden; font-family: var(--font-body); }
.bw-chat__head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 2px solid var(--line); background: var(--surface-0); }
.bw-chat__avatar { display: grid; place-items: center; width: 44px; height: 44px; }
.bw-chat__name { display: block; font: 800 17px/22px var(--font-display); color: var(--ink); }
.bw-chat__role { display: block; font-size: 13px; line-height: 18px; color: var(--ink-muted); font-weight: 500; }
.bw-chat__list { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4); }
.bw-msg { max-width: 82%; padding: 10px 14px; font-size: 16px; line-height: 24px; border-radius: 18px; }
.bw-msg--ai { align-self: flex-start; background: var(--surface-0); color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.bw-msg--user { align-self: flex-end; background: var(--brand-600); color: var(--on-brand); border-bottom-right-radius: 6px; }
.bw-msg--typing { display: inline-flex; gap: 5px; padding: 14px 16px; }
.bw-msg--typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-500); animation: bw-dot 1.2s infinite ease-in-out; }
.bw-msg--typing i:nth-child(2) { animation-delay: .15s; }
.bw-msg--typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bw-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
.bw-chat__input { display: flex; gap: var(--space-2); padding: var(--space-3) var(--space-4) var(--space-4); }
.bw-input { flex: 1; min-height: 46px; padding: 0 var(--space-4); border: 2px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface-0); color: var(--ink); font: 400 16px/24px var(--font-body); }
.bw-input::placeholder { color: var(--ink-muted); }
.bw-input:focus { outline: none; border-color: var(--brand-700); }
.bw-chat__send { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border: 0; border-radius: var(--radius-md); background: var(--brand-600); color: var(--on-brand); cursor: pointer; box-shadow: 0 3px 0 var(--brand-edge); }
.bw-chat__send:focus-visible { outline: 3px solid var(--brand-700); outline-offset: 2px; }

/* Text field */
.bw-field { display: flex; flex-direction: column; gap: 6px; font-family: var(--font-body); }
.bw-field__label { font: 600 14px/20px var(--font-body); color: var(--ink); }
.bw-field .bw-input { min-height: 48px; width: 100%; }
.bw-field__msg { display: flex; align-items: center; gap: 6px; font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.bw-field--error .bw-input { border-color: var(--danger); }
.bw-field__msg--error { color: var(--danger); font-weight: 500; }
.bw-input:disabled { background: var(--surface-100); color: var(--ink-muted); }

/* Bottom nav */
.bw-nav { display: flex; justify-content: space-around; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: var(--surface-0); border-top: 1px solid var(--line); }
.bw-nav__item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border: 0; background: none; color: var(--ink-muted); font: 600 12px/16px var(--font-body); cursor: pointer; border-radius: var(--radius-md); }
.bw-nav__icon { position: relative; display: grid; place-items: center; width: 52px; height: 32px; border-radius: var(--radius-pill); transition: background-color .15s ease; }
.bw-nav__item--active { color: var(--brand-700); }
.bw-nav__item--active .bw-nav__icon { background: var(--brand-50); }
.bw-nav__item:focus-visible { outline: 3px solid var(--brand-700); outline-offset: 1px; }
.bw-nav__badge { position: absolute; top: 3px; right: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--surface-0); }

/* Logo */
.bw-logo { display: inline-flex; align-items: center; gap: .4em; }
.bw-logo__mark { flex: none; }
.bw-logo__word { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.03em; color: var(--ink); line-height: 1; }
.bw-logo__way { color: var(--brand-700); }

/* Barg: life in small doses — blink, talk, think */
.bw-barg { flex: none; display: block; overflow: visible; }
.bw-barg * { transform-box: fill-box; transform-origin: center; }
.bw-barg--idle .bw-barg__eyes, .bw-barg--listening .bw-barg__eyes { animation: bw-blink 4.5s infinite; }
.bw-barg--celebrate .bw-barg__leaf, .bw-barg--happy .bw-barg__leaf { animation: bw-sway .9s ease-in-out 2; transform-origin: 0% 100%; }
.bw-barg__talk { animation: bw-talk .32s infinite alternate ease-in-out; }
.bw-barg__dot { animation: bw-dot 1.2s infinite ease-in-out; }
.bw-barg__dot:nth-of-type(2) { animation-delay: .15s; }
.bw-barg__dot:nth-of-type(3) { animation-delay: .3s; }
.bw-barg--celebrate, .bw-barg--happy { animation: bw-pop .5s cubic-bezier(.3,1.6,.5,1) 1; }
@keyframes bw-blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
@keyframes bw-talk { from { transform: scaleY(.45); } to { transform: scaleY(1.1); } }
@keyframes bw-sway { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-10deg); } }
@keyframes bw-pop { from { transform: scale(.85); } to { transform: scale(1); } }

@media (prefers-reduced-motion: reduce) {
  .bw-barg, .bw-barg * { animation: none !important; }
  .bw-btn, .bw-opt, .bw-lesson, .bw-pbar__fill, .bw-ring__fill { transition: none; }
  .bw-msg--typing i { animation: none; opacity: .8; }
}

/* ---------- Loyihaga qo'shimchalar ---------- */
/* AnswerOption: klaviatura raqami (1–4) */
.bw-opt__key { font: 700 13px/1 var(--font-body); }
/* LetterTiles: haqiqiy kiritish maydoni katakchalar ustida yashirin turadi (telefon klaviaturasi va nusxa qo'yish bloki uchun) */
.bw-tiles--input { position: relative; cursor: text; }
.bw-tiles__input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; font-size: 16px; caret-color: transparent; }
.bw-tiles__input:focus-visible { outline: none; }
.bw-tiles--input:focus-within { outline: 3px solid var(--brand-700); outline-offset: 4px; border-radius: var(--radius-md); }
.bw-tile--space { width: 14px; border: 0; background: none; box-shadow: none; }
.bw-tile--fixed { border-style: dashed; color: var(--ink-muted); box-shadow: none; }
/* FeedbackSheet ekran pastida */
.bw-sheet--fixed { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0px)); box-shadow: var(--lift); }
.bw-sheet__inner { width: 100%; max-width: 640px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-4); }
.bw-sheet .bw-btn { min-width: 160px; }
@media (max-width: 520px) { .bw-sheet .bw-btn { width: 100%; } }
@media (prefers-reduced-motion: reduce) { .bw-tiles--input:focus-within { transition: none; } }

/* Mashq tepasi (ExerciseTop) */
.bw-extop { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-5); }
.bw-extop .bw-pbar { flex: 1; }
.bw-extop__close { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--radius-md); color: var(--ink-muted); }
.bw-extop__close:hover { background: var(--surface-100); color: var(--ink); }
.bw-extop__count { flex: none; font: 700 14px/20px var(--font-display); color: var(--ink-muted); font-variant-numeric: tabular-nums; }
