:root{
    --font-sans: Inter, "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: Inter, "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --space-xs: 0.35rem;
    --space-sm: 0.65rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2.25rem;
    --space-2xl: 3rem;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --content-max: min(1100px, 96vw);
    --readable-max: min(72ch, 88vw);
}

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

body{
    min-height: 100vh;
    height: auto;
}

#theme-toggle{
    position: fixed;
    top: 1.25rem;
    left: 1.25rem;
    z-index: 2000;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.9rem;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(10px);
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

#theme-toggle:hover{
    transform: translateY(-2px);
    box-shadow: var(--shadow-strong);
}

#theme-toggle:focus-visible{
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

#theme-toggle .toggle-icon{
    font-size: 1.1rem;
}

#theme-toggle .toggle-label{
    font-size: 0.85rem;
    letter-spacing: 0.01em;
}

@media (max-width: 640px){
    #theme-toggle{
        top: 0.75rem;
        left: 0.75rem;
        padding: 0.35rem 0.75rem;
    }
}
#title{
    font-size: clamp(2.4rem, 7.2vw, 6rem);
    margin-bottom: 0.2em;
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.04;
    letter-spacing: -0.02em;
}
#footer{
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: min(1200px, 100%);
    box-sizing: border-box;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-md);
    flex: 0 0 auto; /* do not grow or shrink */
    background: transparent;
    color: var(--muted);
    gap: var(--space-md);
    font-size: 0.95rem;
}
#signature-box > p{
    margin: 0;
    padding: 0;
    font-size: 0.8em;
    color: var(--muted);
    position: relative;
    transform: translate(19vw, -20px);
    max-width: 55px;
}
/* Ensure the page root can grow with content and allow flexible layout */
html { height: 100%; }
body {
    min-height: 100vh; /* allow body to expand beyond the viewport if content is taller */
    display: flex;
    flex-direction: column;
    margin: 0;
    padding-left: 2vw;
    padding-right: 2vw;
    font-family: var(--font-sans);
    color: var(--text);
    background-color: var(--bg);
    line-height: 1.55;
    transition: background-color 240ms ease, color 240ms ease;
    position: relative;
    isolation: isolate;
}

body::before{
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transform: translateX(-100%);
}

body > *{
    position: relative;
    z-index: 1;
}

body.theme-sweep-dark::before{
    background: #170927;
    animation: theme-color-sweep-fill 720ms cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

body.theme-sweep-light::before{
    background: #f5f7fb;
    animation: theme-color-sweep-fill 720ms cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

@keyframes theme-color-sweep-fill{
    0%{
        opacity: 1;
        transform: translateX(-100%);
    }
    100%{
        opacity: 1;
        transform: translateX(0);
    }
}

#central-box{
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1 0 auto;
    min-height: calc(100vh - 130px);
    width: 100%;
    margin: 0 auto;
}
#about-me{
    text-align: center;
    width: var(--content-max);
    max-width: 100%;
    margin: var(--space-xl) auto;
    padding: clamp(1.2rem, 3vw, 2.8rem);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(4px);
}
.modern-link{
    text-decoration: none;
    color: var(--accent);
    font-weight: 500;
    text-underline-offset: 0.24em;
    transition: color 180ms ease, opacity 180ms ease;
}
.modern-link:hover{
    color: var(--accent);
    opacity: 0.84;
}
.modern-link:focus-visible{
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 3px;
}
.unfinished{
    /* preserved orange for unfinished features */
    color: var(--accent-2) !important;
    font-style: italic !important;

}
.unfinished::after{
    content: "*";
}

.page-section{
    margin-top: var(--space-xl);
}

.page-section p{
    margin-left: auto;
    margin-right: auto;
    max-width: var(--readable-max);
}

.content-narrow{
    max-width: var(--readable-max);
    margin-left: auto;
    margin-right: auto;
}

.grid-2{
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-lg);
}

.grid-3{
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-lg);
}

.title-display-md{
    font-size: clamp(2.2rem, 6vw, 5rem);
}

.footer-link-right{
    padding-left: 100px;
}

.modern-underline{
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-underline-offset: 7px;
    text-decoration-thickness: 3px;
}

.accent2{
    color: var(--accent-2);
}

.contact-grid{
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-lg);
    width: min(680px, 92vw);
    margin: 0 auto;
}

