/* ═══ Navigation Tripotay, habillée par le Système fonctionnel ══════════════════
   Structure V2 gardée (R5 à R9) : en-tête + barre du bas au téléphone, rail d'icônes sur tablette,
   barre latérale + zone droite sur ordinateur. Le système fixe le reste : en-tête de 60 px à fond plein,
   filet seulement au défilement, boutons d'icône `ds-btn ds-btn--quiet ds-btn--icon`, cibles de 44 px,
   état actif par aria-current, calques --ds-z-*.
   Icônes de la navigation : 24 px, la grille native de Lucide (le système ne fixe que 16 / 14 px,
   pour les boutons, lignes et pastilles). */
:root {
  --nav-icon: 24px;
}

/* ─── En-tête ──────────────────────────────────────────────────────────── */
.navbar {
  background: var(--color-bg);
  border-bottom: 1px solid transparent;
  position: sticky;
  top: 0;
  transition: border-color var(--ds-motion-fast);
  z-index: var(--ds-z-sticky);
}

/* Le filet n'apparaît qu'au défilement (app.js) */
.navbar.is-scrolled {
  border-bottom-color: var(--color-border-subtle);
}

.navbar-inner {
  align-items: center;
  display: flex;
  height: var(--ds-size-nav);
  justify-content: space-between;
  margin: 0 auto;
  max-width: 680px;
  padding: 0 var(--space-2);
}

.navbar-left,
.navbar-actions {
  align-items: center;
  display: flex;
  gap: var(--space-1);
}

.navbar-logo {
  align-items: center;
  color: var(--color-text);
  display: inline-flex;
  font-size: var(--ds-font-size-md); /* le nom à côté du logo : Inter 600, 16 px (guide 09) */
  font-weight: var(--ds-font-weight-semibold);
  gap: var(--space-2);
  line-height: 1;
  padding: 0 var(--space-1);
  text-decoration: none;
}


/* Titre d'un écran poussé, à côté de la flèche retour (ex. « Diskisyon ») */
.navbar-title {
  color: var(--color-text);
  font-size: var(--ds-font-size-md);
  font-weight: var(--ds-font-weight-semibold);
  margin-left: var(--space-1);
}

/* Titre seul (écran racine, sans flèche retour) : aligné sur la marge du contenu */
.navbar-title:first-child {
  margin-left: var(--space-2);
}

.navbar-page-title {
  display: none;
}

/* ─── Barre du bas (téléphone, écrans racines : R5) ───────────────────── */
.bottom-nav {
  align-items: center;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border-subtle);
  bottom: 0;
  display: flex;
  height: calc(64px + env(safe-area-inset-bottom));
  justify-content: space-around;
  left: 0;
  padding: var(--space-1) var(--space-2) env(safe-area-inset-bottom);
  position: fixed;
  right: 0;
  z-index: var(--ds-z-sticky);
}

.bottom-nav__item {
  align-items: center;
  border-radius: var(--radius-full);
  color: var(--color-text-subtle); /* --ds-text-3 : icônes au repos */
  display: flex;
  flex: 1;
  flex-direction: column;
  font-size: var(--ds-font-size-xs);
  font-weight: var(--ds-font-weight-medium);
  gap: var(--space-1);
  justify-content: center;
  line-height: 1;
  min-height: 52px;
  min-width: 0;
  padding: var(--space-1);
  text-decoration: none;
  transition: background-color var(--ds-motion-fast), color var(--ds-motion-fast);
}

.bottom-nav__icon {
  height: var(--nav-icon);
  width: var(--nav-icon);
}

/* Actif : l'encre et le demi-gras, comme l'onglet actif du système */
.bottom-nav__item[aria-current='page'] {
  color: var(--color-text);
  font-weight: var(--ds-font-weight-semibold);
}

@media (hover: hover) {
  .bottom-nav__item:hover {
    background: var(--ds-fill);
    color: var(--color-text);
  }
}

/* Notifications non lues : le compteur ambre du système (ds-dot), sur l'icône */
.bottom-nav__icon-wrap {
  display: inline-flex;
  position: relative;
}

.bottom-nav__dot {
  position: absolute;
  right: calc(var(--space-2) * -1);
  top: calc(var(--space-1) * -1);
}

