/* ==========================================================================
   POLICEOLINGO — BASE
   Скидання, типографіка та спільні примітиви (кнопки, картки, чипи,
   прогрес, кільця, аватар, шеврон). Використовується всіма сторінками.
   ========================================================================== */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-ui);
    font-size: var(--fs-md);
    line-height: var(--lh-normal);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    text-rendering: optimizeLegibility;
}

img, svg { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.hidden { display: none !important; }

::selection { background: var(--brand-200); color: var(--text); }

/* Фокус — видимий, але тільки з клавіатури */
:focus-visible {
    outline: 3px solid var(--brand-400);
    outline-offset: 2px;
    border-radius: var(--r-xs);
}
:focus:not(:focus-visible) { outline: none; }

/* Скролбар */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--r-pill);
    border: 3px solid transparent;
    background-clip: content-box;
}

/* ==========================================================================
   ТИПОГРАФІКА
   ========================================================================== */

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: var(--lh-tight);
    letter-spacing: var(--tracking-tight);
}

.t-display { font-family: var(--font-display); font-weight: 700; letter-spacing: var(--tracking-tight); }
.t-num     { font-family: var(--font-mono); font-weight: 700; font-variant-numeric: tabular-nums; }

/* Надзаголовок-мітка: «СКЛАДІТЬ РЕЧЕННЯ», «РОЗДІЛ 2» */
.t-eyebrow {
    font-size: var(--fs-2xs);
    font-weight: 800;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--text-3);
}

.t-muted { color: var(--text-3); }
.t-dim   { color: var(--text-2); }

/* Текст із градієнтом бренду */
.t-grad {
    background: var(--grad-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ==========================================================================
   ШЕВРОН — фірмовий мотив
   ========================================================================== */

.chevron-strip {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}
.chevron-strip::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--chevron);
    pointer-events: none;
    z-index: 1;
}

/* Тонка декоративна лінія-шеврон (роздільник, край шапки) */
.chevron-rule {
    height: 4px;
    border-radius: var(--r-pill);
    background: var(--chevron-gold);
    opacity: 0.85;
}

/* ==========================================================================
   КНОПКИ
   Тактильні: мають нижню «грань», що втискається при натисканні.
   ========================================================================== */

.btn {
    --btn-lip: var(--lip-surface);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: 13px 22px;
    border-radius: var(--r-md);
    font-family: var(--font-ui);
    font-size: var(--fs-md);
    font-weight: 800;
    letter-spacing: -0.01em;
    white-space: nowrap;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--btn-lip);
    transform: translateY(0);
    transition: transform var(--dur-fast) var(--ease-out),
                box-shadow var(--dur-fast) var(--ease-out),
                background var(--dur-fast) var(--ease-out),
                opacity var(--dur-fast) var(--ease-out);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled) {
    transform: translateY(4px);
    box-shadow: 0 0 0 transparent;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: 0 0 0 transparent;
    transform: translateY(4px);
}

