/* ============================================================
   Cantiques EUJC — Détail d'un cantique
   ============================================================ */

:root {
  --hymn-bg:        var(--bg-page);
  --hymn-bg-dark:   var(--accent-dark);
  --hymn-card:      var(--bg-elevated);
  --hymn-text:      var(--text-primary);
  --hymn-muted:     var(--text-secondary);
  --hymn-gold:      var(--accent-gold);
  --hymn-gold-soft: rgba(201, 164, 74, 0.18);
  --hymn-border:    var(--border-soft);
  --hymn-font-size: calc(17px * var(--text-scale, 1));
}

body {
  background: var(--hymn-bg);
}

.hymn-detail-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  /* Espace pour la barre d action (fixe) */
  padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
}

/* ------------------------------------------------------------
   Header
   ------------------------------------------------------------ */
.hymn-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px;
  background: var(--hymn-bg);
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 8px;
}

.hymn-detail-header .icon-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--hymn-text);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 120ms ease;
}

.hymn-detail-header .icon-button:active {
  background: var(--hover-teal-light);
}

.hymn-detail-header .icon-button svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
}

.hymn-detail-header .header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.hymn-detail-header #btn-favorite.is-active {
  color: var(--hymn-gold);
}
.hymn-detail-header #btn-favorite.is-active svg {
  fill: currentColor;
}

/* ------------------------------------------------------------
   Contenu principal
   ------------------------------------------------------------ */
#hymn-detail {
  flex: 1;
  padding: 8px 20px 24px;
}

/* --- Intro : numéro + titre + meta --- */
.hymn-detail-intro {
  margin-bottom: 20px;
}

.hymn-number-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--hymn-gold);
  letter-spacing: 1px;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.hymn-detail-intro h1 {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
  color: var(--hymn-text);
  margin: 0 0 8px;
  letter-spacing: -0.3px;
}

.hymn-metadata {
  font-size: 13.5px;
  color: var(--hymn-muted);
  margin: 0;
}

/* ------------------------------------------------------------
   Onglets de versions
   ------------------------------------------------------------ */
.version-tabs {
  display: flex;
  gap: 8px;
  margin: 18px 0 22px;
  padding-bottom: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.version-tabs::-webkit-scrollbar { display: none; }

.version-tab {
  flex: 0 0 auto;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--bg-elevated);
  color: var(--hymn-muted);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 140ms ease;
}

.version-tab:active { transform: scale(0.96); }

.version-tab.is-active {
  background: var(--hymn-bg-dark);
  color: var(--p-cream-100);   /* crème forcée pour contraste sur vert forêt */
}

/* ------------------------------------------------------------
   Blocs de paroles
   ------------------------------------------------------------ */
.hymn-lyrics {
  display: flex;
  flex-direction: column;
  gap: 20px;
  font-family: var(--font-body);
  font-size: var(--hymn-font-size);
  line-height: 1.65;
  color: var(--hymn-text);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.lyric-block {
  position: relative;
}

.lyric-block h2 {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--hymn-gold);
  margin: 0 0 8px;
}

