/* inash stickers: страница «оживи свой стакан».
   Внешний вид — токены ниже (это тема «минимал»). Темы (static/themes/*.css) меняют токены и отдельные детали,
   цвета и шрифты бренда приходят из brand.json через <style> в index.html. Новый вид = новые токены, а не правки здесь. */
:root {
    /* Цвета (бренд задаёт свои) */
    --primary: #3B4449;
    --accent: #7A8590;
    --bg: #F4F5F6;
    --text: #2B3135;
    --surface: #FFFFFF;          /* вторичные кнопки, плашки */
    --on-primary: #FFFFFF;       /* текст на --primary */
    --on-accent: #FFFFFF;
    --bg-image: none;            /* картинка или градиент поверх --bg */
    --bg-size: cover;            /* фото — cover, узоры тем — auto */
    --fs-bg: #141110;            /* фон полноэкранного режима */

    /* Шрифты */
    --font-heading: system-ui, sans-serif;
    --font-body: "Inter", system-ui, sans-serif;
    --heading-weight: 600;
    --heading-transform: none;
    --heading-spacing: 0.04em;

    /* Формы и тени */
    --radius-btn: 999px;
    --radius-card: 18px;
    --border-w: 2px;
    --btn-border: var(--primary);
    --shadow-btn: none;
    --shadow-btn-active: none;
    --btn-press: scale(0.97);
    --shadow-card: 0 12px 34px rgba(0, 0, 0, 0.14);
    --logo-filter: none;         /* тёмная тема осветляет тёмный логотип */
}

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

html, body { min-height: 100%; }

body {
    /* Отдельными свойствами: в --bg-image может быть несколько градиентов через запятую */
    background-color: var(--bg);
    background-image: var(--bg-image);
    background-size: var(--bg-size);
    background-position: center;
    background-repeat: no-repeat;
    color: var(--text);
    font-family: var(--font-body);
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

.hidden { display: none !important; }

.screen {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: max(16px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
    text-align: center;
}

/* --- Начало --- */
.logo {
    width: min(220px, 55vw);
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 50%;
    box-shadow: var(--shadow-card);
}

.logo, .logo-anim { filter: var(--logo-filter); }
.logo-anim .logo { filter: none; } /* надпись внутри анимации — фильтр уже на обёртке */

/* Широкий логотип (brand.json: "logo_style": "wide") — без круга и тени */
.logo--wide {
    width: min(300px, 75vw);
    aspect-ratio: auto;
    object-fit: contain;
    border-radius: 0;
    box-shadow: none;
}

/* --- Анимация логотипа: только transform и opacity, их рисует видеокарта --- */
/* Знак — та же картинка logo.png, обрезанная до левой части (--mark — доля ширины) */
.logo-anim { position: relative; line-height: 0; }

.logo-word {
    display: block;
    clip-path: inset(0 0 0 calc(var(--mark) * 100%));
    animation: logo-word 0.6s 0.35s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.logo-mark {
    position: absolute;
    inset: 0 auto 0 0;
    width: calc(var(--mark) * 100%);
    background: var(--logo) left center / calc(100% / var(--mark)) 100% no-repeat;
    transform-origin: 50% 100%;
    animation: logo-stick 0.7s cubic-bezier(0.3, 0.8, 0.3, 1.2) both;
    transition: transform 0.25s ease-out;
    overflow: hidden;
    /* Блик пробегает только по самому знаку, а не по прозрачному фону */
    -webkit-mask: var(--logo) left center / calc(100% / var(--mark)) 100% no-repeat;
    mask: var(--logo) left center / calc(100% / var(--mark)) 100% no-repeat;
}

.logo-mark::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.55) 50%, transparent 65%);
    transform: translateX(-120%);
    animation: logo-shine 0.7s 1s ease-in-out both;
}

/* Наведение / нажатие: уголок стикера чуть приподнимается */
.logo-anim:hover .logo-mark,
.logo-anim:active .logo-mark { transform: rotate(-6deg) translateY(-3px) scale(1.04); transform-origin: 100% 100%; }

