@font-face {
    font-family: Modulus;
    src: url("Modulus Pro Regular.otf") format("opentype");
    font-display: swap;
}

@font-face {
    font-family: Modulus;
    font-weight: bold;
    src: url("Modulus Pro Bold.otf") format("opentype");
    font-display: swap;
}

@font-face {
    src: url('font.woff2') format('woff2');
    font-family: Inter;
    font-display: swap;
}

/* ── Design Tokens ── */
:root {
    --background: image-set(url('bg2.webp') type('image/webp'), url('bg2.jpg') type('image/jpeg'));
    --primary-color: #9af;
    --primary-glow: rgba(153, 170, 255, 0.2);
    --text-color: #fff;
    --text-muted: rgba(255, 255, 255, 0.72);
    --glass-bg: rgba(255, 255, 255, 0.055);
    --glass-border: rgba(255, 255, 255, 0.09);
    --glass-hover: rgba(255, 255, 255, 0.09);
    --transition: 0.25s ease;
    --radius: 16px;
    --radius-sm: 12px;
    font-weight: 500;
    line-height: 1.6;
    font-family: Modulus, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* ── Reset ── */
h1, p { margin: 0; }
a { text-decoration: none; }

html {
    -webkit-tap-highlight-color: transparent;
    scrollbar-width: thin;
    scrollbar-gutter: stable;
    user-select: none;
    overflow-y: scroll;
}

::selection {
    background: var(--primary-glow);
    color: #fff;
}

body {
    margin: 0 auto;
    min-width: 320px;
    max-width: min(1280px, 100% - 100px);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
    padding-right: 0;
    overflow-y: scroll;
    position: relative;
}

@media (width < 880px) {
    body {
        max-width: calc(100% - 40px);
    }
}

/* ── Background ── */
#bg {
    --multiplier: clamp(0, calc(-5 * var(--scroll, 0) + 1.5), 1);
    position: fixed;
    transform: translate(calc(var(--tx, 0) * var(--multiplier, 1)), calc(var(--ty, 0) * var(--multiplier, 1)));
    z-index: -1;
    filter: blur(clamp(0px, calc(50px * var(--scroll, 0) + -5px), 10px)) brightness(clamp(.3, calc(-.45 * var(--scroll, 0) + .8), .8));
    inset: -30px;
    background: var(--primary-color) var(--background) center/cover no-repeat;
}

/* ── Header / Hero ── */
header {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 48px;
    transform: translateY(-50%);
    margin-top: 45vh;
}

@media (width < 1300px) {
    header {
        margin-right: auto;
        margin-left: auto;
        max-width: 950px;
    }
}

@media (width < 880px) {
    header {
        flex-direction: column;
        gap: 24px;
        margin-right: auto;
        margin-left: auto;
        max-width: 480px;
    }
    header h1 { text-align: center; }
    header p { text-align: center; }
}

/* Avatar — Gestalt: Figure-Ground (ring + shadow separate from bg) */
header img {
    animation: 1s ease-in-out .2s both avatar;
    border-radius: 50%;
    width: clamp(130px, 26vmin, 200px);
    height: clamp(130px, 26vmin, 200px);
    pointer-events: none;
    border: 3px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    transition: box-shadow 0.4s, border-color 0.4s;
}

header img:hover {
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3), 0 0 24px var(--primary-glow);
}

@keyframes avatar {
    0% { transform: scale(.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

header section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

header svg {
    width: min(500px, 100%);
}

/* SVG name draw animation */
@keyframes animate-svg-stroke-1 {
    0% { stroke-dashoffset: 2505.140625px; stroke-dasharray: 2505.140625px; }
    100% { stroke-dashoffset: 0; stroke-dasharray: 2505.140625px; }
}

@keyframes animate-svg-fill-1 {
    0% { fill: transparent; }
    100% { fill: rgb(255, 255, 255); }
}

.svg-elem-1 {
    animation: animate-svg-stroke-1 20s ease-out 0s both,
               animate-svg-fill-1 0.7s cubic-bezier(0.47, 0, 0.745, 0.715) 0.9s both;
}

/* Header tagline */
header p {
    -webkit-mask: linear-gradient(to right, #fff 45%, transparent 55%) 0 0/220% 100% no-repeat;
    opacity: clamp(.7, .75 * var(--scroll, 0) + .7, .85);
    animation: 1.7s ease-in-out 0.3s both bio;
    color: var(--text-color);
    font-weight: normal;
    font-size: clamp(17px, 2.8vmin, 24px);
    letter-spacing: 0.01em;
}

@keyframes bio {
    0% { -webkit-mask-position: 100% 0; }
    100% { -webkit-mask-position: 0% 0; }
}

/* Social Links — HCI: Fitts's Law (44px targets), Feedback (hover transform) */
.social-links {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    animation: move-socials-down 1.7s ease-out 0.3s both;
}

@media (width < 880px) {
    .social-links {
        justify-content: center;
    }
}

.social-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all var(--transition);
}

.social-links a:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.2);
}

.social-links svg {
    height: 22px;
    width: 22px;
}

@keyframes move-socials-down {
    from { transform: translateY(-80px); }
    to { transform: translateY(0); }
}

/* ── Scroll Arrow — HCI: Affordance + Feedback ── */
#arrow {
    display: flex;
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    justify-content: center;
    transition: opacity .2s;
}

#arrow svg {
    opacity: .45;
    transition: opacity .2s, transform .3s ease;
    cursor: pointer;
    padding: 0 15px;
    width: 60px;
    height: 90px;
    color: var(--text-color);
}

#arrow svg:hover {
    opacity: .8;
    transform: translateY(4px);
}

body[style*='.'] #arrow {
    opacity: 0;
    pointer-events: none;
}

