: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;

    --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;

    color-scheme: dark;
}

/* Scrollbar */
*::-webkit-scrollbar {
    width: 6px;
    height: 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);
}

body {
	background: var(--clr-bg);
	color: var(--clr-text);
}

header#main {
    min-height: var(--nav-height);
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    justify-content: center;

    /* backdrop-filter: blur(8px); */
    background-color: var(--clr-bg-2);
    border-bottom: 1px solid var(--clr-border);

    .logo-container {
        display: flex;
        align-items: center;
        gap: .4rem;
        font-weight: bold;

        a {
            display: flex;
            align-items: center;
            font-size: 24px;
        }

        a > svg {
            color: var(--clr-accent);
            transition: transform 0.2s ease-in-out;
            display: inline-block;
        }
        a:hover > svg {
            transform: rotate(30deg);
        }
    }

    a:not(.button) {
        color: var(--clr-text);
        text-decoration: none;
        font-weight: bold;
        transition: all .2s ease;
    }

    nav.desktop {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: space-between;
        max-width: 80rem;
        width: 80rem;
        padding: 0 1rem;

        .links-container,
        .auth-container {
            height: 100%;
            display: flex;
            gap: 2rem;

            &:has(.button + .button) {
                gap: .5rem;
            }

            >*:not(.button) {
                display: grid;
                place-content: center;
                position: relative;

                &::after {
                    content: "";
                    position: absolute;
                    width: 0;
                    height: 2px;
                    bottom: 0;
                    left: 50%;
                    transform: translateX(-50%);
                    background: linear-gradient(90deg, #34d399, #22d3ee);
                    transition: width 0.2s ease;
                }

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

                &:hover::after {
                    width: 100%;
                }

                &.active {
                    color: var(--clr-accent);
                }

                &.active::after {
                    width: 100%;

                    /* @starting-style {
                        width: 4px;
                    } */
                }
            }

            .button {
                align-self: center;
            }
        }
    }

    nav.mobile {
        flex: 1;
        display: none;
        grid-template-rows: var(--nav-height) 0fr;
        padding: 0 1rem;
        /* backdrop-filter: blur(8px); */
        background-color: var(--clr-bg-2);
        transition: all .2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        z-index: 3;

        .nav-toggle {
            label {
                border: 1px solid white;
                border-radius: 100vw;
                display: inline-block;
            }

            /* https://jonsuh.com/hamburgers/ */
            .hamburger {
                padding: 15px 15px;
                display: inline-block;
                cursor: pointer;
                transition-property: opacity, filter;
                transition-duration: 0.15s;
                transition-timing-function: linear;
                font: inherit;
                color: inherit;
                text-transform: none;
                background-color: transparent;
                border: 0;
                margin: 0;
                overflow: visible;
            }

            .hamburger:hover {
                opacity: 0.7;
            }

            .hamburger.is-active:hover {
                opacity: 0.7;
            }

            .hamburger.is-active .hamburger-inner,
            .hamburger.is-active .hamburger-inner::before,
            .hamburger.is-active .hamburger-inner::after {
                background-color: var(--clr-accent-2);
            }

            .hamburger-box {
                width: 40px;
                height: 24px;
                display: inline-block;
                position: relative;
            }

            .hamburger-inner {
                display: block;
                top: 50%;
                margin-top: -2px;
            }

            .hamburger-inner,
            .hamburger-inner::before,
            .hamburger-inner::after {
                width: 40px;
                height: 4px;
                background-color: var(--clr-accent-2);
                border-radius: 4px;
                position: absolute;
                transition-property: transform;
                transition-duration: 0.15s;
                transition-timing-function: ease;
            }

            .hamburger-inner::before,
            .hamburger-inner::after {
                content: "";
                display: block;
            }

            .hamburger-inner::before {
                top: -10px;
            }

            .hamburger-inner::after {
                bottom: -10px;
            }

            .hamburger--squeeze .hamburger-inner {
                transition-duration: 0.075s;
                transition-timing-function: cubic-bezier(0.55, 0.055, 0.675, 0.19);
            }

            .hamburger--squeeze .hamburger-inner::before {
                transition: top 0.075s 0.12s ease, opacity 0.075s ease;
            }

            .hamburger--squeeze .hamburger-inner::after {
                transition: bottom 0.075s 0.12s ease, transform 0.075s cubic-bezier(0.55, 0.055, 0.675, 0.19);
            }

            #nav-content-toggle {
                display: none;
            }
        }

        .mobile-nav-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .mobile-nav-content {
            overflow: hidden;
            opacity: 0;
            visibility: hidden;
            transition: all .3s ease-in;

            .links-container {
                display: flex;
                flex-direction: column;
                gap: 1rem;
                padding: 1rem;
                font-weight: bold;
            }

            .links-container>* {
                padding: 1rem;
                font-size: 1.1rem;
                text-align: center;
                border-radius: var(--radius);
                transition: all .2s ease-in-out;

                &:hover {
                    color: var(--clr-accent-2);
                    background-color: var(--clr-bg-3);
                }

                &.active {
                    color: var(--clr-bg);
                    background-color: rgb(8, 128, 146);
                }
            }
        }
    }

    /* mobile nav toggle */
    .mobile:has(#nav-content-toggle:checked),
    .mobile:has(.hamburger--squeeze.is-active) {
        grid-template-rows: var(--nav-height) 1fr;
    }

    .mobile:has(#nav-content-toggle:checked) .mobile-nav-content,
    .mobile:has(.hamburger--squeeze.is-active) .mobile-nav-content {
        opacity: 1;
        visibility: visible;
    }

    #nav-content-toggle:checked+label .hamburger-inner,
    .hamburger--squeeze.is-active .hamburger-inner {
        transform: rotate(45deg);
        transition-delay: 0.12s;
        transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
    }

    #nav-content-toggle:checked+label .hamburger-inner::before,
    .hamburger--squeeze.is-active .hamburger-inner::before {
        top: 0;
        opacity: 0;
        transition: top 0.075s ease, opacity 0.075s 0.12s ease;
    }

    #nav-content-toggle:checked+label .hamburger-inner::after,
    .hamburger--squeeze.is-active .hamburger-inner::after {
        bottom: 0;
        transform: rotate(-90deg);
        transition: bottom 0.075s ease, transform 0.075s 0.12s cubic-bezier(0.215, 0.61, 0.355, 1);
    }
}

@media (max-width: 1024px) {
    header#main {
        backdrop-filter: none;
        border-bottom: 1px solid transparent;
    }

    nav.desktop {
        display: none !important;
    }

    nav.mobile {
        display: grid !important;
        border-bottom: 1px solid var(--clr-border);
    }
}

