/*
GeoRankle Achievements 1.0

Achievement button, gallery, progress cards and unlock toast.
*/

body.achievements-open {
    overflow: hidden;
}

/* =========================================================
   Topbar controls
   ========================================================= */

.game-topbar {
    grid-template-columns:
        auto
        minmax(0, 1fr)
        46px;
}

.game-topbar-left {
    position: relative;
    z-index: 8;

    grid-column: 1;
    grid-row: 1;

    display: flex;
    align-items: center;
    gap: 8px;
}

.game-topbar-left .help-button {
    grid-column: auto;
    grid-row: auto;
}

.achievement-button {
    position: relative;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 46px;
    height: 46px;
    margin: 0;
    padding: 0;

    border: 1px solid #fde68a;
    border-radius: 15px;

    appearance: none;
    -webkit-appearance: none;

    background:
        linear-gradient(
            180deg,
            #fffef4,
            #fff5c2
        );

    color: #854d0e;
    cursor: pointer;

    box-shadow:
        0 8px 20px rgba(202, 138, 4, 0.13),
        inset 0 1px 0 #ffffff;

    transition:
        transform 0.16s ease,
        border-color 0.16s ease,
        box-shadow 0.16s ease;
}

.achievement-button:hover {
    border-color: #facc15;
    transform: translateY(-2px);

    box-shadow:
        0 11px 24px rgba(202, 138, 4, 0.2),
        inset 0 1px 0 #ffffff;
}

.achievement-button:active {
    transform: translateY(1px);
}

.achievement-button:focus-visible {
    outline: 3px solid rgba(250, 204, 21, 0.34);
    outline-offset: 3px;
}

.achievement-button-icon {
    font-size: 21px;
    line-height: 1;
}

.achievement-button-count {
    position: absolute;
    top: -6px;
    right: -6px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 20px;
    height: 20px;
    padding: 0 5px;

    border: 2px solid #ffffff;
    border-radius: 999px;

    background: #f59e0b;
    color: #ffffff;

    font-size: 10px;
    font-weight: 900;
    line-height: 1;

    box-shadow: 0 3px 8px rgba(146, 64, 14, 0.23);
}

/* =========================================================
   Gallery overlay
   ========================================================= */

.achievements-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;

    display: none;
    align-items: center;
    justify-content: center;

    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px;

    overflow-x: hidden;
    overflow-y: auto;

    background:
        radial-gradient(
            circle at 50% 10%,
            rgba(250, 204, 21, 0.24),
            transparent 40%
        ),
        rgba(15, 23, 42, 0.7);

    opacity: 0;

    -webkit-backdrop-filter: blur(11px);
    backdrop-filter: blur(11px);

    overscroll-behavior: contain;

    transition: opacity 0.18s ease;
}

.achievements-overlay.is-visible {
    display: flex;
    opacity: 1;
}

.achievements-overlay[hidden] {
    display: none !important;
}

.achievements-modal {
    position: relative;

    width: min(790px, 100%);
    max-height: calc(100dvh - 48px);
    margin: auto;
    padding: 30px;

    overflow-x: hidden;
    overflow-y: auto;

    border: 1px solid rgba(255, 255, 255, 0.92);
    border-radius: 30px;

    background:
        linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.998),
            rgba(255, 251, 235, 0.99)
        );

    color: #111827;

    box-shadow:
        0 36px 94px rgba(15, 23, 42, 0.44),
        0 12px 34px rgba(15, 23, 42, 0.17),
        inset 0 1px 0 #ffffff;

    scrollbar-width: thin;
    scrollbar-color: #d6d3d1 transparent;

    animation:
        geoRankleAchievementsEnter
        0.32s
        cubic-bezier(0.18, 1.16, 0.35, 1)
        both;
}

.achievements-modal::-webkit-scrollbar {
    width: 8px;
}

.achievements-modal::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: #d6d3d1;
    background-clip: padding-box;
}

.achievements-close {
    position: absolute;
    top: 14px;
    right: 16px;
    z-index: 5;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;

    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 999px;

    appearance: none;
    -webkit-appearance: none;

    background: rgba(226, 232, 240, 0.78);
    color: #475569;

    font: inherit;
    font-size: 27px;
    font-weight: 800;
    line-height: 1;

    cursor: pointer;

    transition:
        transform 0.16s ease,
        background-color 0.16s ease,
        color 0.16s ease;
}

.achievements-close:hover {
    background: #fef3c7;
    color: #92400e;
    transform: rotate(4deg) scale(1.04);
}

.achievements-close:focus-visible,
.achievements-done:focus-visible {
    outline: 3px solid rgba(245, 158, 11, 0.36);
    outline-offset: 3px;
}

/* =========================================================
   Header and collection progress
   ========================================================= */

.achievements-header {
    display: flex;
    flex-direction: column;
    align-items: center;

    margin: 0 44px 21px;

    text-align: center;
}

