/*
 * brand.css — design CAF (label musical « CAF? »).
 *
 * Reproduit la signature visuelle source unptit.cafe (Lausanne/Vevey) :
 *   - Split-view 50/50 desktop (nav-albums géante à gauche, contenu à droite)
 *   - Police Simplon (Medium base + Bold display)
 *   - Chips menu position:fixed top-left (pilules arrondies)
 *   - Panneau #events position:fixed top-right (release meta / liste mixes)
 *   - Mobile <48em : nav.left cachée, <details> dropdown au sommet, #events
 *     repositionné en bas
 *
 * Charge APRÈS assets/shared/css/components.css. Cascade : @layer brand bat
 * @layer blocks sans guerre de spécificité.
 *
 * Discipline ADR-006 :
 *   - var(--token) UNIQUEMENT (linté par scripts/lint-tokens-only.sh)
 *   - JAMAIS de px (le linter le refuse, vw/vh/em/rem OK)
 *   - Breakpoints en em (47.99em) — les media queries CSS ne supportent pas
 *     var(--token)
 *   - 0.0625rem pour bordures fines (border-width 1/16 rem)
 *   - JAMAIS d'override de :root (piège unlayered tokens.css) — passer par
 *     tokens.semantic.dtcg.json
 */
@layer brand {

  /* --- @font-face : Simplon (WOFF servis depuis assets/themes/caf/fonts/) -- */
  @font-face {
    font-family: 'SimplonMedium';
    src: url('../fonts/SimplonNorm-Medium-WebXL.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
  }
  @font-face {
    font-family: 'SimplonBold';
    src: url('../fonts/SimplonNorm-Bold-WebXL.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
  }

  /* --- Base ------------------------------------------------------------- */
  html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
  }
  body {
    color: var(--color-text);
    background: var(--color-bg);
    font-family: var(--font-family-base);
    line-height: 1.2;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  body::-webkit-scrollbar { display: none; }

  a {
    color: inherit;
    text-decoration: none;
    transition: padding 0.3s ease-out, letter-spacing 0.2s ease-out;
  }

  /* Liens DANS le corps de texte éditorial (kirbytext + descriptions) :
     soulignés pour être identifiables comme des liens. Le chrome (nav-albums
     géante, chips .nav-sections, galeries, cartes) garde `text-decoration:none`
     par choix de design brutaliste — ces liens ont d'autres affordances
     (décalage de padding / inversion de couleur au survol). On ne cible donc
     QUE la prose, pas tous les `a`. Le décalage du soulignement améliore la
     lisibilité sans px (em autorisé par le linter ADR-006). */
  .block-text a,
  .block-list a,
  .block-callout a,
  .block-accordion a,
  .event .description a,
  .page-about-content .text a {
    text-decoration: underline;
    text-underline-offset: 0.15em;
  }

  /* Skip-link a11y — visible uniquement au focus clavier. */
  .skip-link {
    position: absolute;
    left: -9999rem;
    top: auto;
  }
  .skip-link:focus {
    position: fixed;
    left: var(--space-xs);
    top: var(--space-xs);
    background: var(--color-text);
    color: var(--color-bg);
    padding: var(--space-xs) var(--space-block);
    z-index: 9999;
  }

  /* --- Container + row split-view --------------------------------------- */
  #main.container-full {
    width: 100%;
    min-height: 100vh;
    overflow: hidden;
  }
  .row {
    display: flex;
    width: 100%;
    overflow-y: hidden;
  }
  .col-6.left,
  .col-6.repros {
    width: 50%;
    height: 100vh;
    overflow-y: auto;
    margin: 0;
    -ms-overflow-style: none;
    scrollbar-width: none;
    box-sizing: border-box;
  }
  .col-6.left::-webkit-scrollbar,
  .col-6.repros::-webkit-scrollbar { display: none; }

  /* --- Nav-albums (signature visuelle géante) --------------------------- */
  nav[aria-label] { margin: 0; padding: 0; }
  .nav-albums {
    list-style: none;
    padding: 5vh 0 0 var(--space-block);
    margin: 0;
  }
  .nav-albums li {
    line-height: 0.8;
    margin: 0;
    padding: 0;
  }
  .nav-albums a {
    font-family: var(--font-family-display);
    font-size: var(--font-size-display-fluid);
    font-variant-numeric: tabular-nums;
    color: var(--color-text);
    line-height: 0.8;
    padding-left: 0;
    display: inline-block;
    text-decoration: none;
    text-transform: uppercase;
    transition: padding-left 0.5s ease-out;
  }
  .nav-albums a:hover,
  .nav-albums a[aria-current] { padding-left: 5.7vw; }

  /* --- #menu : 4 chips pilule fixes top-left --------------------------- */
  .nav-sections {
    position: fixed;
    top: 2vh;
    left: 2vw;
    z-index: 100;
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5vw;
  }
  .nav-sections li {
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .nav-sections a {
    display: inline-block;
    border: 0.0625rem solid var(--color-border);
    border-radius: var(--chip-radius);
    background: var(--color-bg);
    color: var(--color-text);
    padding: 0.25rem 0.75rem;
    font-size: var(--font-size-sm);
    line-height: 1;
    text-transform: uppercase;
    box-sizing: border-box;
  }
  .nav-sections a[aria-current],
  .nav-sections a:hover {
    background: var(--color-text);
    color: var(--color-bg);
  }

  /* --- #events : panneau fixe top-right (meta release / liste mixes) --- */
  #events {
    position: fixed;
    top: 2vh;
    right: 5vw;
    width: 40vw;
    max-height: 95vh;
    overflow-y: auto;
    border: 0.0625rem solid var(--color-border);
    border-radius: var(--chip-radius);
    background: var(--color-bg);
    font-family: var(--font-family-base);
    line-height: 1;
    z-index: 100;
    box-sizing: border-box;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  #events::-webkit-scrollbar { display: none; }
  .event {
    background: var(--color-bg);
    font-size: var(--font-size-sm);
    border-bottom: 0.0625rem solid var(--color-border);
  }
  .event:last-child {
    border-bottom: 0;
    padding-bottom: 0.25rem;
  }
  .event h1,
  .event h2 {
    font-family: var(--font-family-display);
  }
  .event h1,
  .event h2,
  .event h3 {
    font-size: var(--font-size-sm);
    margin: 0;
    font-variant-numeric: tabular-nums;
    padding: 0.25rem 0.5rem;
    font-weight: normal;
  }
  .event time,
  .event h1 time,
  .event h3,
  .event .right { float: right; }
  .event ul {
    list-style: none;
    margin: 0;
    padding: 0;
  }
  .event li {
    border-top: 0.0625rem solid var(--color-border-subtle);
    padding: 0.0625rem 0.25rem;
  }
  .event .description {
    padding: 0.25rem 0.5rem;
  }
  .bandcamp-link {
    text-align: center;
    border-top: 0.0625rem solid var(--color-border-subtle);
    padding: 0.25rem 0;
  }
  .bandcamp-link a {
    text-decoration: none;
    letter-spacing: 0;
    transition: letter-spacing 0.2s ease-out;
  }
  .bandcamp-link a:hover { letter-spacing: 0.03em; }

  /* --- Album-gallery (colonne droite .repros) -------------------------- */
  .album-gallery,
  .release-gallery,
  .gig-gallery {
    list-style: none;
    margin: 0;
    padding: 7vh 0 0 0;
    width: 100%;
  }
  .album-gallery li,
  .release-gallery li,
  .gig-gallery li {
    padding-right: 0.3125rem;
  }
  .album-gallery picture,
  .release-gallery picture,
  .gig-gallery picture { display: block; line-height: 0; }
  .album-gallery img,
  .release-gallery img,
  .gig-gallery img {
    width: 100%;
    height: auto;
    display: block;
  }

  /* --- Hover-images (fade au survol de .event) ------------------------- */
  /* .image-teuf : 1 div fixe par gig, position randomisée par JS via
     --hover-x/--hover-y (set au mouseenter), fade-in via .is-visible.
     pointer-events:none pour ne pas casser le hover du .event/li parent. */
  .image-teuf {
    pointer-events: none;
    position: fixed;
    top: var(--hover-y, 20vh);
    left: var(--hover-x, 20vw);
    opacity: 0;
    transition: opacity 0.3s ease-out;
    z-index: 50;
    will-change: opacity;
  }
  .image-teuf img,
  .image-teuf picture img {
    border: 0.0625rem solid var(--color-text);
    border-radius: 1.5rem;
    max-height: 60vh;
    max-width: 40vw;
    width: auto;
    height: auto;
    display: block;
  }
  .image-teuf.is-visible { opacity: 1; }

  /* --- Embed video (iframe wrapper) ------------------------------------ */
  /* `.embed-video` = vidéo du panneau #events (snippet embed-video.php). Le
     bloc vidéo du builder émet `.video-embed` (stylé par components.css). */
  .embed-video {
    margin: 0;
    width: 100%;
    aspect-ratio: 16 / 9;
  }
  .embed-video iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
  }

  /* --- Bouton CTA (bloc `button`) -------------------------------------- *
   * Le bloc rend `<a class="btn btn--{primary,secondary}">`. components.css
   * (@layer blocks) pose `color:#fff` sur `.btn--primary`, mais le `a {
   * color: inherit }` ci-dessus (@layer brand) le NEUTRALISE — l'ordre de
   * couche prime sur la spécificité → le texte retombait sur #000 = noir sur
   * fond noir (illisible). On redéclare donc le bouton ici, calé sur la
   * signature chip CAF (pilule N&B, inversion au survol). */
  .block-button a.btn {
    display: inline-block;
    border: 0.0625rem solid var(--color-border);
    border-radius: var(--chip-radius);
    padding: 0.5rem 1rem;
    text-transform: uppercase;
    font-size: var(--font-size-sm);
    line-height: 1;
    transition: background 0.2s ease-out, color 0.2s ease-out;
  }
  .block-button a.btn--primary {
    background: var(--color-text);
    color: var(--color-bg);
  }
  .block-button a.btn--secondary {
    background: var(--color-bg);
    color: var(--color-text);
  }
  .block-button a.btn:hover,
  .block-button a.btn:focus-visible {
    background: var(--color-bg);
    color: var(--color-text);
  }
  .block-button a.btn--secondary:hover,
  .block-button a.btn--secondary:focus-visible {
    background: var(--color-text);
    color: var(--color-bg);
  }

  /* --- Contenu builder : alignement brutaliste ------------------------- *
   * 4c — titres du builder en police display (signature SimplonBold), comme
   *      le reste de la marque (components.css les laissait en base).
   * 4d — médias à bords nets : le `--radius` 4px de components.css détonne
   *      avec le N&B brutaliste (galeries et nav sont à angles vifs). */
  .block-heading {
    font-family: var(--font-family-display);
  }
  .block-image img,
  .video-embed iframe,
  .video-embed video {
    border-radius: 0;
  }

  /* --- Card-grid (fallback pour pages listing simples si exposées) ---- */
  .card-grid {
    list-style: none;
    padding: 7vh var(--space-block) 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    gap: var(--space-block);
  }
  .card { background: var(--color-bg); }
  .card-link { display: block; color: inherit; }
  .card-link picture,
  .card-link img { display: block; width: 100%; height: auto; }
  .card-body {
    padding: var(--space-xs) 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }
  .card-title {
    font-family: var(--font-family-display);
    margin: 0;
  }
  .card-artist,
  .card-date,
  .card-lieu,
  .card-year {
    color: var(--color-text-subtle);
    font-size: var(--font-size-sm);
    margin: 0;
  }

  /* --- Listing compact (espressos) ------------------------------------- *
   * Signature visuelle ancien : la page espressos rend un flux texte-only
   * dense dans la colonne droite (pas de cartes-images). On aplatit la
   * présentation via CSS scopé par body.page-espressos. La galerie reste sur
   * les pages détail (release) — non touchée.
   *
   * NB : la page `events` ne passe PLUS par ici — elle rend sa liste agrégée
   * dans le panneau `#events` (fiches `.event` + hover-images, cf. snippet
   * `events-list`), sans aucun `.block-cards`. Les ex-règles
   * `body.page-events .block-cards*` ont été retirées (mortes depuis le
   * redesign /events 2026-06-27).
   */
  body.page-espressos .col-6.repros {
    padding: 7vh var(--space-block) 0;
    box-sizing: border-box;
  }

  /* Espressos — page éditoriale plate (33 blocs image+text).
   * Aplatit en flux 1-col compact : images cachées, lien + date inline. Le
   * panneau #events reste avec son titre. Reproduit la table compacte de
   * l'ancien `espresso.php` (□ ESPRESSO0xx | titre — date).
   */
  body.page-espressos .col-6.repros .layout-section {
    padding: 0;
  }
  body.page-espressos .col-6.repros .layout-container {
    padding-inline: 0;
    max-width: none;
  }
  body.page-espressos .col-6.repros .block-image {
    display: none;
  }
  body.page-espressos .col-6.repros .block-text {
    border-bottom: 0.0625rem solid var(--color-border);
    padding: 0.25rem 0.5rem;
    font-size: var(--font-size-sm);
    line-height: 1.4;
    font-variant-numeric: tabular-nums;
  }
  body.page-espressos .col-6.repros .block-text p {
    margin: 0;
    display: inline;
  }
  body.page-espressos .col-6.repros .block-text p + p::before {
    content: ' — ';
  }
  body.page-espressos .col-6.repros .block-text a {
    color: inherit;
    text-decoration: none;
  }
  body.page-espressos .col-6.repros .block-text a:hover {
    text-decoration: underline;
  }

  /* --- Page d'about / default — repro inside #events ------------------- */
  .page-about-content {
    padding: 0;
  }
  .page-about-content .text {
    padding: 0.5rem;
    line-height: 1.4;
  }

  /* --- Empty-state (fallback releases vide) ---------------------------- */
  .empty-state {
    padding: 7vh var(--space-block) 0;
    font-family: var(--font-family-base);
  }
  .empty-state h2 {
    font-family: var(--font-family-display);
    margin: 0 0 var(--space-block);
  }

  /* --- Nav-mobile (caché desktop, visible < 48em) ---------------------- */
  .nav-mobile {
    display: none;
  }
  .nav-mobile > summary {
    list-style: none;
    cursor: pointer;
    padding: 0.25rem 0.75rem;
    border: 0.0625rem solid var(--color-border);
    border-radius: var(--chip-radius);
    background: var(--color-bg);
    text-transform: uppercase;
    font-size: var(--font-size-sm);
    display: inline-block;
  }
  .nav-mobile > summary::-webkit-details-marker { display: none; }
  .nav-mobile[open] > summary {
    background: var(--color-text);
    color: var(--color-bg);
  }
  .nav-mobile ul {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
  }
  .nav-mobile-albums li {
    font-family: var(--font-family-display);
    font-size: var(--font-size-h1);
    line-height: 1.1;
  }
  .nav-mobile-sections {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5vw;
    margin-top: 0.5rem;
  }
  .nav-mobile-sections li {
    font-size: var(--font-size-sm);
  }
  .nav-mobile-sections a {
    display: inline-block;
    border: 0.0625rem solid var(--color-border);
    border-radius: var(--chip-radius);
    padding: 0.25rem 0.75rem;
    text-transform: uppercase;
  }

  /* --- Mobile <48em ----------------------------------------------------- */
  @media (max-width: 47.99em) {
    .col-6.left { display: none; }
    .col-6.repros {
      width: 100%;
      height: auto;
      padding-top: 7vh;
    }
    .row { display: block; overflow: visible; }

    /* Nav-sections (chips fixes) cachées en mobile : remplacées par <details>. */
    .nav-sections { display: none; }
    .nav-mobile {
      display: block;
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      z-index: 1000;
      padding: 2vh;
      background: var(--color-bg);
      box-sizing: border-box;
    }

    /* #events : repositionné en bas, pleine largeur. */
    #events {
      position: fixed;
      bottom: 3vh;
      top: auto;
      left: 5vw;
      right: auto;
      width: 90vw;
      max-height: 50vh;
    }

    .album-gallery,
    .release-gallery,
    .gig-gallery { padding-top: 0; }
    .card-grid { grid-template-columns: 1fr; }

    /* Hover-images cachées sur mobile (pas de souris → pas de hover utile,
       et écran trop petit pour le rendu fixe). */
    .image-teuf { display: none; }
  }

  /* --- HTMX loading indicator (Alpine x-bind:data-loading) ------------- */
  /* Pendant un swap HTMX (`body[data-loading="true"]`), légère baisse
     d'opacité de #page-content avec un délai de 0.1s : si le swap est
     instantané (<100ms, cas courant en local), aucun changement visible.
     Si le serveur traîne, le user voit que ça charge sans flash brutal. */
  body[data-loading="true"] #page-content {
    opacity: 0.5;
    transition: opacity 0.15s ease-out 0.1s;
  }

  /* Reduced motion : retire transitions. */
  @media (prefers-reduced-motion: reduce) {
    a { transition: none; }
    body[data-loading="true"] #page-content { transition: none; }
  }
}
