/* Formation handpan Pandrum - feuille de style (mobile d'abord) */

@font-face {
  font-family: 'Montserrat';
  src: url('fonts/Montserrat.ttf') format('truetype-variations'),
       url('fonts/Montserrat.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0F1518;
  --surface: #1B2529;
  --slate: #2E3D44;
  --gold: #D9AE72;
  --gold-hover: #E5C08C;
  --on-gold: #11181B;
  --text: #F2F5F6;
  --muted: #9FB0B7;
  --danger: #F2A08F;

  --gutter: 16px;
  --card-w: min(78vw, 340px);
  --card-gap: 10px;
  --radius: 8px;
  --topbar-h: 56px;
  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: dark;
}

@media (min-width: 900px) {
  :root {
    --gutter: 48px;
    --card-w: 320px;
    --card-gap: 12px;
    --topbar-h: 68px;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; height: auto; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: inherit; -webkit-tap-highlight-color: transparent; }
svg { display: block; flex: none; }
[hidden] { display: none !important; }

:focus:not(:focus-visible) { outline: none; }
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 4px;
}
[tabindex="-1"]:focus { outline: none; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: fixed;
  left: 12px;
  top: -120px;
  z-index: 100;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--gold);
  color: var(--on-gold);
  font-weight: 700;
  text-decoration: none;
}
.skip:focus { top: calc(12px + env(safe-area-inset-top)); }

main:focus { outline: none; }

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 20px;
  border: 0;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.btn svg { width: 20px; height: 20px; }
.btn--primary { background: var(--gold); color: var(--on-gold); }
.btn--secondary { background: rgba(46, 61, 68, .85); color: var(--text); }
.btn--small { min-height: 44px; padding: 10px 16px; font-size: 14px; }

@media (hover: hover) {
  .btn--primary:hover { background: var(--gold-hover); }
  .btn--secondary:hover { background: #3A4D56; }
}

.btn--mark.is-done {
  background: transparent;
  color: var(--gold);
  box-shadow: inset 0 0 0 1.5px var(--gold);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
}
.icon-btn svg { width: 24px; height: 24px; }
@media (hover: hover) { .icon-btn:hover { background: rgba(46, 61, 68, .7); } }

.link-btn {
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  background: none;
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
}

.tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(217, 174, 114, .14);
  box-shadow: inset 0 0 0 1px rgba(217, 174, 114, .45);
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  line-height: 1.3;
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: middle;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .16em;
  line-height: 1.4;
  text-transform: uppercase;
}

.meter {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(46, 61, 68, .95);
}
.meter > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--gold);
}

.state {
  min-height: 60vh;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 32px var(--gutter);
  color: var(--muted);
  text-align: center;
}
.state--error { color: var(--danger); }

/* ---------- Barre du haut ---------- */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
  background-color: transparent;
  background-image: linear-gradient(to bottom, rgba(15, 21, 24, .85), rgba(15, 21, 24, 0));
  transition: background-color .25s ease, box-shadow .25s ease;
}
.topbar.is-solid {
  background-color: var(--bg);
  box-shadow: 0 1px 0 rgba(46, 61, 68, .7);
}

.topbar__left { display: flex; align-items: center; gap: 4px; min-width: 0; }
.topbar__left .icon-btn { margin-left: -10px; }

.topbar__logo {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 2px;
  border-radius: 4px;
}
.topbar__logo img { width: auto; height: 22px; }

@media (min-width: 900px) {
  .topbar__logo img { height: 28px; }
}

.lang { display: flex; align-items: center; }
.lang button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
}
.lang__code {
  display: block;
  width: 38px;
  padding: 6px 0;
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  line-height: 1.2;
  transition: background-color .15s ease, color .15s ease;
}
.lang button[aria-pressed="true"] .lang__code { background: var(--gold); color: var(--on-gold); }
@media (hover: hover) { .lang button:hover .lang__code { color: var(--text); } .lang button[aria-pressed="true"]:hover .lang__code { color: var(--on-gold); } }

/* ---------- Écran mot de passe ---------- */

