/* frontend/css/views/wellbeing.css — feuille Bien-être (#/bien-etre), vue js/views/wellbeing.js.
   Maquette : design/maquettes/C_BienEtre.dc.html (mesures reprises telles quelles). Les briques
   communes (feuille, puces, boutons, champs, listes, états vides) viennent de css/components.css.
   Couleurs propres au module (fond de « Ma collection », forme qui respire) : variables --wb-*
   ci-dessous, avec leur version sombre (pas de maquette sombre de cette feuille : valeurs dérivées
   des tuiles sombres de C_Accueil_Sombre.dc.html). */

.wb,
.wb-reader {
  --wb-collection: #F6F3FF;
  --wb-shape: #CDB8FF;
}
[data-theme="dark"] .wb,
[data-theme="dark"] .wb-reader {
  --wb-collection: #251F3A;
  --wb-shape: #8C78E8;
}

/* ---------- Onglets internes (puces de l'en-tête) ---------- */

/* -8 px = les -6 px de .chips (place de l'anneau de focus, components.css) + 2 px de rapprochement. */
.wb-tabs { margin-top: -8px; }

.wb-panel {
  display: flex;
  flex-direction: column;
}

.wb-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- Phrase du jour ---------- */

.wb-phrase {
  border-radius: var(--r-card);
  padding: 12px 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.wb-phrase__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
}
.wb-phrase__next {
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  padding: 0;
  border-radius: 22px;
  background: var(--glass);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}
.wb-phrase__text {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 24px;
  line-height: 28px;
  overflow-wrap: anywhere;
}
.wb-phrase__link { align-self: flex-start; margin-left: -4px; }

/* ---------- Ma collection ---------- */

.wb-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wb-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-height: 20px;
}
.wb-section__head .link-btn { align-self: center; margin: -12px -4px -12px 0; }
.wb-section__aside {
  font-size: 13px;
  line-height: 16px;
  color: var(--mute);
}

.wb-collection {
  background: var(--wb-collection);
  border-radius: var(--r-card);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.wb-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.wb-dots .is-new { animation: wb-pop 0.45s ease-out; }
@keyframes wb-pop {
  0% { transform: scale(0); }
  70% { transform: scale(1.35); }
  100% { transform: scale(1); }
}
.wb-collection__empty {
  font-size: 13px;
  line-height: 17px;
  color: var(--mute);
}
.wb-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  line-height: 16px;
}
.wb-legend__item {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ---------- Formulaire court (moment, phrase) ---------- */

.wb-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  border-radius: var(--r-card);
  border: 1.5px solid var(--line);
  background: var(--surface);
}
.wb-form__textrow {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.wb-form__textrow .field__input {
  flex: 1;
  min-width: 0;
}
textarea.wb-form__text { min-height: 76px; }
.wb-form__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}
.wb-form__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.wb-spacer { flex: 1; }

/* Champ date iOS : sans apparence native, il garde la hauteur et le rayon des autres champs. */
.wb-date {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
  display: block;
  line-height: 44px;
}
.wb-date::-webkit-date-and-time-value { text-align: left; }

