/* Private lesson notes (assets/notes.js, server/notes.php; Daniel, 2026-11-20).
   Lesson pages: from 1440 px the panel stands in the right margin, opposite the lesson map; narrower,
   the "My notes" button (bottom left; the lesson-map button has the right) opens it at the side, and on
   a phone as a sheet from the bottom. No backdrop: the lesson stays readable and scrollable.
   My progress: the Notes pane (#notes-pane). */
:root { --np-rule: color-mix(in srgb, var(--accent) 15%, transparent); --np-paper: #fefef9; --np-warn: #9a5b13; }
:root[data-theme="dark"] { --np-rule: color-mix(in srgb, var(--accent) 15%, transparent); --np-paper: #211e1a; --np-warn: #e0b45a; }

/* ---- The button ---- */
.notes-btn { display: inline-flex; align-items: center; gap: 8px; position: fixed; z-index: 50;
  left: max(14px, env(safe-area-inset-left)); bottom: calc(16px + env(safe-area-inset-bottom));
  padding: 8px 16px 8px 13px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
  background: var(--card); background: color-mix(in srgb, var(--card) 94%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: var(--fg); font: inherit; font-size: 14px; box-shadow: 0 6px 18px rgba(30, 34, 20, .16); }
.notes-btn:hover { border-color: var(--accent); }
.notes-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.notes-btn .fa { color: var(--accent); font-size: 15px; margin: 0; }
.notes-btn .notes-dot { position: absolute; left: 25px; top: 6px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px var(--card); }
.notes-btn .notes-dot[hidden] { display: none; }
:root[data-theme="dark"] .notes-btn { box-shadow: 0 6px 18px rgba(0, 0, 0, .4); }
body.notes-open .notes-btn { display: none; }
/* The one-time "Tap any Hebrew word" note (say.js) sits at the bottom too: the button waits above it. */
@media (max-width: 1439px) { body:has(.hb-say-tip) .notes-btn { bottom: calc(84px + env(safe-area-inset-bottom)); } }

/* ---- The panel ---- */
.notes-panel { position: fixed; z-index: 65; display: flex; flex-direction: column; box-sizing: border-box;
  right: max(14px, env(safe-area-inset-right)); top: 68px; bottom: calc(16px + env(safe-area-inset-bottom)); width: min(400px, calc(100vw - 28px));
  padding: 16px 16px 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--card);
  box-shadow: 0 14px 40px rgba(30, 34, 20, .18); font-size: 15px; line-height: 1.4; }
.notes-panel[hidden] { display: none; }
:root[data-theme="dark"] .notes-panel { box-shadow: 0 14px 40px rgba(0, 0, 0, .5); }
.np-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 0 0 10px 2px; }
.np-k { margin: 2px 0 2px; font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.np-k .fa { margin-right: 4px; }
.np-where { margin: 0; font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.np-x { position: relative; flex: 0 0 30px; width: 30px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 50%;
  background: var(--card); cursor: pointer; }
.np-x::before, .np-x::after { content: ""; position: absolute; left: 50%; top: 50%; width: 12px; height: 1.6px; border-radius: 1px;
  background: var(--muted); transform: translate(-50%, -50%) rotate(45deg); }
.np-x::after { transform: translate(-50%, -50%) rotate(-45deg); }
.np-x:hover { border-color: var(--accent); }
.np-x:hover::before, .np-x:hover::after { background: var(--accent); }

/* The writing surface: a ruled page. Every line takes its own direction (a Hebrew line runs right to
   left, an English one left to right), and the rules move with the text. */
.np-paper { flex: 1 1 auto; min-height: 120px; display: flex; border: 1px solid var(--line); border-radius: 12px; background: var(--np-paper); overflow: hidden; }
.np-paper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.np-text { flex: 1 1 auto; width: 100%; box-sizing: border-box; margin: 0; padding: 6px 14px 14px; border: 0; outline: 0; resize: none;
  font: inherit; font-size: 16px; line-height: 36px; color: var(--fg); background: transparent;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 35px, var(--np-rule) 35px, var(--np-rule) 36px);
  background-position: 0 0; background-attachment: local;
  unicode-bidi: plaintext; text-align: start; overflow-wrap: break-word; scrollbar-width: thin; }
.np-text::placeholder { color: var(--muted); opacity: .85; }
.np-text:disabled { cursor: progress; }

/* Hebrew letter pad. */
.np-pad { margin: 10px 0 0; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.np-pad[hidden] { display: none; }
.np-keys { display: grid; gap: 5px; }
.np-keys + .np-keys { margin-top: 6px; }
.np-letters { grid-template-columns: repeat(9, 1fr); }
.np-marks { grid-template-columns: repeat(8, 1fr); padding-top: 6px; border-top: 1px solid var(--line); }
.np-ctrl { grid-template-columns: 1fr 52px 52px; }
.np-keys button { min-width: 0; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--card);
  color: var(--he); font: inherit; font-size: 19px; line-height: 1; cursor: pointer; }
.np-marks button { font-size: 22px; }
.np-ctrl button { font-size: 14px; color: var(--muted); }
.np-ctrl .np-del, .np-ctrl .np-nl { font-size: 17px; }
.np-keys button:hover { border-color: var(--accent); color: var(--accent); }
.np-keys button:active { background: color-mix(in srgb, var(--accent) 14%, var(--card)); }

.np-bar { display: flex; align-items: center; gap: 10px; margin: 10px 0 0; min-height: 32px; }
.np-he { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: none; color: var(--accent); font: inherit; font-size: 13.5px; cursor: pointer; }
.np-he span { font-size: 17px; line-height: 1; }
.np-he:hover { border-color: var(--accent); }
.np-he.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.np-status { flex: 1 1 auto; min-width: 0; font-size: 13px; color: var(--muted); text-align: right; }
.np-status.is-warn { color: var(--np-warn); }
.np-count { flex: 0 0 auto; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.np-count.is-over { color: var(--bad); font-weight: 700; }
.np-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 2px 0; padding-top: 8px;
  border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.np-foot a { color: var(--accent); text-decoration: none; font-weight: 700; white-space: nowrap; }
.np-foot a:hover { text-decoration: underline; }
.np-foot .fa-chevron-right { font-size: 10px; }
.np-lock .fa { font-size: 11px; margin-right: 4px; color: var(--accent); }

/* A guest's panel: what notes are, and the two doors. */
.np-guest { padding: 8px 4px 4px; }
.np-guest p { margin: 0 0 12px; color: var(--muted); }
.np-guest .np-guest-lead { font-size: 19px; line-height: 1.3; font-weight: 700; color: var(--fg); }
.np-guest .np-lock { font-size: 13.5px; }
.np-guest-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px !important; }
.np-guest-actions a { text-decoration: none; font-size: 15px; padding: 8px 18px; }
.notes-panel:has(.np-guest) { bottom: auto; }

/* "Add to my notes" beside a selection in the lesson. */
.notes-quote { position: fixed; z-index: 70; display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px;
  border: 1px solid var(--accent); border-radius: 999px; background: var(--accent); color: var(--on-accent);
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; box-shadow: 0 6px 16px rgba(30, 34, 20, .22); }
.notes-quote[hidden] { display: none; }
.notes-quote .fa { margin: 0; }
:root[data-theme="dark"] .notes-quote { box-shadow: 0 6px 16px rgba(0, 0, 0, .5); }

/* Wide screens: in the right margin, under the header, like the lesson map on the left. */
@media (min-width: 1440px) {
  .notes-panel { left: calc(50% + 434px); right: max(14px, calc(50% - 410px - 24px - 380px)); width: auto; top: 92px; bottom: 24px;
    box-shadow: none; }
  :root[data-theme="dark"] .notes-panel { box-shadow: none; }
  .notes-btn { left: calc(50% + 434px); top: 92px; bottom: auto; box-shadow: none; }
  :root[data-theme="dark"] .notes-btn { box-shadow: none; }
}
/* Phones: a sheet from the bottom, over the lower part of the lesson. */
@media (max-width: 640px) {
  .notes-panel { left: 0; right: 0; top: auto; bottom: 0; width: auto; height: min(72vh, 600px); height: min(72dvh, 600px);
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0; border-bottom: 0; }
  .notes-panel::before { content: ""; display: block; width: 40px; height: 4px; margin: 0 auto 10px; border-radius: 2px; background: var(--line); }
  .notes-panel:has(.np-guest) { height: auto; }
  /* With the letter pad open the sheet stands taller, and the page keeps at least four lines. */
  .notes-panel.pad-on { height: min(92vh, 760px); height: min(92dvh, 760px); }
  .notes-panel.pad-on .np-paper { min-height: 100px; }
  .notes-panel.pad-on .np-keys button { height: 36px; }
  .np-text { font-size: 17px; }
  .np-keys button { height: 40px; font-size: 21px; }
  .np-ctrl button { font-size: 14px; }
  .notes-btn { padding: 10px 14px 10px 12px; }
  .np-foot { font-size: 12px; }
}
@media print { .notes-btn, .notes-panel, .notes-quote { display: none !important; } }

/* ---- My progress: the Notes pane ---- */
.notes-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 0 0 16px; }
.notes-lock { flex: 1 1 100%; margin: 0; font-size: 14px; color: var(--muted); }
.notes-lock .fa { color: var(--accent); margin-right: 5px; font-size: 12px; }
.notes-find { flex: 1 1 240px; }
.notes-find input { width: 100%; box-sizing: border-box; padding: 9px 16px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--fg); font: inherit; font-size: 15px; unicode-bidi: plaintext; }
.notes-find input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.notes-dl { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; padding: 8px 16px; text-decoration: none; }
.note-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.note-item[hidden] { display: none; }
.note-item > a { display: block; padding: 14px 18px 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--card);
  color: inherit; text-decoration: none; }
