/* Bottom navigation mobile-first 770jerusalem.com
   Empilee AU-DESSUS du sticky player existant.
   Nav 60px + sticky player 60px = 120px de padding bottom mobile.
*/

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
  display: flex;
  z-index: 1000;
  padding-bottom: env(safe-area-inset-bottom);
  font-family: "Heebo", system-ui, sans-serif;
  direction: rtl;
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: #6b7280;
  font-size: 11px;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav__item:hover,
.bottom-nav__item:focus-visible {
  color: #002e5c;
  outline: none;
}

.bottom-nav__item.active {
  color: #002e5c;
}

.bottom-nav__item svg {
  width: 24px;
  height: 24px;
  display: block;
}

.bottom-nav__label {
  font-family: inherit;
  line-height: 1;
}

/* Chevron sur l'item categories : masque par defaut (mobile) */
.bottom-nav__item .chevron {
  display: none;
}

/* Accordion masque par defaut (mobile) */
.sidebar-accordion {
  display: none;
}

@media (min-width: 769px) {
  .bottom-nav {
    top: 0;
    right: 0;
    left: auto;
    bottom: auto;
    width: 220px;
    height: 100vh;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 24px;
    padding-bottom: 0;
    gap: 4px;
    border-top: none;
    border-left: 1px solid #e5e7eb;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.04);
  }

  .bottom-nav__item[data-nav="listening"] {
    display: none;
  }

  .bottom-nav__item {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    margin: 0 12px;
    height: auto;
    font-size: 15px;
    border-radius: 8px;
    text-align: right;
  }

  .bottom-nav__item:hover {
    background: #f3f4f6;
    color: #002e5c;
  }

  .bottom-nav__item.active {
    background: #e0e7ff;
    color: #002e5c;
    font-weight: 600;
  }

  .bottom-nav__item svg {
    width: 22px;
    height: 22px;
  }

  body {
    padding-right: 220px;
    padding-bottom: 0;
  }
  body.has-sticky-player {
    padding-bottom: 88px;
  }

  #sticky-player {
    right: 220px !important;
  }

  /* Sidebar : conteneur scrollable global pour accommoder l'accordeon */
  .bottom-nav {
    overflow-y: auto;
  }

  /* Reorder desktop : home / search / categories(+ accordeon) / listening */
  .bottom-nav__item[data-nav="home"]       { order: 1; }
  .bottom-nav__item[data-nav="search"]     { order: 2; }
  .bottom-nav__item[data-nav="categories"] { order: 3; }
  #sidebar-categories-accordion            { order: 4; }
  .bottom-nav__item[data-nav="listening"]  { order: 5; }

  /* Chevron visible en desktop sur l'item toggle */
  .bottom-nav__item[data-toggle] .chevron {
    display: block;
    width: 16px !important;
    height: 16px !important;
    margin-right: auto;
    transition: transform 0.2s ease;
  }
  .bottom-nav__item[data-toggle].open .chevron {
    transform: rotate(180deg);
  }

  /* Accordion : masque par defaut, ouvert avec .open */
  .sidebar-accordion {
    display: block;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
    margin: 0 12px;
  }
  .sidebar-accordion.open {
    max-height: calc(100vh - 280px);
    overflow-y: auto;
  }
  .sidebar-accordion h3 {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    padding: 12px 8px 6px;
    margin: 0;
    letter-spacing: 0.04em;
  }
  .sidebar-accordion ul {
    list-style: none;
    padding: 0;
    margin: 0 0 8px 0;
  }
  .sidebar-accordion li a {
    display: block;
    padding: 8px 12px;
    font-size: 14px;
    color: #374151;
    text-decoration: none;
    border-radius: 6px;
    margin: 0;
    transition: background-color 120ms, color 120ms;
  }
  .sidebar-accordion li a:hover {
    background: #f3f4f6;
    color: #002e5c;
  }
  .sidebar-accordion li a.active,
  .sidebar-accordion li a.is-active {
    background: #e0e7ff;
    color: #002e5c;
    font-weight: 600;
  }
  .sidebar-accordion .cat-count {
    color: #9ca3af;
    font-weight: 400;
    margin-right: 4px;
  }

  /* Sections imbriquees : speakers, parashiyot */
  .sidebar-accordion .sidebar-section {
    margin-bottom: 4px;
  }
  .sidebar-accordion .sidebar-section-title {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    padding: 12px 8px 6px;
    margin: 0;
    letter-spacing: 0.04em;
  }
  .sidebar-accordion .sidebar-section-toggle,
  .sidebar-accordion .sidebar-subsection-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: transparent;
    border: none;
    padding: 10px 8px;
    margin: 0;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    text-align: right;
    direction: rtl;
    border-radius: 6px;
    transition: background-color 120ms;
  }
  .sidebar-accordion .sidebar-subsection-toggle {
    text-transform: none;
    font-size: 13px;
    color: #374151;
    padding: 8px 12px;
  }
  .sidebar-accordion .sidebar-section-toggle:hover,
  .sidebar-accordion .sidebar-subsection-toggle:hover {
    background: #f3f4f6;
    color: #002e5c;
  }
  .sidebar-accordion .sidebar-section-toggle .chevron,
  .sidebar-accordion .sidebar-subsection-toggle .chevron {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    transition: transform 0.2s ease;
  }
  .sidebar-accordion .sidebar-section[data-open="true"] > .sidebar-section-toggle .chevron,
  .sidebar-accordion .sidebar-subsection[data-open="true"] > .sidebar-subsection-toggle .chevron {
    transform: rotate(180deg);
  }

  /* Repli : cache contenu quand data-open=false */
  .sidebar-accordion .sidebar-section[data-open="false"] > .sidebar-list,
  .sidebar-accordion .sidebar-section[data-open="false"] > .sidebar-subsections {
    display: none;
  }
  .sidebar-accordion .sidebar-subsection[data-open="false"] > .sidebar-list {
    display: none;
  }

  /* Subsections (livres parashiyot) : indentation */
  .sidebar-accordion .sidebar-subsections {
    padding: 0;
  }
  .sidebar-accordion .sidebar-subsection {
    margin-bottom: 2px;
  }
  .sidebar-accordion .sidebar-subsection > .sidebar-list {
    padding-right: 12px;
  }
  .sidebar-accordion .sidebar-subsection > .sidebar-list li a {
    font-size: 13px;
    padding: 6px 10px;
  }
}

