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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: #264653;
    background-color: #faf9f6;
}

/* Circuit-body scroll background */
#circuit-bg {
    position: fixed;
    top: 50%;
    right: 1.5vw;
    transform: translateY(-50%);
    height: min(88vh, 760px);
    aspect-ratio: 400 / 760;
    z-index: 0;
    pointer-events: none;
}

#circuit-bg svg {
    display: block;
    width: 100%;
    height: 100%;
}

#circuit-bg .c-trace {
    fill: none;
    stroke: rgba(42, 157, 143, 0.30);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#circuit-bg .c-line {
    fill: none;
    stroke: rgba(38, 70, 83, 0.26);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#circuit-bg .c-line.thin {
    stroke-width: 1.25;
}

#circuit-bg .c-via {
    fill: #faf9f6;
    stroke: rgba(38, 70, 83, 0.32);
    stroke-width: 1.5;
}

#circuit-bg .c-pad {
    fill: rgba(42, 157, 143, 0.30);
}

#circuit-bg .c-led {
    fill: rgba(231, 111, 81, 0.45);
}

#circuit-bg .c-heart {
    fill: rgba(231, 111, 81, 0.10);
    stroke: rgba(231, 111, 81, 0.50);
    stroke-width: 2;
    stroke-linejoin: round;
}

/* Lub-dub heartbeat, scaled about the heart's own center */
#circuit-bg .c-heartbeat {
    transform-box: fill-box;
    transform-origin: center;
    animation: heart-beat 1.5s ease-in-out infinite;
}

@keyframes heart-beat {
    0%, 40%, 100% { transform: scale(1); }
    10% { transform: scale(1.16); }
    20% { transform: scale(1); }
    28% { transform: scale(1.08); }
}

#circuit-bg .c-part {
    opacity: 0;
    will-change: opacity, transform;
}

#circuit-bg.assembled .c-led {
    animation: led-pulse 2.8s ease-in-out infinite;
}

@keyframes led-pulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}

/* Narrower windows: content column reaches under the figure, so soften it */
@media (max-width: 1250px) {
    #circuit-bg {
        opacity: 0.55;
    }
}

@media (max-width: 900px) {
    #circuit-bg {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    #circuit-bg.assembled .c-led,
    #circuit-bg .c-heartbeat {
        animation: none;
    }
}

main,
footer {
    position: relative;
    z-index: 1;
}

/* Spotlight cursor effect */
#spotlight {
    pointer-events: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
}

/* Top Navigation */
#topnav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: #faf9f6;
    border-bottom: 2px solid #e9c46a;
    padding: 0.75rem 2.5rem;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.nav-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #264653;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    gap: 1.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav-link {
    text-decoration: none;
    color: #264653;
    font-size: 0.9rem;
    font-weight: 600;
    padding-bottom: 2px;
    border-bottom: 1.5px solid transparent;
    transition: color 0.2s ease;
    white-space: nowrap;
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 100%;
    height: 1.5px;
    background-color: #2a9d8f;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s ease;
}

.nav-link:hover::after {
    transform: scaleX(1);
}

.nav-link:hover {
    color: #2a9d8f;
}

.nav-link.active {
    color: #264653;
    border-bottom: 1.5px solid #e9c46a;
}

/* Tab sections — always visible for scroll layout */
.tab-section {
    display: block;
}

/* Main Content */
main {
    max-width: 860px;
    margin: 0 auto;
    margin-top: 58px;
    padding: 3rem 3.5rem;
}

section {
    margin-bottom: 4rem;
    padding-top: 2rem;
    scroll-margin-top: 72px;
}

h1, h2, h3, .nav-name {
    font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
}

h1 {
    font-size: 2.2rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    margin-bottom: 1.5rem;
    color: #264653;
    padding-bottom: 0.5rem;
    position: relative;
}

/* Underline sweeps in when the section scrolls into view */
h1::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, #e9c46a 60%, #e76f51);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.15s;
}

