/* ═══════════════ Djouney v3 — glisser quelque chose (module M3) ═══════════════
   components/objects.js : classes .ob- (voir ARCHITECTURE.md § 14.2).
   Seule couleur vive : la fleur du duo (cachets pleins, bouton « Sceller »). */

/* ─── Les cachets de cire ─── */
.ob-tokens {
  --ob-token: 14px;
  display: inline-flex;
  align-items: center;
  gap: calc(var(--ob-token) * .5);
  vertical-align: middle;
  line-height: 0;
}

/* Le creux : l'empreinte d'un cachet consommé, pressée dans le papier (--deboss à l'échelle du cachet). */
.ob-token {
  position: relative;
  flex: none;
  width: var(--ob-token);
  height: var(--ob-token);
  border-radius: 50%;
  background: var(--porcelain);
  box-shadow:
    inset 1.5px 2px 3px rgba(var(--shadow-rgb), .3),
    inset -1px -1px 2px rgba(var(--light-rgb), calc(.95 * var(--hl-a)));
}

/* Le vrai cachet de cire (createWaxSeal) : il déborde un peu du creux pour le couvrir, se pose (scale)
   ou fond (fondu) quand le solde change. Le cachet garde ses propres transitions (fleur héritée). */
.ob-token__wax {
  position: absolute;
  inset: -22%;
  opacity: 0;
  transform: scale(.35) rotate(-14deg);
  transition: transform 640ms var(--ease), opacity 420ms var(--ease);
  transition-delay: var(--ob-delay, 0ms);
  pointer-events: none;
}
.ob-token__wax .ink-seal { display: block; width: 100%; height: 100%; }
.ob-token:nth-child(2) .ob-token__wax { transform: scale(.35) rotate(10deg); }
.ob-token:nth-child(3) .ob-token__wax { transform: scale(.35) rotate(-6deg); }
.ob-token.is-full .ob-token__wax { opacity: 1; transform: none; }
/* Chaque cachet un peu tourné, comme pressé à la main. */
.ob-token.is-full:nth-child(2) .ob-token__wax { transform: rotate(-9deg); }
.ob-token.is-full:nth-child(3) .ob-token__wax { transform: rotate(7deg); }

/* ─── La feuille ─── */
.ob { display: flex; flex-direction: column; min-width: 0; }
.ob-view { display: flex; flex-direction: column; min-width: 0; }
.ob-compose,
.ob-menu.is-back { animation: obIn var(--mid) var(--ease); }
@keyframes obIn { from { opacity: 0; transform: translateY(8px); } }

/* Un prénom très long, sans espace, se coupe plutôt que d'élargir la feuille (qui défilerait de côté). */
.ob-title { overflow-wrap: anywhere; }
.ob-sub { margin-bottom: 12px; color: rgba(var(--ink-rgb), .84); overflow-wrap: anywhere; }
.ob-label { margin: 4px 0 -4px; color: rgba(var(--ink-rgb), .84); }

/* ─── Écran 1 : le solde et les trois objets ─── */
.ob-purse {
  display: flex;
  align-items: center;
  min-height: 24px;
  margin: -2px 0 20px;
}

.ob-cards { display: flex; flex-direction: column; gap: 12px; }

.ob-card {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 76px;
  padding: 14px 16px 14px 14px;
  border: 0;
  border-radius: 20px;
  background: var(--milk);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--emboss-sm), inset 1px 1px 0 rgba(var(--light-rgb), calc(.95 * var(--hl-a)));
  transition: transform .15s var(--ease), box-shadow .25s var(--ease), opacity .4s var(--ease), background-color .4s var(--ease);
}
.ob-card:active { transform: translateY(1px); box-shadow: var(--deboss); }
.ob-card__icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--porcelain);
  box-shadow: var(--deboss);
  color: var(--stem);
}
.ob-card__icon svg { width: 24px; height: 24px; }
.ob-card__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.ob-card__title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.25;
}
.ob-card__line {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 14px;
  line-height: 1.4;
  color: rgba(var(--ink-rgb), .84);
}
.ob-card__go { display: grid; place-items: center; color: rgba(var(--ink-rgb), .6); transform: scaleX(-1); }
.ob-card__go svg { width: 18px; height: 18px; }