/* Choix du type : trois boutons de 52 px (maquette), vraies cases radio cachées. */
.wb-kinds {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.wb-kinds legend {
  padding: 0;
  margin-bottom: 6px;
}
.wb-kinds__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.wb-kind {
  position: relative;
  display: flex;
  min-width: 0;
}
.wb-kind__box {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0 4px;
  border-radius: 18px;
  border: 1.5px solid var(--field-line);
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  line-height: 15px;
  font-weight: 600;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
}
.wb-kind input:checked + .wb-kind__box {
  border-color: var(--acc);
  background: var(--lilas);
  box-shadow: inset 0 0 0 1px var(--acc);
}
.wb-kind input:focus-visible + .wb-kind__box {
  outline: 3px solid var(--acc);
  outline-offset: 2px;
}
.wb-kind input[aria-invalid="true"] + .wb-kind__box { border-color: var(--danger); }

.wb-themes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ---------- Lignes de moment (« Souviens-toi », carnet) ---------- */

.wb-mlist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wb-mrow {
  width: 100%;
  min-height: 56px;
  padding: 8px 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}
button.wb-mrow {
  font: inherit;
  cursor: pointer;
}
button.wb-mrow:active { background: var(--chip); }
.wb-mrow__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.wb-mrow__text {
  font-size: 15px;
  line-height: 19px;
  font-weight: 500;
}
.wb-mrow__meta {
  font-size: 12px;
  line-height: 15px;
  color: var(--mute);
}
.wb-mrow__edit {
  flex: none;
  display: flex;
  color: var(--mute);
}

/* ---------- Carnet ---------- */

.wb-search {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wb-search__input {
  -webkit-appearance: none;
  appearance: none;
}
.wb-results {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.wb-month {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wb-month__title { margin: 0; }

/* ---------- Phrases ---------- */

.wb-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.wb-count {
  font-size: 13px;
  line-height: 16px;
  font-weight: 600;
  color: var(--mute);
}
.wb-plist { margin-top: -4px; }
.wb-prow {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  border-bottom: 1px solid var(--line);
}
.wb-prow-item:last-child .wb-prow { border-bottom: 0; }
.wb-prow-item + .wb-prow-item .wb-form,
.wb-prow-item .wb-form { margin: 8px 0; }
.wb-star {
  flex: none;
  width: 44px;
  height: 44px;
  margin-left: -10px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--mute);
  display: flex;
  align-items: center;
  justify-content: center;
}
.wb-star[aria-pressed="true"] { color: var(--merci); }
.wb-star[aria-busy="true"] { opacity: 0.6; }
.wb-prow__main {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
}
.wb-prow__text {
  font-size: 15px;
  line-height: 19px;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.wb-prow__meta {
  font-size: 12px;
  line-height: 15px;
  color: var(--mute);
}
.wb-prow__edit {
  flex: none;
  display: flex;
  color: var(--mute);
  pointer-events: none;
}

/* ---------- Jour gris ---------- */

.wb-gray {
  background: var(--chip);
  border-radius: var(--r-card);
  padding: 14px 14px 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.wb-gray__col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.wb-gray__title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 18px;
  line-height: 22px;
}
.wb-gray__text {
  font-size: 13px;
  line-height: 17px;
  color: var(--mute);
}
.wb-gray__phase {
  display: block;
  height: 34px;
  padding-top: 6px;
  font-size: 16px;
  line-height: 20px;
  font-weight: 600;
}

.wb-breath {
  position: relative;
  flex: none;
  width: 72px;
  height: 72px;
  border: 0;
  padding: 0;
  border-radius: 36px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
}
.wb-breath__shape {
  width: 56px;
  height: 56px;
  border-radius: 46% 54% 50% 50% / 52% 46% 54% 48%;
  background: var(--wb-shape);
}
/* 8 s par souffle : la forme grandit 4 s (inspire) puis se resserre 4 s (expire). */
.wb-breath__shape.is-breathing { animation: wb-breathe 8s ease-in-out infinite; }
@keyframes wb-breathe {
  0%, 100% { transform: scale(0.68); }
  50% { transform: scale(1); }
}

/* ---------- « Les lire » : plein écran, une phrase à la fois ---------- */

.wb-reader {
  position: fixed;
  inset: 0;
  z-index: 90;            /* au-dessus de la feuille (50), sous la confirmation (100) et les toasts (120) */
  display: flex;
  flex-direction: column;
  padding:
    calc(env(safe-area-inset-top, 0px) + 16px)
    calc(env(safe-area-inset-right, 0px) + 20px)
    max(24px, calc(env(safe-area-inset-bottom, 0px) + 12px))
    calc(env(safe-area-inset-left, 0px) + 20px);
  background: var(--lilas);
  color: var(--ink);
  opacity: 0;
  transition: opacity 200ms ease;
}
.wb-reader.is-open { opacity: 1; }
.wb-reader__close {
  align-self: flex-end;
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  padding: 0;
  border-radius: 22px;
  background: var(--glass);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}
.wb-reader__body {
  flex: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  cursor: pointer;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.wb-reader__text {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 34px;
  line-height: 40px;
  overflow-wrap: anywhere;
}
.wb-reader__nav {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.wb-reader__count {
  font-size: 14px;
  line-height: 18px;
  font-weight: 600;
  color: var(--mute);
}
.wb-flip svg { transform: scaleX(-1); }

/* ---------- Mouvement réduit ---------- */
/* base.css raccourcit déjà toute animation ; ici on les coupe net : la forme reste immobile et
   le texte « Inspire… / Expire… » (minuteur JS) guide seul la respiration. */
@media (prefers-reduced-motion: reduce) {
  .wb-breath__shape.is-breathing,
  .wb-dots .is-new { animation: none; }
  .wb-reader { transition: none; }
}
