/* =====================================================================
   Petits Points : l'atelier de broderie (préfixe ptp-)
   La barre, le plein écran et les infobulles sont dans css/games.css.
   ===================================================================== */

.ptp-jeu {
  --mg-jeu-largeur: 1204px;
  --mgb-fond: radial-gradient(90% 200% at 0% 0%, rgba(243, 185, 18, 0.16), transparent 55%), linear-gradient(100deg, #471a2b, #76283b 60%, #94402f);
  --mgb-accent: #f4c96f;
  --mgb-titre: linear-gradient(100deg, #fff6e0, #f4c96f);
  --mgb-police-titre: "Fraunces", Georgia, serif;
  --mgb-texte: #fbeedd;
  --mgb-doux: #e0b7a8;
  --mgb-filet: rgba(255, 233, 200, 0.2);
  --mg-stat-largeur: 4.6em;
  --mg-fs-fond: #21130c;
  --mg-bulle-fond: #3a1622;

  --ptp-papier: #f8f0dd;
  --ptp-encre: #3a2517;
  --ptp-laiton: #d9a441;
  --ptp-grenat: #76283b;
}

.ptp-jeu [hidden] {
  display: none !important;
}

.ptp-jeu .mg-barre-titre {
  font-style: italic;
  font-weight: 700;
}

/* Téléphone : le titre garde sa ligne, les boutons de l'atelier passent dessous */
@media (max-width: 599px) {
  .ptp-jeu .mg-barre {
    flex-wrap: wrap;
  }

  .mg-jeu.ptp-jeu .mg-barre-titre {
    flex: 1 0 100%;
    max-width: none;
    border-right: 0;
    overflow: visible;
  }
}

/* ---------- La table de travail : un noyer sous la lampe ---------- */
.ptp-zone {
  position: relative;
  box-sizing: border-box;
  align-self: center;
  width: min(var(--mg-barre-largeur, 1180px), calc(100vw - 24px));
  border-radius: 16px;
  overflow: hidden;
  background:
    radial-gradient(75% 90% at 50% 18%, rgba(255, 205, 140, 0.26), transparent 70%),
    radial-gradient(120% 120% at 50% 50%, transparent 55%, rgba(12, 5, 2, 0.55)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='500'%3E%3Cfilter id='b'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.006 .19' numOctaves='4' seed='11'/%3E%3CfeColorMatrix values='0 0 0 0 .1 0 0 0 0 .05 0 0 0 0 .02 0 0 0 1.5 -.45'/%3E%3C/filter%3E%3Crect width='900' height='500' filter='url(%23b)'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #5e3a22, #4a2c19);
  background-size: auto, auto, 900px 500px, auto;
  box-shadow: inset 0 0 0 1px rgba(255, 220, 170, 0.08), 0 12px 30px -14px rgba(40, 20, 8, 0.55);
}

.ptp-jeu.mg-fs .ptp-zone {
  align-self: stretch;
  width: auto;
  flex: 1;
  min-height: 0;
}

/* ---------- La courtepointe ---------- */
.ptp-courtepointe {
  position: absolute;
  inset: 12px;
  display: grid;
  grid-template-columns: 34px repeat(6, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr)) 48px;
  padding: 9px;
  border-radius: 8px;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0 3px, transparent 3px 7px),
    #6d2337;
  box-shadow: 0 16px 34px -10px rgba(10, 4, 1, 0.8), inset 0 0 0 1px rgba(255, 220, 190, 0.18);
}

.ptp-courtepointe::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1.5px dashed rgba(255, 236, 205, 0.55);
  border-radius: 6px;
  pointer-events: none;
}

.ptp-etiquette {
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  color: #f9e2c0;
  font: italic 500 0.86rem/1 "Fraunces", Georgia, serif;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
}

.ptp-carre {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  background-color: #b77;
  box-shadow: inset 0 0 0 1px rgba(60, 25, 10, 0.25), inset 0 0 14px rgba(60, 25, 10, 0.2);
  transition: transform 0.2s cubic-bezier(0.2, 1.4, 0.4, 1), box-shadow 0.2s, filter 0.2s;
}

