:root {
    --nav-height: 4rem;

    --clr-bg: #0b1220;
    --clr-bg-2: #0f1729;
    --clr-bg-3: #1e293b;
    --clr-text: #e7edf5;
    --clr-muted: #9fb0c6;
    --clr-muted-2: #cbd5e1;
    --clr-border: rgba(148, 163, 184, .18);
    --clr-border-2: rgba(148, 163, 184, .28);
    --clr-accent: rgb(52, 211, 153);
    --clr-accent-2: rgb(34, 211, 238);
    --error: #e7000b;

    --clr-success: rgb(52, 211, 153);
    --clr-success-bg: rgba(52, 211, 153, 0.16);
    --clr-success-border: rgba(52, 211, 153, 0.8);

    --fs-small: 14px;
    --fs-medium: 18px;
    --fs-big: 40px;
    --fs-bigger: 80px;

    --radius: .6rem;

    --gap-small: .4rem;
    --gap-medium: 2rem;
    --gap-big: 5rem;

    --spaceing-1: 0.375rem;
    --spaceing-2: .6rem;
    --spaceing-3: .875rem;
    --spaceing-4: 1rem;
    --spaceing-5: 1.4rem;
    --spaceing-6: 2rem;
    --spaceing-7: 6rem;
}

/* Scrollbar */
*::-webkit-scrollbar {
    width: 8px;
}

*::-webkit-scrollbar-track {
    background: var(--clr-bg);
}

*::-webkit-scrollbar-thumb {
    background: var(--clr-border-2);
    border-radius: 4px;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--clr-muted);
}

main {
    min-height: calc(100vh - var(--nav-height) - 4rem);
    padding: 0 var(--spaceing-4);
}

a.link,
label>a {
    color: var(--clr-accent-2);
    text-decoration: underline 0.1em transparent;
    text-underline-offset: 0.5em;
    transition: all 0.2s ease-in-out;

    &:hover,
    &:focus-visible {
        text-decoration-color: var(--clr-accent-2);
        text-underline-offset: 0.15em;
    }
}

.hidden {
    display: none;
}

.muted {
    color: var(--clr-muted);
}

.inline-block {
    display: inline-block;
}

.b-alert {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    color: var(--clr-success);
    background-color: var(--clr-success-bg);
    border: 1px solid var(--clr-success-border);
    border-radius: var(--radius);

    &.error,
    &:has(.error) {
        --clr-success: rgb(255, 3, 3);
        --clr-success-bg: rgba(220, 17, 1, 0.16);
        --clr-success-border: rgba(241, 6, 6, 0.81);
    }
}

.b-height {
    min-height: calc(100vh - 6rem);
}

.b-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    
    background-color: var(--clr-bg-2);
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--clr-text);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: all .2s ease-in-out;

    &:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    &:hover:not(:disabled) {
        background-color: var(--clr-bg-2);
    }

    &:active:not(:disabled) {
        background-color: var(--clr-bg-3);
    }

    &:focus-visible {
        outline: 1px solid var(--clr-accent);
        outline-offset: 2px;
    }

    &.outlined {
        background: var(--clr-bg-2);
        color: var(--clr-muted);
        border-color: var(--clr-border-2);

        &:hover:not(:disabled) {
            color: var(--clr-text);
        }
    }



    &.cta {ckground: var(--clr-bg);
	                border-color: var(--clr-accent);
			            color: var(--clr-accent);

        font-weight: bold;

        &:hover:not(:disabled) {
            background: var(--clr-bg);
            border-color: var(--clr-accent);
            color: var(--clr-accent);
        }

        &:active:not(:disabled) {
            background: var(--clr-bg-3);
        }
    }

    &.error {
        background-color: rgba(239, 68, 68, 0.1);
        color: #ef4444;
        border-color: rgba(239, 68, 68, 0.3);

        &:hover:not(:disabled) {
            background-color: rgba(239, 68, 68, 0.2);
            border-color: #ef4444;
            box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
        }

        &:active:not(:disabled) {
            background-color: rgba(239, 68, 68, 0.15);
        }
    }

    &.small {
        padding: 0.375rem 0.75rem;
        font-size: 0.8125rem;
        gap: 0.5rem;
    }

    &.full-width {
        width: 100%;
    }

    &.loading {
        position: relative;
        color: transparent;
        pointer-events: none;
        cursor: progress;
        user-select: none;

        &::after {
            content: "";
            position: absolute;
            width: 1rem;
            height: 1rem;
            top: 50%;
            left: 50%;
            margin-left: -0.5rem;
            margin-top: -0.5rem;
            border: 2px solid transparent;
            border-top-color: var(--clr-text);
            border-radius: 50%;
            animation: button-spin 0.6s linear infinite;
        }
    }

    /* Loading spinner color overrides for different button types */
    &.outline.loading::after {
        border-top-color: var(--clr-text);
    }

    &.error.loading::after {
        border-top-color: #ef4444;
    }
}

