/* Theme variables and shared assets */
:root {
    --dark-blue: #12161c;
    --blue: #2f6fed;

    --dyslexia-font: "OpenDyslexic", sans-serif;
    --normal-font: "noto-sans", sans-serif;

    --grid-background:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
}

/* Font definitions */
@font-face {
    font-family: "OpenDyslexic";
    src: url("../fonts/OpenDyslexic-Regular.otf") format("opentype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "noto-sans";
    src: url("../fonts/NotoSansNerdFont-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* Global layout and typography */
html,
body {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    min-height: 100%;
}

*,
*::before,
*::after {
    box-sizing: inherit;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 0;

    background-color: var(--dark-blue);
    background-image: var(--grid-background);
    background-size: 18px 18px;

    font-family: var(--normal-font);
    font-size: 18px;
    color: #e5eaf3;
}

body.dyslexia-mode {
    font-family: var(--dyslexia-font);
}

main {
    flex: 1;
}

/* Page loading overlay */
#page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #12161c;
    z-index: 99999;
    pointer-events: none;
    transition:
        opacity 0.25s ease,
        visibility 0.25s;
}

#page-loader .progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 2px;
    width: 0%;
    background: linear-gradient(90deg, #6366f1, #a855f7);
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.6);
    transition: width 0.2s ease-out;
}

#page-loader.is-done {
    opacity: 0;
    visibility: hidden;
}

/* Header layout */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 16px 24px;
}

/* Navigation layout and links */
nav ul {
    display: flex;
    flex-flow: row wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;

    margin: 0;
    padding: 0;
    list-style: none;
}

nav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 12px;

    color: #aab7cc;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;

    transition:
        color 200ms ease,
        background-color 200ms ease,
        border-color 200ms ease,
        transform 200ms ease;
}

/* Navigation interaction states */
nav a:hover {
    color: #ffffff;
    background-color: rgb(255 255 255 / 5%);
    border-color: rgb(255 255 255 / 8%);
    transform: translateY(-1px);
}

nav a[aria-current="page"] {
    color: #ffffff;
    background-color: rgb(47 111 237 / 16%);
    border-color: rgb(47 111 237 / 35%);
}

nav a.active {
    position: relative;
    border: none;
    border-radius: 12px;
    background-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.15);
}

nav a.active::before {
    content: "";
    position: absolute;
    inset: 0;
    padding: 1px;
    border-radius: inherit;
    background: linear-gradient(
        135deg,
        transparent 0%,
        transparent 5%,
        rgba(168, 85, 247, 0.3) 25%,
        rgba(168, 85, 247, 0.3) 100%
    );
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

nav a:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 4px;
}

/* Font toggle button */
.font-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;

    width: 48px;
    height: 48px;
    padding: 0;

    position: relative;

    background: #202630;
    border: 1px solid #3a4352;
    border-radius: 14px;

    color: #e5eaf3;
    cursor: pointer;

    box-shadow:
        0 2px 8px rgb(0 0 0 / 12%),
        inset 0 1px 0 rgb(255 255 255 / 3%);

    transition:
        background-color 250ms ease,
        border-color 250ms ease,
        box-shadow 250ms ease,
        transform 180ms ease;
}

/* Font toggle label */
.font-toggle__thumb {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    font-family: var(--dyslexia-font);
    font-size: 19px;
    font-weight: 400;
    line-height: 1;

    color: #dce5f5;

    transform: scale(1) rotate(0deg);
    transform-origin: center;

    transition:
        color 220ms ease,
        transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1),
        font-size 220ms ease;
}

/* Font toggle active state */
.font-toggle[aria-pressed="true"] {
    background: rgb(47 111 237 / 16%);
    border-color: var(--blue);

    box-shadow:
        0 0 0 1px rgb(47 111 237 / 10%),
        0 0 14px rgb(47 111 237 / 12%);
}

.font-toggle[aria-pressed="true"] .font-toggle__thumb {
    font-family: var(--normal-font);
    font-weight: 700;
    color: #70a0ff;
    transform: scale(1.08);
}

/* Font toggle interaction states */
.font-toggle:hover {
    border-color: var(--blue);
    background-color: #252e3c;
}