.gate {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(72px + env(safe-area-inset-top)) var(--gutter) 48px;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(217, 174, 114, .13), rgba(15, 21, 24, 0) 62%),
    var(--bg);
}
.gate__lang {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 6px);
  right: max(calc(var(--gutter) - 6px), env(safe-area-inset-right));
}
.gate__card { width: 100%; max-width: 380px; text-align: center; }
.gate__logo { width: auto; height: 34px; margin: 0 auto 28px; }
.gate__title {
  margin: 0 0 28px;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
}
.field { text-align: left; }
.field label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.field__wrap { position: relative; }
.field input {
  width: 100%;
  min-height: 52px;
  padding: 12px 54px 12px 16px;
  border: 1px solid var(--slate);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px; /* évite le zoom automatique sur iPhone */
}
.field input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 10px; }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field__toggle { position: absolute; top: 4px; right: 4px; color: var(--muted); }
.field__toggle svg { width: 22px; height: 22px; }
.gate__error {
  min-height: 21px;
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
}
.gate__card .btn { width: 100%; margin-top: 14px; }
.gate__intro { margin: -14px 0 22px; color: var(--muted); font-size: 15px; }
.gate__card .field + .field { margin-top: 16px; }
.gate__card .field input { padding-right: 16px; }
.gate__card .field__wrap input { padding-right: 54px; }
.gate__hint { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.gate__switch { display: inline-block; margin-top: 18px; }
#gate-submit[aria-busy="true"] { opacity: .7; }

/* ---------- Accueil : image d'accueil ---------- */

.hero {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: min(74vh, 640px);
  min-height: min(74svh, 640px);
  padding: calc(var(--topbar-h) + env(safe-area-inset-top) + 24px) var(--gutter) 28px;
  overflow: hidden;
}
.hero__media {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to top,
    var(--bg) 0%,
    var(--bg) 4%,
    rgba(15, 21, 24, .93) 30%,
    rgba(15, 21, 24, .5) 58%,
    rgba(15, 21, 24, .3) 78%,
    rgba(15, 21, 24, .7) 100%);
}
.hero__content { max-width: 600px; }
.hero__title {
  margin: 0;
  font-size: clamp(28px, 7.6vw, 54px);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -.01em;
  text-wrap: balance;
}
.hero__meta {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}
.hero__progress { max-width: 340px; margin-top: 18px; }
.hero__progress p { margin: 0 0 7px; font-size: 13px; font-weight: 600; }
.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}
.hero__actions .btn { flex: 1 1 auto; }

@media (min-width: 900px) {
  .hero {
    min-height: min(82vh, 760px);
    padding-bottom: 64px;
  }
  .hero__media {
    left: auto;
    width: 70%;
    object-position: 45% 40%;
  }
  .hero::before {
    background:
      linear-gradient(90deg, var(--bg) 0%, var(--bg) 30%, rgba(15, 21, 24, .65) 45%, rgba(15, 21, 24, 0) 66%),
      linear-gradient(to top, var(--bg) 0%, var(--bg) 5%, rgba(15, 21, 24, .82) 14%, rgba(15, 21, 24, .4) 28%, rgba(15, 21, 24, 0) 44%),
      linear-gradient(to bottom, rgba(15, 21, 24, .65) 0%, rgba(15, 21, 24, 0) 22%);
  }
  .hero__meta { font-size: 15px; }
  .hero__actions .btn { flex: 0 0 auto; padding-inline: 26px; }
}

/* ---------- Accueil : rangées ---------- */

.rows {
  padding: 4px 0 calc(48px + env(safe-area-inset-bottom));
  scroll-margin-top: calc(var(--topbar-h) + env(safe-area-inset-top));
}
.rows:focus { outline: none; }

.row { margin-top: 26px; }
.row:first-child { margin-top: 8px; }

.row__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
  margin-bottom: 6px;
  padding: 0 var(--gutter);
}
.row__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}
.row__num { color: var(--gold); }
.row__meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.row__viewport { position: relative; }

.row__track {
  display: flex;
  gap: var(--card-gap);
  margin: 0;
  padding: 6px var(--gutter) 10px;
  list-style: none;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--gutter);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.row__track::-webkit-scrollbar { display: none; }

.row__item {
  flex: 0 0 var(--card-w);
  scroll-snap-align: start;
}

.card {
  display: block;
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
}
.card:focus-visible { outline: none; }
.card__media {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 0 0 1px rgba(46, 61, 68, .55);
  transition: transform .2s ease, box-shadow .2s ease;
}
.card:focus-visible .card__media { outline: 2px solid var(--gold); outline-offset: 3px; }
.card__media img { width: 100%; height: 100%; object-fit: cover; }

@media (hover: hover) and (pointer: fine) {
  .card:hover .card__media {
    transform: scale(1.025);
    box-shadow: 0 0 0 1px rgba(217, 174, 114, .65), 0 10px 24px rgba(0, 0, 0, .45);
  }
}

.card__badge {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px 4px 7px;
  border-radius: 999px;
  background: rgba(15, 21, 24, .88);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}
.card__badge svg { width: 14px; height: 14px; color: var(--gold); }

.card__bar {
  display: block;
  height: 3px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--slate);
}
.card__bar > span { display: block; height: 100%; background: var(--gold); }

/* Flèches des rangées : ordinateur uniquement */
.row__nav { display: none; }