/* Plus de cachet : les objets perdent leur relief, comme estompés dans la porcelaine. */
.ob-card[aria-disabled="true"] {
  opacity: .5;
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(var(--hollow-rgb), .7);
  cursor: not-allowed;
}
.ob-card[aria-disabled="true"]:active { transform: none; box-shadow: inset 0 0 0 1px rgba(var(--hollow-rgb), .7); }
.ob-card[aria-disabled="true"] .ob-card__icon { box-shadow: none; background: transparent; }

.ob-note {
  margin: 18px 0 2px;
  text-align: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 15.5px;
  line-height: 1.45;
  color: var(--ink);
}
.ob-note.is-nudged { animation: obNudge 900ms var(--ease); }
@keyframes obNudge { 35% { opacity: .4; transform: translateY(-2px); } }

/* ─── Composition ─── */
.ob-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.ob-fields > .sheet-title { margin-top: -4px; }
.ob-fields > .ob-sub { margin-top: -10px; margin-bottom: 0; }

.ob-back {
  align-self: flex-start;
  min-height: 44px;
  margin: -6px 0 -6px -10px;
  gap: 4px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
}
.ob-back svg { width: 16px; height: 16px; }

.ob-pane { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ob-pane--voice { margin-top: 2px; }
.ob-hint {
  margin: 0;
  text-align: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 15px;
  color: rgba(var(--ink-rgb),.86);
}

/* La photo, au format 4/5 : creusée tant qu'elle est vide, en relief une fois choisie. */
.ob-photo-wrap { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ob-photo {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 236px);
  aspect-ratio: 4 / 5;
  padding: 0;
  border: 0;
  border-radius: 18px;
  overflow: hidden;
  background: var(--porcelain);
  box-shadow: var(--deboss);
  color: var(--stem);
  transition: box-shadow .45s var(--ease), background-color .45s var(--ease), transform .15s var(--ease);
}
.ob-photo:active { transform: translateY(1px); }
.ob-photo.has-photo { background: var(--milk); box-shadow: var(--emboss); }
.ob-photo__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: obDevelop 900ms var(--ease);
}
@keyframes obDevelop { from { opacity: 0; filter: saturate(.2) brightness(1.15); } }
.ob-photo__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 15px;
  line-height: 1.4;
  color: rgba(var(--ink-rgb),.86);
}
.ob-photo__empty svg { width: 34px; height: 34px; color: var(--stem); }
.ob-photo.is-loading { cursor: progress; }
.ob-photo.is-loading .ob-photo__empty { animation: obBreathe 1.6s var(--ease) infinite alternate; }
@keyframes obBreathe { to { opacity: .55; } }
.ob-photo__change { min-height: 44px; font-size: 14px; }

/* Le choix du secret : trois segments creusés, celui choisi en relief. */
.ob-seg {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--porcelain);
  box-shadow: var(--deboss);
}
.ob-seg__btn {
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(var(--ink-rgb),.84);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  transition: background-color .3s var(--ease), box-shadow .3s var(--ease), color .3s var(--ease);
}
.ob-seg__btn[aria-pressed="true"] { background: var(--milk); color: var(--ink); box-shadow: var(--emboss-sm); }

/* Le papier réglé où l'on écrit à la main. */
.ob-paper {
  display: block;
  width: 100%;
  min-height: calc(30px * 3 + 20px);
  max-height: 46vh;
  padding: 10px 16px;
  border: 0;
  border-radius: 16px;
  resize: none;
  field-sizing: content;
  background-color: var(--milk);
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 29px, rgba(var(--ink-rgb),.12) 29px, rgba(var(--ink-rgb),.12) 30px);
  background-position: 0 10px;
  background-attachment: local;
  box-shadow: var(--deboss);
  color: var(--ink);
  font-family: var(--font-hand);
  font-weight: 500;
  font-size: 24px;
  line-height: 30px;
  outline: none;
  overflow-wrap: anywhere;
}
.ob-paper::placeholder { color: var(--ink-faint); }
.ob-paper:focus { box-shadow: var(--deboss), 0 0 0 2px var(--ink-faint); }
.ob-paper--ink { min-height: calc(30px * 6 + 20px); }

