/* ========== Global Styles ========== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    scroll-behavior: smooth;
}


/* ========== Body Styling ========== */

body {
    font-family: "DM Sans", sans-serif;
    font-optical-sizing: auto;
    font-weight: 500;
    font-style: normal;
    background-color: #18121e;
    position: relative;
}


/* ========== Typography ========== */

h2 {
    font-size: clamp(2.7rem, 5vw, 6rem);
    /* Responsive font size */
    color: white;
    font-weight: 500;
    letter-spacing: -3px;
}

.title span {
    color: #cb9bff;
    font-family: "IBM Plex Serif", serif;
    font-weight: 100;
    font-style: italic;
    font-size: clamp(1.2rem, 100rem);
}

.portfolio-content span {
    color: #cb9bff;
    font-family: "IBM Plex Serif", serif;
    font-weight: 100;
    font-style: italic;
    font-size: clamp(1.2rem, 100rem);
}

.subtitle {
    font-size: 1rem;
    letter-spacing: 0px;
    margin-top: -25px
}

.subtitle span {
    color: #cb9bff;
    font-family: "IBM Plex Serif", serif;
    font-weight: 100;
    font-style: italic;
}


/* ========== Links ========== */

a {
    text-decoration: none;
    color: inherit;
}

::selection {
    color: white;
    background: #cb9bff;
}


/* ========== Logo Section ========== */

.logo {
    width: 100%;
    height: 30vh;
    padding-top: 18rem;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-bottom: 7rem;
}


/* ========== Container ========== */

.container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}


/* ========== Header Container ========== */

.header-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 40px;
}


/* ========== Buttons Styling ========== */

.buttons-container {
    display: flex;
    flex-direction: row;
    gap: 15px;
    padding-bottom: 10rem;
}

.custom-button {
    font-family: "DM Sans", sans-serif;
    font-weight: 500;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: white;
    background-color: transparent;
    border: 2px solid #a992f7;
    border-radius: 30px;
    padding: 15px 35px;
    position: relative;
    transition: transform 0.3s ease;
}

.custom-button:hover {
    transform: translateY(-5px);
}

.custom-button img {
    margin-left: 10px;
}

.arrow-icon {
    width: 12px;
    height: 12px;
}

.arrow-down {
    transform: rotate(135deg);
    /* Points down-right */
}


/* ========== Portfolio Section ========== */

.portfolio-content {
    width: 1000px;
}

.portfolio-content span {
    font-size: 3rem;
}

.portfolio-content h3 {
    color: white;
    font-weight: 500;
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    padding-top: 1rem;
    word-break: break-word;
    line-height: 1.4;
}


/* ========== Grid Container ========== */

.grid-wrapper {
    display: flex;
    justify-content: center;
    /* adds side spacing */
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3rem;
    margin-top: 4rem;
    max-width: 1000px;
    width: 100%;
    justify-content: center;
    /* aligns content inside grid horizontally */
}


/* This makes sure if the last row has only 1 item, it will be centered */

.grid-container>*:nth-last-child(1):nth-child(3n + 1) {
    grid-column: 2 / span 1;
}

.grid-container>div:nth-last-child(1):nth-child(3n+1) {
    margin-top: 3rem;
}

.grid-item {
    background-color: #1a1a1a;
    border-radius: 10px;
    overflow: hidden;
    text-align: center;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    height: 400px;
    transition: transform 0.3s ease;
    --offset-y: 0px;
    transform: translateY(var(--offset-y));
    cursor: pointer;
    /* Make the card feel interactive */
}


/* ========== Overlay ========== */

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1;
    transition: background-color 0.3s ease;
}

.grid-item:hover .overlay {
    background-color: rgba(0, 0, 0, 0.3);
}


/* Make the whole card clickable */

.card-link {
    text-decoration: none;
    /* Remove underline from links */
    color: inherit;
    /* Inherit the text color */
    display: block;
    /* Make the entire card clickable */
    position: relative;
    /* Ensure no layout shifts */
}


/* ========== Project Name Styling ========== */