.achievements-header-icon {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 64px;
    height: 64px;
    margin-bottom: 10px;

    border: 1px solid #fde68a;
    border-radius: 20px;

    background:
        linear-gradient(
            180deg,
            #fffdf0,
            #ffef9c
        );

    font-size: 33px;

    box-shadow:
        0 13px 27px rgba(245, 158, 11, 0.2),
        inset 0 1px 0 #ffffff;
}

.achievements-title {
    margin: 0;

    font-size: 31px;
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -0.5px;
}

.achievements-introduction {
    margin: 7px 0 0;

    color: #64748b;

    font-size: 14px;
    font-weight: 700;
    line-height: 1.45;
}

.achievements-summary {
    margin: 0 0 18px;
    padding: 13px 15px;

    border: 1px solid #fde68a;
    border-radius: 15px;

    background: rgba(255, 251, 235, 0.86);
}

.achievements-summary-content {
    display: grid;
    grid-template-columns: auto minmax(100px, 1fr);
    align-items: center;
    gap: 14px;
}

.achievements-summary-text {
    color: #78350f;

    font-size: 13px;
    font-weight: 900;
    line-height: 1.2;
}

.achievements-summary-track,
.achievement-progress-track {
    position: relative;

    display: block;

    width: 100%;

    overflow: hidden;

    border-radius: 999px;

    background: #e7e5e4;
}

.achievements-summary-track {
    height: 9px;
}

.achievements-summary-fill,
.achievement-progress-fill {
    display: block;

    height: 100%;

    border-radius: inherit;

    background:
        linear-gradient(
            90deg,
            #fbbf24,
            #f59e0b
        );

    transition: width 0.32s ease;
}

/* =========================================================
   Achievement cards
   ========================================================= */

.achievements-grid {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.achievement-card {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    align-items: center;
    gap: 12px;

    min-width: 0;
    padding: 14px;

    border: 1px solid #e2e8f0;
    border-radius: 17px;

    background: #ffffff;

    box-shadow:
        0 6px 16px rgba(15, 23, 42, 0.055),
        inset 0 1px 0 rgba(255, 255, 255, 0.92);

    transition:
        transform 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease;
}

.achievement-card.is-unlocked {
    border-color: #fde68a;

    background:
        linear-gradient(
            145deg,
            #ffffff,
            #fffbeb
        );

    box-shadow:
        0 8px 20px rgba(202, 138, 4, 0.11),
        inset 0 1px 0 #ffffff;
}

.achievement-card.is-unlocked:hover {
    border-color: #facc15;
    transform: translateY(-2px);

    box-shadow:
        0 12px 24px rgba(202, 138, 4, 0.15),
        inset 0 1px 0 #ffffff;
}

.achievement-card.is-locked {
    background: #f8fafc;
}

.achievement-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 54px;
    height: 54px;

    border: 1px solid #e2e8f0;
    border-radius: 16px;

    background: #f1f5f9;

    font-size: 26px;
    line-height: 1;

    box-shadow: inset 0 1px 0 #ffffff;
}

.achievement-card.is-unlocked
    .achievement-card-icon {
    border-color: #fde68a;

    background:
        linear-gradient(
            180deg,
            #fffdf2,
            #ffed9b
        );

    box-shadow:
        0 7px 15px rgba(245, 158, 11, 0.16),
        inset 0 1px 0 #ffffff;
}

.achievement-card-content {
    display: flex;
    flex-direction: column;

    min-width: 0;
}

.achievement-card-title {
    margin: 0 0 3px;

    color: #1f2937;

    font-size: 14px;
    font-weight: 900;
    line-height: 1.2;
}

.achievement-card.is-locked
    .achievement-card-title {
    color: #475569;
}

.achievement-card-description {
    margin: 0;

    color: #64748b;

    font-size: 11px;
    font-weight: 700;
    line-height: 1.35;
}

.achievement-progress-row {
    display: grid;
    grid-template-columns: auto minmax(50px, 1fr);
    align-items: center;
    gap: 8px;

    margin-top: 8px;
}

.achievement-progress-text {
    color: #64748b;

    font-size: 9px;
    font-weight: 900;
    line-height: 1.2;
    white-space: nowrap;
}

.achievement-card.is-unlocked
    .achievement-progress-text {
    color: #a16207;
}

.achievement-progress-track {
    height: 6px;
}

.achievement-card.is-locked
    .achievement-progress-fill {
    background:
        linear-gradient(
            90deg,
            #94a3b8,
            #64748b
        );
}

.achievements-note {
    margin: 15px 0 0;

    color: #64748b;

    font-size: 11px;
    font-weight: 800;
    line-height: 1.4;
    text-align: center;
}

.achievements-done {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 100%;
    min-height: 51px;
    margin: 15px 0 0;
    padding: 12px 20px;

    border: 1px solid #f2c600;
    border-radius: 15px;

    appearance: none;
    -webkit-appearance: none;

    background:
        linear-gradient(
            180deg,
            #ffe866,
            #ffd400 60%,
            #ffc400
        );

    color: #211c00;

    font: inherit;
    font-size: 15px;
    font-weight: 900;
    line-height: 1.2;

    cursor: pointer;

    box-shadow:
        0 9px 19px rgba(255, 208, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.72);

    transition:
        transform 0.17s ease,
        box-shadow 0.17s ease,
        filter 0.17s ease;
}