footer {
    background: var(--clr-bg-2);
    border-top: 1px solid var(--clr-border);
    padding: 1rem;

    .footer-content {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
        text-align: center;
    }

    .footer-logo {
        font-size: 1.5rem;
        font-weight: 700;
        background: linear-gradient(135deg, var(--clr-accent) 0%, var(--clr-accent-2) 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }

    .footer-links {
        display: flex;
        gap: 2rem;
        flex-wrap: wrap;
        justify-content: center;

        a {
            color: var(--clr-muted);
            font-size: 0.95rem;

            /* &:hover {
                color: var(--clr-accent);
            } */
        }
    }

    .footer-copyright {
        color: var(--clr-muted);
        font-size: 0.875rem;
    }
}

.link {
    color: var(--color-secondary);
    text-decoration: underline 0.1em transparent;
    text-underline-offset: 0.5em;
    transition: all 0.2s ease-in-out;

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

    &:has(svg) {
        display: inline-flex;
        align-items: center;
        gap: .5rem;
    }
}

/* .button {
    padding-block: 0.75rem;
    padding-inline: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    border: 1px solid oklch(37.2% .044 257.287);
    border-radius: 8px;
    line-height: 1;
    font-size: 1.1rem;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;

    > svg {
        width: 1.2rem;
        height: 1.2rem;
    }

    &:has(svg) {
        padding-inline: 0.75rem;
    }

    &:hover {
        color: oklch(69.6% .17 162.48);
        border-color: oklch(69.6% .17 162.48);
    }
} */

.button {
    padding: 0.625rem 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    background-color: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--color-foreground);
    text-decoration: none;
    white-space: nowrap;
    outline: 2px solid transparent;
    cursor: pointer;

    &:hover:not(:disabled) {
        background-color: var(--color-muted);
    }

    /* &:active:not(:disabled) {
        transform: scale3d(0.95, 0.95, 0.95);
    } */

    &:focus-visible {
        outline: 2px solid var(--color-primary);
        outline-offset: 4px;
    }

    &.outlined {
        background: var(--color-card);
        color: var(--color-foreground);
        border-color: var(--color-border);

        &:hover:not(:disabled) {
            color: var(--color-primary);
            border-color: rgba(52, 211, 153, 0.3);
        }
    }

    &.cta {
        color: var(--color-background);
        font-weight: bold;
        background-size: 300% 100%;
        background-image: linear-gradient(to right, var(--color-primary), rgb(52, 211, 200), white, rgb(34, 238, 214), var(--color-secondary));
        transition: all .2s ease-in-out;

        &:hover {
            background-position: 100% 0;
        }
    }

    &.error {
        color: var(--color-destructive);
        border-color: var(--color-destructive-light);

        &:hover:not(:disabled) {
            color: var(--color-destructive);
            background-color: var(--color-destructive-lighter);
            border-color: var(--color-destructive-light);
        }

        &:active:not(:disabled) {
            background-color: var(--color-destructive-lighter);
        }
    }

    &.small {
        padding: 0.375rem 0.75rem;
        font-size: var(--fs-small);
        gap: 0.5rem;
    }

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

    .loading-icon {
        width: 0px;
        aspect-ratio: 1/1;
        transition: all .2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    }
    &:has(.loading-icon) {
        padding-right: .75rem;
    }
    &.loading {
        padding-right: 1.25rem;
        cursor: progress;
        user-select: none;

        /* reveal loading icon on loading class */
        .loading-icon {
            width: 16px; /* TODO: add variable size later */
        }
    }

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

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

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

/* htmx request state — any hx-* form gets a spinner on its submit button */
/* reveal loading icon on loading class */
form.htmx-request .button .loading-icon {
    width: 16px; /* TODO: add variable size later */
}

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

    h2,
    h3 {
        font-size: 1.5rem;
        line-height: 1;
    }
}

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

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

