@font-face {
    font-family: Alte;
    src: url("../fonts/AlteHaasGroteskRegular.ttf") format("truetype");
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: Alte;
    src: url("../fonts/AlteHaasGroteskBold.ttf") format("truetype");
    font-weight: 700;
    font-display: swap;
}

/* VARIABLES — couleurs, marges et taille du texte. */
:root {
    --bg: #1c1c1c;
    --fg: #e8e8e8;
    --line: #3b3b3b;
    --red: #f50000;
    --pad: 1vw;
    --small: clamp(12px,1.12vw,18px);
}

/* BASE — normalisation et styles généraux. */
* {
    box-sizing: border-box;
}

html {
    scrollbar-width: thin;
    scrollbar-color: #888 var(--bg);
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: #888;
}

::selection {
    background: var(--red);
    color: var(--bg);
}

footer::selection,
footer *::selection {
    background: var(--bg);
    color: var(--fg);
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: Alte,Arial,sans-serif;
    line-height: 1.05;
}

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

a:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
}

h1,h2,p,figure {
    margin: 0;
}

.skip {
    position: absolute;
    left: 1rem;
    top: -100px;
    z-index: 5;
    background: white;
    color: black;
    padding: 10px;
}

.skip:focus {
    top: 0;
}

/* HEADER — grille et navigation. */
.header {
    padding: 0 var(--pad);
    font-size: var(--small);
    font-weight: 700;
    position: relative;
    z-index: 2;
}

.header>div {
    display: grid;
    grid-template-columns: 50% 25% 25%;
    padding: .45vw 0;
}

.header>div:first-child {
    border-bottom: 1px solid var(--line);
}

.header>div>*:last-child {
    text-align: right;
}

.home .header {
    position: absolute;
    top: 0;
    width: 100%;
    background: #2225;
    color: white;
}

/* HERO — média au-dessus des informations. */
.hero {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-rows: minmax(160px, 1fr) auto;
    gap: calc(2 * var(--pad));
    padding-bottom: calc(2 * var(--pad));
    overflow: hidden;
    border-radius: 0 0 8px 8px;
    color: white;
    background: var(--bg);
}

.hero-media {
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.hero-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-preview {
    opacity: 0;
}

.hero-preview.is-ready {
    opacity: 1;
}

.hero-caption {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
    margin: 0 var(--pad);
}

.hero h1 {
    font-size: 3.05vw;
    line-height: .91;
    font-weight: 400;
}

.hero-word {
    display: inline-block;
    overflow: hidden;
    vertical-align: bottom;
    line-height: 1.05;
    padding-bottom: .2em;
    margin-bottom: -.34em;
}

.hero-word > span,
.hero-detail-word > span {
    display: block;
    animation: hero-word-in 350ms ease-out both;
    animation-delay: calc(var(--word) * 45ms);
}

@keyframes hero-word-in {
    from { transform: translateY(140%); }
    to { transform: translateY(0); }
}

.hero-details {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    font-size: 1.05vw;
    line-height: 1.13;
    text-transform: uppercase;
}

.hero-detail-word {
    display: inline-block;
    overflow: hidden;
    vertical-align: bottom;
    padding-bottom: .2em;
    margin-bottom: -.2em;
}

.hero-details h2 {
    font-size: inherit;
    font-weight: 700;
}

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

.hero-details button {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    text-transform: inherit;
    cursor: pointer;
}

.hero-details button:hover {
    opacity: .75;
}

.hero-details button:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
}

/* INDEX DES PROJETS — titre et lignes. */
.work {
    padding: 5vw var(--pad) 7vw;
}

.work h2 {
    font-size: 6.25vw;
    font-weight: 400;
    line-height: 1;
    margin-bottom: 1.6vw;
}

.project-row {
    display: grid;
    grid-template-columns: 50% 35% 15%;
    border-top: 1px solid var(--line);
    padding: .45vw 0;
    font-size: clamp(14px,1.48vw,24px);
}

.project-row span:last-child {
    text-align: right;
}

.project-row.has-preview,
.project-row.has-preview * {
    cursor: none;
}

.project-preview {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 20;
    width: 25vw;
    height: 25vw;
    overflow: hidden;
    pointer-events: none;
    background: var(--bg);
}

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

.project-row.labels {
    font-size: var(--small);
    font-weight: 700;
    border: 0;
    color: #ccc;
}

.project-row.labels button {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.project-row.labels button:last-child {
    text-align: right;
}

.project-row.labels button:hover {
    opacity: .75;
}

.project-row.labels button:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
}

