/* ============================================================
   forge.css — "The Forge": merged problem (receipts) + engine (demo),
   laid out as a LEFT/RIGHT diptych. Loaded after styles.css. Reuses the
   existing bezel (.problem-frame), receipt (.receipt*), and demo
   (.engine-demo, .demo-*) styling; this file only adds the diptych layout.
   ============================================================ */

.forge-head { text-align: center; }
.forge-deck {
  max-width: 58ch;
  margin: 14px auto 0;
  font-size: clamp(1rem, 1.4vw, 1.12rem);
  line-height: 1.55;
  color: rgba(14, 14, 12, 0.74);   /* ~7:1 on paper — passes AA */
  text-wrap: pretty;
}

/* ---- Diptych: left pane = the proof, right pane = the live machine ---- */
.forge-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(28px, 4vw, 60px);
  align-items: start;
  margin-top: clamp(30px, 4vw, 48px);
  position: relative;
}

@media (min-width: 1025px) {
  /* hairline seam between the two panes */
  .forge-split::before {
    content: "";
    position: absolute;
    top: 4%;
    bottom: 4%;
    left: 50%;
    width: 1px;
    background: linear-gradient(transparent, var(--border-strong), transparent);
    transform: translateX(-50%);
  }
  /* A 3-up receipt is too cramped at half width, so the proof reads as a
     vertical sequence in its pane: your bullet → other-AI lie → Klepify. */
  .forge-split .receipt-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  /* keep the live machine in view while the proof column scrolls past it */
  .forge-machine {
    position: sticky;
    top: 92px;
  }
}

@media (max-width: 1024px) {
  .forge-split {
    grid-template-columns: 1fr;
    gap: clamp(40px, 8vw, 64px);
  }
}

/* ---- Act II heading ---- */
.forge-machine { margin-top: 0; }
.forge-act-h {
  font-family: var(--font-display, "Bricolage Grotesque", serif);
  font-size: clamp(28px, 3.4vw, 42px);
  line-height: 1.02;
  text-align: center;
  letter-spacing: -0.01em;
  margin: 0 0 clamp(18px, 2.4vw, 28px);
  color: var(--ink);
}
.forge-act-h em { font-style: italic; color: var(--coral); }

/* ============================================================
   "Klepify" step amplified — live before→after bullet rewrite.
   Plays while .demo-state-klepifying is .active (app.js toggles it,
   ~4.5s dwell). Pure CSS so no JS changes; static fallback under
   reduced motion. Mirrors the receipt argument inside the demo.
   ============================================================ */
.demo-rewrite {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  text-align: left;
}
.demo-rw-row {
  position: relative;
  border: 1px solid var(--border, rgba(14,14,12,0.1));
  border-radius: 10px;
  padding: 9px 11px;
  background: rgba(14,14,12,0.02);
  overflow: hidden;
}
.demo-rw-tag {
  display: inline-block;
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 8.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}
.demo-rw-tag-acid {
  background: var(--acid);
  color: var(--ink);
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}
.demo-rw-text {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink);
}
.demo-rw-before .demo-rw-text { color: rgba(14,14,12,0.62); }
.demo-rw-arrow {
  align-self: center;
  color: var(--acid-deep);
  line-height: 0;
  margin: -2px 0;
}
.demo-rw-after .demo-rw-text mark {
  background: transparent;
  color: inherit;
  padding: 0 2px;
  border-radius: 4px;
}
.demo-rw-locks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.demo-rw-locks span {
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 8.5px;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: rgba(212,255,61,0.22);
  border: 1px solid rgba(14,14,12,0.12);
  border-radius: 999px;
  padding: 2px 7px;
}