.tab-section.in-view h1::after {
    transform: scaleX(1);
}

.article-page h1::after {
    display: none;
}

h2 {
    font-size: 1.55rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #2a9d8f;
}

h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: #264653;
}

p {
    margin-bottom: 1rem;
    font-size: 1rem;
}

a {
    color: #264653;
    text-decoration: underline;
    transition: color 0.3s ease;
}

a:hover {
    color: #e76f51;
}

/* About Section Email Decoration - Sun */
.email-decoration {
    margin: 1rem auto 0;
    display: block;
    opacity: 0;
}

.email-decoration.animate {
    animation: fadeIn 1s ease-in forwards;
}

.sun-center {
    transform: scale(0);
    transform-origin: center;
}

.email-decoration.animate .sun-center {
    animation: popIn 0.8s ease-out forwards;
    animation-delay: 0.5s;
}

.sun-ray {
    opacity: 0;
    transform-origin: center;
}

.email-decoration.animate .sun-ray-1 {
    animation: rayAppear 0.4s ease-out forwards;
    animation-delay: 1s;
}

.email-decoration.animate .sun-ray-2 {
    animation: rayAppear 0.4s ease-out forwards;
    animation-delay: 1.1s;
}

.email-decoration.animate .sun-ray-3 {
    animation: rayAppear 0.4s ease-out forwards;
    animation-delay: 1.2s;
}

.email-decoration.animate .sun-ray-4 {
    animation: rayAppear 0.4s ease-out forwards;
    animation-delay: 1.3s;
}

.email-decoration.animate .sun-ray-5 {
    animation: rayAppear 0.4s ease-out forwards;
    animation-delay: 1.4s;
}

.email-decoration.animate .sun-ray-6 {
    animation: rayAppear 0.4s ease-out forwards;
    animation-delay: 1.5s;
}

.email-decoration.animate .sun-ray-7 {
    animation: rayAppear 0.4s ease-out forwards;
    animation-delay: 1.6s;
}

.email-decoration.animate .sun-ray-8 {
    animation: rayAppear 0.4s ease-out forwards;
    animation-delay: 1.7s;
}

