/* ============================================================
   SHEETPOST V2 — the live demo: paste rows -> map -> validate
   -> preview -> (simulated) file to KSeF. One free run, then
   the gate. Everything runs locally in the browser.
   ============================================================ */

.demo-stage { position: relative; }

.demo-shell {
  border: 1px solid transparent;
  border-radius: var(--r-panel);
  background:
    linear-gradient(var(--bg-1), var(--bg-1)) padding-box,
    var(--line-grad) border-box;
  /* clip, not hidden: this panel is nearly viewport sized, and `hidden` would
     make it a scroll container that the wheel can fall into the moment its
     content grows past it. It clips a gradient border, nothing more. */
  overflow: clip;
}

/* top bar: steps */
.demo-bar {
  list-style: none; margin: 0;
  display: flex; align-items: center; gap: 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  padding: 0 clamp(14px, 2vw, 22px);
  overflow-x: auto;
  scrollbar-width: none;
}
.demo-bar::-webkit-scrollbar { display: none; }
.dstep {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--font-m); font-size: var(--fs-mini); font-weight: 600;
  color: var(--fg-faint);
  padding: 15px 16px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color var(--d2) ease, border-color var(--d2) ease;
}
.dstep .dn {
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--line-hi);
  font-size: var(--fs-nano);
  flex: none;
}
.dstep.active { color: var(--fg-hi); border-bottom-color: var(--acc); }
.dstep.active .dn { border-color: var(--acc); color: var(--acc); }
.dstep.done { color: var(--fg-lo); }
.dstep.done .dn { background: var(--acc-dim); border-color: transparent; color: var(--acc); }
.dstep::after { content: none; } /* spacing handled by gap */