/* Couture du carré */
.ptp-carre::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1.5px dashed rgba(255, 248, 228, 0.7);
  pointer-events: none;
}

.ptp-carre:hover,
.ptp-carre:focus-visible {
  z-index: 2;
  transform: scale(1.07) rotate(-0.6deg);
  outline: none;
  box-shadow: 0 12px 26px -6px rgba(15, 5, 0, 0.75), inset 0 0 0 1px rgba(60, 25, 10, 0.25);
}

.ptp-carre canvas {
  display: block;
  height: calc(100% - 22px);
  aspect-ratio: 1;
  max-width: calc(100% - 22px);
  object-fit: contain;
  border-radius: 2px;
  box-shadow: 0 1px 4px rgba(50, 20, 5, 0.5);
}

.ptp-carre.ptp-vient-finir {
  animation: ptp-pose 0.9s cubic-bezier(0.2, 1.4, 0.4, 1);
  z-index: 3;
}

@keyframes ptp-pose {
  0% { transform: scale(1.5) rotate(-5deg); }
  60% { transform: scale(0.97); }
  100% { transform: none; }
}

.ptp-carre .ptp-etoiles {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  margin: 0;
  padding: 0 6px 1px;
  border-radius: 8px;
  background: rgba(52, 22, 12, 0.86);
  font-size: 0.8rem;
  line-height: 1.3;
}

.ptp-carre-marque {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 0 6px;
  border-radius: 8px;
  background: var(--ptp-laiton);
  color: #2e1a0b;
  font: italic 700 0.68rem/1.45 "Fraunces", Georgia, serif;
}

/* Le bandeau du chef-d'œuvre, sous les carrés */
.ptp-bonus {
  grid-column: 1 / -1;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 0;
  margin: 5px 0 0;
  padding: 0 14px;
  border: 0;
  border-radius: 4px;
  background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0 4px, transparent 4px 9px), #4c1826;
  color: #e6c8a8;
  font: italic 500 0.92rem/1.1 "Fraunces", Georgia, serif;
  cursor: not-allowed;
  overflow: hidden;
}

.ptp-bonus strong,
.ptp-bonus > span:not(.ptp-bonus-sceau) {
  font-family: "Fraunces", Georgia, serif;
}

.ptp-bonus strong {
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
}

.ptp-bonus canvas {
  height: 40px;
  width: 40px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #c58a4b;
}

.ptp-bonus-sceau {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #a23c55, #5c1a2c);
  box-shadow: inset 0 0 0 2px rgba(255, 220, 190, 0.35);
  color: #f3d6b4;
  font: 700 0.95rem/28px "Fraunces", Georgia, serif;
  text-align: center;
}