.project-row.labels button[data-direction="ascending"]::after {
    content: " ↑";
}

.project-row.labels button[data-direction="descending"]::after {
    content: " ↓";
}

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

/* FOOTER — grille, signature et liens. */
footer {
    background: var(--red);
    color: var(--bg);
    display: grid;
    grid-template-columns: 50% 25% 25%;
    padding: 1vw var(--pad);
    border-radius: 0 0 8px 8px;
    font-size: clamp(14px,1.5vw,24px);
    gap: 0;
}

.signature {
    font-weight: 700;
    font-size: 11.5vw;
    line-height: .77;
    letter-spacing: -.055em;
    display: flex;
    flex-direction: column;
    align-self: start;
}

footer nav {
    display: flex;
    flex-direction: column;
    padding-left: .6vw;
}

footer nav br {
    height: 1em;
}

footer nav .legal-link {
    font-size: clamp(12px,1vw,16px);
}

.clocks>div {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5vw;
    gap: 8px;
}

.clocks time {
    font-variant-numeric: tabular-nums;
}

/* INFORMATIONS — grille du CV. */
.cv {
    padding: 5vw var(--pad) 0;
    font-size: var(--small);
    font-weight: 700;
}

.cv-head,.cv-row {
    display: grid;
    grid-template-columns: 33.333% 66.667%;
    border-bottom: 1px solid var(--line);
}

.cv-head {
    grid-template-columns: repeat(3,1fr);
    padding-bottom: .5vw;
}

.cv-row {
    padding: .5vw 0 4vw;
    min-height: 9.5vw;
}

.cv-entry {
    display: grid;
    grid-template-columns: 1fr 1fr;
    margin-bottom: 1.2vw;
}

.cv-entry>div:first-child {
    padding-right: 7vw;
}

.muted {
    color: #969696;
}

/* PROJETS — métadonnées. */
.case {
    padding: 5vw var(--pad) 2.5vw;
    font-size: var(--small);
    font-weight: 700;
}

.case-labels,.case-meta {
    display: grid;
    grid-template-columns: 25% 25% 35% 15%;
    gap: 0;
}

.case-labels {
    border-bottom: 1px solid var(--line);
    padding-bottom: .5vw;
}

.case-meta {
    padding: .5vw 0 1.3vw;
    font-weight: 400;
}

.case-meta h1 {
    font-size: inherit;
    font-weight: inherit;
}

.case-meta>*:last-child,.case-labels>*:last-child {
    text-align: right;
}

.case-meta>div:nth-child(3) {
    padding-right: 1vw;
}

/* GALERIE JUSTIFIÉE — chaque ligne possède sa propre hauteur.
   Les proportions sont calculées dans js/bento.js, sans recadrage. */
.bento {
    display: flex;
    flex-direction: column;
    gap: var(--pad);
}

.bento-row {
    display: flex;
    gap: var(--pad);
    align-items: flex-start;
}

.tile {
    flex: 0 0 auto;
    min-width: 0;
    overflow: hidden;
    background: #333;
}

.tile img,
.tile video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.tile-image-button {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: none;
    cursor: zoom-in;
}

.tile-image-button:focus-visible,
.tile-video-button:focus-visible {
    outline: 2px solid var(--fg);
    outline-offset: -2px;
}

.tile-video {
    position: relative;
}

.tile-video-button {
    position: absolute;
    inset: 0;
    border: 0;
    padding: 8px;
    background: transparent;
    color: var(--fg);
    font: inherit;
    text-align: right;
    cursor: zoom-in;
}

.tile-video-button.with-controls {
    inset: 8px 8px auto auto;
    width: 44px;
    height: 44px;
    background: var(--bg);
    text-align: center;
}

html.lightbox-open {
    overflow: hidden;
}

.lightbox {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 24px;
    border: 0;
    background: transparent;
    cursor: zoom-out;
}

.lightbox[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox::backdrop {
    background: rgba(0,0,0,.5);
}

.lightbox img,
.lightbox video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: default;
}

.lightbox-error {
    color: var(--fg);
}

.lightbox-close {
    position: absolute;
    z-index: 1;
    top: 8px;
    right: 12px;
    padding: 4px 8px;
    border: 0;
    background: var(--bg);
    color: var(--fg);
    font: inherit;
    font-size: 32px;
    cursor: pointer;
}

.lightbox-nav {
    position: absolute;
    z-index: 1;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 48px;
    padding: 0;
    border: 0;
    background: var(--bg);
    color: var(--fg);
    font: inherit;
    font-size: 32px;
    cursor: pointer;
}