.logo-anim.played .logo-word,
.logo-anim.played .logo-mark,
.logo-anim.played .logo-mark::after { animation: none; }

@keyframes logo-stick {
    0% { opacity: 0; transform: translateY(-24px) rotate(-14deg) scale(1.3); }
    55% { opacity: 1; transform: translateY(0) rotate(3deg) scale(0.95); }
    78% { transform: rotate(-1deg) scale(1.02); }
    100% { opacity: 1; transform: none; }
}

@keyframes logo-word {
    from { opacity: 0; transform: translateX(-12px); }
    to { opacity: 1; transform: none; }
}

@keyframes logo-shine { to { transform: translateX(120%); } }

h1 {
    font-family: var(--font-heading);
    font-weight: var(--heading-weight);
    font-size: clamp(26px, 7vw, 34px);
    letter-spacing: var(--heading-spacing);
    text-transform: var(--heading-transform);
    color: var(--primary);
    margin-top: 8px;
}

.intro {
    max-width: 300px;
    line-height: 1.5;
    opacity: 0.75;
}

/* --- Кнопки --- */
.actions {
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }

.btn {
    display: block;
    width: 100%;
    padding: 15px 18px;
    border-radius: var(--radius-btn);
    border: var(--border-w) solid var(--btn-border);
    box-shadow: var(--shadow-btn);
    font: 600 16px var(--font-body);
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s, opacity 0.2s;
    user-select: none;
}

.btn:active { transform: var(--btn-press); box-shadow: var(--shadow-btn-active); }

/* Кнопки с иконкой: иконка и подпись в ряд по центру */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; }

.ico {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-btn .ico { width: 22px; height: 22px; vertical-align: middle; }

/* Подсказка: иконка-прицел только в режиме «нажмите на стакан» */
.hint { display: inline-flex; align-items: center; gap: 8px; }
.hint .ico { display: none; width: 18px; height: 18px; }
.hint.attention .ico { display: block; }
.btn:disabled { opacity: 0.5; }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.secondary { background: var(--surface); color: var(--primary); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--accent); padding: 10px; }

/* --- Ожидание --- */
.spinner {
    width: 48px;
    height: 48px;
    border: 5px solid color-mix(in srgb, var(--primary) 20%, transparent);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Загрузка: иконка-стикер отклеивается за уголок и приклеивается обратно */
.loader-sticker {
    position: relative;
    width: 72px;
    height: 72px;
}

.loader-sticker img {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 22%;
    transform-origin: 100% 100%;
    animation: peel 1.4s ease-in-out infinite;
}

/* Тень под стикером: становится шире, когда уголок поднят */
.loader-sticker::before {
    content: "";
    position: absolute;
    left: 10%;
    right: 10%;
    bottom: -10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.18);
    filter: blur(4px);
    animation: peel-shadow 1.4s ease-in-out infinite;
}


@keyframes peel {
    0%, 15%, 100% { transform: none; }
    45%, 60% { transform: rotate(-10deg) translateY(-8px) scale(1.04); }
}

@keyframes peel-shadow {
    0%, 15%, 100% { transform: scaleX(1); opacity: 0.8; }
    45%, 60% { transform: scaleX(0.75); opacity: 0.4; }
}


/* --- Результат --- */
#result-screen { justify-content: flex-start; gap: 12px; }

.hint {
    font-weight: 500;
    font-size: 14px;
    color: var(--accent);
    min-height: 20px;
}