/* Écran sans barre en bas (R5) : pas d'espace réservé pour elle */
body.no-bottom-bar .main {
  padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
}

/* ─── Tiroir « Meni » (téléphone et tablette) ─────────────────────────── */
.hamburger-overlay {
  background: var(--ds-overlay);
  display: none;
  inset: 0;
  opacity: 0;
  position: fixed;
  transition: opacity var(--ds-motion-base);
  z-index: var(--ds-z-overlay);
}

.hamburger-overlay.open {
  display: block;
  opacity: 1;
}

/* Il flotte au-dessus de la page : .ds-floating (base.html) donne la surface un cran plus claire en sombre,
   le filet et l'ombre (guide 07, règle 1). Collé au bord de l'écran : pas d'arrondi, filet à droite seulement. */
.hamburger-panel {
  border-radius: 0;
  border-width: 0 1px 0 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  left: 0;
  max-width: 330px;
  position: fixed;
  top: 0;
  transform: translateX(-100%);
  transition: transform var(--ds-motion-glide) var(--ds-motion-ease);
  width: 86%;
  z-index: var(--ds-z-overlay);
}

.hamburger-panel.open {
  transform: translateX(0);
}

.hamburger-header {
  align-items: center;
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  height: var(--ds-size-nav);
  justify-content: space-between;
  padding: 0 var(--space-2) 0 var(--space-5);
}

.hamburger-brand {
  color: var(--color-text);
  font-size: var(--ds-font-size-md);
  font-weight: var(--ds-font-weight-semibold);
}

.hamburger-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) 0 var(--space-1);
}

.hamburger-panel .pwa-install-card {
  margin: var(--space-2) var(--space-4) !important;
}

/* Carte « Pataje Tripotay » */
.share-card {
  align-items: center;
  color: var(--color-text);
  cursor: pointer;
  display: flex;
  font: inherit;
  gap: var(--space-3);
  margin: var(--space-2) var(--space-4);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  width: calc(100% - 2 * var(--space-4));
}

.share-card__text small {
  color: var(--color-text-subtle);
  display: block;
  font-size: var(--ds-font-size-xs);
}

.share-card__text b {
  font-size: var(--ds-font-size-sm);
  font-weight: var(--ds-font-weight-semibold);
}


/* Réseaux sociaux */
.social-grid {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: 1fr 1fr;
  margin: 0;
  padding: 0 var(--space-4);
}

.social-btn {
  align-items: center;
  background: var(--ds-fill);
  border-radius: var(--radius-full);
  color: var(--color-text);
  display: flex;
  font-size: var(--ds-font-size-sm);
  font-weight: var(--ds-font-weight-medium);
  gap: var(--space-2);
  min-height: var(--ds-size-target);
  padding: 0 var(--space-3);
  text-decoration: none;
  transition: background-color var(--ds-motion-fast);
}

.social-btn:hover {
  background: var(--ds-fill-strong);
}

.social-icon {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  height: var(--ds-size-icon);
  justify-content: center;
  width: var(--ds-size-icon);
}

.social-icon svg {
  fill: var(--color-text);
  height: var(--ds-size-icon);
  width: var(--ds-size-icon);
}

/* Bas du tiroir : crédit */
.hamburger-bottom {
  border-top: 1px solid var(--color-border-subtle);
  margin-top: var(--space-2);
}

.hamburger-footer {
  color: var(--color-text-subtle);
  font-size: var(--ds-font-size-xs);
  line-height: var(--ds-line-height-prose);
  padding: var(--space-4);
  text-align: center;
}

.hamburger-credit-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .hamburger-panel {
    transition: none;
  }
}

/* ─── Bannière de bienvenue (1re visite, sans compte) ─────────────────── */
.welcome {
  margin: var(--space-3) var(--space-4) var(--space-1);
  position: relative;
}

.welcome__title {
  color: var(--color-text);
  font-size: var(--ds-font-size-md);
  font-weight: var(--ds-font-weight-semibold);
  margin: 0 var(--space-10) var(--space-2) 0;
}

.welcome__text {
  color: var(--color-text-muted);
  font-size: var(--ds-font-size-sm);
  line-height: var(--ds-line-height-prose);
  margin: 0 0 var(--space-4);
}

.welcome__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.welcome__close {
  position: absolute;
  right: var(--space-1);
  top: var(--space-1);
}