.profile-picture-section {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 1.5rem;
	padding-bottom: 1.6rem;
	border-bottom: 1px solid var(--clr-border);
}

.b-dropdown {
	position: relative;

	button {
		width: 100%;
		padding: 1rem;
		justify-content: space-between;
		border: 1px solid var(--clr-border);

		&:focus {
			outline: none;
			border-color: var(--clr-accent);
			box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.1);
		}

		& svg {
			width: 24px;
			height: 24px;
			transition: transform 0.2s ease;
		}

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

	.b-dropdown-menu {
		position: absolute;
		top: calc(100% + 0.5rem);
		left: 0;
		right: 0;
		background-color: var(--clr-bg-2);
		border: 1px solid var(--clr-border-2);
		border-radius: 0.5rem;
		max-height: 250px;
		overflow-y: auto;
		z-index: 5;
		box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
		opacity: 0;
		visibility: hidden;
		transform: translateY(-10px);
		transition: all 0.2s ease-in-out;

		&.open {
			opacity: 1;
			visibility: visible;
			transform: translateY(0);
		}
	}

	.dropdown-search {
		position: sticky;
		top: 0;
		padding: 0.75rem;
		background-color: var(--clr-bg-2);
		border-bottom: 1px solid var(--clr-border);

		input {
			width: 100%;
			padding: 0.5rem;
			background-color: var(--clr-bg);
			border: 1px solid var(--clr-border);
			border-radius: 0.25rem;
			color: var(--clr-text);
			font-size: 0.875rem;
		}

		input:focus {
			outline: none;
			border-color: var(--clr-accent);
		}
	}

	.dropdown-option {
		padding: 0.75rem 1rem;
		cursor: pointer;
		transition: background-color 0.15s ease;
		font-size: 0.875rem;

		&:hover {
			background-color: rgba(52, 211, 153, 0.1);
		}

		&.selected {
			background-color: rgba(52, 211, 153, 0.15);
			color: var(--clr-accent);
		}
	}
}
/* Modal */
.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);
        }
    }
}

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

