/* ==========================================================================
   Live Phrase Bank & Correction Board
   Everything is scoped under .pb, so nothing here can touch the rest of the theme.
   To restyle it, change the variables in the first block only.
   ========================================================================== */

.pb {
  /* Theme hooks: each one falls back to the theme's own variable, then to a fixed value. */
  --pb-bg:      var(--card, #fbf8f2);      /* drawer background */
  --pb-ink:     var(--ink, #16181d);       /* main text */
  --pb-muted:   var(--muted, #474c55);     /* small print */
  --pb-rule:    var(--rule, #d9d1c2);      /* hairlines */
  --pb-accent:  var(--orange, #b8461a);    /* buttons, badge */
  --pb-font:    var(--sans, 'Inter', system-ui, sans-serif);
  --pb-head:    var(--head, 'Playfair Display', Georgia, serif);

  /* Category colours (all pass AA contrast on the cream background). */
  --pb-vocab:   #1d5c88;
  --pb-grammar: #b8461a;
  --pb-pron:    #5a3d8f;

  --pb-width:   400px;                     /* drawer width on a laptop */
  --pb-entry:   20px;                      /* note size: big enough to read on a shared screen */
  --pb-radius:  8px;
  --pb-speed:   .22s;

  font-family: var(--pb-font);
  color: var(--pb-ink);
}
.pb *, .pb *::before, .pb *::after { box-sizing: border-box; }
.pb [hidden] { display: none !important; }
.pb button { font-family: inherit; cursor: pointer; }
.pb :focus-visible { outline: 3px solid #e8b33b; outline-offset: 2px; }

/* ---------- Floating toggle ---------- */
.pb-toggle {
  position: fixed; right: 20px; bottom: 20px; z-index: 9000;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 12px 10px 14px;
  border: 1px solid var(--pb-rule); border-radius: 999px;
  background: var(--pb-bg); color: var(--pb-ink);
  font-size: 15px; font-weight: 700; line-height: 1;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .16);
  opacity: .92;
  transition: opacity var(--pb-speed), transform var(--pb-speed), right var(--pb-speed);
}
.pb-toggle:hover { opacity: 1; transform: translateY(-1px); }
.pb-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pb-count {
  min-width: 24px; padding: 4px 7px; border-radius: 999px;
  background: var(--pb-accent); color: #fff;
  font-size: 13px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums;
}
.pb-count[data-n="0"] { background: var(--pb-rule); color: var(--pb-muted); }
.pb.is-open .pb-toggle { right: calc(min(var(--pb-width), 100vw) + 16px); }

/* ---------- Drawer ---------- */
.pb-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 9001;
  width: min(var(--pb-width), 100vw);
  display: flex; flex-direction: column;
  background: var(--pb-bg);
  border-left: 1px solid var(--pb-rule);
  box-shadow: -10px 0 40px rgba(0, 0, 0, .18);
  transform: translateX(105%);
  visibility: hidden;
  transition: transform var(--pb-speed) ease, visibility 0s linear var(--pb-speed);
}
.pb.is-open .pb-drawer { transform: none; visibility: visible; transition: transform var(--pb-speed) ease; }

.pb-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 18px 12px; border-bottom: 2px solid var(--pb-ink); }
.pb-title { font-family: var(--pb-head); font-weight: 900; font-size: 26px; line-height: 1.1; }
.pb-lesson { font-size: 13px; color: var(--pb-muted); margin-top: 4px; line-height: 1.3; }
.pb-close { border: 0; background: none; color: var(--pb-ink); font-size: 30px; line-height: 1; padding: 0 6px; border-radius: 6px; }
.pb-close:hover { color: var(--pb-accent); }

/* ---------- Category pills ---------- */
.pb-cats { display: flex; gap: 6px; padding: 14px 18px 0; }
.pb-cat {
  flex: 1; padding: 9px 6px; border-radius: 999px;
  border: 2px solid var(--c); background: transparent; color: var(--c);
  font-size: 13px; font-weight: 700; line-height: 1.15; white-space: nowrap;
}
.pb-cat[data-cat="vocab"]   { --c: var(--pb-vocab); }
.pb-cat[data-cat="grammar"] { --c: var(--pb-grammar); }
.pb-cat[data-cat="pron"]    { --c: var(--pb-pron); }
.pb-cat[aria-checked="true"] { background: var(--c); color: #fff; }

/* ---------- Input row ---------- */
.pb-form { display: flex; align-items: center; gap: 6px; padding: 12px 18px 0; }
.pb-in {
  flex: 1; min-width: 0; height: 46px; padding: 0 12px;
  border: 2px solid var(--pb-ink); border-radius: var(--pb-radius);
  background: #fff; color: var(--pb-ink);
  font: 600 17px var(--pb-font);
}
.pb-in::placeholder { color: #8a8f98; font-weight: 400; }
.pb-in-wrong { border-color: var(--pb-rule); }
.pb-arrow { font-size: 20px; font-weight: 800; color: var(--pb-grammar); }
.pb-add { height: 46px; padding: 0 14px; border: 0; border-radius: var(--pb-radius); background: var(--pb-ink); color: #fff; font-size: 15px; font-weight: 700; }
.pb-add:hover { background: var(--pb-accent); }
.pb-hint { margin: 8px 18px 0; font-size: 12px; color: var(--pb-muted); line-height: 1.4; }

/* ---------- Board ---------- */
.pb-board { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 18px 18px; margin-top: 10px; border-top: 1px solid var(--pb-rule); }
.pb-empty { margin: 28px 0; text-align: center; color: var(--pb-muted); font-size: 15px; line-height: 1.5; }
.pb-group { margin-top: 16px; }
.pb-group[data-cat="vocab"]   { --c: var(--pb-vocab); }
.pb-group[data-cat="grammar"] { --c: var(--pb-grammar); }
.pb-group[data-cat="pron"]    { --c: var(--pb-pron); }
.pb-group h3 { margin: 0 0 6px; display: flex; align-items: center; gap: 8px; font: 800 12px var(--pb-font); letter-spacing: .12em; text-transform: uppercase; color: var(--c); }
.pb-group h3 span { font-weight: 700; letter-spacing: 0; color: var(--pb-muted); }
.pb-list { list-style: none; margin: 0; padding: 0; }
.pb-item { display: flex; align-items: flex-start; gap: 4px; border-left: 4px solid var(--c); background: #fff; border-radius: 0 var(--pb-radius) var(--pb-radius) 0; margin-top: 6px; }
.pb-item.is-new { animation: pb-flash .9s ease; }
@keyframes pb-flash { from { background: #ffe9b0; } to { background: #fff; } }
.pb-text {
  flex: 1; min-width: 0; padding: 9px 4px 9px 12px;
  border: 0; background: none; color: var(--pb-ink); text-align: left;
  font: 600 var(--pb-entry)/1.3 var(--pb-font); overflow-wrap: anywhere; cursor: text;
}
.pb-text:hover { background: rgba(0, 0, 0, .04); }
.pb-wrong { color: #7a2a12; text-decoration: line-through; text-decoration-thickness: 2px; font-weight: 400; }
.pb-to { color: var(--pb-grammar); font-weight: 800; padding: 0 6px; }
.pb-del { flex: none; width: 36px; height: 40px; border: 0; background: none; color: var(--pb-muted); font-size: 24px; line-height: 1; border-radius: 6px; }
.pb-del:hover { color: #a3210b; background: rgba(163, 33, 11, .08); }
/* editing a note in place */
.pb-edit { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 4px 6px 8px; }
.pb-edit .pb-in { height: 40px; flex: 1 1 120px; font-size: 17px; }

/* ---------- Footer: exports and clear ---------- */
.pb-foot { padding: 12px 18px 16px; border-top: 1px solid var(--pb-rule); display: flex; flex-direction: column; gap: 8px; }
.pb-exports { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pb-btn { padding: 10px 6px; border: 1.5px solid var(--pb-ink); border-radius: var(--pb-radius); background: transparent; color: var(--pb-ink); font-size: 13px; font-weight: 700; line-height: 1.2; }
.pb-btn:hover { background: var(--pb-ink); color: #fff; }
.pb-btn:disabled { opacity: .4; cursor: default; background: transparent; color: var(--pb-ink); }
.pb-clear { border-color: var(--pb-rule); color: var(--pb-muted); }
.pb-clear.is-armed, .pb-clear.is-armed:hover { background: #a3210b; border-color: #a3210b; color: #fff; }

/* ---------- Toast ---------- */
.pb-toast {
  position: absolute; left: 50%; bottom: 120px; transform: translate(-50%, 10px);
  padding: 10px 18px; border-radius: 999px; background: var(--pb-ink); color: #fff;
  font-size: 15px; font-weight: 700; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.pb-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Inside Presentation Mode (the .pr overlay from present.js) ----------
   phrase-bank.js moves the widget into the overlay while it is open, so it is still
   there in full screen. With the drawer open, the slide makes room for it. */
.pr .pb-toggle { bottom: 96px; z-index: 6; }
.pr .pb.is-open .pb-toggle { display: none; }          /* the drawer has its own close button */
.pr .pb-drawer { z-index: 7; }
.pr-idle .pb:not(.is-open) .pb-toggle { opacity: 0; }
.pr-idle .pb-drawer, .pr-idle .pb-drawer * { cursor: auto; }
.pr-idle .pb-drawer button { cursor: pointer; }
.pr-idle .pb-drawer input { cursor: text; }
@media (min-width: 900px) {
  .pr.pb-docked { padding-right: var(--pb-dock, 400px); transition: padding .22s; }   /* --pb-dock is set by phrase-bank.js */
}

/* ---------- Small screens and reduced motion ---------- */
@media (max-width: 520px) {
  .pb { --pb-width: 100vw; }
  .pb-exports { grid-template-columns: 1fr; }
  .pb.is-open .pb-toggle { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .pb-drawer, .pb-toggle, .pb-toast { transition: none; }
  .pb-item.is-new { animation: none; }
}
@media print { .pb { display: none; } }

/* ---------- Send to student ---------- */
.pb-send { background: var(--pb-accent); border-color: var(--pb-accent); color: #fff; font-size: 15px; padding: 12px 6px; }
.pb-send:hover { background: var(--pb-ink); border-color: var(--pb-ink); }
.pb-send:disabled, .pb-send:disabled:hover { background: transparent; border-color: var(--pb-rule); color: var(--pb-muted); }
.pb-levels { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; font-weight: 700; color: var(--pb-muted); }
.pb-levels .pb-btn { flex: 1; }

/* ---------- "Notes from your class" on the student page (outside the drawer, so it prints) ---------- */
.pb-sheet h2 { margin-bottom: 4px; }
.pb-sheet-sub { font-family: var(--sans, Inter, sans-serif); font-size: 14px; color: var(--muted, #5d6778); margin: 0 0 6px; }
.pb-sheet h3 { font: 800 12px var(--sans, Inter, sans-serif); letter-spacing: .12em; text-transform: uppercase; margin: 18px 0 6px; }
.pb-sheet h3[data-cat="vocab"] { color: #1d5c88; } .pb-sheet h3[data-cat="grammar"] { color: #b8461a; } .pb-sheet h3[data-cat="pron"] { color: #5a3d8f; }
.pb-sheet ul { list-style: none; margin: 0; padding: 0; }
.pb-sheet li { font-family: var(--sans, Inter, sans-serif); font-weight: 600; font-size: 18px; line-height: 1.35; padding: 7px 0 7px 12px; border-left: 3px solid var(--line, #d8cfbd); margin-top: 6px; overflow-wrap: anywhere; }
.pb-sheet s { color: #7a2a12; font-weight: 400; } .pb-sheet .pb-to { color: #b8461a; font-weight: 800; padding: 0 6px; }
@media print { .pb-sheet-sub { display: none; } .pb-sheet li { font-size: 13px; padding: 3px 0 3px 10px; } }

/* ---------- Reminders: notes from an earlier day, and "clear the board?" after sending ---------- */
.pb-old { margin: 12px 0 0; padding: 10px 12px; border-radius: var(--pb-radius); background: #fff3d6; border: 1px solid #e8c36a; font-size: 14px; line-height: 1.4; }
.pb-levels span { flex: 1 1 100%; }
.pb-levels span b { color: var(--pb-ink); }

/* ---------- Free-lesson board (default.hbs): only visible while Present mode is open ---------- */
.pb[data-mode="sample"]:not(.pb-live) { display: none; }

/* v1.9.24 · simpler footer: one send button with a short explanation, one print button; timer stays visible */
.pb-how { margin: 2px 0 6px; font-size: 13px; line-height: 1.4; color: var(--pb-muted); }
.pb-exports { grid-template-columns: 1fr !important; }
.pb[data-mode="student"] .pb-how-t { display: none; }
.pr.pb-docked .pr-timer { right: calc(var(--pb-dock, 400px) + 26px); }
@media (max-width: 899px) { .pr.pb-docked .pr-timer { right: auto; left: 12px; } }
.pb-toast { white-space: normal; max-width: 90%; text-align: center; }

.pb-linkbtn { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: var(--pb-ink); text-decoration: underline; cursor: pointer; }
a.pb-btn { text-align: center; text-decoration: none; }
.pb-preview-note { margin: 0 0 12px; padding: 8px 12px; border-radius: 6px; background: #fff3d6; border: 1px solid #e8c36a; font-size: 14px; }
@media print { .pb-preview-note { display: none; } }
