@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700&family=Inter:wght@400;500;600&display=swap');

/* ================= VARIABLES & THEMES ================= */
:root {
    --font-display: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    --color-white: #ffffff;
    --color-bg: #0a0a0f;
    --color-text: #e8e8f0;
    --color-text-transparent: rgba(232, 232, 240, 0);
    --color-star: #ffffff;
    --color-muted: #dfcfcf;
    --color-accent: #7B61FF;
    --color-surface: rgba(255, 255, 255, 0.05);
    --color-border: rgba(255, 255, 255, 0.15);
    --color-border-hover: rgba(255, 255, 255, 0.3);
    --color-focus: rgba(255, 255, 255, 0.4);
    --color-surface-hover: rgba(255, 255, 255, 0.08);
    --color-error: #ff6b6b;

    --text-xs: 0.85rem;
    --text-sm: 0.9rem;
    --text-base: 1rem;
    --text-md: 1.1rem;
    --text-lg: 1.25rem;
    --text-xl: 2rem;
    --text-2xl: 3rem;
    --text-3xl: 4rem;

    --space-xs: 0.5em;
    --space-sm: 1em;
    --space-md: 2em;
    --space-lg: 4em;
}

[data-theme="light"] {
    --color-bg: #f5f5f0;
    --color-text: #111111;
    --color-text-transparent: rgba(17, 17, 17, 0);
    --color-star: #000000;
    --color-muted: #3d3c3c;
    --color-accent: #5B41FF;
    --color-border-hover: rgba(0, 0, 0, 0.3);
    --color-focus: rgba(0, 0, 0, 0.4);
    --color-surface-hover: rgba(0, 0, 0, 0.08);
    --color-surface: rgba(0, 0, 0, 0.05);
    --color-border: rgba(0, 0, 0, 0.15);
}

/* ================= RESET & GENERAL ================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.pfp {
    width: 300px;
    height: 300px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--color-border);
    margin-bottom: var(--space-md);
}

html {
    font-family: var(--font-body);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
}

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    transition: background-color 400ms ease, color 400ms ease;
}

.hidden {
    display: none !important;
}

.highlight {
    color: var(--color-accent);
    text-decoration: underline;
    text-underline-offset: 6px;
}

.subtitle {
    color: var(--color-muted);
    font-size: var(--text-md);
    margin-bottom: var(--space-md);
}

/* ================= BACKGROUND ================= */
.starfield {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: var(--color-bg);
    overflow: hidden;
    transition: background-color 400ms ease;
}

.star {
    position: absolute;
    background: var(--color-star);
    border-radius: 50%;
    animation: twinkle var(--dur) ease-in-out infinite alternate,
               drift var(--drift) linear infinite;
    opacity: 0.9;
}

[data-theme="light"] .star {
    background: var(--color-star);
}

.meteor {
    position: absolute;
    width: 120px;
    height: 2px;
    background: linear-gradient(to right, var(--color-text-transparent), var(--color-text));
    border-radius: 2px;
    transform-origin: right center;
    transform: rotate(35deg);
    animation: shoot var(--speed) linear var(--delay) infinite;
}

[data-theme="light"] .meteor {
    background: linear-gradient(to right, var(--color-text-transparent), var(--color-text));
}

/* ================= NAV ================= */
nav {
    padding: 1.2em 2em;
    display: flex;

    position: fixed;
    top: 0;
    left: 0;
    width: 100%;

    background: transparent;
    backdrop-filter: blur(2px);

    border-bottom: 1px solid var(--color-border);

    z-index: 100;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 2em;
    align-items: center;
    width: 100%;
}

nav li:first-child {
    margin-right: auto;
    font-weight: 600;
    font-size: var(--text-md);
}

#theme-toggle {
    background: none;
    border: 1px solid var(--color-border);
    color: var(--color-text);
    padding: 0.4em 0.75em;
    border-radius: 2em;
    cursor: pointer;
    font-size: var(--text-base);
    transition: all 400ms ease;
}

@media (max-width: 600px) {
    nav {
        padding: 1em 1em;
    }
    nav ul {
        gap: 0.8em;
    }
    nav li:not(:first-child) {
        font-size: var(--text-sm);
    }
    #theme-toggle {
        padding: 0.3em 0.5em;
        font-size: var(--text-sm);
    }
}

/* ================= LINKS ================= */
nav a {
    text-decoration: none;
    color: var(--color-muted);
    position: relative;

    transition: color 0.2s ease;
}

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

