/* ------------------------------
   Fonts & Resets
------------------------------ */
@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap');

*, *::before, *::after {
    box-sizing: border-box;
    transition: all 0.4s ease-in-out;
}

::-webkit-scrollbar {
    display: none;
}

html {
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: 'Roboto Mono', monospace;
    background-color: var(--body-bg);
    color: var(--text-color);
    display: flex;
}

body.hidden {
    opacity: 0;
    transition: all 0.4s ease-in-out;

    & main {
        transform: translateX(10%);
        transition: transform 1.2s ease-in-out;
    }

    & nav {
        transform: translateX(-100%);
        transition: transform 1.2s ease-in-out;
    }
}

::selection {
    background-color: var(--primary-color);
    color: var(--card-bg);
}

::-moz-selection {
    background-color: var(--primary-color);
    color: var(--card-bg);
}

/* ------------------------------
   Theme Variables
------------------------------ */
:root {
    --current-testimonial: 0;
    --previous-testimonial: 0;
    /* Primary (changes with swatches) */
    --primary-color: var(--primary-blue);

    --primary-orange: #ff7a00;
    --primary-blue: #1d9bf0;
    --primary-red: #ff004d;
    --primary-green:  #00ba7c;
    --primary-purple: #7856ff;

    --body-bg: #ffffff;
    --card-bg: #ececee;
    --text-color: #111111;
    --secondary-color: #374151;
    --alt-color: #1f2937;
    --testimonial-bg: #ececee;
    --nav-bg: #ececee;
}

:root[data-theme="dark"] {
    --body-bg: #000000;
    --card-bg: #111111;
    --text-color: #f5f5f5;
    --secondary-color: #9ca3af;
    --alt-color: #e5e7eb;
    --testimonial-bg: #161616;
    --nav-bg: #161616;
}

/* ------------------------------
   Layout
------------------------------ */
.container {
    max-height: 100%;
    width: min(100%, 72rem);
}

main {
    height: 100dvh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;

    @media (max-width: 667px) {
        scroll-snap-type: none;
        height: auto;

        & > section {
            height: auto;
            scroll-margin-top: 3rem;
        }
        & > section#contact {
            height: 92dvh;
        }
    }
}

nav {
    padding: 0 clamp(0.125rem, 1vw, 1rem);
    height: 100vh;
    display: flex;
    align-items: center;
    background: var(--nav-bg);
    position: sticky;
    top: 0;
    z-index: 100;
}

section {
    height: 100dvh;
    padding: clamp(2rem, 6vw, 8rem);
    scroll-snap-align: start;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 100vw;
}

section h2 {
    color: var(--text-color);
    font-size: clamp(1.4rem, 4vw, 2rem);
    margin: 0 0 2rem 0;

    @media (max-width: 667px) {
        margin: 1rem 0;
    }
}

.special {
    color: var(--primary-color);
    font-weight: bold;
}

/* ------------------------------
   Typography
------------------------------ */
.code p:last-child {
    font-size: clamp(1rem, 3vw, 1.8rem);
    text-wrap: nowrap;
    width: 0;
    max-width: fit-content;
    overflow: hidden;
    border-right: 1px solid var(--primary-color);
    animation: typewriter 4s steps(44)  forwards,
    caret-blink 1s linear infinite;

    @media (max-width: 1280px) {
        animation: none;
        text-wrap: wrap;
        width: 100%;
        border-right: none;
    }

    @media (max-width: 667px) {
        margin: 0.5rem 0 0;
    }
}

@keyframes typewriter {
    to {width: 100%}
}

@keyframes caret-blink {
    0%, 100% { border-right-color: var(--primary-color); }
    50% { border-right-color: transparent; }
}

.code {
    font-size: 2rem;
    background: var(--card-bg);
    padding: clamp(1rem, 3vw, 2rem);
    border-radius: 1rem;

    & svg {
        float: right
    }
}

/* ------------------------------
   Navigation
------------------------------ */

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

nav ul {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

nav ul li {
    position: relative;
}

li a {
    color: var(--secondary-color);
    transition: color 0.2s ease-in-out;
    display: block;
    height: fit-content;
    width: fit-content;
}

li#cv a {
    font-size: 1.2rem;
    text-decoration: none;
}

li a:hover {
    color: var(--primary-color);
}

nav img.author-avatar {
    width: clamp(1.2rem, 7vw, 2.6rem);
    aspect-ratio: 1;
}

@media (max-width: 667px) {
    body {
        flex-direction: column;
    }
    nav {
        padding: 0.5rem;
        height: auto;
        width: 100%;
        justify-content: center;
    }
    nav ul {
        flex-direction: row;
    }
}

