/*
 * La page d'appel web (lot WC2). Chargée **après** demo.css : elle reprend ses
 * polices, ses jetons de `.scene` (jour et nuit) et ses auras, et n'ajoute que
 * l'écran d'appel du prototype `docs/yelda-air-appel-web-prototype.html`.
 *
 * Toutes ses classes portent le préfixe `cw-` : demo.css a déjà `.brand`,
 * `.mark`, `.big`, `.tel`… et un nom partagé hériterait de leurs styles.
 */

.scene {
  --go: #1f9d5c;
  --stop: #d93f46;
  --warn: #b26b00;
  --line: #e4e0da;
  --panel: #ffffff;
}
.scene[data-mode='night'] {
  --go: #2fbf73;
  --stop: #f0656b;
  --warn: #e6a23c;
  --line: #24223a;
  --panel: #110f1d;
}

.cw [hidden] {
  display: none !important;
}

/*
 * Un écran d'appel tient dans l'écran, et ne défile jamais. demo.css pose
 * `body { min-height: 100vh }` et `.scene { min-height: 600px }` pour la page
 * projetée ; sur mobile, 100vh est la hauteur **sans** barre d'adresse, donc
 * plus haute que ce qu'on voit, et la page défilait. Ici, la hauteur visible
 * (`dvh`, `vh` en repli) et rien de plus : c'est l'onde qui rétrécit pour faire
 * place aux sous-titres, jamais la page qui s'allonge.
 */
html:has(.cw),
body:has(.cw) {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
.scene:has(.cw) {
  flex: 0 0 auto;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
}

.cw {
  position: relative;
  z-index: 1;
  height: 100%;
  min-height: 0;
  /* Filet pour un écran vraiment trop court (paysage) : le contenu défile
     dans la carte, la page ne bouge pas. */
  overflow-y: auto;
  max-width: 440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: max(20px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
    max(28px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
}
.cw button {
  font: inherit;
  color: inherit;
}
.cw button:focus-visible,
.cw a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.cw h1:focus {
  outline: none;
}

.cw-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: 0;
}

.cw-mark {
  font-family: var(--display);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--accent);
}
.cw-brand {
  font-size: 13px;
  color: var(--dim);
  margin: 6px 0 0;
}
.cw-brand strong {
  color: var(--ink);
  font-weight: 600;
}

.cw-who {
  margin: 26px 0 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 34px;
  letter-spacing: -0.02em;
  line-height: 1.05;
  text-wrap: balance;
}
.cw-line {
  margin: 8px 0 0;
  font-size: 15px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.cw-ai {
  margin: 14px 0 0;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  font-size: 12.5px;
  color: var(--ink);
}
.cw-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 14px 0 0;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  font-size: 12.5px;
  color: var(--dim);
}
.cw-pill i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--go);
}
.cw-pill.cw-warn i {
  background: var(--warn);
}

/* L'espace qui reste, et seulement lui : l'onde est le seul élément élastique. */
.cw-orbwrap {
  position: relative;
  flex: 1 1 0;
  width: 100%;
  min-height: 64px;
}
.cw-orb,
.cw-orbwrap .cw-ring {
  position: absolute;
  inset: 0;
  margin: auto;
  aspect-ratio: 1;
  width: auto;
  max-width: 100%;
}
.cw-orb {
  height: min(220px, 100%);
}
.cw-note {
  font-size: 13px;
  color: var(--dim);
  max-width: 30ch;
  margin: 0 auto 18px;
  text-wrap: balance;
}
.cw-note a {
  color: inherit;
  font-variant-numeric: tabular-nums;
}
.cw-foot {
  margin-top: auto;
}

/* `.cw button` hérite la couleur du texte : le combiné, lui, reste blanc. */
.cw .cw-callbtn {
  color: #fff;
}
.cw-callbtn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #fff;
  transition: transform 0.15s ease;
}
.cw-callbtn:active {
  transform: scale(0.94);
}
.cw-callbtn svg {
  width: 32px;
  height: 32px;
}
.cw-go {
  background: var(--go);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--go) 40%, transparent);
}
.cw-stop {
  background: var(--stop);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--stop) 40%, transparent);
}
.cw-stop svg {
  transform: rotate(135deg);
}
.cw-calllabel {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--dim);
}

