/* Notes on a lesson (server/public/feedback.js). Colours, fonts and the overlay look come from the viewer's own
   style sheet (viewer/style.css: --panel, --fg, --accent, --ov-line, .ov; viewer/lesson.css: .lz-btn). */

/* the button in the lesson bar */
.fbk-btn svg { flex: none; }
.fbk-btn[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.fbk-count { font: 600 11.5px var(--mono); min-width: 18px; padding: 1px 5px; border-radius: 999px; background: var(--accent); color: var(--panel); text-align: center; box-sizing: border-box; }
.fbk-count[hidden], .fbk-sheet[hidden], .fbk-notes[hidden], .fbk-pic[hidden], .fbk-line[hidden], .fbk-name[hidden], .fbk-as[hidden], .fbk-link[hidden] { display: none !important; }

/* the sheet: under the lesson bar, left; the figure, the caption and the transport stay in sight */
.fbk-sheet { position: absolute; z-index: 16; top: calc(var(--lz-top-b, 50px) + 10px); left: var(--gap); box-sizing: border-box;
  width: min(560px, calc(100vw - var(--lz-panel-w) - 3 * var(--gap))); max-height: calc(100% - var(--lz-top-b, 50px) - 24px); overflow-y: auto;
  padding: 12px 14px 12px; font: 400 14px/1.45 var(--body); color: var(--fg); background: var(--panel); pointer-events: auto; }
.fbk-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.fbk-head b { color: var(--fg); font-weight: 600; }
.fbk-head .sp, .fbk-acts .sp { flex: 1; }
.fbk-x { font: 600 13px var(--body); color: var(--muted); background: none; border: 1px solid transparent; border-radius: 6px; min-height: 30px; padding: 0 8px; cursor: pointer; }
.fbk-x:hover { color: var(--fg); border-color: var(--ov-line); }
.fbk-link { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.fbk-line { margin: 8px 0 0; padding: 2px 0 2px 10px; border-left: 3px solid var(--accent); color: var(--muted); font-size: 13px; max-height: 4.4em; overflow: hidden; }
.fbk-body { display: grid; grid-template-columns: 124px minmax(0, 1fr); gap: 12px; margin-top: 10px; align-items: start; }
.fbk-sheet.nopic .fbk-body { grid-template-columns: minmax(0, 1fr); }
.fbk-pic { width: 100%; max-height: 150px; object-fit: cover; object-position: center top; display: block; border: 1px solid var(--ov-line); border-radius: 4px; background: var(--stage); }
.fbk-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.fbk-chip { font: 500 12.5px var(--body); color: var(--muted); background: none; border: 1px solid var(--ov-line); border-radius: 999px; min-height: 28px; padding: 0 10px; cursor: pointer; }
.fbk-chip[aria-pressed="true"] { color: var(--panel); background: var(--accent); border-color: var(--accent); }
.fbk-text { width: 100%; box-sizing: border-box; min-height: 84px; resize: vertical; font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--ov-line); border-radius: 6px; padding: 8px 10px; }
.fbk-text:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.fbk-acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.fbk-b { font: 600 13.5px var(--body); color: var(--fg); background: var(--panel); border: 1px solid var(--ov-line); border-radius: 8px; min-height: 36px; padding: 0 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.fbk-b.primary { background: var(--accent); border-color: var(--accent); color: var(--panel); }
.fbk-b:disabled { opacity: .45; cursor: default; }
.fbk-b[hidden] { display: none; }
.fbk-b .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.fbk-b[aria-pressed="true"] .dot { background: #c8402f; animation: fbk-blink 1s infinite; }
.fbk-b.waiting { border-color: var(--warn); color: var(--warn); }
.fbk-b.waiting .dot { background: var(--warn); }
.fbk-b kbd { font: 500 11.5px var(--mono); opacity: .75; }
@keyframes fbk-blink { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .fbk-b[aria-pressed="true"] .dot { animation: none; } }
.fbk-name { font: inherit; font-size: 13.5px; color: var(--fg); background: var(--bg); border: 1px solid var(--ov-line); border-radius: 8px; min-height: 36px; padding: 0 10px; flex: 1 1 110px; min-width: 110px; width: auto; box-sizing: border-box; }
.fbk-as { font: 500 12px var(--mono); color: var(--muted); border: 1px solid var(--ov-line); border-radius: 999px; padding: 2px 9px; }
.fbk-fine { margin: 8px 0 0; font-size: 12px; color: var(--muted); }

/* toast */
.fbk-toast { position: absolute; z-index: 22; left: 50%; bottom: calc(var(--gap) + var(--lz-bot-h, 150px) + 16px); transform: translateX(-50%); display: flex; align-items: center; gap: 12px;
  max-width: calc(100vw - 32px); box-sizing: border-box; padding: 8px 14px; font: 500 13.5px var(--body); color: var(--fg); background: var(--panel); pointer-events: auto; }
.fbk-toast button { font: 600 13.5px var(--body); color: var(--accent); background: none; border: 0; padding: 4px 2px; cursor: pointer; }

/* the notes inside the lesson text */
.lz-step:has(> .fbk-mark) { display: flex; align-items: center; gap: 10px; }
.fbk-mark { display: inline-flex; align-items: center; gap: 3px; vertical-align: baseline; margin-left: 5px; padding: 0 6px 0 4px; min-height: 20px; font: 600 11.5px var(--mono); line-height: 1;
  color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); border-radius: 999px; cursor: pointer; }
.fbk-mark svg { width: 13px; height: 13px; }
.fbk-mark[aria-expanded="false"] { background: none; }
.fbk-notes { margin: 6px 0 12px; border-left: 3px solid var(--warn); background: color-mix(in srgb, var(--warn) 7%, transparent); cursor: auto; font-size: .93em; }
.fbk-notes.solo { margin-top: 16px; }
.fbk-notes h3 { margin: 0; padding: 8px 10px 0; font: 600 12px var(--mono); color: var(--muted); letter-spacing: .02em; }
.fbk-note { padding: 8px 10px; }
.fbk-note + .fbk-note { border-top: 1px solid var(--ov-line); }
.fbk-note.viewer { box-shadow: inset 3px 0 0 var(--accent); }
.fbk-meta { font-size: 12px; color: var(--muted); }
.fbk-meta b { color: var(--fg); font-weight: 600; }
.fbk-chg { margin-left: 6px; padding: 0 6px; border: 1px solid var(--warn); border-radius: 999px; color: var(--warn); white-space: nowrap; }
.fbk-note blockquote { margin: 4px 0 0; padding-left: 8px; border-left: 2px solid var(--ov-line); color: var(--muted); font-size: .95em; }
.fbk-note p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.fbk-do { display: flex; gap: 14px; margin-top: 4px; font-size: 12.5px; }
.fbk-do:empty { display: none; }

/* phones: the sheet runs edge to edge over the bottom of the screen; the button shows its icon only */
@media (max-width: 767px) {
  .fbk-btn { position: relative; min-width: 38px; justify-content: center; padding: 0 8px; }
  .fbk-count { position: absolute; top: -5px; right: -5px; }
  .fbk-btn .fbk-lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .fbk-sheet { position: fixed; z-index: 40; top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 82dvh; border-radius: 0; border-inline: 0; border-bottom: 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); font-size: 15px; box-shadow: 0 -8px 24px rgb(0 0 0 / .18); }
  .fbk-body { display: block; }                    /* the picture small in the corner, the chips beside it, the text field across */
  .fbk-pic { float: right; width: 88px; max-height: 88px; margin: 0 0 8px 12px; }
  .fbk-text { display: block; clear: both; font-size: 16px; }      /* below 16 px iOS zooms the page on focus */
  .fbk-name { font-size: 16px; }
  /* notes in the lesson text run to both screen edges, like the steps they sit in */
  .fbk-notes { margin-left: calc(3px - var(--lz-pad)); margin-right: calc(-1 * var(--lz-pad)); }
  .fbk-note, .fbk-notes h3 { padding-left: calc(var(--lz-pad) - 6px); padding-right: var(--lz-pad); }
  .fbk-b kbd { display: none; }
  .fbk-toast { position: fixed; left: 8px; right: 8px; top: calc(max(6px, env(safe-area-inset-top, 0px)) + 50px); bottom: auto; transform: none; max-width: none; justify-content: space-between; }
}
