/* style.css — Just Forms (clean, unified, responsive)
   - One design system (no duplicates)
   - Modern UI shell for all pages
   - Preserves affidavit-body layout + Times-based court previews
*/

/* =========================
   Base + tokens
   ========================= */
/* ===========================
   UI FONT — ATKINSON HYPERLEGIBLE NEXT (self-hosted)
   =========================== */

@font-face{
  font-family: "Atkinson Hyperlegible Next";
  src: url("./fonts/atkinson-hyperlegible/AtkinsonHyperlegibleNextVF-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

*,
*::before,
*::after { box-sizing: border-box; }

:root{
  /* Frame */
  --page-bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f7f8fb;

  /* Text (your requested text color) */
  --text: #1F1F1F;
  --muted: #4b5563;
  --border: #d6deea;

  /* Brand (your requested primary) */
  --accent: #3b5bdb;
  --on-accent: #ffffff;

  /* Status (your requested) */
  --error:   #D32F2F;
  --warning: #ED6C02;
  --success: #2E7D32;

  /* Layout */
  --radius: 14px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.10);
  --content-max: 1100px;
  --pad-x: 20px;

  /* A11y (derived from primary) */
  --focus: 3px solid rgba(74, 102, 227, 0.40);

  /* Fonts (UI) — Atkinson Hyperlegible Next is self-hosted via @font-face above */
  --font-sans: "Atkinson Hyperlegible Next",
               "Atkinson Hyperlegible",
               ui-sans-serif, system-ui, -apple-system, "Segoe UI",
               Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;

}

html, body { height: 100%; }
body { margin: 0; }

/* =========================
   Modern UI shell
   ========================= */

.ui-modern{
  background: var(--page-bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.55;
}

.ui-modern main{
  width: 100%;
  padding: 22px var(--pad-x) 40px;
}

.ui-modern .container{
  max-width: var(--content-max);
  margin: 0 auto;
}

/* “Card” surface for content sections (intake pages primarily) */
.ui-modern section{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

/* Optional reusable card class */
.ui-modern .card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 14px 0;
}

.ui-modern h1{
  font-size: 1.65rem;
  line-height: 1.2;
  margin: 0 0 10px;
}
.ui-modern h2{
  font-size: 1.2rem;
  line-height: 1.25;
  margin: 0 0 10px;
}
.ui-modern p{ margin: 0 0 12px; }
.ui-modern .muted,
.ui-modern .hint,
.ui-modern .form-preamble,
.ui-modern .form-instruction{ color: var(--muted); }

/* =========================
   Toolbar
   ========================= */

.ui-modern .toolbar{
  position: sticky;
  top: 0;
  z-index: 20;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;

  background: rgba(255,255,255,0.82);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
  padding: 10px 12px;
  margin: 0 0 14px;

  backdrop-filter: blur(8px);
}

.ui-modern .toolbar-actions{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* =========================
   Buttons
   ========================= */

/* Support both .btn and plain button usage (your HTML uses both) */
.ui-modern .btn,
.ui-modern button{
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.ui-modern .btn:hover,
.ui-modern button:hover{
  border-color: #b8c4d8;
}

.ui-modern .btn:focus-visible,
.ui-modern button:focus-visible,
.ui-modern input:focus-visible,
.ui-modern select:focus-visible,
.ui-modern textarea:focus-visible{
  outline: var(--focus);
  outline-offset: 2px;
}

.ui-modern .btn[disabled],
.ui-modern button[disabled]{
  opacity: 0.55;
  cursor: not-allowed;
}

/* Variants */
.ui-modern .btn-primary{
  background: var(--accent);
  border-color: transparent;
  color: var(--on-accent);
}
.ui-modern .btn-primary:hover{ filter: brightness(0.98); }

.ui-modern .btn-ghost{ background: transparent; }

.ui-modern .btn-danger{
  background: var(--error);
  border-color: var(--error);
  color: #fff;
}

/* =========================
   Forms (shared)
   ========================= */

.ui-modern form{ margin-top: 12px; }

.ui-modern fieldset{
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin: 14px 0;
  background: var(--surface);
}

.ui-modern legend{
  padding: 0 8px;
  font-weight: 700;
}

.ui-modern label{
  display: block;
  font-weight: 700;
  margin: 10px 0 6px;
}

.ui-modern input[type="text"],
.ui-modern input[type="email"],
.ui-modern input[type="number"],
.ui-modern input[type="date"],
.ui-modern select,
.ui-modern textarea{
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
}

/* Ensure form controls use the UI font (some browsers don’t inherit font-family for inputs) */
.ui-modern input,
.ui-modern textarea,
.ui-modern select{
  font-family: var(--font-sans);
  font-size: inherit;
  line-height: inherit;
}


.ui-modern ::placeholder{ color: #64748b; }

/* Checkbox/radio alignment */
.ui-modern input[type="checkbox"],
.ui-modern input[type="radio"]{
  width: 18px;
  height: 18px;
  margin: 0;
}

.ui-modern .choice-row,
.ui-modern .radio-row{
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.ui-modern .radio-row label,
.ui-modern .choice-row label{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin: 0;
}

/* Two-column “First/Last name” grid pattern */
.ui-modern .name-row{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 720px){
  .ui-modern .name-row{ grid-template-columns: 1fr; }
}

/* Utility spacing you already use */
.ui-modern .mt-6{ margin-top: 6px; }
.ui-modern .mt-8{ margin-top: 8px; }
.ui-modern .mt-12{ margin-top: 12px; }
.ui-modern .ml-6{ margin-left: 6px; }

/* Visually hidden (a11y) */
.ui-modern .visually-hidden{
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap;
}

/* =========================
   Court File Number row (index.html)
   ========================= */

.ui-modern .court-file{ margin-top: 10px; }

.ui-modern .court-file-row{
  display: grid;
  grid-template-columns:
    minmax(4ch, 6ch)
    auto
    minmax(10ch, 14ch)
    auto
    minmax(6ch, 8ch);
  gap: 8px;
  align-items: center;
}

.ui-modern .court-file-sep{
  color: var(--muted);
  font-weight: 700;
  user-select: none;
  text-align: center;
}

@media (max-width: 520px){
  .ui-modern .court-file-row{ grid-template-columns: 1fr; }
  .ui-modern .court-file-sep{ display: none; }
}

/* Remove number spinners */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button{
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"]{
  -moz-appearance: textfield;
  appearance: textfield;
}

/* =========================
   Affidavit body page
   Preserve layout + court previews
   ========================= */

/* IMPORTANT: don’t apply section “card” shell to body page structural sections;
   your body page uses its own card blocks + preview areas. */
.page-affidavit-body section{
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

/* Keep long-form affidavit text readable in editor area */
.ui-modern .para-editor,
.ui-modern .ProseMirror{
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
}

/* ----- Court-form preview blocks (Times, print-like) ----- */
.page-affidavit-body #heading,
.page-affidavit-body #intro,
.page-affidavit-body #jurat,
.page-affidavit-body #backsheet{
  font-family: "Times New Roman", Times, serif;
  color: #000;
}

/* ===== General Heading preview (Word-like) ===== */
#heading .gh{
  max-width: 6.5in;
  margin: 0 auto 10px auto;
  padding: 0;
  font-family: "Times New Roman", Times, serif;
}
#heading .gh-line{ line-height: 2; margin: 0; display: block; }
#heading .gh-file-no{ text-align: right; }
#heading .gh-court{ text-align: center; text-transform: uppercase; }
#heading .gh-court-top{ display: block; font-style: italic; font-weight: 400; }
#heading .gh-court-bottom{ display: block; font-style: normal; font-weight: 700; }
#heading .gh-between{ text-align: left; letter-spacing: 0.25em; }
#heading .gh-parties,
#heading .gh-and{ text-align: center; }
#heading .gh-and{ letter-spacing: 0.5px; font-weight: 600; }
#heading .gh-role{ text-align: right; }

/* ===== Affidavit intro title ===== */
#intro h2{
  text-align: center;
  text-transform: uppercase;
  font-family: "Times New Roman", Times, serif;
  font-weight: 700;
  margin: 4px 0 8px;
  letter-spacing: 0.5px;
}
#intro p{ text-align: left; }

/* =========================
   Jurat — print-friendly
   ========================= */
.jurat{
  font-family:"Times New Roman", serif;
  font-size:12pt;
  line-height:1.25;
}
.jurat h2{ font-size:16pt; margin:0 0 8px; }
.jurat p{ margin:0 0 8px; }
.jurat .note-italic{ font-style:italic; }
.jurat .section-title{ font-weight:700; font-style:italic; margin:10px 0 6px; }

.jurat .inline-fill{
  display:flex;
  flex-wrap:wrap;
  gap:8px 10px;
  align-items:flex-end;
}

.jurat .fill{
  display:inline-block;
  width:18ch;
  height:1.1em;
  line-height:1.1em;
  border-bottom:1px solid #000;
  vertical-align:baseline;
}
.jurat .fill.sm{ width:12ch; }
.jurat .fill.md{ width:22ch; }
.jurat .fill.lg{ width:34ch; }

.jurat .sig-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:24px;
  margin:10px 0 14px;
}
.jurat .sig{
  display:flex;
  flex-direction:column;
  gap:6px;
}
.jurat .sig .sig-pad{ height:40px; }
.jurat .sig .sig-line{ border-bottom:1px solid #000; height:0; }
.jurat .sig .cap{ font-style:italic; }

.jurat .comm-block{ margin:10px 0 6px; }
.jurat .comm-block .cap{ font-style:italic; }

@media print{
  .jurat h2{ margin-bottom:6pt; }
  .jurat .sig-grid{ gap:18px; }
}

/* =========================
   Form 4C Backsheet
   ========================= */
.bs{
  font-family: "Times New Roman", Times, serif;
  color: #111;
}
.bs-toprow{
  display:grid;
  grid-template-columns:1fr auto 1fr;
  align-items:end;
  gap:12px;
  padding:8px 0 6px;
}
.bs-side{ text-align:left; }
.bs-side-right{ text-align:right; }
.bs-names{ font-variant:small-caps; letter-spacing:.02em; line-height:1.2; overflow-wrap:anywhere; }
.bs-role{ font-size:.95em; margin-top:2px; }
.bs-and{ text-align:center; font-style:italic; }
.bs-toprule{ border-top:2px solid #000; margin:6px 0 0; }

.bs-body{
  display:grid;
  grid-template-columns:1fr 1fr;
  min-height:240px;
}
.bs-main{
  border-left:2px solid #000;
  padding:12px 18px 0 18px;
  display:grid;
  grid-auto-rows:min-content;
  row-gap:10px;
}
.bs-file-topline{
  text-align:right;
  white-space:nowrap;
  line-height:1;
  overflow:hidden;
  text-overflow:ellipsis;
}
.bs-court{ text-align:center; }
.bs-court-top{ font-style:italic; font-weight:400; }
.bs-court-bottom{ font-style:normal; font-weight:700; }
.bs-commence{ text-align:center; }
.bs-doc-title{
  text-align:center;
  font-weight:700;
  text-transform:uppercase;
  margin-top:6px;
}
.bs-sworn{
  text-align:center;
  font-weight:700;
}
.bs-filer{ text-align:center; margin-top:6px; line-height:1.4; }
.bs-filer-name{ font-weight:600; }
.bs-filer-addr{ margin-top:2px; }
.bs-filer-contact{ margin-top:2px; }
.bs-filer-license{ margin-top:2px; }

/* =========================
   Paragraph editor layout (keep)
   ========================= */

.row{
  display: grid;
  grid-template-columns: 140px 1fr 320px;
  gap: 16px 24px;
  align-items: start;
  margin-bottom: 24px;
}
.para-num-row{
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.num-controls{
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
@media (max-width: 1100px){
  .row{ grid-template-columns: 160px 1fr; }
  .row-file{ grid-column: 1 / -1; }
}

.pill{
  font: 600 .85rem/1 var(--font-sans);
  padding: .2rem .5rem;
  border: 1px solid #d9e0ef;
  border-radius: 999px;
  background: #fff;
}

/* Move control */
.applyReorder{
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.95rem;
}
.applyReorder:hover{ border-color: #b8c4d8; }
.applyReorder[disabled]{ opacity: .6; cursor: not-allowed; }

.no-inline{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  margin-bottom: 6px;
}
.move-controls{ display: flex; flex-direction: column; gap: 4px; }
.row-num .num{ width: 5.5ch; text-align: center; padding: 6px 8px; }

/* TipTap editor surface */
.para-editor{
  width: 100%;
  min-height: 160px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  outline: none;
  white-space: normal;
  word-wrap: break-word;
}
.para-editor:focus{
  border-color: #b8c4d8;
  box-shadow: 0 0 0 3px rgba(74, 102, 227, 0.16);
}

/* RTE toolbar */
.rte-toolbar{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  margin: 8px 0;
}
.rte-toolbar button{
  padding: 8px 10px;
  border-radius: 10px;
  min-height: 36px;
}
.rte-toolbar .sep{
  width: 1px;
  background: rgba(15,23,42,.16);
  margin: 0 2px;
}

/* List styling inside the editor */
.para-editor ul,
.para-editor ol{
  padding-left: 1.5rem;
  margin: .25rem 0;
}
.para-editor ol{ list-style-type: lower-alpha !important; }
.para-editor li{ margin: .15rem 0; }

/* Inline exhibit chips */
.exh-chip{
  display: inline;
  background: none;
  border: none;
  padding: 0;
  margin: 0 0.2em;
  font-weight: 700;
  line-height: inherit;
  user-select: none;
  -webkit-user-select: none;
  color: inherit;
}

/* Multi-exhibit strip & rail chips */
.exhibit-strip{
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.exhibit-chip{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid #d9e0ef;
  border-radius: 999px;
  background: #fff;
}
.exhibit-chip .exhibit-actions{
  display: inline-flex;
  gap: 6px;
}
.exhibit-chip button{
  padding: 0 6px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  font-size: 12px;
  line-height: 22px;
}
.exhibit-chip button:hover{ background: #eef2ff; }

.clickable{
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.clickable:focus{
  outline: var(--focus);
  outline-offset: 2px;
}

/* Exhibit scheme toggle */
.scheme-control{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
  font-size: 14px;
}
.scheme-label{ color: var(--muted); }
.switch{ position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input{ display: none; }
.slider{
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5e1;
  border-radius: 24px;
  transition: .2s;
}
.slider:before{
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: .2s;
}
.switch input:checked + .slider{ background: var(--success); }
.switch input:checked + .slider:before{ transform: translateX(18px); }

/* Controls toolbar area on body page */
.controls{
  margin: .5rem 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
}
.controls-right{
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* =========================
   Modal (unified)
   ========================= */

.modal[aria-hidden="true"]{ display: none; }
.modal[aria-hidden="false"]{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
}
.modal-dialog{
  background: #fff;
  border-radius: 12px;
  padding: 18px 20px;
  width: min(520px, 92vw);
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.modal-actions{
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Make the intake modal scroll if too tall */
#docMetaModal[aria-hidden="false"] .modal-dialog{
  max-height: calc(100vh - 32px);
  overflow: auto;
}
@supports (height: 100dvh){
  #docMetaModal[aria-hidden="false"] .modal-dialog{
    max-height: calc(100dvh - 32px);
  }
}

/* Errors */
.form-errors{
  color: var(--error);
  margin-top: .25rem;
  font-size: 0.95rem;
}
.field{ margin: 8px 0 10px; }
.field input[type="date"].error,
.field textarea.error,
.field input[type="text"].error,
.field select.error{
  outline: 2px solid var(--error);
  outline-offset: 2px;
  border-color: var(--error);
}
