/* ==========================================================================
   Pivotari — "New message" proposal composer (popup)
   Uses the tokens from styles.css
   ========================================================================== */

.compose-layer {
  position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; padding: 24px;
  visibility: hidden; pointer-events: none;
}
.compose-layer.open { visibility: visible; pointer-events: auto; }
.compose-scrim {
  position: absolute; inset: 0; background: rgba(243,238,227,.35);
  backdrop-filter: blur(10px) saturate(140%); -webkit-backdrop-filter: blur(10px) saturate(140%);
  opacity: 0; transition: opacity .6s var(--ease-out);
}
.compose-layer.open .compose-scrim { opacity: 1; }

.compose {
  position: relative; width: min(680px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column;
  background: rgba(251,249,244,.93); backdrop-filter: saturate(170%) blur(28px); -webkit-backdrop-filter: saturate(170%) blur(28px);
  border: 1px solid rgba(255,254,250,.7); border-radius: 22px; overflow: hidden;
  box-shadow: 0 1px 0 rgba(255,254,250,.8) inset, 0 50px 120px -30px rgba(20,20,20,.45);
  transform-origin: var(--ox, 50%) var(--oy, 100%);
  transform: translateY(40px) scale(.92); opacity: 0;
  transition: transform .75s var(--ease-out), opacity .5s var(--ease-out);
}
.compose-layer.open .compose { transform: none; opacity: 1; }
.compose.sending { transform: translateY(-40px) scale(.96) !important; opacity: .0 !important; transition: transform .7s var(--ease-out), opacity .5s .15s; }

/* title bar */
.compose-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--line);
  background: rgba(243,238,227,.55);
}
.compose-bar .lights { display: flex; gap: 7px; }
.compose-bar .lights i { width: 11px; height: 11px; border-radius: 50%; background: var(--grey-4); transition: background .3s; }
.compose-bar:hover .lights i:first-child { background: #d9695f; }
.compose-bar:hover .lights i:nth-child(2) { background: #e0b44d; }
.compose-bar:hover .lights i:nth-child(3) { background: #7fb069; }
.compose-bar .title { font-size: .86rem; font-weight: 500; color: var(--ink-2); letter-spacing: .01em; }
.compose-close {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--card);
  display: grid; place-items: center; cursor: pointer; color: var(--ink); transition: transform .6s var(--ease-out), background .3s, color .3s;
}
.compose-close:hover { transform: rotate(90deg); background: var(--ink); color: var(--on-ink); }
.compose-close svg { width: 14px; height: 14px; }

/* body */
.compose form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.compose-scroll { overflow-y: auto; flex: 1; }
.hline {
  display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 12px;
  padding: 0 22px; border-bottom: 1px solid var(--line-2); min-height: 52px;
  opacity: 0; transform: translateY(8px); transition: opacity .6s var(--ease-out), transform .6s var(--ease-out), background .3s;
  transition-delay: calc(var(--i, 0) * 60ms + 200ms);
}
.compose-layer.open .hline { opacity: 1; transform: none; }
.hline:focus-within { background: rgba(255,254,250,.55); }
.hline > label, .hline > .k { font-size: .82rem; color: var(--grey-2); letter-spacing: .01em; }
.hline input {
  width: 100%; border: 0; outline: 0; background: transparent; font: 400 .98rem var(--sans); color: var(--ink);
  padding: 14px 0; caret-color: var(--accent);
}
.hline input::placeholder, .compose textarea::placeholder { color: var(--grey-3); }
.hline .pair { display: grid; grid-template-columns: 1fr 1.2fr; gap: 14px; }
.hline .pair input + input { border-left: 1px solid var(--line-2); padding-left: 14px; }
.to-chip {
  display: inline-flex; align-items: center; gap: 8px; justify-self: start;
  padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
  font-size: .88rem; color: var(--ink-2);
}
.to-chip b { width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: var(--on-ink); display: grid; place-items: center; font: 400 .8rem var(--serif); }
.to-chip span { color: var(--grey-2); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 0; }
.tag-btn {
  font: 500 .8rem var(--sans); color: var(--grey-1); background: transparent; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px;
  transition: background .35s, color .35s, border-color .35s, transform .4s var(--ease-out);
}
.tag-btn:hover { border-color: var(--grey-3); transform: translateY(-1px); }
.tag-btn[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

.compose textarea {
  display: block; width: 100%; min-height: 190px; resize: vertical; border: 0; outline: 0; background: transparent;
  font: 400 1rem/1.7 var(--sans); color: var(--ink); padding: 18px 22px; caret-color: var(--accent);
  opacity: 0; transition: opacity .7s var(--ease-out) .55s;
}
.compose-layer.open .compose textarea { opacity: 1; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* footer */
.compose-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 14px 16px 14px 22px; border-top: 1px solid var(--line); background: rgba(243,238,227,.45);
}
.compose-foot .note { font-size: .8rem; color: var(--grey-2); max-width: 340px; }
.compose-foot .note.err { color: #b13a3a; }
.compose-foot .note a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.send svg { width: 16px; height: 16px; }
.send:hover svg { transform: translate(3px, -3px); }
.send[disabled] { opacity: .6; cursor: progress; }
.hline.invalid { background: rgba(177,58,58,.05); }
.hline.invalid > label { color: #b13a3a; }

/* sent state */
.sent {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 40px;
  background: var(--bg); opacity: 0; visibility: hidden; transition: opacity .6s var(--ease-out);
}
.compose.done .sent { opacity: 1; visibility: visible; }
.sent svg.tick { width: 74px; height: 74px; margin: 0 auto 26px; }
.sent svg.tick circle { stroke: var(--accent); stroke-dasharray: 220; stroke-dashoffset: 220; }
.sent svg.tick path { stroke: var(--ink); stroke-dasharray: 60; stroke-dashoffset: 60; }
.compose.done .sent svg.tick circle { animation: draw 1s var(--ease-out) .15s forwards; }
.compose.done .sent svg.tick path { animation: draw .7s var(--ease-out) .8s forwards; }
.sent h3 { font-family: var(--serif); font-weight: 400; font-size: clamp(2.2rem, 5vw, 3rem); line-height: 1.05; margin-bottom: 12px; }
.sent h3 em { color: var(--accent-text); }
.sent p { max-width: 380px; margin: 0 auto 28px; }

body.compose-open { overflow: hidden; }

@media (max-width: 640px) {
  .compose-layer { padding: 0; place-items: end center; }
  .compose { width: 100%; max-height: 92vh; border-radius: 22px 22px 0 0; transform: translateY(100%); }
  .hline { grid-template-columns: 70px 1fr; padding: 0 16px; }
  .hline .pair { grid-template-columns: 1fr; gap: 0; }
  .hline .pair input + input { border-left: 0; padding-left: 0; border-top: 1px solid var(--line-2); }
  .compose textarea { padding: 16px; min-height: 160px; }
  .compose-foot { padding: 12px 16px; }
  .compose-foot .note { order: 2; flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .compose, .hline, .compose textarea { opacity: 1; transform: none; }
}

/* ---------- Platform picker (search + live suggestions) ---------- */
.hline-tags { align-items: start; }
.hline-tags > label { padding-top: 17px; }
.tagbox { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 0; min-width: 0; }
.picked { display: contents; }
.chip-on {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 9px 7px 13px; border-radius: 999px;
  background: var(--ink); color: var(--on-ink); border: 1px solid var(--ink); cursor: pointer;
  font: 500 .8rem var(--sans); animation: chip-in .45s var(--ease-out) both;
}
.chip-on i { font-style: normal; font-size: .95rem; line-height: 1; opacity: .55; transition: opacity .25s, transform .4s var(--ease-out); }
.chip-on:hover i { opacity: 1; transform: rotate(90deg); }
.finder {
  display: inline-flex; align-items: center; gap: 7px; flex: 0 1 170px; min-width: 130px;
  padding: 0 12px; height: 34px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
  transition: border-color .3s, box-shadow .4s var(--ease-out), flex-basis .5s var(--ease-out);
}
.finder:focus-within { border-color: var(--grey-3); box-shadow: 0 0 0 4px rgba(184,155,94,.14); flex-basis: 220px; }
.finder svg { width: 15px; height: 15px; color: var(--grey-2); flex: none; }
.finder input { border: 0; outline: 0; background: transparent; width: 100%; font: 400 .86rem var(--sans); color: var(--ink); padding: 0; caret-color: var(--accent); }
.finder input::placeholder { color: var(--grey-3); }
.suggest { display: contents; }
.chip-add {
  font: 500 .8rem var(--sans); color: var(--grey-1); background: transparent; cursor: pointer;
  border: 1px dashed var(--grey-4); border-radius: 999px; padding: 7px 12px;
  transition: background .3s, color .3s, border-color .3s, transform .4s var(--ease-out);
  animation: chip-in .5s var(--ease-out) both; animation-delay: calc(var(--k, 0) * 45ms);
}
.chip-add::before { content: "+ "; color: var(--accent); }
.chip-add:hover { border-style: solid; border-color: var(--grey-3); color: var(--ink); transform: translateY(-1px); }
.chip-add.other::before, .chip-add.custom::before { content: ""; }
.chip-add.other { border-style: solid; }
.chip-add.other.on { background: var(--bg-3); color: var(--ink); border-color: var(--grey-3); }
.chip-add.custom { border-style: solid; color: var(--ink); }
@keyframes chip-in { from { opacity: 0; transform: translateY(6px) scale(.96); } to { opacity: 1; transform: none; } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.hline-other { max-height: 0; min-height: 0; border-bottom-color: transparent; overflow: hidden; transition: max-height .6s var(--ease-out), opacity .6s var(--ease-out), transform .6s var(--ease-out), border-color .3s, background .3s; }
.compose-layer.open .hline-other { opacity: 0; transform: translateY(-6px); }
.compose-layer.open .hline-other.show { max-height: 80px; min-height: 52px; opacity: 1; transform: none; border-bottom-color: var(--line-2); transition-delay: 0s; }

@media (max-width: 640px) {
  .finder { flex: 1 1 100%; }
  .finder:focus-within { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .chip-on, .chip-add { animation: none; }
}
