/* ==========================================================================
   Lawgistics, document creator (wizard + live document preview)
   ========================================================================== */

.wizard {
  display: grid;
  grid-template-columns: minmax(360px, 460px) 1fr;
  gap: clamp(24px, 3vw, 44px);
  align-items: start;
  padding: clamp(24px, 4vw, 48px) 0 80px;
}

/* ------------------------------------------------------------- stepper -- */

.wiz-steps {
  display: flex; align-items: flex-start;
  margin-bottom: 22px; overflow-x: auto; padding-bottom: 4px;
}
.wiz-step {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  background: none; border: 0; cursor: pointer; padding: 0;
  min-width: 64px; flex: 1;
}
.wiz-step__dot {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--sans); font-size: .82rem; font-weight: 700;
  background: var(--cream-deep); color: var(--ink-soft);
  border: 1.5px solid var(--line);
  transition: all .25s var(--ease);
}
.wiz-step__label {
  font-size: .68rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-soft);
  text-align: center; max-width: 90px; line-height: 1.3;
}
.wiz-step.is-current .wiz-step__dot { background: var(--navy); border-color: var(--navy); color: var(--white); }
.wiz-step.is-current .wiz-step__label { color: var(--ink); }
.wiz-step.is-done .wiz-step__dot { background: var(--green); border-color: var(--green); color: var(--white); }
.wiz-step.is-done .wiz-step__label { color: var(--green); }
.wiz-step__bar {
  flex: 1 1 24px; height: 2px; background: var(--line);
  margin-top: 16px; min-width: 16px; border-radius: 2px;
}
.wiz-step__bar.is-done { background: var(--green); }

/* --------------------------------------------------------- signatures -- */

.sig-block {
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; margin-bottom: 16px; background: var(--cream);
}
.sig-block h4 { font-family: var(--sans); font-size: .85rem; font-weight: 700; margin: 0 0 10px; color: var(--ink); }
.sig-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.sig-tabs button {
  flex: 1; font-family: var(--sans); font-size: .8rem; font-weight: 600;
  padding: 8px; border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid var(--line); background: var(--white); color: var(--ink-soft);
  transition: all .2s var(--ease);
}
.sig-tabs button.is-active { border-color: var(--navy); color: var(--navy); background: var(--navy-soft); }
.sig-canvas {
  width: 100%; height: 110px; background: var(--white);
  border: 1px dashed var(--line); border-radius: var(--r-sm);
  cursor: crosshair; touch-action: none; display: block;
}
.sig-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.sig-preview {
  margin-top: 10px; padding: 8px 12px; background: var(--white);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  display: none; align-items: center; gap: 12px;
}
.sig-preview.is-on { display: flex; }
.sig-preview img { max-height: 44px; }
.sig-typed {
  font-family: 'Segoe Script', 'Bradley Hand', 'Brush Script MT', 'Snell Roundhand', cursive;
  font-size: 26px; color: #1c2129; line-height: 1.2;
}
.doc__sig-line { position: relative; }
.doc__sig-line img { position: absolute; bottom: 4px; left: 8px; max-height: 44px; max-width: 85%; }
.doc__sig-line .sig-typed { position: absolute; bottom: 2px; left: 8px; }

/* ------------------------------------------------------ checkout modal -- */

.modal-scrim {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(26, 31, 40, .55);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-scrim.is-on { display: flex; }
.modal {
  background: var(--white); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); max-width: 420px; width: 100%;
  padding: 32px;
}
.modal h3 { font-size: 1.3rem; margin-bottom: 8px; }
.modal p { font-size: .9rem; }
.modal .btn-row { margin-top: 20px; }

.btn[disabled] { opacity: .45; pointer-events: none; }

.wiz-panel { position: sticky; top: 96px; }

.wiz-card {
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: clamp(22px, 3vw, 32px);
  box-shadow: var(--shadow-sm);
}
.wiz-card h2 { font-size: 1.35rem; margin-bottom: 18px; }

.wiz-nav { display: flex; gap: 10px; justify-content: space-between; margin-top: 24px; }

.wiz-progress { height: 3px; background: var(--cream-deep); border-radius: 3px; margin-bottom: 22px; overflow: hidden; }
.wiz-progress span { display: block; height: 100%; background: var(--navy); border-radius: 3px; transition: width .3s var(--ease); }

/* voice input */
.field-voice { position: relative; }
.field-voice .input, .field-voice .textarea { padding-right: 46px; }
.mic-btn {
  position: absolute; right: 8px; top: 34px;
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--white); color: var(--ink-soft);
  display: grid; place-items: center; cursor: pointer;
  transition: all .2s var(--ease);
}
.field-voice .textarea + .mic-btn, .mic-btn.for-textarea { top: 32px; }
.mic-btn:hover { border-color: var(--navy); color: var(--navy); }
.mic-btn.is-listening {
  background: var(--navy); border-color: var(--navy); color: var(--white);
  animation: mic-pulse 1.2s ease-out infinite;
}
@keyframes mic-pulse {
  0% { box-shadow: 0 0 0 0 rgba(45, 74, 117, .35); }
  100% { box-shadow: 0 0 0 12px rgba(45, 74, 117, 0); }
}
.voice-hint { font-size: .76rem; color: var(--ink-soft); margin-top: 6px; display: none; }
.voice-hint.is-on { display: block; color: var(--navy); font-weight: 500; }