@keyframes button-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.b-card {
    background-color: var(--clr-bg-2);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    display: flex;
    flex-direction: column;
    gap: var(--spaceing-5);

    h2,
    h3 {
        font-family: 'Courier New', monospace;
        font-size: 1.5rem;
        line-height: 1;
        padding-bottom: var(--spaceing-2);
    }
}

@media (max-width: 640px) {
    .b-card {
        padding: var(--spaceing-5) var(--spaceing-4);
    }
}

.goofy-card {
    margin: 0 auto;
    max-width: 58ch;
    width: 100%;
}

.b-badge {
    padding: var(--spaceing-1) var(--spaceing-3);
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: lowercase;
    letter-spacing: 0.5px;

    &.easy {
        background: rgba(52, 211, 153, 0.15);
        color: var(--clr-accent);
        border: 1px solid rgba(52, 211, 153, 0.3);
    }

    &.medium {
        background: rgba(251, 191, 36, 0.15);
        color: #fbbf24;
        border: 1px solid rgba(251, 191, 36, 0.3);
    }

    &.hard {
        background: rgba(239, 68, 68, 0.15);
        color: #ef4444;
        border: 1px solid rgba(239, 68, 68, 0.3);
    }

    &.available {
        background: rgba(148, 163, 184, 0.15);
        color: var(--clr-muted-2);
        border: 1px solid var(--clr-border-2);
    }

    &.running {
        background: rgba(34, 211, 238, 0.15);
        color: var(--clr-accent-2);
        border: 1px solid rgba(34, 211, 238, 0.3);

        display: inline-flex;
        align-items: center;
        gap: 0.5rem;

        &::before {
            content: '';
            width: 6px;
            height: 6px;
            background-color: var(--clr-accent-2);
            border-radius: 50%;
            animation: pulse 2s ease-in-out infinite;
        }
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

.b-profile-avatar {
    --_width: 120px;
    position: relative;
    width: var(--_width);
    height: var(--_width);
    border: 3px solid var(--clr-accent);
    box-shadow: 0 0 20px rgba(52, 211, 153, 0.3);
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;

    img,
    label {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }

    img {
        object-fit: cover;
    }

    label {
        display: grid;
        place-content: center;
        cursor: pointer;
        color: red;
        background-color: rgba(0, 0, 0, 0.3);
        opacity: 0;
        transition: all .16s ease-in-out;

        &:hover {
            opacity: 1;
        }
    }

    &:has(input:checked) {
        img {
            display: none;
        }

        label {
            opacity: 0;
        }
    }
}

.b-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--clr-accent) 0%, var(--clr-accent-2) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: auto;

    svg {
        width: 60px;
        height: 60px;
        color: var(--clr-bg);
    }
}

/* Filter Chips */
.b-filter-chips {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;

    .b-chip {
        padding: 0.75rem 1.5rem;
        border: 1px solid var(--clr-border-2);
        background: var(--clr-bg-2);
        color: var(--clr-muted);
        border-radius: 2rem;
        font-weight: bold;
        cursor: pointer;
        transition: all 0.2s ease;
        text-transform: capitalize;

        &:hover {
            border-color: var(--clr-accent);
            color: var(--clr-text);
        }

        input {
            display: none;
        }

        &:has(input:checked) {
            background: linear-gradient(135deg, var(--clr-accent), var(--clr-accent-2));
            border-color: transparent;
            color: var(--clr-bg);
        }
    }
}

