/*
 * Bond Composer — Paper DNA on the writing sheet only.
 *
 * Pairs with js/bond-stream.js BondComposerDNA and BondProceduralTextures.
 * Side recipient preview (#bondComposerPreview) is disabled per product sign-off.
 */

/* ───────────────────────────────────────────────────────────────────
   (a) Procedural paper-DNA badge on the composition surface
   The JS module sets `data-composer-dna="1"` on #canvasPaperSheet
   once it has layered the procedural grain over the existing
   stationery background. We add a subtle inner highlight to amplify
   the perceived paper depth, and a soft outline ring to telegraph
   "this is real stationery" without competing with the existing
   stationery shadow.
   ─────────────────────────────────────────────────────────────────── */
.canvas-paper-sheet[data-composer-dna="1"] {
  padding: 30px 40px 44px 48px;
  box-shadow:
    0 12px 36px rgba(0,0,0,0.32),
    0 2px 8px rgba(0,0,0,0.18),
    inset 0 0 80px rgba(255,255,255,0.08),
    inset 0 0 2px rgba(255,255,255,0.22),
    inset 0 1px 0 rgba(255,255,255,0.35);
  background-blend-mode: multiply, normal;
}

/* Letter margins — text begins near the top like real stationery (a short
   top margin, not glued to the edge and not stranded mid-page). */
.canvas-paper-sheet[data-composer-dna="1"] .capture-canvas-textarea {
  padding: 16px 6px 28px 2px;
  min-height: 320px;
  line-height: 2.05;
  box-sizing: border-box;
}
.canvas-paper-sheet[data-composer-dna="1"] .capture-canvas-textarea::placeholder {
  color: rgba(60, 45, 32, 0.38);
  font-style: italic;
}

/* Ink on paper — readable contrast (no mix-blend-mode; it killed legibility). */
.canvas-paper-sheet .capture-canvas-textarea,
.canvas-paper-sheet textarea {
  mix-blend-mode: normal;
  color: rgba(18, 12, 8, 0.94);
  text-shadow: 0.2px 0.35px 0 rgba(0, 0, 0, 0.1);
  -webkit-font-smoothing: antialiased;
  caret-color: rgba(18, 12, 8, 0.95);
}
.canvas-paper-sheet[data-composer-dna="1"] .capture-canvas-textarea,
.canvas-paper-sheet[data-composer-dna="1"] textarea {
  mix-blend-mode: normal;
  color: rgba(18, 12, 8, 0.94);
  text-shadow: 0.2px 0.35px 0 rgba(0, 0, 0, 0.1);
  -webkit-font-smoothing: antialiased;
  caret-color: rgba(18, 12, 8, 0.95);
}
.canvas-paper-sheet[data-composer-dna="1"] .canvas-textarea::selection,
.canvas-paper-sheet[data-composer-dna="1"] textarea::selection {
  background: rgba(122, 31, 24, 0.22);
}

/* Recipient preview pane — disabled (product: no side-box on composer). */
.bondc-composer-preview,
#bondComposerPreview {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
}

/* Legacy preview styles below — inert while disabled. */
.bondc-composer-preview--legacy {
  position: absolute;
  right: auto;
  left: calc(50% + min(210px, 42vw) + 20px);
  top: 46%;
  transform: translateY(-50%) translateX(20px);
  width: 220px;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s cubic-bezier(0.22,1,0.36,1),
              transform 0.5s cubic-bezier(0.22,1,0.36,1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  /* Do not steal taps from the composer underneath. */
}
.bondc-composer-preview.is-visible {
  opacity: 1;
  transform: translateY(-50%);
}
/* Crane-style envelope — Lettra body + baronial flap (56% apex).
   Procedural grain is painted on top via applyPaperToElement. */
.bondc-composer-preview-envelope {
  position: relative;
  width: 100%;
  height: 248px;
  border-radius: 4px;
  background: linear-gradient(165deg, #faf6ee 0%, #f2ead8 50%, #e6dcc4 100%);
  box-shadow:
    0 14px 34px rgba(0,0,0,0.48),
    0 3px 10px rgba(0,0,0,0.28),
    inset 0 1px 0 rgba(255,255,255,0.5);
  overflow: hidden;
  transform: perspective(820px) rotateX(3deg) rotate(-0.6deg);
}
.bondc-composer-preview-envelope::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0,0,0,0.04) 0%, transparent 18%, transparent 82%, rgba(0,0,0,0.05) 100%);
  pointer-events: none;
  z-index: 1;
}
.bondc-composer-preview-flap {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: linear-gradient(180deg, rgba(255,255,255,0.42) 0%, rgba(0,0,0,0.05) 88%);
  clip-path: polygon(6% 0, 94% 0, 50% 56%);
  pointer-events: none;
  box-shadow: inset 0 -1px 0 rgba(154,135,92,0.35);
}
.bondc-composer-preview-flap::after {
  content: "";
  position: absolute;
  left: 6%;
  right: 6%;
  top: 0;
  height: 56%;
  border-bottom: 1px solid rgba(120,100,70,0.28);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  pointer-events: none;
}

