/* ==========================================================================
   My Easy Science - Reference Maker (paper-tools/reference-maker/)
   Tool-specific layout only. Shared look comes from /assets/ui.css and
   the Paper Tools UI kit in /ui/paper-tools-ui.css.
   Uses only ui.css variables; no hardcoded colours.
   ========================================================================== */

/* ---------- How it works guide (top of page) ---------- */
/* Round 3: one line that says what this tool is for, so it is not
   confused with Reference Generator (a whole list vs one article). */
.rm-distinction {
  color: var(--muted);
  font-size: var(--fs-sm);
  margin-top: calc(var(--s3) * -1);
  margin-bottom: var(--s4);
}

.rg-guide {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s3);
  margin: 0 0 var(--s5);
  padding: 0;
  list-style: none;
  counter-reset: rg-step;
}
.rg-guide li {
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
  padding: var(--s4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}
.rg-guide li::before {
  counter-increment: rg-step;
  content: counter(rg-step);
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: var(--fs-sm);
  font-weight: 700;
}
.rg-guide strong { display: block; margin-bottom: var(--s1); font-size: var(--fs-base); }
.rg-guide span { color: var(--muted); font-size: var(--fs-sm); line-height: var(--lh); }

/* ---------- Tabs ---------- */
.rm-tabs {
  display: flex;
  gap: var(--s2);
  flex-wrap: wrap;
  margin-bottom: var(--s4);
  border-bottom: 1px solid var(--line);
}
.rm-tabs [role="tab"] {
  appearance: none;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: var(--radius-control) var(--radius-control) 0 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 650;
  font-size: var(--fs-sm);
  padding: var(--s3) var(--s4);
  margin-bottom: -1px;
  cursor: pointer;
  min-height: 44px;
}
.rm-tabs [role="tab"]:hover { color: var(--ink); background: var(--surface-2); }
.rm-tabs [role="tab"][aria-selected="true"] {
  color: var(--primary);
  background: var(--surface);
  border-color: var(--line);
  box-shadow: inset 0 2px 0 var(--primary);
}
.rm-tabs [role="tab"]:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.rm-tab-panel { margin-bottom: var(--s4); }
.rm-tab-panel h2 { font-size: var(--fs-lg); }

/* ---------- Steps layout ---------- */
.rg-steps {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s4);
  margin-bottom: var(--s4);
}
.rg-steps .card h2 { font-size: var(--fs-lg); }
.rg-step-label {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  margin-bottom: var(--s2);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--primary);
}
.rg-step-label .icon { width: 18px; height: 18px; }

.rg-link-row { display: flex; gap: var(--s2); align-items: flex-start; }
.rg-link-row .input { flex: 1; min-width: 0; }
.rg-link-row .btn { flex: none; }

.rg-file-row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.rg-file-name { font-size: var(--fs-sm); color: var(--muted); overflow-wrap: anywhere; }
input[type="file"].rg-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}
.rg-file-input:focus-visible + label { box-shadow: var(--focus-ring); }

/* ---------- Details form ---------- */
.rg-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 var(--s4);
}
.rg-form-grid .field--wide { grid-column: 1 / -1; }
.rg-form-grid .field { margin-bottom: var(--s3); }

.rg-style-row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.rg-style-row .field-label { margin: 0 var(--s2) 0 0; }
.rg-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); }

/* ---------- Verify chips and "not available" hints ---------- */
.rm-chip-slot { display: inline-block; vertical-align: middle; margin-left: var(--s1); }
.rm-chip-slot:empty { display: none; }
.rm-na {
  display: block;
  color: var(--muted);
  font-style: italic;
}

/* ---------- Author editor ---------- */
.rm-author-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, .5fr) auto auto;
  gap: var(--s2);
  align-items: end;
  margin-bottom: var(--s2);
  padding: var(--s3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
}
.rm-author-row--org {
  grid-template-columns: minmax(0, 1fr) auto auto;
}
.rm-author-row .field { margin-bottom: 0; }
.rm-author-row .field label { font-size: var(--fs-xs); }
.rm-author-row .btn { min-height: 44px; }
.rm-author-row .rm-author-org { display: flex; align-items: center; gap: var(--s1); min-height: 44px; font-size: var(--fs-sm); white-space: nowrap; }
.rm-author-row .rm-author-move { display: flex; gap: var(--s1); }
.rm-author-row .rm-author-move .btn { padding: var(--s1) var(--s2); min-width: 44px; }
.rm-check { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s1); font-weight: 400; cursor: pointer; }
.rm-check input { width: 20px; height: 20px; flex: none; accent-color: var(--primary); }
.rm-inline-field { max-width: 220px; margin-top: var(--s2); }

/* ---------- Source and result notes ---------- */
.rm-notes {
  margin: var(--s3) 0;
  padding-left: var(--s5);
  color: var(--muted);
  font-size: var(--fs-sm);
}
.rm-notes li { margin-bottom: var(--s1); }

/* ---------- Result ---------- */
.rg-result {
  padding: var(--s4);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  font-size: var(--fs-base);
  line-height: 1.7;
  overflow-wrap: break-word;
}
.rg-result:empty { display: none; }
.rg-result-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }
.rg-bib {
  margin: var(--s3) 0 0;
  padding: var(--s3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.rg-bib:empty { display: none; }

/* ---------- Reference list ---------- */
.rm-list { margin: var(--s3) 0; padding-left: var(--s5); }
.rm-list li { margin-bottom: var(--s3); line-height: 1.6; overflow-wrap: break-word; }
.rm-list .rm-list-num { font-weight: 700; }
.rm-list .rm-list-actions { display: inline-flex; gap: var(--s2); margin-left: var(--s2); }
.rm-list .rm-list-actions .btn { min-height: 32px; padding: var(--s1) var(--s2); font-size: var(--fs-xs); }

/* ---------- Title search and batch results ---------- */
.rm-search-item {
  padding: var(--s3);
  margin-bottom: var(--s2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
}
.rm-search-item p { margin: 0 0 var(--s2); }
.rm-search-item .rm-search-meta { color: var(--muted); font-size: var(--fs-sm); }
.rm-batch-row { display: flex; gap: var(--s2); align-items: baseline; padding: var(--s2) 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.rm-batch-row:last-child { border-bottom: 0; }

/* ---------- Worked example ---------- */
.rg-example td { vertical-align: top; }
.rg-example td:first-child { white-space: nowrap; font-weight: 650; }
.rg-example-output { line-height: 1.7; }

/* ---------- Small screens ---------- */
@media (max-width: 767px) {
  .rg-guide { grid-template-columns: 1fr; }
  .rg-steps { grid-template-columns: 1fr; }
  .rg-form-grid { grid-template-columns: 1fr; }
  .rg-link-row { flex-direction: column; }
  .rg-link-row .btn { width: 100%; }
  .rm-author-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .rm-author-row .rm-author-move { grid-column: 1 / -1; }
  .rm-author-row--org { grid-template-columns: minmax(0, 1fr); }
}
