/* RazorGantt default styles — populated incrementally as phases land. */

:root {
    --rg-row-height: 36px;
    --rg-bar-height: 24px;
    --rg-bar-radius: 4px;
    --rg-bar-font-size: 12px;
    --rg-axis-height: 28px;
    --rg-header-tier-height: 24px;
    --rg-dimmed-bg: rgba(0, 0, 0, 0.04);
    --rg-grid-line-color: #e5e7eb;
    --rg-header-bg: #f9fafb;
    --rg-label-column-bg: #f9fafb;
    --rg-bar-fill: #4a90e2;
    --rg-bar-progress-fill: rgba(0, 0, 0, 0.2);
    --rg-bar-label-color: #ffffff;
    --rg-tooltip-bg: #1f2937;
    --rg-tooltip-fg: #f9fafb;

    /* Per-CPM-type dependency arrow colors. */
    --rg-dep-color-fs: #555555;
    --rg-dep-color-ss: #2a7a5e;
    --rg-dep-color-ff: #a77a2a;
    --rg-dep-color-sf: #7a2a7a;
    --rg-dep-color-stacked-head: #000000;
    --rg-dep-stroke-width: 1.5px;

    /* Baseline ghost-bar overlay. */
    --rg-baseline-fill: rgba(150, 150, 150, 0.18);
    --rg-baseline-stroke: #9ca3af;
    --rg-baseline-stroke-dasharray: 4 2;

    /* Vertical reference lines. */
    --rg-reference-line-color: #dc2626;
    --rg-reference-line-width: 2px;
    --rg-reference-line-label-color: #b91c1c;
}

/* ---------- Outer shell ---------- */

.rg-chart {
    display: block;
    font-size: var(--rg-bar-font-size);
    border: 1px solid var(--rg-grid-line-color);
    border-radius: 4px;
    background: #fff;
    color: #111827;
}

.rg-scroll-viewport {
    overflow: auto;
    /* Reserve space for the scrollbar regardless of whether content overflows,
       so the chart does not jitter horizontally when the scrollbar appears/
       disappears on hover. */
    scrollbar-gutter: stable;
    max-height: 600px;
    position: relative;
}

.rg-layout {
    display: flex;
    align-items: stretch;
    min-height: 100%;
}

.rg-scroll-inner {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

/* ---------- Label column ---------- */

.rg-label-column {
    background: var(--rg-label-column-bg);
    border-right: 1px solid var(--rg-grid-line-color);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    /* Sticky to the viewport's left edge: horizontal scroll does not move it,
       but vertical scroll does (it is a normal flex child otherwise). */
    position: sticky;
    left: 0;
    z-index: 3;
}

.rg-label-column-resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    right: -3px;   /* straddle the border so the handle feels clickable on both sides */
    width: 6px;
    cursor: col-resize;
    z-index: 4;
    user-select: none;
    touch-action: none;
}

.rg-label-column-resize-handle:hover,
.rg-label-column-resize-handle.rg-dragging {
    background: rgba(37, 99, 235, 0.25);
}

/* Pan-drag cursor on the chart body while a drag is in progress (class toggled by JS). */
.rg-scroll-viewport.rg-panning,
.rg-scroll-viewport.rg-panning .rg-scroll-inner,
.rg-scroll-viewport.rg-panning .rg-scroll-inner * {
    cursor: grabbing !important;
    user-select: none;
}

.rg-label-column-header {
    border-bottom: 1px solid var(--rg-grid-line-color);
    background: var(--rg-header-bg);
    box-sizing: border-box;
    position: sticky;
    top: 0;
    z-index: 1;
    flex-shrink: 0;
}

.rg-row-label {
    padding: 0 12px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--rg-grid-line-color);
    box-sizing: border-box;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: #374151;
}

.rg-group-row-label {
    font-weight: 600;
    background: rgba(0, 0, 0, 0.03);
    cursor: pointer;
    user-select: none;
    gap: 6px;
}

.rg-group-row-label:hover {
    background: rgba(0, 0, 0, 0.06);
}

.rg-group-row-label:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: -2px;
}

.rg-group-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 150ms ease;
    color: #6b7280;
}

.rg-group-row-label.rg-group-expanded .rg-group-chevron {
    transform: rotate(90deg);
}

.rg-group-row-label-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Header region (tiers + axis) ---------- */

.rg-header-region {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--rg-header-bg);
    border-bottom: 1px solid var(--rg-grid-line-color);
    flex-shrink: 0;
}

.rg-axis-header-tier {
    position: relative;
    height: var(--rg-header-tier-height);
    border-bottom: 1px solid var(--rg-grid-line-color);
}

.rg-axis-header-tier-span {
    position: absolute;
    top: 0;
    height: 100%;
    padding: 0 6px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    border-right: 1px solid var(--rg-grid-line-color);
    font-weight: 500;
    color: #374151;
    text-decoration: none;
}

a.rg-axis-header-tier-span:hover {
    background: rgba(37, 99, 235, 0.08);
    text-decoration: underline;
}

.rg-axis {
    display: flex;
    height: var(--rg-axis-height);
}

