/* Kiwimoov — /show, reproduction des vues de l'app (fragments au centre de la timeline)

   Chaque `.app` est un morceau d'écran de l'application mobile, redessiné en
   HTML/CSS à l'échelle 1. Les valeurs viennent du thème de kiwimoov-mobile
   (shared/theme : colors, radius, spacing, typography) et de ses composants
   de base (shared/ui : AppCard, AppButton, AppBadge, SharedItemRow, AppTabs…).
   Si l'app change, c'est ici qu'on réaligne.

   La couleur d'identité suit le mode, comme dans l'app :
   data-mode="coach" = brun-orangé, data-mode="eleve" = vert. */

.app {
  /* Mode élève par défaut (useThemeColors) */
  --k-primary: #97aa3a;
  --k-primary-light: #b3c072;
  --k-primary-soft: #ecf0db;
  --k-primary-faint: #f7f8f2;
  --k-primary-dark: #657227;

  --k-canvas: #fbf8ef;
  --k-surface: #ffffff;
  --k-surface-muted: #f3f1ea;
  --k-text: #181715;
  --k-text-2: #585550;
  --k-text-3: #7b766e;
  --k-text-disabled: #a39c92;
  --k-border-subtle: #ece8df;
  --k-border: #ddd8ce;
  --k-border-strong: #b9b1a4;
  --k-success: #2d9e5a;
  --k-success-light: #e6f7ee;
  --k-warning: #f5a623;
  --k-mastered: #97aa3a;

  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  padding: 16px;
  border: 1px solid var(--k-border-subtle);
  border-radius: 28px;
  background: var(--k-canvas);
  box-shadow: 0 12px 28px rgba(12, 18, 13, 0.12);
  color: var(--k-text);
  /* L'app n'embarque pas de police : elle utilise celle du système. */
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 20px;
  text-align: left;
  overflow: hidden;
}

.app[data-mode="coach"] {
  --k-primary: #b98950;
  --k-primary-light: #cca980;
  --k-primary-soft: #eee6dd;
  --k-primary-faint: #f7f5f2;
  --k-primary-dark: #75552f;
}

.app * {
  box-sizing: border-box;
  margin: 0;
}

.app svg {
  flex: none;
  display: block;
}

/* ── TEXTE (typography.ts) ── */
.k-h4 {
  font-size: 16px;
  line-height: 22px;
  font-weight: 600;
}

.k-label {
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
}

.k-label-lg {
  font-size: 15px;
  line-height: 20px;
  font-weight: 600;
}

.k-meta {
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  color: var(--k-text-2);
}

.k-caption {
  font-size: 11px;
  line-height: 14px;
  color: var(--k-text-3);
}

.k-overline {
  font-size: 10px;
  line-height: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--k-text-3);
}

.k-brand {
  color: var(--k-primary);
}

/* ── MISE EN PAGE ── */
.k-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.k-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.k-grow {
  flex: 1;
  min-width: 0;
}

.k-between {
  justify-content: space-between;
}

/* ── CARTE (AppCard) ── */
.k-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 22px;
  background: var(--k-surface);
}

.k-card--dim {
  opacity: 0.55;
}

/* ── LIGNE D'ÉLÉMENT (SharedItemRow) ── */
.k-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 60px;
  padding: 8px;
  border-radius: 22px;
  background: var(--k-surface);
}

.k-row-icon {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--k-border);
  border-radius: 50%;
  background: var(--k-surface);
  color: var(--k-primary);
}

.k-row-icon svg {
  width: 18px;
  height: 18px;
}

.k-row-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.k-row-copy .k-label,
.k-row-copy .k-caption {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.k-grip,
.k-chevron {
  width: 16px;
  height: 16px;
  color: var(--k-text-3);
}

/* Pastille de maîtrise posée sous l'icône (MasteryToneDot) */
.k-dot {
  position: absolute;
  bottom: -5px;
  left: 50%;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  border: 2px solid var(--k-surface);
  border-radius: 50%;
  background: var(--k-text-2);
}

.k-dot--mastered {
  background: var(--k-mastered);
}

/* ── AVATAR ── */
.k-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--k-primary-soft);
  color: var(--k-primary-dark);
  font-size: 14px;
  font-weight: 600;
}

.k-avatar--sm {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.k-avatars {
  display: flex;
}

.k-avatars .k-avatar {
  margin-left: -8px;
  border: 2px solid var(--k-canvas);
}

.k-avatars .k-avatar:first-child {
  margin-left: 0;
}

/* ── BOUTON (AppButton) ── */
.k-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 44px;
  padding: 9px 16px;
  border: 1.25px solid var(--k-border);
  border-radius: 16px;
  background: var(--k-surface);
  color: var(--k-text);
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}

.k-btn--primary {
  border-color: var(--k-primary);
  background: var(--k-primary);
  color: #fff;
  box-shadow: 0 8px 18px rgba(21, 33, 23, 0.08);
}