@keyframes rayAppear {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Sun continuous animation */
.email-decoration.animate .sun-center {
    animation: popIn 0.8s ease-out forwards, sunPulse 3s ease-in-out infinite;
    animation-delay: 0.5s, 2s;
}

@keyframes sunPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Section Headers with Animations */
.section-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.section-header h1 {
    margin-bottom: 0;
}

/* Year Block Header */
.year-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.year-header h2 {
    margin: 0;
}

.year-animation {
    opacity: 0;
    flex-shrink: 0;
}

.year-animation.animate {
    animation: fadeIn 1s ease-in forwards;
}

/* 2025 PCB Animation */
.year-animation.animate .pcb-board {
    stroke-dasharray: 250;
    stroke-dashoffset: 250;
    animation: drawLine 2s ease-out forwards;
    animation-delay: 0.3s;
}

.pcb-trace {
    stroke-dasharray: 50;
    stroke-dashoffset: 50;
}

.year-animation.animate .pcb-trace-1 {
    animation: drawLine 0.8s ease-out forwards;
    animation-delay: 1s;
}

.year-animation.animate .pcb-trace-2 {
    animation: drawLine 0.8s ease-out forwards;
    animation-delay: 1.3s;
}

.year-animation.animate .pcb-trace-3 {
    animation: drawLine 0.8s ease-out forwards;
    animation-delay: 1.6s;
}

.pcb-component {
    opacity: 0;
    transform: scale(0);
}

.year-animation.animate .pcb-comp-1 {
    animation: popIn 0.4s ease-out forwards;
    animation-delay: 1.8s;
}

.year-animation.animate .pcb-comp-2 {
    animation: popIn 0.4s ease-out forwards;
    animation-delay: 2s;
}

.year-animation.animate .pcb-comp-3 {
    animation: popIn 0.4s ease-out forwards;
    animation-delay: 2.2s;
}

.year-animation.animate .pcb-chip {
    opacity: 0;
    transform: scale(0);
    animation: popIn 0.5s ease-out forwards;
    animation-delay: 2.4s;
}

/* PCB continuous animation - signal flow */
.pcb-component {
    animation: popIn 0.4s ease-out forwards, componentGlow 2s ease-in-out infinite;
}

.year-animation.animate .pcb-comp-1 {
    animation-delay: 1.8s, 3s;
}

.year-animation.animate .pcb-comp-2 {
    animation-delay: 2s, 3.2s;
}

.year-animation.animate .pcb-comp-3 {
    animation-delay: 2.2s, 3.4s;
}

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

/* 2024 Bio Animation - EEG */
.bio-animation {
    opacity: 0;
}

.bio-animation.animate {
    animation: fadeIn 1s ease-in forwards;
}

/* EEG Wave Animation */
.eeg-wave {
    stroke-dasharray: 250;
    stroke-dashoffset: 250;
}

.year-animation.animate .eeg-wave {
    animation: drawLine 2.5s ease-in-out forwards, eegPulse 2s ease-in-out infinite;
    animation-delay: 0.5s, 3s;
}

.year-animation.animate .eeg-baseline {
    opacity: 0;
    animation: fadeIn 0.5s ease-in forwards;
    animation-delay: 0.3s;
}

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

/* 2023 Computer Animation */
.year-animation.animate .monitor-bezel, .year-animation.animate .monitor-screen {
    opacity: 0;
    animation: fadeIn 0.5s ease-in forwards;
    animation-delay: 0.3s;
}

.year-animation.animate .code-line {
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
}

.year-animation.animate .code-line-1 {
    animation: drawLine 0.6s ease-out forwards;
    animation-delay: 1s;
}

.year-animation.animate .code-line-2 {
    animation: drawLine 0.6s ease-out forwards;
    animation-delay: 1.3s;
}

.year-animation.animate .code-line-3 {
    animation: drawLine 0.6s ease-out forwards;
    animation-delay: 1.6s;
}

.year-animation.animate .monitor-stand, .year-animation.animate .monitor-base {
    opacity: 0;
    transform: translateY(-10px);
    animation: dropIn 0.5s ease-out forwards;
    animation-delay: 2s;
}

/* Computer continuous animation - screen glow */
.year-animation.animate .monitor-screen {
    animation: fadeIn 0.5s ease-in forwards, screenGlow 3s ease-in-out infinite;
    animation-delay: 0.3s, 2.5s;
}

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

@keyframes drawLine {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes popIn {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes dropIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Projects Animation - Magnifying Glass */
.projects-animation {
    opacity: 0;
}

.projects-animation.animate {
    opacity: 0;
    animation: fadeIn 1s ease-in forwards;
}

.projects-animation.animate .mag-lens {
    stroke-dasharray: 130;
    stroke-dashoffset: 130;
    animation: drawLine 1.5s ease-out forwards;
    animation-delay: 0.5s;
}

.projects-animation.animate .mag-inner {
    opacity: 0;
    animation: fadeIn 0.8s ease-in forwards;
    animation-delay: 1.5s;
}

.projects-animation.animate .mag-handle {
    stroke-dasharray: 30;
    stroke-dashoffset: 30;
    animation: drawLine 0.8s ease-out forwards;
    animation-delay: 1.8s;
}

.projects-animation.animate .mag-sparkle {
    opacity: 0;
    transform: scale(0);
}

.projects-animation.animate .mag-sparkle-1 {
    animation: sparkle 0.6s ease-out forwards;
    animation-delay: 2.2s;
}

.projects-animation.animate .mag-sparkle-2 {
    animation: sparkle 0.6s ease-out forwards;
    animation-delay: 2.5s;
}

@keyframes sparkle {
    0% {
        opacity: 0;
        transform: scale(0);
    }
    50% {
        opacity: 1;
        transform: scale(1.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Magnifying glass continuous animation - sparkle pulse */
.projects-animation.animate .mag-sparkle {
    animation: sparkle 0.6s ease-out forwards, sparklePulse 2s ease-in-out infinite;
}

.projects-animation.animate .mag-sparkle-1 {
    animation-delay: 2.2s, 3s;
}

.projects-animation.animate .mag-sparkle-2 {
    animation-delay: 2.5s, 3.3s;
}

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

/* Writing Animation - Paper with Writing */
.writing-animation {
    opacity: 0;
}

.writing-animation.animate {
    opacity: 0;
    animation: fadeIn 1s ease-in forwards;
}

.writing-animation.animate .paper-sheet {
    opacity: 0;
    transform: translateY(-20px);
    animation: dropIn 0.6s ease-out forwards;
    animation-delay: 0.3s;
}

.writing-animation.animate .paper-fold {
    opacity: 0;
    animation: fadeIn 0.4s ease-in forwards;
    animation-delay: 0.8s;
}

.writing-animation.animate .writing-line {
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
}

.writing-animation.animate .writing-line-1 {
    animation: drawLine 0.6s ease-out forwards;
    animation-delay: 1s;
}

.writing-animation.animate .writing-line-2 {
    animation: drawLine 0.6s ease-out forwards;
    animation-delay: 1.2s;
}

.writing-animation.animate .writing-line-3 {
    animation: drawLine 0.6s ease-out forwards;
    animation-delay: 1.4s;
}

.writing-animation.animate .writing-line-4 {
    animation: drawLine 0.6s ease-out forwards;
    animation-delay: 1.6s;
}

.writing-animation.animate .writing-line-5 {
    animation: drawLine 0.6s ease-out forwards;
    animation-delay: 1.8s;
}

.writing-animation.animate .writing-line-6 {
    animation: drawLine 0.6s ease-out forwards;
    animation-delay: 2s;
}

/* Paper continuous animation - gentle float */
.writing-animation.animate .paper-sheet {
    animation: dropIn 0.6s ease-out forwards, paperFloat 4s ease-in-out infinite;
    animation-delay: 0.3s, 2.5s;
}

@keyframes paperFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-3px);
    }
}

/* Classes Animation - Stacking Books */
.classes-animation {
    opacity: 0;
}

.classes-animation.animate {
    opacity: 0;
    animation: fadeIn 1s ease-in forwards;
}

.classes-animation.animate .book {
    opacity: 0;
    transform: translateY(-30px) scale(0.8);
}

.classes-animation.animate .book-1 {
    animation: dropBook 0.7s ease-out forwards;
    animation-delay: 0.5s;
}

.classes-animation.animate .book-2 {
    animation: dropBook 0.7s ease-out forwards;
    animation-delay: 0.9s;
}

.classes-animation.animate .book-3 {
    animation: dropBook 0.7s ease-out forwards;
    animation-delay: 1.3s;
}

.classes-animation.animate .book-4 {
    animation: dropBook 0.7s ease-out forwards;
    animation-delay: 1.7s;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

@keyframes dropBook {
    0% {
        opacity: 0;
        transform: translateY(-30px) scale(0.8);
    }
    60% {
        transform: translateY(5px) scale(1.05);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Books continuous animation - gentle bob */
.classes-animation.animate .book-1 {
    animation: dropBook 0.7s ease-out forwards, bookBob 3s ease-in-out infinite;
    animation-delay: 0.5s, 2.5s;
}

.classes-animation.animate .book-2 {
    animation: dropBook 0.7s ease-out forwards, bookBob 3s ease-in-out infinite;
    animation-delay: 0.9s, 2.7s;
}

.classes-animation.animate .book-3 {
    animation: dropBook 0.7s ease-out forwards, bookBob 3s ease-in-out infinite;
    animation-delay: 1.3s, 2.9s;
}

.classes-animation.animate .book-4 {
    animation: dropBook 0.7s ease-out forwards, bookBob 3s ease-in-out infinite;
    animation-delay: 1.7s, 3.1s;
}

@keyframes bookBob {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-2px) scale(1);
    }
}

/* About Section */
.about-content {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.profile-image {
    width: 300px;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    object-fit: cover;
}

.about-text {
    flex: 1;
    min-width: 300px;
}

#about .contact {
    margin-top: 1.5rem;
}

/* Experience Section */
.year-block {
    margin-bottom: 2.5rem;
    padding: 1.5rem;
    background-color: #ffffff;
    border-radius: 8px;
    border-left: 4px solid #e76f51;
}

.year-block h2 {
    margin-top: 0;
}

.year-block ul {
    margin-left: 1.5rem;
    margin-top: 0.75rem;
}

.year-block li {
    margin-bottom: 0.75rem;
}

.year-block ul ul {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.year-block ul ul li {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

/* Projects Section */
#projects ul {
    margin-left: 1.5rem;
}

#projects > ul > li {
    margin-bottom: 1rem;
}

#projects ul ul {
    margin-top: 0.5rem;
    margin-left: 1.5rem;
}

#projects ul ul li {
    margin-bottom: 0.5rem;
}

/* Writing Section */
#writing ul {
    margin-left: 1.5rem;
}

#writing li {
    margin-bottom: 0.5rem;
}