/* code block */
.code-block {
    margin-top: 1rem;
    padding: var(--spaceing-4);
    background: var(--clr-bg-2);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;

    + *:not(.code-block) {
        margin-top: 1rem;
    }

    .code-block-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: var(--spaceing-3);
    }

    code {
        display: block;
        color: var(--clr-accent);
        font-size: 1rem;

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

/* FAQ and tutorial section */
.faq-section,
.tutorial-section {
    display: grid;
    grid-template-columns: 3fr 2fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
        "header header"
        "article aside";
    column-gap: var(--spaceing-6);

    header {
        grid-area: header;
    }

    article,
    .main-content {
        grid-area: article;

        .tut-block:not(.tut-block:first-child),
        .tut-hr {
            margin-top: 2rem;
        }

        h2 {
            padding-top: 0.6rem;
        }
    }

    aside {
        grid-area: aside;
        align-self: start;
        position: sticky;
        top: calc(var(--nav-height) + 1rem);
    }
}

@media (max-width: 1024px) {

    .faq-section,
    .tutorial-section {
        display: block;
    }

    aside {
        margin-block: var(--spaceing-6);
    }
}

.b-badge {
    --_clr-bg: var(--clr-bg);
    --_clr-text: var(--clr-muted-2);

    width: fit-content;
    height: fit-content;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: var(--spaceing-1) var(--spaceing-3);
    border-radius: var(--radius);
    color: var(--_clr-text);
    border: 1px solid var(--_clr-text);
    background: color-mix(in oklch, var(--_clr-bg) 80%, transparent);
    backdrop-filter: blur(6px);
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: lowercase;
    letter-spacing: 0.5px;

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

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

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

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

    &.under-dev {
        background: rgba(228, 209, 43, .15);
        border: 1px solid rgba(228, 209, 43, .45);
        color: #e4d12b;
    }

    &.gray,
    &.grey {
        background: rgba(148, 163, 184, 0.1);
        color: var(--clr-muted);
        border: 1px solid var(--clr-border);
    }

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

    /* Membership, not status — accent colored but no pulsing dot. */
    &.joined {
        background: rgba(52, 211, 153, 0.15);
        color: var(--clr-accent);
        border: 1px solid rgba(52, 211, 153, 0.3);
    }

    &.running {
        --_clr-bg: var(--clr-accent);
        --_clr-text: var(--clr-accent);
        background: color-mix(in oklch, var(--_clr-bg) 40%, transparent);
        /* background: rgba(52, 211, 153, 0.15);
        color: var(--clr-accent);
        border: 1px solid rgba(52, 211, 153, 0.3); */

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

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* Billing — current plan + history tables on the pricing page.
   Scoped to .sub-dashboard: .status-active also exists inside .comp-table with
   a different look, and the two must not meet. */
.sub-dashboard {
    margin-bottom: 3rem;

    h2 {
        color: #fff;
        font-size: 1.25rem;
        margin-bottom: 0.75rem;
    }

    h2 + h2,
    .sub-table-scroll + h2 {
        margin-top: 2.5rem;
    }

    .sub-table-scroll {
        overflow-x: auto;
        background: var(--clr-bg-2);
        border: 1px solid var(--clr-border);
        border-radius: 1rem;
    }

    .sub-table {
        width: 100%;
        border-collapse: collapse;
        min-width: 40rem;

        th,
        td {
            padding: 0.9rem 1.25rem;
            text-align: left;
            vertical-align: top;
        }

        th {
            background: var(--clr-bg-3);
            color: var(--clr-muted);
            font-size: 0.7rem;
            font-weight: 700;
            letter-spacing: 0.06em;
            text-transform: uppercase;
        }

        tbody tr + tr {
            border-top: 1px solid var(--clr-border);
        }

        /* History is context, not the thing you came for. */
        tr.is-past {
            opacity: 0.65;
        }
    }

    .align-right {
        text-align: right;
    }

    .sub-plan {
        color: #fff;
        font-weight: 700;
    }

    .sub-price {
        color: var(--clr-accent);
        font-size: 0.85rem;
    }

    .sub-ref,
    .sub-note {
        color: var(--clr-muted);
        font-size: 0.7rem;
    }

    .sub-ref {
        font-family: var(--font-mono, monospace);
        margin-top: 0.2rem;
        word-break: break-all;
    }

    .sub-note {
        font-size: 0.75rem;
        margin-top: 0.25rem;
    }

    .sub-date {
        color: var(--clr-text);
        font-size: 0.9rem;
        white-space: nowrap;
    }

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

    .status-pill {
        display: inline-block;
        padding: 0.2rem 0.7rem;
        border-radius: 999px;
        border: 1px solid var(--clr-border);
        font-size: 0.7rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        white-space: nowrap;
    }

    /* Anything without its own rule keeps the neutral pill above. */
    .status-active,
    .status-trialing {
        border-color: var(--clr-accent);
        background: rgba(52, 211, 153, 0.12);
        color: var(--clr-accent);
    }

    .status-past_due,
    .status-unpaid,
    .status-incomplete {
        border-color: #f59e0b;
        background: rgba(245, 158, 11, 0.12);
        color: #fbbf24;
    }

    .status-canceled,
    .status-refunded,
    .status-incomplete_expired {
        border-color: #ef4444;
        background: rgba(239, 68, 68, 0.1);
        color: #f87171;
    }

    .btn-cancel {
        padding: 0.45rem 1rem;
        border-radius: var(--radius);
        border: 1px solid rgba(239, 68, 68, 0.5);
        background: transparent;
        color: #f87171;
        font-size: 0.85rem;
        cursor: pointer;
        transition: background 0.2s ease;

        &:hover {
            background: rgba(239, 68, 68, 0.1);
        }
    }

    /* Same geometry as .btn-cancel, neutral tone: opening the Stripe portal is
       not a destructive action. */
    .btn-portal {
        padding: 0.45rem 1rem;
        border-radius: var(--radius);
        border: 1px solid rgba(148, 163, 184, 0.5);
        background: transparent;
        color: inherit;
        font-size: 0.85rem;
        cursor: pointer;
        transition: background 0.2s ease;

        &:hover {
            background: rgba(148, 163, 184, 0.12);
        }
    }
}

/* Toasts — used to be AlpineJS x-transition; now the enter animation is pure
   CSS (so there is no FOUC and no x-cloak equivalent to worry about) and only
   the timing lives in project.js. */
@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-0.5rem);
    }
}

