/* =========================================================================
   Certification Hermes — Bibliothèque audio
   Charte Chatton System
   Palette : #001524 (Bleu Nuit) · #00E5FF (Cyan Électrique) · #E0E6ED (Gris Acier)
   Typographie : Liberation Serif (fallback serif élégant)
   ========================================================================= */

:root {
  --bg: #001524;
  --bg-elev: #022133;
  --bg-elev-2: #03324a;
  --cyan: #00E5FF;
  --cyan-dim: rgba(0, 229, 255, 0.35);
  --steel: #E0E6ED;
  --steel-dim: #8FA3B5;
  --white: #FFFFFF;
  --serif: "Liberation Serif", "DejaVu Serif", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--steel);
  font-family: var(--serif);
  line-height: 1.5;
  min-height: 100vh;
}

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(0, 229, 255, 0.06), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(0, 229, 255, 0.05), transparent 60%),
    var(--bg);
}

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--cyan-dim);
  background: linear-gradient(180deg, rgba(0, 229, 255, 0.04), transparent 80%);
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.4rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.4rem;
}
.header-inner .logo {
  height: 64px;
  width: auto;
  flex-shrink: 0;
  border: 1px solid var(--cyan-dim);
  border-radius: 6px;
  background: var(--bg);
}
.header-titles h1 {
  margin: 0;
  font-size: 1.9rem;
  letter-spacing: 0.5px;
  color: var(--white);
  font-weight: 700;
}
.header-titles h1::after {
  content: "";
  display: block;
  width: 56px;
  height: 2px;
  background: var(--cyan);
  margin-top: 0.35rem;
}
.subtitle {
  margin: 0.3rem 0 0;
  color: var(--cyan);
  font-size: 1rem;
  letter-spacing: 0.5px;
  font-style: italic;
}

/* ---------- Layout ---------- */
.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ---------- Lecteur global ---------- */
.global-player {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-elev);
  border: 1px solid var(--cyan);
  border-radius: 10px;
  padding: 0.9rem 1.1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "meta controls"
    "audio audio";
  gap: 0.5rem 1rem;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(0, 229, 255, 0.08);
  align-items: center;
}
.gp-meta { grid-area: meta; min-width: 0; }
.gp-now-label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--cyan);
  font-style: italic;
}
.gp-title {
  display: block;
  color: var(--white);
  font-size: 1.08rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#gp-audio {
  grid-area: audio;
  width: 100%;
  filter: invert(0.92) hue-rotate(160deg) saturate(1.2);
  border-radius: 6px;
}
.gp-controls {
  grid-area: controls;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.gp-controls button,
.gp-progress button {
  background: transparent;
  border: 1px solid var(--cyan-dim);
  color: var(--cyan);
  border-radius: 6px;
  width: 38px;
  height: 38px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.gp-controls button:hover,
.gp-progress button:hover {
  background: rgba(0, 229, 255, 0.12);
  border-color: var(--cyan);
  color: var(--white);
}
.gp-count {
  color: var(--steel-dim);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  margin-left: 0.3rem;
}
#gp-stop2 {
    width: auto;
    white-space: nowrap;
    min-width: max-content;
}

/* ---------- Progression de bloc ---------- */
.gp-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--bg-elev);
  border: 1px solid var(--cyan-dim);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  width: 100%;
  box-sizing: border-box;
}
.gp-progress-text {
  color: var(--steel-dim);
  font-size: 0.85rem;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
  text-align: right;
}
.link-btn {
  background: transparent;
  border: none;
  color: var(--cyan);
  cursor: pointer;
  font-family: var(--serif);
  font-size: 0.85rem;
  text-decoration: underline;
  white-space: nowrap;
  flex-shrink: 0;
}
.link-btn:hover { color: var(--white); }

/* ---------- Toolbar + filtre ---------- */
.tree-toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}
.toolbar-btn {
  background: transparent;
  border: 1px solid var(--cyan-dim);
  color: var(--steel);
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
  font-family: var(--serif);
  cursor: pointer;
  font-size: 0.88rem;
}
.toolbar-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}
.filter {
  flex: 1;
  min-width: 180px;
  background: var(--bg-elev);
  border: 1px solid var(--cyan-dim);
  color: var(--steel);
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
  font-family: var(--serif);
  font-size: 0.95rem;
}
.filter::placeholder { color: var(--steel-dim); }
.filter:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.15);
}
.results-count { color: var(--steel-dim); font-size: 0.85rem; }

/* ---------- Arbre ---------- */
.tree {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.node-block {
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--bg-elev);
  transition: border-color 0.18s, background 0.18s;
}
.node-block[open] {
  border-color: var(--cyan-dim);
  background: var(--bg-elev);
}