/* Raccourci clavier affiché dans les libellés */
kbd {
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--ds-radius-sm);
  color: var(--color-text-muted);
  font-family: inherit;
  font-size: var(--ds-font-size-xs);
  padding: 0 var(--space-1);
}

/* ═══ R9 : coquille responsive (body.v2-shell), à la Threads ════════════════
   < 768px    : en-tête avec Meni, barre du bas sur les écrans racines (R5)
   768–1279   : rail d'icônes à gauche (bouton Meni en bas pour les liens), colonne, zone droite avec (+)
   ≥ 1280px   : barre latérale avec libellés et liens en bas (pas de Meni), colonne, zone droite
   La colonne est centrée sur la fenêtre : les deux zones latérales ont la même largeur.
   Dès 768px, la colonne est une carte (bordure, coins arrondis) qui contient tout le fil. */
:root {
  --rail-w: 0px;
  /* Colonne de 680px au plus, en laissant au moins la largeur du rail de chaque côté */
  --col-w: min(680px, 100vw - 2 * var(--rail-w));
  /* Bord gauche de la colonne : centrée sur la fenêtre, sans jamais passer sous le rail */
  --col-left: max(var(--rail-w), (100vw - var(--col-w)) / 2);
}

@media (min-width: 768px) {
  :root {
    --rail-w: 76px;
  }
}

@media (min-width: 1280px) {
  :root {
    /* À 1280px la zone gauche fait exactement 300px : la colonne reste centrée */
    --rail-w: 300px;
  }
}

/* Éléments propres au rail : invisibles au téléphone */
.v2-shell .rail__brand,
.v2-shell .rail__menu,
.v2-shell .rail__footer,
.v2-shell .side-fab,
.v2-shell .right-rail {
  display: none;
}

/* Au téléphone, les destinations restent des enfants directs de la barre */
.v2-shell .rail__items {
  display: contents;
}

/* Écran poussé : pas de barre du bas (R5) ; le même élément sert de rail dès 768px */
.v2-shell .bottom-nav--rail-only {
  display: none;
}

/* ── 600–767px : colonne bordée sur les côtés, barre du bas gardée ── */
@media (min-width: 600px) and (max-width: 767px) {
  .v2-shell .bottom-nav__item {
    max-width: 120px;
  }

  .v2-shell .main {
    padding-bottom: calc(var(--ds-space-18) + var(--space-4) + env(safe-area-inset-bottom));
  }

  .v2-shell.no-bottom-bar .main {
    padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
  }

  .v2-shell .main,
  .v2-shell .navbar,
  .v2-shell .search-bar {
    border-left: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
  }
}

/* ── ≥ 600px : en-tête, recherche, contenu, barre de réponse et snackbar sur la même colonne ── */
@media (min-width: 600px) {
  .v2-shell .navbar-left {
    gap: 0;
  }

  .v2-shell .main,
  .v2-shell .navbar,
  .v2-shell .search-bar {
    box-sizing: border-box;
    margin-left: var(--col-left);
    max-width: var(--col-w);
    width: 100%;
  }

  .v2-shell .main {
    background: var(--color-bg);
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: 0;
  }

  .v2-shell .navbar-inner {
    max-width: none;
  }

  .v2-shell .post-card {
    margin-bottom: var(--space-3);
  }

  /* Le contenu vit directement dans la colonne */
  .v2-shell .main > .container {
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    max-width: none;
    min-height: calc(100vh - 100px);
    width: auto;
  }

  .v2-shell .main > .container.feed-container {
    padding: 0;
  }

  /* Éléments fixes : alignés sur la colonne, pas sur la fenêtre */
  .v2-shell .reply-bar {
    border-left: 1px solid var(--color-border);
    border-radius: 0;
    border-right: 1px solid var(--color-border);
    left: var(--col-left);
    max-width: var(--col-w);
    right: auto;
    transform: none;
    width: 100%;
  }

  .v2-shell .snack-root {
    left: var(--col-left);
    max-width: var(--col-w);
    right: auto;
    width: 100%;
  }
}