.toast {
    animation: toast-in 0.3s ease both;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Generic: banner.html's alerts leave through this same class. */
.is-dismissing {
    opacity: 0;
    transform: translateY(-1.25rem);
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .toast {
        animation: none;
    }

    .toast,
    .is-dismissing {
        transition: opacity 0.01ms;
    }
}

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

    > * {
        --_active-color: #34d399;

        padding: 0.4rem 1.2rem;
        border: 1px solid var(--clr-border-2);
        background: var(--clr-bg-2);
        color: var(--clr-muted);
        border-radius: 2rem;
        font-weight: bold;
        cursor: pointer;
        user-select: none;
        transition: all 0.2s ease-in-out, padding 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);

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

        input {
            display: none;
        }

        /* text content */
        *:not(input) {
            --_size: 0;

            position: relative;

            /* the dot */
            &::after {
                content: "";
                position: absolute;
                width: var(--_size);
                height: var(--_size);
                border-radius: 50%;
                top: 50%;
                right: -1.2rem;
                transform: translateY(-50%);
                background: var(--_active-color);
                transition: width 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
                /* transform-origin: right center; */
                transform-origin: left;
            }
        }

        &:has(input:checked) {
            background: rgba(52, 211, 153, 0.15);
            border-color: var(--clr-accent);
            color: var(--clr-accent);

            padding-right: 2rem;

            :not(input)::after {
                --_size: 10px;
            }
        }

        &[for="medium"] {
            --_active-color: #fbbf24;
        }
        &[for="hard"] {
            --_active-color: var(--error);
        }
    }
}