/* Classes Section */
.class-category {
    margin-bottom: 1.5rem;
}

.class-category h3 {
    margin-top: 0;
    color: #2a9d8f;
}

.class-category ul {
    margin-left: 1.5rem;
}

.class-category li {
    margin-bottom: 0.5rem;
}

/* Hobbies Animation - Water Polo Ball on Waves */
.hobbies-animation {
    opacity: 0;
}

.hobbies-animation.animate {
    animation: fadeIn 1s ease-in forwards;
}

.hobby-wave {
    stroke-dasharray: 120;
    stroke-dashoffset: 120;
}

.hobbies-animation.animate .hobby-wave-1 {
    animation: drawLine 1.2s ease-out forwards, waveDrift 3.5s ease-in-out infinite;
    animation-delay: 0.4s, 2s;
}

.hobbies-animation.animate .hobby-wave-2 {
    animation: drawLine 1.2s ease-out forwards, waveDrift 3.5s ease-in-out infinite reverse;
    animation-delay: 0.7s, 2.3s;
}

.hobby-ball {
    opacity: 0;
    transform: translateY(-25px);
    transform-box: fill-box;
    transform-origin: center;
}

.hobbies-animation.animate .hobby-ball {
    animation: ballDrop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards, ballBob 2.6s ease-in-out infinite;
    animation-delay: 1.2s, 2.4s;
}

