/**
 * Tag Cloud Pro knowledge graph front-end styles.
 *
 * AI Dev Prompt:
 * Keep this UI quiet and canvas-first. Toolbar controls should feel native,
 * while Cytoscape node rendering remains in tag-cloud-pro-graph.js.
 */

.tcp-graph {
    --tcp-graph-text: #172033;
    --tcp-graph-muted: #667085;
    --tcp-graph-line: rgba(98, 112, 133, 0.16);
    --tcp-graph-surface: rgba(255, 255, 255, 0.86);
    --tcp-graph-surface-strong: rgba(255, 255, 255, 0.96);
    --tcp-graph-stage-bg: #fbfcfd;
    --tcp-graph-accent: #cc0000;
    --tcp-graph-accent-soft: rgba(204, 0, 0, 0.1);
    --tcp-graph-accent-line: rgba(204, 0, 0, 0.42);
    --tcp-graph-shadow: 0 18px 48px rgba(15, 23, 42, 0.09);
    display: grid;
    gap: 12px;
    width: 100%;
    color: var(--tcp-graph-text);
    opacity: 0;
    transform: translateY(6px);
    animation: tcpGraphShellIn 360ms ease forwards;
}

.tcp-graph-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--tcp-graph-line);
    border-radius: 8px;
    background: var(--tcp-graph-surface);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
    backdrop-filter: blur(10px);
}

.tcp-graph-search {
    position: relative;
    display: block;
    flex: 1 1 320px;
    min-width: min(100%, 280px);
}

.tcp-graph-search span {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.tcp-graph-search-input {
    width: 100%;
    min-height: 40px;
    margin: 0;
    padding: 8px 12px;
    border: 1px solid var(--tcp-graph-line);
    border-radius: 6px;
    background: var(--tcp-graph-surface-strong);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
    color: var(--tcp-graph-text);
    font: inherit;
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.tcp-graph-search-input:focus {
    border-color: var(--tcp-graph-accent-line);
    box-shadow: 0 0 0 3px var(--tcp-graph-accent-soft);
}

.tcp-graph-actions {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 6px;
}

.tcp-graph-button {
    min-height: 36px;
    margin: 0;
    padding: 0 11px;
    border: 1px solid var(--tcp-graph-line);
    border-radius: 6px;
    background: var(--tcp-graph-surface-strong);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    color: var(--tcp-graph-text);
    cursor: pointer;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 650;
    line-height: 1;
    text-decoration: none;
    transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, color 160ms ease, transform 160ms ease;
}

.tcp-graph-button-icon {
    display: inline-grid;
    width: 38px;
    min-width: 38px;
    padding: 0;
    place-items: center;
    font-size: 1.18rem;
    line-height: 1;
}

.tcp-graph-button:hover,
.tcp-graph-button:focus {
    border-color: var(--tcp-graph-accent-line);
    background: #ffffff;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
    color: var(--tcp-graph-accent);
    transform: translateY(-1px);
}

.tcp-graph-button:focus-visible {
    outline: 2px solid var(--tcp-graph-accent-line);
    outline-offset: 2px;
}

.tcp-graph-stage {
    position: relative;
    width: 100%;
    min-height: 320px;
    border: 1px solid var(--tcp-graph-line);
    border-radius: 8px;
    background-color: var(--tcp-graph-stage-bg);
    background:
        radial-gradient(circle at 12% 8%, rgba(204, 0, 0, 0.055), transparent 30%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), var(--tcp-graph-stage-bg));
    box-shadow: var(--tcp-graph-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.72);
    overflow: hidden;
    opacity: 0.72;
    transform: translateY(8px) scale(0.992);
    transition: opacity 620ms ease, transform 620ms ease, filter 620ms ease;
    filter: saturate(0.92);
    cursor: grab;
    overscroll-behavior: contain;
    touch-action: none;
    isolation: isolate;
}

.tcp-graph.is-grabbing-node .tcp-graph-stage,
.tcp-graph.is-panning-graph .tcp-graph-stage {
    cursor: grabbing;
}

.tcp-graph-stage::before {
    position: absolute;
    inset: 0;
    z-index: 0;
    background:
        linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.42), transparent),
        radial-gradient(circle at 30% 34%, rgba(204, 0, 0, 0.1), transparent 16%),
        radial-gradient(circle at 70% 54%, rgba(100, 116, 139, 0.1), transparent 18%);
    content: "";
    opacity: 1;
    pointer-events: none;
    transform: translateX(-24%);
    transition: opacity 420ms ease;
    animation: tcpGraphStageSweep 1.6s ease-in-out infinite;
}

.tcp-graph-stage > div {
    position: relative;
    z-index: 1;
}

.tcp-graph-stage canvas {
    z-index: 1;
    background: transparent !important;
}

.tcp-graph.is-ready .tcp-graph-stage {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: saturate(1);
}

.tcp-graph.is-ready .tcp-graph-stage::before {
    opacity: 0;
    animation-play-state: paused;
}

.tcp-graph-stage:focus-visible {
    outline: 2px solid var(--tcp-graph-accent-line);
    outline-offset: 3px;
}

.tcp-graph-fallback {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.tcp-graph-empty {
    display: grid;
    min-height: 260px;
    place-items: center;
    border: 1px solid var(--tcp-graph-line);
    border-radius: 8px;
    background: var(--tcp-graph-surface);
}

@media (max-width: 700px) {
    .tcp-graph-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .tcp-graph-search {
        flex-basis: auto;
        min-width: 100%;
    }

    .tcp-graph-actions {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        width: 100%;
    }

    .tcp-graph-button {
        width: 100%;
    }

    .tcp-graph-button-icon {
        width: 100%;
        min-width: 0;
    }
}

@keyframes tcpGraphShellIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes tcpGraphStageSweep {
    0% {
        transform: translateX(-36%);
    }

    55%,
    100% {
        transform: translateX(36%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .tcp-graph,
    .tcp-graph-stage,
    .tcp-graph-stage::before {
        animation: none;
        transition: none;
    }

    .tcp-graph,
    .tcp-graph.is-ready .tcp-graph-stage {
        opacity: 1;
        transform: none;
    }

    .tcp-graph-stage::before {
        opacity: 0;
    }
}