.project-name {
    position: absolute;
    bottom: 1rem;
    z-index: 2;
    font-size: 1.4rem;
    font-weight: bold;
    color: white;
    text-align: left;
    justify-content: left;
    display: inline-flex;
    align-items: center;
    transition: color .3s ease-in-out, box-shadow .3s ease-in-out;
    padding: 0 .25rem;
    width: 100%;
}

.project-name::after {
    content: attr(data-hover);
    position: absolute;
    width: 100%;
    opacity: 0;
    color: #fff;
    align-items: center;
    text-align: left;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.grid-item:hover .project-name::after {
    opacity: 1;
    transform: translateY(0);
    /* Slide into view */
}

.grid-item:hover .project-name {
    color: transparent;
    /* Hide text */
    box-shadow: inset 100px 0 0 0 #cb9bff;
    /* Purple box appears */
}

.project-name a {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    font-size: 1.4rem;
    font-weight: bold;
    color: white;
    box-shadow: inset 0 0 0 0 #bf83ff;
    margin: 0 0.7rem;
    padding: 0 0.25rem;
    transition: color 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
    position: relative;
}

.project-name a::after {
    content: attr(data-hover);
    /* Use the value of the data-hover attribute */
    position: absolute;
    width: 100%;
    opacity: 0;
    color: #fff;
    align-items: center;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: translateY(10px);
    /* Add transform to animate in */
}

.project-name a:hover::after,
.grid-item:hover .project-name a::after {
    opacity: 1;
    transform: translateY(0);
}

.project-name a:hover,
.grid-item:hover .project-name a {
    color: transparent;
    /* Hide the original text */
    box-shadow: inset 100px 0 0 0 #cb9bff;
}

.project-name p {
    font-size: 1.4rem;
    color: white;
    font-weight: bold;
    margin: 0;
    /* Remove extra spacing */
}


/* ========== Image Styling ========== */

.grid-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.grid-item:hover img {
    transform: scale(1.1);
    transition: transform 0.3s ease;
}


/* ========== About Me Section ========== */

.aboutme-content {
    width: 100%;
    max-width: 1000px;
    margin: 15rem auto 8rem;
    text-align: center;
}

.aboutme-content span {
    font-size: 3rem;
    color: #cb9bff;
    font-family: "IBM Plex Serif", serif;
    font-weight: 100;
    font-style: italic;
}

.aboutme-content h3 {
    color: white;
    font-weight: 500;
    font-size: 1.5rem;
    margin-top: 1rem;
}

.tags {
    position: absolute;
    z-index: 2;
    text-align: left;
}

.tags p {
    font-size: 0.9rem;
    color: white;
    margin: 0.2rem 0;
}

.anchor-fix {
    display: block;
    position: relative;
    top: -100px;
    /* adjust as needed based on your header height */
    visibility: hidden;
}


/* ========== About Me Container ========== */

.aboutme-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4rem;
    margin-top: 4rem;
}


/* ========== Profile Image Styling ========== */

.profile-image {
    flex-shrink: 0;
    width: 200px;
    height: 200px;
    overflow: hidden;
}

.profile-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}


/* ========== About Me Text Styling ========== */

.aboutme-text {
    max-width: 800px;
    color: white;
    font-size: 1rem;
    line-height: 1.8;
    font-family: "Open Sans", sans-serif;
    font-weight: 100;
    text-align: left;
}

.aboutme-text p {
    margin-bottom: 2rem;
}


/* ========== Contact Section ========== */

.contact-content {
    width: 100%;
    max-width: 1000px;
    text-align: center;
}

.contact-content span {
    font-size: 3rem;
    color: #cb9bff;
    font-family: "IBM Plex Serif", serif;
    font-weight: 100;
    font-style: italic;
}

.contact-content h3 {
    color: white;
    font-weight: 500;
    font-size: 1.5rem;
    margin-top: 1rem;
}


/* ========== Contact Buttons ========== */

.contact-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4rem;
    margin-top: 4rem;
}