.rg-division {
    flex-shrink: 0;
    box-sizing: border-box;
    border-right: 1px solid var(--rg-grid-line-color);
    padding: 0 4px;
    display: flex;
    align-items: center;
    overflow: hidden;
    white-space: nowrap;
    color: #6b7280;
    font-size: 0.75rem;
}

.rg-division-dim {
    background: var(--rg-dimmed-bg);
}

/* ---------- Chart body (SVG) ---------- */

.rg-body {
    position: relative;
}

.rg-chart-svg {
    display: block;
    background: transparent;
}

.rg-row {
    /* per-row styling hook; currently a no-op, present for Layer-2 consumer overrides */
}

/* Horizontal row dividers. Hidden by default so existing consumers see no visual change;
   opt in by setting a non-transparent --rg-row-divider-color on any chart ancestor:
       .my-chart { --rg-row-divider-color: var(--rg-grid-line-color); }
*/
.rg-row-divider-layer {
    pointer-events: none;
}

.rg-row-divider {
    stroke: var(--rg-row-divider-color, transparent);
    stroke-width: 1;
    fill: none;
}

.rg-group-header .rg-group-header-bg {
    fill: rgba(0, 0, 0, 0.03);
}

.rg-group-header.rg-group-collapsed .rg-group-header-bg {
    fill: rgba(0, 0, 0, 0.05);
}

.rg-group-summary {
    fill: var(--rg-bar-fill);
    opacity: 0.5;
    rx: var(--rg-bar-radius);
    ry: var(--rg-bar-radius);
}

/* ---------- Vertical reference lines ---------- */

.rg-reference-layer {
    pointer-events: none;
}

.rg-reference-line {
    stroke: var(--rg-reference-line-color);
    stroke-width: var(--rg-reference-line-width);
    fill: none;
}

.rg-reference-label-layer {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 0;
    pointer-events: none;
    z-index: 3;
}

.rg-reference-line-label {
    position: absolute;
    top: 2px;
    transform: translateX(-50%);
    padding: 1px 6px;
    background: var(--rg-header-bg);
    border: 1px solid var(--rg-reference-line-color);
    border-radius: 2px;
    color: var(--rg-reference-line-label-color);
    font-size: 0.75rem;
    white-space: nowrap;
    line-height: 1.2;
}

/* ---------- Dependency arrows ---------- */

.rg-dep-layer {
    pointer-events: none;
}

.rg-dep-arrow-group {
    pointer-events: auto;
    cursor: pointer;
}

.rg-dep-arrow {
    stroke-width: var(--rg-dep-stroke-width);
    fill: none;
    /* Keep stroke width readable when preserveAspectRatio="none" stretches the SVG. */
    vector-effect: non-scaling-stroke;
}

.rg-dep-arrow-fs { stroke: var(--rg-dep-color-fs); }
.rg-dep-arrow-ss { stroke: var(--rg-dep-color-ss); }
.rg-dep-arrow-ff { stroke: var(--rg-dep-color-ff); }
.rg-dep-arrow-sf { stroke: var(--rg-dep-color-sf); }

/* Invisible wider hit-test path behind each visible arrow. Lets tiny arrows still
   catch clicks without enlarging the visible stroke. */
.rg-dep-arrow-hit {
    stroke: transparent;
    stroke-width: 12px;
    fill: none;
    vector-effect: non-scaling-stroke;
    pointer-events: stroke;
}

.rg-bar {
    cursor: pointer;
}

.rg-bar .rg-bar-body {
    fill: var(--rg-bar-fill);
    rx: var(--rg-bar-radius);
    ry: var(--rg-bar-radius);
}

.rg-bar .rg-bar-progress {
    fill: var(--rg-bar-progress-fill);
    pointer-events: none;
}

.rg-bar-baseline {
    fill: var(--rg-baseline-fill);
    stroke: var(--rg-baseline-stroke);
    stroke-dasharray: var(--rg-baseline-stroke-dasharray);
    rx: var(--rg-bar-radius);
    ry: var(--rg-bar-radius);
    pointer-events: none;
}

.rg-bar-label {
    fill: var(--rg-bar-label-color);
    font-size: var(--rg-bar-font-size);
    pointer-events: none;
    user-select: none;
}

.rg-bar-label-truncate,
.rg-bar-label-ellipsis {
    /* SVG <text> has no built-in ellipsis; in v1 we simply clip via overflow on the
       containing <foreignObject>-less element, which means the text sits inside the
       bar rect bounds. The two variants differ semantically (future: ellipsis glyph)
       but render identically for now. */
}

.rg-bar-label-hide {
    display: none;
}

.rg-bar-label-overflow-right {
    /* Rendered past the bar's right edge; nothing to clip. */
}

/* ---------- Tooltip ---------- */

.rg-tooltip-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.rg-tooltip-anchor {
    /* Transparent hover target sized to exactly match its bar. Width/left/top/height
       come from the component; this rule only owns non-geometric properties. */
    position: absolute;
    pointer-events: auto;
}

.rg-tooltip {
    position: absolute;
    left: 0;
    top: 0;
    background: var(--rg-tooltip-bg);
    color: var(--rg-tooltip-fg);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8125rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 120ms ease;
    z-index: 5;
    max-width: 320px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.rg-tooltip-anchor:hover .rg-tooltip {
    opacity: 1;
}
