/**
 * Annotations plugin — stylesheet.
 *
 * Colour tokens use DokuWiki's __xxx__ replacement syntax so the theme
 * controls the palette.  Hard-coded colours are limited to the annotation-
 * specific highlights (amber / green) which are intentionally opinionated.
 *
 * FF78 ESR safe: no :has(), :not() with selectors, aspect-ratio, container
 * queries, or CSS nesting.
 */

/* =========================================================================
   Highlight spans
   ========================================================================= */

.ann-highlight-open {
    background-color: rgba(251, 191, 36, 0.35);   /* amber-300 @ 35% */
    border-bottom: 2px solid rgba(245, 158, 11, 0.7);
    border-radius: 2px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.ann-highlight-open:hover {
    background-color: rgba(251, 191, 36, 0.55);
}

.ann-highlight-resolved {
    background-color: rgba(134, 239, 172, 0.30);  /* green-300 @ 30% */
    border-bottom: 2px solid rgba(74, 222, 128, 0.6);
    border-radius: 2px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.ann-highlight-resolved:hover {
    background-color: rgba(134, 239, 172, 0.50);
}

/* =========================================================================
   Counter bar
   ========================================================================= */

#ann-counter-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5em;
    padding: 0.4em 0.75em;
    margin-bottom: 0.75em;
    background: __background_alt__;
    border: 1px solid __border__;
    border-radius: 4px;
    color: __text__;
}

.ann-orphan-link {
    color: __link__;
    text-decoration: underline;
    cursor: pointer;
}

/* =========================================================================
   Gutter markers
   ========================================================================= */

/* Markers are appended to document.body as position:absolute elements so
   that no template overflow:hidden can clip them. Top/left are set inline
   via JS using getBoundingClientRect() + scroll offsets. All markers share
   the same X position (left edge of the .page column) so they form a tidy
   vertical column in the document margin. */
.ann-gutter-marker {
    position: absolute;
    padding: 0;
    border: none;
    background: none;
    color: rgba(245, 158, 11, 0.8); /* amber — open */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: color 0.15s ease, transform 0.12s ease;
}

/* Suppress any UA button background on all interactive states. */
.ann-gutter-marker:hover,
.ann-gutter-marker:focus,
.ann-gutter-marker:active {
    background: none;
    outline: none;
    box-shadow: none;
}

.ann-gutter-marker:hover {
    color: rgba(245, 158, 11, 1);
}

.ann-gutter-marker[data-status="resolved"] {
    color: rgba(74, 222, 128, 0.8); /* green — resolved */
}

.ann-gutter-marker[data-status="resolved"]:hover {
    color: rgba(74, 222, 128, 1);
}

/* =========================================================================
   Annotation panel
   ========================================================================= */

.ann-panel {
    margin: 0.75em 0 1em;
    border: 1px solid __border__;
    border-left: 3px solid rgba(245, 158, 11, 0.7);
    background: __background_alt__;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    contain: layout;
}

/* =========================================================================
   Thread entries (annotation + replies)
   ========================================================================= */

.ann-thread-entry {
    padding: 0.65em 0.85em;
    border-bottom: 1px solid __border__;
}

.ann-thread-entry:last-of-type {
    border-bottom: none;
}

/* Root annotation entry: lighter background so it stands out from the panel. */
.ann-thread-entry.ann-annotation {
    background: __background__;
}

/* Reply entries: inset card with the same lighter background. */
.ann-reply {
    margin-left: 1.5em;
    background: __background__;
    border-left: 2px solid __border__;
}

/* =========================================================================
   Meta row (avatar, author, time, status, close button)
   ========================================================================= */

.ann-meta {
    display: flex;
    align-items: center;
    gap: 0.4em;
    margin-bottom: 0.35em;
    flex-wrap: wrap;
}

.ann-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.8em;
    height: 1.8em;
    border-radius: 50%;
    background: __link__;
    color: #fff;
    font-size: 0.75em;
    font-weight: 700;
    flex-shrink: 0;
}

.ann-author {
    font-weight: 600;
    color: __text__;
}

.ann-time {
    color: __text_alt__;
    font-size: 0.85em;
}

