/**
 * 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.
 *
 * The two highlight hues are driven by CSS custom properties that action.php
 * injects from the color_open / color_resolved config (as "r,g,b" triplets);
 * every fill/border/marker/pill tint below is that hue at a different opacity.
 * The :root fallbacks here keep the built-in amber/green palette when the
 * injected <style> is absent (e.g. annotations off, or a stripped template).
 *
 * NOTE: every rgba() that contains var() is LESS-escaped as ~"rgba(var(…), a)".
 * DokuWiki compiles plugin CSS through lesserphp, which otherwise evaluates
 * rgba() at compile time, reads var() as 0, and bakes the colour to #000000.
 * The escape makes lesserphp emit the declaration verbatim so the browser
 * resolves the custom property at render time. Keep new var()-based colours
 * escaped the same way.
 */

:root {
    --ann-open-rgb: 245, 158, 11;     /* amber — open / unresolved (config default) */
    --ann-resolved-rgb: 74, 222, 128; /* green — resolved (config default) */
}

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

.ann-highlight-open {
    background-color: ~"rgba(var(--ann-open-rgb), 0.35)";   /* amber-300 @ 35% */
    border-bottom: 2px solid ~"rgba(var(--ann-open-rgb), 0.7)";
    border-radius: 2px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.ann-highlight-open:hover {
    background-color: ~"rgba(var(--ann-open-rgb), 0.55)";
}

.ann-highlight-resolved {
    background-color: ~"rgba(var(--ann-resolved-rgb), 0.30)";  /* green-300 @ 30% */
    border-bottom: 2px solid ~"rgba(var(--ann-resolved-rgb), 0.6)";
    border-radius: 2px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.ann-highlight-resolved:hover {
    background-color: ~"rgba(var(--ann-resolved-rgb), 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(var(--ann-open-rgb), 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(var(--ann-open-rgb), 1)";
}

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

.ann-gutter-marker[data-status="resolved"]:hover {
    color: ~"rgba(var(--ann-resolved-rgb), 1)";
}

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

.ann-panel {
    margin: 0.75em 0 1em;
    border: 1px solid __border__;
    border-left: 3px solid ~"rgba(var(--ann-open-rgb), 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(var(--ann-open-rgb), 0.25)";
    color: #92400e;
    border: 1px solid ~"rgba(var(--ann-open-rgb), 0.5)";
}

.ann-status-resolved {
    background: ~"rgba(var(--ann-resolved-rgb), 0.25)";
    color: #166534;
    border: 1px solid ~"rgba(var(--ann-resolved-rgb), 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(var(--ann-open-rgb), 0.6)";
    color: __text__;
    font-size: 0.9em;
    background: ~"rgba(var(--ann-open-rgb), 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(var(--ann-open-rgb), 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);
}

/* Static amber glow drawing the eye to the freshly-revealed "Annotate" button.
   The rgba() is LESS-escaped (~"…") so DokuWiki's CSS compiler passes it through
   verbatim instead of evaluating var() to black; the browser resolves the
   custom property at render time. FF78 ESR safe. */
.ann-tooltip .ann-btn {
    box-shadow: 0 0 8px 2px ~"rgba(var(--ann-open-rgb), 0.45)", 0 1px 4px rgba(0,0,0,0.25);
}

/* =========================================================================
   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;
}

/* Each orphaned annotation renders as a full thread (root + replies). Wrap it
   like an inline panel so multiple orphaned threads stay visually separated. */
.ann-orphan-thread {
    margin-bottom: 0.75em;
    border: 1px solid __border__;
    border-left: 3px solid ~"rgba(var(--ann-open-rgb), 0.7)";
    background: __background_alt__;
    contain: layout;
}

.ann-orphan-thread:last-child {
    margin-bottom: 0;
}

.ann-orphan-thread[data-status="resolved"] {
    border-left-color: ~"rgba(var(--ann-resolved-rgb), 0.6)";
}

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

.ann-panel[data-status="resolved"] {
    border-left-color: ~"rgba(var(--ann-resolved-rgb), 0.6)";
}

/* =========================================================================
   Admin overview (annotated-pages table) — mirrors the lastseen panel
   ========================================================================= */

.plugin_annotations_admin .annotations_admin_bar {
    margin: 0.6em 0;
}

.plugin_annotations_admin .annotations_admin_id {
    color: __text_alt__;
    font-size: 90%;
}

.plugin_annotations_admin td.annotations_admin_num,
.plugin_annotations_admin td.annotations_admin_actions,
.plugin_annotations_admin .annotations_admin_filteractions,
.plugin_annotations_admin th {
    text-align: center;
    white-space: nowrap;
}

.plugin_annotations_admin th,
.plugin_annotations_admin td {
    vertical-align: middle;
}

/* per-column filter row */
.plugin_annotations_admin .annotations_admin_filterrow td {
    padding-top: 0.3em;
    padding-bottom: 0.3em;
}

.plugin_annotations_admin .annotations_admin_filterrow input.edit {
    width: 100%;
    box-sizing: border-box;
}

.annotations_admin_clear {
    margin-left: 0.5em;
    font-size: 90%;
}

.annotations_admin_none {
    text-align: center;
    color: __text_alt__;
    font-style: italic;
}

.annotations_admin_count {
    color: __text_alt__;
    font-size: 90%;
}

/* the POST forms targeted via the form= attribute carry only hidden inputs */
.plugin_annotations_admin .annotations_admin_post {
    display: none;
}

/* numbered pager */
.annotations_admin_pager {
    margin: 0.6em 0;
}

.annotations_admin_pager .pager_btn,
.annotations_admin_pager .pager_cur,
.annotations_admin_pager .pager_gap,
.annotations_admin_pager .pager_disabled {
    display: inline-block;
    min-width: 1.6em;
    padding: 0.15em 0.45em;
    margin: 0 0.1em;
    text-align: center;
}

.annotations_admin_pager .pager_btn,
.annotations_admin_pager .pager_cur,
.annotations_admin_pager .pager_disabled {
    border: 1px solid __border__;
}

.annotations_admin_pager .pager_btn {
    text-decoration: none;
}

.annotations_admin_pager .pager_cur {
    background-color: __background_alt__;
    font-weight: bold;
}

.annotations_admin_pager .pager_disabled {
    color: __text_alt__;
}

.annotations_admin_pager .pager_gap {
    border: 0;
}
