/* ============================================================
   GravityLearningPath — Journey Map with Circle-Packing
   ============================================================ */

/* --- Wrapper --- */
.gravity-learning-path-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 400px;
    overflow: hidden;
    background: var(--gravity-surface-secondary, #f8f9fa);
    border-radius: var(--gravity-radius-md, 8px);
    display: flex;
    flex-direction: column;
}

/* --- Toolbar --- */
.gravity-learning-path-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--gravity-surface-primary, #ffffff);
    border-bottom: 1px solid var(--gravity-border, #dee2e6);
    flex-shrink: 0;
    min-height: 48px;
}

/* --- Time slider --- */
.gravity-learning-path-time-slider {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    max-width: 300px;
}

.gravity-learning-path-time-slider-label {
    font-size: 0.75rem;
    color: var(--gravity-text-secondary, #6c757d);
    white-space: nowrap;
}

/* --- Toolbar actions --- */
.gravity-learning-path-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.gravity-learning-path-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: none;
    border: 1px solid var(--gravity-border, #dee2e6);
    border-radius: var(--gravity-radius-sm, 4px);
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    color: var(--gravity-text-secondary, #6c757d);
    font-size: 0.75rem;
    transition: all 0.15s ease;
}

.gravity-learning-path-toolbar-btn:hover {
    background-color: var(--gravity-surface-hover, #e9ecef);
    color: var(--gravity-text-primary, #212529);
}

.gravity-learning-path-toolbar-btn svg {
    width: 16px;
    height: 16px;
}

/* --- SVG Container --- */
.gravity-learning-path-svg-container {
    flex: 1;
    min-height: 0;
    overflow: hidden; /* D3 zoom handles pan, no native scrollbars */
    position: relative;
}

.gravity-learning-path-svg {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
}

.gravity-learning-path-svg:active {
    cursor: grabbing;
}

/* --- Zoom group (D3 applies transform here) --- */
.zoom-group {
    /* No transition — D3 handles smooth zooming */
}

/* --- Loading state --- */
.gravity-learning-path-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 100%;
    color: var(--gravity-text-tertiary, #adb5bd);
    font-size: 0.875rem;
}

.gravity-learning-path-loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gravity-border, #dee2e6);
    border-top-color: var(--gravity-text-secondary, #6c757d);
    border-radius: 50%;
    animation: lp-spin 0.6s linear infinite;
}

@keyframes lp-spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   Journey Trail — dashed path connecting L1 centers
   ============================================================ */
.lp-journey-trail {
    fill: none;
    stroke: var(--gravity-text-tertiary, #adb5bd);
    stroke-width: 3;
    stroke-dasharray: 12 6;
    stroke-linecap: round;
    opacity: 0.5;
}

/* ============================================================
   Node Circles — depth-based styling
   ============================================================ */
.lp-circle {
    cursor: pointer;
    transition: filter 0.15s ease;
}

.lp-circle:hover circle {
    filter: brightness(1.1);
    stroke-opacity: 0.8;
    stroke-width: 2;
}

/* Depth-specific circle styling */
.lp-circle--depth-1 circle {
    /* L1: large translucent journey stops */
}

.lp-circle--depth-2 circle {
    /* L2: mid-size sub-areas */
}

.lp-circle--depth-3 circle {
    /* L3: topics */
}

.lp-circle--depth-4 circle {
    /* L4+: small dots */
}

/* --- Unexposed node styling (grey, no data) --- */
.lp-circle--unexposed circle {
    stroke: rgba(0, 0, 0, 0.1);
}

/* --- Weak node styling (red pulse ring) --- */
.lp-circle--weak circle {
    stroke: rgba(244, 67, 54, 0.7);
    stroke-width: 2.5;
    animation: lp-weak-pulse 2s ease-in-out infinite;
}

@keyframes lp-weak-pulse {
    0%, 100% {
        stroke-width: 2.5;
        stroke-opacity: 0.7;
    }
    50% {
        stroke-width: 4;
        stroke-opacity: 1;
    }
}

/* ============================================================
   Weak Cluster Rings
   ============================================================ */
.lp-weak-ring {
    fill: rgba(244, 67, 54, 0.04);
    stroke: rgba(244, 67, 54, 0.3);
    stroke-width: 1.5;
    stroke-dasharray: 6 4;
    cursor: pointer;
    transition: fill 0.2s ease, stroke 0.2s ease;
}

.lp-weak-ring:hover {
    fill: rgba(244, 67, 54, 0.1);
    stroke: rgba(244, 67, 54, 0.6);
}

/* ============================================================
   Circle Labels — foreignObject inside circles
   Visibility controlled by SVG data-zoom attribute
   ============================================================ */
.lp-label-fo {
    overflow: visible;
    pointer-events: none; /* Let clicks pass through to the circle */
}

.lp-circle-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    text-align: center;
    /* font-size set inline per node, proportional to radius */
    line-height: 1.2;
    color: #000;
    pointer-events: auto;
    overflow: hidden;
}

/* Trend indicator pinned to the top of the circle */
.lp-circle-trend {
    flex-shrink: 0;
    pointer-events: none;
}

/* Flexible spacer — absorbs middle space where child circles live */
.lp-circle-spacer {
    flex: 1;
}

/* Label + practice button pinned to the bottom of the circle */
.lp-circle-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    pointer-events: auto;
}

.lp-circle-label-text {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    max-width: 100%;
    word-break: break-word;
}

/* --- Label visibility by zoom level ---
   data-zoom is set on the SVG by JS:
   "overview" = full map, "region" = L1 focused, "detail" = L2+ focused
*/

/* Overview: only L1 labels visible */
.gravity-learning-path-svg[data-zoom="overview"] .lp-label-fo--depth-3,
.gravity-learning-path-svg[data-zoom="overview"] .lp-label-fo--depth-4 {
    display: none;
}

/* Region: L1 + L2 labels visible */
.gravity-learning-path-svg[data-zoom="region"] .lp-label-fo--depth-4 {
    display: none;
}

/* Detail: all labels visible (default, no hiding needed) */

/* ============================================================
   Practice Buttons (on weak exposed leaf nodes)
   ============================================================ */
.lp-practice-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* width/height set inline, proportional to node radius */
    border: none;
    border-radius: 50%;
    background: rgba(244, 67, 54, 0.8);
    color: white;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
    pointer-events: auto;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.lp-practice-btn:hover {
    background: rgba(211, 47, 47, 1);
    transform: scale(1.15);
}

.lp-practice-btn svg {
    width: 10px;
    height: 10px;
}

/* ============================================================
   Tooltip (position: fixed, JS mouse tracking)
   ============================================================ */
.gravity-learning-path-tooltip {
    position: fixed;
    z-index: 1000;
    max-width: 280px;
    padding: 0.625rem 0.75rem;
    background: var(--gravity-surface-primary, #ffffff);
    border: 1px solid var(--gravity-border, #dee2e6);
    border-radius: var(--gravity-radius-md, 8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    font-size: 0.75rem;
    pointer-events: none;
}

.gravity-learning-path-tooltip-header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-bottom: 0.375rem;
}

.gravity-learning-path-tooltip-level {
    font-size: 0.625rem;
    color: var(--gravity-text-tertiary, #adb5bd);
    font-weight: 600;
    text-transform: uppercase;
}

.gravity-learning-path-tooltip-title {
    font-weight: 600;
    color: var(--gravity-text-primary, #212529);
}

.gravity-learning-path-tooltip-description {
    color: var(--gravity-text-secondary, #6c757d);
    margin-bottom: 0.375rem;
    font-size: 0.6875rem;
}

.gravity-learning-path-tooltip-metrics {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.gravity-learning-path-tooltip-metric {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}

.gravity-learning-path-tooltip-metric-label {
    color: var(--gravity-text-tertiary, #adb5bd);
    font-size: 0.625rem;
    text-transform: uppercase;
    font-weight: 600;
    flex-shrink: 0;
}

.gravity-learning-path-tooltip-metric-value {
    color: var(--gravity-text-primary, #212529);
    font-weight: 500;
    text-align: right;
}

.gravity-learning-path-tooltip-metric-level {
    color: var(--gravity-text-secondary, #6c757d);
    font-size: 0.6875rem;
    font-weight: 400;
}

.gravity-learning-path-tooltip-footer {
    margin-top: 0.375rem;
    padding-top: 0.375rem;
    border-top: 1px solid var(--gravity-border, #dee2e6);
    color: var(--gravity-text-tertiary, #adb5bd);
    font-size: 0.625rem;
    font-style: italic;
}

/* Trend classes for tooltip */
.gravity-learning-path-tooltip-trend--up {
    color: var(--gravity-success, #2e7d32);
}

.gravity-learning-path-tooltip-trend--down {
    color: var(--gravity-error, #c62828);
}

.gravity-learning-path-tooltip-trend--stable {
    color: var(--gravity-text-secondary, #6c757d);
}

/* --- Empty state --- */
.gravity-learning-path-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--gravity-text-tertiary, #adb5bd);
    font-size: 0.875rem;
}
