/* css/header.css - All header-related styles */

/* =========================
   HEADER (plus compact + plus dark)
========================= */
header{
  background: var(--header-violet-dark);
  color:#fff;
  height: 84px;
  padding: 0 1.25rem;
  display:flex;
  justify-content:space-between;
  align-items:center;
  box-shadow: 0 8px 18px rgba(0,0,0,.35);
  position: sticky;
  top: 0;
  z-index: 2000;
  margin: 0 !important;
}

.logo-link{
  display:flex;
  align-items:center;
  padding-left: 2rem;
}

.logo-img{
  height: 54px;
  width:auto;
  cursor: pointer;
}

nav{
  display:flex;
  gap: 1.6rem;
  align-items:center;
}

nav a{
  color:#fff;
  text-decoration:none;
  font-weight:600;
  letter-spacing:.02em;
  transition: color .2s, text-shadow .2s, opacity .2s;
  opacity:.92;
  cursor: pointer;
}

nav a:hover{
  opacity: 1;
  color: var(--brand-violet);
  text-shadow: none;
}

/* Chapter page nav styling to match index */
.chapter-nav-right{
  display:flex;
  gap: 1.6rem;
  align-items:center;
}

.chapter-nav-right a{
  color:#fff;
  text-decoration:none;
  font-weight:600;
  letter-spacing:.02em;
  transition: color .2s, text-shadow .2s, opacity .2s;
  opacity:.92;
  cursor: pointer;
}

.chapter-nav-right a:hover{
  opacity: 1;
  color: var(--brand-violet);
  text-shadow: none;
}

/* =========================
   LANGUAGE SELECTOR
========================= */
.language-selector{ position:relative; }

.lang-button{
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color:#fff;
  cursor:pointer;
  padding:.45rem .75rem;
  border-radius: 10px;
  font-weight:700;
  display:flex;
  align-items:center;
  gap:.5rem;
  transition: background .2s, border-color .2s, transform .12s;
}

.lang-button:hover{
  background: rgba(255,255,255,0.12);
  border-color: rgba(70,227,107,.35);
  transform: translateY(-1px);
}

.arrow{ font-size:.7rem; opacity:.9; }

/* drapeaux */
.lang-flag,
.lang-item img{
  width: 22px;
  height: 16px;
  object-fit: cover;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}

.lang-dropdown{
  position:absolute;
  top:100%;
  right:0;
  margin-top:.55rem;
  background: rgba(11,11,15,.96);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  box-shadow: 0 14px 26px rgba(0,0,0,.35);
  display:none;
  flex-direction:column;
  min-width: 170px;
  overflow:hidden;
  z-index: 3000;
}

.lang-dropdown.show{ display:flex; }

.lang-item{
  background:none;
  border:none;
  color:#fff;
  cursor:pointer;
  padding:.75rem .95rem;
  text-align:left;
  display:flex;
  align-items:center;
  gap:10px;
  transition: background .2s, color .2s;
}

.lang-item:hover{
  background: rgba(184,124,255,.14);
  color: var(--brand-violet);
}



/* =========================
   CHAPTER TITLE BUTTON
   (same behavior as lang-button)
========================= */

.chapter-title-button{
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color:#fff;
  cursor:pointer;
  padding:.45rem .75rem;
  border-radius: 10px;
  font-weight:700;
  display:flex;
  align-items:center;
  gap:.5rem;
  transition: background .2s, border-color .2s, transform .12s;
}

.chapter-title-button:hover{
  background: rgba(255,255,255,0.12);
  border-color: rgba(70,227,107,.35);
  transform: translateY(-1px);
}


/* =========================
   CHAPTER SELECTOR
========================= */
.chapter-selector{ position:relative; }

.chapter-button{
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color:#fff;
  cursor:pointer;
  padding:.45rem .75rem;
  border-radius: 10px;
  font-weight:700;
  display:flex;
  align-items:center;
  gap:.5rem;
  transition: background .2s, border-color .2s, transform .12s, color .2s;
  font-size: 1rem;
}

