/* ============================================================
   CrossWord — library.css
   Phase 10: Library tab, bookmarks, notes, reading plans,
   note modal.
   ============================================================ */

/* ── Library header ──────────────────────────────────────── */
.lib-header {
    padding: var(--sp-md) var(--sp-md) 0;
}

/* ── Library tabs ────────────────────────────────────────── */
.lib-tabs {
    display: flex;
    padding: var(--sp-sm) var(--sp-md) 0;
    gap: 0;
    border-bottom: 1px solid var(--border-light);
    margin-top: var(--sp-sm);
}

.lib-tab {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 0;
    font-family: var(--font-display);
    font-size: 0.72rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    margin-bottom: -1px;
}

.lib-tab.active {
    color: var(--navy);
    border-bottom-color: var(--gold);
}

/* ── Section content ─────────────────────────────────────── */
#lib-content {
    padding: var(--sp-md);
}

.lib-empty {
    text-align: center;
    padding: var(--sp-xl) 0;
    color: var(--text-muted);
}

.lib-empty p {
    font-size: 0.95rem;
    margin-bottom: var(--sp-xs);
}

/* ── Group header ────────────────────────────────────────── */
.lib-group {
    margin-bottom: var(--sp-lg);
}

.lib-group-title {
    font-family: var(--font-display);
    font-size: 0.7rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding-bottom: var(--sp-xs);
    border-bottom: 1px solid var(--border-light);
    margin-bottom: var(--sp-sm);
}

/* ── List rows ───────────────────────────────────────────── */
.lib-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-md);
    padding: var(--sp-sm) 0;
    border-bottom: 1px solid var(--border-light);
}

.lib-row:last-child { border-bottom: none; }

.lib-row-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.lib-ref {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--navy);
    font-weight: 600;
}

.lib-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
}

.lib-note-preview {
    font-size: 0.82rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
}

.lib-row-actions {
    display: flex;
    gap: var(--sp-xs);
    flex-shrink: 0;
}

/* ── Note icon badge in reader ───────────────────────────── */
.note-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--border);
    font-size: 0.9rem;
    padding: 2px;
    transition: color 0.2s;
    line-height: 1;
}

.note-btn:hover  { color: var(--navy-mid); }
.note-btn.active { color: var(--navy); }

/* ── Note modal ──────────────────────────────────────────── */
.note-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 600;
    background: rgba(17, 37, 72, 0.55);
    backdrop-filter: blur(2px);
    align-items: flex-end;
    justify-content: center;
    padding: var(--sp-md);
}

.note-modal.open {
    display: flex;
    animation: modalBackdropIn 0.2s ease;
}

@media (min-width: 768px) {
    .note-modal { align-items: center; }
}

.note-modal-inner {
    background: var(--surface);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    width: 100%;
    max-width: 540px;
    overflow: hidden;
    animation: lessonSlideUp 0.25s cubic-bezier(0.16,1,0.3,1);
    box-shadow: var(--shadow-xl);
}

@media (min-width: 768px) {
    .note-modal-inner {
        border-radius: var(--r-xl);
        animation: lessonFadeIn 0.2s cubic-bezier(0.16,1,0.3,1);
    }
}

.note-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-md);
    background: var(--navy);
    border-bottom: 1px solid rgba(201,168,76,0.2);
}

.note-modal-ref {
    font-family: var(--font-display);
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    color: var(--parchment);
}

.note-modal-close {
    background: none;
    border: none;
    color: rgba(237,227,207,0.6);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 4px;
    border-radius: var(--r-sm);
}

.note-modal-close:hover { color: var(--parchment); }

.note-textarea {
    width: 100%;
    padding: var(--sp-md);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--surface);
    border: none;
    resize: vertical;
    min-height: 120px;
    outline: none;
}

.note-modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-sm) var(--sp-md);
    background: var(--surface-raised);
    border-top: 1px solid var(--border-light);
}

.note-char-count {
    font-family: var(--font-display);
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

/* ── Reading plans ───────────────────────────────────────── */
.plan-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--r-lg);
    padding: var(--sp-md);
    margin-bottom: var(--sp-md);
    box-shadow: var(--shadow-sm);
}

.plan-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: var(--sp-sm);
}

.plan-name {
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 2px;
}

