/* ParaPrep, Medication (Monograph) Builder (Brief 20) page styles.
   Reuses the design tokens + base components from styles.css; adds the drug
   picker grid, the monograph skeleton (field slots) and the fact-tile bank.
   Shared chrome (footer-rich, demo-bar, draft badge) is duplicated per page by
   project convention (see algorithm-builder.css). Responsive 360 to 1280px. */

/* ---- Shared chrome ---- */
.footer-rich {
  max-width: 1000px; margin: 0 auto; padding: 1.5rem; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between;
  color: var(--muted); font-size: .8rem;
}
.footer-rich a { color: var(--muted); }
.footer-rich a:hover { color: var(--teal-dark); }
.footer-rich .legal-links { display: flex; gap: 1rem; flex-wrap: wrap; }

.disclaimer-bar {
  background: var(--amber-bg); border-bottom: 1px solid #f0e3c4; color: #6b5418;
  font-size: .82rem; padding: .6rem 1.5rem; text-align: center;
}

#builder { max-width: 1000px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

.demo-bar {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  background: #eef5f4; border: 1px dashed var(--teal); color: var(--teal-dark);
  border-radius: var(--radius); padding: .6rem .9rem; margin-bottom: 1.5rem; font-size: .82rem;
}
.demo-bar strong { font-weight: 700; }
.demo-bar .spacer { margin-left: auto; }