.chapter-button:hover{
  background: rgba(255,255,255,0.12);
  border-color: rgba(184,124,255,.35);
  color: var(--brand-violet);
  transform: translateY(-1px);
}

.chapter-dropdown{
  position:absolute;
  top:100%;
  left:50%;
  transform: translateX(-50%);
  margin-top:.55rem;
  background: rgba(11,11,15,.96);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  box-shadow: 0 14px 26px rgba(0,0,0,.35);
  display:none;
  flex-direction:column;
  min-width: 250px;
  overflow:hidden;
  z-index: 3000;
}

.chapter-dropdown.show{ display:flex; }

.chapter-item{
  background:none;
  border:none;
  color:#fff;
  cursor:pointer;
  padding:.75rem .95rem;
  text-align:left;
  display:block;
  transition: background .2s, color .2s;
  text-decoration: none;
  font-size: .95rem;
}

.chapter-item:hover{
  background: rgba(184,124,255,.14);
  color: var(--brand-violet);
}

/* =====================================================
   CHAPTER PAGE — HEADER SPÉCIFIQUE
===================================================== */

/* centre RÉEL du titre chapitre */
body.chapter-page .chapter-title-center{
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2100;
}



body.chapter-page .chapter-dropdown{
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: .5rem;
  background: rgba(11,11,15,.96);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  min-width: 240px;
  display: none;
  z-index: 3000;
}

body.chapter-page .chapter-dropdown.show{
  display: block;
}

body.chapter-page .chapter-item{
  padding: .75rem .95rem;
  cursor: pointer;
}

body.chapter-page .chapter-item:hover{
  background: rgba(184,124,255,.14);
  color: var(--brand-violet);
}

/* =========================
   RESPONSIVE HEADER
========================= */

@media (max-width: 900px) {
  .chapter-page header.chapter-header {
    grid-template-columns: auto 1fr;
    gap: 12px;
  }

  .chapter-page .chapter-nav-right {
    display: none;
  }
}

@media (max-width: 600px) {
  .chapter-page .chapter-title-button {
    font-size: 0.9rem;
    padding: 6px 14px;
  }
}

