/* ==============================================================================
 * Mentifyll: címer-szerű jelvények és a jelvény-/jutalomtervező (v0.15.0)
 * Minden szín a tokens.css változóiból (sötét és világos téma is, WCAG AA).
 * ============================================================================== */

/* ---------- A címer (SVG) ---------- */
.crest {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.crest-locked {
    filter: grayscale(0.95) brightness(0.72) contrast(0.92);
    opacity: 0.88;
}

@keyframes crest-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

@keyframes crest-pop {
    0% { transform: scale(0.4) rotate(-8deg); opacity: 0; }
    60% { transform: scale(1.08) rotate(2deg); opacity: 1; }
    100% { transform: scale(1) rotate(0); }
}

@keyframes crest-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.0); }
    50% { box-shadow: 0 0 34px 6px rgba(251, 191, 36, 0.35); }
}

/* ---------- Jelvényfal ---------- */
.crest-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin: 0 0 12px;
    padding: 0;
    list-style: none;
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

.crest-legend li {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.crest-legend i {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1.5px solid var(--color-border);
}

.crest-legend i.t-bronze { background: #cd7f32; }
.crest-legend i.t-silver { background: #b9c3d1; }
.crest-legend i.t-gold { background: #f2c230; }
.crest-legend i.t-platinum { background: #8fd3e6; }

.crest-filter {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.crest-filter button {
    padding: 5px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-surface);
    color: var(--color-text-main);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
}

.crest-filter button[aria-pressed="true"] {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--on-primary);
}

.crest-wall {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
    margin-top: 8px;
}

.crest-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 10px 12px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-text-main);
    font: inherit;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.crest-tile:hover,
.crest-tile:focus-visible {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md, 0 8px 20px rgba(0, 0, 0, 0.18));
}

.crest-tile:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
}

.crest-tile.is-earned {
    border-color: var(--color-yellow-dark);
    background: linear-gradient(180deg, var(--color-surface) 55%, rgba(251, 191, 36, 0.10));
}

.crest-tile.is-earned .crest {
    animation: crest-float 4.5s ease-in-out infinite;
}

.crest-art {
    display: block;
    width: min(100%, 138px);
}

.crest-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    align-items: center;
}

.crest-tier {
    padding: 1px 9px;
    border-radius: var(--radius-full);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: #1a1204;
}

.crest-tier-bronze { background: #e0a775; }
.crest-tier-silver { background: #d3dae4; }
.crest-tier-gold { background: #f6cf55; }
.crest-tier-platinum { background: #a9e3f1; }

.crest-state {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--color-text-muted);
}

.crest-tile.is-earned .crest-state {
    color: var(--color-primary-dark, var(--color-primary));
}

/* ---------- Részletező ablak és ünneplés ---------- */
.crest-modal-back {
    position: fixed;
    inset: 0;
    z-index: 2200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(5, 8, 15, 0.72);
}

.crest-modal {
    position: relative;
    width: min(100%, 420px);
    max-height: 92vh;
    overflow-y: auto;
    padding: 22px 22px 18px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-text-main);
    text-align: center;
    box-shadow: var(--shadow-lg, 0 20px 60px rgba(0, 0, 0, 0.45));
}

.crest-modal.is-earned {
    animation: crest-glow 3s ease-in-out infinite;
}

.crest-modal .crest-big {
    width: min(70%, 240px);
    margin: 0 auto 8px;
}

.crest-modal.is-fresh .crest-big {
    animation: crest-pop 0.7s cubic-bezier(.2, .9, .3, 1.2);
}

.crest-modal h3 {
    margin: 6px 0 2px;
    font-size: 1.25rem;
    color: var(--color-heading);
}

.crest-motto {
    margin: 0 0 8px;
    font-family: Georgia, 'Times New Roman', serif;
    font-style: italic;
    color: var(--color-text-muted);
}

.crest-desc {
    margin: 8px 0;
    font-size: 0.92rem;
    line-height: 1.5;
}

.crest-how {
    margin: 10px 0 0;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    background: var(--color-surface-variant);
    border: 1px solid var(--color-border);
    font-size: 0.85rem;
    text-align: left;
}

.crest-modal .crest-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 34px;
    height: 34px;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    background: var(--color-surface);
    color: var(--color-text-main);
    font-size: 1rem;
    cursor: pointer;
}

.crest-modal .btn {
    width: auto;
    margin-top: 14px;
}

/* Új jelvény: kis felugró kártya (a gyakorlás közben nem szakítja meg a munkát) */
.crest-toast-stack {
    position: fixed;
    left: 50%;
    top: 70px;
    z-index: 2300;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transform: translateX(-50%);
    pointer-events: none;
}

.crest-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    width: min(92vw, 380px);
    padding: 10px 14px 10px 10px;
    border: 2px solid var(--color-yellow-dark);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-text-main);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
    cursor: pointer;
    animation: crest-pop 0.6s cubic-bezier(.2, .9, .3, 1.2);
}

.crest-toast .crest-art {
    width: 64px;
    flex: 0 0 64px;
}

.crest-toast strong {
    display: block;
    font-size: 0.78rem;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--color-yellow-text);
}

.crest-toast span {
    font-size: 0.95rem;
    font-weight: 700;
}

.crest-toast small {
    display: block;
    color: var(--color-text-muted);
}

/* ---------- Jutalom-kép (a boltban) ---------- */
.fm-reward-art {
    display: inline-block;
    width: 74px;
    height: auto;
    vertical-align: middle;
}

.fm-reward-art .crest {
    width: 100%;
}

@media (prefers-reduced-motion: reduce) {
    .crest-tile.is-earned .crest,
    .crest-modal.is-earned,
    .crest-modal.is-fresh .crest-big,
    .crest-toast {
        animation: none;
    }

    .crest-tile {
        transition: none;
    }
}

@media (max-width: 520px) {
    .crest-wall {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 10px;
    }
}
