/* ============================================================
   HealthLit Mechanics Library
   Visit Prep Builder — styles

   Every colour and face is read from a host variable with a
   fallback, so the mechanic inherits a module's palette when it is
   embedded and still renders on its own. Nothing here imports or
   assumes a particular module, and nothing here brands anything:
   rendering the finished document belongs to the host module.

   Motion is opt-in: transitions are declared only inside
   prefers-reduced-motion: no-preference, so a reader who has asked
   for less motion gets none rather than a reduced amount. That
   includes the review screen's grouping, which is laid out rather
   than animated into place.

   Nothing here depends on hover, drag, gesture or pointer motion.
   Hover states repeat what the resting state already shows.

   The markup this styles, settled by the ruling of September 4, 2026
   that a line's text sits outside its control:

     <div class="vpb vpb-capture">
       <p class="vpb-prompt">…the fixed prompt…</p>
       <ul class="vpb-lines">
         <li class="vpb-line">
           <p class="vpb-line-text" id="…">…line text, tap-to-define
              connectors live inside it…</p>
           <button type="button" class="vpb-toggle" aria-pressed="false"
                   aria-labelledby="…label… …line text…">
             <span class="vpb-mark" aria-hidden="true"></span>
             <span class="vpb-toggle-label">Keep for notes</span>
           </button>
         </li>
       </ul>
     </div>

   The line text is a sibling of the toggle, never a child of it. A
   control cannot contain another control: nesting the module's
   tap-to-define buttons inside a toggle would flatten them out of the
   accessibility tree and make looking a word up also keep the line.

   Selection state is carried three ways and depends on none of them
   alone: the label text changes, the marker changes shape from an
   open square to a filled square with a check, and the colour
   changes. §9.6 forbids colour as the only carrier; the label alone
   would satisfy it, and the marker is there for a reader who scans
   rather than reads.
   ============================================================ */

