/* Home View Specific Styles */
#home-view {
    margin: 0;
    padding: 0;
    background-color: var(--letterbox-color); /* Ensure letterbox background in all modes */
}

.tiles-container {
    position: relative;
    width: 100%;
    height: calc(var(--actual-vh, 100vh) - var(--header-height, 70px));
    background-color: var(--bg-color);
    margin: 0;
    padding: 0;
    overflow: hidden;
    transition: width 0.3s ease, height 0.3s ease; /* Smooth width and height transitions */
}

/* In fit and fill modes, tiles container should inherit aspect ratio container size, not viewport size */
#home-view.screen-fit-mode .tiles-container,
#home-view.screen-fill-mode .tiles-container {
    width: 100%;
    height: 100%;
    background-color: var(--bg-color); /* Keep content background */
}

.concept-tile {
    background-color: var(--tile-color);
    border-radius: 8px;
    box-shadow: 0 4px 8px var(--tile-shadow);
    overflow: hidden;
    cursor: pointer;
    position: absolute; /* Always use absolute positioning */
    transition: box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    
    /* Prevent context menu and improve touch interactions */
    touch-action: manipulation;
    -webkit-touch-callout: none; /* Prevents callout (long press menu) on iOS Safari */
    -webkit-user-select: none;   /* Prevents text selection */
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.concept-tile:hover {
    box-shadow: 0 6px 12px var(--tile-shadow);
}

.concept-tile.dragging {
    opacity: 0.8;
    cursor: grabbing;
    z-index: 10;
    box-shadow: 0 0 0 2px var(--secondary-color);
}

.concept-tile.resizing {
    opacity: 0.9;
    z-index: 10;
    box-shadow: 0 0 0 2px var(--secondary-color);
    cursor: move; /* Show move cursor to indicate interaction */
    pointer-events: all !important; /* Ensure all events are captured during resize */
}

/* Resize handles */
.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: var(--secondary-color);
    border-radius: 50%;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.2s ease;
}

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

.resize-handle:hover {
    opacity: 1 !important;
    transform: scale(1.2);
}

/* Make resize handles more touch-friendly on mobile */
@media (max-width: 768px) {
    .resize-handle {
        width: 18px;
        height: 18px;
        opacity: 0.6;
    }
    
    .resize-handle.top-left {
        top: -9px;
        left: -9px;
    }
    
    .resize-handle.top-right {
        top: -9px;
        right: -9px;
    }
    
    .resize-handle.bottom-left {
        bottom: -9px;
        left: -9px;
    }
    
    .resize-handle.bottom-right {
        bottom: -9px;
        right: -9px;
    }
}

.resize-handle.top-left {
    top: -5px;
    left: -5px;
    cursor: nwse-resize;
}

.resize-handle.top-right {
    top: -5px;
    right: -5px;
    cursor: nesw-resize;
}

.resize-handle.bottom-left {
    bottom: -5px;
    left: -5px;
    cursor: nesw-resize;
}

.resize-handle.bottom-right {
    bottom: -5px;
    right: -5px;
    cursor: nwse-resize;
}

.tile-header {
    background-color: var(--primary-color);
    color: white;
    padding: var(--spacing-sm);
    text-align: center;
    font-weight: bold;
    flex-shrink: 0; /* Prevent header from shrinking */
}

.tile-content {
    padding: var(--spacing-sm);
    flex: 1; /* Take up remaining space after header */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 0; /* Allow flex item to shrink below content size */
}

.tile-preview {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: #f5f5f5;
    border-radius: 4px;
}

.tile-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    pointer-events: none;
}

.no-preview {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    font-weight: 500;
    text-align: center; /* Ensure text is centered when wrapping */
    /* Font size will be set dynamically by FontSizer */
}