/* ── ≥ 768px : rail à gauche (icônes seules jusqu'à 1279px), colonne en carte ── */
@media (min-width: 768px) {
  .v2-shell .bottom-nav,
  .v2-shell .bottom-nav--rail-only {
    align-items: center;
    border: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    height: auto;
    justify-content: flex-start;
    padding: 0 0 calc(var(--space-4) + env(safe-area-inset-bottom));
    right: auto;
    top: 0;
    width: var(--rail-w);
  }

  /* Le logo occupe la même bande que l'en-tête de la colonne : il se lit comme l'en-tête du site */
  .v2-shell .rail__brand {
    align-items: center;
    color: var(--color-text);
    display: flex;
    flex: none;
    gap: var(--space-3);
    height: var(--ds-size-nav);
    justify-content: center;
    text-decoration: none;
    width: 48px;
  }

  .v2-shell .rail__brand .logo {
    flex: none;
  }

  .v2-shell .rail__name {
    display: none;
  }

  .v2-shell .rail__items {
    align-items: center;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
  }

  .v2-shell .bottom-nav__item,
  .v2-shell .rail__menu {
    flex: none;
    flex-direction: row;
    height: 52px;
    padding: 0;
    width: 60px;
  }

  /* Icônes seules ; le libellé reste lu par les lecteurs d'écran */
  .v2-shell .nav-label {
    clip: rect(0 0 0 0);
    display: block;
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
  }

  .v2-shell .rail__menu {
    align-items: center;
    background: none;
    border: 0;
    border-radius: var(--radius-full);
    color: var(--color-text-subtle);
    cursor: pointer;
    display: flex;
    justify-content: center;
    margin-top: auto;
    transition: background-color var(--ds-motion-fast), color var(--ds-motion-fast);
  }

  .v2-shell .rail__menu:hover {
    background: var(--ds-fill);
    color: var(--color-text);
  }

  .v2-shell .rail__menu .icon {
    height: var(--nav-icon);
    width: var(--nav-icon);
  }


  .v2-shell .main,
  .v2-shell.no-bottom-bar .main {
    padding-bottom: 0;
  }

  /* Le logo et la navigation sont dans le rail : pas de Meni ni de logo dans l'en-tête */
  .v2-shell .btn-hamburger,
  .v2-shell .navbar-logo {
    display: none;
  }

  /* La colonne en carte : un seul rectangle bordé aux coins arrondis contient tout le fil ;
     les pòs gardent leur trait de séparation. L'en-tête reste au-dessus, sur le fond de la page. */
  .v2-shell .main {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-6);
    min-height: calc(100dvh - var(--ds-size-nav) - var(--space-6));
    overflow: clip;
  }

  /* Pas de filet : c'est le haut de la carte qui sépare l'en-tête du fil */
  .v2-shell .navbar {
    border-bottom: 0;
  }

  /* Le haut de la carte ne bouge pas au défilement, comme un chambranle : l'en-tête porte son filet
     et ses coins arrondis, le fil passe dessous. ::before masque le fil hors des coins, ::after
     dessine le haut de la carte (au repos, il se pose exactement sur le haut de .main). */
  .v2-shell .navbar::before,
  .v2-shell .navbar::after {
    content: '';
    height: var(--radius-lg);
    left: 0;
    pointer-events: none;
    position: absolute;
    right: 0;
    top: 100%;
  }

  .v2-shell .navbar::before {
    background: var(--color-bg);
  }

  .v2-shell .navbar::after {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-bottom: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  /* La barre de réponse ferme le bas de la carte */
  .v2-shell .reply-bar {
    border-top: 1px solid var(--color-border);
  }

  /* (+) Pibliye : seul élément de la zone droite, centré dans celle-ci (élément flottant : .ds-floating) */
  .v2-shell .side-fab {
    align-items: center;
    bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
    color: var(--color-text);
    display: flex;
    height: 60px;
    justify-content: center;
    left: calc(var(--col-left) + var(--col-w) + (100vw - var(--col-left) - var(--col-w) - 60px) / 2);
    position: fixed;
    text-decoration: none;
    width: 60px;
    z-index: var(--ds-z-sticky);
  }

  .v2-shell .side-fab:hover {
    background: var(--ds-fill);
  }

  .v2-shell .side-fab .icon {
    height: var(--nav-icon);
    width: var(--nav-icon);
  }
}