@keyframes waveDrift {
    0%, 100% {
        transform: translateX(0);
    }
    50% {
        transform: translateX(5px);
    }
}

@keyframes ballDrop {
    0% {
        opacity: 0;
        transform: translateY(-25px);
    }
    70% {
        opacity: 1;
        transform: translateY(4px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes ballBob {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-6px) rotate(10deg);
    }
}

/* Animation polish - continuous motion overrides */

/* Sun: slow rotation once risen */
.email-decoration.animate {
    animation: fadeIn 1s ease-in forwards, sunSpin 30s linear infinite;
    animation-delay: 0s, 2.5s;
}

@keyframes sunSpin {
    to {
        transform: rotate(360deg);
    }
}

/* EEG: sweeping monitor-style redraw instead of opacity pulse */
.year-animation.animate .eeg-wave {
    animation: drawLine 2.5s ease-in-out forwards, eegFlow 5s linear infinite;
    animation-delay: 0.5s, 3.2s;
}

@keyframes eegFlow {
    from {
        stroke-dashoffset: 0;
    }
    to {
        stroke-dashoffset: -500;
    }
}

/* PCB: signal pulses travel along the traces after drawing */
.year-animation.animate .pcb-trace-1 {
    animation: drawLine 0.8s ease-out forwards, traceFlow 2.2s linear infinite;
    animation-delay: 1s, 2.8s;
}

.year-animation.animate .pcb-trace-2 {
    animation: drawLine 0.8s ease-out forwards, traceFlow 2.2s linear infinite;
    animation-delay: 1.3s, 3.2s;
}

.year-animation.animate .pcb-trace-3 {
    animation: drawLine 0.8s ease-out forwards, traceFlow 2.2s linear infinite;
    animation-delay: 1.6s, 3.6s;
}

@keyframes traceFlow {
    from {
        stroke-dashoffset: 0;
    }
    to {
        stroke-dashoffset: -100;
    }
}

/* Chip joins the component glow cycle */
.year-animation.animate .pcb-chip {
    animation: popIn 0.5s ease-out forwards, componentGlow 2s ease-in-out infinite;
    animation-delay: 2.4s, 3.6s;
}

/* Magnifying glass: gentle searching sweep */
.projects-animation.animate {
    animation: fadeIn 1s ease-in forwards, magSearch 5s ease-in-out infinite;
    animation-delay: 0s, 3s;
}

@keyframes magSearch {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
    }
    30% {
        transform: translate(-4px, 2px) rotate(-4deg);
    }
    65% {
        transform: translate(4px, -2px) rotate(4deg);
    }
}

