:root {
    --vertical-gap: 12rem;
    --tile-gap: 0.5rem;
    --border-radius: 6px;
    --max-width: 1200px;

    --bg-dark: hsl(0, 0%, 0%);
    --bg: hsl(0, 0%, 5%);
    --bg-light: hsl(0, 0%, 12%);
    --bg-50: hsla(0, 0%, 5%, 0.5);
    --text: hsl(0, 0%, 95%);
    --text-5: hsla(0, 0%, 95%, 0.05);
    --text-muted: hsl(0, 0%, 70%);
    --border: hsl(0, 0%, 15%);

    /* light 
    --bg-dark: hsl(0, 0%, 90%);
    --bg: hsl(0, 0%, 95%);
    --bg-light: hsl(0, 0%, 100%);
    --text: hsl(0, 0%, 5%);
    --text-muted: hsl(0, 0%, 30%);
    --border: hsl(0, 0%, 85%);*/
}
  
@font-face {
    font-family: 'Inter';
    src: url('assets/fonts/Inter-VariableFont_opsz,wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
}

@font-face {
    font-family: 'FragmentMono';
    src: url('assets/fonts/FragmentMono-Regular.ttf') format('truetype');
    font-weight: 100 500;
    font-style: normal;
}

* {
    font-family: 'Inter', sans-serif;
    scroll-behavior: smooth;
    margin: 0;
    padding: 0;
    color: var(--text);
    object-fit: scale-down;
    box-sizing: border-box;
    text-decoration: none;
}

[popover] {
    position-area: bottom span-left;
    background-color: transparent;
    border: none;
    padding: 0;
    margin: 0;
}

html.lenis, html.lenis body {
    height: auto;
}

.lenis.lenis-smooth {
    scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
    overscroll-behavior: contain;
}

.lenis.lenis-stopped {
    overflow: clip;
}

.lenis.lenis-smooth iframe {
    pointer-events: none;
}

body, html {
    width: 100%;
}

html {
    background: var(--bg);
}

body {
    max-width: var(--max-width);
    margin: auto;
    padding: 2rem;
}

nav {
    width: 100%;
    display: grid;
    grid-template-columns: auto 1fr auto;
    justify-items: center;
    align-items: center;
    gap: 1rem;
}

nav img {
    width: 2rem;
}

nav .social-links {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
}

nav #menu-button {
    display: none;
}

nav #menu {
    z-index: 1000;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    align-items: start;
    gap: 1rem;
    backdrop-filter: blur(10px);
}

nav #menu a {
    text-align: left;
    color: var(--text);
}

nav button {
    font-size: 2rem;
    background-color: transparent;
    border: none;
    cursor: pointer;
}

nav a {
    transition: 0.3s;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
}

nav a:hover {
    text-decoration: underline;
    color: var(--text);
}

header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: calc(var(--vertical-gap) / 1.5);
}

header .title {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

header .title h1 {
    font-weight: 600;
    font-size: clamp(2rem, 10vw, 5rem);
    line-height: clamp(2rem, 10vw, 5rem);
    text-transform: uppercase;
    text-wrap: nowrap;
}

header .title p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.2rem;
    text-align: center;
    width: clamp(200px, 100%, 360px);
}

header .title button {
    cursor: pointer;
    background-color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    color: var(--bg-light);
    padding: 0.5rem 1rem;
    font-weight: 600;
    font-size: 0.8rem;
}

header .title [popover] {
    position-area: bottom;
    padding: 1rem;
}

header .title button,
header .title a {
    display: inline-block;
    transition: 0.2s;
    cursor: pointer;
    background-color: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    color: var(--text);
    padding: 0.5rem 1rem;
    font-weight: 600;
    font-size: 0.8rem;
}

header .title button:hover, 
header .title a:hover {
    background-color: var(--text);
    color: var(--bg);
}

main {
    display: flex;
    flex-direction: column;
    gap: var(--vertical-gap);
    margin: var(--vertical-gap) 0;
}

main .project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: var(--tile-gap);
}

main .project-grid .project {
    transition: 0.3s;
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    overflow: clip;
    box-shadow: 0 0 8px var(--text-5) inset;
}

main .project-grid .project:hover {
    filter: brightness(1.2);
}

main .project-grid .project .badge {
    padding: 1rem;
    position: absolute;
    display: flex;
    justify-content: flex-end;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    height: 100%;
    gap: 1rem;
}

main .project-grid .project .badge h2 {
    user-select: none;
    font-weight: 600;
    font-size: 0.9rem;
}

main .project-grid .project .badge p,
main .project-grid .project .badge li {
    user-select: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.8rem;
    list-style-position: inside;
}

main .project-grid .project .title {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
}

main .project-grid .project a {
    transition: 0.3s;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.8rem;
}

main .project-grid .project a:hover {
    color: var(--text);
    text-decoration: underline;
}

main .project-grid .project .col {
    display: flex;
    justify-content: flex-start;
    flex-direction: column;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.25rem;
}

main .project-grid .project img {
    user-select: none;
    width: 100%;
}

main .project-grid .project .preview-indicator {
    animation: pulse 2s infinite;
    position: absolute;
    right: 1rem;
    top: 1rem;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background-color: transparent;
    pointer-events: none;
    transition: 0.2s;
    z-index: 100;
}

main .project-grid .project.preview-playing .preview-indicator {
    background-color: var(--text);
    box-shadow: 0 0 8px var(--text);
}

footer {
    padding: 3rem 0;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    justify-content: start;
    align-items: start;
    gap: 2rem 3rem;
}

footer .col {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

footer a,
footer p,
footer button {
    transition: 0.3s;
    text-align: left;
    color: var(--text-muted);
    font-size: 0.8rem;
    background-color: transparent;
    border: none;
    cursor: pointer;
}

footer a:hover,
footer button:hover {
    text-decoration: underline;
    color: var(--text);
}

footer img {
    width: 2rem;
}

footer [popover] {
    position-area: top span-right;
}

#policy-popover {
    background-color: var(--bg-light);
    color: var(--text);
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    max-width: 400px;
    max-height: 60vh;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

#policy-popover div {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#policy-popover h2 {
    font-weight: 600;
    font-size: 0.9rem;
}

#bg-shader {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 10000;
    mix-blend-mode: normal;
    opacity: 0.5;
}

.bg-fallback {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: radial-gradient(ellipse at 20% 10%, rgba(255,140,60,0.06), transparent 8%),
                radial-gradient(ellipse at 80% 90%, rgba(80,120,255,0.04), transparent 10%),
                linear-gradient(180deg, rgba(255,255,255,0.01), rgba(0,0,0,0.02));
}

body > *:not(canvas):not(script) {
    position: relative;
    z-index: 1;
}

@media (prefers-reduced-motion: reduce) {
    #bg-shader, .bg-fallback { display: none; }
}

@media (max-width: 600px) {
    :root {
        --vertical-gap: 4rem;
    }

    nav {
        display: flex;
        justify-content: space-between;
    }

    nav .social-links {
        display: none;
    }

    nav #preview-toggle {
        display: none;
    }

    nav #menu-button {
        display: block;
    }

    header .title p {
        width: auto;
    }

    main .project-grid {
        grid-template-columns: 1fr;
    }

    footer {
        flex-direction: column;
    }

}

/* Ensure page content sits above the background canvas */
body > *:not(#bg-shader):not(script) {
    position: relative;
    z-index: 1;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}