/* Modal */
.b-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(11, 18, 32, 0.35);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spaceing-5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;

    &.active {
        opacity: 1;
        visibility: visible;

        .b-modal {
            transform: scale(1);
        }
    }

    .b-modal {
        background: var(--clr-bg-2);
        border: 1px solid var(--clr-border-2);
        border-radius: var(--radius);
        max-width: 700px;
        width: 100%;
        max-height: 90vh;
        overflow-y: auto;
        transform: scale(0);
        transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
        position: relative;

        &.expanded {
            transition: all 0.4s ease;
        }

        .modal-header {
            padding: 2rem;
            border-bottom: 1px solid var(--clr-border);
            display: flex;
            justify-content: space-between;
            align-items: center;

            .modal-title {
                font-family: 'Courier New', monospace;
                font-size: 1.75rem;
                font-weight: bold;
                color: var(--clr-text);
            }

            .modal-close {
                color: var(--clr-muted);
                font-size: 1.5rem;
                line-height: 1;
                transition: color 0.2s ease;
            }

            .modal-close:hover {
                color: var(--clr-text);
            }
        }

        .modal-body {
            padding: var(--spaceing-6);

            .modal-info {
                display: grid;
                gap: var(--spaceing-5);
                margin-bottom: var(--spaceing-6);

                .info-row {
                    display: flex;
                    justify-content: space-between;
                    padding-bottom: var(--spaceing-4);
                    border-bottom: 1px solid var(--clr-border);

                    .info-label {
                        color: var(--clr-muted);
                        font-weight: 500;
                    }

                    .info-value {
                        color: var(--clr-text);
                        font-weight: 600;
                        text-align: end;
                    }
                }
            }
        }

        .modal-footer {
            padding: var(--spaceing-6);
            border-top: 1px solid var(--clr-border);
            display: flex;
            justify-content: flex-end;
            gap: var(--spaceing-4);
        }
    }
}

/* Leaderboard */

.sort-chip {
    display: inline-block;
    background-color: var(--clr-bg-2);
    border: 1px solid var(--border);
    border-radius: 100vw;
    width: fit-content;

    /* &:has(input:checked) {
      background-color: var(--border-2);
      border-color: var(--clr-bg-2);
    }

    &:has(input:checked) label svg {
      display: block;
    } */

    input {
        display: none;
    }

    label {
        display: flex;
        gap: .6rem;
        align-items: center;
        padding: .6rem 1rem;
        line-height: 1;
        user-select: none;
        cursor: pointer;

        &.active>svg {
            transform: rotate(180deg);
        }

        svg {
            display: none;
            width: 18px;
            height: 18px;
            transition: rotate .2s ease-in-out;
        }
    }
}

.rank-icon {
    width: 4rem;
    height: 4rem;
    margin: .6rem;
}

.leaderboard-container {
    --_bg: var(--bg-2);
    --clr-border: var(--border);

    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--clr-border);
}

.comparison-table {
    display: grid;
    /* grid-auto-rows: 5rem; */
    grid-template-rows: 4rem max-content;
    align-items: start;
    height: 70vh;
    overflow: auto;

    header {
        display: grid;
        align-self: stretch;
        background-color: #0b1220;
        padding: 0 1rem;
        position: sticky;
        top: 0;
    }

    >.grid-row {
        display: grid;
        grid-template-columns: 1fr 2fr 1fr 1fr;
        gap: 1rem;
        align-items: center;
        justify-items: center;
        padding: 0 1rem;

        &.current-user {
            border: 2px solid rgb(34 211 238 / 0.6);
            background: rgb(34 211 238 / 0.06);
            border-radius: 6px;
        }

        p {
            margin: 0;
        }

        >*:nth-child(2) {
            justify-self: start;
        }

        .user-info {
            display: flex;
            align-items: center;
            gap: 1rem;
            text-decoration: none;
            color: var(--text);
            border: 1px solid transparent;
            border-radius: 100vw;
            padding: .4rem 1.4rem .4rem 1rem;
            margin-block: 0.4rem;

            &:hover {
                border: 1px solid var(--clr-border);
            }

            img {
                width: 2.6rem;
                height: 2.6rem;
                object-fit: cover;
                border-radius: 100vw;
            }

            .name {
                font-weight: bold;
            }
        }
    }

    > :not(header) {
        >*:nth-child(3) {
            color: green;
        }
    }

    >*+* {
        border-top: 1px solid var(--clr-border);
    }
}