.font-toggle[aria-pressed="true"]:hover {
    background: rgb(47 111 237 / 24%);
}

.font-toggle:hover .font-toggle__thumb {
    color: #ffffff;
}

.font-toggle:active {
    transform: scale(0.94);
}

.font-toggle:active .font-toggle__thumb {
    transform: scale(0.92);
}

.font-toggle:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 4px;
}

/* Footer layout */
footer {
    display: flex;
    justify-content: center;
    align-items: flex-end;

    .copyright-symbol {
        font-family: var(--normal-font);
    }
}

/* Mobile layout */
@media (max-width: 600px) {
    header {
        flex-wrap: wrap;
        padding: 16px;
    }

    nav {
        width: 100%;
    }

    nav ul {
        justify-content: flex-start;
        gap: 6px;
    }

    nav a {
        padding: 9px 12px;
        font-size: 14px;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    nav a,
    .font-toggle,
    .font-toggle__thumb {
        transition: none;
    }
}
/* Global selection styles */
::selection {
    background-color: rgba(168, 85, 247, 0.4);
    color: #ffffff;
}

::-moz-selection {
    background-color: rgba(168, 85, 247, 0.4);
    color: #ffffff;
}

/* 404 page styles */
/* 1. Layout Container */

.not-found-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 160px);
    text-align: center;
    padding: 2rem;
}

/* 2. Massive Animated Typography */
.huge-404 {
    font-size: clamp(8rem, 20vw, 15rem);
    font-weight: 900;
    line-height: 1;
    margin: 0;
    margin-bottom: 1rem;
    letter-spacing: -0.05em;

    /* Shimmering gradient */
    background: linear-gradient(
        to right,
        #6366f1 20%,
        #a855f7 40%,
        #a855f7 60%,
        #6366f1 80%
    );
    background-size: 200% auto;
    color: transparent;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;

    /* Fluid continuous animation */
    animation: shine-gradient 5s linear infinite;

    /* Subtle glow to detach from dark background */
    filter: drop-shadow(0 0 40px rgba(168, 85, 247, 0.2));
}

@keyframes shine-gradient {
    to {
        background-position: 200% center;
    }
}

.error-subtitle {
    font-size: 1.25rem;
    color: #94a3b8;
    margin-top: 1rem;
    margin-bottom: 3rem;
    font-weight: 400;
}

/* 3. Glow Border Button */
.btn-glow-border {
    position: relative;
    display: inline-flex;
    border-radius: 9999px;
    padding: 2px; /* Border thickness */
    /* Ensure the rotating square behind doesn't leak out of the pill shape */
    overflow: hidden;
    text-decoration: none;
    transition:
        transform 0.3s ease,
        box-shadow 0.3s ease;
    /* Fix for Safari border-radius overflow bug */
    -webkit-mask-image: -webkit-radial-gradient(white, black);
    /* Removes default focus outline and replaces it with custom shadow */
    outline: none;
}

/* Focus and Hover states */
.btn-glow-border:hover,
.btn-glow-border:focus-visible {
    transform: scale(1.02);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.3);
}

/* rotating conic gradient background */
.btn-glow-border::before {
    content: "";
    position: absolute;
    /* Extends the element well beyond the borders so corners don't show when rotating */
    top: -155%; /* -155% top & bottom for angle */
    left: -100%;
    right: -100%;
    bottom: -155%;
    background: conic-gradient(
        transparent,
        transparent,
        transparent,
        #6366f1,
        #a855f7
    );
    animation: rotate-border 4s linear infinite;
}

@keyframes rotate-border {
    100% {
        transform: rotate(360deg);
    }
}

/* The inner button that masks the center of the gradient */
.btn-inner {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    /* Must match your site background color exactly to hide the gradient behind it */
    background-color: #12161c;
    color: #f8fafc;
    padding: 0.8rem 2.5rem;
    border-radius: 9999px;
    font-size: 1rem;
    font-weight: 500;
    z-index: 1;
    transition: background-color 0.3s ease;
}

.btn-glow-border:hover .btn-inner,
.btn-glow-border:focus-visible .btn-inner {
    /* Slightly lightens the inner background */
    background-color: #1e2532;
}