@media (max-width: 768px) {
  body {
    padding-bottom: calc(120px + env(safe-area-inset-bottom));
  }
  body.has-sticky-player {
    padding-bottom: calc(120px + env(safe-area-inset-bottom));
  }
  #sticky-player {
    bottom: calc(60px + env(safe-area-inset-bottom)) !important;
  }
}

/* Banniere + tagline globales (header unifie) */
.site-header {
  width: 100%;
  background: #fff;
}

.site-banner-link {
  display: block;
  width: 100%;
  text-decoration: none;
  line-height: 0;
}

.site-banner {
  width: 100%;
  height: auto;
  max-width: 1200px;
  display: block;
  margin: 0 auto;
}

.site-tagline {
  text-align: center;
  font-size: 18px;
  font-weight: 500;
  color: #002e5c;
  margin: 8px 16px 16px;
  direction: rtl;
  line-height: 1.4;
}

@media (min-width: 769px) {
  .site-banner-link { padding: 16px 24px 0; }
  .site-tagline { font-size: 22px; margin: 12px 24px 20px; }
}

@media (min-width: 769px) {
  .sidebar-section-toggle,
  .sidebar-section-title,
  .sidebar-section--always-open > h3 {
    background: #e0e7ff;
    color: #002e5c;
    font-weight: 600;
    border-radius: 8px;
    padding: 10px 16px;
    margin: 12px 12px 6px;
    width: calc(100% - 24px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: none;
    cursor: pointer;
    text-align: right;
    font-family: inherit;
    font-size: 15px;
    transition: background-color 120ms;
  }
  
  .sidebar-section--always-open > h3 {
    cursor: default;
  }
  
  .sidebar-section-toggle:hover {
    background: #c7d2fe;
  }
  
  .sidebar-section-toggle .chevron {
    transition: transform 200ms;
  }
  
  .sidebar-section[data-open="true"] > .sidebar-section-toggle .chevron {
    transform: rotate(180deg);
  }
}

/* === Headers de section sidebar : fond bleu cohérent avec items actifs === */
@media (min-width: 769px) {
  .sidebar-section-title,
  .sidebar-section-toggle {
    background: #e0e7ff !important;
    color: #002e5c !important;
    font-weight: 700 !important;
    font-size: 15px !important;
    border-radius: 8px;
    padding: 2px 16px; line-height: 1.1;
    margin: 12px 12px 6px;
    width: calc(100% - 24px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: none;
    cursor: pointer;
    text-align: right;
    font-family: inherit;
    transition: background-color 120ms;
    box-sizing: border-box;
  }
  
  .sidebar-section-title {
    cursor: default;
  }
  
  .sidebar-section-toggle:hover {
    background: #c7d2fe !important;
  }
  
  .sidebar-section-toggle .chevron,
  .sidebar-subsection-toggle .chevron {
    transition: transform 200ms;
  }
  
  .sidebar-section[data-open="true"] > .sidebar-section-toggle .chevron,
  .sidebar-subsection[data-open="true"] > .sidebar-subsection-toggle .chevron {
    transform: rotate(180deg);
  }
}


/* === Override final hauteur compacte === */
@media (min-width: 769px) {
  .sidebar-section-title,
  .sidebar-section-toggle {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
    line-height: 1 !important;
    min-height: 0 !important;
  }
}

/* === Fix largeur header sujets + affinage padding items actifs === */
@media (min-width: 769px) {
  .sidebar-section-title {
    width: calc(100% - 24px) !important;
    box-sizing: border-box !important;
  }
  
  /* Items actifs (catégories) : padding plus fin */
  .bottom-nav__item.active,
  .sidebar-list a.is-active,
  .sidebar-list a.active,
  .sidebar-list .active {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
  }
}

/* === Override final hauteur compacte === */
@media (min-width: 769px) {
  .sidebar-section-title,
  .sidebar-section-toggle {
    padding-top: 2px !important;
    padding-bottom: 2px !important;
    line-height: 1 !important;
    min-height: 0 !important;
  }
}

/* === Items actifs : pas de fond bleu, juste bold === */
@media (min-width: 769px) {
  .sidebar-list a.is-active,
  .sidebar-list a.active {
    background: transparent !important;
    font-weight: 700 !important;
    color: #002e5c !important;
  }
}
