/* Notes side-panel + global-summary banner */

/* Width is controlled via the --notes-panel-width CSS variable so the panel
 * and the main-content padding stay in sync as the user drags to resize. */
:root {
    --notes-panel-width: 320px;
}

/* When the notes panel is expanded, push the main content over instead of
 * overlaying the transcript. The panel itself is still position:fixed; we
 * reserve a strip on the right of the page layout so nothing flows underneath.
 *
 * .app-layout normally caps at max-width: 1400px (centered). With that cap in
 * place, wide viewports would still shrink the transcript even though the
 * panel lives outside the centered layout. Lift the cap while the panel is
 * open so the transcript gets to use the full remaining viewport width.
 */
body.notes-panel-expanded .app-layout {
    max-width: none;
    margin: 0;
    padding-right: var(--notes-panel-width);
    transition: padding-right 0.2s ease-out;
}

/* Disable transitions while the user is actively dragging the resize handle \u2014
 * otherwise the panel and padding lag behind the cursor. */
body.notes-panel-resizing .app-layout,
body.notes-panel-resizing .notes-panel {
    transition: none !important;
}
body.notes-panel-resizing {
    cursor: col-resize;
    user-select: none;
}

/* Reclaim more space by hiding the per-language Table of Contents when the
 * notes panel is open \u2014 the user is focused on notes; TOC can be toggled via
 * the normal navigation. */
body.notes-panel-expanded .toc {
    display: none;
}

/* On narrow viewports, fall back to overlay so the transcript doesn't get
 * crushed. */
@media (max-width: 900px) {
    body.notes-panel-expanded .app-layout {
        padding-right: 0;
    }
}

