@font-face{font-family:"DM Sans";font-style:normal;font-weight:100 1000;font-display:swap;src:url("/assets/dm-sans.woff2") format("woff2")}
@font-face{font-family:"Instrument Serif";font-style:normal;font-weight:400;font-display:swap;src:url("/assets/instrument-serif.woff2") format("woff2")}

:root {
  color-scheme: dark;
  --nuit: #10291f;      /* fond de scène, vert sapin */
  --tilleul: #d6ee99;   /* la balle et le temps */
  --craie: #eef3e6;     /* texte principal */
  --mousse: #a9bfae;    /* texte secondaire */
  --sol: #4d6b5c;       /* ligne de battue */
  --braise: #ffc98f;    /* attention, erreurs, focus */
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "DM Sans", Arial, sans-serif;
}

* { box-sizing: border-box }
[hidden] { display: none !important }
html, body { height: 100% }
body { margin: 0; background: var(--nuit); color: var(--craie); font: 17px/1.45 var(--sans); -webkit-text-size-adjust: 100% }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent }
:focus-visible { outline: 3px solid var(--braise); outline-offset: 4px }
p { margin: 0 }
.noscript { padding: 14px 20px; background: #ffc98f1c; color: var(--braise); font-weight: 600; text-align: center }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap }

#ecoute {
  height: 100vh;
  height: 100dvh;
  min-height: 540px;
  width: min(560px, 100%);
  margin-inline: auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  padding: max(14px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
           max(18px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  text-align: center;
}

/* En-tête : la marque et l'état de l'écoute, rien d'autre. */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px }
.brand { display: inline-flex; align-items: center; gap: 8px; font: 400 28px/1 var(--serif); letter-spacing: -.6px }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 13px; border-radius: 999px;
  background: #ffffff12; font-size: 14px; font-weight: 600; color: var(--craie) }
.pill b { width: 9px; height: 9px; border-radius: 50%; background: var(--mousse); opacity: .6 }
[data-state="starting"] .pill b, [data-state="searching"] .pill b { background: var(--braise); opacity: 1 }
[data-state="pulse"] .pill b { background: var(--tilleul); opacity: 1 }
[data-state="error"] .pill { color: var(--braise) }
[data-state="error"] .pill b { background: var(--braise); opacity: 1 }

/* La scène : une balle qui retombe sur la ligne de battue à chaque temps. */
.stage {
  /* Le rebond occupe toute la hauteur disponible, quel que soit l'écran. */
  container-type: size;
  --ball: clamp(64px, min(26vmin, 26cqh), 180px);
  --jump: max(40px, calc(100cqh - var(--ball) - 60px));
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  min-height: 200px; padding-top: 12px;
}
.air { position: relative; flex: 1 1 auto; min-height: 0; width: 100%; display: flex; justify-content: center; align-items: flex-end }
.ball {
  display: block; width: var(--ball); height: var(--ball); border-radius: 50%;
  background: var(--tilleul);
  box-shadow: inset 0 calc(var(--ball) * -.08) 0 #00000018;
  transform-origin: 50% 100%;
  transform: translateY(calc(var(--lift, 0) * var(--jump) * -1))
             scale(calc(1 + .07 * var(--glow, 0)), calc(1 - .1 * var(--glow, 0)));
  opacity: .26;
  will-change: transform, opacity;
}
[data-state="pulse"] .ball { opacity: max(.26, var(--opacity, 1)) }
.floor { position: relative; width: min(100%, calc(var(--ball) * 3.2)); height: 34px; border-top: 2px solid var(--sol) }
.shadow, .impact { position: absolute; left: 50%; top: -1px; border-radius: 50%; pointer-events: none }
.shadow { width: calc(var(--ball) * .9); height: 14px; margin-left: calc(var(--ball) * -.45);
  background: #00000040; transform: scaleX(calc(1 - .45 * var(--lift, 0))); opacity: calc(.9 - .5 * var(--lift, 0)) }
.impact { width: calc(var(--ball) * 2.1); height: 26px; margin-left: calc(var(--ball) * -1.05); top: -13px;
  background: radial-gradient(closest-side, var(--tilleul), transparent);
  opacity: var(--glow, 0) }
/* iOS 16.0 et 16.1 ignorent color-mix : la ligne garde alors sa couleur de base. */
@supports (color: color-mix(in srgb, red, blue)) {
  [data-state="pulse"] .floor { border-top-color: color-mix(in srgb, var(--sol), var(--tilleul) calc(var(--glow, 0) * 70%)) }
}

/* Lecture : le tempo, une phrase d'aide, et rien d'autre. */
.reading { display: grid; justify-items: center; gap: 10px; padding: 8px 0 18px; align-content: start }
.tempo { display: flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums }
.tempo[hidden] { display: flex !important; visibility: hidden }
#bpm { font: 400 64px/1 var(--serif); letter-spacing: -1px; color: var(--craie) }
.tempo abbr { text-decoration: none; font-size: 15px; font-weight: 650; color: var(--mousse) }
.hint { max-width: 30ch; min-height: 2.9em; font-size: 18px; font-weight: 450; color: var(--craie) }
[data-state="idle"] .hint, [data-state="starting"] .hint { color: var(--mousse) }
#level[hidden] { display: block !important; visibility: hidden }
#level { width: 96px; height: 6px; border: 0; border-radius: 6px; overflow: hidden; background: #ffffff1f; appearance: none }
#level::-webkit-meter-bar { height: 6px; border: 0; border-radius: 6px; background: #ffffff1f }
#level::-webkit-meter-optimum-value, #level::-webkit-meter-suboptimum-value, #level::-webkit-meter-even-less-good-value { background: var(--braise) }
#level::-moz-meter-bar { background: var(--braise) }
.error { max-width: 32ch; padding: 12px 16px; border-radius: 14px; background: #ffc98f1c; color: var(--braise); font-size: 16px; font-weight: 550 }

/* Actions : un seul grand bouton pour commencer, un petit pour arrêter. */
.actions { display: grid; justify-items: center; gap: 12px }
.listen { width: min(100%, 420px); min-height: 64px; padding: 14px 24px; border: 0; border-radius: 999px;
  background: var(--tilleul); color: var(--nuit); font-size: 21px; font-weight: 750; letter-spacing: -.2px }
.listen:hover { background: #e3f5b5 }
.listen:active { transform: translateY(1px) }
.stop { min-height: 48px; min-width: 148px; padding: 10px 22px; border: 1.5px solid #ffffff40; border-radius: 999px;
  background: transparent; font-size: 16px; font-weight: 650; color: var(--craie) }
.stop:hover { border-color: #ffffff80 }
.privacy { max-width: 34ch; font-size: 13px; color: var(--mousse) }

/* Réglage ponctuel, une fois par téléphone : replié par défaut, discret. */
.reglage { max-width: 34ch; font-size: 13px; color: var(--mousse) }
.reglage summary { min-height: 32px; padding: 6px 4px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; list-style: none }
.reglage summary::-webkit-details-marker { display: none }
.reglage[open] summary { color: var(--craie) }
.reglage p { margin: 4px 0 10px; font-size: 14px }
.reglage-actions { display: flex; align-items: center; justify-content: center; gap: 10px }
.reglage-actions button { min-height: 48px; min-width: 104px; padding: 8px 14px; border: 1.5px solid #ffffff40; border-radius: 999px;
  background: transparent; font-size: 15px; font-weight: 650; color: var(--craie) }
.reglage-actions output { min-width: 9ch; font-size: 14px; font-weight: 650; color: var(--craie); font-variant-numeric: tabular-nums }

@media (min-width: 700px) {
  body { font-size: 18px }
  #ecoute { padding-top: 28px; padding-bottom: 32px }
  .hint { font-size: 20px }
}
/* Réglage ouvert : la page s'allonge (on la fait défiler) au lieu de tout comprimer. */
#ecoute:has(.reglage[open]) { height: auto; min-height: 100dvh }
#ecoute:has(.reglage[open]) .stage { min-height: 260px }
#ecoute:has(.reglage[open]) .hint { display: none }

/* Téléphone couché sur un pupitre : la balle à gauche, le tempo et les boutons à droite. */
@media (orientation: landscape) and (max-height: 560px) {
  #ecoute { width: min(980px, 100%); min-height: 300px; column-gap: 28px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto;
    padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: max(10px, env(safe-area-inset-bottom)) }
  .top { grid-column: 1 / -1 }
  .stage { grid-column: 1; grid-row: 2 / 4; min-height: 0; padding-top: 4px }
  .reading { grid-column: 2; grid-row: 2; align-content: end; gap: 6px; padding: 0 0 10px }
  .actions { grid-column: 2; grid-row: 3; gap: 8px }
  #bpm { font-size: 48px }
  .hint { font-size: 16px; min-height: 0 }
  .listen { min-height: 56px; font-size: 19px }
  .privacy, .reglage { font-size: 12px }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important }
  .ball { transform: none }
  .shadow { transform: none }
}
