/* Jethro Justice — Case Binder.
   Loaded after site.css and uses its tokens. Everything here is scoped to #caseBinder or a
   binder- prefix so it cannot reach the guided organizer below it. */

/* ---------- shell ---------- */

.binder-shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px max(20px, env(safe-area-inset-right)) 8px max(20px, env(safe-area-inset-left));
}

.binder-shell[data-loading] .binder-loading { display: block; }
.binder-loading { display: none; color: var(--ink-soft); }

.binder-shell h2 {
  font-size: 26px;
  line-height: 1.25;
  margin: 0 0 8px;
}

.binder-lede { color: var(--ink-soft); margin: 0 0 24px; }

.binder-notice { margin: 12px 0; font-size: 15px; color: var(--ok); }
.binder-notice.is-error { color: var(--warn); }

.binder-progress { margin: 12px 0; }
.binder-progress-label { margin: 0 0 8px; font-size: 15px; color: var(--ink-soft); }
.binder-progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-tint);
  overflow: hidden;
}
.binder-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--gold);
  transition: width 0.2s ease-out;
}
@media (prefers-reduced-motion: reduce) {
  .binder-progress-fill { transition: none; }
}

#binderStorageNotice {
  background: var(--warn-bg);
  border-left: 3px solid var(--gold);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 15px;
  margin-bottom: 16px;
}

/* ---------- case type ---------- */

/* site.css sets `.field label { display: block }`, which outranks a bare class inside a
   fieldset — these rows are scoped to beat it rather than to fight it with !important. */
.field .case-type-option {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  background: var(--bg);
}
.field .case-type-option:hover { border-color: var(--navy-soft); background: var(--bg-alt); }
.field .case-type-option input { margin-top: 4px; flex: 0 0 auto; }
.case-type-text { display: block; }
.case-type-label { display: block; font-size: 17px; }
.case-type-summary { display: block; color: var(--ink-soft); font-size: 15px; margin-top: 2px; }

/* ---------- headline ---------- */

.binder-summary {
  border: 1px solid var(--line);
  border-left: 4px solid var(--navy);
  border-radius: var(--radius);
  padding: 18px 20px;
  background: var(--bg-alt);
  margin: 24px 0 20px;
}
.binder-case-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin: 0 0 6px;
}
.binder-headline {
  font-size: 20px;
  line-height: 1.4;
  font-weight: 600;
  margin: 0;
  color: var(--navy);
}
.binder-critical {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 15px;
  color: var(--warn);
}

/* ---------- context questions ---------- */

.eligibility-row, .context-row { margin-bottom: 14px; }
.eligibility-test { margin: 0 0 6px; }
.eligibility-answers { display: flex; gap: 16px; }
.field .eligibility-answer { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.eligibility-notice { margin-top: 10px; }
.eligibility-continue { color: var(--ink-soft); font-size: 15px; }

.field .context-row label { display: block; margin-bottom: 4px; }
.context-toggle { display: flex; align-items: flex-start; gap: 10px; }
.context-toggle input { margin-top: 4px; flex: 0 0 auto; }
.field .context-toggle label { margin-bottom: 0; }
#binderCourtDate {
  font: inherit;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

/* ---------- escalation ---------- */

.binder-escalation { margin-bottom: 14px; }
.binder-escalation-message { font-weight: 600; margin: 0 0 10px; }

.binder-contacts { list-style: none; margin: 0; padding: 0; }
.binder-contact {
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: 15px;
}
.binder-contact:first-child { border-top: 0; }
.binder-contact-meta { display: block; color: var(--ink-soft); font-size: 14px; }

.open-badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  vertical-align: middle;
}
.open-badge.is-open { background: #e8f5ee; color: var(--ok); }
.open-badge.is-closed { background: var(--bg-tint); color: var(--ink-soft); }

/* ---------- binder list ---------- */

.binder-group { margin: 26px 0; }
.binder-group-heading {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--navy-soft);
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  margin: 0 0 6px;
}
.binder-group-note { color: var(--ink-soft); font-size: 14px; margin: 0 0 12px; }
.binder-group-reordered { color: var(--warn); font-size: 14px; margin: 0 0 12px; font-weight: 600; }

.binder-items { list-style: none; margin: 0; padding: 0; }

.binder-item {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--bg);
}