.lyric-lines {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lyric-lines p {
  margin: 0;
  font-family: var(--font-body);
  line-height: 1.6;
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* --- Couplet numéroté (source_block / verse) --- */
.lyric-block-source_block,
.lyric-block-verse {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.lyric-block-source_block .lyric-lines,
.lyric-block-verse .lyric-lines {
  flex: 1;
}

.lyric-number {
  flex: 0 0 22px;
  padding-top: 1px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 15px;
  color: var(--hymn-text);
  text-align: right;
}

/* --- Refrain : bloc beige --- */
.lyric-block-refrain {
  background: var(--hymn-gold-soft);
  padding: 16px 18px;
  border-radius: 12px;
}

.lyric-block-refrain h2 {
  margin-bottom: 10px;
}

/* --- Commentaire : discret, en italique --- */
.lyric-block-comment {
  border-left: 3px solid var(--hymn-gold);
  padding-left: 12px;
  color: var(--hymn-muted);
}

.lyric-block-comment h2 {
  color: var(--hymn-muted);
}

/* ------------------------------------------------------------
   États vides / chargement
   ------------------------------------------------------------ */
.detail-loading,
.detail-empty {
  text-align: center;
  color: var(--hymn-muted);
  padding: 40px 20px;
  font-size: 14px;
}

/* ------------------------------------------------------------
   Barre d'action bas
   ------------------------------------------------------------ */
.hymn-action-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
  gap: 4px;
  /* Padding bas SANS safe-area (déjà géré par la bottom-nav en dessous) */
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  /* Même teinte que la bottom-nav pour continuité visuelle */
  background: var(--bg-page-translucent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--hymn-border);
  /* Ombre légère vers le haut pour décoller du contenu */
  box-shadow: 0 -4px 20px var(--shadow-soft);
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  border: none;
  background: transparent;
  color: var(--hymn-text);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 12px;
  transition: background 120ms ease;
}

.action-btn:active {
  background: var(--hover-teal-light);
}

.action-btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.action-btn-primary {
  color: var(--hymn-gold);
}

/* ------------------------------------------------------------
   Menu contextuel
   ------------------------------------------------------------ */
/* Styles migrés vers sheets.css (classe .sheet unifiée) */

.hymn-menu-sheet .menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-radius: 12px;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--hymn-text);
  text-align: left;
  cursor: pointer;
}

.hymn-menu-sheet .menu-item:active {
  background: var(--hover-teal-light);
}

.hymn-menu-sheet .menu-item svg {
  width: 20px;
  height: 20px;
  color: var(--hymn-muted);
  flex: 0 0 auto;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------
   Mode lecture (fond sombre)
   ------------------------------------------------------------ */
body.is-reading-mode {
  background: #0a0a0a;
  color: #f5f0e6;
}

body.is-reading-mode .hymn-detail-page {
  background: #0a0a0a;
}

body.is-reading-mode .hymn-detail-header,
body.is-reading-mode #hymn-detail,
body.is-reading-mode .hymn-detail-intro h1,
body.is-reading-mode .hymn-metadata,
body.is-reading-mode .hymn-lyrics,
body.is-reading-mode .lyric-number,
body.is-reading-mode .lyric-lines p {
  color: #f5f0e6;
  background: transparent;
}

body.is-reading-mode .hymn-detail-header {
  background: #0a0a0a;
}

body.is-reading-mode .hymn-number-label {
  color: #e4c37f;
}

body.is-reading-mode .icon-button {
  color: #f5f0e6;
}

body.is-reading-mode .lyric-block h2 {
  color: #e4c37f;
}

body.is-reading-mode .version-tab {
  background: rgba(245, 240, 230, 0.1);
  color: rgba(245, 240, 230, 0.7);
}

body.is-reading-mode .version-tab.is-active {
  background: #f5f0e6;
  color: #14392e;
}

body.is-reading-mode .lyric-block-refrain {
  background: rgba(184, 147, 90, 0.18);
}

body.is-reading-mode .hymn-action-bar {
  background: #141414;
  border-top-color: rgba(245, 240, 230, 0.1);
}

body.is-reading-mode .action-btn {
  color: #f5f0e6;
}

body.is-reading-mode .report-cta-btn {
  border-color: rgba(245, 240, 230, 0.25);
  color: rgba(245, 240, 230, 0.6);
}

body.is-reading-mode .report-cta-btn:active {
  color: #e4c37f;
  border-color: rgba(184, 147, 90, 0.5);
}

/* ------------------------------------------------------------
   Responsive
   ------------------------------------------------------------ */
@media (min-width: 768px) {
  #hymn-detail {
    max-width: 680px;
    margin: 0 auto;
    padding: 16px 32px 32px;
  }
  .hymn-detail-header {
    max-width: 680px;
    margin: 0 auto;
    padding: 16px 32px;
  }
  .hymn-detail-intro h1 {
    font-size: 32px;
  }
}