.canvas-wrap {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.canvas-box {
    position: relative;
    max-width: 100%;
    border-radius: var(--radius-card);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

#canvas {
    display: block;
    max-width: 100%;
    max-height: calc(100dvh - 300px);
    touch-action: none;
}

.icon-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.icon-btn:active { transform: scale(0.92); }

/* --- Полный экран: фото на весь экран, кнопки снизу --- */
.fs-bar { display: none; }

body.fs-open { overflow: hidden; }

.fullscreen .canvas-wrap {
    position: fixed;
    inset: 0;
    z-index: 40;
    flex-direction: column;
    gap: 14px;
    background: var(--fs-bg);
    padding: max(10px, env(safe-area-inset-top)) 0 max(14px, env(safe-area-inset-bottom));
}

.fullscreen .canvas-box { border-radius: 0; border: none; box-shadow: none; }
.fullscreen #canvas { max-height: calc(100dvh - 110px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }

.fullscreen .fs-bar {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 420px;
    padding: 0 16px;
}

.fs-bar .btn { flex: 1; padding: 13px 8px; font-size: 15px; white-space: nowrap; }

/* --- Корзина: удерживаешь или тянешь часть рисунка → сюда, чтобы удалить --- */
.trash {
    position: absolute;
    left: 50%;
    bottom: 16px;
    width: 58px;
    height: 58px;
    margin-left: -29px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.85);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.6) translateY(20px);
    transition: opacity 0.2s, transform 0.2s, background 0.2s;
    pointer-events: none;
}

.trash svg { width: 28px; height: 28px; fill: #fff; }
.trash.visible { opacity: 1; transform: scale(1); }
.trash.over { background: #E5484D; transform: scale(1.25); }
.trash.ate { animation: trash-ate 0.4s ease-out; }

@keyframes trash-ate {
    30% { transform: scale(1.4) rotate(-10deg); }
    60% { transform: scale(1.2) rotate(8deg); }
    100% { transform: scale(1) rotate(0); }
}

/* --- Сохранение: вспышка, как у камеры, и галочка --- */
.flash {
    position: absolute;
    inset: 0;
    background: #fff;
    opacity: 0;
    pointer-events: none;
}

.flash.go { animation: flash 0.5s ease-out; }

@keyframes flash {
    0% { opacity: 0; }
    15% { opacity: 0.85; }
    100% { opacity: 0; }
}

.saved-badge {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    pointer-events: none;
    opacity: 0;
}

.saved-badge svg { width: 88px; height: 88px; filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.35)); }
.saved-badge circle { fill: var(--primary); stroke: #fff; stroke-width: 3; }
.saved-badge path {
    fill: none;
    stroke: var(--on-primary);
    stroke-width: 5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
}

.saved-badge span {
    color: #fff;
    font: 700 20px var(--font-body);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.saved-badge.show { animation: badge 1.8s ease-out forwards; }
.saved-badge.show path { animation: draw 0.4s 0.2s ease-out forwards; }

@keyframes badge {
    0% { opacity: 0; transform: scale(0.5); }
    18% { opacity: 1; transform: scale(1.08); }
    28% { transform: scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes draw { to { stroke-dashoffset: 0; } }

.btn.done { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.edit-hint { font-size: 12px; opacity: 0.55; }

/* Режим «нажмите на стакан»: подсказка заметнее, курсор-прицел */
#canvas.picking { cursor: crosshair; }

.hint.attention {
    color: var(--on-accent);
    background: var(--accent);
    padding: 8px 16px;
    border-radius: var(--radius-btn);
    animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
    50% { transform: scale(1.05); }
}

.row .btn { white-space: nowrap; padding-left: 8px; padding-right: 8px; }

/* --- Сообщения --- */
.toast {
    position: fixed;
    left: 50%;
    bottom: max(24px, env(safe-area-inset-bottom));
    transform: translate(-50%, 20px);
    background: var(--text);
    color: var(--bg);
    padding: 10px 18px;
    border-radius: var(--radius-btn);
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
    max-width: calc(100vw - 32px);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --- Ссылки бренда (brand.json "links") --- */
.brand-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    max-width: 360px;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-btn);
    border: 1px solid color-mix(in srgb, var(--text) 14%, transparent);
    background: color-mix(in srgb, var(--surface) 70%, transparent);
    color: var(--text);
    font: 500 14px var(--font-body);
    text-decoration: none;
}

.brand-link .ico { width: 18px; height: 18px; }
.brand-link:active { transform: scale(0.97); }

/* Кто отключил анимации в системе — видит всё сразу и без движения */
@media (prefers-reduced-motion: reduce) {
    .logo-word, .logo-mark, .logo-mark::after,
    .loader-sticker img, .loader-sticker::before { animation: none !important; }
    .logo-mark { transition: none; }
}