.k-btn--lg {
  padding: 11px 16px;
  font-size: 15px;
  line-height: 20px;
}

.k-btn--full {
  display: flex;
  width: 100%;
}

.k-btn svg {
  width: 16px;
  height: 16px;
}

/* ── BADGE (AppBadge) ── */
.k-badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border: 1px solid var(--k-border-subtle);
  border-radius: 999px;
  background: var(--k-surface-muted);
  color: var(--k-text-2);
  font-size: 11px;
  line-height: 14px;
  white-space: nowrap;
}

.k-badge--success {
  border-color: var(--k-success-light);
  background: var(--k-success-light);
  color: var(--k-success);
}

.k-badge svg {
  width: 12px;
  height: 12px;
}

/* ── BARRE D'ÉTAT (AttendanceStatusBar) ── */
.k-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 11px 16px;
  border-radius: 16px;
  background: var(--k-success-light);
  color: var(--k-success);
  font-size: 15px;
  line-height: 20px;
  font-weight: 600;
  text-align: center;
}

.k-status svg {
  width: 16px;
  height: 16px;
}

/* ── RECHERCHE (AppSearchInput) ── */
.k-search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--k-border);
  border-radius: 16px;
  background: var(--k-surface);
  font-size: 14px;
}

.k-search svg {
  width: 16px;
  height: 16px;
  color: var(--k-text-3);
}

/* ── BARRE D'ACTIONS DE SÉANCE (SessionActionBar) ── */
.k-actionbar {
  display: flex;
  gap: 8px;
  margin: 4px -16px -16px;
  padding: 8px 16px 12px;
  border-top: 1px solid var(--k-border);
  background: var(--k-surface);
}

.k-quick {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 56px;
  padding: 0 4px;
  border: 1.25px solid var(--k-primary);
  border-radius: 16px;
  background: var(--k-primary);
  color: #fff;
  font-size: 11px;
  line-height: 14px;
  font-weight: 600;
  box-shadow: 0 8px 18px rgba(21, 33, 23, 0.08);
}

.k-quick svg {
  width: 18px;
  height: 18px;
}

/* ── VIGNETTE VIDÉO ── */
.k-video {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  background: linear-gradient(135deg, #2d2a27 0%, #534e47 55%, #716b62 100%);
  color: #fff;
  overflow: hidden;
}

/* Silhouette en mouvement : rappelle qu'il s'agit d'une vidéo de cours. */
.k-video-figure {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: rgba(255, 255, 255, 0.22);
}

.k-video-play {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.42);
}

.k-video-play svg {
  width: 18px;
  height: 18px;
}

.k-video-time {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.42);
  font-size: 11px;
  line-height: 14px;
}

.k-video--sm {
  width: 132px;
  border-radius: 10px;
}

.k-video--sm .k-video-play {
  width: 30px;
  height: 30px;
}

.k-video--sm .k-video-play svg {
  width: 14px;
  height: 14px;
}

/* ── SCANNER DE QR CODE (QrScannerView) ── */
.k-scan {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  /* Pas de hauteur propre : le scanner prend celle de la page qui le remplace. */
  border-radius: 22px;
  background: #171717;
  color: #fff;
}