@media (hover: hover) and (pointer: fine) and (min-width: 900px) {
  .row__nav {
    position: absolute;
    top: 6px;
    z-index: 2;
    display: grid;
    place-items: center;
    width: calc(var(--gutter) - 4px);
    height: calc(var(--card-w) * 9 / 16);
    padding: 0;
    border: 0;
    color: var(--text);
    opacity: .75;
    transition: opacity .2s ease, background-color .2s ease;
  }
  .row__nav svg { width: 30px; height: 30px; }
  .row__nav--prev {
    left: 0;
    border-radius: 0 var(--radius) var(--radius) 0;
    background: linear-gradient(90deg, rgba(15, 21, 24, .95), rgba(15, 21, 24, .55));
  }
  .row__nav--next {
    right: 0;
    border-radius: var(--radius) 0 0 var(--radius);
    background: linear-gradient(270deg, rgba(15, 21, 24, .95), rgba(15, 21, 24, .55));
  }
  .row:hover .row__nav, .row__nav:focus-visible { opacity: 1; }
  .row__nav:hover { color: var(--gold); }
  .row__nav:focus-visible { outline-offset: -2px; }
}

/* ---------- Lecteur ---------- */

.player {
  padding-top: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
}

.player__stage {
  position: relative;
  background: #000;
}
.player__video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}

.player__error {
  margin: 12px var(--gutter) 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgba(242, 160, 143, .1);
  color: var(--danger);
  font-size: 14px;
}

.player__info { padding: 16px var(--gutter) 0; }

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 14px;
  padding: 0 4px 0 12px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.player__title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.22;
}
.player__title .tag { margin-left: 6px; position: relative; top: -2px; }

.player__meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
}
.player__code { color: var(--gold); font-weight: 700; }

.player__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
.player__actions .btn { flex: 1 1 auto; }

/* Encart de fin de vidéo */
.upnext {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(15, 21, 24, .9);
  text-align: center;
}
.upnext__count {
  margin: 0;
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
}
.upnext__title {
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upnext__text { margin: 0; color: var(--muted); font-size: 14px; }
.upnext__timer {
  width: 140px;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--slate);
}
.upnext__timer > span {
  display: block;
  height: 100%;
  background: var(--gold);
  transform-origin: left center;
  animation: upnext-timer 5s linear forwards;
}
@keyframes upnext-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.upnext__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 4px; }

@media (min-width: 600px) {
  .upnext { gap: 12px; }
  .upnext__count { font-size: 14px; }
  .upnext__title { font-size: 20px; white-space: normal; max-width: 36ch; }
}

/* Liste « Dans ce chapitre » */
.episodes { padding: 28px var(--gutter) 0; }
.episodes__title {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 700;
}
.ep-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.ep {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 8px;
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
}
@media (hover: hover) { .ep:hover { background: rgba(27, 37, 41, .75); } }
.ep.is-current {
  background: var(--surface);
  box-shadow: inset 3px 0 0 var(--gold);
}
.ep:focus-visible { outline-offset: -2px; border-radius: 10px; }
.ep__thumb {
  position: relative;
  flex: 0 0 116px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface);
}
.ep__thumb img { width: 100%; height: 100%; object-fit: cover; }
.ep__bar {
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: rgba(46, 61, 68, .95);
}
.ep__bar > span { display: block; height: 100%; background: var(--gold); }
.ep__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.ep__code { color: var(--gold); font-size: 12px; font-weight: 700; line-height: 1.3; }
.ep__title {
  display: -webkit-box;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.ep__title .tag { margin-left: 4px; padding: 1px 6px; font-size: 10px; }
.ep.is-current .ep__title { color: var(--gold); }
.ep__dur { color: var(--muted); font-size: 12px; font-weight: 500; }
.ep__check {
  display: grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(217, 174, 114, .16);
  color: var(--gold);
}
.ep__check svg { width: 16px; height: 16px; }

.next-chapter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  margin: 22px var(--gutter) 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}
.next-chapter small {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.next-chapter strong { display: block; font-size: 16px; font-weight: 700; line-height: 1.3; }
.next-chapter svg { width: 24px; height: 24px; color: var(--gold); }
@media (hover: hover) { .next-chapter:hover { background: #22303A; } }

@media (min-width: 1024px) {
  .player {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 32px;
    align-items: start;
    max-width: 1600px;
    margin: 0 auto;
    padding: calc(var(--topbar-h) + 20px) var(--gutter) 56px;
  }
  .player__stage { overflow: hidden; border-radius: 12px; }
  .player__error { margin-inline: 0; }
  .player__info { padding: 22px 0 0; }
  .player__title { font-size: 30px; }
  .player__actions .btn { flex: 0 0 auto; }
  .player__aside {
    position: sticky;
    top: calc(var(--topbar-h) + 20px);
    max-height: calc(100vh - var(--topbar-h) - 40px);
    overflow-y: auto;
    padding: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--slate) transparent;
  }
  .episodes { padding: 0; }
  .next-chapter { margin: 18px 0 0; }
}

/* ---------- Mouvements réduits ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
  .upnext__timer { display: none; }
  .card:hover .card__media { transform: none; }
}
