/* studio bali — site public
 * Mise en page : une colonne par projet, défilement horizontal entre les colonnes,
 * défilement vertical dans chaque colonne (comme l'ancien modèle Cargo « nonfeed »).
 */

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

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    background: var(--bg, #fff);
    color: var(--accent, #2f7c71);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Barre du haut ---------- */

.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 50;
    display: flex;
    align-items: baseline;
    gap: 30px;
    height: 50px;
    padding: 15px 35px;
    background: var(--bg, #fff);
    white-space: nowrap;
}

.brand {
    /* Titre centré horizontalement dans la barre du haut */
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    color: var(--accent);
    font-weight: bold;
    text-decoration: none;
    white-space: nowrap;
}

.back {
    color: var(--accent);
    opacity: .55;
    text-decoration: none;
}
.back:hover { opacity: 1; }

/* ---------- Barre des projets (en bas de page) ---------- */

.quicknav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 18px;
    height: var(--nav-h, 44px);
    padding: 0 35px;
    background: var(--bg, #fff);
    white-space: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
}
.quicknav::-webkit-scrollbar { display: none; }

.quicknav a {
    color: var(--accent);
    opacity: .55;
    text-decoration: none;
    transition: opacity .2s;
}
.quicknav a:hover,
.quicknav a.is-active { 
  opacity: 1; 
  font-weight: bold;
}

.preview-badge {
    margin-left: auto;
    padding: 2px 8px;
    border-radius: 3px;
    background: #fff3c4;
    color: #7a5d00;
    font-size: 11px;
}

/* ---------- Chevrons < > (défilement de 3 projets) ---------- */

/* Zone de 30 % de l'écran de chaque côté : invisible, elle apparaît quand la souris
   s'en approche (géré en JavaScript, pour ne pas bloquer les clics sur les projets en dessous) */
.chev-zone {
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 45;                     /* sous la barre du haut et la barre des projets (50) */
    display: flex;
    align-items: center;             /* rond au centre vertical */
    width: 30vw;
    opacity: 0;                      /* invisible de base */
    pointer-events: none;            /* laisse passer les clics vers le site */
    /* apparition franche, sans fondu */
}
.chev-zone-prev {
    left: 0;
    justify-content: flex-start;
    padding-left: 10px;              /* triangle à 10 px du bord */
}
.chev-zone-next {
    right: 0;
    justify-content: flex-end;
    padding-right: 10px;
}
.chev-zone.is-visible,
.chev-zone:has(.chev:focus-visible) { opacity: 1; }      /* aussi au clavier (Tab) */
.chev-zone.is-visible .chev,
.chev-zone:has(.chev:focus-visible) .chev { pointer-events: auto; }   /* seul le rond est cliquable */

/* Le triangle (180 px de large, 95 % de la hauteur de la page) */
.chev {
    flex: none;
    width: 180px;
    height: 95vh;
    padding: 0;
    border: 0;
    background: #fff;
    color: var(--accent);
    cursor: pointer;
    pointer-events: none;
    /* forme : seule la surface du triangle est cliquable */
    clip-path: polygon(100% 0, 0 50%, 100% 100%);        /* pointe vers la gauche */
}
.chev-next { clip-path: polygon(0 0, 100% 50%, 0 100%); } /* pointe vers la droite */
.chev svg { display: none; }                              /* l'ancien chevron n'est plus affiché */
.chev:focus-visible { outline: none; background: var(--accent-soft, #e5f1ef); }
.chev[disabled] { opacity: .35; cursor: default; }

/* ---------- Colonnes ---------- */

.columns {
    display: flex;
    align-items: stretch;
    height: 100vh;
    height: 100dvh;
    padding: 50px 0 var(--nav-h, 44px) 35px;
    overflow-x: auto;
    overflow-y: hidden;
}
body.is-single .columns { padding-bottom: 0; }

.col {
    --c: var(--accent);
    flex: 0 0 auto;
    width: calc(var(--w, 440px) + var(--gap, 100px));
    height: 100%;
    padding: 0 var(--gap, 100px) 0 0;
    overflow-x: hidden;
    overflow-y: auto;
    color: var(--c);
    /* Défilement vertical sans barre visible */
    scrollbar-width: none;          /* Firefox, Chrome et Edge récents */
    -ms-overflow-style: none;       /* anciens Edge */
}
.col::-webkit-scrollbar { display: none; }  /* Safari, anciens Chrome */

.col-in {
    max-width: var(--w, 440px);
    padding-bottom: 60px;
}

/* Projet avec un fond de couleur (réglé dans l'admin) */
.col.has-bg .col-in {
    min-height: 100%;
    padding: 24px 24px 60px;
    background: var(--colbg);
}

.col.is-draft { opacity: .6; }
.col.is-draft::before {
    content: "brouillon — non publié";
    display: block;
    margin-bottom: 10px;
    color: #a66f00;
    font-size: 11px;
}

body.is-single .columns { overflow-x: hidden; }
body.is-single .col { width: 100%; }
body.is-single .col-in { max-width: min(var(--w, 440px), 100%); }

/* ---------- Contenus ---------- */

.b-text { margin: 0 0 20px; }

.b-text h1 {
    margin: 0 0 6px;
    color: var(--c);
    font-size: 43px;
    line-height: 41px;
    font-weight: bold;
}
.b-text h2 {
    margin: 0 0 6px;
    font-size: 30px;
    line-height: 32px;
    font-weight: normal;
}
.b-text h3 {
    margin: 0 0 4px;
    font-size: 16px;
    line-height: 24px;
    font-weight: normal;
}
.b-text h6, .b-text .small {
    font-size: 11px;
    line-height: 17px;
    font-weight: normal;
    margin: 0;
}
.b-text .xl {
    font-size: 60px;
    line-height: 55px;
}
.b-text .lg {
    font-size: 44px;
    line-height: 48px;
    font-weight: bold;
}
.b-text .code {
    font-size: 24px;
    line-height: 28px;
}
.b-text p { margin: 0 0 1em; }
.b-text p:last-child { margin-bottom: 0; }
.b-text ul, .b-text ol { margin: 0 0 1em; padding-left: 1.4em; }
.b-text blockquote { margin: 0 0 1em; padding-left: 1em; border-left: 2px solid currentColor; font-style: italic; }

.b-text a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.b-text a:hover { background: #ccccff; color: #000; text-decoration: none; }

.b-image { margin: 0 0 20px; }
.b-image img {
    display: block;
    width: 100%;
    height: auto;
    cursor: zoom-in;
    background: rgba(0,0,0,.04);
}
.b-image figcaption {
    margin-top: 5px;
    font-size: 11px;
    line-height: 1.4;
}

.permalink {
    display: inline-block;
    margin-top: 10px;
    color: var(--c);
    opacity: 0;
    font-size: 11px;
    transition: opacity .2s;
}
.col:hover .permalink { opacity: .5; }

/* ---------- Visionneuse ---------- */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.97);
}
.lightbox[hidden] { display: none; }
.lightbox img {
    max-width: calc(100vw - 140px);
    max-height: calc(100vh - 80px);
    object-fit: contain;
}
.lightbox button {
    position: absolute;
    border: 0;
    background: none;
    color: var(--accent);
    font: 300 44px/1 Arial, sans-serif;
    cursor: pointer;
    padding: 10px 18px;
}
.lb-close { top: 10px; right: 15px; }
.lb-prev { left: 10px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 10px; top: 50%; transform: translateY(-50%); }
.lb-caption {
    position: absolute;
    bottom: 15px; left: 0; right: 0;
    text-align: center;
    font-size: 11px;
}

/* ---------- Téléphones : les colonnes s'empilent ---------- */

@media (max-width: 720px) {
    .topbar { padding: 15px 20px; gap: 20px; }
    .quicknav { padding: 0 20px; }
    .chev-zone { display: none; }
    /* Une colonne = un écran ; on passe d'un projet à l'autre d'un balayage */
    .columns {
        display: flex;
        height: 100vh;
        height: 100dvh;
        padding: 50px 0 var(--nav-h, 44px);
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;      /* chaque balayage s'arrête sur un projet */
        overscroll-behavior-x: contain;     /* pas de « retour arrière » du navigateur */
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .columns::-webkit-scrollbar { display: none; }
    .columns.is-gliding { scroll-snap-type: none; }   /* pendant un glissement lancé par la barre */
    .col {
        flex: 0 0 100vw;
        width: 100vw;
        height: 100%;
        padding: 0 20px;
        overflow-x: hidden;
        overflow-y: auto;                   /* chaque projet défile de haut en bas */
        scroll-snap-align: start;
        scroll-snap-stop: always;           /* un seul projet par balayage */
        overscroll-behavior-y: contain;
    }
    .col-in { padding-bottom: 40px; }
    body.is-single .columns { scroll-snap-type: none; }
    .col-in { max-width: none; }
    .col.has-bg { padding: 0; }
    .col.has-bg .col-in { padding: 20px 20px 40px; }
    .b-text h1 { font-size: 34px; line-height: 34px; }
    .b-text .xl { font-size: 44px; line-height: 42px; }
    .lightbox img { max-width: 100vw; }
    .lb-prev, .lb-next { display: none; }
}