.notes-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: var(--notes-panel-width);
    max-width: 90vw;
    background: var(--surface, #ffffff);
    color: var(--on-surface, #222);
    border-left: 1px solid var(--border, #ddd);
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.06);
    transform: translateX(100%);
    transition: transform 0.2s ease-out, width 0.2s ease-out;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    font-family: inherit;
}

/* Drag handle on the left edge of the panel: 6px-wide hit target so the
 * cursor is easy to catch; a 1px highlight line appears on hover. */
.notes-panel-resize-handle {
    position: absolute;
    top: 0;
    left: -3px;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 9002;
    background: transparent;
}

.notes-panel-resize-handle::after {
    content: '';
    position: absolute;
    top: 0;
    left: 2px;
    width: 2px;
    height: 100%;
    background: transparent;
    transition: background 0.15s;
}

.notes-panel-resize-handle:hover::after,
body.notes-panel-resizing .notes-panel-resize-handle::after {
    background: var(--accent, #4a90e2);
}

.notes-panel.expanded {
    transform: translateX(0);
}

.notes-panel-header {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border, #eee);
    gap: 8px;
}

.notes-panel-title {
    font-weight: 600;
    font-size: 14px;
    flex: 0 0 auto;
}

.notes-panel-icon {
    opacity: 0.7;
    margin-left: 4px;
}

.notes-panel-view-toggle {
    flex: 1;
    display: inline-flex;
    justify-content: center;
    gap: 0;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 6px;
    padding: 2px;
    margin: 0 6px;
}

.notes-panel-view-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted, #666);
    border-radius: 4px;
    line-height: 1.4;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}

.notes-panel-view-btn:hover {
    color: inherit;
}

.notes-panel-view-btn.active {
    background: #ffffff;
    color: inherit;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.notes-panel-autoscroll,
.notes-panel-close {
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
    color: inherit;
}

.notes-panel-autoscroll:hover,
.notes-panel-close:hover {
    background: rgba(0, 0, 0, 0.06);
}

.notes-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 0 60px;
    font-size: 13px;
    line-height: 1.45;
    font-family: 'SFMono-Regular', 'Menlo', 'Consolas', monospace;
    position: relative;
}

.notes-panel-chapter {
    border-left: 3px solid transparent;
    transition: border-left-color 0.15s ease;
}

.notes-panel-chapter:not(.collapsed) {
    border-left-color: var(--accent, #4a90e2);
}

.notes-panel-chapter-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    background: #e5f4f2;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 13px;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 1px solid transparent;
}

.notes-panel-chapter:not(.collapsed) .notes-panel-chapter-header {
    border-bottom-color: var(--border, #e0e4eb);
}

.notes-panel-chapter-header:hover {
    background: #d6ecea;
}

.notes-panel-chapter-caret {
    display: inline-block;
    width: 12px;
    text-align: center;
    transition: transform 0.15s ease;
    color: var(--muted, #666);
    font-size: 10px;
}

.notes-panel-chapter.collapsed .notes-panel-chapter-caret {
    transform: rotate(-90deg);
}

.notes-panel-chapter-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notes-panel-chapter-count {
    color: var(--muted, #888);
    font-weight: 500;
    font-size: 11px;
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 8px;
    border-radius: 10px;
    min-width: 22px;
    text-align: center;
}

.notes-panel-chapter-body {
    padding: 6px 14px 10px;
}

.notes-panel-chapter.collapsed .notes-panel-chapter-body {
    display: none;
}

.notes-panel-note {
    display: flex;
    gap: 6px;
    padding: 4px 2px;
    border-radius: 4px;
    cursor: pointer;
    align-items: baseline;
}

.notes-panel-note:hover {
    background: rgba(0, 0, 0, 0.04);
}

/* Sub-bullets (level 1): indent and use a slightly muted bullet glyph */
.notes-panel-note.level-1 {
    padding-left: 22px;
    opacity: 0.92;
}

.notes-panel-note.level-1 .notes-panel-bullet {
    font-size: 0.85em;
    color: var(--muted, #888);
}

.notes-panel-bullet {
    color: var(--accent, #4a90e2);
    flex: 0 0 auto;
}

.notes-panel-text {
    flex: 1;
    word-break: break-word;
}

/* Markdown rendering inside a bullet. Use 700 (not 600) to ensure visible bold
 * across all system fonts \u2014 600 can look near-identical to regular on some. */
.notes-panel-text strong { font-weight: 700; color: inherit; }
.notes-panel-text em { font-style: italic; color: inherit; }
.notes-panel-text code {
    font-family: 'SFMono-Regular', 'Menlo', 'Consolas', monospace;
    font-size: 0.92em;
    padding: 0 3px;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.05);
}

.notes-panel-time {
    flex: 0 0 auto;
    color: var(--muted, #aaa);
    font-size: 10px;
    opacity: 0;
    transition: opacity 0.15s;
}

.notes-panel-note:hover .notes-panel-time {
    opacity: 1;
}

.notes-panel-jump {
    position: absolute;
    bottom: 12px;
    right: 12px;
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    background: var(--accent, #4a90e2);
    color: white;
    cursor: pointer;
    font-size: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Tab on right edge when panel is collapsed */
.notes-panel-tab {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    background: var(--accent, #4a90e2);
    color: white;
    padding: 14px 8px;
    border-top-left-radius: 6px;
    border-bottom-left-radius: 6px;
    cursor: pointer;
    z-index: 9001;
    font-size: 12px;
    font-weight: 600;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    display: none;
    align-items: center;
    gap: 6px;
    user-select: none;
    box-shadow: -2px 0 6px rgba(0, 0, 0, 0.1);
}

.notes-panel-tab.visible {
    display: flex;
}

.notes-panel-tab-badge {
    background: white;
    color: var(--accent, #4a90e2);
    border-radius: 10px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 700;
    writing-mode: horizontal-tb;
}

/* Global-summary banner — pinned at top of main content */
.global-summary-banner {
    margin: 10px 14px;
    padding: 10px 14px;
    background: var(--surface-alt, #f7f9fc);
    border: 1px solid var(--border, #d8e1ec);
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.global-summary-banner-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
}

.global-summary-banner-title {
    flex: 1;
}

.global-summary-banner-toggle {
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
    color: inherit;
}

.global-summary-banner-toggle:hover {
    background: rgba(0, 0, 0, 0.06);
}

.global-summary-banner-body {
    font-size: 13px;
    line-height: 1.6;
}

/* Pulse highlight when a note click jumps the transcript */
.notes-jump-highlight {
    background-color: rgba(255, 220, 100, 0.4) !important;
    transition: background-color 0.5s ease-out;
}

/* ===== Edit overlay ====================================================== */

.notes-panel-note {
    position: relative;
}

.notes-panel-note .notes-panel-bullet,
.notes-panel-note .notes-panel-time {
    cursor: pointer;
}

[data-view-mode="edited"] .notes-panel-note .notes-panel-text {
    cursor: text;
    border-radius: 3px;
}

[data-view-mode="edited"] .notes-panel-note:hover .notes-panel-text {
    background: rgba(0, 0, 0, 0.04);
}

.notes-panel-pen {
    color: var(--accent, #4a90e2);
    font-size: 11px;
    margin-left: 4px;
    flex: 0 0 auto;
    opacity: 0.7;
}

.notes-panel-delete {
    background: none;
    border: none;
    color: var(--muted, #888);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 4px;
    border-radius: 3px;
    opacity: 0;
    transition: opacity 0.12s ease, color 0.12s ease, background 0.12s ease;
    flex: 0 0 auto;
}

.notes-panel-note:hover .notes-panel-delete {
    opacity: 1;
}

.notes-panel-delete:hover {
    color: #c0392b;
    background: rgba(192, 57, 43, 0.08);
}

.notes-panel-note.user-added .notes-panel-bullet {
    color: var(--accent, #4a90e2);
}

.notes-panel-note.user-added .notes-panel-text {
    font-style: italic;
}

.notes-panel-edit-textarea {
    flex: 1;
    min-height: 22px;
    width: 100%;
    font-family: inherit;
    font-size: inherit;
    line-height: 1.45;
    padding: 4px 6px;
    border: 1px solid var(--accent, #4a90e2);
    border-radius: 4px;
    background: #ffffff;
    color: inherit;
    resize: vertical;
    box-sizing: border-box;
    overflow: hidden;
}

.notes-panel-edit-textarea:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.18);
}

.notes-panel-note.editing {
    background: rgba(74, 144, 226, 0.04);
    border-radius: 4px;
}

.notes-panel-chapter-tail {
    margin-top: 4px;
}

.notes-panel-add-note {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 4px;
    color: var(--muted, #888);
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
    font-style: italic;
    user-select: none;
    transition: background 0.12s ease, color 0.12s ease;
}

.notes-panel-add-note:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--accent, #4a90e2);
}

.notes-panel-add-note-glyph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.08);
    color: inherit;
    font-size: 14px;
    line-height: 1;
    flex: 0 0 auto;
}

.notes-panel-add-note:hover .notes-panel-add-note-glyph {
    background: var(--accent, #4a90e2);
    color: white;
}

.notes-panel-add-note-textarea {
    margin: 2px 0 4px;
}

/* Original (read-only) mode: hide edit-only affordances. */
[data-view-mode="original"] .notes-panel-delete,
[data-view-mode="original"] .notes-panel-add-note,
[data-view-mode="original"] .notes-panel-chapter-tail {
    display: none;
}
