:root {
    --background-color: #f4f4f4;
    --text-color: #111;
    --muted-color: #6b6b6b;
    --border-color: #8c8c8c;
    --surface-color: #fff;
    --shadow-color: rgba(0, 0, 0, 0.12);
    --logo-font: "Galada", cursive;
    --heading-font: "Space Grotesk", sans-serif;
    --text-font: "Inter", sans-serif;
    --caption-font: "Space Mono", monospace;
    --nav-height: 4rem;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --background-color: #11131a;
    --text-color: #f4f3ef;
    --muted-color: #a7adbd;
    --border-color: #50576a;
    --surface-color: #1b1f2a;
    --shadow-color: rgba(0, 0, 0, 0.35);
}

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

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

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--text-font);
    color: var(--text-color);
    background-color: var(--background-color);
    line-height: 1.6;
    transition: color 0.25s ease, background-color 0.25s ease;
}

img {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
    text-decoration: none;
}

ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

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

/* centers content and keeps side spacing on small screens */
.container {
    width: min(100% - 2rem, 1200px);
    margin-inline: auto;
}

/* ---------- scroll progress + skip link ---------- */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 20;
    background: var(--text-color);
    transform: scaleX(0);
    transform-origin: left;
}

@media (hover: hover) and (pointer: fine) {
    html,
    html * {
        cursor: url("assets/images/bug-cursor.svg") 16 7, auto !important;
    }
}

.skip-link {
    position: absolute;
    left: 1rem;
    top: -4rem;
    z-index: 200;
    padding: 0.6rem 1rem;
    background: var(--text-color);
    color: var(--background-color);
    border-radius: 8px;
}

.skip-link:focus {
    top: 1rem;
}

/* ---------- nav ---------- */
.nav {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--background-color);
    border-bottom: 1px dashed var(--muted-color);
}

.nav__inner {
    display: flex;
    gap: clamp(0.75rem, 2vw, 1.5rem);
    align-items: center;
    min-height: var(--nav-height);
}

.nav__logo {
    position: relative;
    display: inline-block;
    font-family: var(--logo-font);
    font-size: 1.5rem;
    transform-origin: left center;
    transition: transform 0.25s ease;
    animation: nav-logo-enter 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.nav__logo::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0.1rem;
    left: 0;
    height: 2px;
    background: currentColor;
    border-radius: 999px;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.nav__logo:hover,
.nav__logo:focus-visible {
    transform: translateY(-2px);
}

.nav__logo:hover::after,
.nav__logo:focus-visible::after {
    transform: scaleX(1);
}

@keyframes nav-logo-enter {
    from {
        opacity: 0;
        filter: blur(5px);
        clip-path: inset(0 100% 0 0);
    }

    to {
        opacity: 1;
        filter: blur(0);
        clip-path: inset(0);
    }
}

.nav__toggle {
    display: none;
    align-items: center;
    gap: 0.55rem;
    min-height: 44px;
    padding: 0.45rem 0.7rem;
    color: var(--text-color);
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font: 0.75rem var(--caption-font);
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s, border-color 0.2s;
}

.theme-toggle {
    display: none;
    align-items: center;
    gap: 0.45rem;
    min-height: 44px;
    padding: 0.35rem 0.65rem;
    color: var(--text-color);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    font: 0.7rem var(--caption-font);
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s, border-color 0.2s, transform 0.2s;
}

.js .theme-toggle {
    display: inline-flex;
}

.theme-toggle__icon {
    display: grid;
    place-items: center;
    width: 1rem;
    color: var(--muted-color);
    transition: color 0.2s;
}

.theme-toggle__track {
    position: relative;
    width: 2rem;
    height: 1.15rem;
    padding: 2px;
    background: var(--border-color);
    border-radius: 999px;
    transition: background-color 0.2s;
}

.theme-toggle__thumb {
    display: block;
    width: 0.85rem;
    height: 0.85rem;
    background: var(--surface-color);
    border-radius: 50%;
    box-shadow: 0 1px 3px var(--shadow-color);
    transition: transform 0.2s ease;
}

.theme-toggle__label {
    min-width: 2.2rem;
    text-align: left;
}

:root[data-theme="dark"] .theme-toggle__thumb {
    transform: translateX(0.85rem);
}

:root[data-theme="light"] .theme-toggle__icon--light,
:root[data-theme="dark"] .theme-toggle__icon--dark {
    color: var(--text-color);
}

.nav__list {
    margin-left: auto;
}

.nav__toggle-code {
    color: var(--muted-color);
}

.nav__toggle-icon {
    display: grid;
    width: 18px;
    gap: 3px;
}

.nav__toggle-icon span {
    display: block;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: opacity 0.2s, transform 0.2s;
}

.nav__toggle-icon span:nth-child(2) {
    width: 70%;
    margin-left: auto;
}

.nav__toggle-icon span:nth-child(3) {
    width: 85%;
}

.nav__toggle[aria-expanded="true"] .nav__toggle-icon span:first-child {
    transform: translateY(5px) rotate(45deg);
}

.nav__toggle[aria-expanded="true"] .nav__toggle-icon span:nth-child(2) {
    opacity: 0;
}

.nav__toggle[aria-expanded="true"] .nav__toggle-icon span:last-child {
    width: 100%;
    transform: translateY(-5px) rotate(-45deg);
}

.nav__list {
    display: flex;
    gap: clamp(1rem, 3vw, 2.5rem);
    font-size: 0.9rem;
    letter-spacing: 0.05em;
}

.nav__list a {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    transition: color 0.2s;
}

.nav__list a::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 8px;
    height: 1px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s ease;
}

