/* styles/biomes/epilogue.css
   Biome 8 — THE EPILOGUE ("The Cycle Remembers").

   Redesigned to a receipt triptych + sparkline strip + signature beat,
   reusing the café receipt vocabulary so the closing screen reads as
   "the same document language closing itself" rather than a stats
   dashboard. No System voice fires here; the bottom safe zone is
   reserved exclusively for the "Close the ledger" signature button. */

#epilogue {
  /* Deep settlement-blue base — same tonal floor as the Tide pool.
     The player is looking at the same water from a higher vantage. */
  background:
    radial-gradient(ellipse 80% 60% at 50% 60%,
      rgba(20, 50, 60, 0.55) 0%,
      transparent 70%),
    linear-gradient(180deg,
      #050810 0%,
      #0a1418 60%,
      #0a1820 100%);
}

#epilogue-stage {
  position: absolute;
  inset: var(--narrator-zone) 0 var(--system-zone) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 1vh 5vw 0;
  gap: 2.2vh;
  z-index: 3;
  overflow-y: auto;
}

.epilogue-eyebrow {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: rgba(160, 240, 220, 0.55);
  opacity: 0;
  transition: opacity 1400ms ease;
}
#epilogue.assembled .epilogue-eyebrow { opacity: 1; }

/* =====================================================================
   SPARKLINE STRIP — 3 small SVG charts above the receipts
   ===================================================================== */

#epilogue-sparklines {
  display: flex;
  gap: 2vw;
  align-items: stretch;
  justify-content: center;
  width: min(640px, 90vw);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 1200ms ease, transform 1200ms ease;
}
#epilogue-sparklines.revealed {
  opacity: 1;
  transform: translateY(0);
}

.epi-sparkline {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 10px 6px;
  background: rgba(20, 30, 40, 0.55);
  border: 1px solid rgba(160, 220, 220, 0.18);
  border-radius: 2px;
}
.epi-sl-label {
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(184, 212, 232, 0.7);
}
.epi-sl-svg {
  width: 100%;
  height: 32px;
  display: block;
}
.epi-sl-line {
  fill: none;
  stroke: rgba(160, 240, 220, 0.85);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 4px rgba(160, 240, 220, 0.55));
}
.epi-sl-dot {
  fill: rgba(232, 248, 255, 0.95);
}
.epi-sl-empty {
  font-family: var(--mono);
  font-size: 11px;
  fill: rgba(184, 212, 232, 0.35);
}
.epi-sl-final {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  color: rgba(232, 248, 255, 0.92);
  text-shadow: 0 0 12px rgba(160, 240, 220, 0.3);
}
/* Tone variants — friction reads warmer, chargebacks toll-red */
.epi-sparkline.reclaimed .epi-sl-line {
  stroke: rgba(232, 144, 80, 0.85);
  filter: drop-shadow(0 0 4px rgba(232, 144, 80, 0.5));
}
.epi-sparkline.reclaimed .epi-sl-final {
  color: rgba(248, 200, 152, 0.95);
  text-shadow: 0 0 12px rgba(232, 144, 80, 0.35);
}
/* Chargeback bars (discrete events) */
.epi-sl-bar.hit {
  stroke: rgba(232, 100, 70, 0.95);
  stroke-width: 2;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px rgba(232, 100, 70, 0.5));
}
.epi-sl-bar.miss {
  stroke: rgba(120, 140, 150, 0.35);
  stroke-width: 1.2;
  stroke-linecap: round;
}

/* =====================================================================
   RECEIPT TRIPTYCH — 3 receipts side by side, slight rotation each
   ===================================================================== */

#epilogue-receipts {
  display: flex;
  gap: 1.6vw;
  align-items: stretch;
  justify-content: center;
  width: min(960px, 94vw);
  flex-wrap: wrap;
}

.epi-receipt {
  flex: 1 1 260px;
  max-width: 320px;
  min-width: 240px;
  padding: 14px 18px 18px;
  /* Reusing the café receipt's paper aesthetic — same warm-cream
     gradient + dashed dividers + paper drop-shadow. */
  background:
    linear-gradient(180deg, rgba(248, 240, 220, 0.95) 0%, rgba(232, 220, 196, 0.92) 100%);
  color: #2a1d10;
  border: 1px solid rgba(120, 80, 40, 0.4);
  border-radius: 2px;
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.55),
    0 2px 6px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(20px) rotate(0deg);
  transition:
    opacity   1000ms ease,
    transform 1000ms cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  /* Slight per-card tilt for paper-feel; overridden in reduced motion. */
}
.epi-receipt:nth-child(1) { transform: translateY(20px) rotate(-1.2deg); }
.epi-receipt:nth-child(2) { transform: translateY(20px) rotate(0.8deg);  }
.epi-receipt:nth-child(3) { transform: translateY(20px) rotate(-0.6deg); }