/* subtle underline animation */
nav a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -4px;

    width: 0;
    height: 1px;

    background: var(--color-border-hover);
    transition: width 0.25s ease;
}

nav a:hover::after {
    width: 100%;
}

/* ================= HERO SECTION ================= */

header {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 100%;
    min-height: 100vh;

    padding: 0;
}

header .text-container {
    padding: 0 var(--space-md);
}

h1 {
    font-size: var(--text-3xl);
    line-height: 1.1;
    margin-bottom: 0.4em;
}

header p {
    font-size: var(--text-lg);
    color: var(--color-muted);
    margin-bottom: var(--space-md);
    max-width: 500px;
}

#typed-text {
    font-size: var(--text-lg);
    display: inline-block;
    min-width: 16ch;
    color: var(--color-accent);
}

#typed-text::after {
    content: "|";
    animation: blink 700ms step-end infinite;
}

.hero-item {
    opacity: 0;
    transform: translateY(25px);
    
    animation-name: fadeUp;
    animation-duration: 0.8s;
    animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
    animation-fill-mode: forwards;
}

.delay-1 { animation-delay: 0.15s; }
.delay-2 { animation-delay: 0.3s; }
.delay-3 { animation-delay: 0.45s; }
.delay-4 { animation-delay: 0.6s; }

/* ================= CTA BUTTON ================= */
.cta-button {
    position: relative;
    z-index: 10;
    display: inline-block;
    text-decoration: none;
    color: var(--color-text);
    background-color: var(--color-surface);
    padding: 0.75em 1.75em;
    border-radius: 0.5em;
    font-weight: 600;
    border: 1px solid var(--color-border);
    
    /* only transition color properties, NOT transform */
    transition:
        background-color 0.25s ease,
        color 0.25s ease,
        border-color 0.25s ease;
}

.cta-button:hover {
    background-color: var(--color-text);
    color: var(--color-bg);
    border-color: var(--color-text);
    animation: spring-pop 0.5s ease forwards;
}

.cta-button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-focus);
}
.cta-button:active {
    transform: translateY(-2px) scale(1.05);
    transition-duration: 0.1s;
}

/* ================= PROJECTS & MAIN ================= */
main {
    width: min(75em, 100%);
    margin: calc(var(--space-lg) + 60px) auto var(--space-lg);
    padding: 0 var(--space-md);
}

main h1 {
    font-size: var(--text-2xl);
    margin-bottom: var(--space-sm);
}

.projects-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-md);
}

/* Tablet */
@media (min-width: 768px) {
    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop — clean adaptive layout */
@media (min-width: 1024px) {
    .projects-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        align-items: start; /* IMPORTANT: prevents stretching */
    }
}

.project-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 1em;
    padding: var(--space-md);
    align-self: start;
    transition: transform 400ms cubic-bezier(0.34, 1.56, 0.64, 1), 
                background-color 200ms ease, 
                border-color 200ms ease;
}

.project-card:hover {
    border-color: var(--color-border-hover);
    background-color: var(--color-surface-hover);
    transform: translateY(-6px);
}

.project-desc {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-top: 0;
    transition: max-height 400ms ease, margin-top 400ms ease, opacity 400ms ease; 
}

.project-card.open .project-desc {
    max-height: 1000px;
    margin-top: var(--space-xs);
    opacity: 1;
}

.desc-toggle {
    background-color: transparent;
    border: none;
    color: var(--color-muted);
    cursor: pointer;
    font-size: var(--text-sm);
    padding: 0.5em 0;
    margin: var(--space-xs) 0;
    font-weight: 500;
    transition: all 200ms ease;
}

.desc-toggle:hover {
    opacity: 0.8;
}

.project-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.project-link:hover h2 {
    text-decoration: underline;
}

.project-card h2 {
    font-size: var(--text-lg);
    margin-bottom: 0.75em;
}

/* ================= TAGS & LABELS ================= */
.tags {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
    margin-bottom: var(--space-sm);
}

.tag {
    background-color: var(--color-surface);
    padding: 0.25em 0.75em;
    border-radius: 2em;
    font-size: var(--text-xs);
    color: var(--color-muted);
}

.tag-button {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    padding: 0.4em 1em;
    border-radius: 2em;
    font-size: var(--text-sm);
    cursor: pointer;
    margin-right: var(--space-xs);
    margin-bottom: var(--space-sm);
    transition: all 200ms ease;
    font-family: inherit;
    font-weight: 500;
}