/* A blocking gap has to be unmistakable at a glance — this is the one thing someone
   needs to see in three seconds. */
.binder-item.is-blocking {
  border-left: 4px solid var(--warn);
  background: var(--warn-bg);
}
.binder-item.is-have { background: var(--bg-alt); }
.binder-item.is-flagged { border-left: 4px solid var(--navy-soft); }

.binder-item-main { flex: 1 1 260px; min-width: 0; }
.binder-item-label { font-weight: 600; margin: 0 0 4px; }
.binder-item-why { color: var(--ink-soft); font-size: 15px; margin: 0; }
.binder-item-citation { color: var(--ink-soft); font-size: 13px; margin: 4px 0 0; font-style: italic; }

.binder-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
  background: var(--warn);
  color: #fff;
}
.binder-tag.is-done { background: var(--ok); }
.binder-tag.is-flag { background: var(--navy-soft); }

.binder-item-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  flex: 0 0 auto;
}
.binder-status {
  font: inherit;
  font-size: 15px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  min-height: 40px;
}

/* ---------- documents ---------- */

.binder-doc-notice {
  background: var(--warn-bg);
  border-left: 3px solid var(--gold);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 15px;
  margin: 0 0 16px;
}

.doc-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  width: 100%;
  border-top: 1px solid var(--line);
}

.doc-row {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.doc-row.is-detached { opacity: 0.85; }

.doc-row-main { flex: 1 1 240px; min-width: 0; }
.doc-row-title { margin: 0; font-weight: 600; font-size: 15.5px; word-break: break-word; }
.doc-row-meta { margin: 2px 0 0; font-size: 14px; color: var(--ink-soft); word-break: break-word; }
.doc-row-detached { margin: 4px 0 0; font-size: 14px; color: var(--warn); }

.doc-row-controls { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; flex: 0 0 auto; }
.doc-exhibit-toggle { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.doc-move { min-width: 40px; }
.doc-remove { color: var(--warn); }

.doc-add-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; width: 100%; }
.doc-add-hint { font-size: 13.5px; color: var(--ink-soft); }

.doc-form {
  width: 100%;
  margin: 10px 0 4px;
  padding: 14px;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 12px;
}
.doc-form-field { display: flex; flex-direction: column; gap: 4px; }
.doc-form-field label { font-size: 14px; font-weight: 600; color: var(--ink-soft); }
.doc-form-field input {
  font: inherit;
  font-size: 15px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}
.doc-form-actions { display: flex; gap: 8px; }

/* ---------- exhibit index ---------- */

.exhibit-index { margin-top: 28px; }
.exhibit-index-heading {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--navy-soft);
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  margin: 0 0 12px;
}
.exhibit-index-list { margin: 0; padding-left: 22px; }
.exhibit-entry { margin-bottom: 14px; }
.exhibit-entry-label { font-weight: 600; margin: 0 0 2px; }
.exhibit-entry-meta { margin: 0; font-size: 15px; color: var(--ink-soft); }
.exhibit-entry-filed { margin: 2px 0 0; font-size: 14px; color: var(--ink-soft); font-style: italic; }

.binder-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 24px 0 16px; }
.binder-file-button { position: relative; overflow: hidden; }
.binder-file-button.is-busy { opacity: 0.45; pointer-events: none; }

.legal-line {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* ---------- acquisition panel ---------- */

.acquisition-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 36, 63, 0.45);
  z-index: 40;
}

.acquisition-panel {
  position: fixed;
  z-index: 41;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(640px, calc(100vw - 32px));
  max-height: min(80vh, 720px);
  overflow-y: auto;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 18px 48px rgba(10, 23, 41, 0.28);
}

.acquisition-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}
.acquisition-head h3 { margin: 0; font-size: 20px; }

.acquisition-close {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 8px;
  font-size: 20px;
  line-height: 1;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--ink-soft);
  min-height: 40px;
}
.acquisition-close:hover { background: var(--bg-alt); border-color: var(--navy-soft); }

.acquisition-field { margin-bottom: 14px; }
.acquisition-field-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin: 0 0 2px;
  font-weight: 600;
}
.acquisition-field-value { margin: 0; }
.acquisition-list { margin: 4px 0 0; padding-left: 20px; }
.acquisition-list li { margin-bottom: 4px; }
.acquisition-links { list-style: none; margin: 4px 0 0; padding: 0; }
.acquisition-links li { margin-bottom: 4px; }