.epi-receipt.revealed { opacity: 1; }
.epi-receipt:nth-child(1).revealed { transform: translateY(0) rotate(-1.2deg); }
.epi-receipt:nth-child(2).revealed { transform: translateY(0) rotate(0.8deg);  }
.epi-receipt:nth-child(3).revealed { transform: translateY(0) rotate(-0.6deg); }

/* Reuse the café receipt's typography vocabulary.
   The classes os-vendor / os-location / os-divider / os-qty / os-name /
   os-price already exist in cafe.css — those styles cascade through. */
.epi-receipt .os-vendor {
  font-size: 0.76rem;
  letter-spacing: 0.22em;
  font-weight: 600;
  text-transform: uppercase;
  color: #3a2618;
}
.epi-receipt .os-location {
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  color: rgba(58, 38, 24, 0.72);
  margin-top: 2px;
  text-transform: lowercase;
}
.epi-receipt .os-divider {
  margin: 10px 0;
  border-top: 1px dashed rgba(120, 80, 40, 0.5);
}
.epi-os-rows {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.epi-os-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  align-items: baseline;
  font-size: 0.7rem;
  color: rgba(40, 24, 12, 0.92);
}
.epi-os-row .os-qty {
  color: rgba(80, 50, 24, 0.75);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.epi-os-row .os-name {
  font-family: var(--serif);
  font-style: italic;
}
.epi-os-row .os-price {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.epi-os-row.negative .os-price {
  color: #8a2418;
  font-weight: 700;
}

/* =====================================================================
   STAMP — large rotated outcome seal in the lower half of each receipt
   ===================================================================== */

.epi-stamp {
  display: inline-block;
  align-self: flex-end;
  margin-top: 8px;
  padding: 6px 14px;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  border: 2.5px solid currentColor;
  border-radius: 2px;
  transform: rotate(-5deg);
  /* Faint ink-bleed via text-shadow + box-shadow */
  text-shadow:
    1px 0 0 currentColor,
    -1px 0 0 rgba(0, 0, 0, 0.1);
  box-shadow:
    inset 0 0 0 1px transparent,
    0 0 0 0 rgba(0, 0, 0, 0);
  opacity: 0.92;
}

.epi-stamp-kept {
  color: #1b5a3a;
  background: rgba(120, 220, 160, 0.12);
  transform: rotate(-4deg);
}
.epi-stamp-reclaimed {
  color: #8a2418;
  background: rgba(220, 80, 60, 0.12);
  transform: rotate(5deg);
}
.epi-stamp-declined {
  color: #3a2618;
  background: rgba(120, 100, 80, 0.14);
  transform: rotate(-2deg);
  opacity: 0.78;
}
.epi-stamp-incomplete {
  color: rgba(80, 60, 40, 0.55);
  background: transparent;
  border-color: rgba(120, 100, 80, 0.45);
  border-style: dashed;
  opacity: 0.7;
  transform: rotate(-3deg);
}

/* SEALED state — fires on signature click. Adds a final CLOSED overlay
   (a giant rotated "CLOSED" stamp across the whole receipt) so the
   document visibly becomes inert. */
.epi-receipt::after {
  content: 'CLOSED';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.4em;
  color: rgba(80, 30, 30, 0);  /* invisible until .sealed */
  border: 4px double rgba(80, 30, 30, 0);
  border-radius: 2px;
  transform: rotate(-12deg) scale(1.2);
  pointer-events: none;
  transition: color 500ms ease, border-color 500ms ease, transform 600ms ease;
}
.epi-receipt.sealed::after {
  color: rgba(120, 30, 30, 0.85);
  border-color: rgba(120, 30, 30, 0.55);
  transform: rotate(-12deg) scale(1);
  text-shadow:
    1px 1px 0 rgba(0, 0, 0, 0.1),
    -1px -1px 0 rgba(255, 220, 200, 0.2);
}

/* =====================================================================
   PER-SCENARIO TINT — each receipt picks up its scenario's palette
   ===================================================================== */

.epi-receipt[data-scenario="cross_border"] {
  border-color: rgba(168, 84, 44, 0.5);
}
.epi-receipt[data-scenario="cross_border"] .os-vendor {
  color: #5a2a14;
}
.epi-receipt[data-scenario="marketplace"] {
  background:
    linear-gradient(180deg, rgba(244, 246, 248, 0.95) 0%, rgba(220, 226, 232, 0.92) 100%);
  border-color: rgba(80, 100, 120, 0.45);
  color: #1a2530;
}
.epi-receipt[data-scenario="marketplace"] .os-vendor {
  color: #1a2838;
}
.epi-receipt[data-scenario="marketplace"] .os-location {
  color: rgba(40, 60, 80, 0.7);
}
.epi-receipt[data-scenario="marketplace"] .os-divider {
  border-top-color: rgba(80, 100, 120, 0.5);
}
.epi-receipt[data-scenario="marketplace"] .epi-os-row {
  color: rgba(20, 35, 50, 0.92);
}

/* =====================================================================
   SIGNATURE BUTTON — appears after 4s; the player's closing beat
   ===================================================================== */

#epilogue-signature {
  margin-top: 1.5vh;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 1200ms ease, transform 1200ms ease;
  pointer-events: none;
}
#epilogue-signature.revealed {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#epilogue-close-btn {
  background: rgba(10, 24, 28, 0.85);
  border: 1px solid rgba(160, 240, 220, 0.5);
  color: rgba(232, 248, 255, 0.92);
  font-family: var(--mono);
  font-size: 0.86rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  padding: 1em 2.2em;
  border-radius: 2px;
  cursor: pointer;
  transition:
    border-color 400ms ease,
    background   400ms ease,
    color        400ms ease,
    box-shadow   400ms ease;
}
#epilogue-close-btn:hover,
#epilogue-close-btn:focus-visible {
  border-color: rgba(248, 232, 192, 0.85);
  background: rgba(40, 60, 70, 0.85);
  color: rgba(252, 244, 220, 0.96);
  box-shadow: 0 0 22px rgba(160, 240, 220, 0.3);
  outline: none;
}