/* Articles Carousel */
.carousel-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1.5rem 0 2rem;
}

.carousel-track {
    display: flex;
    gap: 1.25rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    padding: 0.5rem 0.25rem 1rem;
    flex: 1;
}

.carousel-track::-webkit-scrollbar {
    display: none;
}

.carousel-loading {
    color: #2a9d8f;
    font-style: italic;
    margin: 1rem auto;
}

.carousel-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid #e9c46a;
    background-color: #ffffff;
    color: #264653;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.carousel-btn:hover {
    background-color: #e9c46a;
    transform: scale(1.08);
}

.article-card {
    scroll-snap-align: start;
    flex: 0 0 230px;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    border-radius: 10px;
    border: 1px solid #eee6d8;
    box-shadow: 0 3px 8px rgba(38, 70, 83, 0.08);
    text-decoration: none;
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.article-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 18px rgba(38, 70, 83, 0.15);
    color: inherit;
}

.article-thumb {
    height: 140px;
    background-color: #f4efe4;
    overflow: hidden;
}

.article-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.article-thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 1.1rem;
    background: #264653;
    border-bottom: 1px solid #eee6d6;
}

.article-thumb-placeholder span {
    font-size: 1.05rem;
    line-height: 1.4;
    font-weight: 600;
    color: #faf9f6;
    font-family: Georgia, 'Times New Roman', serif;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-card-body {
    padding: 0.85rem 1rem 1rem;
}

.article-card-body h4 {
    font-size: 0.98rem;
    color: #264653;
    line-height: 1.35;
    margin-bottom: 0.4rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-card-body .article-date {
    font-size: 0.8rem;
    color: #2a9d8f;
    margin: 0;
}

/* Article Reader Page */
.article-page {
    max-width: 720px;
    margin: 58px auto 0;
    padding: 3rem 2rem;
}

.article-back {
    display: inline-block;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.article-page h1 {
    border-bottom: none;
    margin-bottom: 0.4rem;
    padding-bottom: 0;
}

.article-meta {
    color: #2a9d8f;
    font-size: 0.95rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e9c46a;
}

.article-content h3,
.article-content h4 {
    margin-top: 2rem;
    color: #264653;
}

.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1rem 0;
}

.article-content blockquote {
    border-left: 4px solid #e9c46a;
    padding-left: 1rem;
    margin: 1.5rem 0;
    color: #2a9d8f;
    font-style: italic;
}

.article-content ul,
.article-content ol {
    margin: 0 0 1rem 1.5rem;
}

.article-content li {
    margin-bottom: 0.5rem;
}

.article-content figcaption {
    text-align: center;
    font-size: 0.85rem;
    color: #2a9d8f;
    margin-top: -0.5rem;
    margin-bottom: 1rem;
}

.article-original {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid #e9c46a;
    font-size: 0.9rem;
    color: #2a9d8f;
}

/* ================================================================
   Expressive detail animations
   ================================================================ */

/* Content reveal: blocks drift up as they enter the viewport.
   The .reveal class is added by JS, so no-JS visitors see everything. */
.reveal {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal.visible {
    opacity: 1;
    transform: none;
}

/* Article cards cascade in as they load */
.article-card {
    opacity: 0;
    animation: cardIn 0.55s ease-out forwards;
    animation-delay: calc(var(--i, 0) * 90ms);
}

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

/* PCB: signal pulses ride the traces, LED heartbeat on the chip */
.pcb-pulse {
    opacity: 0;
}

.year-animation.animate .pcb-pulse-1 {
    animation: pulseAcross 2.2s linear infinite;
    animation-delay: 3s;
}

.year-animation.animate .pcb-pulse-2 {
    animation: pulseDown 2.2s linear infinite;
    animation-delay: 3.9s;
}

@keyframes pulseAcross {
    0% {
        opacity: 0;
        transform: translateX(0);
    }
    8% {
        opacity: 1;
    }
    48% {
        opacity: 1;
        transform: translateX(36px);
    }
    56%, 100% {
        opacity: 0;
        transform: translateX(40px);
    }
}

@keyframes pulseDown {
    0% {
        opacity: 0;
        transform: translateY(0);
    }
    8% {
        opacity: 1;
    }
    48% {
        opacity: 1;
        transform: translateY(36px);
    }
    56%, 100% {
        opacity: 0;
        transform: translateY(40px);
    }
}

.pcb-led {
    opacity: 0;
}

.year-animation.animate .pcb-led {
    animation: ledBlink 1.6s ease-in-out infinite;
    animation-delay: 3s;
}

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

/* EEG: a signal dot rides along the brainwave */
.eeg-dot {
    opacity: 0;
}

@supports (offset-path: path("M 0 0 L 10 10")) {
    .year-animation.animate .eeg-dot {
        offset-path: path("M 15 40 L 20 40 L 23 32 L 26 48 L 29 25 L 32 55 L 35 38 L 38 42 L 42 40 L 45 35 L 48 45 L 51 30 L 54 50 L 57 40 L 60 37 L 65 40 L 68 33 L 71 47 L 74 28 L 77 52 L 80 40 L 85 40 L 88 36 L 91 44 L 95 40 L 100 40 L 103 35 L 106 45");
        offset-rotate: 0deg;
        animation: eegRide 4.5s linear infinite;
        animation-delay: 3.2s;
    }
}

@keyframes eegRide {
    0% {
        offset-distance: 0%;
        opacity: 0;
    }
    6% {
        opacity: 1;
    }
    88% {
        opacity: 1;
    }
    100% {
        offset-distance: 100%;
        opacity: 0;
    }
}

/* Writing: a pen sweeps across the page as the lines appear */
.writing-pen {
    opacity: 0;
}

.writing-animation.animate .writing-pen {
    animation:
        penFadeIn 0.3s ease-out 0.95s forwards,
        penWrite 1.7s ease-in-out 1s forwards,
        penIdle 3.2s ease-in-out 3.2s infinite;
}

@keyframes penFadeIn {
    to {
        opacity: 1;
    }
}

@keyframes penWrite {
    0% {
        transform: translate(22px, 22px);
    }
    13% {
        transform: translate(55px, 22px);
    }
    17% {
        transform: translate(22px, 30px);
    }
    30% {
        transform: translate(50px, 30px);
    }
    34% {
        transform: translate(22px, 38px);
    }
    47% {
        transform: translate(58px, 38px);
    }
    51% {
        transform: translate(22px, 46px);
    }
    64% {
        transform: translate(48px, 46px);
    }
    68% {
        transform: translate(22px, 54px);
    }
    81% {
        transform: translate(53px, 54px);
    }
    85% {
        transform: translate(22px, 62px);
    }
    98% {
        transform: translate(45px, 62px);
    }
    100% {
        transform: translate(47px, 61px);
    }
}

@keyframes penIdle {
    0%, 100% {
        transform: translate(47px, 61px) rotate(0deg);
    }
    50% {
        transform: translate(47px, 59.5px) rotate(-4deg);
    }
}

/* Classes: graduation cap lands on the stack, tassel swings */
.grad-cap {
    opacity: 0;
    transform: translateY(-26px);
    transform-box: fill-box;
    transform-origin: center;
}

.classes-animation.animate .grad-cap {
    animation:
        capDrop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) 2.2s forwards,
        capSway 4s ease-in-out 3.2s infinite;
}

@keyframes capDrop {
    0% {
        opacity: 0;
        transform: translateY(-26px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes capSway {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-1.5px) rotate(2deg);
    }
}

.grad-tassel {
    transform-box: fill-box;
    transform-origin: top left;
}

.classes-animation.animate .grad-tassel {
    animation: tasselSwing 2.5s ease-in-out 3s infinite;
}

@keyframes tasselSwing {
    0%, 100% {
        transform: rotate(0deg);
    }
    50% {
        transform: rotate(12deg);
    }
}

/* Hobbies: splash droplets kick up as the ball bobs */
.splash {
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
}

.hobbies-animation.animate .splash-1 {
    animation: splashUp 2.6s ease-out infinite;
    animation-delay: 2.4s;
}

.hobbies-animation.animate .splash-2 {
    animation: splashUp 2.6s ease-out infinite;
    animation-delay: 2.55s;
}

.hobbies-animation.animate .splash-3 {
    animation: splashUp 2.6s ease-out infinite;
    animation-delay: 2.7s;
}

@keyframes splashUp {
    0%, 55% {
        opacity: 0;
        transform: translateY(0) scale(0.6);
    }
    68% {
        opacity: 0.9;
        transform: translateY(-7px) scale(1);
    }
    82%, 100% {
        opacity: 0;
        transform: translateY(-11px) scale(1.1);
    }
}

/* Projects: a glint sweeps across the lens while it searches */
.mag-glint {
    opacity: 0;
}

.projects-animation.animate .mag-glint {
    animation: glintSweep 4s ease-in-out infinite;
    animation-delay: 3.5s;
}

@keyframes glintSweep {
    0%, 18% {
        opacity: 0;
        transform: translate(-16px, 16px);
    }
    30% {
        opacity: 0.85;
    }
    42%, 100% {
        opacity: 0;
        transform: translate(16px, -16px);
    }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0ms !important;
    }

    .reveal {
        opacity: 1;
        transform: none;
    }

    html {
        scroll-behavior: auto;
    }
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    background-color: #ffffff;
    border-top: 1px solid #e9c46a;
    margin-top: 4rem;
}

footer p {
    margin: 0;
    color: #264653;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    #topnav {
        padding: 0.6rem 1rem;
        gap: 0.5rem;
    }

    .nav-name {
        font-size: 0.95rem;
    }

    .nav-links {
        gap: 0.85rem;
    }

    .nav-link {
        font-size: 0.78rem;
    }

    main {
        margin-top: 52px;
        padding: 1.5rem 1rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    .year-block {
        padding: 1rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .year-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .projects-animation,
    .writing-animation,
    .classes-animation,
    .hobbies-animation,
    .year-animation {
        width: 70px;
        height: 70px;
    }

    .email-decoration {
        width: 50px;
        height: 50px;
    }

    .article-card {
        flex: 0 0 200px;
    }

    .carousel-btn {
        display: none;
    }

    .article-page {
        margin-top: 52px;
        padding: 2rem 1.25rem;
    }
}