.ann-status {
    display: inline-block;
    padding: 0.1em 0.45em;
    border-radius: 10em;
    font-size: 0.78em;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.ann-status-open {
    background: rgba(251, 191, 36, 0.25);
    color: #92400e;
    border: 1px solid rgba(245, 158, 11, 0.5);
}

.ann-status-resolved {
    background: rgba(134, 239, 172, 0.25);
    color: #166534;
    border: 1px solid rgba(74, 222, 128, 0.4);
}

/* =========================================================================
   Body text and quoted selection
   ========================================================================= */

.ann-body {
    white-space: pre-wrap;
    word-break: break-word;
    color: __text__;
    margin-bottom: 0.4em;
}

.ann-quote {
    margin-bottom: 0.65em;
    padding: 0.25em 0.6em;
    border-left: 3px solid rgba(245, 158, 11, 0.6);
    color: __text__;
    font-style: italic;
    font-size: 0.9em;
    background: rgba(251, 191, 36, 0.08);
    border-radius: 0 2px 2px 0;
}

/* =========================================================================
   Action buttons row
   ========================================================================= */

.ann-actions {
    display: flex;
    gap: 0.5em;
    flex-wrap: wrap;
    margin-top: 0.65em;
}

.ann-btn {
    display: inline-block;
    padding: 0.2em 0.55em;
    font-size: 0.85em;
    border: 1px solid __border__;
    border-radius: 3px;
    background: __background__ !important;
    color: __text__;
    cursor: pointer;
    line-height: 1.4;
    transition: background-color 0.12s ease;
}

.ann-btn:hover {
    background: __background_alt__ !important;
}

.ann-btn-primary {
    background: __link__ !important;
    border-color: __link__;
    color: #fff;
}

.ann-btn-primary:hover {
    background: __link__ !important;
    color: #fff;
    opacity: 0.88;
}

/* Disabled state: prevent UA-stylesheet background overrides and ensure
   primary buttons keep their link colour. */
.ann-btn:disabled,
.ann-btn[disabled] {
    background: __background__;
    opacity: 0.55;
    cursor: not-allowed;
}

.ann-btn:disabled:hover,
.ann-btn[disabled]:hover {
    background: __background__;
}

.ann-btn-primary:disabled,
.ann-btn-primary[disabled] {
    background: __link__;
    color: #fff;
}

.ann-btn-primary:disabled:hover,
.ann-btn-primary[disabled]:hover {
    background: __link__;
    opacity: 0.55;
}

/* Spinner shown while an AJAX request is in flight (set by setBusy()).
   The translate(-50%,-50%) is baked into every keyframe so it stays perfectly
   centred regardless of sub-pixel rounding and never jigles. */
@keyframes ann-spin {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to   { transform: translate(-50%, -50%) rotate(360deg); }
}

.ann-btn-busy {
    position: relative;
    color: transparent;
}

.ann-btn-busy::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0.75em;
    height: 0.75em;
    border: 2px solid rgba(0, 0, 0, 0.25);
    border-top-color: rgba(0, 0, 0, 0.75);
    border-radius: 50%;
    animation: ann-spin 0.6s linear infinite;
}

.ann-btn-primary.ann-btn-busy::after {
    border-color: rgba(255, 255, 255, 0.35);
    border-top-color: rgba(255, 255, 255, 0.9);
}

.ann-btn-danger {
    border-color: #dc2626;
    color: #dc2626;
}

.ann-btn-danger:hover {
    background: rgba(220, 38, 38, 0.08);
}

.ann-btn-admin {
    border-color: __border__;
    color: __text__;
}

/* Close button — lives inside .ann-meta, pushed right via margin-left:auto (set in JS). */
.ann-close {
    font-size: 1.35em;
    line-height: 1;
    padding: 0.05em 0.3em;
    border: none;
    background: none !important;
    color: __text_alt__;
    cursor: pointer;
    flex-shrink: 0;
}

.ann-close:hover {
    color: __text__;
    background: none !important;
}

/* =========================================================================
   Reply form + new-annotation form
   ========================================================================= */

.ann-reply-form,
.ann-new-form {
    padding: 0.65em 0.85em;
}

.ann-new-form {
    margin: 0.75em 0 1em;
    border: 1px solid __border__;
    border-left: 3px solid rgba(245, 158, 11, 0.7);
    background: __background_alt__;
    contain: layout;
}

.ann-body-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 0.4em 0.6em;
    font: inherit;
    border: 1px solid __border__;
    background: __background__;
    color: __text__;
    resize: vertical;
    margin-bottom: 0.65em;
}

.ann-body-input:focus {
    outline: 1px solid __link__;
}

.ann-form-row {
    display: flex;
    gap: 0.4em;
}

.ann-form-row + .ann-quote {
    margin-top: 0.65em;
}

/* =========================================================================
   Selection tooltip
   ========================================================================= */

.ann-tooltip {
    position: absolute;
    z-index: 9000;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* =========================================================================
   Orphan drawer
   ========================================================================= */

.ann-orphan-drawer {
    display: flow-root; /* BFC: shrinks to avoid overlapping the floated TOC */
    margin-bottom: 0.65em;
    padding: 0.75em 1em;
    border: 1px dashed __border__;
    border-radius: 4px;
    background: __background_alt__;
}

.ann-orphan-drawer h4 {
    margin: 0 0 0.3em;
    font-size: 0.95em;
    color: __text__;
}

.ann-orphan-note {
    font-size: 0.85em;
    color: __text__;
    margin-bottom: 0.75em;
}

/* =========================================================================
   Resolved annotation panels: shift to green accent
   ========================================================================= */

.ann-panel[data-status="resolved"] {
    border-left-color: rgba(74, 222, 128, 0.6);
}