.btn--brand   { --btn-lip: var(--lip-brand); background: var(--brand-600); color: #fff; }
.btn--brand:hover:not(:disabled) { background: var(--brand-500); }

.btn--ok      { --btn-lip: var(--lip-ok);  background: var(--ok-500);  color: #fff; }
.btn--err     { --btn-lip: var(--lip-err); background: var(--err-500); color: #fff; }

.btn--gold    { --btn-lip: 0 4px 0 var(--gold-600); background: var(--gold-500); color: #2A1B04; }

.btn--ghost   { background: transparent; box-shadow: none; color: var(--text-2); font-weight: 700; }
.btn--ghost:hover { background: var(--bg-sunken); color: var(--text); }
.btn--ghost:active:not(:disabled) { transform: none; }

.btn--outline { background: var(--surface); box-shadow: var(--lip-surface), inset 0 0 0 2px var(--border); }
.btn--outline:hover:not(:disabled) { box-shadow: var(--lip-surface), inset 0 0 0 2px var(--brand-300); color: var(--brand-600); }

.btn--lg   { padding: 17px 30px; font-size: var(--fs-lg); border-radius: var(--r-lg); }
.btn--sm   { padding: 9px 15px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn--full { width: 100%; }

/* Іконкова кнопка */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: var(--r-sm);
    color: var(--text-2);
    transition: background var(--dur-fast) var(--ease-out),
                color var(--dur-fast) var(--ease-out),
                transform var(--dur-fast) var(--ease-out);
    -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover  { background: var(--bg-sunken); color: var(--text); }
.icon-btn:active { transform: scale(0.92); }

/* ==========================================================================
   КАРТКИ ТА ПОВЕРХНІ
   ========================================================================== */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-sm);
}

.card--flat   { box-shadow: none; }
.card--raised { box-shadow: var(--sh-md); }
.card--pad    { padding: var(--sp-5); }

.card--interactive {
    cursor: pointer;
    transition: transform var(--dur-base) var(--ease-out),
                box-shadow var(--dur-base) var(--ease-out),
                border-color var(--dur-base) var(--ease-out);
}
.card--interactive:hover  { transform: translateY(-3px); box-shadow: var(--sh-lg); border-color: var(--border-strong); }
.card--interactive:active { transform: translateY(-1px); }

/* ==========================================================================
   ЧИПИ ТА ЗНАЧКИ
   ========================================================================== */

.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 6px 13px;
    border-radius: var(--r-pill);
    font-size: var(--fs-xs);
    font-weight: 800;
    letter-spacing: -0.01em;
    background: var(--bg-sunken);
    color: var(--text-2);
    white-space: nowrap;
}

.chip--brand { background: var(--brand-050); color: var(--brand-600); }
.chip--gold  { background: var(--gold-100);  color: var(--gold-600); }
.chip--ok    { background: var(--ok-100);    color: var(--ok-600); }
.chip--err   { background: var(--err-100);   color: var(--err-600); }

/* Жетон — значок зі званням, метриками, стріком */
.badge-stat {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px 7px 10px;
    border-radius: var(--r-pill);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--sh-xs);
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.badge-stat svg { width: 17px; height: 17px; flex-shrink: 0; }

.badge-stat--streak      { color: var(--gold-600); }
.badge-stat--streak svg  { color: var(--gold-500); }
.badge-stat--xp          { color: var(--brand-600); }
.badge-stat--xp svg      { color: var(--brand-500); }
/* Погаслий стан — стріку ще немає */
.badge-stat--off         { color: var(--text-3); }
.badge-stat--off svg     { color: var(--text-3); filter: grayscale(1); }

/* ==========================================================================
   ПРОГРЕС
   ========================================================================== */

.bar {
    display: block;
    height: 10px;
    border-radius: var(--r-pill);
    background: var(--bg-sunken);
    overflow: hidden;
    position: relative;
}
.bar__fill {
    display: block;
    height: 100%;
    border-radius: var(--r-pill);
    background: var(--grad-progress);
    width: 0;
    transition: width var(--dur-slower) var(--ease-out);
    position: relative;
    overflow: hidden;
}
.bar__fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--chevron);
}
.bar--gold .bar__fill { background: var(--grad-streak); }
.bar--ok   .bar__fill { background: var(--grad-ok); }
.bar--thin { height: 6px; }
.bar--thick { height: 14px; }

/* Сегментований прогрес — по одному сегменту на завдання, як у сторіз */
.segbar { display: flex; gap: 3px; flex: 1; }
.segbar__seg {
    flex: 1;
    height: 6px;
    border-radius: var(--r-pill);
    background: var(--bg-sunken);
    overflow: hidden;
    position: relative;
}
.segbar__seg::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--grad-progress);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--dur-slow) var(--ease-out);
}
.segbar__seg.is-done::after    { transform: scaleX(1); }
.segbar__seg.is-current::after { transform: scaleX(0.45); }
.segbar__seg.is-wrong::after   { transform: scaleX(1); background: var(--err-500); }

/* Кільце прогресу (SVG-обгортка) */
.ring { display: block; transform: rotate(-90deg); }
.ring__track { stroke: var(--bg-sunken); fill: none; }
.ring__fill {
    fill: none;
    stroke-linecap: round;
    transition: stroke-dashoffset var(--dur-slower) var(--ease-out);
}

/* ==========================================================================
   АВАТАР
   ========================================================================== */

.avatar {
    position: relative;
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
}
.avatar__gen { border-radius: 50%; display: block; flex-shrink: 0; }

.avatar__img,
.avatar__ph {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: grid;
    place-items: center;
    background: var(--grad-brand);
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    overflow: hidden;
}
.avatar__ring { position: absolute; inset: -7px; pointer-events: none; }