.cw-timer {
  margin: 10px 0 0;
  font-size: 16px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

/* Les sous-titres rétrécissent après l'onde : le haut (la réplique la plus
   ancienne) est rogné, la dernière reste lisible au-dessus des boutons. */
.cw-captions {
  flex: 0 1 auto;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  /* La coupe du haut se fond plutôt que de trancher une ligne en deux. */
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 28px);
  mask-image: linear-gradient(to bottom, transparent, #000 28px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 18px;
  text-align: left;
}
.cw-cap {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.4;
  padding: 8px 12px;
  border-radius: 14px;
  max-width: 88%;
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  border: 1px solid var(--line);
  overflow-wrap: break-word;
  animation: cw-rise 0.25s ease;
}
.cw-cap.cw-agent {
  align-self: flex-start;
}
.cw-cap.cw-you {
  align-self: flex-end;
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
}
.cw-cap b {
  display: block;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 600;
}
@keyframes cw-rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.cw-controls {
  display: grid;
  grid-template-columns: repeat(3, 76px);
  gap: 18px 26px;
  justify-content: center;
  align-items: start;
}
.cw-ctl {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--dim);
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}
.cw-b {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--panel) 75%, transparent);
  border: 1px solid var(--line);
  color: var(--ink);
}
.cw-ctl[aria-pressed='true'] .cw-b {
  background: var(--ink);
  color: var(--ground);
  border-color: var(--ink);
}
.cw-ctl svg {
  width: 24px;
  height: 24px;
}
.cw-hang {
  grid-column: 2;
  margin-top: 8px;
}

.cw-ring {
  position: relative;
  width: 150px;
  height: min(150px, 100%);
  display: grid;
  place-items: center;
}
.cw-ring::before,
.cw-ring::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  animation: cw-pulse 1.8s ease-out infinite;
}
.cw-ring::after {
  animation-delay: 0.9s;
}
.cw-core {
  width: 58%;
  height: 58%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--accent) 55%, white), var(--accent));
}
@keyframes cw-pulse {
  from {
    transform: scale(0.6);
    opacity: 0.7;
  }
  to {
    transform: scale(1.25);
    opacity: 0;
  }
}

.cw-sheet {
  margin-top: auto;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
  text-align: left;
  box-shadow: 0 16px 40px rgba(20, 21, 31, 0.12);
}
.cw-sheet h2 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
}
.cw-sheet p {
  margin: 0;
  color: var(--dim);
  font-size: 13.5px;
}

.cw-big {
  font-family: var(--display);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.02em;
  margin: 38px 0 6px;
  text-wrap: balance;
}
.cw-sub {
  color: var(--dim);
  font-size: 14px;
  max-width: 30ch;
  text-wrap: balance;
  margin: 0 auto;
}
.cw-ghost {
  margin-top: 14px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  font-size: 14px;
}
.cw-err {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 40px auto 0;
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  color: var(--warn);
}
.cw-err svg {
  width: 26px;
  height: 26px;
}

/* Écran court (petit téléphone, clavier ou barre d'adresse ouverts) : l'en-tête
   se resserre pour laisser deux répliques de sous-titres au-dessus des boutons. */
@media (max-height: 640px) {
  .cw-who {
    margin-top: 10px;
    font-size: 28px;
  }
  .cw-line,
  .cw-timer {
    margin-top: 4px;
  }
  .cw-pill,
  .cw-ai {
    margin-top: 8px;
  }
  .cw-captions {
    margin-bottom: 10px;
  }
  .cw-controls {
    gap: 10px 26px;
  }
  .cw-b {
    width: 54px;
    height: 54px;
  }
  .cw-callbtn {
    width: 66px;
    height: 66px;
  }
  .cw-hang {
    margin-top: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cw-ring::before,
  .cw-ring::after,
  .cw-cap {
    animation: none;
  }
  .cw-callbtn {
    transition: none;
  }
}