.lightbox-previous {
    left: 8px;
}

.lightbox-next {
    right: 8px;
}

.lightbox-nav[aria-disabled="true"] {
    opacity: .4;
    cursor: default;
}

.lightbox-close:focus-visible,
.lightbox-nav:focus-visible {
    outline: 2px solid var(--fg);
}

/* PAGES LÉGALES — mise en page du texte. */
.legal {
    max-width: 850px;
    padding: 6vw var(--pad);
    line-height: 1.5;
}

.legal h1 {
    font-size: clamp(32px,5vw,72px);
    line-height: 1;
}

.legal h2 {
    margin-top: 2rem;
    font-size: 1.3rem;
}

.legal p {
    margin-top: .7rem;
}

.legal a {
    text-decoration: underline;
}

@media(max-width:650px) {
    :root {
        --pad: 12px;
    }

    .header>div {
        grid-template-columns: 52% 25% 23%;
        padding: 7px 0;
    }

    .hero h1 {
        font-size: 9vw;
    }

    .work {
        padding: 40px var(--pad) 60px;
    }

    .work h2 {
        font-size: 9vw;
        margin-bottom: 20px;
    }

    .project-row {
        padding: 8px 0;
        grid-template-columns: 52% 30% 18%;
    }

    .cv {
        padding-top: 40px;
    }

    .cv-head {
        grid-template-columns: 25% 48% 27%;
    }

    .cv-row {
        grid-template-columns: 25% 75%;
        padding: 10px 0 30px;
    }

    .cv-entry {
        grid-template-columns: 64% 36%;
        gap: 4px;
        margin-bottom: 15px;
    }

    .cv-entry>div:first-child {
        padding-right: 8px;
    }

    .case {
        padding-top: 40px;
    }

    .case-labels {
        display: none;
    }

    .case-meta {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        margin-bottom: 12px;
    }

    .case-meta>div:first-child {
        display: contents;
    }

    .case-meta h1,
    .case-meta>div:nth-child(3),
    .case-meta>div:last-child {
        grid-column: 1/-1;
    }

    .case-meta>div:last-child {
        text-align: left;
    }

    .hero-caption {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .hero-details {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        font-size: 13px;
        row-gap: 12px;
    }

    footer {
        grid-template-columns: 1fr 1fr;
        gap: 24px;
        padding: 16px var(--pad);
    }

    .signature {
        grid-column: 1/-1;
        font-size: 23vw;
    }

    .clocks>div {
        margin-bottom: 12px;
    }

}

/* Navigation : survol, page active et défilement doux. */
html {
    scroll-behavior: smooth;
}

a[href] {
    transition: opacity 180ms ease;
}

a[href]:hover, a[href]:active, a[aria-current] {
    opacity: .75;
    text-decoration: none;
}

.header {
    display: grid;
    grid-template-columns: 50% 50%;
}

.header::after {
    content: "";
    position: absolute;
    left: var(--pad);
    right: var(--pad);
    top: 50%;
    border-top: 1px solid currentColor;
    pointer-events: none;
}

.header > .brand {
    display: grid;
    grid-template-rows: 1fr 1fr;
}

.header > .brand > span {
    padding: .45vw 0;
}

.header > .header-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    padding: 0;
    border: 0;
}

.header > .header-links > a {
    padding: .45vw 0;
}

.header > .header-links > a:nth-child(even) {
    text-align: right;
}

@media (max-width: 650px) {
    .header {
        grid-template-columns: 52% 48%;
    }

    .header > .brand > span, .header > .header-links > a {
        padding: 7px 0;
    }

}

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

    a[href] {
        transition: none;
    }

    .hero-word > span,
    .hero-detail-word > span {
        animation: none;
    }

}

/* Signature statique du footer */
footer .signature {
    color: inherit;
    opacity: 1;
    cursor: default;
}

/* BAS DE PAGE — le footer est le dernier bloc, sans marge ni arrondi.
   La grille réserve au contenu tout l’espace libre de la fenêtre.
   Sur l’accueil, le header est absolu : il ne prend aucune rangée. */
html {
    min-height: 100%;
    margin: 0;
    padding: 0;
    background: var(--red);
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-rows: auto 1fr auto;
}

body.home {
    grid-template-rows: 1fr auto;
}

body > main {
    min-width: 0;
}

body > footer {
    width: 100%;
    margin: 0;
    border-radius: 0;
    align-self: end;
}

/* Le footer reste le dernier élément réel du document. */
body > footer {
    margin-bottom: 0;
    border-bottom: 0;
}