/* Accordion */
.b-accordion {
    --_label-height: 4rem;
    --_clr-border: transparent;
    margin: 1rem auto;
    width: 100%;
    max-width: 64rem;
    display: grid;
    grid-template-rows: var(--_label-height) 0fr;
    transition: all .2s ease-in-out;
    background-color: var(--clr-bg-2);
    border: 1px solid var(--_clr-border);
    border-radius: var(--radius);

    &:first-of-type {
        margin-top: 0;
    }

    &:last-of-type {
        margin-bottom: 0;
    }

    &:has(label:hover) {
        --_clr-border: var(--clr-border);
    }

    &:has(input:checked) {
        grid-template-rows: var(--_label-height) 1fr;
        --_clr-border: var(--clr-border);

        .content {
            opacity: 1;
        }
    }

    &:not(:has(input:checked)) label svg {
        transform: rotate(0deg);
    }

    >input {
        display: none;
    }

    label {
        padding: 0 1rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
        cursor: pointer;
        user-select: none;

        svg {
            width: 18px;
            height: 18px;
            transform: rotate(90deg);
            transition: all .2s ease-in-out;
            color: var(--clr-text);
        }
    }

    .content {
        overflow: hidden;
        opacity: 0;
        transition: all .4s ease-in-out;

        >* {
            padding: 0 1rem 1rem;
            color: var(--clr-muted);

            >*+* {
                margin-top: var(--spaceing-2);
            }
        }
    }
}

/* Competition table — status-coded rows + chip filtering.
   Scoped to .comp-table: the leaderboard uses the same .table/.content classes
   and must not inherit any of this. */
.comp-table {
    .comp-info {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    /* Bar on every status so the 3px never shifts the grid between rows. */
    .content {
        border-left: 3px solid transparent;

        &.status-upcoming {
            border-left-color: var(--clr-accent-2);
            background: rgba(34, 211, 238, 0.04);
        }

        &.status-active {
            border-left-color: var(--clr-accent);
            background: rgba(52, 211, 153, 0.05);
        }

        &.status-completed {
            border-left-color: var(--clr-border);
            opacity: 0.6;
        }
    }

    /* Filter: JS marks matches with .show, this hides the rest. No chip
       checked = no .show anywhere = every row visible. */
    &:has(.content.show) .content:not(.show) {
        display: none;
    }
}

/* Table */
.table {
    background: var(--clr-bg-2);
    border: 1px solid var(--clr-border);
    border-radius: 1rem;
    width: 100%;
    overflow-x: auto;

    header,
    .content {
        display: grid;
        grid-template-columns: 70px minmax(10rem, 1fr) 120px 100px;
        place-items: center;
        gap: 1rem;
        padding: 15px 20px;
        min-width: fit-content;
    }

    header {
        background: var(--clr-bg-3);
        font-size: 0.9rem;
        font-weight: bold;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: var(--clr-muted);
    }

    .content {
        border-bottom: 1px solid var(--clr-border);

        &:last-of-type {
            border-bottom: none;
        }

        &:hover {
            background: rgba(52, 211, 153, 0.03);
        }

        .comp-name-link {
            position: relative;
            height: 100%;
            color: var(--clr-text);
            text-decoration: none;
            font-weight: 600;
            font-size: 1rem;
            transition: color 0.2s ease;
            display: flex;
            align-items: center;
            gap: 0.5rem;

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

            & svg {
                width: 16px;
                height: 16px;
                opacity: 0;
                transform: translateX(-4px);
                transition: all 0.2s ease;
            }

            &:hover svg {
                opacity: 1;
                transform: translateX(0);
            }

            .crown-icon {
                position: absolute;
                top: 5px;
                left: 0;
                width: 20px;
                height: 20px;
                transform: rotateZ(-40deg);
            }
        }

        .schedule-cell {
            display: grid;
            place-self: center;
            gap: 0.25rem;
        }

        .schedule-dates {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            color: var(--clr-text);
        }

        .schedule-dates svg {
            width: 16px;
            height: 16px;
            color: var(--clr-accent-2);
            flex-shrink: 0;
        }

        .schedule-arrow {
            color: var(--clr-muted)!important;
        }

        .schedule-duration {
            font-size: 0.9375rem;
            color: var(--clr-muted);
            padding-left: 1.5rem;
        }
    }

    .name-wrapper {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }
}

/* ---------------------------------------------------------------------------
   Success feedback: flag reveal, htmx request states, toast check draw.
   All motion is disabled under prefers-reduced-motion at the bottom. */

/* Tutorial quiz flag card */
@keyframes flag-card-in {
    from {
        opacity: 0;
        transform: translateY(0.5rem);
    }
}

@keyframes flag-glow {
    0% {
        text-shadow: none;
    }

    40% {
        text-shadow: 0 0 14px rgba(34, 211, 238, 0.8);
    }

    100% {
        text-shadow: 0 0 6px rgba(52, 211, 153, 0.35);
    }
}

/* Height growth: the wrapper transitions 0fr -> 1fr, so the quiz card grows
   smoothly instead of jumping when the flag appears. Initial 0fr state comes
   from .htmx-added, which htmx removes on settle. */
.tut-flag-wrap {
    display: grid;
    grid-template-rows: 1fr;
    transition: all 0.3s ease-out;

    > .tut-flag-card {
        overflow: hidden;
        min-height: 0;
        /* the margin sits outside the clipped box, so it animates separately */
        transition: margin-top 0.3s ease-out;
    }
}

/* The swapped-in quiz card is content-identical to the old one — fading the
   whole card would flicker, so only the flag area animates. */
#quiz-card.htmx-added {
    opacity: 1;
}