/* ------------------------------
   Buttons
------------------------------ */
.btn img {
    width: clamp(0.6rem, 4vw, 1.4rem);
    aspect-ratio: 1;
    padding: 0.5rem;
    border-radius: 50%;
    background: white;
    box-sizing: content-box;
    outline-offset: 0.125rem;
    outline: 0.125rem dashed transparent;

    &:hover {
        outline-color: var(--text-color);
    }
}

/* ------------------------------
   Hero Section
------------------------------ */
#hero .container {
    display: flex;
    flex-direction: column;
    gap: clamp(1rem, 4vw, 3rem);
}

#hero .social-links {
    width: fit-content;

    @media (max-width: 667px) {
        width: 100%;
    }
}

#hero .author {
    display: flex;
    align-items: center;
    gap: 2rem;
}

#hero .author h1 {
    font-size: clamp(1.2rem, 5vw, 1.8rem);
    margin: clamp(1rem, 4vw, 1.2rem) 0;
}

#hero .user {
    display: block;
    margin: 1rem 0;
    font-weight: normal;
    font-size: clamp(0.8rem, 3vw, 1rem);

    & .user-id {
        color: #bf83fb
    }
}

#tech-stack {
    display: flex;
    justify-content: space-between;
    align-items: center;

    @media (max-width: 1024px) {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}


@media (max-width: 667px) {
    #tech-stack {
        align-items: center;
    }

    #hero .author {
        flex-direction: column;
        gap: 0;

        & > div > * {
            text-align: center;
        }
    }
}

.marquee-wrapper {
    max-width: 100%;
    display: flex;
    gap: 0.5rem;
    overflow: hidden;
    position: relative;
}

.marquee {
    flex-shrink: 0;
    animation: scroll 8s linear infinite;
}

.marquee img {
    width: clamp(20rem, 82vw , 36rem);
    display: block;
}

/* Gradient overlay */
.marquee-wrapper::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to right, var(--body-bg) 2%, transparent, var(--body-bg) 98%);
    z-index: 10;
}

@keyframes scroll {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(-100%);
    }
}


/* ------------------------------
   About
------------------------------ */

#about {
    align-items: flex-start;
}

#about-me {
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    line-height: 1.4;
    font-weight: 200;
}

.dud {
    color: var(--secondary-color);
    user-select: none;
}

/* ------------------------------
   Featured Projects
------------------------------ */

#featured-projects .container {
    height: 100%;
}

#featured-projects__cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(12rem, 24vw, 16rem), 1fr));
    gap: 1rem;
}

#featured-projects.hidden .card {
    transform: translateX(-8rem);
    opacity: 0;
    transition: opacity 1ms ease-out, transform 1ms ease-out;
}

.card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--card-bg);
    border: 0.125rem solid transparent;
    border-radius: 1rem;
    cursor: pointer;

    @media (max-width: 867px) {
        grid-column: span 2;
        flex-direction: row;
        gap: 0.25rem;

        & .links {
            margin-left: auto;
        }
    }
}

.card:first-child {
    transition: opacity 0.6s ease-in-out, transform 0.6s ease-in-out, border-color 0.4s ease-in-out;
}

.card:nth-child(2) {
    transition: opacity 0.6s ease-in-out 0.2s, transform 0.6s ease-in-out 0.1s, border-color 0.4s ease-in-out 0s;
}
.card:nth-child(3) {
    transition: opacity 0.6s ease-in-out 0.4s, transform 0.6s ease-in-out 0.2s, border-color 0.4s ease-in-out 0s;
}
.card:nth-child(4) {
    transition: opacity 0.6s ease-in-out 0.6s, transform 0.6s ease-in-out 0.3s, border-color 0.4s ease-in-out 0s;
}
.card:nth-child(5) {
    transition: opacity 0.6s ease-in-out 0.8s, transform 0.6s ease-in-out 0.4s, border-color 0.4s ease-in-out 0s;
}
.card:nth-child(6) {
    transition: opacity 0.6s ease-in-out 1s, transform 0.6s ease-in-out 0.5s, border-color 0.4s ease-in-out 0s;
}

.card:hover {
    border-color: var(--primary-color);
}

.card h3 {
    margin: 0;
    font-size: clamp(0.4rem, 4vw, 1.2rem);
    font-weight: bold;
    text-wrap: nowrap;
}

.card p {
    font-size: 0.8rem;
    margin-left: 0;
    text-wrap: nowrap;

    @media (max-width: 768px) {
        display: none;
    }
}

.card svg {
    width: clamp(1.2rem, 8vw, 3rem);
    aspect-ratio: 1;
}

/* ------------------------------
   Testimonials
------------------------------ */
.testimonial.hidden i,
.testimonial.hidden .author {
    opacity: 0;
}

.testimonial.hidden .avatar img {
    background-color: transparent;
}

