:root {
    color-scheme: dark;

    /* Neutrals */
    --page-bg: #1a1a2e;
    --border: #3a3a5c;

    /* Text */
    --text: #e0e0e8;
    --text-desc: #aaaac0;
    --text-muted: #5a5a78;

    /* Accents */
    --sakura: #d92d6a;
    --sakura-dark: #a3204f;
    /* sakura tuned for small text on card backgrounds (4.5:1+) */
    --sakura-text: #ff7aa8;

    --btn-bg: #363660;
    --btn-shadow: #2c2c50;
}

[data-theme="light"] {
    color-scheme: light;

    --page-bg: #f4f2ef;
    --border: #d0d0d8;

    --text: #1a1a2e;
    --text-desc: #4a4a60;
    --text-muted: #8a8aa0;

    --sakura-text: #a3204f;

    --btn-bg: #e0deda;
    --btn-shadow: #c8c4be;
}

html {
    scroll-behavior: smooth;
}

/* visually hidden but available to screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.skip-link,
.skip-link:visited {
    position: absolute;
    left: 1rem;
    top: -4rem;
    z-index: 10;
    padding: .5rem 1rem;
    border-radius: 0 0 8px 8px;
    background: var(--sakura);
    color: #fff;
    transition: top .2s;
}
.skip-link:focus {
    top: 0;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 3px;
}

body {
    max-width: 75em;
    margin: 0 auto;
    padding: 0 2rem;
    font-family: "Outfit", sans-serif;
    color: var(--text);
    background-color: var(--page-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* scoped to the top bar: case-study pages have a second <nav> (the
   prev/next pager) that must not inherit these */
body > nav {
    font-size: 1.25rem;
    font-weight: 400;
    display: flex;
    align-items: center;
    padding: 1.5rem 0;
    gap: 2rem;
}

body > nav a:first-child {
    font-weight: 500;
    font-size: 1.75rem;
    margin-right: auto;
}

.hero {
    min-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    text-align: center;
}

.hero h1 {
    font-size: clamp(3rem, 9vw, 6rem);
    line-height: 1.1;
    margin: 0 0 0 0;
    font-weight: 500;
}

.typewriter {
    margin: 2.5rem 0;
    color: var(--text-desc);
    font-size: clamp(1.4rem, 4vw, 2rem);
}

.typewriter p {
    margin: 0;
}

.typewriter-text {
    border-right: 2px solid var(--sakura);
    padding-right: .2rem;
    animation: caret-blink 1.1s steps(2) infinite;
}

@keyframes caret-blink {
    50% { border-color: transparent; }
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

h2 {
    text-align: center;
    font-size: 3rem;
    font-weight: 500;
}
h3 {
    text-align: center;
    font-size: 1.25rem;
    font-weight: 500;
    margin: 0;
}

.aboutbody {
    display: flex;
    flex-direction: row;
    gap: 2rem
}

.aboutimg {
    flex: 1;
    min-width: 0;
    width: 100%;
    object-fit: cover;
    border-radius: 24px;
}

.aboutcontent {
    flex: 2;
    margin: 1rem;
}

.card p {
    line-height: 1.5rem;
    margin: 0;
    color: var(--text-desc);
}
.card img {
    height: 2rem;
}

.cards {
    display: flex;
    flex-direction: row;
    gap: 3rem;
}
.card {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: .5rem;
    padding: 1.25rem;
    border-radius: 24px;
    text-align: center;
    border: 1px solid var(--text-desc);
    justify-content: center;
}

.aboutdesc {
    font-size: 1.5rem;
    line-height: 2rem;
    font-weight: 200;
    color: var(--text-desc);
}

.hero-name {
    position: relative;
}

.avatar {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 5rem;
    animation: bug-walk 6s linear infinite;
}

.avatar img {
    display: block;
    /* dark is the default theme, so the inverted look is the base state.
       smoothly cross-fade the filter when the user toggles themes. */
    transition: filter .3s ease;
    filter: invert(1) hue-rotate(180deg);
    width: 5rem;
}

/* light mode uses the original, un-inverted gif */
[data-theme="light"] .avatar img {
    filter: none;
}

@keyframes bug-walk {
    0%   { left: 0%;                transform: scaleX(-1);  }
    49%  { left: calc(100% - 5rem); transform: scaleX(-1);  }
    50%  { left: calc(100% - 5rem); transform: scaleX(1); }
    100% { left: 0%;                transform: scaleX(1); }
}

.skillcontent {
    display: grid;
    grid-template-columns: repeat(auto-fill, 8.5rem);
    justify-content: center;
    gap: 1rem;
}

.skillitem p {
    margin: 0;
    font-size: .8rem;
    font-weight: 300;
    padding-top: .25rem;
    color: var(--text-desc);
}
.skillitem .skillname {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text);
    padding-top: 0;
}