.note-item > a:hover { border-color: var(--accent); }
.note-item > a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.note-item-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin: 0 0 8px; }
.note-item-head .chip { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--accent); color: var(--on-accent);
  font-size: 12.5px; font-weight: 700; letter-spacing: .02em; }
.note-item-head .chip.chip-bonus { background: var(--bonus); color: var(--on-bonus); }
.note-item-head .chip.chip-wrap { background: var(--wrap); color: var(--on-wrap); }
.note-item-title { font-weight: 700; font-size: 17px; }
.note-item-text { margin: 0 0 10px; padding: 2px 0 2px 12px; border-left: 3px solid var(--np-rule); white-space: pre-line; unicode-bidi: plaintext; text-align: start;
  font-size: 15.5px; line-height: 1.7; color: var(--fg); overflow-wrap: break-word;
  display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.note-item-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin: 0; font-size: 13px; color: var(--muted); }
.note-item-meta .dot { opacity: .6; }
.note-item-open { margin-left: auto; color: var(--accent); font-weight: 700; }
.note-item-open .fa { font-size: 10px; margin-left: 2px; }
.notes-none, .notes-count { color: var(--muted); font-size: 14px; }
.notes-count { margin: 14px 0 0; text-align: center; }
.notes-empty { padding: 30px 24px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); text-align: center; }
.notes-empty > .fa { font-size: 30px; color: var(--accent); }
.notes-empty h2 { margin: 10px 0 8px; font-size: 1.35em; }
.notes-empty p { max-width: 520px; margin: 0 auto 10px; color: var(--muted); }
.notes-empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 16px !important; }
.notes-empty-actions a { text-decoration: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
