/* ==========================================================================
   My Easy Science - Reference Generator (research/reference-generator.html)
   Tool-specific layout only. Shared look comes from /assets/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 Maker (one article vs a whole list). */
.rg-distinction {
  color: var(--muted);
  font-size: var(--fs-sm);
  margin-top: calc(var(--s3) * -1);
  margin-bottom: var(--s4);
}

/* Round 3: the manual details form is the anchor target of the
   "details form below" link in Step 1; keep it clear of the header. */
#refForm { scroll-margin-top: calc(var(--header-h) + var(--s3)); }

.rg-guide {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 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); }

/* ---------- 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); }

/* ---------- 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; }

/* ---------- 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%; }
}
