/* hsdc.css — HD-POE Spatial Tiling Substrate */

/* ── Workspace Canvas ── */
.hsdc-workspace {
    position: relative;
    flex: 1;
    overflow: auto;
    background: var(--bg-primary, #fafafa);
    background-image: radial-gradient(circle, rgba(0, 0, 0, 0.06) 1px, transparent 1px);
    background-size: 20px 20px;
    min-height: 100%;
}

/* ── Base Tile ── */
.tile {
    position: absolute;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-color, #d0d0d0);
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    transition: box-shadow 0.15s ease, opacity 0.15s ease;
}

.tile:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ── Tile Header ── */
.tile-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.02);
    border-bottom: 1px solid var(--border-color, #d0d0d0);
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
}

.tile-header:active {
    cursor: grabbing;
}

.tile-type-badge {
    font-family: var(--font-mono);
    font-size: var(--text-4xs);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 2px 5px;
    border: 1px solid var(--border-color, #d0d0d0);
    border-radius: 2px;
    color: var(--text-muted, #888);
    flex-shrink: 0;
}

.tile-memory-badge {
    display: inline-flex;
    gap: 3px;
    margin-left: auto;
    margin-right: 4px;
    flex-shrink: 0;
}

.mem-tier {
    font-family: var(--font-mono);
    font-size: var(--text-5xs);
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 1px 3px;
    border-radius: 2px;
}

.mem-m1 {
    background: #e3f2fd;
    color: #1565c0;
    border: 1px solid #90caf9;
}

.mem-m2 {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.mem-m3 {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffcc80;
}

.tile--branch .tile-type-badge {
    border-color: #1565c0;
    color: #1565c0;
}

.tile--control .tile-type-badge {
    border-color: #f57f17;
    color: #f57f17;
}

.tile--widget .tile-type-badge {
    border-color: #2e7d32;
    color: #2e7d32;
}

.tile--output .tile-type-badge {
    border-color: var(--text-primary, #1a1a1a);
    color: var(--text-primary, #1a1a1a);
}

.tile-title {
    font-family: var(--font-mono);
    font-size: var(--text-micro);
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.tile-controls {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.tile-ctrl-btn {
    font-family: var(--font-mono);
    font-size: var(--text-xs-sm);
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 2px;
    background: transparent;
    color: var(--text-muted, #888);
    cursor: pointer;
    transition: border-color 0.1s ease, color 0.1s ease, background 0.1s ease;
}

.tile-ctrl-btn:hover {
    border-color: var(--border-color, #d0d0d0);
    color: var(--text-primary, #1a1a1a);
}

.tile-ctrl-close:hover {
    border-color: #c62828;
    color: #c62828;
    background: rgba(198, 40, 40, 0.06);
}

/* ── Tile Body ── */
.tile-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.tile-content {
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: var(--text-micro);
    line-height: 1.6;
    color: var(--text-primary, #1a1a1a);
}

/* ── Tile Actions ── */
.tile-actions {
    display: flex;
    gap: 1px;
    border-top: 1px solid var(--border-color, #d0d0d0);
    background: rgba(0, 0, 0, 0.02);
    flex-shrink: 0;
}

.tile-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 8px;
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-muted, #888);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color 0.1s ease, background 0.1s ease;
    white-space: nowrap;
}

.tile-action-btn:hover {
    color: var(--text-primary, #1a1a1a);
    background: rgba(0, 0, 0, 0.04);
}

.tile-action-btn + .tile-action-btn {
    border-left: 1px solid var(--border-color, #d0d0d0);
}

.tile-action-btn svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.tile-action-btn:hover svg {
    opacity: 1;
}

/* ── Tile Resize Handle ── */
.tile-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, var(--border-color, #d0d0d0) 50%);
    opacity: 0.4;
    transition: opacity 0.15s;
}

.tile:hover .tile-resize-handle {
    opacity: 0.8;
}

/* ── Tile States ── */
.tile--compressed {
    height: auto !important;
    min-height: 0;
}

.tile--compressed .tile-body {
    display: none;
}

.tile--compressed .tile-resize-handle {
    display: none;
}

.tile--compressed .tile-header {
    border-bottom: none;
}

.tile--pinned {
    border-color: #1565c0;
    border-width: 1px 1px 1px 3px;
}

.tile--complete {
    border-color: #2e7d32;
}

.tile--complete .tile-type-badge {
    border-color: #2e7d32;
    color: #2e7d32;
}

.tile--focused {
    border-color: var(--color-active, #6A73B0);
    box-shadow: 0 0 0 2px rgba(106, 115, 176, 0.25), 0 2px 8px rgba(0, 0, 0, 0.08);
}

.tile--search-match {
    border-left: 3px solid #f9a825;
}

.tile--search-dim {
    opacity: 0.35;
    pointer-events: none;
}

/* ── Tile Drag State ── */
.tile.dragging {
    opacity: 0.85;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* ── Workspace Empty State ── */
.workspace-empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 1;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.workspace-empty-state.hidden {
    opacity: 0;
    visibility: hidden;
}

.workspace-empty-state__panel {
    max-width: 400px;
    width: 100%;
    padding: 32px;
    pointer-events: auto;
}

.workspace-empty-state__heading {
    font-family: var(--font-mono);
    font-size: var(--text-3xs);
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted, #888);
    margin-bottom: 8px;
}

.workspace-empty-state__desc {
    font-family: var(--font-mono);
    font-size: var(--text-micro);
    line-height: 1.65;
    color: var(--text-muted, #888);
    margin: 0 0 24px 0;
}

.workspace-empty-state__section {
    margin-bottom: 16px;
}

.workspace-empty-state__section-title {
    font-family: var(--font-mono);
    font-size: var(--text-4xs);
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-secondary, #555);
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    margin-bottom: 8px;
}

.workspace-empty-state__shortcuts {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.workspace-empty-state__shortcut {
    display: flex;
    align-items: baseline;
    gap: 12px;
    font-family: var(--font-mono);
    font-size: var(--text-micro);
    line-height: 1.6;
    color: var(--text-muted, #888);
}

.workspace-empty-state__key {
    display: inline-block;
    padding: 1px 6px;
    font-family: var(--font-mono);
    font-size: var(--text-3xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-secondary, #555);
    border: 1px solid var(--border-color, #d0d0d0);
    border-radius: 2px;
    background: rgba(0, 0, 0, 0.02);
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 52px;
    text-align: center;
}

.workspace-empty-state__action {
    color: var(--text-muted, #888);
    flex: 1;
}

.workspace-empty-state__grid-note {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    color: var(--text-muted, #aaa);
    border-top: 1px solid var(--border-color, #e0e0e0);
    padding-top: 12px;
    margin-top: 16px;
    line-height: 1.65;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .tile {
        position: relative !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: auto !important;
        margin-bottom: 8px;
    }

    .tile-resize-handle {
        display: none;
    }

    .hsdc-workspace {
        display: flex;
        flex-direction: column;
        padding: 8px;
        gap: 8px;
        background-image: none;
    }
}
