:root {
    --bg: #e9e9e9;
    --surface: #dedede;
    --ink: #222222;
    --muted: #5f5f5f;
    --line: #cdcdcd;
    --accent: #0a72c2;
    --on-accent: #ffffff;

    --dock-bg: #5c5c5c;
    --dock-item: #6b6b6b;
    --dock-ink: #f2f2f2;
    --cta-bg: #e9e9e9;
    --cta-ink: #222222;

    --sans: 'Outfit', system-ui, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, monospace;
    --wrap: 1232px;
    --gutter: clamp(1rem, 4vw, 2.5rem);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #222222;
        --surface: #2b2b2b;
        --ink: #e9e9e9;
        --muted: #9a9a9a;
        --line: #3a3a3a;
        --accent: #4cb0ff;
        --on-accent: #0b1a26;

        --dock-bg: #2e2e2e;
        --dock-item: #383838;
        --dock-ink: #e9e9e9;
        --cta-bg: #1a1a1a;
        --cta-ink: #e9e9e9;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #222222;
    --surface: #2b2b2b;
    --ink: #e9e9e9;
    --muted: #9a9a9a;
    --line: #3a3a3a;
    --accent: #4cb0ff;
    --on-accent: #0b1a26;

    --dock-bg: #2e2e2e;
    --dock-item: #383838;
    --dock-ink: #e9e9e9;
    --cta-bg: #1a1a1a;
    --cta-ink: #e9e9e9;
    color-scheme: dark;
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 2rem;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 1.0625rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    /* Laisse la place au dock fixe en bas */
    padding-bottom: 6.5rem;
}

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

a {
    color: inherit;
}

button {
    font: inherit;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 2px;
}

::selection {
    background: var(--accent);
    color: var(--on-accent);
}

.sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.skip {
    position: absolute;
    left: var(--gutter);
    top: -3rem;
    padding: 0.5rem 0.8rem;
    background: var(--ink);
    color: var(--bg);
    z-index: 30;
}

.skip:focus {
    top: 0.75rem;
}

/* Thème + dock */

.theme-toggle {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 20;
    display: grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--bg);
    color: var(--ink);
    cursor: pointer;
}

.theme-toggle:hover {
    border-color: var(--muted);
}

.dock {
    position: fixed;
    left: 50%;
    bottom: 1.75rem;
    z-index: 20;
    transform: translateX(-50%);
    display: flex;
    align-items: stretch;
    gap: 0.375rem;
    padding: 0.375rem;
    background: var(--dock-bg);
    color: var(--dock-ink);
    border-radius: 14px;
    font-size: 0.875rem;
    max-width: calc(100vw - 2rem);
}

.dock a {
    text-decoration: none;
}

.dock-avatar img {
    width: 3.625rem;
    height: 3.625rem;
    border-radius: 9px;
    object-fit: cover;
}

.dock-links {
    display: flex;
    gap: 0.25rem;
    padding: 0.44rem 0.375rem;
    background: var(--dock-item);
    border-radius: 9px;
}

.dock-links a {
    display: grid;
    place-items: center;
    padding: 0 0.875rem;
    border-radius: 6px;
    opacity: 0.8;
}

.dock-links a:hover,
.dock-links a.is-active {
    opacity: 1;
    background: var(--dock-bg);
}

.dock-cta {
    display: grid;
    place-items: center;
    padding: 0 1rem;
    background: var(--cta-bg);
    color: var(--cta-ink);
    border-radius: 9px;
    font-weight: 600;
    white-space: nowrap;
}

/* Layout */

.hero,
.section,
.site-footer {
    max-width: calc(var(--wrap) + 2 * var(--gutter));
    margin: 0 auto;
    padding-inline: var(--gutter);
}

/* Hero : un calque sélectionné dans Figma */

.hero {
    min-height: min(100svh, 62.5rem);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: 5rem;
    padding-bottom: 7rem;
    text-align: center;
}

.hello {
    font-size: clamp(1.375rem, 3.4vw, 3rem);
    font-weight: 500;
}