/* --- the choreography, gated on .active --- */
@media (prefers-reduced-motion: no-preference) {
  /* scan sweep + dim on the original */
  .demo-rw-before::after {
    content: "";
    position: absolute;
    left: 0; right: 0;
    height: 38%;
    top: -40%;
    background: linear-gradient(rgba(212,255,61,0), rgba(212,255,61,0.5), rgba(212,255,61,0));
    pointer-events: none;
    opacity: 0;
  }
  .demo-state-klepifying.active .demo-rw-before { animation: rwDim 4.5s both; }
  .demo-state-klepifying.active .demo-rw-before::after { animation: rwScan 4.5s ease-in-out both; }
  .demo-state-klepifying.active .demo-rw-arrow { animation: rwArrow 4.5s both; }
  .demo-state-klepifying.active .demo-rw-after { animation: rwAfter 4.5s both; }
  .demo-state-klepifying.active .demo-rw-after .demo-rw-text mark { animation: rwLite 0.5s ease both; }
  .demo-state-klepifying.active .demo-rw-after .demo-rw-text mark:nth-of-type(1) { animation-delay: 2.3s; }
  .demo-state-klepifying.active .demo-rw-after .demo-rw-text mark:nth-of-type(2) { animation-delay: 2.8s; }
  .demo-state-klepifying.active .demo-rw-locks span { animation: rwPop 0.4s ease both; }
  .demo-state-klepifying.active .demo-rw-locks span:nth-child(1) { animation-delay: 3.1s; }
  .demo-state-klepifying.active .demo-rw-locks span:nth-child(2) { animation-delay: 3.25s; }
  .demo-state-klepifying.active .demo-rw-locks span:nth-child(3) { animation-delay: 3.4s; }

  /* before is hidden until active too, so it doesn't flash on other states */
  .demo-rw-after { opacity: 0; }
  .demo-rw-arrow { opacity: 0; }
  .demo-rw-locks span { opacity: 0; }
}

@keyframes rwDim {
  0%, 32% { opacity: 1; }
  46%     { opacity: 0.55; transform: scale(0.995); }
  100%    { opacity: 0.55; transform: scale(0.995); }
}
@keyframes rwScan {
  0%   { top: -40%; opacity: 0; }
  6%   { opacity: 1; }
  30%  { top: 100%; opacity: 1; }
  31%, 100% { opacity: 0; }
}
@keyframes rwArrow {
  0%, 30% { opacity: 0; transform: translateY(-5px); }
  40%     { opacity: 1; transform: translateY(0); }
  100%    { opacity: 1; }
}
@keyframes rwAfter {
  0%, 38% { opacity: 0; transform: translateY(10px); }
  54%     { opacity: 1; transform: translateY(0); }
  100%    { opacity: 1; }
}
@keyframes rwLite {
  to { background: var(--acid); color: var(--ink); }
}
@keyframes rwPop {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

/* reduced motion: show the finished, honest result, no choreography */
@media (prefers-reduced-motion: reduce) {
  .demo-rw-before .demo-rw-text { color: rgba(14,14,12,0.55); }
  .demo-rw-after .demo-rw-text mark { background: var(--acid); color: var(--ink); }
}

/* --- Solo demo (receipt removed). The demo-stage (callouts + side panel) needs
   the FULL section width; a narrow column wraps the callouts one word per line
   and clips the panel. So: single full-width column, no seam, not sticky. --- */
.forge--solo .receipt { display: none; }
.forge--solo .forge-split { grid-template-columns: 1fr; }
.forge--solo .forge-split::before { display: none; }
.forge--solo .forge-machine { position: static; }

/* Tighten the solo demo's vertical rhythm — no deck/sub-heading anymore, so
   kill the dead space between the heading/band and the demo. */
.forge--solo .forge-split { margin-top: clamp(10px, 1.6vw, 20px); }
.forge--solo .engine-demo { margin-top: 0; padding-top: 0; }
.forge--solo .demo-stage { min-height: 0; align-items: start; }

/* Tri-bullet proof inside the "Tailors honestly" callout (C). Tiny by design
   so all three rows sit on the same card: You (faded original), Other AI
   (struck-through inflation), Klepify (the honest rewrite). */
.demo-tri { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.demo-tri-row {
  display: grid;
  grid-template-columns: 50px 1fr;
  gap: 7px;
  align-items: baseline;
}
.demo-tri-tag {
  font-family: var(--font-mono, "JetBrains Mono", monospace);
  font-size: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
}
.demo-tri-txt { font-size: 10.5px; line-height: 1.3; color: var(--ink); }
.demo-tri-you .demo-tri-tag { color: var(--muted); }
.demo-tri-you .demo-tri-txt { color: rgba(14,14,12,0.58); }
.demo-tri-them .demo-tri-tag { color: var(--coral); }
.demo-tri-them .demo-tri-txt {
  color: rgba(14,14,12,0.5);
  text-decoration: line-through;
  text-decoration-color: rgba(224,122,95,0.7);
}
.demo-tri-us .demo-tri-tag { color: var(--acid-deep, #5c7a00); }
.demo-tri-us .demo-tri-txt { font-weight: 600; }