.demo-body { padding: clamp(18px, 3vw, 34px); min-height: 400px; }
.dpane { display: none; animation: dpane-in var(--d2) var(--e-out); }
.dpane.active { display: block; }
@keyframes dpane-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* pane 1: input */
.dropzone {
  border: 1.5px dashed var(--ctl-line);
  border-radius: var(--r-card);
  padding: clamp(28px, 5vw, 48px);
  text-align: center;
  transition: border-color var(--d2) ease, background var(--d2) ease;
  cursor: pointer;
}
.dropzone:hover, .dropzone.drag { border-color: var(--acc); background: var(--acc-dim); }
.dropzone .ico { width: 30px; height: 30px; margin: 0 auto 12px; color: var(--acc); }
.dropzone b { color: var(--fg-hi); font-weight: 600; display: block; }
.dropzone .hint { margin-top: 6px; }
.demo-inputrow { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; justify-content: center; }
.dpane[data-pane="1"] { display: none; }
.dpane[data-pane="1"].active { display: grid; gap: 0; }
.demo-paste { margin-top: 16px; }
.demo-paste textarea { min-height: 130px; font-family: var(--font-m); font-size: var(--fs-mini); line-height: 1.6; resize: vertical; }
.demo-parsemsg { margin-top: 10px; font-family: var(--font-m); font-size: var(--fs-mini); color: var(--fg-lo); min-height: 1.4em; }
.demo-parsemsg.err { color: var(--seal-bright); }
.demo-nextrow { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.demo-nextrow .btn { white-space: normal; text-align: center; }
@media (max-width: 480px) {
  .demo-nextrow { flex-direction: column-reverse; }
  .demo-nextrow .btn { width: 100%; }
  .demo-inputrow .btn { flex: 1 1 100%; }
}

.dpane-h { margin-bottom: 14px; }

/* pane 2: mapping */
.map-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: clamp(18px, 3vw, 32px); }
.map-table { display: grid; gap: 10px; }
.map-row {
  display: grid; grid-template-columns: 1fr auto 1.1fr;
  gap: 10px; align-items: center;
  border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 10px 12px; background: var(--bg-2);
}
.map-row .m-src { font-family: var(--font-m); font-size: var(--fs-mini); color: var(--fg-hi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-row .m-src small { display: block; color: var(--fg-faint); font-size: var(--fs-nano); }
.map-row .m-arrow { color: var(--fg-faint); }
.map-row select { padding: 8px 10px; font-size: var(--fs-mini); }
.party-stack { display: grid; gap: 12px; align-content: start; }
.party-card { border: 1px solid var(--line); border-radius: var(--r-card); background: var(--bg-2); padding: 16px; display: grid; gap: 12px; }
.party-card h4 { font-family: var(--font-m); font-size: var(--fs-nano); text-transform: uppercase; letter-spacing: 0.12em; color: var(--fg-lo); margin: 0; }
@media (max-width: 880px) { .map-grid { grid-template-columns: 1fr; } }

/* pane 3: validation */
.checks { display: grid; gap: 9px; }
/* six short rows across 1070px is a lot of nothing: pair them up */
@media (min-width: 900px) { .checks { grid-template-columns: 1fr 1fr; gap: 10px 12px; } }
.check {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: var(--r-in);
  background: var(--bg-2); padding: 12px 14px;
  opacity: 0.45; transform: translateY(4px);
  transition: opacity var(--d2) var(--e-out), transform var(--d2) var(--e-out), border-color var(--d2) ease;
}
.check.on { opacity: 1; transform: none; }
.check .c-ico { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; border: 1px solid var(--ctl-line); color: var(--fg-lo); }
.check.pass { border-color: rgba(62, 207, 142, 0.35); }
.check.pass .c-ico { background: var(--acc-dim); border-color: transparent; color: var(--acc); }
.check.fail { border-color: rgba(200, 69, 47, 0.5); }
.check.fail .c-ico { background: rgba(200, 69, 47, 0.15); border-color: transparent; color: var(--seal-bright); }
.check b { font-size: 0.86rem; color: var(--fg-hi); font-weight: 600; display: block; }
.check small { color: var(--fg-lo); font-size: var(--fs-mini); }
.check.fail small { color: var(--seal-bright); }

/* pane 4: preview + xml */
.prev-aside { display: grid; gap: 14px; align-content: start; }
.prev-lede { color: var(--fg); font-size: 0.95rem; }
.prev-feats li { color: var(--fg); }

.prev-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: clamp(18px, 3vw, 30px); align-items: start; }
.prev-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.ptab {
  font-family: var(--font-m); font-size: var(--fs-mini); font-weight: 600;
  color: var(--fg); padding: 10px 16px; border-radius: var(--r-pill);
  border: 1px solid var(--ctl-line);
  transition: color var(--d1) ease, border-color var(--d1) ease, background var(--d1) ease;
}
.ptab:hover { color: var(--fg-hi); border-color: var(--line-hi); }
.ptab[aria-selected="true"] { color: var(--acc); border-color: rgba(62,207,142,.4); background: var(--acc-dim); }
.ptab[aria-selected="true"]:hover { color: var(--acc); }
.xmlview {
  border: 1px solid var(--line); border-radius: var(--r-card);
  scrollbar-width: thin;
  background: #060907;
  padding: 16px;
  max-height: 380px; overflow: auto;
}
.xmlview .xml { font-size: var(--fs-nano); line-height: 1.7; }
@media (max-width: 880px) { .prev-grid { grid-template-columns: 1fr; } }

/* pane 5: send */
.sendlog {
  border: 1px solid var(--line); border-radius: var(--r-card);
  background: #060907;
  padding: 18px;
  min-height: 220px;
  font-family: var(--font-m); font-size: var(--fs-mini); line-height: 2;
  color: var(--fg-lo);
}
.sendlog .log-line { display: block; }
.sendlog .l-ok { color: var(--acc); }
.sendlog .l-run { color: var(--fg-hi); }
.sendlog .cursor-blink::after { content: "▌"; color: var(--acc); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.upo {
  margin-top: 16px;
  border: 1px solid rgba(62, 207, 142, 0.35);
  background: var(--acc-dim);
  border-radius: var(--r-card);
  padding: 16px 18px;
  display: none;
  align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.upo.show { display: flex; }
.upo .u-id { font-family: var(--font-m); font-size: var(--fs-mini); color: var(--acc-bright); word-break: break-all; }
.upo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.upo .u-label { font-family: var(--font-m); font-size: var(--fs-nano); color: var(--fg-lo); display: block; letter-spacing: 0.1em; }

/* demo footer note + gate */
.demo-note {
  margin-top: 18px;
  display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center;
  font-family: var(--font-m); font-size: var(--fs-mini); color: var(--fg-lo);
}
@media (max-width: 760px) {
  .demo-note { gap: 8px 16px; }
  .demo-runs, .demo-lead { margin-left: 0; flex: 1 1 100%; }
}
.demo-note .d-privacy { display: inline-flex; align-items: center; gap: 7px; }
.demo-lead { color: var(--acc); }
.hint.ok { color: var(--acc); }
.demo-runs { margin-left: auto; }

/* paywall: a fixed overlay, so it cannot scroll away from the focus it traps */
.gate {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: none; place-items: center;
  background: rgba(4, 6, 5, 0.82);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  padding: 24px;
  text-align: center;
}
.gate.show { display: grid; }
.gate-card {
  max-width: 460px; width: 100%;
  display: grid; gap: 14px; justify-items: center; position: relative;
  background: var(--bg-1);
  border: 1px solid var(--ctl-line);
  border-radius: var(--r-panel);
  padding: 34px 30px 28px;
  box-shadow: var(--el-2);
  animation: gate-in var(--d2) var(--e-out);
}
@keyframes gate-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.gate-card .modal-close { position: absolute; top: 10px; right: 10px; }
/* The gate's card is darker than the panels the base seal was tuned for, and
   the stamp is small here: #C8452F lands at 3.9:1. The bright seal is 5.6:1. */
.gate-card .stamp {
  opacity: 1; transform: rotate(-6deg); font-size: 0.85rem;
  color: var(--seal-bright); border-color: var(--seal-bright);
}
.gate-card h3 { font-size: 1.6rem; }
.gate-card p { font-size: 0.94rem; color: var(--fg); }
.gate-form { display: flex; gap: 8px; width: 100%; }
.gate-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.gate-form .input { flex: 1; }

@media (max-width: 640px) {
  .dstep { padding: 13px 10px; }
  .dstep .dtxt { display: none; }
  .dstep.active .dtxt { display: inline; }
}
