/* Lecteur de séance guidée (plein écran). Préfixe des classes : .pl- */

.pl {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  --pl-c: var(--accent);
  --pl-soft: var(--accent-soft);
  --pl-ring: min(68vw, 38dvh, 340px);
}
.pl[data-phase="rest"] { --pl-c: var(--ok); --pl-soft: var(--ok-soft); }
.pl[data-phase="prep"],
.pl[data-phase="switch"] { --pl-c: var(--warn); --pl-soft: var(--warn-soft); }

/* Halo de couleur de la phase en haut de l'écran. */
.pl::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(130% 55% at 50% 0%, var(--pl-soft), transparent 72%);
}

.pl-screen {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-top: var(--safe-top);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

.pl-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ───────── Barre du haut ───────── */

.pl-top {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 6px 8px;
}
.pl-icon-btn { flex: none; background: rgba(255, 255, 255, 0.06); }
.pl-top-mid { flex: 1; min-width: 0; padding: 0 4px; }
.pl-progress { height: 8px; }
.pl-progress > span { background: var(--pl-c); }
.pl-clock {
  flex: none;
  min-width: 52px;
  text-align: right;
  font-size: 18px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Rappel « Touche ici pour activer le son » (iOS après réouverture). */
.pl-hint {
  position: absolute;
  left: 50%;
  top: calc(var(--safe-top) + 62px);
  z-index: 2;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 32px);
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 200, 87, 0.4);
  background: #2e2614;
  color: var(--warn);
  font-size: 15px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.pl-hint[hidden] { display: none; }

/* ───────── Zone centrale ───────── */

.pl-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 2.2dvh, 22px);
  padding: 8px 20px;
  text-align: center;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
/* Centrage vertical sans couper le haut si le contenu déborde (marges auto). */
.pl-main > :first-child { margin-top: auto; }
.pl-main > :last-child { margin-bottom: auto; }