#testimonials-cards {
    display: flex;
    align-items: stretch;
    gap: 4rem;
    overflow-x: hidden;
    overflow-y: clip;
    border-radius: 1rem;
    user-select: none;
}

.testimonial {
    position: relative;
    display: flex;
    min-width: 100%;
    background: var(--testimonial-bg);
    border-radius: 1rem;
}

.testimonial > .avatar > img {
    height: 100%;
    background-color: var(--primary-color);
    border-top-left-radius: 1rem;
    border-bottom-left-radius: 1rem;
}

.testimonial .content {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 2rem;
    padding: 2rem;
    border-top-right-radius: 1rem;
    border-bottom-right-radius: 1rem;
}

.testimonial .content i {
    line-height: 1.8;
    font-size: clamp(0.8rem, 2vw, 1.2rem);
}

.testimonial .content .special {
    font-size: 1.2rem;
}

.testimonial .author {
    display: flex;
}

.testimonial .author img {
    width: clamp(4rem, 10vw, 6rem);
    aspect-ratio: 1;
    display: none;
    border-radius: 50%;
    outline: 0.125rem dashed var(--primary-color);
    outline-offset: 0.4rem;
}

.testimonial .author .title {
    margin: 0;
    font-size: clamp(0.8rem, 4vw, 1.4rem);
}

.testimonial .author p {
    font-size: clamp(0.6rem, 3vw, 1rem);
    color: var(--primary-color);
    margin-bottom: 0;
}

.testimonial > span {
    position: absolute;
    right: 2rem;
    bottom: 2rem;
    width: 5rem;
    height: 5rem;
    padding: 0.5rem;
    text-align: center;
    font-size: 4rem;
    color: var(--card-bg);
    background: var(--text-color);
    border-radius: 50%;
}

@media (max-width: 992px) {
    .testimonial .content {
        flex-direction: column-reverse;
        justify-content: start;
        gap: 2rem;
    }
    .testimonial > span {
        display: none;
    }
    .testimonial > .avatar > img {
        display: none;
    }
    .testimonial .author {
        align-items: center;
        gap: 2rem;

        & > img {
            display: block;
        }
    }
}

/* Testimonials Controls */
#testimonials-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    margin-top: 2rem;
}

#testimonials-controls .buttons {
    display: flex;
    gap: 2rem;
}

#testimonials-controls button {
    background: transparent;
    border: none;
}

#testimonials-controls .bar {
    flex-grow: 1;
    max-width: 50%;
    display: flex;
    align-items: center;
    gap: 1rem;
}

#testimonials-controls .bar > .current {
    flex-grow: 1;
    position: relative;
    width: clamp(6rem, 24vw, 12rem);;
    height: 0.25rem;
    background: var(--testimonial-bg);
    border-radius: 0.25rem;
}

#testimonials-controls .bar > .current::after {
    content: "";
    position: absolute;
    left: calc(var(--current-testimonial) * (100% / 12));
    width: calc(100% / 12);
    height: 100%;
    background: var(--primary-color);
    border-radius: 0.25rem;
    transition: none;
}

/* Testimonials Control Bar Stretching Animation */
.bar-stretch-forward::after {
    animation: stretch-forward 1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.bar-stretch-backward::after {
    animation: stretch-backward 1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes stretch-forward {
    0% {
        left: calc(var(--previous-testimonial) * (100% / 12));
        width: calc(100% / 12);
    }
    50% {
        left: calc(var(--previous-testimonial) * (100% / 12));
        width: calc(((var(--current-testimonial) - var(--previous-testimonial)) + 1) * (100% / 12));
    }
    100% {
        left: calc(var(--current-testimonial) * (100% / 12));
        width: calc(100% / 12);
    }
}

@keyframes stretch-backward {
    0% {
        left: calc(var(--previous-testimonial) * (100% / 12));
        width: calc(100% / 12);
    }
    50% {
        left: calc(var(--current-testimonial) * (100% / 12));
        width: calc(((var(--previous-testimonial) - var(--current-testimonial)) + 1) * (100% / 12));
    }
    100% {
        left: calc(var(--current-testimonial) * (100% / 12));
        width: calc(100% / 12);
    }
}

/* ------------------------------
   Contact
------------------------------ */
#contact {
    background: linear-gradient(135deg, var(--primary-color) 40%, black);
}

#contact h2 {
    margin: 0 0 1rem 0;
    color: var(--body-bg);
}

#contact.hidden > .container > div {
    opacity: 0;
}

#contact .container > div {
    display: flex;
    transition: all 0.8s ease-in-out;

    & .figure {
        background: var(--primary-color);
        margin: clamp(1rem, 4vw, 2rem) 0 clamp(1rem, 4vw, 2rem) clamp(1rem, 4vw, 2rem);
        flex-grow: 1;
        max-width: 45%;
        overflow: hidden;
        transition: 0s;

        & img {
            width: 100%;
        }
    }
}