/* =====================================================================
   SECONDARY ACTIONS — Replay / Reset reveal AFTER signature is signed
   ===================================================================== */

#epilogue-actions {
  display: flex;
  gap: 1.2em;
  margin-top: 1.5vh;
  opacity: 0;
  transition: opacity 1600ms ease;
  pointer-events: none;
}
#epilogue-actions.revealed {
  opacity: 1;
  pointer-events: auto;
}

#epilogue-actions button {
  background: rgba(10, 24, 28, 0.75);
  border: 1px solid rgba(160, 240, 220, 0.3);
  color: rgba(232, 248, 255, 0.78);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 0.75em 1.3em;
  border-radius: 2px;
  cursor: pointer;
  transition: border-color 400ms ease, color 400ms ease;
}
#epilogue-actions button:hover,
#epilogue-actions button:focus-visible {
  border-color: rgba(248, 232, 192, 0.6);
  color: rgba(252, 244, 220, 0.95);
  outline: none;
}
#epilogue-actions button[data-action="reset"] {
  border-color: rgba(232, 144, 80, 0.3);
  color: rgba(232, 168, 120, 0.7);
}
#epilogue-actions button[data-action="reset"]:hover,
#epilogue-actions button[data-action="reset"]:focus-visible {
  border-color: rgba(232, 144, 80, 0.75);
  color: rgba(248, 200, 152, 0.95);
}

/* =====================================================================
   INERT STATE — after the player signs, receipts go quiet
   ===================================================================== */

#epilogue.inert .epi-receipt {
  filter: grayscale(0.2) brightness(0.95);
  pointer-events: none;
}
#epilogue.inert #epilogue-sparklines {
  opacity: 0.6;
}

/* =====================================================================
   REDUCED MOTION — drop the receipt tilts + stamp rotations
   ===================================================================== */

@media (prefers-reduced-motion: reduce) {
  .epi-receipt,
  .epi-receipt:nth-child(1),
  .epi-receipt:nth-child(2),
  .epi-receipt:nth-child(3) {
    transform: none !important;
    transition-duration: 200ms;
  }
  .epi-stamp,
  .epi-stamp-kept,
  .epi-stamp-reclaimed,
  .epi-stamp-declined,
  .epi-stamp-incomplete {
    transform: none !important;
  }
  .epi-receipt::after {
    transform: scale(1) !important;
  }
  #epilogue-sparklines,
  #epilogue-signature,
  #epilogue-actions {
    transition-duration: 200ms;
  }
}

/* ---------- MOBILE (C7) ----------
   Receipt triptych stacks; sparklines compress to single column;
   labels get a touch larger so they're not sub-9px. */
@media (max-width: 520px) {
  #epilogue-receipts {
    flex-direction: column;
    align-items: center;
    gap: 14px;
  }
  .epi-receipt {
    width: min(280px, 88vw);
    min-width: 0;
  }
  #epilogue-sparklines {
    gap: 12px;
    width: min(300px, 92vw);
    flex-direction: column;
  }
  .epi-sl-label { font-size: 0.68rem; }
  .epi-sl-value { font-size: 1rem; }
  #epilogue-actions {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }
  #epilogue-actions button {
    min-height: 48px;
    width: 100%;
  }
}
