/* ==========================================================================
   Phase 6 UX — makes the existing workbook exercises usable on screen.
   Purely additive: this file is injected into the generated copies under
   site/workbooks/ by tools/sync_workbooks.py. It never edits the canonical
   workbook markup or a single word of clinical text — it only styles the
   states the runtime (workbook.js) adds to elements that were already
   there (option tags, checkbox rows, blank writing lines, scales).
   ========================================================================== */

:root{
  --ws-accent:#1f6f66; --ws-accent-soft:#e6f1ef; --ws-line:#c9cfd4;
  --ws-ink:#1b1f24; --ws-ink-soft:#5c6670; --ws-white:#fff;
}

/* ---- fit the fixed-width print pages onto small screens ---------------- */
:root{ --ws-zoom:1; }
html, body{ max-width:100%; }
.rhh-page{ zoom:var(--ws-zoom); }
@supports not (zoom:1){
  /* older engines: scale instead, and pull back the space the scale leaves */
  .rhh-page{ transform:scale(var(--ws-zoom)); transform-origin:top right; }
}

/* ---- top bar: back to the library + save state ------------------------- */
.ws-bar{
  position:sticky; top:0; z-index:50; display:flex; align-items:center; gap:12px;
  justify-content:space-between; flex-wrap:wrap;
  padding:10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background:var(--ws-white); border-bottom:1px solid var(--ws-line);
  font-family:'Noto Sans Arabic',system-ui,sans-serif;
}
.ws-bar a.ws-back{
  display:inline-flex; align-items:center; gap:8px; min-height:44px; padding:8px 16px;
  border:1.5px solid var(--ws-line); border-radius:999px; text-decoration:none;
  color:var(--ws-accent); font-size:14px; font-weight:700; background:var(--ws-white);
}
.ws-bar a.ws-back:hover{ border-color:var(--ws-accent); background:var(--ws-accent-soft); }
.ws-status{ font-size:13px; color:var(--ws-ink-soft); }
.ws-status[data-state="saved"]{ color:var(--ws-accent); font-weight:700; }

