/* Puzzle Display Styles */

/* Grid Container */
.grid-wrapper {
    position: relative;
    display: inline-block;
    margin: 20px auto;
}

/* Puzzle Grid */
.puzzle-grid {
    border-collapse: collapse;
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    user-select: none;
    background-color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.puzzle-grid td {
    width: 40px;
    height: 40px;
    text-align: center;
    vertical-align: middle;
    border: 1px solid #ddd;
    padding: 0;
    position: relative;
}

/* Highlights Layer */
.highlights-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.highlight {
    position: absolute;
    background-color: #FFD700;
    opacity: 0.3;
    border-radius: 4px;
    pointer-events: none;
}

/* Word List */
.word-list {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-top: 20px;
}

.word-list h3 {
    margin-bottom: 15px;
    color: #4A90E2;
}

.word-list ul {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.word-list li {
    padding: 8px 12px;
    background-color: #f5f5f5;
    border-radius: 4px;
    font-weight: 600;
}

/* Preview Container */
.preview-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.puzzle-preview {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.puzzle-preview h2 {
    text-align: center;
    color: #4A90E2;
    margin-bottom: 20px;
}

/* Text Answer Key */
.text-answer-key {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-top: 20px;
}

/* Visual Answer Grid */
.answer-grid-visual {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.answer-grid-wrapper {
    position: relative;
    display: inline-block;
}

.answer-lines-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    overflow: visible;
}

.answer-line {
    stroke: #b8a9c9;
    stroke-width: 28;
    stroke-linecap: round;
    fill: none;
    opacity: 0.6;
}

.answer-border {
    stroke: #d4a000;
    stroke-width: 2;
    fill: none;
}

.answer-grid {
    border-collapse: collapse;
}

.answer-grid td {
    width: 40px;
    height: 40px;
    text-align: center;
    vertical-align: middle;
    border: 1px solid #e0e0e0;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    font-weight: bold;
    position: relative;
    z-index: 5;
    padding: 0;
    box-sizing: border-box;
}

.answer-grid-wrapper {
    position: relative;
    display: inline-block;
    line-height: 0;
}

.answer-key-preview {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.answer-key-preview h2 {
    text-align: center;
    color: #4A90E2;
    margin-bottom: 20px;
}

.answer-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.answer-table thead {
    background-color: #4A90E2;
    color: white;
}

.answer-table th,
.answer-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.answer-table tbody tr:hover {
    background-color: #f5f5f5;
}

.answer-table .word {
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

.answer-table .location {
    font-family: monospace;
    font-size: 14px;
}

.answer-table .direction {
    color: #666;
}

/* Print Styles */
@media print {
    body {
        background-color: white;
    }
    
    header,
    footer,
    .preview-actions {
        display: none;
    }
    
    .puzzle-grid {
        box-shadow: none;
    }
    
    .puzzle-grid td {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
    
    .word-list {
        box-shadow: none;
        page-break-before: avoid;
    }
    
    .answer-key-preview {
        page-break-before: always;
    }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .puzzle-grid td {
        width: 25px;
        height: 25px;
        font-size: 14px;
    }
    
    .word-list ul {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}

/* Print-First Styles for PDF */
.pdf-page {
    width: 100%;
    height: 100%;
    padding: 40px;
    background-color: white;
}

.pdf-title {
    text-align: center;
    font-size: 24px;
    margin-bottom: 30px;
    font-weight: bold;
}

.pdf-grid {
    margin: 0 auto;
    display: table;
}

.pdf-word-list {
    margin-top: 30px;
    column-count: 3;
    column-gap: 20px;
}

.pdf-word-item {
    break-inside: avoid;
    padding: 5px 0;
}