.bondc-composer-preview-window {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  z-index: 3;
  width: 72%;
  max-width: 168px;
  min-height: 58px;
  padding: 10px 12px 8px;
  box-sizing: border-box;
  text-align: center;
  background: rgba(246, 239, 220, 0.94);
  border: 0.5px solid rgba(155, 135, 92, 0.5);
  border-radius: 2px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.65),
    0 2px 8px rgba(0,0,0,0.12);
  pointer-events: none;
}
.bondc-composer-preview-window-to {
  display: block;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(80,55,30,0.5);
  margin-bottom: 2px;
}
.bondc-composer-preview-window-name {
  display: block;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.25;
  color: rgba(42,29,18,0.9);
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bondc-composer-preview-postmark {
  position: absolute;
  top: 8px;
  right: 6px;
  left: auto;
  width: 82px;
  height: 82px;
  z-index: 5;
  opacity: 0.88;
  transform: rotate(-7deg);
  pointer-events: none;
}
.bondc-composer-preview-postmark svg {
  width: 100%;
  height: 100%;
}

.bondc-composer-preview-from {
  position: absolute;
  left: 50%;
  bottom: 22%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  max-width: 78%;
  pointer-events: none;
}
.bondc-composer-preview-from-label {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-size: 11px;
  color: rgba(58,42,28,0.52);
  letter-spacing: 0.06em;
}
.bondc-composer-preview-from-name {
  font-family: 'Caveat', cursive;
  font-size: 20px;
  color: rgba(36,24,12,0.9);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Wax on flap point — matches ceremony + email artwork placement. */
.bondc-composer-preview-wax {
  position: absolute;
  left: 50%;
  bottom: 14%;
  transform: translateX(-50%);
  z-index: 6;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  overflow: visible;
  pointer-events: none;
}
.bondc-composer-preview-wax-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow:
    0 2px 6px rgba(0,0,0,0.45),
    inset 0 1px 2px rgba(255,255,255,0.15);
}
.bondc-composer-preview-wax-monogram {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 600;
  font-size: 22px;
  color: rgba(255,238,210,0.92);
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  letter-spacing: 0.02em;
}
/* Cleavage halves — two thin sectors over the wax disc that drift
   apart in a slow, subtle loop. Spec §6: single crack line, two
   pieces, no debris cascade. Default static; .is-visible parent
   triggers the loop. */
.bondc-composer-preview-wax-half {
  position: absolute;
  left: 0;
  right: 0;
  height: 50%;
  background: rgba(0,0,0,0);
  pointer-events: none;
  transform-origin: 50% 100%;
  transition: transform 0.6s cubic-bezier(0.22,1,0.36,1);
}
.bondc-composer-preview-wax-half--top {
  top: 0;
  transform-origin: 50% 100%;
}
.bondc-composer-preview-wax-half--bot {
  bottom: 0;
  transform-origin: 50% 0;
}
.bondc-composer-preview.is-visible:not(.bondc-composer-preview--static)
  .bondc-composer-preview-wax-half--top {
  animation: bondcComposerCleaveTop 9s cubic-bezier(0.22,1,0.36,1) infinite;
}
.bondc-composer-preview.is-visible:not(.bondc-composer-preview--static)
  .bondc-composer-preview-wax-half--bot {
  animation: bondcComposerCleaveBot 9s cubic-bezier(0.22,1,0.36,1) infinite;
}
@keyframes bondcComposerCleaveTop {
  0%, 65%, 100% { transform: translateY(0) rotate(0); opacity: 0; }
  72%           { transform: translateY(-3px) rotate(-0.5deg); opacity: 0.5; }
  82%           { transform: translateY(-7px) rotate(-1.5deg); opacity: 0.35; }
  95%           { transform: translateY(0) rotate(0); opacity: 0; }
}
@keyframes bondcComposerCleaveBot {
  0%, 65%, 100% { transform: translateY(0) rotate(0); opacity: 0; }
  72%           { transform: translateY(2px) rotate(0.5deg); opacity: 0.5; }
  82%           { transform: translateY(5px) rotate(1.5deg); opacity: 0.35; }
  95%           { transform: translateY(0) rotate(0); opacity: 0; }
}
/* Override the half overlays to be visible during the animation; the
   keyframes set opacity from 0→0.5 so the cleavage line "appears"
   only during the cleavage moment, then fades back. The halves are
   transparent — they exist only to drive the line + drift. */
.bondc-composer-preview.is-visible:not(.bondc-composer-preview--static)
  .bondc-composer-preview-wax-half {
  background: linear-gradient(180deg, rgba(0,0,0,0.0) 70%, rgba(0,0,0,0.25) 100%);
}
.bondc-composer-preview.is-visible:not(.bondc-composer-preview--static)
  .bondc-composer-preview-wax-half--bot {
  background: linear-gradient(0deg, rgba(0,0,0,0.0) 70%, rgba(0,0,0,0.25) 100%);
}


/* Reduced-motion + narrow-screen layout ───────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .bondc-composer-preview.is-visible
    .bondc-composer-preview-wax-half {
    animation: none !important;
  }
}
@media (max-width: 960px) {
  .bondc-composer-preview {
    left: auto;
    right: 12px;
    width: 168px;
    transform: translateY(-50%) translateX(20px);
  }
  .bondc-composer-preview.is-visible {
    transform: translateY(-50%);
  }
  .bondc-composer-preview-envelope { height: 188px; }
  .bondc-composer-preview-postmark { width: 68px; height: 68px; }
  .bondc-composer-preview-from-name { font-size: 17px; }
  .bondc-composer-preview-window-name { font-size: 15px; }
}
/* Below 720px we anchor to the bottom-center above the action bar so
   the preview never collides with the textarea on a phone. */
@media (max-width: 720px) {
  .bondc-composer-preview {
    position: fixed;
    right: auto;
    left: 50%;
    bottom: 110px;
    top: auto;
    transform: translateX(-50%) translateY(12px);
    width: 220px;
  }
  .bondc-composer-preview.is-visible {
    transform: translateX(-50%) translateY(0);
  }
}
/* Reflection mode is a focused journaling state with no recipient —
   suppress the preview pane entirely so the canvas stays clean. */
.capture-canvas.reflection-mode .bondc-composer-preview { display: none !important; }

/* ───────────────────────────────────────────────────────────────────
   (c) Post-cleavage Wallet button host
   Mounted inside #letterCeremony by the BondCeremony.mount wrapper in
   js/bond-stream.js (in-app) and by an inline hook in bond-letter.html
   (public page). Position: bottom-center with a soft fade-in that
   matches the existing post-done Close button cadence.
   ─────────────────────────────────────────────────────────────────── */
.bondc-letter-wallet-host {
  position: absolute;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%) translateY(8px);
  z-index: 6;
  opacity: 0;
  transition: opacity 0.6s cubic-bezier(0.22,1,0.36,1),
              transform 0.6s cubic-bezier(0.22,1,0.36,1);
  pointer-events: none;
}
.bondc-letter-wallet-host.is-visible {
  opacity: 1;
  transform: translateX(-50%);
  pointer-events: auto;
}
/* Base Apple-HIG Wallet button — duplicated from bond-calendar.html
   (line 280-288) so this file is the single CSS source bond-letter.html
   and bond-interface.html need to load alongside js/bond-wallet-pass.js
   for the post-cleavage letter wallet button. Calendar/invite pages
   keep their inline styles unchanged. */