.sel {
    position: relative;
    margin-top: 0.4rem;
}

.sel h1 {
    font-size: clamp(5rem, 17.8vw, 16rem);
    font-weight: 700;
    line-height: 1;
    text-transform: uppercase;
    padding: 0 0.055em;
}

.sel-frame {
    position: absolute;
    inset: -1.5px;
    border: 1.5px solid var(--accent);
    pointer-events: none;
}

.sel-frame i {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--bg);
    border: 1.5px solid var(--accent);
}

.sel-frame i:nth-child(1) { top: -5.5px; left: -5.5px; }
.sel-frame i:nth-child(2) { top: -5.5px; right: -5.5px; }
.sel-frame i:nth-child(3) { bottom: -5.5px; left: -5.5px; }
.sel-frame i:nth-child(4) { bottom: -5.5px; right: -5.5px; }

.sel-size {
    position: absolute;
    left: 50%;
    top: calc(100% + 10px);
    transform: translateX(-50%);
    padding: 0.1rem 0.4rem;
    background: var(--accent);
    color: var(--on-accent);
    border-radius: 3px;
    font-family: var(--mono);
    font-size: 0.8rem;
    white-space: nowrap;
}

.cursor {
    position: absolute;
    right: 0.5rem;
    bottom: -1.75rem;
    display: flex;
    align-items: flex-start;
    gap: 2px;
    pointer-events: none;
    /* Démarre après l'intro pour ne pas fausser la mesure de départ du curseur */
    animation: drift 7s ease-in-out 2s infinite alternate;
}

.cursor svg {
    flex: none;
    width: 20px;
    height: 28px;
    fill: var(--accent);
    stroke: var(--bg);
    stroke-width: 1.2;
}

.cursor span {
    margin-top: 20px;
    padding: 0.25rem 0.625rem;
    background: var(--accent);
    color: var(--on-accent);
    border-radius: 4px 12px 12px 12px;
    font-size: 0.875rem;
    font-weight: 600;
}

@keyframes drift {
    0% { transform: translate(0, 0); }
    50% { transform: translate(12px, -8px); }
    100% { transform: translate(-6px, 5px); }
}

.role {
    margin-top: 3.5rem;
    font-size: clamp(1.375rem, 2.8vw, 2.5rem);
    font-weight: 500;
    line-height: 1.2;
}

.lead {
    max-width: 40rem;
    margin-top: 1rem;
    font-size: clamp(1.0625rem, 1.6vw, 1.375rem);
    font-weight: 300;
    color: var(--muted);
}

.facts {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem 2.25rem;
    margin-top: 2.5rem;
    font-size: clamp(1.375rem, 2.8vw, 2.5rem);
    font-weight: 500;
    line-height: 1.2;
}

.facts li + li::before {
    content: "/";
    margin-right: 2.25rem;
    color: var(--line);
}

.facts strong {
    font-weight: 500;
    color: var(--accent);
}

/* Sections */

.section {
    padding-top: clamp(5rem, 14vh, 8.75rem);
}

.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
    position: relative;
    padding-bottom: 1.25rem;
    margin-bottom: 3rem;
}

/* Pseudo-élément plutôt que border pour pouvoir dessiner la ligne au défilement */
.section-head::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: var(--line);
    transform-origin: left;
    transition: scale 1.1s cubic-bezier(0.65, 0, 0.35, 1) 0.15s;
}

.section-head h2 {
    display: flex;
    align-items: baseline;
    gap: 1.125rem;
    font-size: clamp(2.25rem, 5vw, 3.5rem);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.section-index,
.section-info,
.work-num,
.stack dt,
.copy {
    font-family: var(--mono);
    font-size: 0.8rem;
    font-weight: 400;
    letter-spacing: 0.02em;
}

.section-index {
    color: var(--accent);
}

.section-info {
    color: var(--muted);
}

/* Projets */

.work {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3.5rem 2rem;
}

.work-item--wide {
    grid-column: 1 / -1;
}

.work-item img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
}