/* summary commun */
.node-block > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.5rem 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.node-block > summary::-webkit-details-marker { display: none; }
.node-block > summary::marker { content: ""; }

/* chevron */
.chev {
  display: inline-block;
  width: 1.1em;
  text-align: center;
  color: var(--cyan);
  font-size: 0.8rem;
  transition: transform 0.18s;
}
.node-block[open] > summary .chev { transform: rotate(90deg); }

/* niveau de profondeur */
.depth-0 { background: transparent; border: none; }
.depth-0 > summary { padding: 0.35rem 0.1rem; }
.depth-0 > summary .node-label { font-size: 1.15rem; font-weight: 700; color: var(--white); }
.depth-0[open] > summary .node-label { color: var(--cyan); }

.depth-1 { background: var(--bg-elev); }
.depth-1 > summary .node-label { font-size: 1.04rem; font-weight: 700; color: var(--steel); }
.depth-1[open] > summary .node-label { color: var(--white); }

.depth-2 { background: rgba(2, 33, 51, 0.5); }
.depth-2 > summary .node-label { font-size: 0.98rem; color: var(--steel); }

.depth-3 { background: rgba(3, 50, 74, 0.45); }
.depth-3 > summary .node-label { font-size: 0.95rem; color: var(--steel-dim); }

/* survol : titre s'illumine en cyan */
.node-block > summary:hover .node-label,
.node-block > summary:hover .node-id {
  color: var(--cyan);
}
.node-block > summary:hover {
  background: rgba(0, 229, 255, 0.07);
}

.node-id {
  color: var(--steel-dim);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.node-label { flex: 1; min-width: 0; }

/* compteur enfants */
.node-count {
  color: var(--steel-dim);
  font-size: 0.78rem;
  font-style: italic;
  white-space: nowrap;
  padding-left: 0.4rem;
}

/* ---------- Boutons par bloc ---------- */
.block-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: 0.6rem;
}
.play-block-btn {
  background: transparent;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  border-radius: 6px;
  padding: 0.22rem 0.6rem;
  font-family: var(--serif);
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.play-block-btn:hover {
  background: var(--cyan);
  color: var(--bg);
}
.play-block-btn.playing {
  background: var(--cyan);
  color: var(--bg);
  font-weight: 700;
}
.m3u-link {
  color: var(--steel-dim);
  text-decoration: none;
  font-size: 0.8rem;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
}
.m3u-link:hover { color: var(--cyan); border-color: var(--cyan-dim); }

/* ---------- Segment (feuille avec mp3) ---------- */
.segment {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.45rem 0.8rem 0.45rem 1.6rem;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
  flex-wrap: wrap;
}
.segment + .segment { margin-top: 0.25rem; }
.segment:hover { background: rgba(0, 229, 255, 0.05); }

.segment-title {
  flex: 1;
  min-width: 200px;
  color: var(--steel);
  font-size: 0.95rem;
}
.segment-title .seg-id {
  color: var(--steel-dim);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-right: 0.45rem;
}

/* lecteur individuel stylisé */
.segment audio {
  width: 260px;
  max-width: 50%;
  height: 34px;
  filter: invert(0.92) hue-rotate(160deg) saturate(1.2);
}

/* segment en cours de lecture : bordure cyan + glow */
.segment.is-current {
  border-color: var(--cyan);
  background: rgba(0, 229, 255, 0.08);
  box-shadow: 0 0 0 1px var(--cyan), 0 0 18px rgba(0, 229, 255, 0.18);
}
.segment.is-current .segment-title { color: var(--white); }
.segment.is-current .segment-title .seg-id { color: var(--cyan); }

/* ---------- Conteneurs enfants ---------- */
.children {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.35rem 0 0.5rem 1.1rem;
}

/* ---------- États filtrage ---------- */
.tree.filtering .node-block:not(.match):not(.has-match) { display: none; }
.tree.filtering .segment:not(.match) { display: none; }
mark.hl {
  background: rgba(0, 229, 255, 0.22);
  color: var(--white);
  border-radius: 2px;
  padding: 0 1px;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--cyan-dim);
  text-align: center;
  padding: 1.2rem;
  color: var(--steel-dim);
  font-size: 0.85rem;
  font-style: italic;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .global-player { grid-template-columns: 1fr; grid-template-areas: "meta" "controls" "audio"; }
  .segment { padding-left: 1rem; }
  .segment audio { width: 100%; max-width: 100%; }
  .header-inner { flex-direction: column; text-align: center; gap: 0.8rem; }
}