.ptp-bonus-ouvert {
  background: linear-gradient(100deg, #8a5a14, #e0ab3f 45%, #f6d27c 55%, #8a5a14);
  color: #2e1a0b;
  cursor: pointer;
  transition: filter 0.2s, transform 0.2s;
}

.ptp-bonus-ouvert:hover,
.ptp-bonus-ouvert:focus-visible {
  filter: brightness(1.1);
  outline: none;
  transform: scale(1.01);
}

.ptp-bonus-ouvert .ptp-bonus-sceau {
  background: radial-gradient(circle at 35% 30%, #fff1c9, #c68c26);
  color: #5c1a2c;
}

/* Six tissus imprimés */
.ptp-tissu-0 { background: radial-gradient(circle at 50% 50%, #f2d9a6 0 2px, transparent 2.6px) 0 0/13px 13px, #c8603f; }
.ptp-tissu-1 { background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.28) 0 6px, transparent 6px 12px), repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.28) 0 6px, transparent 6px 12px), #3f7a8c; }
.ptp-tissu-2 { background: repeating-linear-gradient(90deg, #e8c070 0 5px, #dbab56 5px 10px, #f3dda8 10px 12px); }
.ptp-tissu-3 { background: radial-gradient(circle at 25% 25%, #fbeed6 0 1.6px, transparent 2px) 0 0/10px 10px, radial-gradient(circle at 75% 75%, #fbeed6 0 1.6px, transparent 2px) 0 0/10px 10px, #5e7f4e; }
.ptp-tissu-4 { background: repeating-linear-gradient(45deg, rgba(255, 240, 220, 0.36) 0 3px, transparent 3px 9px), #a23c55; }
.ptp-tissu-5 { background: radial-gradient(circle at 50% 50%, #f7b9a2 0 3px, transparent 3.6px) 0 0/18px 18px, radial-gradient(circle at 50% 50%, #f7b9a2 0 2px, transparent 2.5px) 9px 9px/18px 18px, #33527c; }

/* ---------- L'atelier ---------- */
.ptp-atelier {
  position: absolute;
  inset: 0;
}

.ptp-toile,
.ptp-aiguille {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.ptp-toile {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.ptp-aiguille {
  pointer-events: none;
  z-index: 5;
}

/* La fiche du modèle : une étiquette nouée */
.ptp-fiche {
  position: absolute;
  left: 14px;
  top: 22px;
  z-index: 2;
  box-sizing: border-box;
  width: 170px;
  padding: 26px 14px 14px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 .4 0 0 0 0 .3 0 0 0 0 .2 0 0 0 .1 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23p)'/%3E%3C/svg%3E"),
    #eadcb9;
  color: var(--ptp-encre);
  clip-path: polygon(22px 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 0 100%, 0 22px);
  transform: rotate(-1.6deg);
  transition: opacity 0.4s, transform 0.5s;
  text-align: center;
}

.ptp-fiche-trou {
  position: absolute;
  top: 9px;
  left: 50%;
  width: 11px;
  height: 11px;
  margin-left: -5.5px;
  border-radius: 50%;
  background: #3e2415;
  box-shadow: 0 0 0 2.5px var(--ptp-laiton);
}

.ptp-fiche p {
  margin: 0;
}

.ptp-fiche-num {
  font: 700 0.7rem/1.2 "Fraunces", Georgia, serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: pre-line;
  color: #8a5a39;
}

.ptp-fiche-nom {
  margin: 2px 0 10px !important;
  font: italic 700 1.12rem/1.15 "Fraunces", Georgia, serif;
}

.ptp-apercu {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  background: #f4ebd6;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(90, 60, 30, 0.3);
  image-rendering: pixelated;
}

.ptp-atelier:has(.ptp-fils-grand) .ptp-apercu {
  cursor: crosshair;
  touch-action: none;
}

.ptp-etoiles {
  margin: 8px 0 0;
  color: #cf9119;
  font-size: 1.15rem;
  letter-spacing: 0.1em;
  line-height: 1;
}

.ptp-etoiles i {
  font-style: normal;
  opacity: 0.25;
}

.ptp-etoiles-grandes {
  font-size: 2rem;
}

.ptp-fiche-record {
  margin-top: 6px !important;
  font: italic 500 0.78rem/1.25 "Fraunces", Georgia, serif;
  color: #7a5335;
}

/* Le présentoir à fils */
.ptp-fils {
  position: absolute;
  right: 12px;
  top: 12px;
  bottom: 12px;
  z-index: 2;
  width: 190px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  transition: opacity 0.4s;
}

/* Chef-d'œuvre : présentoir plus étroit, plus de place pour la toile */
.ptp-fils-grand {
  width: 132px;
}

.ptp-nav {
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
  margin-top: 2px;
}

.ptp-nav .ptp-outil {
  flex: 1 1 0;
  height: 38px;
  margin: 0;
  padding: 0;
  font: 700 1.2rem/1 "Fraunces", Georgia, serif;
}

.ptp-nav .ptp-outil.actif {
  transform: none;
}

.ptp-fils-grand .ptp-outil {
  flex-basis: 38px;
  padding: 0 4px;
  font-size: 0.86rem;
}

.ptp-fil {
  position: relative;
  display: block;
  flex: 0 1 50px;
  min-height: 26px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transition: transform 0.22s cubic-bezier(0.2, 1.5, 0.4, 1), opacity 0.3s, filter 0.2s;
  filter: drop-shadow(0 3px 3px rgba(10, 4, 1, 0.5));
}

.ptp-fil svg {
  display: block;
  width: 100%;
  height: 100%;
}

.ptp-fil:hover {
  transform: translateX(-4px);
}

.ptp-fil.actif {
  transform: translateX(-13px) scale(1.04);
  filter: drop-shadow(0 0 6px rgba(255, 215, 130, 0.65)) drop-shadow(0 4px 4px rgba(10, 4, 1, 0.5));
}

.ptp-fil.fini {
  opacity: 0.42;
}

.ptp-fil:focus-visible,
.ptp-outil:focus-visible {
  outline: 2px solid #ffe9bd;
  outline-offset: 1px;
}

.ptp-fil-bande {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-width: 44px;
  padding: 1px 4px;
  box-sizing: border-box;
  background: #fbf4e2;
  color: var(--ptp-encre);
  font: 700 0.86rem/1.3 "Fraunces", Georgia, serif;
  text-align: center;
  box-shadow: 0 1px 2px rgba(40, 20, 8, 0.5);
}

.ptp-fil-touche {
  position: absolute;
  left: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: rgba(30, 14, 6, 0.72);
  color: #fff4dd;
  font: 700 0.62rem/15px Arial, sans-serif;
  text-align: center;
}

.ptp-outil {
  position: relative;
  flex: 0 0 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
  padding: 0 10px;
  border: 1px solid rgba(255, 228, 190, 0.3);
  border-radius: 10px;
  background: rgba(30, 14, 6, 0.48);
  color: #fbeedd;
  font: italic 500 0.95rem/1 "Fraunces", Georgia, serif;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.ptp-outil:hover {
  background: rgba(30, 14, 6, 0.7);
}

.ptp-outil.actif {
  border-color: #ffd98a;
  background: #7a2c3f;
  transform: translateX(-6px);
}

.ptp-outil svg {
  width: 20px;
  height: 20px;
}

/* Le conseil de la couturière */
.ptp-souffle {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 6;
  transform: translateX(-50%);
  max-width: min(520px, 86%);
  padding: 8px 16px;
  border-radius: 20px;
  background: rgba(45, 19, 12, 0.94);
  color: #fff1d8;
  font: italic 500 0.98rem/1.25 "Fraunces", Georgia, serif;
  text-align: center;
  box-shadow: 0 8px 18px -6px rgba(0, 0, 0, 0.6);
  animation: ptp-monte 0.3s ease-out;
  pointer-events: none;
}

@keyframes ptp-monte {
  from { opacity: 0; transform: translate(-50%, 8px); }
}

/* La carte de fin */
.ptp-atelier.en-finale .ptp-fiche,
.ptp-atelier.en-finale .ptp-fils {
  opacity: 0;
  pointer-events: none;
}

.ptp-carte {
  position: absolute;
  z-index: 4;
  left: 77%;
  top: 50%;
  box-sizing: border-box;
  width: min(370px, 38%);
  min-width: 290px;
  padding: 26px 26px 22px;
  transform: translate(-50%, -50%) rotate(1deg);
  background: var(--ptp-papier);
  color: var(--ptp-encre);
  border-radius: 5px;
  text-align: center;
  box-shadow: 0 22px 42px -12px rgba(8, 3, 0, 0.8);
  animation: ptp-carte 0.55s cubic-bezier(0.2, 1.3, 0.4, 1);
}

.ptp-carte::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1.5px dashed rgba(118, 40, 59, 0.5);
  border-radius: 3px;
  pointer-events: none;
}

@keyframes ptp-carte {
  from { opacity: 0; transform: translate(-40%, -46%) rotate(5deg); }
}

.ptp-carte p {
  margin: 0;
}

.ptp-carte-sur {
  font: 700 0.72rem/1.2 "Fraunces", Georgia, serif;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ptp-grenat);
}

.ptp-carte h2 {
  margin: 6px 0 8px;
  color: var(--ptp-encre);
  font: italic 700 2.1rem/1.05 "Fraunces", Georgia, serif;
  border: 0;
  background: none;
}

.ptp-carte-mot {
  min-height: 2.5em;
  font: italic 500 1.03rem/1.28 "Fraunces", Georgia, serif;
  color: #68452d;
}

.ptp-carte .ptp-etoiles {
  margin: 12px 0 2px;
}

.ptp-carte-temps {
  font: italic 500 0.95rem/1.2 "Fraunces", Georgia, serif;
  color: #68452d;
}

.ptp-carte-actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin-top: 16px;
}

.ptp-carte-actions .mg-btn {
  font-family: "Fraunces", Georgia, serif;
}

.ptp-carte-actions .mg-btn:not(.ptp-btn-principal) {
  background: #eddfbd;
  color: #4a2d1a;
  border: 1px solid #c9ad7c;
}

.ptp-carte-actions .mg-btn:not(.ptp-btn-principal):hover {
  background: #e3d1a6;
}

.ptp-carte-actions .ptp-btn-principal {
  flex: 1 0 100%;
  background: var(--ptp-grenat);
  color: #fff4e2;
  border-color: var(--ptp-grenat);
}

.ptp-carte-actions .ptp-btn-principal:hover {
  background: #912f47;
}

/* ---------- Écrans moyens et petits : les fils passent sous la toile ---------- */
@media (max-width: 899px) {
  .ptp-fiche {
    display: none;
  }

  .ptp-fils {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
  }

  .ptp-fil {
    flex: 0 0 76px;
    height: 34px;
    min-height: 0;
  }

  .ptp-fil.actif {
    transform: translateY(-5px) scale(1.04);
  }

  .ptp-outil {
    flex: 0 0 auto;
    height: 34px;
    margin: 0;
    font-size: 0.82rem;
  }

  .ptp-outil.actif {
    transform: translateY(-3px);
  }

  .ptp-carte {
    left: 50%;
    top: auto;
    bottom: 10px;
    width: min(420px, 92%);
    min-width: 0;
    padding: 16px 18px 14px;
    transform: translateX(-50%) rotate(0.5deg);
    animation: none;
  }

  .ptp-carte h2 {
    font-size: 1.5rem;
    margin: 2px 0 4px;
  }

  .ptp-carte-mot {
    min-height: 0;
    font-size: 0.92rem;
  }

  .ptp-etoiles-grandes {
    font-size: 1.5rem;
  }

  .ptp-carte-actions {
    margin-top: 8px;
  }
}

/* Téléphone : la courtepointe défile sur 3 colonnes */
@media (max-width: 599px) {
  .ptp-courtepointe {
    inset: 6px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: none;
    grid-auto-rows: auto;
    overflow-y: auto;
    padding: 8px;
  }

  .ptp-courtepointe::after {
    display: none;
  }

  .ptp-etiquette {
    grid-column: 1 / -1;
    writing-mode: horizontal-tb;
    transform: none;
    height: 30px;
    align-self: center;
  }

  .ptp-carre {
    height: 108px;
  }

  .ptp-bonus {
    flex-wrap: wrap;
    gap: 2px 8px;
    min-height: 62px;
    padding: 6px 10px;
    text-align: center;
  }

  .ptp-fil {
    flex-basis: 62px;
    height: 30px;
  }

  .ptp-fil-bande {
    min-width: 26px;
    font-size: 0.74rem;
  }

  .ptp-fil-touche {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ptp-carre,
  .ptp-fil,
  .ptp-carte,
  .ptp-souffle {
    transition: none;
    animation: none;
  }
}