.work-item figcaption {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 0.875rem;
    margin-top: 1.125rem;
}

.work-num {
    grid-row: span 2;
    padding-top: 0.45rem;
    color: var(--muted);
}

.work-item h3 {
    font-size: 1.375rem;
    font-weight: 600;
    line-height: 1.4;
}

.work-item p {
    color: var(--muted);
}

/* Profil */

.profile {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 28.75rem;
    gap: 2.5rem 5rem;
}

.profile-text p {
    font-size: clamp(1.25rem, 2vw, 1.625rem);
    line-height: 1.45;
}

.profile-text p + p {
    margin-top: 1.5rem;
    color: var(--muted);
}

.stack div {
    display: grid;
    grid-template-columns: 5.25rem 1fr;
    gap: 1rem;
    padding: 1rem 0;
    border-top: 1px solid var(--line);
}

.stack div:last-child {
    border-bottom: 1px solid var(--line);
}

.stack dt {
    color: var(--muted);
    padding-top: 0.2rem;
}

.stack dd {
    font-size: 1.125rem;
}

.quote {
    margin-top: 6rem;
    padding: 0.5rem 0 0.5rem 2rem;
    border-left: 3px solid var(--accent);
}

.quote p {
    font-size: clamp(1.75rem, 3.6vw, 2.75rem);
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.015em;
}

.quote figcaption {
    margin-top: 1rem;
    color: var(--muted);
    font-size: 1.125rem;
}

/* Contact */

.contact {
    padding-bottom: clamp(5rem, 14vh, 8.75rem);
}

.contact-lead {
    color: var(--muted);
    font-size: clamp(1.0625rem, 1.6vw, 1.375rem);
    font-weight: 300;
}

.contact-mail {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
    margin-top: 1.5rem;
}

.contact-mail a {
    font-size: clamp(1.875rem, 5.5vw, 4rem);
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1.1;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.contact-mail a:hover {
    color: var(--accent);
}

.copy {
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: none;
    color: var(--muted);
    cursor: pointer;
}

.copy:hover {
    color: var(--ink);
    border-color: var(--muted);
}

.socials {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 2.5rem;
}

.socials a {
    display: inline-block;
    padding: 0.625rem 1.125rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    text-decoration: none;
}

.socials a span {
    color: var(--muted);
}

.socials a:hover {
    border-color: var(--muted);
}

/* Footer */

.site-footer {
    display: flex;
    justify-content: space-between;
    padding-bottom: 2.5rem;
    font-size: 0.875rem;
    color: var(--muted);
}

.site-footer > * {
    padding-top: 1.5rem;
    border-top: 1px solid var(--line);
    flex: 1;
}

.site-footer > a {
    text-align: right;
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--ink);
}

/* Animations */

@keyframes rise {
    from { opacity: 0; translate: 0 1.5rem; }
}

@keyframes dock-in {
    from { opacity: 0; translate: 0 150%; }
}

@keyframes pop {
    50% { scale: 1.08; }
}

.hello,
.sel h1,
.role,
.lead,
.facts {
    animation: rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.sel h1 { animation-delay: 0.1s; }
.role { animation-delay: 0.7s; }
.lead { animation-delay: 0.8s; }
.facts { animation-delay: 0.9s; }

/* Cachés le temps que les polices chargent, puis animés en JS */
.sel.is-intro .sel-frame,
.sel.is-intro .cursor {
    visibility: hidden;
}

.dock {
    animation: dock-in 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) 1.1s both;
}

.theme-toggle {
    animation: rise 0.6s ease-out 1.2s both;
    transition: border-color 0.2s, scale 0.15s;
}

.theme-toggle:active {
    scale: 0.9;
}

.dock-links a,
.dock-cta {
    transition: background-color 0.25s, opacity 0.25s, scale 0.15s;
}

.dock-cta:hover {
    scale: 1.04;
}