.bondwallet-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: #000; color: #fff; border: none; border-radius: 8px;
  padding: 6px 14px 6px 10px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  cursor: pointer; min-height: 34px; line-height: 1.0;
  transition: opacity 0.15s, transform 0.1s;
}
.bondwallet-btn:hover { opacity: 0.92; transform: translateY(-1px); }
.bondwallet-btn:disabled { opacity: 0.55; cursor: progress; transform: none; }
.bondwallet-btn-apple {
  display: inline-flex; align-items: center; justify-content: center;
}
.bondwallet-btn-apple svg { display: block; color: #fff; }
.bondwallet-btn-text {
  display: flex; flex-direction: column; align-items: flex-start;
  justify-content: center; text-align: left;
}
.bondwallet-btn-small {
  font-size: 0.55rem; letter-spacing: 0.02em; color: #e5e5e5;
  line-height: 1.0; text-transform: none;
}
.bondwallet-btn-large {
  font-size: 0.95rem; font-weight: 600; letter-spacing: -0.01em;
  color: #fff; line-height: 1.05; margin-top: 1px;
}

.bondc-letter-wallet-host .bondwallet-btn {
  /* Slightly more compact than the calendar surface — the post-cleavage
     moment is contemplative, the affordance should be present but not
     compete with the letter content. */
  padding: 8px 16px;
  font-size: 14px;
}
@media (max-width: 540px) {
  .bondc-letter-wallet-host {
    bottom: 70px;
  }
}

/* Variant used by bond-letter.html — the button sits INSIDE the
   growth-card's CTA row instead of floating over the stage. Reset
   the absolute-positioning + scaling so it inherits the row's flow,
   and stretch the button to match sibling CTA widths so the column
   looks deliberate on mobile. */
.bondc-letter-wallet-host--growth {
  position: static;
  transform: none;
  opacity: 1;
  pointer-events: auto;
  flex: 1 1 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bondc-letter-wallet-host--growth .bondwallet-btn {
  width: 100%;
  justify-content: center;
  min-height: 44px;
  padding: 12px 18px;
  font-size: 14px;
}
@media (max-width: 540px) {
  .bondc-letter-wallet-host--growth {
    flex: 1 1 100%;
  }
}