/* ── Main Content ── */
#main {
    display: flex;
    flex-direction: column;
    gap: 20px;
    opacity: calc(var(--scroll) / 0.15);
    margin-top: calc(35vh * (1 - min(var(--scroll), 1)));
    margin-bottom: calc(1vh * min(var(--scroll), 1));
    min-height: calc(100vh - 20vh - 20vh);
    flex: 1 0 auto;
    max-width: 950px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

@media (width < 880px) {
    #main {
        margin-right: auto;
        margin-left: auto;
        max-width: 480px;
    }
}

/* ── Glass Card — Gestalt: Common Region + Figure-Ground ── */
.bio,
.collapsible-section {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 28px 32px;
    transition: background var(--transition), border-color var(--transition), box-shadow 0.3s ease;
}

.bio:hover,
.collapsible-section:hover {
    background: var(--glass-hover);
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
}

@media (width < 880px) {
    .bio,
    .collapsible-section {
        padding: 24px 20px;
    }
}

/* ── Bio Section — Gestalt: Hierarchy ── */
.bio {
    color: var(--text-color);
}

.bio h2 {
    margin: 0 0 10px 0;
    color: var(--text-color);
    font-size: 1.5em;
    letter-spacing: 0.02em;
}

.bio p {
    font-size: 1.08em;
    line-height: 1.7;
    color: var(--text-muted);
}

/* ── Collapsible Sections — HCI: Progressive Disclosure ── */
.collapsible-section {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
}

.collapsible-section details {
    color: var(--text-color);
    padding: 0;
    margin: 0;
    width: 100%;
    box-sizing: border-box;
}

.collapsible-section summary {
    padding: 0;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Chevron indicator — HCI: Affordance */
.collapsible-section summary::after {
    content: '';
    width: 9px;
    height: 9px;
    border-right: 2px solid var(--text-color);
    border-bottom: 2px solid var(--text-color);
    transform: rotate(-45deg);
    transition: transform 0.3s ease;
    margin-left: auto;
    opacity: 0.4;
    flex-shrink: 0;
}

.collapsible-section details[open] summary::after {
    transform: rotate(45deg);
}

.collapsible-section summary::before {
    display: none;
}

.collapsible-section summary::-webkit-details-marker {
    display: none;
}

.collapsible-section summary h2 {
    margin: 0;
    color: var(--text-color);
    font-size: 1.5em;
    letter-spacing: 0.02em;
}

.collapsible-section .content {
    overflow: hidden;
    box-sizing: border-box;
    padding: 0 6px 0 0;
    margin: 0;
    width: 100%;
}

.collapsible-section .content::after {
    content: '';
    display: block;
    height: 8px;
}

.collapsible-section .content p {
    margin-bottom: 0;
    opacity: 0.85;
}

.collapsible-section .content ul {
    margin-top: 10px;
    padding-left: 20px;
}

/* ── Experience Items — Gestalt: Proximity + Similarity ── */
.collapsible-section .content:has(.experience-item) {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.experience-item {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all var(--transition);
}

.experience-item:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.12);
    transform: translateX(4px);
}

.experience-main {
    flex-grow: 1;
}

.experience-aside {
    flex-shrink: 0;
    text-align: right;
}

.experience-main p,
.experience-aside p {
    margin: 0;
}

.experience-aside p {
    opacity: 0.55;
    font-size: 0.9em;
}

@media (width < 600px) {
    .experience-item {
        flex-direction: column;
        gap: 6px;
    }
    .experience-aside {
        text-align: left;
    }
    .experience-aside p {
        font-size: 0.85em;
    }
}

/* ── Project Cards — Gestalt: Common Region + Similarity ── */
.content:has(.project-card) {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 20px;
}

.project-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 22px 26px;
    border-left: 3px solid var(--primary-color);
    background: rgba(255, 255, 255, 0.035);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    transition: all var(--transition);
}

.project-card:hover {
    background: rgba(255, 255, 255, 0.075);
    transform: translateX(6px);
    border-left-color: #bdf;
    box-shadow: -3px 0 16px var(--primary-glow);
}

.project-title {
    margin: 0;
    font-size: 1.25em;
    color: var(--text-color);
    font-weight: bold;
    letter-spacing: 0.01em;
}

.project-tagline {
    margin: 0;
    font-style: italic;
    opacity: 0.72;
    font-size: 0.95em;
}

.project-description {
    margin: 2px 0 0 0;
    opacity: 0.8;
    line-height: 1.6;
}

@media (width < 600px) {
    .project-card {
        align-items: center;
        text-align: center;
        padding: 20px;
    }
}

/* ── Footer ── */
footer {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 15vh;
    font-size: 18px;
    position: relative;
    z-index: 1;
    width: 100%;
    margin-top: auto;
}

footer p {
    opacity: .5;
    transition: opacity .3s;
    color: var(--text-color);
    line-height: 2;
    text-align: center;
}

footer p:hover {
    opacity: .7;
}

footer a {
    transition: color .2s;
    color: var(--primary-color);
}

footer a:hover {
    color: #bdf;
}

/* ── Custom Scrollbar (min.js) ── */
#os {
    position: fixed;
    inset: 0 0 0 auto;
    box-sizing: border-box;
    padding: 4px;
    width: 16px;
}

@media (width < 880px) {
    #os { display: none; }
}

#track {
    height: 100%;
    touch-action: none;
}

#handle {
    transition: background-color .2s;
    border-radius: 4px;
    background: #def6;
}

#handle:before {
    position: absolute;
    inset: -4px;
    content: '';
}

#handle:hover {
    background: #defa;
}

/* Native scrollbar hidden (custom replaces it) */
::-webkit-scrollbar { width: 17px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: transparent; }