.ob-count {
  margin: -6px 4px 0 0;
  text-align: right;
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: rgba(var(--ink-rgb),.84);
}
.ob-count.is-near { color: var(--ink); font-weight: 600; }
.ob-count.is-over { color: var(--ink); font-weight: 600; text-decoration: underline; text-decoration-color: var(--thread); text-underline-offset: 3px; }

/* Le brouillon repris de la ligne d'écriture. */
.ob-draft {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 8px;
  margin: -4px 0 -6px;
}
.ob-draft__text {
  margin: 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 14px;
  color: rgba(var(--ink-rgb),.86);
}
.ob-fresh { min-height: 44px; font-size: 13.5px; }

/* Le lieu secret. */
.ob-place { display: flex; flex-direction: column; gap: 10px; }
.ob-place .ob-label { margin: 6px 0 -2px; }
.ob-locate { align-self: flex-start; }
/* Le nom du lieu fait partie du secret : il s'écrit à la main, comme lui. */
.ob-place-name { font-family: var(--font-hand); font-size: 23px; font-weight: 500; line-height: 1.1; padding-top: 10px; padding-bottom: 10px; }
.ob-locate svg { width: 20px; height: 20px; color: var(--stem); }
.ob-locate.is-busy { cursor: progress; box-shadow: var(--deboss); }
.ob-locate.is-busy svg { animation: obBreathe 1.2s var(--ease) infinite alternate; }
.ob-status {
  margin: 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 15px;
  line-height: 1.45;
  color: rgba(var(--ink-rgb),.86);
}
.ob-status.is-found { color: var(--ink); }
.ob-status.is-error { padding-left: 10px; color: var(--ink); box-shadow: inset 2px 0 0 var(--thread); }

/* Les ambiances de la capsule : en relief, celle choisie enfoncée dans la porcelaine. */
.ob-amb { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.ob-amb__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 66px;
  padding: 8px 4px;
  border: 0;
  border-radius: 16px;
  background: var(--milk);
  color: var(--ink);
  box-shadow: var(--emboss-sm);
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.25;
  text-align: center;
  transition: box-shadow .3s var(--ease), background-color .3s var(--ease), transform .15s var(--ease);
}
.ob-amb__btn svg { width: 22px; height: 22px; color: var(--stem); }
.ob-amb__btn[aria-pressed="true"] { background: var(--porcelain); box-shadow: var(--deboss); font-weight: 600; }

/* Sceller. */
.ob-send { margin-top: 6px; }
.ob-send.is-busy { cursor: progress; }
.ob-send.is-busy:disabled { opacity: .8; }
.ob-why {
  margin: -6px 0 0;
  text-align: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 14px;
  color: rgba(var(--ink-rgb),.84);
}

/* L'anneau de focus épouse chaque pièce (porcelaine.css l'arrondit à 8 px, ce qui déformerait les cartes). */
.ob-card:focus-visible { border-radius: 20px; }
.ob-photo:focus-visible { border-radius: 18px; }
.ob-amb__btn:focus-visible { border-radius: 16px; }
.ob .btn:focus-visible,
.ob-seg__btn:focus-visible { border-radius: 999px; }

@media (max-width: 380px) {
  .ob-amb { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ob-card { gap: 12px; padding-right: 12px; }
}

/* ─── Mouvement réduit : de simples fondus ─── */
@media (prefers-reduced-motion: reduce) {
  .ob-token__wax { transform: none; transition: opacity 400ms ease !important; transition-delay: 0ms !important; }
  .ob-compose,
  .ob-menu.is-back { animation: obFade 300ms ease !important; }
  .ob-photo__img { animation: obFade 400ms ease !important; }
  .ob-note.is-nudged,
  .ob-photo.is-loading .ob-photo__empty,
  .ob-locate.is-busy svg { animation: none !important; }
}
@keyframes obFade { from { opacity: 0; } }
