/* KuroCat Typecho plugin — all styles are scoped to #kurocat-root / .kurocat-restore */

#kurocat-root {
    --kurocat-scale: 1;
    position: fixed;
    bottom: 0;
    z-index: 9998;
    width: calc(360px * var(--kurocat-scale));
    height: calc(320px * var(--kurocat-scale));
    pointer-events: none;
    visibility: hidden;
    user-select: none;
    -webkit-user-select: none;
    box-sizing: border-box;
}

#kurocat-root.kurocat-left {
    left: 0;
    right: auto;
}

#kurocat-root.kurocat-right {
    right: 0;
    left: auto;
}

#kurocat-root.kurocat-ready {
    visibility: visible;
}

#kurocat-root.kurocat-manual-hidden,
#kurocat-root.kurocat-mobile-hidden {
    display: none !important;
}

#kurocat-root canvas {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
    touch-action: none;
    outline: none;
}

#kurocat-root.kurocat-interactive canvas {
    pointer-events: auto;
    cursor: default;
}

#kurocat-root.kurocat-dragging canvas {
    cursor: grabbing;
}

#kurocat-keys {
    position: absolute;
    right: 8px;
    bottom: 8px;
    z-index: 2;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(18, 18, 22, 0.62);
    color: #f7f1e6;
    font: 600 11px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    letter-spacing: 0.04em;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
    white-space: nowrap;
}

#kurocat-keys.kurocat-keys-off {
    display: none;
}

#kurocat-root .kurocat-actions {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 3;
    display: flex;
    gap: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

#kurocat-root.kurocat-hover .kurocat-actions,
#kurocat-root .kurocat-actions:focus-within {
    opacity: 1;
}

#kurocat-root .kurocat-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 50%;
    background: rgba(18, 18, 22, 0.62);
    color: #f7f1e6;
    font: 600 14px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    cursor: pointer;
    pointer-events: none;
    transition: transform 0.15s ease, background 0.15s ease;
}

#kurocat-root .kurocat-action-btn svg {
    display: block;
}

#kurocat-root.kurocat-hover .kurocat-action-btn,
#kurocat-root .kurocat-actions:focus-within .kurocat-action-btn,
#kurocat-root .kurocat-action-btn:focus-visible {
    pointer-events: auto;
}

#kurocat-root .kurocat-action-btn:hover {
    transform: scale(1.08);
    background: rgba(18, 18, 22, 0.82);
}

/* Touch devices have no hover: keep both action buttons reachable. */
@media (hover: none) {
    #kurocat-root .kurocat-actions {
        opacity: 1;
    }

    #kurocat-root .kurocat-action-btn {
        pointer-events: auto;
    }
}

#kurocat-dialog {
    position: absolute;
    bottom: calc(100% - 10px);
    left: 12px;
    right: auto;
    z-index: 4;
    box-sizing: border-box;
    max-width: min(320px, calc(100vw - 24px));
    padding: 8px 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.96);
    color: #2b2622;
    font: 13px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    pointer-events: none;
    word-break: break-word;
    white-space: pre-wrap;
}

#kurocat-root.kurocat-right #kurocat-dialog {
    left: auto;
    right: 12px;
}

#kurocat-dialog.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#kurocat-dialog::after {
    content: "";
    position: absolute;
    left: 24px;
    bottom: -6px;
    width: 12px;
    height: 12px;
    background: inherit;
    border-right: 1px solid rgba(0, 0, 0, 0.06);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    transform: rotate(45deg);
}

#kurocat-root.kurocat-right #kurocat-dialog::after {
    left: auto;
    right: 24px;
}

.kurocat-restore {
    position: fixed;
    bottom: 12px;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    background: rgba(18, 18, 22, 0.72);
    color: #f7f1e6;
    font: 600 16px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.kurocat-restore.kurocat-left {
    left: 12px;
    right: auto;
}

.kurocat-restore.kurocat-right {
    right: 12px;
    left: auto;
}

.kurocat-restore.kurocat-visible {
    display: flex;
}

.kurocat-restore:hover {
    background: rgba(18, 18, 22, 0.88);
}

.kurocat-restore:focus-visible,
#kurocat-root .kurocat-action-btn:focus-visible {
    outline: 2px solid #f0a35e;
    outline-offset: 2px;
}