.nav__list a.is-active::after {
    transform: scaleX(1);
}

/* ---------- hero ---------- */
.hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: clamp(2rem, 5vw, 5rem);
    padding-block: clamp(2rem, 8vw, 6rem);
}

.hero__text {
    flex: 1 1 0;
    min-width: 0;
}

.hero__heading {
    font-family: var(--heading-font);
    font-size: clamp(2rem, 5vw, 3.5rem);
    line-height: 1.15;
    margin: 0 0 1rem;
}

.hero__heading span:not([aria-hidden]) {
    color: var(--muted-color);
}

.grey__color {
    color: var(--muted-color);
}

.hero__text-body {
    font-size: clamp(1rem, 2vw, 1.25rem);
    margin: 0 0 0.5rem;
}

.hero__affiliation {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0.75rem 0 0;
    color: var(--muted-color);
}

.hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.hero__button {
    font: inherit;
    text-align: center;
}

.hero__button--primary {
    color: var(--background-color);
    background-color: var(--text-color);
}

.hero__proof {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    margin-top: 1.25rem;
    color: var(--muted-color);
    font-size: 0.875rem;
}

.hero__proof a {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.hero__caption {
    font-family: var(--caption-font);
    font-size: 0.875rem;
    margin: 0;
}

.hero__image {
    flex: 0 1 clamp(320px, 40vw, 400px);
    min-width: 0;
}

.hero__image img {
    width: 100%;
    height: auto;
    aspect-ratio: 720 / 972;
    object-fit: cover;
    border-radius: 25px;
}

/* ---------- sections ---------- */
.section {
    padding-block: clamp(2rem, 6vw, 4rem);
    border-top: 1px dashed var(--muted-color);
    scroll-margin-top: var(--nav-height);
}

.section__title {
    font-family: var(--heading-font);
    font-size: clamp(1.5rem, 3vw, 2rem);
    margin: 0 0 1.5rem;
}

.section__text {
    max-width: 60ch;
    margin: 0 0 1.5rem;
}

/* ---------- projects ---------- */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: 1.5rem;
}

.project-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    transition: border-color 0.2s, transform 0.25s ease, box-shadow 0.25s ease;
}

.project-card__title {
    font-family: var(--heading-font);
    font-size: 1.25rem;
    margin: 0;
}

.project-card__text {
    margin: 0;
    font-size: 0.95rem;
}

.project-card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-family: var(--caption-font);
    font-size: 0.75rem;
}

.project-card__tags li {
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
}

.project-card__links {
    display: flex;
    gap: 1rem;
    margin-top: auto; /* pins links to the bottom so cards line up */
    font-size: 0.9rem;
}

.project-card__links a {
    padding-block: 0.6rem;
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* ---------- skills ---------- */
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-family: var(--caption-font);
    font-size: 0.875rem;
}

.tag-list li {
    padding: 0.4rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    transition: border-color 0.2s;
}

/* ---------- certifications ---------- */
.badge-list {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1.5rem;
}

/* ---------- button ---------- */
.button {
    display: inline-block;
    min-height: 44px;
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--text-color);
    border-radius: 999px;
    transition: background-color 0.2s, color 0.2s;
}

.ambient-toggle {
    display: none;
    position: fixed;
    right: max(1rem, env(safe-area-inset-right));
    bottom: max(1rem, env(safe-area-inset-bottom));
    z-index: 15;
    align-items: center;
    gap: 0.6rem;
    min-height: 44px;
    padding: 0.65rem 1rem;
    color: var(--text-color);
    background-color: var(--background-color);
    border: 1px solid var(--text-color);
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    font: 0.75rem var(--caption-font);
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s, transform 0.2s;
}

.js .ambient-toggle {
    display: inline-flex;
}

.ambient-toggle[aria-pressed="true"] {
    color: var(--background-color);
    background-color: var(--text-color);
}

.ambient-toggle:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

/* ---------- contact form ---------- */
.contact-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 60ch;
    margin-top: 2rem;
}

.contact-form__label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-family: var(--caption-font);
    font-size: 0.875rem;
}

.contact-form__field {
    width: 100%;
    padding: 0.75rem 1rem;
    font: inherit;
    font-size: 1rem; /* 16px stops iOS zoom on focus */
    color: inherit;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    transition: border-color 0.2s;
}