/* ---- selectable option tags -------------------------------------------- */
.rhh-tag.ws-choice{
  cursor:pointer; user-select:none; min-height:44px; display:inline-flex; align-items:center;
  gap:7px; padding:9px 16px !important; border:1.5px solid var(--ws-line); background:var(--ws-white);
  transition:background .12s ease, border-color .12s ease, color .12s ease;
}
.rhh-tag.ws-choice::before{
  content:""; width:15px; height:15px; border:1.5px solid var(--ws-line); border-radius:50%;
  flex:none; transition:background .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.rhh-tag.ws-choice:hover{ border-color:var(--ws-accent); }
.rhh-tag.ws-choice[aria-pressed="true"]{
  background:var(--ws-accent); border-color:var(--ws-accent); color:var(--ws-white);
}
.rhh-tag.ws-choice[aria-pressed="true"]::before{
  background:var(--ws-white); border-color:var(--ws-white); box-shadow:inset 0 0 0 3px var(--ws-accent);
}
.rhh-tag.ws-choice:focus-visible, .rhh-check-row.ws-check:focus-visible,
.ws-scale:focus-visible{ outline:2.5px solid var(--ws-accent); outline-offset:2px; }

/* ---- checkbox rows: the whole row is the target ------------------------ */
.rhh-check-row.ws-check{
  cursor:pointer; user-select:none; min-height:44px; align-items:center;
  border-radius:8px; padding:5px 7px; margin-inline:-7px;
  transition:background .12s ease;
}
.rhh-check-row.ws-check:hover{ background:var(--ws-accent-soft); }
.rhh-check-row.ws-check[aria-checked="true"] .rhh-checkbox{
  background:var(--ws-accent); border-color:var(--ws-accent); position:relative;
}
.rhh-check-row.ws-check[aria-checked="true"] .rhh-checkbox::after{
  content:""; position:absolute; inset:0; margin:auto; width:5px; height:9px;
  border:solid #fff; border-width:0 2px 2px 0; transform:rotate(45deg) translate(-1px,-1px);
}
.rhh-check-row.ws-check[aria-checked="true"] span{ font-weight:700; color:var(--ws-accent); }

/* ---- writing areas: the blank lines become real fields ----------------- */
.ws-write{
  display:block; width:100%; box-sizing:border-box; resize:vertical;
  font-family:'Noto Sans Arabic',system-ui,sans-serif; font-size:10.5pt; line-height:2;
  color:var(--ws-ink); background:transparent; border:none; border-radius:6px;
  padding:2px 6px; margin:0;
  background-image:repeating-linear-gradient(transparent,transparent calc(2em - 1px),var(--ws-line) calc(2em - 1px),var(--ws-line) 2em);
}
.ws-write:focus{
  outline:none; background-color:var(--ws-accent-soft);
  box-shadow:0 0 0 2px var(--ws-accent);
}
.ws-inline{
  font-family:'Noto Sans Arabic',system-ui,sans-serif; font-size:inherit; color:var(--ws-ink);
  background:transparent; border:none; border-bottom:1.5px solid var(--ws-line);
  min-width:130px; min-height:40px; padding:4px 8px; border-radius:4px 4px 0 0;
}
.ws-inline:focus{ outline:none; border-bottom-color:var(--ws-accent); background:var(--ws-accent-soft); }

/* ---- rating scales ------------------------------------------------------ */
.rhh-scale.ws-scale{ cursor:pointer; padding-block:6px; }
.rhh-scale.ws-scale .track{ min-height:12px; }
.rhh-scale.ws-scale .dot{ transition:inset-inline-start .12s ease, left .12s ease; }

/* ---- Phase 8A: mark-complete control (docs/phase8/ENGINE_SPEC.md §1d) -- */
.ws-complete{
  display:block; width:fit-content; margin:28px auto 8px; min-height:48px;
  padding:12px 26px; border:1.5px solid var(--ws-accent); border-radius:999px;
  background:var(--ws-white); color:var(--ws-accent); font-size:15px; font-weight:700;
  font-family:'Noto Sans Arabic',system-ui,sans-serif; cursor:pointer;
}
.ws-complete:hover:not(:disabled){ background:var(--ws-accent-soft); }
.ws-complete:disabled{
  background:var(--ws-accent); color:var(--ws-white); border-color:var(--ws-accent);
  cursor:default; opacity:1;
}

/* ---- "next steps" rows become real links ------------------------------- */
.rhh-nextsteps .row.ws-link{
  cursor:pointer; text-decoration:none; color:inherit; border-radius:10px;
  transition:background .12s ease, box-shadow .12s ease, transform .06s ease;
}
.rhh-nextsteps .row.ws-link:hover{ background:var(--ws-accent-soft); box-shadow:0 2px 10px rgba(0,0,0,.08); }
.rhh-nextsteps .row.ws-link:active{ transform:scale(.995); }
.rhh-nextsteps .row.ws-link:focus-visible{ outline:2.5px solid var(--ws-accent); outline-offset:2px; }
.rhh-nextsteps .row.ws-link .book{ color:var(--ws-accent); font-weight:800; }

/* ---- phone ------------------------------------------------------------- */
@media (max-width:560px){
  .rhh-tag.ws-choice{ min-height:46px; }
  .rhh-check-row.ws-check{ min-height:48px; }
  .ws-inline{ min-height:44px; }
  .ws-write{ line-height:2.2; min-height:54px; }
  .ws-bar{ gap:8px; }
  .ws-bar a.ws-back{ font-size:13.5px; }
  .ws-status{ font-size:12px; }
}

/* Screen only — printing keeps the original workbook exactly as designed. */
@media print{
  .ws-bar{ display:none !important; }
  .ws-write, .ws-inline{ background:none; box-shadow:none; }
}
