/* TapeType page — on top of shared/ui.css (TapetIdle UX) */

/* =========================
   TOPBAR (clean + simple)
   ========================= */
.ttTopbar{
  display:grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items:center;
}

.ttActions{ justify-self:end; display:flex; gap:12px; align-items:center; flex-wrap:wrap; }
.ttLeftActions, .ttRightActions{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.ttLeftActions{ justify-content:flex-start; }
.ttRightActions{ justify-content:flex-end; }

.btnIcon{ width:40px; padding-left:0; padding-right:0; text-align:center; }

.hudMini{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.hudItemSmall{ padding: 6px 10px; border-radius: 999px; border:1px solid var(--stroke); background: color-mix(in srgb, var(--panel2) 76%, var(--a2)); font-weight:900; }
.hudItemSmall .k{ color: var(--muted); margin-right: 6px; font-weight: 900; }
.hudItemSmall .v{ font-weight: 950; }

/* Make points HUD look less bulky in Tapetype */
#pointsHud{ padding: 7px 10px; }
#pointsHud .pt-total{ font-size: 14px; }
#pointsHud #ptTotal{ font-size: 18px; }

@media (max-width: 980px){
  .ttTopbar{ grid-template-columns: 1fr; justify-items:stretch; }
  .ttActions{ justify-self:stretch; justify-content:space-between; }
}

/* Mode toggles (Tutoriel / Libre)
   - default handled in JS by adding body.mode-learn or body.mode-free */
.learnOnly{ display:none; }
.freeOnly{ display:none; }
body.mode-learn .learnOnly{ display:block; }
body.mode-learn .freeOnly{ display:none; }
body.mode-free .learnOnly{ display:none; }
body.mode-free .freeOnly{ display:block; }

/* Some learn/free elements are flex groups */
body.mode-learn .ttGroup.learnOnly{ display:flex; }
body.mode-free .ttGroup.freeOnly{ display:flex; }

/* Accessibility helper */
.srOnly{ position:absolute!important; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

/* Small segmented controls + select (topbar) */
.seg{ display:flex; gap:8px; padding: 6px; border-radius: 999px; border:1px solid var(--stroke); background: color-mix(in srgb, var(--panel2) 76%, var(--a2)); }
.seg .btn{ border-radius: 999px; }
.btn.isActive{ border-color: color-mix(in srgb, var(--a2) 45%, var(--stroke)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--a2) 14%, transparent); }

.selectWrap{ display:flex; align-items:center; padding: 6px 10px; border-radius: 999px; border:1px solid var(--stroke); background: color-mix(in srgb, var(--panel2) 76%, var(--a2)); }
.select{
  appearance:none;
  background: transparent;
  border: none;
  color: var(--text);
  font-weight: 950;
  padding: 6px 8px;
  border-radius: 999px;
  cursor:pointer;
}
.select:focus{ outline: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--a2) 14%, transparent); }

/* Tutorial header */
.learnHeader{ padding: 10px 6px 6px; }
.learnHeaderGrid{ display:flex; align-items:flex-start; justify-content:space-between; gap: 14px; }
.learnLeft{ min-width: 0; flex: 1 1 auto; }
.learnRight{ flex: 0 0 auto; display:flex; flex-direction:column; align-items:flex-end; gap: 8px; }
.learnRight .learnCtaRow{ justify-content:flex-end; margin-top: 0; }
.learnRow{ display:flex; align-items:center; justify-content:space-between; gap: 10px; flex-wrap:wrap; }
.learnStep{ font-weight: 950; }
.learnBadges{ display:flex; align-items:center; gap: 8px; flex-wrap:wrap; }
.learnKicker{ color: var(--muted); font-weight: 950; letter-spacing:.02em; font-size: 12px; }
.learnTitle{ font-weight: 980; font-size: 18px; margin-top: 2px; }
.learnDesc{ color: var(--muted); font-size: 13px; margin-top: 4px; line-height: 1.35; }
.learnMeta{ display:flex; flex-wrap:wrap; gap: 8px; margin-top: 8px; }