/* ========== Tooltip Styling ========== */

.tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 10;
    margin-bottom: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tooltip img.clipboard-icon {
    width: 16px;
    height: 16px;
    opacity: 0.8;
}

.tooltip:hover img.clipboard-icon {
    opacity: 1;
}

.custom-button:hover .tooltip {
    opacity: 1;
    visibility: visible;
}

.custom-button {
    position: relative;
    z-index: 1;
}


/* ========== Grid Animation for Portfolio ========== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* Offset per columns - Target <a> elements */

.grid-container>div:nth-child(3n + 1) .grid-item {
    --offset-y: 0px;
}

.grid-container>div:nth-child(3n + 2) .grid-item {
    --offset-y: 3rem;
}

.grid-container>div:nth-child(3n) .grid-item {
    --offset-y: 6rem;
}


/* Initial hidden state+fade */

.fade-in-column {
    opacity: 0;
    transform: translateY(20px);
    /* Start slightly lower */
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.fade-in-column.visible {
    opacity: 1;
    transform: translateY(0);
    /* Reset position */
}


/* Media Query for Small Screens */

@media (max-width: 1200px) {
    .logo img {
        width: 120px;
    }
    html,
    body {
        overflow-x: hidden;
    }
}

@media (max-width: 999px) {
    .aboutme-container {
        flex-direction: column;
    }
    .aboutme-content {
        margin: 15rem auto 10rem;
    }
    .grid-wrapper {
        display: flex;
        justify-content: center;
        width: 100%;
    }
    .grid-container {
        display: flex;
        /* disable grid */
        flex-direction: column;
        align-items: center;
        gap: 3rem;
        padding: 0 2rem;
        width: 100%;
        max-width: 850px;
    }
    .grid-container>div {
        width: 100%;
        display: flex;
        justify-content: center;
    }
    .card-link {
        width: 100%;
    }
    .grid-item {
        width: 100%;
        max-width: 100%;
        transform: none !important;
        /* 🔥 Fix the visual position */
        --offset-y: 0px !important;
        /* 🔥 Kill leftover offset on mobile */
    }
    .aboutme-text {
        text-align: center;
        width: 100%;
        max-width: 360px;
    }
    .buttons-container {
        flex-direction: column;
    }
    .grid-container>div:nth-last-child(1):nth-child(3n+1) {
        margin-top: 0px;
    }
}

@media (max-width: 790px) {
    h2 {
        font-size: clamp(2.3rem, 5vw, 6rem);
        letter-spacing: -1px;
    }
    .grid-wrapper {
        display: flex;
        justify-content: center;
        width: 100%;
    }
    .grid-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2.5rem;
        padding: 0 1.5rem;
        width: 100%;
        max-width: 400px;
    }
    .grid-container>div {
        width: 100%;
        display: flex;
        justify-content: center;
    }
    .card-link {
        width: 100%;
    }
    .grid-item {
        width: 100%;
        max-width: 100%;
        transform: none !important;
        --offset-y: 0px !important;
    }
    .portfolio-content h3,
    .aboutme-content h3,
    .contact-content h3 {
        font-size: 1rem;
        padding: 0 1rem;
        text-align: center;
    }
    .grid-container>div:nth-last-child(1):nth-child(3n+1) {
        margin-top: 0;
    }
}

@media (max-width: 600px) {
    .logo img {
        width: 100px;
    }
    .logo {
        padding-top: 12rem;
    }
    .portfolio-content h3,
    .aboutme-content h3,
    .contact-content h3 {
        font-size: 1.1rem;
        padding: 0 1rem;
        text-align: center;
        word-break: break-word;
        line-height: 1.4;
    }
    .grid-container {
        grid-template-columns: 1fr;
        padding: 0 1rem;
    }
    .card-link:nth-child(3n + 1) .grid-item,
    .card-link:nth-child(3n + 2) .grid-item,
    .card-link:nth-child(3n) .grid-item {
        --offset-y: 0px;
    }
    .grid-container>div:last-child {
        justify-self: center;
    }
}