.k-scan-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  /* Les quatre coins du viseur */
  background:
    linear-gradient(#fff, #fff) top left / 20px 3px,
    linear-gradient(#fff, #fff) top left / 3px 20px,
    linear-gradient(#fff, #fff) top right / 20px 3px,
    linear-gradient(#fff, #fff) top right / 3px 20px,
    linear-gradient(#fff, #fff) bottom left / 20px 3px,
    linear-gradient(#fff, #fff) bottom left / 3px 20px,
    linear-gradient(#fff, #fff) bottom right / 20px 3px,
    linear-gradient(#fff, #fff) bottom right / 3px 20px;
  background-repeat: no-repeat;
}

.k-scan-frame svg {
  width: 60px;
  height: 60px;
  padding: 6px;
  border-radius: 6px;
  background: #fff;
  color: #111;
}

.k-scan-hint {
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
}

/* ── NOTIFICATION (NotificationPanel) ── */
.k-notif {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 22px;
  background: var(--k-surface);
  box-shadow: 0 4px 10px rgba(21, 33, 23, 0.05);
}

.k-notif-dot {
  flex: none;
  width: 9px;
  height: 9px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--k-primary);
}

.k-notif-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ── MESSAGERIE (MessageBubble, composeur) ── */
.k-thread {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.k-bubble {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 86%;
  padding: 8px 12px;
  border: 1px solid var(--k-border-subtle);
  border-radius: 16px;
  background: var(--k-surface);
}

.k-bubble--theirs {
  align-self: flex-start;
  border-bottom-left-radius: 6px;
}

.k-bubble--mine {
  align-self: flex-end;
  border-color: var(--k-primary-soft);
  border-bottom-right-radius: 6px;
  background: var(--k-primary-faint);
}

.k-bubble-meta {
  align-self: flex-end;
  color: var(--k-text-3);
  font-size: 11px;
  line-height: 14px;
}

.k-composer {
  display: flex;
  align-items: center;
  gap: 8px;
}

.k-composer-attach {
  width: 20px;
  height: 20px;
  color: var(--k-text-3);
}

.k-composer-input {
  flex: 1;
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--k-border);
  border-radius: 16px;
  background: var(--k-surface);
  color: var(--k-text-disabled);
}

.k-composer-send {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--k-primary);
  color: #fff;
}

.k-composer-send svg {
  width: 18px;
  height: 18px;
}

/* ── MAÎTRISE (MasterySheet) ── */
.k-sheet-handle {
  align-self: center;
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: var(--k-border);
}

.k-assess {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

/* Case « Réussi » : cochée (verte, avec la coche) ou non (neutre, sans coche). */
.k-pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px 4px 8px;
  border: 1px solid var(--k-border);
  border-radius: 999px;
  color: var(--k-text-2);
  font-size: 11px;
  line-height: 14px;
  font-weight: 600;
  transition: border-color 0.3s ease, color 0.3s ease;
}

/* Non cochée : un rond vide ; cochée : la coche verte. */
.k-pill svg {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.25px var(--k-border-strong);
  color: transparent;
  transition: color 0.3s ease, box-shadow 0.3s ease;
}

.k-pill.is-success {
  border-color: var(--k-mastered);
  color: var(--k-mastered);
}

.k-pill.is-success svg {
  box-shadow: none;
  color: var(--k-mastered);
}

.k-divider {
  height: 1px;
  background: var(--k-border-subtle);
}

/* ── PROGRESSION (AppSegmentedProgress) ── */
.k-progress {
  display: flex;
  gap: 4px;
}

.k-progress span {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--k-border-subtle);
  transition: background 0.4s ease;
}

.k-progress span.is-done {
  background: var(--k-primary);
}

/* ── CHANGEMENT D'ÉTAT ──
   Deux états superposés dans la même case : « avant » (le geste à faire) puis
   « après » (le résultat). Le changement se joue quand l'étape est bien
   centrée (classe is-played, posée par timeline-observer.js dans une bande
   plus étroite que celle du zoom), donc juste après que l'écran a grandi.
   Sans JS : seul l'état final s'affiche. */
.k-swap {
  display: grid;
  align-items: center;
}

/* Les deux états remplissent toute la hauteur (écran de scan → page). */
.k-swap--fill {
  align-items: stretch;
}

.k-swap--end {
  justify-items: end;
  align-items: center;
}

.k-swap > * {
  grid-area: 1 / 1;
}

.k-swap > .k-before {
  visibility: hidden;
}

html.js .k-swap > .k-before,
html.js .k-swap > .k-after {
  visibility: visible;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

html.js .timeline-node:not(.is-played):not(.is-past) .k-swap > .k-after {
  opacity: 0;
  transform: scale(0.96);
}

html.js .timeline-node.is-played .k-swap > .k-before,
html.js .timeline-node.is-past .k-swap > .k-before {
  opacity: 0;
  transform: scale(0.96);
}

/* Apparition simple d'un élément (réponse du coach, bouton…) */
html.js .k-appear {
  transition: opacity 0.35s ease, transform 0.35s ease;
}

html.js .timeline-node:not(.is-played):not(.is-past) .k-appear {
  opacity: 0;
  transform: translateY(6px);
}

/* Variante : l'état final est une classe (case cochée, segment rempli,
   pastille verte) plutôt qu'un second élément. */
html.js .k-dot {
  transition: background 0.3s ease;
}

html.js .timeline-node:not(.is-played):not(.is-past) .k-pill.k-late {
  border-color: var(--k-border);
  color: var(--k-text-2);
}

html.js .timeline-node:not(.is-played):not(.is-past) .k-pill.k-late svg {
  box-shadow: inset 0 0 0 1.25px var(--k-border-strong);
  color: transparent;
}

html.js .timeline-node:not(.is-played):not(.is-past) .k-progress span.k-late {
  background: var(--k-border-subtle);
}

html.js .timeline-node:not(.is-played):not(.is-past) .k-dot.k-late {
  background: var(--k-text-2);
}

html.js .timeline-node.is-played .k-swap > *,
html.js .timeline-node.is-played .k-appear,
html.js .timeline-node.is-played .k-late,
html.js .timeline-node.is-played .k-late svg {
  transition-delay: 0.2s;
}

@media (prefers-reduced-motion: reduce) {
  html.js .k-swap > *,
  html.js .k-appear,
  html.js .k-late,
  html.js .k-late svg {
    transition: none !important;
  }
}