.learnKeysRow{ margin-top: 10px; display:flex; flex-direction:column; gap: 8px; }
.keyCaps{ display:flex; flex-wrap:wrap; gap:8px; }
.keycap{ 
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 12px;
  border:1px solid var(--stroke);
  background: color-mix(in srgb, var(--panel2) 76%, var(--a2));
  font-weight: 980;
  letter-spacing: .02em;
  box-shadow: 0 10px 26px rgba(0,0,0,.10);
}
.keycap.pulse{ animation: keyPulse 1.1s ease-in-out infinite; }
@keyframes keyPulse{ 0%{ transform: translateY(0) scale(1); } 50%{ transform: translateY(-1px) scale(1.04);} 100%{ transform: translateY(0) scale(1);} }

.learnCtaRow{ display:flex; gap: 8px; flex-wrap:wrap; margin-top: 10px; }

@media (max-width: 880px){
  .learnHeaderGrid{ flex-direction:column; }
  .learnRight{ align-items:flex-start; }
  .learnRight .learnCtaRow{ justify-content:flex-start; }
}

/* Lesson list */
.lessonList{ display:flex; flex-direction:column; gap: 8px; }
.lessonItem{
  display:flex;
  align-items:flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 18px;
  border:1px solid var(--stroke);
  background: color-mix(in srgb, var(--panel2) 76%, var(--a2));
  cursor:pointer;
  user-select:none;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}
.lessonItem:hover{ border-color: color-mix(in srgb, var(--a2) 35%, var(--stroke)); transform: translateY(-1px); background: color-mix(in srgb, var(--panel2) 82%, var(--a2)); }
.lessonItem.locked{ opacity: .55; cursor:not-allowed; }
.lessonItem.active{ border-color: color-mix(in srgb, var(--a2) 55%, var(--stroke)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--a2) 12%, transparent); }
.lessonDot{ width: 16px; height: 16px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--stroke) 70%, transparent); background: color-mix(in srgb, var(--panel2) 74%, transparent); margin-top: 2px; flex: 0 0 16px; }
.lessonDot.done{ background: color-mix(in srgb, var(--ok) 70%, var(--a2)); border-color: color-mix(in srgb, var(--ok) 60%, var(--stroke)); }
.lessonMain{ min-width: 0; }
.lessonName{ font-weight: 950; font-size: 13px; line-height: 1.25; }
.lessonSub{ color: var(--muted); font-size: 12px; margin-top: 2px; }

/* Learn card: "à faire maintenant" */
.learnNow{
  margin-top: 10px;
  padding: 12px;
  border-radius: 18px;
  border:1px solid var(--stroke);
  background: color-mix(in srgb, var(--panel2) 76%, var(--a2));
}
.learnNow .nowTitle{ font-weight: 980; }
.learnNow .nowLine{ margin-top: 6px; color: var(--muted); font-size: 13px; line-height: 1.35; }
.learnNow .nowKeys{ margin-top: 10px; }
.learnNow .nowBadges{ margin-top: 10px; display:flex; gap: 8px; flex-wrap:wrap; }
.learnNow.bump{ animation: nowBump 260ms ease; }
@keyframes nowBump{ 0%{ transform: scale(1);} 40%{ transform: scale(1.02);} 100%{ transform: scale(1);} }

.lockedDetails{ margin-top: 10px; }
.lockedDetails > summary{ cursor:pointer; color: var(--muted); font-weight: 950; }
.lockedDetails[open] > summary{ color: var(--text); }

.lessonLists{ margin-top: 10px; animation: listIn 200ms ease; }
@keyframes listIn{ from{ opacity:0; transform: translateY(-6px);} to{ opacity:1; transform: translateY(0);} }

/* Subtle shake on mistakes */
.textBox.shake{ animation: boxShake 160ms ease; }
@keyframes boxShake{ 0%{ transform: translateX(0);} 25%{ transform: translateX(-4px);} 55%{ transform: translateX(4px);} 85%{ transform: translateX(-2px);} 100%{ transform: translateX(0);} }

/* Celebration (learn step validated) */
.ttCelebration{ position: fixed; inset: 0; pointer-events:none; z-index: 9999; overflow:hidden; }
.ttConfetti{ position:absolute; width: 10px; height: 16px; border-radius: 4px; opacity: .9; transform: translateY(-20px) rotate(0deg); animation: confettiFall 820ms ease-out forwards; filter: saturate(1.1); }
@keyframes confettiFall{ to{ transform: translateY(120vh) rotate(260deg); opacity:0; } }