.acquisition-methods { width: 100%; border-collapse: collapse; font-size: 15px; margin: 6px 0 16px; }
.acquisition-methods th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  padding: 6px 8px 6px 0;
}
.acquisition-methods td { padding: 8px 8px 8px 0; border-bottom: 1px solid var(--bg-tint); vertical-align: top; }
.acquisition-caution { display: block; color: var(--warn); font-size: 13px; margin-top: 4px; }

.acquisition-unverified { color: var(--ink-soft); font-size: 15px; }
.acquisition-source { margin: 16px 0 0; font-size: 15px; }
.acquisition-verified { display: block; color: var(--ink-soft); font-size: 13px; margin-top: 2px; }

/* ---------- to-do list ---------- */

.binder-todo { margin-top: 28px; }
.binder-todo-heading {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--navy-soft);
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  margin: 0 0 12px;
}
.binder-todo-list { margin: 0; padding-left: 22px; }
.binder-todo-item { margin-bottom: 14px; }
.binder-todo-label { font-weight: 600; margin: 0 0 2px; }
.binder-todo-line { margin: 0; font-size: 15px; color: var(--ink-soft); }
.binder-todo-url { word-break: break-word; font-size: 13px; }

@media (max-width: 640px) {
  .binder-item { flex-direction: column; }
  .binder-item-controls { width: 100%; }
  .binder-status { flex: 1 1 auto; }
}

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

   The binder is hidden by default in print so the organizer's existing packet output is
   exactly what it was. The binder's own print button sets .printing-binder on <body>,
   which swaps which of the two is on the page. */

@media print {
  #caseBinder { display: none; }
  .acquisition-panel, .acquisition-backdrop { display: none !important; }

  body.printing-binder #caseBinder { display: block; }
  body.printing-binder #intake { display: none !important; }

  body.printing-binder .binder-shell { padding: 0; max-width: none; }
  body.printing-binder #binderPicker,
  body.printing-binder #binderEligibility,
  body.printing-binder #binderContext,
  body.printing-binder .binder-actions,
  body.printing-binder .binder-item-controls,
  body.printing-binder .binder-loading { display: none !important; }

  /* Black and white on Letter: colour fills are dropped for rules that survive a mono
     printer, and the blocking rail stays as a heavy black bar. */
  body.printing-binder .binder-item {
    background: transparent;
    border: 1px solid #999;
    padding: 8px 10px;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  body.printing-binder .binder-item.is-blocking { border-left: 6px solid #000; }
  body.printing-binder .binder-tag {
    background: transparent;
    color: #000;
    border: 1px solid #000;
    padding: 0 6px;
  }
  body.printing-binder .binder-summary { background: transparent; border-left: 4px solid #000; }
  body.printing-binder .open-badge { background: transparent; border: 1px solid #666; color: #000; }

  body.printing-binder .binder-group-heading,
  body.printing-binder .binder-todo-heading {
    break-after: avoid;
    page-break-after: avoid;
  }
  body.printing-binder .binder-group { break-inside: auto; }
  body.printing-binder .binder-contact,
  body.printing-binder .binder-todo-item {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* The acquisition to-do list is what the user carries around, so it starts a page. */
  body.printing-binder .binder-todo {
    break-before: page;
    page-break-before: always;
  }

  /* The exhibit index is the page a parent hands across a counter, so it also starts
     clean. Controls and the attach affordance never print; the descriptions do. */
  body.printing-binder .doc-add-wrap,
  body.printing-binder .doc-row-controls,
  body.printing-binder .doc-form,
  body.printing-binder .binder-doc-notice { display: none !important; }

  body.printing-binder .doc-list { border-top: 1px solid #999; margin-top: 8px; }
  body.printing-binder .doc-row {
    border-bottom: 1px solid #ccc;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  body.printing-binder .doc-row.is-detached { opacity: 1; }
  body.printing-binder .doc-row-detached { color: #000; font-style: italic; }

  body.printing-binder .exhibit-index {
    break-before: page;
    page-break-before: always;
  }
  body.printing-binder .exhibit-index-heading {
    break-after: avoid;
    page-break-after: avoid;
  }
  body.printing-binder .exhibit-entry {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