/* ==========================================================================
   ПОРОЖНІ СТАНИ ТА СКЕЛЕТОНИ
   ========================================================================== */

.empty {
    display: grid;
    place-items: center;
    gap: var(--sp-3);
    padding: var(--sp-12) var(--sp-5);
    text-align: center;
    color: var(--text-3);
}
.empty__art { width: 128px; opacity: 0.9; }
.empty__title { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 700; color: var(--text-2); }

.skeleton {
    background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--border) 50%, var(--bg-sunken) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s linear infinite;
    border-radius: var(--r-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ==========================================================================
   АНІМАЦІЇ
   ========================================================================== */

@keyframes pop-in    { from { opacity: 0; transform: scale(0.88); } to { opacity: 1; transform: scale(1); } }
@keyframes rise-in   { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slide-up  { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes shake     { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); }
                       30%, 50%, 70% { transform: translateX(-7px); } 40%, 60% { transform: translateX(7px); } }
@keyframes pulse-ring{ 0% { box-shadow: 0 0 0 0 rgba(43, 92, 230, 0.45); }
                       70% { box-shadow: 0 0 0 16px rgba(43, 92, 230, 0); }
                       100% { box-shadow: 0 0 0 0 rgba(43, 92, 230, 0); } }
@keyframes spin      { to { transform: rotate(360deg); } }
@keyframes float-y   { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }

.anim-rise  { animation: rise-in var(--dur-slow) var(--ease-out) both; }
.anim-pop   { animation: pop-in var(--dur-base) var(--ease-back) both; }
.anim-shake { animation: shake 0.5s var(--ease-in-out); }

/* Каскадна поява списків */
.stagger > * { animation: rise-in var(--dur-slow) var(--ease-out) both; }
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 45ms; }
.stagger > *:nth-child(3) { animation-delay: 90ms; }
.stagger > *:nth-child(4) { animation-delay: 135ms; }
.stagger > *:nth-child(5) { animation-delay: 180ms; }
.stagger > *:nth-child(6) { animation-delay: 225ms; }
.stagger > *:nth-child(7) { animation-delay: 270ms; }
.stagger > *:nth-child(8) { animation-delay: 315ms; }
.stagger > *:nth-child(n+9) { animation-delay: 360ms; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ==========================================================================
   УТИЛІТИ
   ========================================================================== */

.row    { display: flex; align-items: center; gap: var(--sp-3); }
.row--between { justify-content: space-between; }
.col    { display: flex; flex-direction: column; gap: var(--sp-3); }
.grow   { flex: 1; min-width: 0; }
.center { display: grid; place-items: center; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0;
    margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ==========================================================================
   ІКОНКИ (спрайт /static/svg/icons.svg)
   ========================================================================== */

.ico {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.ico--xs { width: 14px; height: 14px; stroke-width: 2.4; }
.ico--sm { width: 18px; height: 18px; stroke-width: 2.2; }
.ico--lg { width: 30px; height: 30px; stroke-width: 1.8; }
.ico--xl { width: 40px; height: 40px; stroke-width: 1.6; }
/* Заливка замість обведення — для вогника стріку, зірки, серця */
.ico--fill { fill: currentColor; stroke: none; }


/* ==========================================================================
   ПОЛЯ ФОРМ
   Спільні для застосунку, лендингу й модалок авторизації.
   ========================================================================== */

.field { margin-bottom: var(--sp-4); }
.field__label {
    display: block;
    font-size: var(--fs-2xs);
    font-weight: 800;
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: var(--sp-2);
}
.field__input,
.field__select {
    width: 100%;
    padding: 13px var(--sp-4);
    border-radius: var(--r-md);
    background: var(--surface);
    border: 2px solid var(--border);
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--text);
    transition: border-color var(--dur-fast) var(--ease-out),
                box-shadow var(--dur-fast) var(--ease-out);
    -webkit-appearance: none;
    appearance: none;
}
.field__input:focus,
.field__select:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 4px var(--brand-050);
}
.field__select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A92AD' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 9 7 7 7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 18px;
    padding-right: 42px;
}
.field__hint { font-size: var(--fs-2xs); color: var(--text-3); font-weight: 600; margin-top: 6px; }