.skillitem {
    border: 1px solid var(--btn-shadow);
    border-radius: 24px;
    background-color: var(--btn-bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    aspect-ratio: 1/1;
}

.skillitem img {
    height: 3.25rem;
    padding-bottom: .6rem;
}

/* projects */
.projectsbody {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.project-card {
    border: 1px solid var(--btn-shadow);
    border-radius: 24px;
    background-color: var(--btn-bg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    color: var(--text);
    text-decoration: none;
    box-shadow: 0 4px 0 var(--btn-shadow);
    transform: translateY(0);
    transition: transform 0.1s, box-shadow 0.1s;
}

.project-card.flagship {
    grid-column: 1 / -1;
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 0 var(--btn-shadow);
}

/* press affordance only when cards are real links (case study pages) */
a.project-card {
    cursor: pointer;
}

a.project-card:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 var(--btn-shadow);
}

.project-media {
    position: relative;
    height: 18rem;
    flex-shrink: 0;
    background-color: var(--page-bg);
    overflow: hidden;
}

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

.project-num,
.project-flag {
    position: absolute;
    top: 1rem;
    background-color: var(--page-bg);
    color: var(--text);
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    padding: .4rem .9rem;
    letter-spacing: .05em;
    z-index: 1;
}

.project-num {
    left: 1rem;
}

.project-flag {
    right: 1rem;
    letter-spacing: .12em;
}

.project-info {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.project-info h3 {
    text-align: left;
    font-size: 1.35rem;
}

.project-info > p {
    margin: 0;
    color: var(--text-desc);
    font-weight: 300;
    line-height: 1.5;
}

.project-tags {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: .5rem;
}

.project-tag {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: .3rem .8rem;
    font-size: .7rem;
    font-weight: 500;
    letter-spacing: .12em;
    color: var(--text-desc);
}

/* contact */
.contact-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.contact-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--btn-shadow);
    border-radius: 24px;
    background-color: var(--btn-bg);
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 4px 0 var(--btn-shadow);
    transform: translateY(0);
    transition: transform 0.1s, box-shadow 0.1s;
}

.contact-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 0 var(--btn-shadow);
}

.contact-card:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 var(--btn-shadow);
}

.contact-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.contact-label {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 500;
    line-height: 1.3;
}

.contact-value {
    margin: 0;
    font-size: .8rem;
    font-weight: 300;
    color: var(--text-desc);
    overflow-wrap: anywhere;
}

/* timeline */
.timeline {
    display: flex;
    flex-direction: column;
    padding-left: 2rem;
    gap: 2rem;
}

.timeline-entry {
    display: flex;
    align-items: center;
    gap: 2rem;
    position: relative;
}

/* line segment */
.timeline-entry::after {
    content: "";
    position: absolute;
    left: -2rem;
    top: 0;
    bottom: -2rem;
    width: 1px;
    background: var(--text-desc);
    transform: translateX(-50%);
}

.timeline-entry:first-child::after {
    top: 50%;
}

.timeline-entry:last-child::after {
    bottom: 50%;
}

/* dot */
.timeline-entry::before {
    content: "";
    position: absolute;
    left: -2rem;
    top: 50%;
    transform: translate(-50%, -50%);
    width: .6rem;
    height: .6rem;
    border-radius: 50%;
    border: 2px solid var(--sakura);
    background-color: var(--page-bg);
    z-index: 1;
}

.timeline-entry:first-child::before {
    background-color: var(--sakura);
}

.timeline-date {
    min-width: 8rem;
    font-size: 1rem;
    font-weight: 300;
    color: var(--text-desc);
}

.timeline-card {
    flex: 1;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 16px;
    background-color: var(--btn-bg);
}

.timeline-org {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .1em;
    color: var(--sakura-text);
    margin: 0 0 .25rem;
}

.timeline-card h3 {
    text-align: left;
    margin: 0 0 .25rem;
}

.timeline-card p:last-child {
    margin: 0;
    color: var(--text-desc);
    font-weight: 300;
}

main {
    display: flex;
    flex-direction: column;
    gap: 6rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 10rem;
    padding: .7rem 1.4rem;
    background: var(--btn-bg);
    border: 1px solid var(--btn-shadow);
    border-radius: 12px;
    font-size: 1.35rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    box-shadow: 0 4px 0 var(--btn-shadow);
    transform: translateY(0);
    transition: transform 0.1s, box-shadow 0.1s;
    text-decoration: none;
    line-height: 1.2;
}

.btn:hover { transform: translateY(-4px); box-shadow: 0 8px 0 var(--btn-shadow); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--btn-shadow); }