#quiz-card.htmx-added .tut-flag-wrap {
    grid-template-rows: 0fr;

    > .tut-flag-card {
        margin-top: 0;
    }
}

.tut-flag-card {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    border: 1px solid rgba(52, 211, 153, 0.3);
    border-radius: var(--radius);
    background: rgba(52, 211, 153, 0.08);
    animation: flag-card-in 0.3s ease-out both;
}

.tut-flag-code {
    margin-top: 0.5rem;
    font-family: monospace;
    font-size: 1.125rem;
    letter-spacing: 2px;
    color: var(--clr-accent-2);
    /* glow starts as the scramble (600ms, flagReveal.js) settles */
    animation: flag-glow 1.2s ease-out 0.6s 1 both;
}

/* htmx request state — any hx-* form gets a spinner on its submit button */
/* @keyframes button-spinner {
    to {
        transform: rotate(360deg);
    }
}

form.htmx-request button[type="submit"] {
    opacity: 0.75;
    pointer-events: none;

    &::after {
        content: "";
        width: 1em;
        height: 1em;
        margin-left: 0.5em;
        border: 2px solid currentColor;
        border-top-color: transparent;
        border-radius: 50%;
        animation: button-spinner 0.6s linear infinite;
    }
} */

/* htmx swap settle: freshly inserted content fades in */
/* .htmx-added {
    opacity: 0;
}

.htmx-settling {
    transition: opacity 0.25s ease-out;
} */

/* Success toast: the check draws itself */
.toast-check path {
    stroke-dasharray: 12;
    stroke-dashoffset: 12;
    animation: check-draw 0.4s ease-out 0.15s forwards;
}

@keyframes check-draw {
    to {
        stroke-dashoffset: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tut-flag-card,
    .tut-flag-code,
    .toast-check path,
    form.htmx-request button[type="submit"]::after {
        animation: none;
    }

    .tut-flag-wrap,
    .tut-flag-wrap > .tut-flag-card {
        transition: none;
    }

    .toast-check path {
        stroke-dashoffset: 0;
    }

    form.htmx-request button[type="submit"]::after {
        content: none;
    }

    .htmx-added {
        opacity: 1;
    }
}
