
/* Base Grid */
.sector-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 2px;
    width: 100%;
    height: 100%;
    background-color: #e5e7eb; /* Gap color */
    border: 1px solid #d1d5db;
}

.cell {
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4px;
    font-size: 0.65rem; /* Small by default */
    cursor: pointer;
    transition: background-color 0.2s;
    overflow: hidden;
    word-wrap: break-word;
    position: relative;
}

.cell:hover {
    background-color: #f9fafb;
}

/* Center Cells (Main Goals of sectors) */
.cell.center-cell {
    background-color: #e0e7ff; /* Indigo 100 */
    font-weight: bold;
    font-size: 0.75rem;
}

/* The Absolute Center Cell (The Grand Goal) */
.sector-4 .cell:nth-child(5) {
    background-color: #4f46e5; /* Indigo 600 */
    color: white;
    font-size: 0.9rem;
}

/* Input Styling within cells */
.cell textarea {
    width: 100%;
    height: 100%;
    resize: none;
    border: none;
    background: transparent;
    text-align: center;
    outline: none;
    font-family: inherit;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    /* pointer-events removed to allow typing */
}

/* Action Buttons inside cell (hidden by default) */
.cell-actions {
    position: absolute;
    bottom: 2px;
    right: 2px;
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    gap: 2px;
}

.cell:hover .cell-actions {
    opacity: 1;
}

.action-btn {
    background: rgba(255,255,255,0.9);
    border-radius: 4px;
    padding: 2px 4px;
    font-size: 10px;
    color: #4f46e5;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.action-btn:hover {
    background: #4f46e5;
    color: white;
}

/* ZOOM STATES */
/* 
   Grid is 3x3.
   0 1 2
   3 4 5
   6 7 8
   
   To zoom into 0 (Top Left), we need to move it to Center and Scale 3x.
   Translate X: 33.33%, Y: 33.33%
*/

.zoom-active .sector-grid {
    opacity: 0.3; /* Dim others */
    pointer-events: none;
}
.zoom-active .sector-grid.focused-sector {
    opacity: 1;
    pointer-events: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    z-index: 10;
}

/* Specific Transforms for each sector to bring it to center */
/* Note: positive translate moves element Right/Down. 
   If we are at Top-Left (0), we need to move Right (+33.33%) and Down (+33.33%) of the PARENT container?
   Actually, transform-origin is center. 
   Top Left (0) is at -33%, -33%. To bring to 0,0, we move +33%, +33%.
   Let's check the math. Container width W. 
   Sector 0 center is at -W/3, -H/3 relative to center.
   So translate(33.33%, 33.33%) corrects it.
*/

#grid-container.zoom-sector-0 { transform: scale(3) translate(33.33%, 33.33%); }
#grid-container.zoom-sector-1 { transform: scale(3) translate(0%, 33.33%); }
#grid-container.zoom-sector-2 { transform: scale(3) translate(-33.33%, 33.33%); }
#grid-container.zoom-sector-3 { transform: scale(3) translate(33.33%, 0%); }
#grid-container.zoom-sector-4 { transform: scale(3) translate(0%, 0%); } /* Center just scales */
#grid-container.zoom-sector-5 { transform: scale(3) translate(-33.33%, 0%); }
#grid-container.zoom-sector-6 { transform: scale(3) translate(33.33%, -33.33%); }
#grid-container.zoom-sector-7 { transform: scale(3) translate(0%, -33.33%); }
#grid-container.zoom-sector-8 { transform: scale(3) translate(-33.33%, -33.33%); }


/* Helper to hide text when zoomed out */
body:not(.zoomed) .sector-grid:not(.sector-4) .cell:not(.center-cell) {
    color: transparent; /* Hide detail text when in overview mode for cleanliness */
}
body:not(.zoomed) .sector-grid:not(.sector-4) .cell:not(.center-cell):hover {
    color: #9ca3af;
}

/* PRINT STYLES */
@media print {
    body {
        background: white;
        height: auto;
        overflow: visible;
    }
    header, #loading-overlay, #wizard-modal, .cell-actions {
        display: none !important;
    }
    #matrix-viewport {
        display: block;
        width: 100%;
        height: auto;
    }
    #grid-container {
        width: 100%;
        height: auto;
        aspect-ratio: 1/1;
        transform: none !important; /* Disable zoom for print */
        box-shadow: none;
        border: 2px solid black;
    }
    .sector-grid {
        border: 1px solid black;
        background-color: black; /* Gap color */
        gap: 1px;
    }
    .cell {
        border: 1px solid #ccc;
        color: black !important;
        font-size: 8pt !important;
    }
    .cell.center-cell {
        background-color: #ddd !important; /* Light gray for print */
        -webkit-print-color-adjust: exact;
    }
    .sector-4 .cell:nth-child(5) {
        background-color: #666 !important; /* Dark gray for print */
        color: white !important;
        -webkit-print-color-adjust: exact;
    }
    .cell textarea {
        color: black;
        overflow: visible;
    }
}