/* ============================================================
   BARRE "SIGNALER UN PROBLÈME" (ajoutée v13)
   ============================================================ */
.report-cta {
  padding: 16px 20px 8px;
  display: flex;
  justify-content: center;
}

.report-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px dashed rgba(13, 46, 34, 0.2);
  border-radius: 10px;
  background: transparent;
  color: #7a8580;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 140ms ease;
}

.report-cta-btn svg {
  width: 15px;
  height: 15px;
  stroke-width: 2;
}

.report-cta-btn:active {
  background: rgba(201, 164, 74, 0.08);
  border-color: rgba(201, 164, 74, 0.4);
  color: #9c7b2e;
}

/* Adaptation au mode lecture (fond sombre) */
body.is-reading-mode .report-cta-btn {
  border-color: rgba(245, 240, 230, 0.25);
  color: rgba(245, 240, 230, 0.6);
}

body.is-reading-mode .report-cta-btn:active {
  color: #e8c56a;
  border-color: rgba(201, 164, 74, 0.5);
}

/* ============================================================
   PANNEAU "AFFICHAGE" (taille + police)
   ============================================================ */
.text-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 70;
  animation: panelFadeIn 180ms ease;
}

.text-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 71;
  background: var(--bg-sheet);
  border-radius: 22px 22px 0 0;
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.15);
  animation: panelSlideUp 220ms ease;
  max-height: 85vh;
  overflow-y: auto;
  box-sizing: border-box;
  color: var(--text-primary);
}

.text-panel-handle {
  width: 40px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  margin: 4px auto 16px;
}

.text-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.text-panel-header h2 {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.text-panel-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.text-panel-close:active {
  background: var(--hover-teal-light);
}

.text-panel-close svg {
  width: 20px;
  height: 20px;
}

.text-panel-section {
  margin-bottom: 24px;
}

.text-panel-label {
  display: block;
  font-family: var(--font-heading);
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.text-panel-slider-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.text-panel-a {
  font-family: var(--font-heading);
  color: var(--text-secondary);
  font-weight: 700;
  flex: 0 0 auto;
}

.text-panel-a-small { font-size: 14px; }
.text-panel-a-large { font-size: 22px; color: var(--text-primary); }

#text-panel-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
  outline: none;
}

#text-panel-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-dark);
  border: 3px solid var(--bg-sheet);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

#text-panel-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-dark);
  border: 3px solid var(--bg-sheet);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.text-panel-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-tertiary);
  padding: 4px 4px 0;
}

.text-panel-fonts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.text-panel-font {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 14px;
  border: 2px solid var(--border-soft);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: all 140ms ease;
  -webkit-tap-highlight-color: transparent;
}

.text-panel-font:active {
  transform: scale(0.985);
}

.text-panel-font.is-active {
  border-color: var(--accent-dark);
  background: var(--hover-teal-light);
}

.text-panel-font-name {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.text-panel-font.is-active .text-panel-font-name {
  color: var(--accent-gold-text);
}

.text-panel-font-sample {
  font-size: 16px;
  color: var(--text-primary);
  line-height: 1.3;
}

@keyframes panelFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes panelSlideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* Share UI styles live in share/share.css. */

/* === iOS safe-area (encoche / Dynamic Island) === */
@supports (padding: env(safe-area-inset-top)) {
  .hymn-detail-header {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }
}

/* ============================================================
   Grands ecrans (1920px+) : lecteur plus large, plus confortable
   ============================================================ */
@media (min-width: 1920px) {
  .hymn-detail-page,
  #hymn-detail {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
  }
  .lyric-lines p {
    font-size: calc(18px * var(--text-scale, 1));
    line-height: 1.75;
  }
}