.contact-card{
    text-align: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    padding: var(--space-md);
}

.projects-timeline{
    --timeline-marker-size: 1rem;
    --timeline-right-inset: clamp(0.5rem, 1.2vw, 1rem);
    position: relative;
    margin-top: var(--space-xl);
    padding-right: calc(var(--space-xl) + var(--timeline-right-inset));
    display: grid;
    gap: var(--space-lg);
}

.projects-timeline::after{
    content: "";
    position: absolute;
    top: 0.25rem;
    bottom: 0.25rem;
    right: var(--timeline-right-inset);
    width: 2px;
    background: linear-gradient(180deg, var(--border) 0%, var(--accent) 50%, var(--border) 100%);
    border-radius: 999px;
    z-index: 1;
}

.timeline-card{
    position: relative;
    z-index: 2;
}
.timeline-item:hover .timeline-card{
    border-color: var(--accent);
    border-width: 1px;
}

.timeline-card{
    text-align: left;
    padding: clamp(1rem, 2.1vw, 1.5rem);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
    box-shadow: var(--shadow-soft);
    transition: border-color 180ms ease, border-width 180ms ease;
}

.timeline-card-layout{
    display: grid;
    grid-template-columns: minmax(140px, 180px) minmax(0, 1fr);
    gap: var(--space-md);
    align-items: start;
}

.timeline-thumb{
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
}

.timeline-title{
    margin: 0;
    font-size: clamp(1.45rem, 2.6vw, 2rem);
    font-family: var(--font-display);
    letter-spacing: -0.01em;
}
.timeline-timeframe{
    margin: var(--space-xs) 0 0;
    margin-top: 0;
    color: var(--accent);
    font-size: 0.95rem;
    font-weight: 500;
}
.timeline-description{
    margin: var(--space-sm) 0 0;
    color: var(--text);
}

.timeline-meta{
    margin: var(--space-md) 0 0;
    color: var(--muted);
    font-size: 0.96rem;
    line-height: 1.45;
}

.timeline-links{
    margin-top: var(--space-md);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}
.github-link{
    color: black !important
}
.timeline-icon-link{
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    text-decoration: none;
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.3rem 0.7rem;
    background: var(--surface);
    font-weight: 600;
    font-size: 0.9rem;
    transition: opacity 180ms ease, transform 180ms ease;
}

.timeline-icon-link:hover{
    opacity: 0.86;
    transform: translateY(-1px);
}

.timeline-icon-link:focus-visible{
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.timeline-icon-link svg{
    width: 1rem;
    height: 1rem;
    fill: currentColor;
}

.timeline-marker{
    position: absolute;
    top: 50%;
    right: calc(var(--timeline-right-inset) - (var(--timeline-marker-size) / 2));
    transform: translateY(-50%);
    width: var(--timeline-marker-size);
    height: var(--timeline-marker-size);
    border-radius: 50%;
    background: transparent;
    border: 2px solid var(--accent);
    z-index: 3;
}

@media (max-width: 900px){
    #footer{
        flex-wrap: wrap;
        justify-content: center;
        text-align: center;
    }

    .grid-3{
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .projects-timeline{
        --timeline-right-inset: 0.45rem;
        padding-right: calc(var(--space-lg) + var(--timeline-right-inset));
    }
}

@media (max-width: 640px){
    body{
        padding-left: 4vw;
        padding-right: 4vw;
    }

    #central-box{
        min-height: auto;
        padding-top: 5.2rem;
    }

    #about-me{
        margin-top: var(--space-md);
        border-radius: var(--radius-md);
    }

    #footer{
        flex-direction: column;
        align-items: center;
        gap: var(--space-sm);
    }

    .footer-link-right{
        padding-left: 0;
    }

    .grid-2,
    .grid-3{
        grid-template-columns: 1fr;
    }

    .contact-grid{
        grid-template-columns: 1fr;
    }

    .projects-timeline{
        --timeline-right-inset: 0.3rem;
        padding-right: calc(var(--space-md) + var(--timeline-right-inset));
        gap: var(--space-md);
    }

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

    .timeline-card-layout{
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce){
    body.theme-sweep-dark::before,
    body.theme-sweep-light::before{
        animation: none;
    }
}