.contact-form__field:focus-visible {
    border-color: var(--text-color);
}

.contact-form__field:user-invalid {
    border-color: #c0392b;
}

.contact-form__field--message {
    min-height: 8rem;
    resize: vertical;
}

.contact-form__submit {
    align-self: flex-start;
    font: inherit;
    color: inherit;
    background: transparent;
    cursor: pointer;
}

.contact-form__submit:disabled {
    opacity: 0.6;
    cursor: progress;
}

.contact-form__status {
    margin: 0;
    min-height: 1.5em;
    font-family: var(--caption-font);
    font-size: 0.875rem;
}

/* ---------- footer ---------- */
.footer {
    padding-block: 2rem;
    border-top: 1px dashed var(--muted-color);
    font-family: var(--caption-font);
    font-size: 0.875rem;
    color: var(--muted-color);
}

.footer p {
    margin: 0;
}

/* ---------- scroll reveal ---------- */
.js .reveal {
    opacity: 1;
    transform: translateY(24px);
    transition: opacity 0.6s ease var(--d, 0s), transform 0.6s ease var(--d, 0s);
}

.js .reveal.is-visible {
    opacity: 1;
    transform: none;
}

/* ---------- hover styles (mouse devices only) ---------- */
@media (hover: hover) {
    .nav__list a:hover {
        color: var(--muted-color);
    }

    .nav__toggle:hover {
        color: var(--background-color);
        background-color: var(--text-color);
        border-color: var(--text-color);
    }

    .theme-toggle:hover {
        border-color: var(--text-color);
        transform: translateY(-1px);
    }

    .theme-toggle:hover .theme-toggle__track {
        background-color: var(--text-color);
    }

    .nav__toggle:hover .nav__toggle-code {
        color: inherit;
    }

    .nav__list a:hover::after {
        transform: scaleX(1);
    }

    .project-card:hover {
        border-color: var(--text-color);
        transform: translateY(-4px);
        box-shadow: 0 12px 24px var(--shadow-color);
    }

    .project-card__links a:hover {
        color: var(--muted-color);
    }

    .tag-list li:hover {
        border-color: var(--text-color);
    }

    .button:hover,
    .contact-form__submit:hover:not(:disabled),
    .ambient-toggle:hover:not(:disabled) {
        background-color: var(--text-color);
        color: var(--background-color);
    }

    .ambient-toggle:hover:not(:disabled) {
        transform: translateY(-2px);
    }

    .hero__button--primary:hover {
        background-color: transparent;
        color: var(--text-color);
    }

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

    .contact-form__field:hover {
        border-color: var(--text-color);
    }
}

/* ---------- tablet / mobile ---------- */
@media (max-width: 768px) {
    .hero {
        flex-direction: column;
        align-items: stretch;
    }

    .hero__image {
        flex: none; /* reset, otherwise 400px would apply to height in column mode */
        width: 100%;
        max-width: clamp(300px, 70vw, 400px);
        margin-inline: auto;
    }
}

@media (min-width: 769px) and (max-width: 900px) {
    .hero__heading {
        font-size: clamp(2rem, 4vw, 2.4rem);
    }
}

/* ---------- small phones ---------- */
@media (max-width: 480px) {
    .nav__list {
        gap: 0.9rem;
        font-size: 0.8rem;
    }

    .theme-toggle {
        gap: 0.3rem;
        padding-inline: 0.45rem;
    }

    .theme-toggle__label {
        display: none;
    }

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

    .hero__button {
        padding-inline: 0.75rem;
    }

    .hero {
        padding-block: 1.5rem;
    }

    .project-card {
        padding: 1.1rem;
    }
}

@media (max-width: 360px) {
    .nav__inner {
        gap: 0.5rem;
    }

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

    .nav__logo {
        font-size: 1.1rem;
    }

    .nav__list {
        gap: 0.4rem;
        font-size: 0.7rem;
    }

    .theme-toggle {
        gap: 0.2rem;
        padding-inline: 0.35rem;
    }
}

@media (max-width: 768px) {
    .nav__inner {
        position: relative;
    }

    .nav__list {
        margin-left: 0;
    }

    .js .nav__toggle {
        display: inline-flex;
    }

    .js .nav__list {
        position: absolute;
        top: calc(100% + 0.5rem);
        right: 0;
        z-index: 11;
        display: none;
        flex-direction: column;
        gap: 0.25rem;
        width: min(16rem, 100%);
        padding: 0.75rem;
        background-color: var(--background-color);
        border: 1px solid var(--border-color);
        border-radius: 10px;
        box-shadow: 0 12px 24px var(--shadow-color);
        font-size: 0.875rem;
        letter-spacing: 0.03em;
    }

    .js .nav__list.is-open {
        display: flex;
    }

    .js .nav__list a {
        padding-inline: 0.75rem;
        border-radius: 6px;
    }

    .js .nav__list a::after {
        left: 0.75rem;
        right: 0.75rem;
    }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    * {
        transition: none !important;
        animation: none !important;
    }
}