.vpb {
  font-family: var(--sans, system-ui, sans-serif);
  color: var(--ink, #1a1a18);
  font-size: calc(15px * var(--fs, 1));
  line-height: 1.6;
}

.vpb *, .vpb *::before, .vpb *::after { box-sizing: border-box; }

.vpb .vpb-h {
  font-family: var(--serif, Georgia, serif);
  font-size: calc(1.35em * var(--fs, 1));
  line-height: 1.3;
  font-weight: 600;
  margin: 0 0 .6em;
}

.vpb :focus-visible {
  outline: 3px solid var(--accent, #c4530a);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- orientation ---------- */
/* Shown once before the first scene offering capture. It explains the
   affordance, so it reads as guidance rather than as a heading. */
.vpb .vpb-orientation {
  margin: 0 0 1.2em;
  padding: .8em 1em;
  border-left: 3px solid var(--accent, #c4530a);
  background: var(--paper, #f7f4ee);
  color: var(--ink-mid, #4a4a44);
}

/* ---------- capture ---------- */
.vpb-capture { margin: 1.2em 0; }

.vpb .vpb-prompt {
  font-size: calc(1.05em * var(--fs, 1));
  margin: 0 0 .7em;
}

.vpb .vpb-lines {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: .6em;
}

.vpb .vpb-line {
  display: grid;
  gap: .5em .9em;
  align-items: start;
  padding: .7em .9em;
  border: 1px solid var(--paper-deep, #d6cfc2);
  border-radius: 6px;
  background: var(--paper, #f7f4ee);
}

/* One column under a narrow viewport, text above its control; two
   columns where there is room, control to the right. No layout here
   depends on a pointer, and the tab order follows the source either
   way: text, then the control that keeps it. */
@media (min-width: 34em) {
  .vpb .vpb-line {
    grid-template-columns: 1fr auto;
  }
}

.vpb .vpb-line-text {
  margin: 0;
  align-self: center;
}

/* A module's tap-to-define connector, styled here only so it stays
   visible as a control inside line text. The connector itself belongs
   to the module; this mechanic must not break it. */
.vpb .vpb-line-text [data-vpb-term],
.vpb .vpb-line-text [data-fwe-term] {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

/* ---------- the line toggle ---------- */
.vpb .vpb-toggle {
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: .5em;
  padding: .45em .8em;
  border: 1.5px solid var(--ink-light, #8a8a80);
  border-radius: 999px;
  background: var(--paper, #f7f4ee);
  color: var(--ink-mid, #4a4a44);
  cursor: pointer;
  white-space: nowrap;
}

.vpb .vpb-toggle[aria-pressed="true"] {
  border-color: var(--accent, #c4530a);
  border-width: 2px;
  color: var(--accent-deep, #a3440a);
  background: var(--accent-light, #f0e8df);
}

/* The marker. Open square when the line is not kept, filled square
   with a check when it is — a shape difference that survives
   greyscale, monochrome and a reader who does not distinguish the two
   colours. */
.vpb .vpb-mark {
  flex: none;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-radius: 3px;
  position: relative;
}

.vpb .vpb-toggle[aria-pressed="true"] .vpb-mark {
  background: currentColor;
}

.vpb .vpb-toggle[aria-pressed="true"] .vpb-mark::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 46%;
  width: .28em;
  height: .5em;
  border: solid var(--paper, #f7f4ee);
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -50%) rotate(45deg);
}

.vpb .vpb-toggle-label { display: inline-block; }

/* ---------- review screen ---------- */
.vpb-review { margin: 1.2em 0; }

.vpb .vpb-note {
  margin: 0 0 1.2em;
  color: var(--ink-mid, #4a4a44);
}

.vpb .vpb-group { margin: 0 0 1.4em; }

.vpb .vpb-group-heading {
  font-family: var(--sans, system-ui, sans-serif);
  font-size: calc(.95em * var(--fs, 1));
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--ink-mid, #4a4a44);
  margin: 0 0 .5em;
}

.vpb .vpb-group-lines {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: .45em;
}

/* A document line. It is read, not operated: nothing here is a
   control, because the review screen shows what was chosen and the
   choosing happens back in the scenes. */
.vpb .vpb-doc-line {
  padding: .6em .8em;
  border-left: 3px solid var(--paper-deep, #d6cfc2);
  background: var(--paper, #f7f4ee);
}

/* ---------- controls ---------- */
.vpb .vpb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .6em;
  margin-top: 1.4em;
}

.vpb .vpb-btn {
  font: inherit;
  padding: .6em 1.1em;
  border-radius: 6px;
  border: 1.5px solid var(--accent, #c4530a);
  cursor: pointer;
}

.vpb .vpb-btn-primary {
  background: var(--accent, #c4530a);
  color: var(--paper, #f7f4ee);
}

.vpb .vpb-btn-secondary {
  background: none;
  color: var(--accent-deep, #a3440a);
}

/* ---------- motion, opt-in only ---------- */
@media (prefers-reduced-motion: no-preference) {
  .vpb .vpb-toggle { transition: border-color .15s ease, color .15s ease, background-color .15s ease; }
  .vpb .vpb-btn { transition: background-color .15s ease, color .15s ease; }
}

/* Hover repeats the resting state's information and adds none of its
   own, so nothing is lost on a device that never hovers. */
@media (hover: hover) {
  .vpb .vpb-toggle:hover { border-color: var(--accent, #c4530a); }
  .vpb .vpb-btn-secondary:hover { background: var(--accent-light, #f0e8df); }
}

/* ---------- forced colours ---------- */
/* Where the system replaces the palette, the marker's shape and the
   label still carry the state. Borders are kept in system colours so
   the pressed state stays visible. */
@media (forced-colors: active) {
  .vpb .vpb-toggle { border-color: ButtonBorder; }
  .vpb .vpb-toggle[aria-pressed="true"] { border-color: Highlight; }
  .vpb .vpb-mark { border-color: ButtonText; }
  .vpb .vpb-toggle[aria-pressed="true"] .vpb-mark { background: Highlight; }
}