.btn.primary {
    background: var(--sakura);
    border-color: var(--sakura-dark);
    box-shadow: 0 4px 0 var(--sakura-dark);
    color: #fff;
}
.btn.primary:hover { box-shadow: 0 8px 0 var(--sakura-dark); }
.btn.primary:active { box-shadow: 0 1px 0 var(--sakura-dark); }

/* icon styling */
.icons {
    display: flex;
    column-gap: 1.5rem;
}
.icon {
    width: 2rem;
    height: 2rem;
    padding: .75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    border-radius: 50%;
    background-color: var(--btn-bg);
    /* ring drawn with box-shadow so outline stays free for keyboard focus */
    --ring-gap: var(--page-bg);
    box-shadow: 0 0 0 2px var(--btn-shadow);
    transition-property: box-shadow, background-color;
    transition-duration: .25s;
}

.contact-card .icon {
    --ring-gap: var(--btn-bg);
}

/* the icon SVGs hardcode a near-white fill — darken them on light backgrounds,
   and restore white on hover when the background becomes a brand colour */
[data-theme="light"] .icon img {
    filter: invert(.85);
}
[data-theme="light"] .icon:hover img,
[data-theme="light"] .contact-card:hover .icon img {
    filter: none;
}

.icon:hover,
.contact-card:hover .icon {
    animation: shake .75s;
}

.icon--instagram:hover,
.contact-card:hover .icon--instagram {
    background-image: radial-gradient(circle at 30% 107%,
    #fdf497 0%, #fdf497 5%,
    #fd5949 45%, #d6249f 60%,
    #285AEB 90%);
    box-shadow: 0 0 0 2px var(--ring-gap), 0 0 0 4px #a02d76;
}
.icon--linkedin:hover,
.contact-card:hover .icon--linkedin {
    background-color: #0077b5;
    box-shadow: 0 0 0 2px var(--ring-gap), 0 0 0 4px #0077b5;
}
.icon--github:hover,
.contact-card:hover .icon--github {
    background-color: #2ea44f;
    box-shadow: 0 0 0 2px var(--ring-gap), 0 0 0 4px #2ea44f;
}
.icon--email:hover,
.contact-card:hover .icon--email {
    background-color: var(--sakura);
    box-shadow: 0 0 0 2px var(--ring-gap), 0 0 0 4px var(--sakura-dark);
}

@keyframes shake {
    10% { transform: rotate(10deg); }
    20% { transform: rotate(-10deg); }
    30% { transform: rotate(10deg); }
    40% { transform: rotate(-10deg); }
}

footer {
    margin-top: auto;
    font-size: 1rem;
    font-weight: 200;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
}

#theme-toggle {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: .5rem;
    display: flex;
    align-items: center;
    transition: color .25s;
}
#theme-toggle:hover { color: var(--sakura); }

[data-theme="light"] .icon-sun,
.icon-moon { display: none; }

[data-theme="light"] .icon-moon { display: block; }

a {
    color: var(--text);
    text-decoration: none;
}
a:visited {
    color: var(--text);
    text-decoration: none;
}

/* ===== responsive ===== */

/* tablet / small laptop */
@media (max-width: 64em) {
    .projectsbody {
        grid-template-columns: repeat(2, 1fr);
    }

    .contact-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* tablet portrait / large phone */
@media (max-width: 48em) {
    body > nav {
        flex-wrap: wrap;
        gap: 1rem 1.5rem;
        font-size: 1.1rem;
    }

    h2 {
        font-size: 2.25rem;
    }

    main {
        gap: 4rem;
    }

    .hero h1 {
        margin-top: 0rem;
    }

    .aboutbody {
        flex-direction: column;
    }

    .aboutimg {
        max-width: 24rem;
        margin: 0 auto;
    }

    .aboutcontent {
        margin: 1rem 0 0 0;
    }

    .aboutdesc {
        font-size: 1.25rem;
        line-height: 1.6;
    }

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

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

    .timeline-entry {
        flex-direction: column;
        align-items: flex-start;
        gap: .5rem;
    }

    /* anchor the dot and line endpoints to the date row instead of entry centre */
    .timeline-entry::before {
        top: .8rem;
    }

    .timeline-entry:first-child::after {
        top: .8rem;
    }

    .timeline-entry:last-child::after {
        bottom: auto;
        top: 0;
        height: .8rem;
    }
}

/* phone */
@media (max-width: 30em) {
    body {
        padding: 0 1.25rem;
    }

    .cards {
        flex-direction: column;
        gap: 1rem;
    }

    .hero-actions {
        flex-direction: column;
        width: min(100%, 18rem);
    }

    .btn {
        width: 100%;
    }

    .project-media {
        height: 14rem;
    }

    footer {
        flex-direction: column;
        gap: .25rem;
        text-align: center;
    }
}

/* respect users who turn animations off */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }

    .typewriter-text {
        border-right-color: var(--sakura);
    }
}