/* Personal highlights and notes. */

:root {
  --pe-yellow: #ffe58a;
  --pe-green: #bdf0c9;
  --pe-blue: #c3e4ff;
  --pe-pink: #ffcade;
}

/* Highlights in the lesson text */
mark.pe-hl { color: inherit; background: var(--pe-yellow); border-radius: 2px; padding: 0.05em 0; cursor: pointer; box-decoration-break: clone; -webkit-box-decoration-break: clone; transition: box-shadow 0.2s; }
mark.pe-hl-yellow { background: var(--pe-yellow); }
mark.pe-hl-green { background: var(--pe-green); }
mark.pe-hl-blue { background: var(--pe-blue); }
mark.pe-hl-pink { background: var(--pe-pink); }
mark.pe-hl:hover { box-shadow: 0 0 0 2px rgba(14, 74, 83, 0.25); }
mark.pe-hl:focus-visible { outline: 2px solid var(--abyss); outline-offset: 1px; }
/* A small marker at the end of a highlight that has a note (generated content isn't part of the text). */
mark.pe-hl.has-note::after { content: ''; display: inline-block; width: 0.5em; height: 0.5em; margin-left: 0.18em; border-radius: 50%; background: var(--abyss); vertical-align: 0.45em; }
mark.pe-hl.pe-flash { animation: pe-flash 1.1s ease 2; }
@keyframes pe-flash { 0%, 100% { box-shadow: 0 0 0 0 rgba(217, 163, 21, 0); } 50% { box-shadow: 0 0 0 5px rgba(217, 163, 21, 0.75); } }

/* Colour swatches (toolbar and popover) */
.pe-swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.9); cursor: pointer; padding: 0; flex: none; }
.pe-swatch-yellow { background: var(--pe-yellow); }
.pe-swatch-green { background: var(--pe-green); }
.pe-swatch-blue { background: var(--pe-blue); }
.pe-swatch-pink { background: var(--pe-pink); }
.pe-swatch:hover { transform: scale(1.1); }
.pe-swatch[aria-pressed='true'] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--abyss); }