#contact #contact-info {
    font-family: 'Arial', sans-serif;
    padding: clamp(1rem, 4vw, 2rem);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

#contact form {
    color: #1f2937;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-top: 1rem;

    & span {
        color: var(--body-bg);
    }

    & > label  {
        display: contents;
    }

    & input, textarea, button {
        font-family: 'Arial', sans-serif;
        font-size: clamp(1rem, 4vw, 1.4rem);
        padding: 0.5rem;
        background-color: #dddddd;
        color: #1f2937;
        border: none;
        resize: none;
        transition: none;

        &:focus-visible {
            outline: 0.125rem solid #1f2937;
        }
    }

    & button {
        color: #dddddd;
        background: #1f2937;
        cursor: pointer;
        font-weight: bold;
    }

    & textarea {
        flex-grow: 1;
    }
}

#contact form > div {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#contact ul {
    display: flex;
    gap: 1rem;
}

.social-links ul {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.social-links li img {
    box-sizing: content-box;
    background: #000000;
    padding: 0.125rem;
    border-radius: 50%;
    height: fit-content;
    outline: 0.125rem dashed transparent;
    outline-offset: 0.125rem;

    &:hover {
        outline-color: var(--text-color);
    }
}

@media (max-width: 992px) {
    #contact .figure {
        display: none;
    }
    #contact .container {
        height: 100%;
    }
    #contact .container > div {
        height: 100%;
    }
}

/* ------------------------------
   Avatar Styles
------------------------------ */
.author-avatar {
    box-sizing: content-box;
    width: clamp(6rem, 16vw , 12rem);
    aspect-ratio: 1;
    padding: 0.25rem;
    border: 0.125rem dashed var(--text-color);
    border-radius: 50%;
    transition: all 0.2s ease-in-out;
}

nav .author-avatar {
    border-color: transparent;
}

nav .author-avatar:hover {
    border-color: var(--text-color);
}

/* ------------------------------
   Swatches (Color Palette)
------------------------------ */
#color-swatch {
    cursor: pointer;
    display: block;
    width: 2rem;
}

.swatches {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    background: rgba(0, 0, 0, 0.5);
}

.swatches.hidden {
    display: none;
}

.swatches h2 {
    margin: 0 0 2rem 0;
}

.colors-palette {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 1rem;
    text-align: center;
    border: 0.125rem solid var(--text-color);
    width: min(35rem, 90%);
    overflow: hidden;
    position: relative;
}

.colors-palette::after {
    content: "❌";
    padding: 0.5rem;
    background: var(--primary-red);
    position: absolute;
    top: 0;
    right: 0;
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    font-weight: bold;
    cursor: pointer;
}

.colors-palette .flex-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.colors-palette button {
    width: clamp(5rem, 9vw, 8rem);
    height: clamp(5rem, 9vw, 8rem);
    border-radius: 0.5rem;
    cursor: pointer;
}

.colors-palette button.active {
    border: 0.25rem dashed var(--alt-color);
}

/* ------------------------------
   Misc
------------------------------ */
#copyright,
.prompt {
    color: var(--secondary-color);
}

#copyright {
    font-size: clamp(0.7rem, 1vw, 0.8rem);
    text-wrap: nowrap;
}

.prompt {
    color: #44c072;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 1rem;

    & > img {
        max-width: 100%;
    }
}

svg, [data-type="svg"] {
    width: clamp(1.4rem, 7vw, 2.2rem);
    aspect-ratio: 1;
    cursor: pointer;
}

input#dark-theme {
    display: none;
}

/* ------------------------------
   Tooltip
------------------------------ */
nav li:hover .tooltip,
nav li:is( *:hover) .tooltip {
    display: block;
}

.tooltip {
    display: none;
    width: fit-content;
    background: var(--alt-color);
    color: var(--card-bg);
    padding: 0.5rem;
    text-wrap: nowrap;
    border-radius: 0.3rem;
    position: absolute;
    top: 0;
    right: -100%;
    transform: translateX(90%);
    z-index: 100;
}

.tooltip::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 100%;
    transform: translateY(-50%);
    border-width: 0.5rem;
    border-style: solid;
    border-color: transparent var(--alt-color) transparent transparent;
}

@media (max-width: 667px) {
    .tooltip {
        top: 120%;
        left: 50%;
        transform: translateX(-50%);
    }
    .tooltip::after {
        top: 0;
        left: 50%;
        transform: translateX(-50%) translateY(-100%);
        border-color: transparent transparent var(--alt-color) transparent;
    }
}