.tag-button:hover {
    border-color: var(--color-border-hover);
    background-color: var(--color-surface-hover);
}

.tag-button.active {
    border-color: var(--color-accent);
    background-color: var(--color-surface);
    color: var(--color-accent);
    font-weight: 600;
}

.tag-button:active {
    background-color: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-white);
}

/* ================= CONTACT FORM ================= */
.contact-content {
    max-width: 600px;
    margin: 0 auto;
}

#personal-statement {
    max-width: 700px;
    margin-bottom: var(--space-lg);
    line-height: 1.8;
    color: var(--color-muted);
    font-size: var(--text-md);
}

form {
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 1.5em;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

label {
    font-size: var(--text-sm);
    color: var(--color-muted);
}

input,
textarea {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.5em;
    padding: 0.75em 1em;
    color: var(--color-text);
    font-family: inherit;
    font-size: var(--text-base);
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-focus);
    box-shadow: 0 0 0 3px var(--color-surface-hover);
}

.error {
    color: var(--color-error);
    font-size: var(--text-xs);
}

button[type="submit"] {
    align-self: flex-start;
    background-color: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-text);
    padding: 0.75em 1.75em;
    border-radius: 0.5em;
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
}

button[type="submit"]:hover {
    background-color: var(--color-text);
    color: var(--color-bg);
    transition: all 200ms ease;
}

#confirmation {
    margin-top: var(--space-md);
    display: inline-block;
    padding: 1em 1.5em;
    border: 1px solid var(--color-border);
    border-radius: 1em;
    background-color: var(--color-surface);
}

#confirmation h2 {
    font-size: var(--text-base);
    margin-bottom: 0.4em;
    font-weight: normal;
    color: var(--color-text);
}

#confirmation p {
    color: var(--color-muted);
    font-size: var(--text-xs);
}

/* ================= TIMELINE ================= */
#timeline h2 {
    font-size: var(--text-xl);
    margin-bottom: var(--space-md);
}

.timeline-list {
    list-style: none;
    position: relative;
    max-width: 700px;
}

.timeline-list::before {
    content: "";
    position: absolute;
    left: 6em;
    top: 0;
    bottom: 0;
    width: 1px;
    background-color: var(--color-border);
}

.timeline-item {
    display: flex;
    gap: var(--space-md);
    margin-bottom: 2.5em;
    position: relative;
}

.timeline-year {
    min-width: 4em;
    text-align: right;
    color: var(--color-muted);
    font-size: var(--text-sm);
    padding-top: 0.2em;
}

.timeline-content {
    padding-left: var(--space-md);
}

.timeline-content h3 {
    font-size: var(--text-md);
    margin-bottom: 0.4em;
}

.timeline-content p {
    color: var(--color-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.timeline-item::before {
    content: "";
    position: absolute;
    left: 5.85em;
    top: 0.4em;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--color-accent);
}

/* ================= KEYFRAMES ================= */
@keyframes fadeUp {
    0% {
        opacity: 0;
        transform: translateY(25px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes twinkle {
    from { opacity: var(--min-op); transform: scale(1); }
    to   { opacity: 1; transform: scale(1.4); }
}

@keyframes drift {
    from { transform: translateY(0); }
    to   { transform: translateY(100vh); }
}

@keyframes shoot {
    0%   { opacity: 0; transform: rotate(35deg) translateX(0); }
    5%   { opacity: 1; }
    80%  { opacity: 1; }
    100% { opacity: 0; transform: rotate(35deg) translateX(2000px); }
}

@keyframes spring-pop {
    0%   { transform: translateY(0)    scale(1);    }
    30%  { transform: translateY(-4px) scale(1.03); }
    55%  { transform: translateY(-1px) scale(1.03); }
    80%  { transform: translateY(-3px) scale(1.03); }
    100% { transform: translateY(-2px) scale(1.03); }
}

/* ================= REDUCED MOTION ================= */
/* 
    Accessibility: Handled preferences for reduced motion (e.g., for users with vestibular disorders).
    - Hero animations and spring-pop are disabled so elements snap strictly to end states.
    - Background stars and meteors are paused or hidden to avoid distracting/nausea-inducing movement.
    - The transition curve on project/skill cards remains, but users won't see large keyframe sweeps.
*/
@media (prefers-reduced-motion: reduce) {
    .hero-item { animation: none; opacity: 1; transform: none; }
    .cta-button:hover { animation: none; }
    .star { animation: none; opacity: 0.5; }
    .meteor { display: none; }
}