/* On very small screens, keep header tidy */
@media (max-width: 560px){
  .learnMeta{ gap: 6px; }
  .seg{ gap:6px; }
}

/* Make the typing box height follow TapeType settings */
.textBox{ height: var(--textBoxH, var(--boxH)); }

/* Progress bar */
.ttProgress{ display:flex; align-items:center; gap:10px; padding: 10px 6px 0; }
.ttProgress .bar{ flex:1; height: 10px; border-radius: 999px; background: color-mix(in srgb, var(--stroke) 50%, transparent); overflow:hidden; }
.ttProgress .barFill{ height:100%; border-radius:999px; background: linear-gradient(90deg, color-mix(in srgb, var(--a2) 70%, var(--ok)), var(--a2)); }
.ttProgressLabel{ min-width: 48px; text-align:right; }

/* Stats card */
.statsGrid{ display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.statPill{ background: color-mix(in srgb, var(--panel2) 78%, var(--a2)); border:1px solid color-mix(in srgb, var(--stroke) 80%, var(--a2)); border-radius: 18px; padding: 10px 12px; display:flex; justify-content:space-between; align-items:baseline; gap:10px; }
.statPill span{ color: var(--muted); font-size: 12px; font-weight: 900; letter-spacing:.02em; }
.statPill b{ font-weight: 950; }
.cardFoot{ margin-top: 10px; font-size: 12px; }

.hide-stats .statsWrap{ display:none; }

/* Text modal */
.ttTextarea{ width:100%; min-height: 220px; resize: vertical; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--stroke); background: color-mix(in srgb, var(--panel2) 80%, var(--a2)); color: var(--text); font: 13px/1.4 var(--mono); }
.ttModalActions{ display:flex; justify-content:flex-end; padding-top: 10px; }

/* Modal tabs (history) */
.modalTabs{ display:flex; align-items:center; gap:10px; padding: 10px 14px 0; }
.tab{ border:1px solid var(--stroke); background: color-mix(in srgb, var(--panel2) 76%, var(--a2)); color: var(--text); padding: 8px 12px; border-radius: 999px; font-weight: 900; cursor:pointer; }
.tab.active{ border-color: color-mix(in srgb, var(--a2) 45%, var(--stroke)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--a2) 14%, transparent); }

/* Tables */
.ttTableWrap{ overflow:auto; border-radius: 16px; border:1px solid var(--stroke); background: color-mix(in srgb, var(--panel2) 76%, var(--a2)); }
.ttTable{ width:100%; border-collapse: collapse; font-size: 12px; }
.ttTable th, .ttTable td{ padding: 10px 12px; border-bottom: 1px solid color-mix(in srgb, var(--stroke) 70%, transparent); text-align:left; white-space: nowrap; }
.ttTable th{ color: var(--muted); font-weight: 950; letter-spacing:.02em; }
.ttTable tbody tr:hover td{ background: color-mix(in srgb, var(--a2) 10%, transparent); }

/* Points HUD injected by points.js */
#pointsHud{
  display:flex;
  align-items: baseline;
  gap: 10px;
  margin-left: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--a2) 18%, var(--stroke));
  background: color-mix(in srgb, var(--panel2) 72%, var(--a2));
}
#pointsHud .pt-total{ font-weight: 950; font-size: 18px; }
#pointsHud #ptTotal{ font-size: 22px; letter-spacing: .01em; }
#pointsHud .pt-label{ color: var(--muted); font-size: 12px; margin-left: 6px; }
#pointsHud .pt-mult{ font-weight: 950; color: var(--muted); }

@keyframes ptBump{ 0%{ transform: scale(1);} 35%{ transform: scale(1.08);} 100%{ transform: scale(1);} }
@keyframes ptMult{ 0%{ transform: scale(1);} 35%{ transform: scale(1.12);} 100%{ transform: scale(1);} }
#pointsHud.bump{ animation: ptBump 220ms ease; }
#pointsHud.mult-bump{ animation: ptMult 240ms ease; }

/* Mobile: stack panels */
@media (max-width: 960px){
  .statsGrid{ grid-template-columns: 1fr; }
}


/* Focusable textbox (tabindex) — avoid default outline */
#textBox:focus{ outline: none; }
#textBox:focus-visible{ outline: none; }
