/* CENDRE occupies a small speech corner and leaves the landscape interactive. */
.cendre-companion {
  --cendre-level: 0;
  position: fixed;
  z-index: 44;
  right: max(28px, env(safe-area-inset-right));
  bottom: max(112px, calc(env(safe-area-inset-bottom) + 100px));
  display: flex;
  align-items: flex-end;
  width: min(460px, calc(100vw - 40px));
  pointer-events: none;
  color: #e8f2e7;
  isolation: isolate;
}
.cendre-companion[hidden] { display: none !important; }
.cendre-portrait { position: relative; width: 154px; height: 202px; flex: 0 0 154px; margin-right: -16px; z-index: 1; }
.cendre-avatar { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .66; filter: drop-shadow(0 0 7px #6bcfc119); }
.cendre-avatar-fallback { position: absolute; inset: 35px 30px 35px; display: grid; place-items: center; font-size: 36px; font-weight: 300; border: 1px solid #a7dfc93d; border-radius: 50%; color: #a7dfc9; background: #192d2bba; }
.has-avatar .cendre-avatar-fallback { display: none; }
.cendre-card { position: relative; flex: 1; min-width: 0; margin-bottom: 18px; padding: 18px 16px 12px 24px; border: 1px solid #afdec047; border-radius: 9px 14px 14px 4px; background: linear-gradient(125deg, #21332dd9, #112223d9); box-shadow: inset 0 1px #f2ffe80d, 0 12px 35px #05191726; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); pointer-events: auto; }
.cendre-heading { display: flex; align-items: baseline; gap: 9px; padding-right: 22px; }
.cendre-name { font-size: 11px; letter-spacing: 2px; font-weight: 650; color: #b0e6cc; }
.cendre-label { font-size: 9px; color: #b5c7bc; white-space: nowrap; }
.cendre-transcript { min-height: 48px; margin: 13px 0 12px; font-size: 16px; line-height: 1.5; font-weight: 400; letter-spacing: .05px; }
.cendre-transcript:empty::before { content: '···'; color: #b0e6cc; letter-spacing: 4px; }
.is-speaking .cendre-transcript::after { content: ''; display: inline-block; height: 14px; width: 2px; margin-left: 4px; vertical-align: -2px; background: #b0e6cc; opacity: .7; }
.cendre-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; border-top: 1px solid #c5dcc51a; padding-top: 5px; }
.cendre-status { flex: 1 0 100%; font-size: 9px; color: #b5c7bc; }
.cendre-companion button { font-family: inherit; cursor: pointer; touch-action: manipulation; }
.cendre-play,.cendre-mute { border: 0; background: none; color: #d5e9d8; font-size: 10px; padding: 4px 0; min-height: 32px; }
.cendre-mute { color: #aabfb4; margin-left: auto; }
.cendre-play:disabled { opacity: .45; cursor: default; }
.cendre-dismiss { position: absolute; top: 3px; right: 3px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: none; color: #a9c2b6; font-size: 21px; }
.cendre-companion button:is(:hover,:focus-visible) { color: #fff5d7; }
.cendre-companion button:focus-visible { outline: 2px solid #c5efd4; outline-offset: 3px; }
.cendre-accessible { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.cendre-signal { position: absolute; bottom: 4px; left: 57px; display: flex; align-items: center; gap: 3px; height: 16px; }
.cendre-signal i { width: 2px; height: 3px; background: #b2edd2; border-radius: 2px; opacity: .7; }
.is-speaking .cendre-signal i { height: calc(3px + var(--cendre-level) * 12px); }
.is-speaking .cendre-signal i:nth-child(even) { height: calc(3px + var(--cendre-level) * 7px); }
.cendre-companion.is-arriving .cendre-portrait { animation: cendre-materialize 650ms cubic-bezier(.2,.7,.2,1) both; }
.cendre-companion.is-arriving .cendre-card { animation: cendre-card-in 450ms 160ms ease-out both; }
.cendre-companion.is-leaving { animation: cendre-card-in 220ms ease-in reverse both; }
@keyframes cendre-materialize { 0% { opacity: 0; transform: translateY(28px) scale(.82); filter: brightness(2); } 55% { opacity: 1; filter: brightness(1.2); } 100% { opacity: 1; transform: none; filter: none; } }
@keyframes cendre-card-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (max-width: 720px), (pointer: coarse) {
  /* A voice beside the traveller: floating subtitles, without a mobile window. */
  .cendre-companion { right: max(12px, env(safe-area-inset-right)); bottom: calc(env(safe-area-inset-bottom) + 208px); width: min(410px, calc(100vw - max(12px, env(safe-area-inset-left)) - max(12px, env(safe-area-inset-right)))); align-items: center; }
  .cendre-portrait { width: 102px; height: 142px; flex-basis: 102px; margin-right: 0; }
  .cendre-signal { display: none; }
  .cendre-card { margin: 0; padding: 8px 5px 0 2px; border: 0; border-radius: 0; background: none; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; text-shadow: 0 1px 3px #102321, 0 1px 8px #102321cc; }
  .cendre-heading { padding-right: 34px; }
  .cendre-name { font-size: 10px; letter-spacing: 2px; color: #c9f5e4; }
  .cendre-label,.cendre-status { display: none; }
  .cendre-transcript { color: #f4fff7; font-size: 14px; line-height: 1.45; min-height: 41px; margin: 8px 0 0; font-weight: 500; }
  .cendre-footer { border: 0; padding: 0; gap: 0 12px; justify-content: flex-start; }
  .cendre-play,.cendre-mute { min-height: 44px; font-size: 10px; color: #d1eadd; text-shadow: inherit; }
  .cendre-mute { margin-left: 0; }
  .cendre-dismiss { width: 44px; height: 44px; top: -8px; right: -4px; color: #c9e5d7; text-shadow: inherit; }
}
@media (max-width: 360px) {
  .cendre-portrait { width: 84px; flex-basis: 84px; height: 125px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .cendre-companion { right: auto; left: max(12px, env(safe-area-inset-left)); bottom: calc(env(safe-area-inset-bottom) + 68px); width: 350px; max-width: calc(100vw - 170px); }
  .cendre-portrait { width: 84px; flex-basis: 84px; height: 122px; }
  .cendre-card { margin: 0; padding: 5px 4px 0; border: 0; border-radius: 0; background: none; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; text-shadow: 0 1px 3px #102321, 0 1px 8px #102321cc; }
  .cendre-transcript { font-size: 14px; min-height: 41px; margin: 6px 0 0; }
  .cendre-status,.cendre-label,.cendre-signal { display: none; }
  .cendre-footer { border: 0; padding: 0; }
  .cendre-play,.cendre-mute,.cendre-dismiss { text-shadow: inherit; }
}
/* Les leçons de CENDRE (étape 2, tâche 10 ; brief 02-lecons-brief.md § 3) : une feuille de verre opaque à 80 % sur tous les formats
   (lisible sur le sable en plein jour), la phrase en costume en italique sur un filet turquoise, des lignes neutres, un pied de boutons
   de 44 px ; repliée, une pastille au même ancrage. Un signal actif borde la feuille d'un liseré turquoise. */
.cendre-companion[data-kind="leçon"] { width: min(658px, calc(100vw - 40px)); }
.cendre-companion :is(.cendre-portrait, .cendre-card, .cendre-lesson-pill, .cendre-lesson-body, .cendre-lesson-status, .cendre-lesson-footer, .cendre-lesson-number)[hidden] { display: none !important; }
.cendre-companion[data-kind="leçon"] .cendre-card { padding: 16px 16px 10px 24px; border-color: #8fd0cb52; background: rgb(14 28 27 / 80%); }
.cendre-companion[data-kind="leçon"].has-signal .cendre-card { box-shadow: inset 2px 0 #8fe3f5, inset 0 1px #f2ffe80d, 0 12px 35px #05191726; }
.cendre-companion[data-kind="leçon"] .cendre-heading { padding-right: 0; }
.cendre-lesson-number { margin-left: auto; font-size: 11px; letter-spacing: .3px; color: #a7dfc9; white-space: nowrap; }
.cendre-lesson-body { margin: 10px 0 6px; color: #f4fff7; font-size: 16px; line-height: 24px; }
.cendre-lesson-body p { margin: 0 0 6px; }
.cendre-lesson-phrase { padding-left: 10px; border-left: 2px solid #8fe3f5; }
.cendre-lesson-phrase em { font-style: italic; color: #dcf4ec; }
.cendre-lesson-status { margin: 0 0 6px; font-size: 13px; line-height: 18px; color: #c9e5d7; }
.cendre-lesson-footer { clear: both; display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-top: 8px; border-top: 1px solid #c5dcc51a; }
.cendre-companion :is(.cendre-lesson-fold, .cendre-lesson-show, .cendre-lesson-skip, .cendre-lesson-ack, .cendre-lesson-pill) { min-width: 44px; min-height: 44px; padding: 0 14px; border: 1px solid #8fd0cb52; border-radius: 8px; background: rgb(24 44 42 / 72%); color: #d5ece4; font-size: 13px; line-height: 1.2; }
.cendre-companion .cendre-lesson-fold { display: grid; place-items: center; margin-right: auto; padding: 0; }
.cendre-companion .cendre-lesson-fold svg { transform: rotate(0deg); }
.cendre-companion .cendre-lesson-ack { min-width: 112px; border-color: #8fd0cb; background: #8fd0cb; color: #0f2221; font-weight: 650; }
.cendre-companion .cendre-lesson-ack:is(:hover, :focus-visible) { color: #0f2221; background: #ade3de; }
.cendre-companion :is(.cendre-lesson-ack, .cendre-lesson-skip):is(:disabled, [aria-disabled="true"]) { opacity: .5; cursor: default; }
.cendre-companion.is-folded { width: auto; justify-content: flex-end; }
/* Repliée, la pastille monte au-dessus d'une fiche ou d'un signal qu'elle recouvrirait (cendre-ui.mjs, `avoid`). */
.cendre-companion.is-folded { translate: 0 calc(-1 * var(--cendre-lift, 0px)); }
.cendre-companion .cendre-lesson-pill { display: inline-flex; align-items: center; gap: 8px; padding: 0 12px 0 6px; border-radius: 22px; background: rgb(14 28 27 / 84%); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); pointer-events: auto; box-shadow: 0 8px 22px #05191733; }
.cendre-lesson-pill-mark { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid #a7dfc96b; border-radius: 50%; color: #a7dfc9; font-size: 14px; }
.cendre-lesson-pill.has-signal .cendre-lesson-pill-mark { border-color: #8fe3f5; color: #8fe3f5; box-shadow: 0 0 0 2px #8fe3f533; }
.cendre-lesson-pill svg { transform: rotate(180deg); }
.cendre-companion.is-swapping .cendre-card { animation: cendre-swap 150ms ease-out both; }
@keyframes cendre-swap { from { opacity: .35; } to { opacity: 1; } }
@media (max-width: 720px), (pointer: coarse) {
  /* Au téléphone, la feuille entière est de verre ; le portrait flotte à gauche et le texte l'enveloppe. */
  .cendre-companion[data-kind="leçon"] { width: min(410px, calc(100vw - max(12px, env(safe-area-inset-left)) - max(12px, env(safe-area-inset-right)))); }
  .cendre-companion[data-kind="leçon"]:not(.is-folded) { display: block; padding: 12px 12px 10px; border: 1px solid #8fd0cb3d; border-radius: 12px; background: rgb(14 28 27 / 80%); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 12px 35px #05191740; pointer-events: auto; }
  .cendre-companion[data-kind="leçon"].has-signal:not(.is-folded) { box-shadow: inset 2px 0 #8fe3f5, 0 12px 35px #05191740; }
  .cendre-companion[data-kind="leçon"] .cendre-portrait { float: left; width: 76px; height: 100px; margin: 0 10px 2px 0; }
  .cendre-companion[data-kind="leçon"] .cendre-card, .cendre-companion[data-kind="leçon"].has-signal .cendre-card { padding: 0; border: 0; background: none; box-shadow: none; text-shadow: none; }
  .cendre-companion[data-kind="leçon"] .cendre-heading { padding-right: 0; }
  .cendre-lesson-body { margin: 6px 0 4px; font-size: 14px; line-height: 20px; }
  /* La phrase en costume se range à côté du portrait (son filet le longe) ; les lignes neutres passent dessous. */
  .cendre-lesson-phrase { display: flow-root; }
  .cendre-lesson-footer { padding-top: 6px; }
  .cendre-companion.is-folded { display: flex; }
}
@media (max-width: 360px), (max-height: 700px) and (max-width: 720px) {
  /* Petit écran : portrait réduit, texte qui défile sous les jauges, pied toujours visible. */
  .cendre-companion[data-kind="leçon"] .cendre-portrait { width: 64px; height: 84px; }
  .cendre-lesson-body { max-height: calc(100dvh - 208px - 132px - 100px); overflow-y: auto; overscroll-behavior: contain; mask-image: linear-gradient(#000 calc(100% - 18px), transparent); }
}
@media (max-height: 500px) and (orientation: landscape) {
  /* Paysage : la feuille à gauche, le texte d'un côté, les boutons empilés de l'autre. */
  .cendre-companion[data-kind="leçon"] { width: min(640px, calc(100vw - 156px)); max-width: none; }
  .cendre-companion[data-kind="leçon"]:not(.is-folded) { display: flex; align-items: flex-start; }
  .cendre-companion[data-kind="leçon"] .cendre-portrait { float: none; flex: 0 0 64px; width: 64px; height: 84px; }
  .cendre-companion[data-kind="leçon"]:not(.is-folded) .cendre-card { display: grid; grid-template-columns: minmax(0, 1fr) 136px; grid-template-areas: "head foot" "body foot" "state foot"; column-gap: 12px; align-items: start; }
  .cendre-companion[data-kind="leçon"] .cendre-heading { grid-area: head; }
  .cendre-companion[data-kind="leçon"] .cendre-lesson-body { grid-area: body; max-height: calc(100dvh - 68px - 120px); overflow-y: auto; }
  .cendre-companion[data-kind="leçon"] .cendre-lesson-status { grid-area: state; }
  .cendre-companion[data-kind="leçon"] .cendre-lesson-footer { grid-area: foot; flex-direction: column; align-items: stretch; justify-content: flex-start; padding-top: 0; border: 0; }
  .cendre-companion[data-kind="leçon"] .cendre-lesson-fold { margin: 0; order: 9; }
  .cendre-companion.is-folded { left: max(12px, env(safe-area-inset-left)); justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  .cendre-companion,.cendre-companion * { animation: none !important; transition: none !important; }
}