/* --------------------------------------------------------- preview pane -- */

.preview-pane { min-width: 0; }

.preview-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.preview-bar .spacer { flex: 1; }
.edit-badge {
  display: none; font-size: .76rem; font-weight: 600;
  color: var(--amber); background: #faf3e3; border: 1px solid #ecd9ae;
  border-radius: 999px; padding: 5px 12px;
}
.edit-badge.is-on { display: inline-block; }

.stale-banner {
  display: none; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #faf3e3; border: 1px solid #ecd9ae; border-radius: var(--r);
  padding: 10px 14px; font-size: .84rem; margin-bottom: 14px;
}
.stale-banner.is-on { display: flex; }

.paper-wrap { position: relative; }

.paper {
  background: var(--white); border: 1px solid var(--line);
  border-radius: 6px; box-shadow: var(--shadow);
  padding: clamp(28px, 5vw, 64px);
  min-height: 500px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}

/* Locked preview: document blurred until unlock, like the paid product. */
.paper-wrap.is-locked .paper {
  overflow: hidden;
}
.paper-wrap.is-locked .doc {
  filter: blur(5px);
  user-select: none;
  pointer-events: none;
}
.lock-overlay {
  display: none;
  position: absolute; inset: 0;
  align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(244, 241, 234, .1), rgba(244, 241, 234, .55));
  border-radius: 6px;
  padding: 24px;
}
.paper-wrap.is-locked .lock-overlay { display: flex; }
.lock-card {
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  padding: 30px 32px; max-width: 380px; text-align: center;
}
.lock-card__icon {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--navy-soft); color: var(--navy);
  display: grid; place-items: center; margin: 0 auto 16px;
}
.lock-card h3 { font-size: 1.2rem; margin-bottom: 6px; }
.lock-card p { font-size: .88rem; margin-bottom: 18px; }
.lock-card .form-note { margin-top: 12px; }
.paper[contenteditable="true"] {
  outline: 2px dashed var(--haze); outline-offset: 6px;
  cursor: text;
}
.paper[contenteditable="true"]:focus { outline-color: var(--navy); }

/* ------------------------------------------------------------ document -- */

.doc {
  font-family: var(--serif);
  color: #1c2129;
  font-size: 15px;
  line-height: 1.7;
}
.doc p { margin: 0 0 .9em; }
.doc__title {
  font-size: 1.7rem; text-align: center; text-transform: uppercase;
  letter-spacing: .04em; margin-bottom: 6px;
}
.doc__dated { text-align: center; margin-bottom: 26px; font-style: italic; }
.doc h2 {
  font-size: 1.02rem; font-weight: 700; text-transform: none;
  letter-spacing: 0; margin: 1.6em 0 .5em;
}

.doc__schedule { margin-top: 32px; }
.doc__table { width: 100%; border-collapse: collapse; font-size: inherit; }
.doc__table th, .doc__table td { border: 1px solid var(--ink, #1a1f28); padding: 8px 10px; text-align: left; vertical-align: top; }
.doc__table th { width: 34%; font-weight: 600; }
.doc__parties ol { padding-left: 1.4em; margin: 0 0 1em; }
.doc__parties li { margin-bottom: .6em; }
.doc__operative { font-weight: 700; margin: 1.4em 0 .4em; }
.doc__clause h2 { margin-top: 1.4em; }
.doc__num { font-weight: 700; margin-right: 6px; }
.doc__sig-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 40px; }
.doc__sig-line { border-bottom: 1px solid #1c2129; height: 48px; margin-bottom: 10px; }
.doc__sig p { font-size: .9rem; line-height: 1.5; }
.doc__notice {
  margin-top: 40px; padding-top: 14px; border-top: 1px solid var(--line);
  font-family: var(--sans); font-size: .72rem; color: var(--ink-soft);
}
.doc--letter .doc__re { font-size: 1.02rem; text-decoration: underline; margin: 1.2em 0; text-align: left; text-transform: uppercase; }
.doc--letter .doc__from { text-align: right; }

/* ---------------------------------------------------------- responsive -- */

@media (max-width: 980px) {
  .wizard { grid-template-columns: 1fr; }
  .wiz-panel { position: static; }
  .paper { max-height: none; }
}

/* --------------------------------------------------------------- print -- */

@media print {
  body * { visibility: hidden; }
  .paper, .paper * { visibility: visible; }
  .paper {
    position: absolute; inset: 0; border: 0; box-shadow: none;
    max-height: none; overflow: visible; padding: 0; border-radius: 0;
    outline: none !important;
  }
  .doc { font-size: 12pt; }
}
