/*
 * WritePadPro core — issue highlights, popover, legend and issue-list styles.
 * Used by WPPHighlight (CSS Custom Highlight API: ::highlight(wpp-<type>)),
 * the editor and the Grammar & Spell Checker.
 *
 * Every category has a colour AND a non-colour cue (underline style or
 * background vs. underline), so categories stay distinguishable for people
 * with colour-vision deficiencies. Palette based on Okabe–Ito.
 *
 *   type           colour      cue
 *   hard           yellow      background (sentence)
 *   veryHard       red         background + thin solid underline (sentence)
 *   adverb         blue        background + dotted underline
 *   passive        green       background + solid underline
 *   complex        purple      background + dashed underline
 *   cliche         orange      background + double underline
 *   hedge          grey        dotted underline only
 *   repeat         magenta     thick solid underline only
 *   longParagraph  slate       faint background only
 *   spelling       red         thick wavy underline (+ faint tint)
 *   grammar        blue        thick wavy underline (+ faint tint)
 *   style          teal        thick dashed underline only
 *   active         indigo      strong background (issue whose popover is open)
 *
 * Literal colours are used inside ::highlight() (custom properties are not
 * reliably inherited by highlight pseudo-elements in older engines).
 * Dark theme is the default; [data-theme="light"] overrides follow.
 */