/* ── 768–1279px : le libellé masqué devient une infobulle au survol / au focus clavier ── */
@media (min-width: 768px) and (max-width: 1279px) {
  .v2-shell .bottom-nav__item {
    position: relative;
  }

  .v2-shell .bottom-nav__item:hover .nav-label,
  .v2-shell .bottom-nav__item:focus-visible .nav-label {
    background: var(--ds-band);
    border-radius: var(--radius-sm);
    clip: auto;
    color: var(--ds-band-text);
    font-size: var(--ds-font-size-xs);
    font-weight: var(--ds-font-weight-semibold);
    height: auto;
    left: calc(100% + var(--space-2));
    line-height: 1;
    overflow: visible;
    padding: var(--space-1) var(--space-2);
    pointer-events: none;
    top: 50%;
    transform: translateY(-50%);
    width: auto;
    z-index: var(--ds-z-raised);
  }
}

/* ── ≥ 1280px : barre latérale avec libellés et liens en bas, sans Meni ── */
@media (min-width: 1280px) {
  .v2-shell .bottom-nav,
  .v2-shell .bottom-nav--rail-only {
    align-items: stretch;
    padding: 0 var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
  }

  .v2-shell .rail__brand {
    justify-content: flex-start;
    padding: 0 var(--space-3);
    width: auto;
  }

  .v2-shell .rail__name {
    display: inline;
    font-size: var(--ds-font-size-lg);
    font-weight: var(--ds-font-weight-semibold);
  }

  .v2-shell .rail__items {
    align-items: stretch;
    gap: 0;
    max-width: 244px;
  }

  .v2-shell .bottom-nav__item {
    font-size: var(--ds-font-size-sm);
    gap: var(--space-3);
    height: 48px;
    justify-content: flex-start;
    padding: 0 var(--space-3);
    width: auto;
  }

  .v2-shell .nav-label {
    clip: auto;
    display: inline;
    height: auto;
    overflow: visible;
    position: static;
    width: auto;
  }

  .v2-shell .rail__menu,
  .v2-shell .hamburger-panel,
  .v2-shell .hamburger-overlay {
    display: none;
  }

  /* Liens (ancien contenu du tiroir) */
  .v2-shell .rail__footer {
    color: var(--color-text-subtle);
    display: flex;
    flex-wrap: wrap;
    font-size: var(--ds-font-size-xs);
    gap: var(--space-1) var(--space-3);
    line-height: var(--ds-line-height-prose);
    margin-top: auto;
    padding: 0 var(--space-3);
  }

  .v2-shell .rail__footer a {
    color: var(--color-text-muted);
    text-decoration: none;
  }

  .v2-shell .rail__footer a:hover {
    color: var(--color-text);
  }

  .v2-shell .rail__footer span {
    flex-basis: 100%;
  }

  /* ── Zone droite : suggestions, au-dessus du (+) Pibliye ── */
  .v2-shell .right-rail {
    bottom: calc(2 * var(--space-6) + 60px + env(safe-area-inset-bottom)); /* laisse la place au (+) de 60 px */
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    left: calc(var(--col-left) + var(--col-w) + var(--space-6));
    overflow-y: auto;
    position: fixed;
    scrollbar-width: none;
    top: var(--ds-size-nav);
    width: min(320px, 100vw - var(--col-left) - var(--col-w) - 2 * var(--space-6));
    z-index: var(--ds-z-sticky);
  }

  .v2-shell .right-rail__card {
    padding: var(--space-3) 0 var(--space-2);
  }

  .v2-shell .right-rail__title {
    color: var(--color-text);
    font-size: var(--ds-font-size-md);
    font-weight: var(--ds-font-weight-semibold);
    margin: 0 0 var(--space-1);
    padding: 0 var(--space-4);
  }

  .v2-shell .right-rail__text {
    color: var(--color-text-muted);
    font-size: var(--ds-font-size-sm);
    line-height: var(--ds-line-height-body);
    margin: 0 0 var(--space-3);
    padding: 0 var(--space-4);
  }

  .v2-shell .right-rail__actions {
    display: flex;
    gap: var(--space-2);
    padding: 0 var(--space-4) var(--space-3);
  }

  .v2-shell .right-rail__row {
    padding: var(--space-2) var(--space-4);
  }

  .v2-shell .right-rail__row .search-person__avatar {
    height: 36px;
    width: 36px;
  }

  .v2-shell .right-rail__cat-icon .icon {
    color: var(--color-accent);
  }
}
