/* avatar-editor.css — the avatar maker sheet (avatar-editor.js).
   Wide screens: a window with the figure on the left and the choices beside it.
   Phones: full screen — the figure in a band at the top, tabs under it, each
   row of choices a strip that scrolls sideways, Save always at the bottom. */

html.ae-open { overflow: hidden; }

.ae {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(6, 4, 18, 0.72);
    backdrop-filter: blur(6px);
    animation: ae-fade 0.18s ease;
}
.ae[hidden] { display: none; }
@keyframes ae-fade { from { opacity: 0; } }

.ae-sheet {
    display: flex;
    flex-direction: column;
    width: min(1000px, 100%);
    height: min(720px, 100%);
    border-radius: 24px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: ae-rise 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes ae-rise { from { transform: translateY(16px) scale(0.98); opacity: 0; } }

.ae-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px 22px;
}
.ae-head h2 { margin: 0; font-size: 1.15rem; font-weight: 800; color: var(--text); }
.ae-close {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
}
.ae-close:hover { background: rgba(255, 255, 255, 0.07); color: var(--text); }

.ae-main {
    flex: 1;
    min-height: 0;
    display: grid;
    /* minmax(0, …): a row of choices that scrolls sideways must not widen the
       column (and with it the sheet) to its own length. */
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 16px;
    padding: 0 16px;
}

/* ── The figure ─────────────────────────────────────────────────────────── */

.ae-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    border-radius: 20px;
    background:
        radial-gradient(ellipse 70% 12% at 50% 84%, rgba(0, 0, 0, 0.35), transparent 70%),
        radial-gradient(circle at 50% 32%, #3a2f8c, #1d1747 72%);
    border: 1px solid var(--line);
}
.ae-figure { width: 240px; height: 360px; }
.ae-figure.ae-pop .ak { animation: ae-pop 0.28s ease; }
@keyframes ae-pop { 40% { transform: scale(1.04, 0.97); } }
.ae-tools { display: flex; gap: 8px; }
.ae-tool {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    font: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
}
.ae-tool:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); }
.ae-tool:disabled { opacity: 0.4; cursor: default; }

/* ── The choices ────────────────────────────────────────────────────────── */

.ae-panel { min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.ae-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    border-radius: 14px;
    background: var(--bg-2);
    overflow-x: auto;
    scrollbar-width: none;
    flex-shrink: 0;
}
.ae-tabs::-webkit-scrollbar { display: none; }
.ae-tab {
    flex: 1 0 auto;
    min-height: 40px;
    padding: 0 14px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text-2);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.ae-tab:hover { color: var(--text); }
/* A shade darker than --accent-strong: white on it reaches 4.5:1. */
.ae-tab[aria-selected="true"] { background: #6550e8; color: #fff; }

.ae-options {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 14px 4px 16px;
    overscroll-behavior: contain;
}
.ae-row { margin-bottom: 16px; animation: ae-fade 0.2s ease; }
.ae-row:last-child { margin-bottom: 0; }
.ae-label { margin: 0 0 8px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); }
.ae-values { display: flex; flex-wrap: wrap; gap: 7px; }

.ae-thumb {
    position: relative;
    width: 64px;
    height: 64px;
    padding: 3px;
    border-radius: 16px;
    border: 1px solid var(--line-strong);
    background: var(--surface-2);
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.12s ease, border-color 0.12s ease;
}
.ae-thumb img { display: block; width: 100%; height: 100%; object-fit: contain; }
.ae-thumb-whole { width: 64px; height: 84px; }
.ae-thumb:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.3); }
.ae-thumb[aria-pressed="true"] { border: 2px solid var(--accent); background: var(--accent-soft); padding: 2px; }
.ae-thumb[aria-pressed="true"]::after {
    content: '';
    position: absolute;
    right: -5px;
    top: -5px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12.5l4 4 8-9' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
    box-shadow: 0 0 0 2px var(--surface);
}

.ae-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.14);
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.12s ease;
}
.ae-swatch:hover { transform: scale(1.1); }
.ae-swatch[aria-pressed="true"] { outline: 2px solid #fff; outline-offset: 3px; }

.ae-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    margin-top: 12px;
    border-top: 1px solid var(--line);
}
.ae-credit { margin-right: auto; font-size: 0.74rem; color: var(--text-3); }

.ae button:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

/* ── Phones ─────────────────────────────────────────────────────────────── */

@media (max-width: 720px), (max-height: 520px) {
    .ae { padding: 0; }
    .ae-sheet { width: 100%; height: 100%; border-radius: 0; border: 0; }
    .ae-head { padding: calc(8px + env(safe-area-inset-top, 0px)) 8px 4px 16px; }
    .ae-main { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 10px; padding: 0 12px; }

    .ae-stage {
        flex-direction: row;
        justify-content: center;
        gap: 18px;
        padding: 6px 12px;
        border-radius: 18px;
    }
    .ae-figure { width: 112px; height: 168px; }
    .ae-tools { flex-direction: column; }
    .ae-hint { position: absolute; left: 12px; right: 12px; bottom: 6px; max-width: none; }
    .ae-stage { position: relative; }

    .ae-options { padding: 12px 0 8px; }
    .ae-row { margin-bottom: 14px; }
    .ae-label { margin-bottom: 6px; }
    /* One line per row, swiped sideways. */
    .ae-values {
        flex-wrap: nowrap;
        overflow-x: auto;
        scroll-snap-type: x proximity;
        scrollbar-width: none;
        padding: 6px 2px 4px;
        margin: -6px 0 0;
    }
    .ae-values::-webkit-scrollbar { display: none; }
    .ae-values > * { scroll-snap-align: center; }
    .ae-thumb { width: 60px; height: 60px; }
    .ae-thumb-whole { width: 60px; height: 80px; }
    .ae-swatch { width: 36px; height: 36px; }

    .ae-foot { margin-top: 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); flex-wrap: wrap; }
    .ae-credit { flex-basis: 100%; text-align: center; order: 3; }
    .ae-foot .btn { flex: 1; }
}

/* ── Parts that need points ─────────────────────────────────────────────── */
.ae-locked { position: relative; }
.ae-thumb.ae-locked img { opacity: 0.38; filter: grayscale(0.6); }
.ae-swatch.ae-locked { opacity: 0.45; display: grid; place-items: center; }
.ae-swatch .ae-lock { font-size: 0.8rem; }
.ae-thumb .ae-lock {
    position: absolute;
    left: 50%;
    bottom: 3px;
    transform: translateX(-50%);
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(12, 10, 29, 0.85);
    color: var(--gold);
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
}
.ae-hint {
    margin: 0;
    max-width: 260px;
    padding: 8px 12px;
    border-radius: 12px;
    background: rgba(12, 10, 29, 0.8);
    border: 1px solid rgba(255, 201, 77, 0.35);
    color: var(--text);
    font-size: 0.82rem;
    text-align: center;
}

/* ── The ready-made avatars on the login and signup pages ───────────────── */

.avatar-grid.kit-grid { grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); }
.kit-card img { width: 100%; max-width: 56px; aspect-ratio: 2 / 3; object-fit: contain; }
.kit-card-own .kit-own-icon { display: grid; place-items: center; width: 56px; aspect-ratio: 2 / 3; font-size: 1.8rem; border-radius: 12px; border: 1px dashed var(--line-strong); }
.kit-card-own img.kit-own-icon { border: 0; }

@media (prefers-reduced-motion: reduce) {
    .ae, .ae-sheet, .ae-row, .ae-figure.ae-pop .ak { animation: none; }
}