.plan-meta {
    font-family: var(--font-display);
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.plan-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: var(--sp-sm);
}

.plan-progress {
    margin-bottom: var(--sp-sm);
}

.plan-progress-meta {
    font-family: var(--font-display);
    font-size: 0.68rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-top: 4px;
}

.plan-next {
    font-size: 0.8rem;
    color: var(--navy-mid);
    margin-top: 2px;
    font-style: italic;
}

.plan-actions {
    display: flex;
    gap: var(--sp-sm);
    margin-top: var(--sp-sm);
}

/* ── Plan completion banner (Reader Mode) ────────────────── */
.plan-complete-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-md);
    padding: var(--sp-sm) var(--sp-md);
    background: linear-gradient(135deg, var(--navy-deep), var(--navy));
    border-top: 1px solid rgba(201,168,76,0.3);
    border-bottom: 1px solid rgba(201,168,76,0.3);
    flex-wrap: wrap;
}

.plan-banner-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.plan-banner-title {
    font-family: var(--font-display);
    font-size: 0.78rem;
    color: rgba(237,227,207,0.85);
    letter-spacing: 0.04em;
}

.plan-banner-day {
    font-family: var(--font-display);
    font-size: 0.62rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--gold);
}

/* Plans link button sits on navy banner — needs light text */
.plan-banner-plans-btn {
    background: rgba(237,227,207,0.12);
    border: 1px solid rgba(237,227,207,0.35);
    border-radius: var(--r-md);
    color: var(--parchment) !important;
    font-family: var(--font-display);
    font-size: 0.68rem;
    letter-spacing: 0.05em;
    padding: 6px 14px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.15s;
}
.plan-banner-plans-btn:hover {
    background: rgba(237,227,207,0.22);
}

/* ── Plan picker modal ───────────────────────────────────── */
.plan-picker-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 600;
    background: rgba(17,37,72,0.55);
    backdrop-filter: blur(2px);
    align-items: flex-end;
    justify-content: center;
    padding: var(--sp-md);
}

.plan-picker-overlay.open {
    display: flex;
    animation: modalBackdropIn 0.2s ease;
}

@media (min-width: 640px) {
    .plan-picker-overlay { align-items: center; }
}

.plan-picker-panel {
    background: var(--surface);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    animation: lessonSlideUp 0.25s cubic-bezier(0.16,1,0.3,1);
}

@media (min-width: 640px) {
    .plan-picker-panel { border-radius: var(--r-xl); }
}

.plan-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-md);
    background: var(--navy);
    border-bottom: 1px solid rgba(201,168,76,0.2);
}

.plan-picker-title {
    font-family: var(--font-display);
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    color: var(--parchment);
}

.plan-picker-close {
    background: none;
    border: none;
    color: rgba(237,227,207,0.55);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--r-sm);
    line-height: 1;
    transition: color 0.15s;
}
.plan-picker-close:hover { color: var(--parchment); }

.plan-picker-list {
    padding: var(--sp-xs) 0 var(--sp-sm);
}

.plan-picker-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-light);
    padding: var(--sp-md);
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}
.plan-picker-item:last-child { border-bottom: none; }
.plan-picker-item:hover { background: var(--surface-raised); }

.plan-picker-name {
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--navy);
}

.plan-picker-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ── Library slide-in panel ──────────────────────────────── */
.library-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 550;
    background: rgba(17,37,72,0.45);
    backdrop-filter: blur(2px);
}
.library-overlay.open { display: block; animation: modalBackdropIn 0.2s ease; }

.library-panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 560;
    width: min(360px, 92vw);
    background: var(--surface);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.16,1,0.3,1);
}
.library-panel.open { transform: translateX(0); }

.library-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-md);
    padding-top: calc(var(--sp-md) + env(safe-area-inset-top, 0px));
    background: var(--navy);
    flex-shrink: 0;
}

.library-panel-title {
    font-family: var(--font-display);
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    color: var(--parchment);
}

.library-panel-close {
    background: none;
    border: none;
    color: rgba(237,227,207,0.6);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--r-sm);
    line-height: 1;
    transition: color 0.15s;
}
.library-panel-close:hover { color: var(--parchment); }

.library-overlay-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-md);
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(var(--sp-md) + env(safe-area-inset-bottom, 0px));
}