/* annotations.css — User highlight marks and annotation tooltip */

/* ============================================================
   HIGHLIGHT MARKS
   ============================================================ */

mark.user-annotation {
    /* Reset browser UA mark color (can be blue on dark system themes) */
    background-color: transparent;
    color: inherit;
    border-radius: 3px;
    padding: 0.18em 0.28em;
    cursor: pointer;
    transition: filter 0.1s ease;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

/* Double class = specificity (0,2,1), beats UA mark rule and the base reset above */
mark.user-annotation.user-annotation--amber { background-color: rgba(245, 158,  11, 0.32); }
mark.user-annotation.user-annotation--sage  { background-color: rgba(107, 158, 120, 0.34); }
mark.user-annotation.user-annotation--steel { background-color: rgba(112, 150, 184, 0.34); }
mark.user-annotation.user-annotation--rose  { background-color: rgba(200, 116, 116, 0.34); }

mark.user-annotation:hover { filter: brightness(0.80); }

/* Dark mode — slightly more opaque so highlights stay visible */
[data-theme="dark"] mark.user-annotation.user-annotation--amber { background-color: rgba(245, 158,  11, 0.40); }
[data-theme="dark"] mark.user-annotation.user-annotation--sage  { background-color: rgba(107, 158, 120, 0.42); }
[data-theme="dark"] mark.user-annotation.user-annotation--steel { background-color: rgba(112, 150, 184, 0.42); }
[data-theme="dark"] mark.user-annotation.user-annotation--rose  { background-color: rgba(200, 116, 116, 0.42); }

/* Cappuccino — dark warm bg, so highlights need dark-mode-level opacity */
[data-theme="cappuccino"] mark.user-annotation.user-annotation--amber { background-color: rgba(245, 180,  70, 0.42); }
[data-theme="cappuccino"] mark.user-annotation.user-annotation--sage  { background-color: rgba(130, 175, 140, 0.42); }
[data-theme="cappuccino"] mark.user-annotation.user-annotation--steel { background-color: rgba(140, 170, 200, 0.42); }
[data-theme="cappuccino"] mark.user-annotation.user-annotation--rose  { background-color: rgba(220, 140, 140, 0.42); }

/* System dark mode fallback (for prefers-color-scheme without explicit data-theme) */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) mark.user-annotation.user-annotation--amber { background-color: rgba(245, 158,  11, 0.40); }
    :root:not([data-theme]) mark.user-annotation.user-annotation--sage  { background-color: rgba(107, 158, 120, 0.42); }
    :root:not([data-theme]) mark.user-annotation.user-annotation--steel { background-color: rgba(112, 150, 184, 0.42); }
    :root:not([data-theme]) mark.user-annotation.user-annotation--rose  { background-color: rgba(200, 116, 116, 0.42); }
}

/* ============================================================
   ANNOTATION TOOLTIP
   Appears on hover over a mark. Inverted colours like the
   selection popup (--text bg, --bg text).
   ============================================================ */

.ann-tooltip {
    position: absolute;
    z-index: 750;
    min-width: 8rem;
    max-width: 15rem;
    background: var(--text);
    color: var(--bg);
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
    padding: 0.45rem 0.6rem;
    font-family: var(--font-sans);
    font-size: 0.73rem;
    line-height: 1.45;

    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease, visibility 0.12s ease;
    pointer-events: none;
}

.ann-tooltip.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.ann-tooltip-note {
    margin-bottom: 0.35rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.ann-tooltip-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.ann-tooltip-date {
    opacity: 0.55;
    font-size: 0.68rem;
}

.ann-tooltip-delete {
    background: none;
    border: none;
    color: var(--bg);
    opacity: 0.65;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 0.7rem;
    padding: 0;
    line-height: 1;
    transition: opacity 0.1s ease;
}

.ann-tooltip-delete:hover { opacity: 1; }

/* ============================================================
   ANNOTATE PICKER
   Appears above the selection when "Annotate" is clicked.
   Inverted colors (dark bg, light text) — same as the tooltip.
   ============================================================ */

.ann-picker {
    position: absolute;
    z-index: 760;
    background: var(--text);
    color: var(--bg);
    border-radius: 5px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.28);
    padding: 0.55rem 0.6rem;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    width: 13rem;

    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease, visibility 0.12s ease;
    pointer-events: none;
}

.ann-picker.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.ann-picker-swatches {
    display: flex;
    gap: 0.45rem;
    margin-bottom: 0.5rem;
    align-items: center;
}

.ann-picker-swatch {
    width: 1.05rem;
    height: 1.05rem;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    outline: none;
    transition: transform 0.1s ease, border-color 0.1s ease;
}

.ann-picker-swatch--amber { background: rgba(245, 158,  11, 0.9); }
.ann-picker-swatch--sage  { background: rgba(107, 158, 120, 0.9); }
.ann-picker-swatch--steel { background: rgba(112, 150, 184, 0.9); }
.ann-picker-swatch--rose  { background: rgba(200, 116, 116, 0.9); }

.ann-picker-swatch.is-selected,
.ann-picker-swatch:focus-visible {
    border-color: var(--bg);
    transform: scale(1.2);
}

.ann-picker-note {
    display: block;
    width: 100%;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    color: inherit;
    font-family: var(--font-sans);
    font-size: 0.72rem;
    padding: 0.28rem 0.4rem;
    margin-bottom: 0.45rem;
    outline: none;
}

.ann-picker-note::placeholder { opacity: 0.5; }

.ann-picker-note:focus {
    border-color: rgba(255, 255, 255, 0.45);
}

.ann-picker-actions {
    display: flex;
    justify-content: flex-end;
}

.ann-picker-submit {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    color: inherit;
    font-family: var(--font-sans);
    font-size: 0.72rem;
    padding: 0.22rem 0.55rem;
    cursor: pointer;
    line-height: 1.4;
    transition: background 0.1s ease;
}

.ann-picker-submit:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* ============================================================
   REDUCE MOTION
   ============================================================ */

[data-reduce-motion] mark.user-annotation { transition: none; }
[data-reduce-motion] .ann-tooltip         { transition: none; }
[data-reduce-motion] .ann-picker          { transition: none; }
