/* Reader feedback (feedback.js): highlights, comments in the margin or under their paragraph, the comment sheet and the list */
:root { --fb-mark: rgba(240, 180, 0, 0.28); --fb-mark-strong: rgba(240, 180, 0, 0.6); }
body.fb-on article.page { position: relative; }
/* a highlight takes no custom properties in some browsers, so the colors are written out */
::highlight(fb) { background-color: rgba(240, 180, 0, 0.28); }
::highlight(fb-active), ::highlight(fb-pending) { background-color: rgba(240, 180, 0, 0.6); }

.fb-ui[hidden] { display: none !important; }
button.fb-ui, .fb-ui button {
  font: 13px/1.2 -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  color: var(--ink);
  background: none;
  border: 0;
  border-radius: 6px;
  padding: 0.4em 0.65em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.fb-ui button:hover { background: var(--shade); }
.fb-ui button:disabled { color: var(--faint); cursor: default; background: none; }

/* one comment: its number and quote, the text, Edit and Delete */
.fb-note { display: block; font-size: 14px; line-height: 1.3; text-align: left; text-indent: 0; hyphens: manual; -webkit-hyphens: manual; }
.fb-note > span, .fb-item > span { display: block; }
.fb-meta { color: var(--faint); font-size: 13px; }
.fb-num { display: inline; font-weight: 700; color: var(--ink); margin-right: 0.4em; }
.fb-lost { display: inline; color: var(--ink); font-style: italic; }
.fb-quote { font-style: italic; }
.fb-text { white-space: pre-wrap; margin-top: 0.15em; }
.fb-actions { margin-left: -0.65em; opacity: 0; transition: opacity 0.15s; }
.fb-note:hover .fb-actions, .fb-note:focus-within .fb-actions { opacity: 1; }
@media (pointer: coarse) { .fb-actions { opacity: 1; } }
.fb-flash { animation: fb-flash 1.8s ease-out; }
@keyframes fb-flash { from { background: var(--fb-mark-strong); } to { background: transparent; } }

/* a wide screen: the text moves left and the comments sit in the right margin, as in Tufte's books */
.fb-margin { position: absolute; top: 0; left: calc(100% + 28px); width: 232px; }
.fb-margin .fb-note { position: absolute; left: 0; right: 0; }
.fb-margin .fb-quote { display: none; }
@media (min-width: 960px) {
  body.fb-chapter .page, body.fb-chapter nav.pager { margin-left: max(0px, calc((100% - 872px) / 2)); margin-right: 0; }
}

/* a narrow screen: the comments sit under their paragraph */
.fb-inline { display: block; margin: 0.5em 0 0.7em 1.5em; text-indent: 0; }
.fb-inline .fb-note { border-left: 2px solid var(--fb-mark-strong); padding-left: 0.6em; }
.fb-inline .fb-note + .fb-note { margin-top: 0.6em; }
.figure + .fb-inline + p, pre + .fb-inline + p { text-indent: 1.5em; }

/* the Comment button: under the selection with a mouse, at the bottom of the screen on a touch screen */
.fb-ui.fb-comment {
  position: absolute;
  z-index: 20;
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  padding: 0.6em 1.1em;
  font-size: 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}
.fb-ui.fb-comment.fb-fixed { position: fixed; top: auto !important; left: 50% !important; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }

.fb-ui.fb-pill {
  position: fixed;
  z-index: 20;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--paper);
  border: 1px solid var(--shade);
  border-radius: 999px;
  padding: 0.55em 1em;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

/* the comment sheet */
.fb-sheet {
  position: fixed;
  z-index: 30;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  width: min(560px, calc(100vw - 32px));
  padding: 12px;
  background: var(--paper);
  border: 1px solid var(--shade);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}
.fb-sheet-quote { font-size: 14px; font-style: italic; color: var(--faint); margin-bottom: 8px; max-height: 3.9em; overflow: hidden; }
/* 16px keeps iOS from zooming in when the text box gets focus */
.fb-sheet textarea, .fb-manual {
  display: block;
  box-sizing: border-box;
  width: 100%;
  padding: 8px;
  font: 16px/1.35 var(--serif);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--shade);
  border-radius: 6px;
  resize: vertical;
}
.fb-sheet-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }
.fb-ui .fb-save, .fb-ui .fb-primary { background: var(--ink); color: var(--paper); }
.fb-ui .fb-save:hover, .fb-ui .fb-primary:hover { background: var(--ink); opacity: 0.85; }
.fb-ui .fb-primary:disabled { background: var(--shade); color: var(--faint); opacity: 1; }

/* the list of all comments: a side panel on a wide screen, a sheet from the bottom on a phone */
.fb-panel {
  position: fixed;
  z-index: 40;
  top: 0;
  right: 0;
  bottom: 0;
  box-sizing: border-box;
  width: min(400px, 100vw);
  overflow-y: auto;
  padding: 16px;
  background: var(--paper);
  border-left: 1px solid var(--shade);
  box-shadow: -6px 0 24px rgba(0, 0, 0, 0.12);
}
.fb-panel-head { display: flex; justify-content: space-between; align-items: center; font-size: 20px; font-weight: 700; }
.fb-panel-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.fb-panel-status { min-height: 1.3em; font: 13px/1.3 -apple-system, BlinkMacSystemFont, system-ui, sans-serif; color: var(--faint); }
.fb-panel h3 { font-size: 16px; margin: 18px 0 4px; }
.fb-item { display: block; padding: 8px 0; border-top: 1px solid var(--shade); text-decoration: none; font-size: 14px; line-height: 1.3; }
.fb-item:hover { text-decoration: none; background: var(--fb-mark); }
.fb-empty { font-size: 14px; color: var(--faint); margin-top: 12px; }
.fb-manual { height: 12em; margin: 8px 0; font: 12px/1.35 var(--mono); }
@media (max-width: 640px) {
  .fb-panel {
    top: auto;
    left: 0;
    width: auto;
    max-height: 80vh;
    border-left: 0;
    border-top: 1px solid var(--shade);
    border-radius: 12px 12px 0 0;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.15);
  }
}

@media print { .fb-ui { display: none !important; } }