.pl-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}
.pl-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
}
.pl-meta-ex { font-size: 15px; font-weight: 600; color: var(--muted); }
.pl-set {
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--pl-soft);
  color: var(--pl-c);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.pl-name {
  max-width: 100%;
  font-size: clamp(26px, 8vw, 40px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  overflow-wrap: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pl-target { font-size: 18px; color: var(--muted); }
.pl-target strong { color: var(--text); font-weight: 750; }

.pl-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
}
.pl-link:active { background: var(--surface-3); }

/* ───────── Compteur de répétitions ───────── */

.pl-counter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 4.5vw, 28px);
  width: 100%;
}
.pl-round-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(64px, 19vw, 84px);
  height: clamp(64px, 19vw, 84px);
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, background 0.15s ease;
}
.pl-round-btn:active { transform: scale(0.94); background: var(--surface-3); }
.pl-count {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.pl-count-val {
  min-width: 1.3em;
  font-family: var(--font-display);
  font-size: clamp(80px, 26vw, 110px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  transition: color 0.15s ease;
}
.pl-count.is-big .pl-count-val { font-size: clamp(64px, 19vw, 84px); }
.pl-count.is-over .pl-count-val { color: var(--ok); }
.pl-count-unit { margin-top: 4px; font-size: 16px; font-weight: 600; color: var(--muted); white-space: nowrap; }

/* ───────── Anneau du minuteur ───────── */

.pl-ring {
  position: relative;
  flex: none;
  width: var(--pl-ring);
  height: var(--pl-ring);
}
.pl-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.pl-ring-track { fill: none; stroke: var(--surface-3); stroke-width: 7; }
.pl-ring-fg {
  fill: none;
  stroke: var(--pl-c);
  stroke-width: 7;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.25s linear, stroke 0.3s ease;
}
.pl-ring-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.pl-ring-num {
  font-family: var(--font-display);
  font-size: clamp(72px, calc(var(--pl-ring) * 0.36), 110px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.pl-ring-num.is-long { font-size: clamp(56px, calc(var(--pl-ring) * 0.26), 90px); }
.pl-ring-label {
  margin-top: 8px;
  max-width: 80%;
  font-size: clamp(14px, calc(var(--pl-ring) * 0.062), 20px);
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--pl-c);
}
.pl.is-paused .pl-ring-num { animation: pl-blink 1.6s ease-in-out infinite; }
@keyframes pl-blink { 50% { opacity: 0.35; } }

/* ───────── Repos ───────── */

.pl-phase-title {
  font-size: clamp(30px, 9vw, 44px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--pl-c);
}
.pl-next {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}
.pl-next-k {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.pl-next-name { font-size: 21px; font-weight: 750; line-height: 1.2; }
.pl-next-sub { font-size: 16px; color: var(--muted); }
.pl-next .pl-link { margin-top: 6px; }

/* ───────── Boutons du bas (zone du pouce) ───────── */

.pl-foot {
  flex: none;
  display: flex;
  gap: 10px;
  width: 100%;
  padding: 10px 16px calc(14px + var(--safe-bottom));
}
.pl-foot .btn {
  flex: 1;
  min-width: 0;
  min-height: 64px;
  padding: 0 10px;
  border-radius: 18px;
  font-size: clamp(16px, 4.8vw, 19px);
  white-space: nowrap;
  overflow: hidden;
}
.pl-foot .pl-btn-narrow { flex: 0 0 auto; padding: 0 18px; }
.pl-foot .pl-btn-icon { flex: 0 0 64px; padding: 0; gap: 0; }

/* ───────── Aperçu et résumé (contenu défilant) ───────── */

.pl-main.pl-scroll { align-items: stretch; text-align: left; gap: 18px; padding-top: 4px; }
.pl-scroll > * { width: 100%; max-width: 560px; margin-left: auto; margin-right: auto; }
.pl-main.pl-scroll > :first-child { margin-top: 0; }
.pl-main.pl-scroll > :last-child { margin-bottom: 16px; }

.pl-pv-head { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.pl-pv-title { font-size: clamp(28px, 8vw, 34px); font-weight: 800; letter-spacing: -0.02em; }
.pl-pv-meta { color: var(--muted); }
.pl-pv-list { list-style: none; margin: 0; padding: 0; }
.pl-pv-num {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 15px;
  font-weight: 750;
}
.pl-pv-info { flex: none; margin-right: -8px; color: var(--muted); }
.pl-pv-tip { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }

.pl-sum-head { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding-top: 8px; }
.pl-sum-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}
.pl-sum-title { font-size: 40px; font-weight: 850; letter-spacing: -0.02em; }
.pl-sum-banner {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--ok-soft);
  color: var(--ok);
  font-weight: 650;
  text-align: center;
}
.pl-sum-empty { text-align: center; color: var(--muted); }
.pl-block .section-title { margin-bottom: 10px; }
.pl-rec-trophy { flex: none; font-size: 22px; line-height: 1; }
.pl-rec-val { flex: none; color: var(--accent); font-size: 17px; }

.pl-feel { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pl-feel-btn {
  min-height: 56px;
  padding: 0 6px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.pl-feel-btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.pl-feel-help { margin-top: 8px; font-size: 14px; color: var(--muted); }

/* ───────── Feuille « Consignes » ───────── */

.pl-sheet {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 82vh;
  max-height: 82dvh;
  text-align: left;
}
.pl-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-right: -8px; }
.pl-sheet .pl-sheet-head h3 { margin: 0; }
.pl-sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pl-sheet-k {
  margin: 4px 0 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.pl-cues, .pl-errors { margin: 0 0 14px; padding-left: 22px; }
.pl-cues li + li, .pl-errors li + li { margin-top: 6px; }
.pl-errors li::marker { color: var(--danger); }

/* ───────── Écrans courts (iPhone SE dans Safari, paysage) ───────── */

@media (max-height: 640px) {
  .pl-main { gap: 10px; }
  .pl-name { -webkit-line-clamp: 1; font-size: clamp(24px, 7vw, 32px); }
  .pl-set { font-size: 18px; padding: 2px 12px; }
  .pl-target { font-size: 16px; }
  .pl-round-btn { width: 64px; height: 64px; }
  .pl-foot .btn { min-height: 58px; }
  .pl-foot .pl-btn-icon { flex-basis: 58px; }
  .pl-next { padding: 8px 14px; }
}

@media (max-height: 480px) {
  .pl { --pl-ring: min(46vw, 44dvh, 260px); }
  .pl-ring-num { font-size: clamp(56px, calc(var(--pl-ring) * 0.36), 96px); }
  .pl-count-val { font-size: 76px; }
  .pl-link { min-height: 40px; }
}

@media (min-width: 600px) {
  .pl-foot { max-width: 560px; margin: 0 auto; }
}