/* ── Highlights: dark theme (default) ───────────────────────────── */
::highlight(wpp-longParagraph) { background-color: rgba(148, 163, 184, 0.10); }
::highlight(wpp-hard)     { background-color: rgba(240, 228, 66, 0.24); }
::highlight(wpp-veryHard) { background-color: rgba(239, 68, 68, 0.26); text-decoration: underline solid rgba(248, 113, 113, 0.9); text-decoration-thickness: 1px; text-underline-offset: 3px; }
::highlight(wpp-adverb)   { background-color: rgba(86, 180, 233, 0.26); text-decoration: underline dotted #7cc4f0; text-decoration-thickness: 2px; text-underline-offset: 3px; }
::highlight(wpp-passive)  { background-color: rgba(16, 185, 129, 0.24); text-decoration: underline solid #34d399; text-decoration-thickness: 1px; text-underline-offset: 3px; }
::highlight(wpp-complex)  { background-color: rgba(168, 85, 247, 0.26); text-decoration: underline dashed #c4a5fd; text-decoration-thickness: 1px; text-underline-offset: 3px; }
::highlight(wpp-cliche)   { background-color: rgba(230, 159, 0, 0.26); text-decoration: underline double #f6b73c; text-underline-offset: 3px; }
::highlight(wpp-hedge)    { text-decoration: underline dotted #a3b1c6; text-decoration-thickness: 2px; text-underline-offset: 3px; }
::highlight(wpp-repeat)   { text-decoration: underline solid #e879b9; text-decoration-thickness: 2px; text-underline-offset: 3px; }
::highlight(wpp-style)    { text-decoration: underline dashed #2dd4bf; text-decoration-thickness: 2px; text-underline-offset: 3px; }
::highlight(wpp-grammar)  { background-color: rgba(96, 165, 250, 0.10); text-decoration: underline wavy #60a5fa; text-decoration-thickness: 2px; text-underline-offset: 3px; }
::highlight(wpp-spelling) { background-color: rgba(248, 113, 113, 0.10); text-decoration: underline wavy #f87171; text-decoration-thickness: 2px; text-underline-offset: 3px; }
::highlight(wpp-active)   { background-color: rgba(129, 140, 248, 0.45); }

/* ── Highlights: light theme ────────────────────────────────────── */
[data-theme="light"] ::highlight(wpp-longParagraph) { background-color: rgba(100, 116, 139, 0.08); }
[data-theme="light"] ::highlight(wpp-hard)     { background-color: rgba(250, 204, 21, 0.38); }
[data-theme="light"] ::highlight(wpp-veryHard) { background-color: rgba(239, 68, 68, 0.22); text-decoration: underline solid #dc2626; text-decoration-thickness: 1px; text-underline-offset: 3px; }
[data-theme="light"] ::highlight(wpp-adverb)   { background-color: rgba(59, 130, 246, 0.20); text-decoration: underline dotted #0072b2; text-decoration-thickness: 2px; text-underline-offset: 3px; }
[data-theme="light"] ::highlight(wpp-passive)  { background-color: rgba(0, 158, 115, 0.20); text-decoration: underline solid #00805c; text-decoration-thickness: 1px; text-underline-offset: 3px; }
[data-theme="light"] ::highlight(wpp-complex)  { background-color: rgba(147, 51, 234, 0.17); text-decoration: underline dashed #7e22ce; text-decoration-thickness: 1px; text-underline-offset: 3px; }
[data-theme="light"] ::highlight(wpp-cliche)   { background-color: rgba(230, 159, 0, 0.28); text-decoration: underline double #b45309; text-underline-offset: 3px; }
[data-theme="light"] ::highlight(wpp-hedge)    { text-decoration: underline dotted #64748b; text-decoration-thickness: 2px; text-underline-offset: 3px; }
[data-theme="light"] ::highlight(wpp-repeat)   { text-decoration: underline solid #be185d; text-decoration-thickness: 2px; text-underline-offset: 3px; }
[data-theme="light"] ::highlight(wpp-style)    { text-decoration: underline dashed #0f766e; text-decoration-thickness: 2px; text-underline-offset: 3px; }
[data-theme="light"] ::highlight(wpp-grammar)  { background-color: rgba(37, 99, 235, 0.07); text-decoration: underline wavy #1d4ed8; text-decoration-thickness: 2px; text-underline-offset: 3px; }
[data-theme="light"] ::highlight(wpp-spelling) { background-color: rgba(220, 38, 38, 0.07); text-decoration: underline wavy #dc2626; text-decoration-thickness: 2px; text-underline-offset: 3px; }
[data-theme="light"] ::highlight(wpp-active)   { background-color: rgba(99, 102, 241, 0.30); }

/* ── Same looks as element classes (fallback <mark>s, legends, lists) ── */
.wpp-mark { color: inherit; background: transparent; border-radius: 2px; padding: 0; text-decoration-skip-ink: none; }
.wpp-mark--longParagraph { background: rgba(148, 163, 184, 0.10); }
.wpp-mark--hard     { background: rgba(240, 228, 66, 0.24); }
.wpp-mark--veryHard { background: rgba(239, 68, 68, 0.26); text-decoration: underline 1px solid rgba(248, 113, 113, 0.9); text-underline-offset: 3px; }
.wpp-mark--adverb   { background: rgba(86, 180, 233, 0.26); text-decoration: underline 2px dotted #7cc4f0; text-underline-offset: 3px; }
.wpp-mark--passive  { background: rgba(16, 185, 129, 0.24); text-decoration: underline 1px solid #34d399; text-underline-offset: 3px; }
.wpp-mark--complex  { background: rgba(168, 85, 247, 0.26); text-decoration: underline 1px dashed #c4a5fd; text-underline-offset: 3px; }
.wpp-mark--cliche   { background: rgba(230, 159, 0, 0.26); text-decoration: underline double #f6b73c; text-underline-offset: 3px; }
.wpp-mark--hedge    { text-decoration: underline 2px dotted #a3b1c6; text-underline-offset: 3px; }
.wpp-mark--repeat   { text-decoration: underline 2px solid #e879b9; text-underline-offset: 3px; }
.wpp-mark--style    { text-decoration: underline 2px dashed #2dd4bf; text-underline-offset: 3px; }
.wpp-mark--grammar  { background: rgba(96, 165, 250, 0.10); text-decoration: underline 2px wavy #60a5fa; text-underline-offset: 3px; }
.wpp-mark--spelling { background: rgba(248, 113, 113, 0.10); text-decoration: underline 2px wavy #f87171; text-underline-offset: 3px; }
.wpp-mark.is-active { background: rgba(129, 140, 248, 0.45); }

[data-theme="light"] .wpp-mark--longParagraph { background: rgba(100, 116, 139, 0.08); }
[data-theme="light"] .wpp-mark--hard     { background: rgba(250, 204, 21, 0.38); }
[data-theme="light"] .wpp-mark--veryHard { background: rgba(239, 68, 68, 0.22); text-decoration-color: #dc2626; }
[data-theme="light"] .wpp-mark--adverb   { background: rgba(59, 130, 246, 0.20); text-decoration-color: #0072b2; }
[data-theme="light"] .wpp-mark--passive  { background: rgba(0, 158, 115, 0.20); text-decoration-color: #00805c; }
[data-theme="light"] .wpp-mark--complex  { background: rgba(147, 51, 234, 0.17); text-decoration-color: #7e22ce; }
[data-theme="light"] .wpp-mark--cliche   { background: rgba(230, 159, 0, 0.28); text-decoration-color: #b45309; }
[data-theme="light"] .wpp-mark--hedge    { text-decoration-color: #64748b; }
[data-theme="light"] .wpp-mark--repeat   { text-decoration-color: #be185d; }
[data-theme="light"] .wpp-mark--style    { text-decoration-color: #0f766e; }
[data-theme="light"] .wpp-mark--grammar  { background: rgba(37, 99, 235, 0.07); text-decoration-color: #1d4ed8; }
[data-theme="light"] .wpp-mark--spelling { background: rgba(220, 38, 38, 0.07); text-decoration-color: #dc2626; }
[data-theme="light"] .wpp-mark.is-active { background: rgba(99, 102, 241, 0.30); }

/* Category dot (popover header, lists) */
.wpp-dot { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; background: #94a3b8; }
.wpp-dot--hard { background: #f0e442; }
.wpp-dot--veryHard { background: #ef4444; }
.wpp-dot--adverb { background: #56b4e9; }
.wpp-dot--passive { background: #10b981; }
.wpp-dot--complex { background: #a855f7; }
.wpp-dot--cliche { background: #e69f00; }
.wpp-dot--hedge { background: #94a3b8; }
.wpp-dot--repeat { background: #e879b9; }
.wpp-dot--longParagraph { background: #64748b; }
.wpp-dot--spelling { background: #f87171; }
.wpp-dot--grammar { background: #60a5fa; }
.wpp-dot--style { background: #2dd4bf; }
[data-theme="light"] .wpp-dot--hard { background: #eab308; }
[data-theme="light"] .wpp-dot--spelling { background: #dc2626; }
[data-theme="light"] .wpp-dot--grammar { background: #1d4ed8; }
[data-theme="light"] .wpp-dot--style { background: #0f766e; }
[data-theme="light"] .wpp-dot--repeat { background: #be185d; }

/* Legend / category toggle chip: <label class="wpp-chip"><input type=checkbox><span class="wpp-swatch wpp-mark--adverb"></span>Adverbs <b>3</b></label> */
.wpp-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--border-strong, rgba(255,255,255,0.15)); border-radius: 999px; font-size: 13px; color: var(--text, #f1f5f9); background: var(--bg2, #1e293b); cursor: pointer; user-select: none; }
.wpp-chip input { margin: 0; accent-color: var(--primary, #6366f1); }
.wpp-chip b { font-variant-numeric: tabular-nums; color: var(--text2, #94a3b8); font-weight: 600; }
.wpp-swatch { display: inline-block; width: 18px; height: 12px; border-radius: 3px; line-height: 12px; text-align: center; font-size: 10px; overflow: hidden; }
.wpp-swatch::before { content: "ab"; color: transparent; }

/* ── Popover ────────────────────────────────────────────────────── */
.wpp-pop {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10000;
    box-sizing: border-box;
    width: max-content;
    min-width: 200px;
    max-width: min(360px, calc(100vw - 16px));
    padding: 12px 14px;
    background: var(--bg2, #1e293b);
    color: var(--text, #f1f5f9);
    border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.15));
    border-radius: var(--radius-sm, 8px);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
    font-family: var(--font, system-ui, -apple-system, 'Segoe UI', sans-serif);
    font-size: 14px;
    line-height: 1.5;
    text-align: left;
    overflow-wrap: anywhere;
}
[data-theme="light"] .wpp-pop { box-shadow: 0 14px 34px rgba(15, 23, 42, 0.18); }
.wpp-pop:focus { outline: none; }
.wpp-pop--animate { animation: wpp-pop-in 0.12s ease-out; }
@keyframes wpp-pop-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.wpp-pop--animate.is-above { animation-name: wpp-pop-in-above; }
@keyframes wpp-pop-in-above { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.wpp-pop__head { display: flex; align-items: center; gap: 8px; margin: -2px 0 4px; }
.wpp-pop__title { font-size: 13px; font-weight: 700; letter-spacing: 0.01em; }
.wpp-pop__src { font-size: 11px; line-height: 18px; padding: 0 7px; border-radius: 999px; border: 1px solid var(--border-strong, rgba(255,255,255,0.15)); color: var(--text2, #94a3b8); white-space: nowrap; }
.wpp-pop__close {
    margin-left: auto; min-width: 28px; min-height: 28px; padding: 0 6px;
    background: none; border: 0; border-radius: 6px; cursor: pointer;
    color: var(--text2, #94a3b8); font-size: 20px; line-height: 1;
}
.wpp-pop__close:hover { background: var(--bg3, #334155); color: var(--text, #f1f5f9); }
.wpp-pop__msg { margin: 0 0 10px; font-size: 14px; color: var(--text, #f1f5f9); }
.wpp-pop__suggs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.wpp-pop__sugg {
    padding: 5px 11px; border: 0; border-radius: 6px; cursor: pointer;
    background: #4f46e5; color: #fff; font: inherit; font-size: 14px; font-weight: 600;
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wpp-pop__sugg:hover { background: #4338ca; }
.wpp-pop__sugg.is-remove { background: #b91c1c; }
.wpp-pop__sugg.is-remove:hover { background: #991b1b; }
.wpp-pop__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border, rgba(255,255,255,0.08)); }
.wpp-pop__btn {
    padding: 4px 10px; border-radius: 6px; cursor: pointer;
    background: transparent; color: var(--text2, #94a3b8);
    border: 1px solid var(--border-strong, rgba(255,255,255,0.15));
    font: inherit; font-size: 13px;
}
.wpp-pop__btn:hover { color: var(--text, #f1f5f9); background: var(--bg3, #334155); }
.wpp-pop button:focus-visible { outline: 2px solid var(--accent, #22d3ee); outline-offset: 2px; }
[data-theme="light"] .wpp-pop button:focus-visible { outline-color: #0e7490; }

/* ── Issue list (side panels, Grammar Checker) ──────────────────── */
.wpp-issues { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.wpp-issue {
    display: grid; gap: 6px; padding: 10px 12px;
    background: var(--bg1, #0f172a);
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    border-left: 4px solid #94a3b8;
    border-radius: var(--radius-sm, 8px);
}
.wpp-issue--spelling { border-left-color: #f87171; }
.wpp-issue--grammar { border-left-color: #60a5fa; }
.wpp-issue--style { border-left-color: #2dd4bf; }
[data-theme="light"] .wpp-issue { background: var(--bg2, #fff); }
[data-theme="light"] .wpp-issue--spelling { border-left-color: #dc2626; }
[data-theme="light"] .wpp-issue--grammar { border-left-color: #1d4ed8; }
[data-theme="light"] .wpp-issue--style { border-left-color: #0f766e; }
.wpp-issue__head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 12px; color: var(--text2, #94a3b8); }
.wpp-issue__cat { font-weight: 700; color: var(--text, #f1f5f9); text-transform: uppercase; letter-spacing: 0.04em; font-size: 11px; }
.wpp-issue__msg { margin: 0; font-size: 14px; color: var(--text, #f1f5f9); }
.wpp-issue__ctx { margin: 0; font-size: 13px; color: var(--text2, #94a3b8); line-height: 1.6; overflow-wrap: anywhere; }
.wpp-issue__ctx mark { color: var(--text, #f1f5f9); font-weight: 600; }
.wpp-issue__actions { display: flex; flex-wrap: wrap; gap: 6px; }
.wpp-issue__actions button {
    padding: 4px 10px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 13px;
    background: transparent; color: var(--text2, #94a3b8); border: 1px solid var(--border-strong, rgba(255,255,255,0.15));
}
.wpp-issue__actions button:hover { color: var(--text, #f1f5f9); background: var(--bg3, #334155); }
.wpp-issue__actions .wpp-apply { background: #4f46e5; border-color: #4f46e5; color: #fff; font-weight: 600; }
.wpp-issue__actions .wpp-apply:hover { background: #4338ca; color: #fff; }
.wpp-issue__actions .wpp-apply.is-remove { background: #b91c1c; border-color: #b91c1c; }
.wpp-issue__actions button:focus-visible { outline: 2px solid var(--accent, #22d3ee); outline-offset: 2px; }
[data-theme="light"] .wpp-issue__actions button:focus-visible { outline-color: #0e7490; }

/* Engine badges */
.wpp-badge { display: inline-block; padding: 0 7px; border-radius: 999px; font-size: 11px; line-height: 18px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.wpp-badge--harper { background: rgba(99, 102, 241, 0.16); color: #a5b4fc; border-color: rgba(129, 140, 248, 0.35); }
.wpp-badge--rules { background: rgba(148, 163, 184, 0.14); color: #cbd5e1; border-color: rgba(148, 163, 184, 0.3); }
.wpp-badge--both { background: rgba(16, 185, 129, 0.14); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.3); }
[data-theme="light"] .wpp-badge--harper { color: #4338ca; background: rgba(99, 102, 241, 0.10); }
[data-theme="light"] .wpp-badge--rules { color: #334155; background: rgba(100, 116, 139, 0.10); }
[data-theme="light"] .wpp-badge--both { color: #047857; background: rgba(16, 185, 129, 0.10); }

/* Engine status line ("Loading the grammar engine…") */
.wpp-engine-note { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text2, #94a3b8); min-height: 20px; }
.wpp-engine-note.is-error { color: var(--danger, #ef4444); }
.wpp-progress { flex: 0 0 120px; height: 6px; border-radius: 999px; background: var(--bg3, #334155); overflow: hidden; }
.wpp-progress > span { display: block; height: 100%; width: 0; background: var(--primary, #6366f1); transition: width 0.2s linear; }

@media (prefers-reduced-motion: reduce) {
    .wpp-pop--animate, .wpp-pop--animate.is-above { animation: none; }
    .wpp-progress > span { transition: none; }
}

@media print {
    .wpp-pop { display: none !important; }
}