/* Floating toolbar for a text selection */
.pe-toolbar { position: absolute; z-index: 80; display: flex; align-items: center; gap: 0.45rem; padding: 0.4rem 0.5rem; background: var(--abyss-dark); color: #fff; border-radius: 6px; box-shadow: 0 6px 22px rgba(8, 57, 64, 0.35); }
.pe-toolbar::after { content: ''; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: var(--abyss-dark); }
.pe-toolbar.below::after { bottom: auto; top: -6px; border: 6px solid transparent; border-top: 0; border-bottom-color: var(--abyss-dark); }
.pe-tool-note, .pe-tool-signin { display: inline-flex; align-items: center; gap: 0.35rem; background: none; border: 0; border-left: 1px solid rgba(255, 255, 255, 0.2); color: #fff; font: 700 0.82rem/1 var(--font-ui); padding: 0.4rem 0.2rem 0.4rem 0.6rem; cursor: pointer; text-decoration: none; white-space: nowrap; }
.pe-tool-signin { border-left: 0; padding-left: 0.2rem; }
.pe-tool-note:hover, .pe-tool-signin:hover { color: var(--sun-neon); }

/* Popover for one highlight (a bottom sheet on phones) */
.pe-pop { position: absolute; z-index: 85; width: min(340px, calc(100vw - 16px)); background: #fff; border: 1px solid var(--border-strong); border-top: 4px solid var(--sun); box-shadow: 0 12px 34px rgba(8, 57, 64, 0.25); padding: 0.75rem 0.9rem 0.85rem; }
.pe-pop.sheet { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; border-radius: 12px 12px 0 0; padding-bottom: calc(0.9rem + env(safe-area-inset-bottom)); }
.pe-pop-head { display: flex; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.5rem; }
.pe-pop-quote { flex: 1; font-size: 0.85rem; font-style: italic; color: var(--fg-muted); line-height: 1.4; }
.pe-pop-head .icon-btn { width: 32px; height: 32px; margin: -0.25rem -0.4rem 0 0; }
.pe-pop textarea { min-height: 5.5rem; font-size: 0.95rem; }
.pe-pop-foot { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.6rem; }
.pe-pop .pe-swatches { display: flex; gap: 0.4rem; }
.pe-pop .pe-swatch { width: 24px; height: 24px; border-color: #fff; box-shadow: 0 0 0 1px var(--border-strong); }
.pe-pop .pe-swatch[aria-pressed='true'] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--abyss); }
.pe-pop-status { flex: 1; font-size: 0.78rem; color: var(--fg-subtle); }
.pe-pop-delete { background: none; border: 0; color: var(--coral-deep); font-weight: 700; font-size: 0.85rem; cursor: pointer; padding: 0.3rem 0; }
.pe-pop-delete:hover { text-decoration: underline; }

/* "My notes (n)" in the lesson header */
.pe-notes-item { margin-left: 0; }
.pe-notes-btn { display: inline-flex; align-items: center; gap: 0.35rem; background: none; border: 0; padding: 0; color: var(--surf-deep); font: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.pe-notes-btn .icon { color: var(--surf); }
.pe-notes-btn:hover { color: var(--abyss); }

/* Drawer listing this lesson's notes */
.pe-drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 76; width: min(420px, 100vw); background: #fff; box-shadow: -8px 0 30px rgba(8, 57, 64, 0.2); display: flex; flex-direction: column; transform: translateX(105%); transition: transform 0.25s ease; visibility: hidden; }
.pe-drawer.open { transform: none; visibility: visible; }
.pe-drawer-backdrop { display: none; position: fixed; inset: 0; z-index: 75; background: rgba(8, 57, 64, 0.45); }
.pe-drawer-open .pe-drawer-backdrop { display: block; }
.pe-drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1rem 0.75rem 1.25rem; border-bottom: 1px solid var(--border); }
.pe-drawer-head h2 { margin: 0; font-family: var(--font-display); text-transform: uppercase; font-weight: 400; font-size: 1.5rem; }
.pe-drawer-list { flex: 1; overflow-y: auto; padding: 0.75rem 1rem 1rem; display: grid; align-content: start; gap: 0.6rem; }
.pe-drawer-foot { border-top: 1px solid var(--border); padding: 0.85rem 1.25rem calc(0.85rem + env(safe-area-inset-bottom)); }
.pe-drawer-foot a { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: 700; text-decoration: none; }
.pe-item { display: grid; gap: 0.35rem; text-align: left; width: 100%; background: var(--bg-alt); border: 0; border-left: 5px solid var(--pe-yellow); padding: 0.7rem 0.85rem; cursor: pointer; font: inherit; color: var(--ink); }
.pe-item:hover { background: #eef3f3; }
.pe-item-yellow { border-left-color: #f0c93c; }
.pe-item-green { border-left-color: #5fc97c; }
.pe-item-blue { border-left-color: #5aaee8; }
.pe-item-pink { border-left-color: #ec7fa9; }
.pe-item-quote { font-size: 0.9rem; font-style: italic; color: var(--fg-muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pe-item-note { font-size: 0.95rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.pe-item-orphan { font-size: 0.78rem; color: var(--coral-deep); font-weight: 600; }
.pe-empty { color: var(--fg-muted); font-size: 0.95rem; padding: 0.5rem 0.25rem; }
.pe-empty p { margin: 0 0 0.6rem; }

/* ---------- My notes page ---------- */
.notes-page .page-head p { max-width: 62ch; }
.notes-tools { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin: 1.5rem 0 0.5rem; }
.notes-tools input[type='search'] { flex: 1 1 240px; max-width: 420px; }
.notes-course { margin-top: 2.5rem; }
.notes-lesson { margin: 1.5rem 0 0; }
.notes-lesson h3 { font-size: 1.1rem; margin: 0 0 0.6rem; }
.notes-lesson h3 a { color: var(--ink); text-decoration: none; }
.notes-lesson h3 a:hover { text-decoration: underline; }
.notes-list { display: grid; gap: 0.6rem; list-style: none; margin: 0; padding: 0; }
.note-card { display: grid; gap: 0.4rem; border: 1px solid var(--border); border-left: 5px solid #f0c93c; padding: 0.85rem 1rem; background: #fff; }
.note-card.pe-item-green { border-left-color: #5fc97c; }
.note-card.pe-item-blue { border-left-color: #5aaee8; }
.note-card.pe-item-pink { border-left-color: #ec7fa9; }
.note-card blockquote { margin: 0; font-style: italic; color: var(--fg-muted); overflow-wrap: anywhere; }
.note-card .note-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.note-card-foot { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; align-items: center; font-size: 0.85rem; color: var(--fg-subtle); }
.note-card-foot a { font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; gap: 0.2rem; }
.note-card-foot .linklike { color: var(--coral-deep); margin-left: auto; }
.notes-empty { text-align: center; padding: 3rem 1rem; color: var(--fg-muted); }
.notes-empty .empty-icon { font-size: 2.6rem; color: var(--sun); margin-bottom: 0.75rem; }
.notes-empty p { max-width: 52ch; margin: 0 auto 1.25rem; }
.notes-demo { background: var(--pe-yellow); padding: 0 0.2em; border-radius: 2px; }