.achievements-done:hover {
    filter: brightness(1.02);
    transform: translateY(-2px);

    box-shadow:
        0 13px 24px rgba(255, 208, 0, 0.32),
        inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.achievements-done:active {
    transform:
        translateY(0)
        scale(0.985);
}

/* =========================================================
   Unlock notification
   ========================================================= */

.achievement-toast-region {
    position: fixed;
    top: 20px;
    left: 50%;
    z-index: 120000;

    width: min(390px, calc(100% - 28px));

    pointer-events: none;

    transform: translateX(-50%);
}

.achievement-toast {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    align-items: center;
    gap: 12px;

    width: 100%;
    padding: 12px 15px;

    border: 1px solid rgba(253, 230, 138, 0.95);
    border-radius: 18px;

    background:
        linear-gradient(
            145deg,
            rgba(255, 255, 255, 0.99),
            rgba(255, 247, 204, 0.99)
        );

    opacity: 0;

    box-shadow:
        0 20px 44px rgba(15, 23, 42, 0.28),
        0 5px 15px rgba(202, 138, 4, 0.18),
        inset 0 1px 0 #ffffff;

    transform:
        translateY(-18px)
        scale(0.96);

    transition:
        opacity 0.22s ease,
        transform 0.28s cubic-bezier(0.18, 1.16, 0.35, 1);
}

.achievement-toast.is-visible {
    opacity: 1;

    transform:
        translateY(0)
        scale(1);
}

.achievement-toast-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 52px;
    height: 52px;

    border: 1px solid #fde68a;
    border-radius: 15px;

    background: #fff8d5;

    font-size: 27px;

    box-shadow:
        0 6px 14px rgba(245, 158, 11, 0.15),
        inset 0 1px 0 #ffffff;
}

.achievement-toast-content {
    display: flex;
    flex-direction: column;
    gap: 2px;

    min-width: 0;
}

.achievement-toast-eyebrow {
    color: #a16207;

    font-size: 10px;
    font-weight: 900;
    line-height: 1.2;
    letter-spacing: 0.7px;
    text-transform: uppercase;
}

.achievement-toast-title {
    color: #1f2937;

    font-size: 16px;
    font-weight: 900;
    line-height: 1.25;
}

@keyframes geoRankleAchievementsEnter {
    from {
        opacity: 0;
        transform:
            translateY(12px)
            scale(0.975);
    }

    to {
        opacity: 1;
        transform:
            translateY(0)
            scale(1);
    }
}

/* =========================================================
   Responsive layout
   ========================================================= */

@media (max-width: 720px) {
    .achievements-overlay {
        padding: 14px;
    }

    .achievements-modal {
        max-height: calc(100dvh - 28px);
        padding: 27px 20px 21px;

        border-radius: 24px;
    }
}

@media (max-width: 620px) {
    .achievements-grid {
        grid-template-columns:
            minmax(0, 1fr);
    }
}

@media (max-width: 500px) {
    .achievements-overlay {
        align-items: flex-start;
        padding: 9px;
    }

    .achievements-modal {
        width: 100%;
        max-height: calc(100dvh - 18px);
        margin: auto 0;
        padding: 23px 14px 17px;

        border-radius: 20px;
    }

    .achievements-close {
        top: 10px;
        right: 10px;

        width: 36px;
        height: 36px;

        font-size: 24px;
    }

    .achievements-header {
        margin: 0 38px 18px;
    }

    .achievements-header-icon {
        width: 55px;
        height: 55px;

        border-radius: 17px;

        font-size: 28px;
    }

    .achievements-title {
        font-size: 27px;
    }

    .achievements-summary-content {
        grid-template-columns:
            minmax(0, 1fr);
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .game-topbar {
        grid-template-columns:
            auto
            minmax(0, 1fr)
            42px;
    }

    .game-topbar-left {
        gap: 6px;
    }

    .achievement-button {
        width: 42px;
        height: 42px;

        border-radius: 13px;
    }

    .achievement-button-icon {
        font-size: 19px;
    }

    .achievement-button-count {
        top: -5px;
        right: -5px;

        min-width: 18px;
        height: 18px;

        font-size: 9px;
    }
}

@media (max-width: 380px) {
    .game-topbar-left {
        gap: 4px;
    }

    .achievement-button,
    .game-topbar-left .help-button {
        width: 38px;
        height: 38px;
    }

    .achievement-card {
        grid-template-columns: 48px minmax(0, 1fr);
        gap: 10px;

        padding: 12px;
    }

    .achievement-card-icon {
        width: 48px;
        height: 48px;

        font-size: 23px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .achievement-button,
    .achievements-overlay,
    .achievements-modal,
    .achievements-close,
    .achievements-summary-fill,
    .achievement-progress-fill,
    .achievement-card,
    .achievements-done,
    .achievement-toast {
        animation: none;
        transition: none;
    }
}