.btn.tiny { padding: .35rem .7rem; font-size: .8rem; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
.btn.ghost { background: transparent; color: var(--teal-dark); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--teal-soft); }
.btn.amber { background: var(--amber); color: #fff; white-space: nowrap; }
.btn.amber:hover { filter: brightness(.95); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.view-title { margin: 0 0 .2rem; }
.view-sub { color: var(--muted); font-size: .92rem; margin: .2rem 0 1.4rem; }

/* ---- Draft badge / note (unverified content) ---- */
.draft-badge {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em;
  color: var(--amber); background: var(--amber-bg); border: 1px solid #f0e3c4;
  border-radius: 999px; padding: .18rem .55rem; white-space: nowrap;
}
.draft-note {
  background: var(--amber-bg); border: 1px solid #f0e3c4; border-left: 4px solid var(--amber);
  color: #6b5418; border-radius: 10px; padding: .7rem .9rem; font-size: .82rem; margin: 0 0 1.2rem;
}

/* ---- Drug picker grid ---- */
.drug-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.drug-card {
  display: flex; flex-direction: column; gap: .5rem; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow); cursor: pointer; width: 100%;
  font: inherit; color: inherit; transition: transform .12s ease, box-shadow .12s ease;
}
.drug-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(20,50,55,.12); }
.drug-card .drug-title { font-size: 1.05rem; font-weight: 700; margin: 0; }
.drug-card .drug-summary { color: var(--muted); font-size: .85rem; margin: 0; }
.drug-chips { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.drug-chips .chip, .meta .chip {
  font-size: .7rem; font-weight: 700; padding: .18rem .55rem; border-radius: 999px;
  background: var(--teal-soft); color: var(--teal-dark);
}
.drug-chips .chip.topic, .meta .chip.topic { background: #eef2f4; color: var(--muted); }
.drug-chips .chip.conc, .meta .chip.conc { background: #fff7e9; color: #6b5418; border: 1px solid #ecd9ac; }
.chip.free { background: #e6f5ec; color: #1f5b3c; font-size: .7rem; font-weight: 700; padding: .18rem .55rem; border-radius: 999px; }
.drug-card .drug-foot { display: flex; align-items: center; gap: .5rem; margin-top: auto; padding-top: .3rem; }
.best-pill {
  font-size: .72rem; font-weight: 800; color: var(--green); background: #e6f5ec;
  border: 1px solid #bfe6cf; border-radius: 999px; padding: .15rem .5rem;
}
.best-pill.done::after { content: " ✓"; }
.drug-card .go { margin-left: auto; color: var(--teal); font-weight: 800; font-size: .85rem; }

.drug-card.locked { border-style: dashed; background: #fbfcfc; cursor: default; }
.drug-card.locked:hover { transform: none; box-shadow: var(--shadow); }
.drug-card.locked .drug-title { color: var(--muted); }
.drug-card .lock-tag {
  font-size: .72rem; font-weight: 800; color: var(--amber); background: var(--amber-bg);
  border: 1px solid #f0e3c4; border-radius: 999px; padding: .15rem .55rem; margin-left: auto;
}

.upgrade-strip {
  display: flex; align-items: center; gap: 1rem; justify-content: space-between; flex-wrap: wrap;
  background: var(--amber-bg); border: 1px solid #f0e3c4; border-left: 4px solid var(--amber);
  border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1.4rem;
}
.upgrade-strip strong { color: var(--amber); }
.upgrade-strip p { margin: .15rem 0 0; color: #6b5418; font-size: .88rem; }

/* ---- Exercise header ---- */
.exercise-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: .4rem; }
.exercise-head .titles { flex: 1 1 280px; }
.exercise-head h2 { margin: 0; font-size: 1.4rem; }
.exercise-head .meta { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin-top: .35rem; }
.source-line { color: var(--muted); font-size: .78rem; margin: .5rem 0 0; }

/* ---- Score + toolbar ---- */
.exercise-toolbar {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .8rem 1rem; box-shadow: var(--shadow); margin: 1rem 0 .8rem;
  position: sticky; top: .6rem; z-index: 5;
}
.score-readout { font-weight: 700; font-size: .9rem; }
.score-readout .pct { font-size: 1.3rem; font-weight: 800; color: var(--teal-dark); }
.score-readout.good .pct { color: var(--green); }
.score-readout.bad .pct { color: var(--red); }
.exercise-toolbar .spacer { margin-left: auto; }

.danger-banner {
  background: #fbe9e7; border: 1px solid var(--red); border-left: 4px solid var(--red);
  color: #8a2a1e; border-radius: 10px; padding: .65rem .9rem; font-size: .85rem; font-weight: 700;
  margin: 0 0 1.2rem;
}

/* ---- The monograph skeleton ---- */
.mono-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.2rem 1.2rem 1.4rem; box-shadow: var(--shadow);
}
.mono-field { display: grid; grid-template-columns: 180px 1fr; gap: .8rem 1rem; align-items: start; padding: .55rem 0; border-top: 1px solid var(--line); }
.mono-field:first-child { border-top: 0; }
.field-label { font-weight: 800; font-size: .82rem; color: var(--teal-dark); text-transform: uppercase; letter-spacing: .03em; padding-top: .55rem; }
.varies-tag { font-size: .62rem; font-weight: 800; color: var(--amber); background: var(--amber-bg); border: 1px solid #f0e3c4; border-radius: 999px; padding: .08rem .4rem; text-transform: none; letter-spacing: 0; }
.field-slots { display: flex; flex-direction: column; gap: .5rem; min-width: 0; }

.slot {
  position: relative; border: 1px dashed #c4d0d4; background: #fbfdfd; color: var(--muted);
  border-radius: 10px; padding: .6rem .8rem; min-height: 2.6rem; display: flex; flex-direction: column;
  justify-content: center; cursor: pointer; font-size: .9rem;
}
.slot.empty .slot-placeholder { font-style: italic; font-size: .82rem; }
.slot.filled { border-style: solid; background: var(--surface); color: var(--ink); font-weight: 600; }
.slot .slot-text { line-height: 1.35; }
.slot:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.slot.over { border-color: var(--teal); background: var(--teal-soft); box-shadow: 0 0 0 3px rgba(15,125,119,.15); }
.slot.target { border-color: var(--teal); }
.slot.correct { border-color: var(--green); background: #e6f5ec; color: #1f5b3c; border-style: solid; }
.slot.incorrect { border-color: var(--red); background: #fbe9e7; color: #8a2a1e; border-style: solid; }
.slot .mark { position: absolute; top: .4rem; right: .55rem; font-weight: 900; }
.slot.correct .mark::before { content: "✓"; color: var(--green); }
.slot.incorrect .mark::before { content: "✗"; color: var(--red); }
.slot .pickup-hint { font-size: .64rem; color: var(--muted); margin-top: .2rem; }

/* ---- The fact-tile bank ---- */
.bank {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem 1.3rem; box-shadow: var(--shadow); margin-top: 1.4rem;
}
.bank h3 { margin: 0 0 .2rem; font-size: 1rem; }
.bank .bank-hint { color: var(--muted); font-size: .8rem; margin: 0 0 .8rem; }
.bank-tokens { display: flex; flex-wrap: wrap; gap: .55rem; min-height: 2.6rem; }
.token {
  font: inherit; text-align: left; cursor: grab; max-width: 100%; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: .55rem .8rem; font-size: .86rem; box-shadow: var(--shadow);
}
.token:hover { border-color: var(--teal); }
.token:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.token.selected { border-color: var(--teal); background: var(--teal-soft); box-shadow: 0 0 0 3px rgba(15,125,119,.18); }
.token:active { cursor: grabbing; }
.token.is-distractor { border-color: var(--red); background: #fdf1ef; }
.token .owner-tag { font-size: .66rem; font-weight: 700; color: #8a2a1e; margin-top: .25rem; }
.bank-empty { color: var(--muted); font-size: .85rem; font-style: italic; }

.selected-note { font-size: .82rem; color: var(--teal-dark); font-weight: 700; margin: .6rem 0 0; min-height: 1rem; }

/* ---- Completion banner ---- */
.complete-banner {
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
  background: #e6f5ec; border: 1px solid var(--green); color: #1f5b3c;
  border-radius: var(--radius); padding: 1rem 1.2rem; margin: 1.3rem 0;
}
.complete-banner strong { font-size: 1.05rem; }

@media (max-width: 620px) {
  .exercise-toolbar { position: static; }
  .mono-field { grid-template-columns: 1fr; gap: .35rem; }
  .field-label { padding-top: 0; }
}
