/* ═══════════════════════════════════════════════════════════════
   LAYOUT SYSTEM ADDITIONS
   Additive styles — does NOT override styles.css
   ═══════════════════════════════════════════════════════════════ */

/* ─── Node action buttons: hidden until hover ─── */
.node-actions {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}
.node:hover .node-actions {
    opacity: 1;
    pointer-events: auto;
}

/* Keep buttons visible while editing or if node is selected */
.node.selected .node-actions,
.node.last-clicked .node-actions {
    opacity: 1;
    pointer-events: auto;
}

/* ─── Layout direction dropdown (toolbar) ─── */
.toolbar-select-wrap { display: flex; align-items: center; }
.toolbar-select {
    height: 32px;
    padding: 0 24px 0 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--pc-controls-text, var(--text-secondary));
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='%238a8f9d'%3E%3Cpath d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}
.toolbar-select:hover  { background: var(--bg-node); color: var(--pc-controls-text-hover, var(--text-primary)); border-color: var(--border-light); }
.toolbar-select:focus  { outline: none; border-color: var(--accent); }
.toolbar-select option { background: var(--bg-elevated); color: var(--pc-controls-text-hover, var(--text-primary)); }

/* Light mode compat */
body.light-mode .toolbar-select {
    background-color: #fff;
    border-color: #d0d0d5;
    color: #333;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='%23555'%3E%3Cpath d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
}
body.light-mode .toolbar-select option {
    background: #fff;
    color: #1a1a1a;
}

/* ─── Radial layout: smooth position transitions ─── */
/* When radial is active, nodes transition position smoothly
   for the rotation effect when switching active core */
body[data-layout="radial"] .node,
body[data-layout="rotational"] .node {
    transition: opacity 0.15s ease;
}
/* Disable transitions during drag */
body[data-layout="radial"] .node.dragging,
body[data-layout="rotational"] .node.dragging {
    transition: none !important;
}

/* ─── Radial ring guides ─── */
.radial-ring {
    pointer-events: none;
}

/* ─── Active core indicator in radial/rotational mode ─── */
body[data-layout="radial"] .node.core-node.radial-active,
body[data-layout="rotational"] .node.core-node.radial-active {
    box-shadow: 0 0 20px rgba(74, 158, 255, 0.4),
                0 0 40px rgba(74, 158, 255, 0.15);
    z-index: 5 !important;
}

/* ═══════════════════════════════════════════════════════════════
   NODE SHAPES
   ═══════════════════════════════════════════════════════════════ */

/* Rectangle — default */
.node.shape-rectangle { border-radius: var(--radius-lg); }

/* Pill — rounded ends */
.node.shape-pill {
    border-radius: 999px;
    padding-left: 24px;
    padding-right: 24px;
}
.node.shape-pill .add-child-btn {
    border: none; background: transparent; color: var(--text-muted);
    font-size: 0.75em; padding: 2px 8px; border-radius: 999px; opacity: 0.7;
}
.node.shape-pill .add-child-btn:hover { color: var(--accent); opacity: 1; background: var(--accent-dim); }

/* ── Shared: shapes that need centered content ── */
.node.shape-circle,
.node.shape-smallcircle,
.node.shape-diamond,
.node.shape-hexagon {
    min-width: unset !important;
    min-height: unset !important;
}
.node.shape-circle .node-content,
.node.shape-smallcircle .node-content,
.node.shape-diamond .node-content,
.node.shape-hexagon .node-content {
    padding-top: 0;
    align-items: center;
    justify-content: center;
    height: 100%;
}
.node.shape-circle .node-body-area,
.node.shape-smallcircle .node-body-area,
.node.shape-diamond .node-body-area,
.node.shape-hexagon .node-body-area {
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex: 0 0 auto;
}
.node.shape-circle .node-header,
.node.shape-smallcircle .node-header,
.node.shape-diamond .node-header,
.node.shape-hexagon .node-header {
    padding-top: 0;
    justify-content: center;
    text-align: center;
    width: 100%;
}
/* Hide extras on compact shapes */
.node.shape-circle .node-description,
.node.shape-circle .node-tags,
.node.shape-circle .resize-handle,
.node.shape-circle .node-card-image-wrap,
.node.shape-circle .node-media-container,
.node.shape-circle .unlock-criteria,
.node.shape-circle .connection-handle,
.node.shape-circle .node-icon,
.node.shape-smallcircle .node-description,
.node.shape-smallcircle .node-tags,
.node.shape-smallcircle .resize-handle,
.node.shape-smallcircle .node-card-image-wrap,
.node.shape-smallcircle .node-media-container,
.node.shape-smallcircle .unlock-criteria,
.node.shape-smallcircle .connection-handle,
.node.shape-smallcircle .node-icon,
.node.shape-smallcircle .node-actions,
.node.shape-smallcircle .level-badge,
.node.shape-smallcircle .node-id-badge,
.node.shape-diamond .node-description,
.node.shape-diamond .node-tags,
.node.shape-diamond .resize-handle,
.node.shape-diamond .node-card-image-wrap,
.node.shape-diamond .node-media-container,
.node.shape-diamond .unlock-criteria,
.node.shape-diamond .connection-handle,
.node.shape-diamond .node-icon,
.node.shape-hexagon .node-description,
.node.shape-hexagon .node-tags,
.node.shape-hexagon .resize-handle,
.node.shape-hexagon .node-card-image-wrap,
.node.shape-hexagon .node-media-container,
.node.shape-hexagon .unlock-criteria,
.node.shape-hexagon .connection-handle,
.node.shape-hexagon .node-icon { display: none; }