@media (max-width: 768px){
  /* Global phone compactness: reduce header and logo footprint */
  header{
    height: 64px;
    padding: 0.25rem 0.65rem;
  }

  .logo-link{
    padding-left: 0;
  }

  .logo-img{
    height: 38px;
  }

  /* Keep header navigation horizontal on phones */
  header > nav,
  header > .chapter-nav-right{
    flex-direction: row;
    align-items: center;
    gap: 0.55rem;
  }

  /* Index header: logo left, chapters centered, links + language right */
  body:not(.chapter-page) header{
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    column-gap: 0.5rem;
  }

  body:not(.chapter-page) header > nav{
    display: contents;
  }

  body:not(.chapter-page) #nav-chapters{
    grid-column: 2;
    justify-self: center;
    font-size: 0.88rem;
    line-height: 1.2;
    white-space: nowrap;
  }

  body:not(.chapter-page) #nav-links{
    grid-column: 3;
    justify-self: end;
    font-size: 0.82rem;
    line-height: 1.2;
    white-space: nowrap;
  }

  body:not(.chapter-page) .language-selector{
    grid-column: 4;
    justify-self: end;
  }

  /* Compact language selector: no full-width bar on phones */
  .lang-button{
    padding: 0.3rem 0.45rem;
    min-height: 32px;
    gap: 0.35rem;
    border-radius: 8px;
    font-size: 0.8rem;
  }

  .lang-flag{
    width: 18px;
    height: 13px;
  }

  .lang-dropdown{
    min-width: 132px;
  }

  .lang-item{
    padding: 0.58rem 0.7rem;
    font-size: 0.82rem;
  }

  .lang-item img{
    width: 18px;
    height: 13px;
  }

  /* Chapter pages: keep language + links usable while staying compact */
  body.chapter-page header{
    padding-left: 0.65rem;
    padding-right: 0.65rem;
  }

  body.chapter-page .chapter-nav-right{
    gap: 0.45rem;
  }

  body.chapter-page .chapter-nav-right > a{
    font-size: 0.78rem;
    line-height: 1.2;
    white-space: nowrap;
  }

  body.chapter-page .chapter-title-center{
    width: min(48vw, 220px);
  }

  body.chapter-page .chapter-title-button{
    max-width: 100%;
    padding: 0.32rem 0.5rem;
    font-size: 0.78rem;
    gap: 0.35rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.chapter-page .chapter-dropdown{
    min-width: 190px;
  }

  /* Chapter pages only (not contact/privacy): keep title and language clickable */
  body.chapter-page:not(.contact-page):not(.privacy-page) header{
    position: relative;
    display: flex;
    align-items: flex-start;
    padding-right: 0.55rem;
    min-height: 62px;
  }

  body.chapter-page:not(.contact-page):not(.privacy-page) .logo-link{
    align-self: flex-start;
    margin-top: 0.08rem;
    position: relative;
    z-index: 2400;
  }

  body.chapter-page:not(.contact-page):not(.privacy-page) .logo-img{
    height: 28px;
  }

  body.chapter-page:not(.contact-page):not(.privacy-page) .chapter-nav-right{
    display: flex;
    margin-left: auto;
    flex: 0 0 auto;
    position: relative;
    z-index: 2300;
    gap: 0;
    align-self: flex-start;
    margin-top: 0.08rem;
  }

  body.chapter-page:not(.contact-page):not(.privacy-page) .chapter-nav-right > a{
    display: none;
  }

  body.chapter-page:not(.contact-page):not(.privacy-page) .chapter-title-center{
    position: absolute;
    left: 46%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(40vw, 205px);
    max-width: calc(100% - 8.8rem);
    min-width: 0;
    z-index: 2200;
    pointer-events: auto;
  }

  body.chapter-page:not(.contact-page):not(.privacy-page) .chapter-title-button{
    width: 100%;
    justify-content: flex-start;
  }

  body.chapter-page:not(.contact-page):not(.privacy-page) #current-chapter-title{
    display: inline-block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.chapter-page:not(.contact-page):not(.privacy-page) .chapter-dropdown{
    left: 0;
    right: auto;
    transform: none;
    min-width: min(82vw, 220px);
    z-index: 2600;
  }
}

@media (max-width: 430px){
  body.chapter-page:not(.contact-page):not(.privacy-page) header{
    justify-content: flex-start;
    height: 60px;
    padding: 0.2rem 0.55rem;
    overflow: visible;
  }

  body.chapter-page:not(.contact-page):not(.privacy-page) .logo-link{
    flex: 0 0 auto;
    padding-left: 0;
  }

  body.chapter-page:not(.contact-page):not(.privacy-page) .logo-img{
    display: block;
    height: 24px;
  }

  body.chapter-page:not(.contact-page):not(.privacy-page) .chapter-title-center{
    left: 45%;
    width: min(42vw, 185px);
    max-width: calc(100% - 8.5rem);
  }

  body.chapter-page:not(.contact-page):not(.privacy-page) #current-chapter-title{
    display: inline-block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.chapter-page:not(.contact-page):not(.privacy-page) .chapter-title-button{
    width: 100%;
    max-width: 100%;
    justify-content: flex-start;
    padding: 0.3rem 0.42rem;
    font-size: 0.72rem;
    gap: 0.26rem;
    overflow: hidden;
  }

  body.chapter-page:not(.contact-page):not(.privacy-page) .chapter-title-button .arrow{
    flex-shrink: 0;
  }

  body.chapter-page:not(.contact-page):not(.privacy-page) .chapter-nav-right{
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0;
    margin-left: auto;
    z-index: 2300;
  }

  body.chapter-page:not(.contact-page):not(.privacy-page) .chapter-nav-right > a{
    display: none;
  }

  body.chapter-page:not(.contact-page):not(.privacy-page) .chapter-nav-right .lang-button{
    min-height: 30px;
    padding: 0.25rem 0.4rem;
  }

  body.chapter-page:not(.contact-page):not(.privacy-page) .chapter-dropdown{
    left: 0;
    right: auto;
    transform: none;
    min-width: min(82vw, 210px);
  }
}