.dock-avatar img {
    transition: rotate 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.dock-avatar:hover img {
    rotate: -6deg;
}

.work-item img {
    transition: translate 0.4s cubic-bezier(0.2, 0.7, 0.2, 1), border-color 0.3s;
}

.work-item:hover img {
    translate: 0 -6px;
    border-color: var(--accent);
}

.work-item h3 {
    transition: color 0.25s;
}

.work-item:hover h3 {
    color: var(--accent);
}

.contact-mail a,
.copy,
.socials a,
.site-footer a {
    transition: color 0.2s, border-color 0.2s;
}

.socials a span {
    display: inline-block;
    transition: translate 0.25s, color 0.2s;
}

.socials a:hover span {
    translate: 2px -2px;
    color: var(--accent);
}

.copy.is-done {
    color: var(--accent);
    border-color: var(--accent);
    animation: pop 0.3s ease-out;
}

/* Apparition au défilement : la classe n'est posée qu'en JS */
.reveal {
    transition:
        opacity 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) var(--d, 0s),
        translate 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) var(--d, 0s);
}

.reveal:not(.is-in) {
    opacity: 0;
    translate: 0 2rem;
}

.section-head.reveal:not(.is-in)::after {
    scale: 0 1;
}

/* Barre de progression et parallaxe du hero, si le navigateur gère les animations liées au scroll */
@supports (animation-timeline: scroll()) {
    @keyframes progress {
        from { scale: 0 1; }
    }

    @keyframes hero-out {
        to { opacity: 0.15; translate: 0 18vh; }
    }

    body::before {
        content: "";
        position: fixed;
        inset: 0 0 auto;
        z-index: 25;
        height: 2px;
        background: var(--accent);
        transform-origin: left;
        animation: progress linear both;
        animation-timeline: scroll(root);
    }

    .hero {
        animation: hero-out linear both;
        animation-timeline: scroll(root);
        animation-range: 0 100vh;
    }
}

/* Changement de thème : cercle qui s'ouvre depuis le bouton (position posée en JS) */
@keyframes theme-reveal {
    from { clip-path: circle(0 at var(--vt-x) var(--vt-y)); }
    to { clip-path: circle(var(--vt-r) at var(--vt-x) var(--vt-y)); }
}

::view-transition-old(root) {
    animation: none;
    mix-blend-mode: normal;
}

::view-transition-new(root) {
    animation: theme-reveal 0.65s cubic-bezier(0.65, 0, 0.35, 1) both;
    mix-blend-mode: normal;
}

/* Responsive */

@media (max-width: 860px) {
    .work {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (max-width: 560px) {
    body {
        padding-bottom: 5.5rem;
    }

    .theme-toggle {
        top: 0.75rem;
        right: 0.75rem;
        width: 2.25rem;
        height: 2.25rem;
    }

    .dock {
        bottom: 0.75rem;
        font-size: 0.8rem;
    }

    .dock-avatar img {
        width: 3.25rem;
        height: 3.25rem;
    }

    .dock-links a {
        padding: 0 0.6rem;
    }

    .dock-cta {
        padding: 0 0.75rem;
    }

    .sel-frame i {
        width: 8px;
        height: 8px;
    }

    .cursor {
        right: 0;
        bottom: -1.5rem;
        scale: 0.8;
        transform-origin: left top;
    }

    .role {
        margin-top: 2.5rem;
    }

    .facts {
        gap: 0.4rem 0.75rem;
    }

    .facts li + li::before {
        margin-right: 0.75rem;
    }

    /* Sur mobile, « 1 Avis » passe à la ligne sans séparateur */
    .facts li:last-child {
        flex-basis: 100%;
    }

    .facts li:last-child::before {
        content: none;
    }

    .section-head {
        padding-bottom: 0.875rem;
        margin-bottom: 2rem;
    }

    .section-head .section-info {
        display: none;
    }

    .work {
        grid-template-columns: 1fr;
        gap: 2.25rem;
    }

    .stack div {
        grid-template-columns: 4rem 1fr;
        gap: 0.75rem;
    }

    .quote {
        margin-top: 3rem;
        padding-left: 1.25rem;
    }
}

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

    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}