/* ── Circle ── */
.node.shape-circle {
    border-radius: 50%;
    overflow: hidden;
    padding: 6px;
    align-items: center;
    justify-content: center;
}
.node.shape-circle .node-title {
    text-align: center; font-size: 0.75em; line-height: 1.15;
    overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.node.shape-circle .add-child-btn {
    font-size: 0.55em; padding: 0 3px; text-align: center; margin-top: 1px;
    border: none; background: transparent; color: var(--text-muted); opacity: 0.7;
}
.node.shape-circle .add-child-btn:hover {
    color: var(--accent); opacity: 1;
}

/* ── Small Circle — title only, minimal ── */
.node.shape-smallcircle {
    border-radius: 50%;
    overflow: hidden;
    padding: 2px;
    align-items: center;
    justify-content: center;
}
.node.shape-smallcircle .node-title {
    text-align: center; font-size: 0.65em; line-height: 1.15;
    overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.node.shape-smallcircle .add-child-btn { display: none; }

/* ═══ CLIP-PATH SHAPES ═══ */
/* Strategy: clip-path on .node-content (not .node), so add-child-btn & actions float outside.
   .node is transparent container. .node-content gets shape, bg, and filter border. */

/* ── Clip-path shared: .node wrapper is transparent ── */
.node.shape-diamond,
.node.shape-hexagon,
.node.shape-parallelogram {
    border: none !important;
    border-radius: 0;
    min-width: unset !important;
    min-height: unset !important;
    overflow: visible;
    background: transparent !important;
    filter: none !important;
    box-shadow: none !important;
}

/* ── Clip-path shared: .node-content gets shape + border shadow ── */
.node.shape-diamond > .node-content,
.node.shape-hexagon > .node-content,
.node.shape-parallelogram > .node-content {
    background: var(--pc-branch-bg, var(--bg-node));
    filter: drop-shadow(0 0 0px var(--node-border-color, var(--border-light)))
            drop-shadow(0 0 2px var(--node-border-color, var(--border-light)))
            drop-shadow(0 0 2px var(--node-border-color, var(--border-light)));
    transition: filter 0.2s ease;
    position: relative;
}
/* Core nodes get core background */
.node.shape-diamond.core-node > .node-content,
.node.shape-hexagon.core-node > .node-content,
.node.shape-parallelogram.core-node > .node-content {
    background: var(--pc-core-bg, var(--bg-surface));
}

/* ── States: target .node-content for glow effects ── */
.node.shape-diamond:hover > .node-content,
.node.shape-hexagon:hover > .node-content,
.node.shape-parallelogram:hover > .node-content {
    filter: drop-shadow(0 0 2px var(--node-border-color, var(--border-light)))
            drop-shadow(0 0 2px var(--node-border-color, var(--border-light)))
            drop-shadow(0 0 8px var(--pc-node-glow))
            drop-shadow(0 0 16px var(--pc-node-glow));
}
.node.shape-diamond.selected > .node-content,
.node.shape-hexagon.selected > .node-content,
.node.shape-parallelogram.selected > .node-content {
    filter: drop-shadow(0 0 2px var(--pc))
            drop-shadow(0 0 2px var(--pc))
            drop-shadow(0 0 10px var(--pc-node-glow));
}
.node.shape-diamond.last-clicked > .node-content,
.node.shape-hexagon.last-clicked > .node-content,
.node.shape-parallelogram.last-clicked > .node-content {
    filter: drop-shadow(0 0 2px #f5c542)
            drop-shadow(0 0 2px #f5c542)
            drop-shadow(0 0 8px rgba(245,197,66,0.4));
}
.node.shape-diamond.dragging > .node-content,
.node.shape-hexagon.dragging > .node-content,
.node.shape-parallelogram.dragging > .node-content {
    filter: drop-shadow(0 0 2px var(--node-border-color, var(--border-light)))
            drop-shadow(0 0 2px var(--node-border-color, var(--border-light)))
            drop-shadow(0 0 12px var(--pc-node-glow))
            drop-shadow(0 0 24px var(--pc-node-glow));
}

/* ── Floating add-child-btn for clip shapes: sits below the shape ── */
.node.shape-diamond > .add-child-btn,
.node.shape-hexagon > .add-child-btn,
.node.shape-parallelogram > .add-child-btn {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6em;
    padding: 2px 8px;
    border: 1px dashed var(--border-light);
    border-radius: var(--radius-sm, 4px);
    background: var(--bg-elevated);
    color: var(--text-muted);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 5;
}
.node.shape-diamond:hover > .add-child-btn,
.node.shape-hexagon:hover > .add-child-btn,
.node.shape-parallelogram:hover > .add-child-btn {
    opacity: 1;
    pointer-events: auto;
}
.node.shape-diamond > .add-child-btn:hover,
.node.shape-hexagon > .add-child-btn:hover,
.node.shape-parallelogram > .add-child-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

/* ── Floating node-actions for clip shapes ── */
.node.shape-diamond .node-actions,
.node.shape-hexagon .node-actions,
.node.shape-parallelogram .node-actions {
    position: absolute;
    top: -8px;
    right: -8px;
    z-index: 10;
    display: flex;
    gap: 2px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm, 4px);
    padding: 2px 4px;
}
.node.shape-diamond:hover .node-actions,
.node.shape-hexagon:hover .node-actions,
.node.shape-parallelogram:hover .node-actions {
    opacity: 1;
    pointer-events: auto;
}

/* ── Diamond ── */
.node.shape-diamond > .node-content {
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 6px;
}
.node.shape-diamond .node-body-area {
    display: flex;
    align-items: center;
    justify-content: center;
}
.node.shape-diamond .node-title {
    text-align: center; font-size: 0.75em; line-height: 1.2;
    overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    max-width: 60%;
    word-break: break-word;
}

/* ── Hexagon ── */
.node.shape-hexagon > .node-content {
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 6px 15%;
}
.node.shape-hexagon .node-body-area {
    display: flex;
    align-items: center;
    justify-content: center;
}
.node.shape-hexagon .node-title {
    text-align: center; font-size: 0.8em; line-height: 1.2;
    overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    max-width: 70%;
    word-break: break-word;
}

/* ── Parallelogram ── */
.node.shape-parallelogram > .node-content {
    clip-path: polygon(10% 0%, 100% 0%, 90% 100%, 0% 100%);
    padding: 6px 14%;
    width: 100%;
    height: 100%;
}
.node.shape-parallelogram .node-header {
    padding-top: 4px;
}
.node.shape-parallelogram .node-title {
    font-size: 0.8em;
    overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.node.shape-parallelogram .node-description {
    font-size: 0.7em;
    overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.node.shape-parallelogram .resize-handle,
.node.shape-parallelogram .connection-handle { display: none; }
/* ═══════════════════════════════════════════════════════════════
   SHAPE TOGGLE BUTTONS
   ═══════════════════════════════════════════════════════════════ */
.shape-toggle-row {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    align-items: center;
}
.shape-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 28px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 4px);
    background: var(--bg-elevated);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}
.shape-toggle-btn:hover {
    border-color: var(--border-light);
    color: var(--text-primary);
    background: var(--bg-node);
}
.shape-toggle-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
    box-shadow: 0 0 6px var(--accent-glow, rgba(74,158,255,0.25));
}
.shape-toggle-btn svg {
    display: block;
    flex-shrink: 0;
}
/* Light mode */
body.light-mode .shape-toggle-btn {
    background: #fff;
    border-color: #d0d0d5;
    color: #888;
}
body.light-mode .shape-toggle-btn:hover {
    color: #333;
    border-color: #aaa;
    background: #f5f5f5;
}
body.light-mode .shape-toggle-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(74, 158, 255, 0.1);
}

/* ── Align button: action style (not a toggle) ── */
#align-children-btn {
    position: relative;
}
#align-children-btn:active {
    transform: scale(0.95);
    background: var(--accent-dim);
    border-color: var(--accent-active-text, var(--accent));
    color: var(--accent-active-text, var(--accent));
}
#align-children-btn.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow, rgba(74,158,255,0.3));
}