/*
GeoRankle How to Play 1.0

Help button and accessible game-guide modal.
*/

body.help-open {
    overflow: hidden;
}

/* =========================================================
   Topbar help button
   ========================================================= */

.help-button {
    position: relative;
    z-index: 8;

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

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

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

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

    appearance: none;
    -webkit-appearance: none;

    background:
        linear-gradient(
            180deg,
            #ffffff,
            #edf7ff
        );

    color: #155e9b;

    font: inherit;
    font-size: 22px;
    font-weight: 900;
    line-height: 1;

    cursor: pointer;

    box-shadow:
        0 8px 20px rgba(15, 23, 42, 0.09),
        inset 0 1px 0 #ffffff;

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

.help-button:hover {
    border-color: #93c5fd;
    transform: translateY(-2px);

    box-shadow:
        0 11px 24px rgba(37, 99, 235, 0.14),
        inset 0 1px 0 #ffffff;
}

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

.help-button:focus-visible {
    outline: 3px solid rgba(18, 146, 242, 0.28);
    outline-offset: 3px;
}

/* =========================================================
   Overlay and modal
   ========================================================= */

.help-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;

    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% 14%,
            rgba(18, 146, 242, 0.2),
            transparent 42%
        ),
        rgba(15, 23, 42, 0.66);

    opacity: 0;

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

    overscroll-behavior: contain;

    transition: opacity 0.18s ease;
}

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

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

.help-modal {
    position: relative;

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

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

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

    background:
        linear-gradient(
            180deg,
            rgba(255, 255, 255, 0.997),
            rgba(246, 251, 255, 0.99)
        );

    color: #111827;

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

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

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

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

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

.help-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;
}

.help-close:hover {
    background: #dbeafe;
    color: #1e40af;
    transform: rotate(4deg) scale(1.04);
}

.help-close:focus-visible,
.help-done:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.36);
    outline-offset: 3px;
}

/* =========================================================
   Header
   ========================================================= */

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

    margin: 0 44px 25px;

    text-align: center;
}

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

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

    border: 1px solid #bfdbfe;
    border-radius: 19px;

    background:
        linear-gradient(
            180deg,
            #eff8ff,
            #d9efff
        );

    font-size: 31px;

    box-shadow:
        0 12px 25px rgba(18, 146, 242, 0.16),
        inset 0 1px 0 #ffffff;
}

