/* Lecteur interactif de cube (player.js). Mobile d'abord : 390 px de large.
   Les couleurs d'interface viennent des variables de Material (--md-*), avec
   une valeur de repli pour une page hors du theme. */

figure.cube-player.cp-on {
  width: 100%;
  max-width: 34rem;
  margin: 1.2rem auto;
  text-align: center;
}
/* sans JavaScript, l'image de secours reste ; avec, elle ne sert qu'a l'impression */
figure.cube-player.cp-on > img { display: none; }

.cp {
  --cp-s: 44px;                                  /* cote d'un cubie */
  --cp-fg: var(--md-default-fg-color, #1c1e22);
  --cp-bg: var(--md-default-bg-color, #fff);
  --cp-soft: var(--md-code-bg-color, #f2f3f5);
  --cp-line: var(--md-default-fg-color--lighter, rgba(0, 0, 0, .32));
  --cp-focus: var(--md-accent-fg-color, #e2531f);
  color: var(--cp-fg);
  border: 1px solid var(--cp-line);
  border-radius: 12px;
  padding: 0 .6rem .6rem;
  overflow: hidden;                              /* jamais de defilement horizontal */
}
@media (min-width: 600px) { .cp { --cp-s: 52px; } }

/* --- le cube ------------------------------------------------------------ */
.cp-scene {
  height: calc(var(--cp-s) * 5.7);
  position: relative;
  perspective: calc(var(--cp-s) * 28);
  touch-action: pan-y;                           /* le doigt peut toujours faire defiler la page */
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  border-radius: 8px;
}
.cp-scene:active { cursor: grabbing; }
.cp-cube, .cp-grp {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
}
.cp-grp { left: 0; top: 0; }
.cp-st, .cp-pl {
  position: absolute;
  box-sizing: border-box;
  background: #15171b;
}
.cp-st {
  /* 1 px de recouvrement : sans lui, un filet de la face opposee passe aux aretes */
  width: calc(var(--cp-s) + 1px);
  height: calc(var(--cp-s) + 1px);
  left: calc(var(--cp-s) / -2 - .5px);
  top: calc(var(--cp-s) / -2 - .5px);
}
.cp-st::before {                                 /* l'autocollant sur le plastique noir */
  content: "";
  position: absolute;
  inset: 5.5%;
  border-radius: 14%;
  background: var(--c, #8a9099);
}
.cp-pl {
  width: calc(var(--cp-s) * 3);
  height: calc(var(--cp-s) * 3);
  left: calc(var(--cp-s) * -1.5);
  top: calc(var(--cp-s) * -1.5);
  display: none;
}
.cp-cut .cp-pl { display: block; }

/* memes teintes que les schemas SVG (tools/render.py) */
.cp-st[data-c="Y"] { --c: #f5cf2e; }
.cp-st[data-c="W"] { --c: #f4f4f1; }
.cp-st[data-c="G"] { --c: #2ea44f; }
.cp-st[data-c="B"] { --c: #2f6fd0; }
.cp-st[data-c="O"] { --c: #ef8b22; }
.cp-st[data-c="R"] { --c: #d0342c; }
.cp-st[data-c="X"] { --c: #8a9099; }

/* --- symboles pour daltoniens : une forme par couleur ------------------- */
.cp-symbols .cp-st::after {
  content: "";
  position: absolute;
  inset: 27%;
  background: #15171b;
}
.cp-symbols .cp-st[data-c="X"]::after { content: none; }
.cp-symbols .cp-st[data-c="Y"]::after { border-radius: 50%; }                      /* disque */
.cp-symbols .cp-st[data-c="W"]::after {                                            /* anneau */
  border-radius: 50%; background: none; border: calc(var(--cp-s) * .07) solid #15171b;
}
.cp-symbols .cp-st[data-c="O"]::after {                                            /* losange */
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}
.cp-symbols .cp-st[data-c="G"]::after {                                            /* triangle */
  background: #fff; clip-path: polygon(50% 4%, 100% 96%, 0 96%);
}
.cp-symbols .cp-st[data-c="B"]::after { background: #fff; }                        /* carre */
.cp-symbols .cp-st[data-c="R"]::after {                                            /* croix */
  background: #fff;
  clip-path: polygon(35% 0, 65% 0, 65% 35%, 100% 35%, 100% 65%, 65% 65%, 65% 100%, 35% 100%, 35% 65%, 0 65%, 0 35%, 35% 35%);
}

/* --- annonce, sequence, commandes --------------------------------------- */
.cp-status {
  margin: 0 0 .5rem !important;
  min-height: 2.9em;                              /* deux lignes : rien ne saute */
  font-size: .85em;
  line-height: 1.45;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cp-seq, .cp-bar, .cp-opts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
}
.cp-bar, .cp-opts { margin-top: .6rem; }
.cp button, .cp select {
  font: inherit;
  color: var(--cp-fg);
  background: var(--cp-soft);
  border: 1px solid var(--cp-line);
  border-radius: 8px;
  min-width: 44px;
  min-height: 44px;                               /* cible tactile */
  margin: 0;
  padding: 0 .35rem;
  cursor: pointer;
}
.cp button { display: inline-flex; align-items: center; justify-content: center; }
.cp-tok {
  font-family: var(--md-code-font-family, ui-monospace, monospace), monospace !important;
  font-weight: 700 !important;
  font-size: .95em !important;
}
.cp .cp-tok {
  /* jetons de sequence : compacts, une sequence de 26 mouvements doit tenir
     en trois lignes sur un telephone. 32 px reste au-dessus du minimum
     WCAG 2.2 AA (24 px) ; les commandes principales gardent 44 px. */
  min-width: 34px;
  min-height: 34px;
  padding: 0 .3rem;
  background: transparent;
}
.cp-seq { gap: 3px; }
.cp-tok[aria-current] {
  background: var(--cp-fg);
  color: var(--cp-bg);
  border-color: transparent;
}
.cp-bar .cp-b { min-width: 52px; }
.cp-play { background: var(--cp-fg) !important; color: var(--cp-bg) !important; min-width: 64px !important; }
.cp-speed, .cp-sym {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 44px;
  font-size: .85em;
  cursor: pointer;
}
.cp-speed { margin-left: .4rem; }
.cp-sym input { width: 22px; height: 22px; margin: 0; accent-color: var(--cp-fg); }
.cp :focus-visible {
  outline: 3px solid var(--cp-focus);
  outline-offset: 2px;
}
.cp-scene:focus-visible { outline-offset: -3px; }
@media (hover: hover) {
  .cp button:hover, .cp select:hover { border-color: var(--cp-fg); }
}

@media print {
  figure.cube-player.cp-on > img { display: block; }
  .cp { display: none; }
}

/* « Mouvement suivant » est LE bouton du debutant, cube en main : plus large,
   bordure marquee, pour qu'on ne le confonde pas avec « Fin ». */
.cp .cp-bar .cp-next { min-width: 76px; border-width: 2px; border-color: var(--cp-fg); }
/* data-compact (accueil) : seulement le cube et les commandes de lecture */
figure.cube-player[data-compact] .cp-seq,
figure.cube-player[data-compact] .cp-opts { display: none; }