.help-title {
    margin: 0;

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

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

    color: #64748b;

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

/* =========================================================
   Shared sections
   ========================================================= */

.help-section {
    margin: 0 0 22px;
}

.help-section-title {
    margin: 0 0 11px;

    color: #334155;

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

/* =========================================================
   Steps
   ========================================================= */

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

.help-step {
    position: relative;

    display: flex;
    flex-direction: column;
    align-items: center;

    min-width: 0;
    padding: 17px 13px;

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

    background:
        linear-gradient(
            180deg,
            #ffffff,
            #eef7ff
        );

    text-align: center;

    box-shadow:
        0 7px 18px rgba(15, 23, 42, 0.06),
        inset 0 1px 0 #ffffff;
}

.help-step-number {
    position: absolute;
    top: 9px;
    left: 10px;

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

    width: 22px;
    height: 22px;

    border-radius: 999px;

    background: #1292f2;
    color: #ffffff;

    font-size: 12px;
    font-weight: 900;
    line-height: 1;
}

.help-step-icon {
    margin-bottom: 8px;

    font-size: 27px;
    line-height: 1;
}

.help-step-title {
    margin: 0 0 5px;

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

.help-step-text {
    margin: 0;

    color: #64748b;

    font-size: 12px;
    font-weight: 700;
    line-height: 1.4;
}

/* =========================================================
   Clues
   ========================================================= */

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

.help-clue {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    gap: 10px;

    min-width: 0;
    padding: 11px 12px;

    border: 1px solid #dbeafe;
    border-radius: 14px;

    background: #f8fbff;
}

.help-clue-symbol {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 42px;
    height: 38px;

    border-radius: 11px;

    font-size: 21px;
    font-weight: 900;
    line-height: 1;
}

.help-clue.is-up
    .help-clue-symbol {
    background: #dbeafe;
    color: #1e40af;
}

.help-clue.is-down
    .help-clue-symbol {
    background: #fee2e2;
    color: #991b1b;
}

.help-clue.is-correct
    .help-clue-symbol {
    background: #dcfce7;
    color: #166534;
}

.help-clue.is-continent
    .help-clue-symbol {
    background: #e0f2fe;
}

.help-clue-content {
    display: flex;
    flex-direction: column;
    gap: 2px;

    min-width: 0;
}

.help-clue-title {
    font-size: 14px;
    font-weight: 900;
    line-height: 1.2;
}

.help-clue-text {
    color: #64748b;

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

/* =========================================================
   Distance colors
   ========================================================= */

.help-distance-list {
    display: grid;
    grid-template-columns:
        repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.help-distance {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 8px;

    min-width: 0;
    padding: 10px;

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

    background: #ffffff;
}

.help-distance-dot {
    grid-row: 1 / span 2;

    width: 13px;
    height: 13px;

    border-radius: 999px;

    box-shadow:
        0 0 0 4px rgba(148, 163, 184, 0.12);
}

.help-distance.is-far
    .help-distance-dot {
    background: #ef4444;
}

.help-distance.is-medium
    .help-distance-dot {
    background: #fb923c;
}

.help-distance.is-close
    .help-distance-dot {
    background: #facc15;
}

.help-distance.is-answer
    .help-distance-dot {
    background: #22c55e;
}

.help-distance-label {
    min-width: 0;

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

.help-distance-value {
    min-width: 0;

    color: #64748b;

    font-size: 10px;
    font-weight: 700;
    line-height: 1.25;
}

/* =========================================================
   Game modes
   ========================================================= */

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

.help-mode-card {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: center;
    gap: 11px;

    min-width: 0;
    padding: 12px 14px;

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

    background: #f8fbff;

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

.help-mode-card.is-active {
    border-color: #93c5fd;
    background: #eaf5ff;

    box-shadow:
        inset 0 0 0 1px rgba(147, 197, 253, 0.34);
}

.help-mode-card[data-help-mode="practice"].is-active {
    border-color: #fde68a;
    background: #fff9d9;

    box-shadow:
        inset 0 0 0 1px rgba(253, 230, 138, 0.42);
}

.help-mode-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 44px;
    height: 44px;

    border-radius: 13px;

    background: #ffffff;

    font-size: 22px;

    box-shadow:
        0 5px 13px rgba(15, 23, 42, 0.08);
}

.help-mode-content {
    display: flex;
    flex-direction: column;
    gap: 3px;

    min-width: 0;
}

.help-mode-title {
    font-size: 14px;
    font-weight: 900;
    line-height: 1.2;
}

.help-mode-text {
    color: #64748b;

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

/* =========================================================
   Primary close action
   ========================================================= */

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

    width: 100%;
    min-height: 51px;
    margin: 3px 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;
}

.help-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);
}

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

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

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

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

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

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

        border-radius: 24px;
    }

    .help-steps {
        grid-template-columns:
            minmax(0, 1fr);
    }

    .help-step {
        display: grid;
        grid-template-columns: 38px minmax(0, 1fr);
        align-items: center;
        gap: 11px;

        padding: 13px 14px 13px 46px;

        text-align: left;
    }

    .help-step-number {
        top: 50%;
        left: 12px;

        transform: translateY(-50%);
    }

    .help-step-icon {
        margin: 0;

        text-align: center;
    }

    .help-distance-list {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }
}

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

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

        border-radius: 20px;
    }

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

        width: 36px;
        height: 36px;

        font-size: 24px;
    }

    .help-header {
        margin: 0 38px 20px;
    }

    .help-header-icon {
        width: 54px;
        height: 54px;

        border-radius: 17px;

        font-size: 28px;
    }

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

    .help-clue-grid,
    .help-mode-grid {
        grid-template-columns:
            minmax(0, 1fr);
    }

    .help-section {
        margin-bottom: 19px;
    }
}

@media (max-width: 480px) {
    .help-button {
        width: 42px;
        height: 42px;

        border-radius: 13px;

        font-size: 20px;
    }
}

@media (max-width: 360px) {
    .help-distance-list {
        grid-template-columns:
            minmax(0, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    .help-button,
    .help-overlay,
    .help-modal,
    .help-close,
    .help-done,
    .help-mode-card {
        animation: none;
        transition: none;
    }
}
