/* ==========================================
   CROSSWORD PAGE STYLES
   ========================================== */

.crossword-page {
    min-height: calc(100vh - 200px);
    background: white;
}

.page-header {
    background: linear-gradient(135deg, #EDE9FE 0%, #CCFBF1 50%, #FFEDD5 100%);
    padding: 3rem 0 2rem;
    text-align: center;
}

.page-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.page-subtitle {
    font-size: 1.125rem;
    color: var(--text-light);
}

.crossword-container {
    padding: 3rem 0;
}

.crossword-grid-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2rem;
    align-items: start;
}

/* ==========================================
   CONTROL PANEL
   ========================================== */

.control-panel {
    background: #F7FAFC;
    padding: 2rem;
    border-radius: 20px;
    position: sticky;
    top: 100px;
}

.control-section {
    margin-bottom: 2rem;
}

.control-section h3 {
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.help-text {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.control-section textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    resize: vertical;
    transition: border-color 0.3s;
}

.control-section textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.word-count {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-top: 0.5rem;
    font-weight: 600;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.95rem;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.control-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.control-actions button {
    width: 100%;
    font-size: 0.95rem;
    padding: 0.75rem 1rem;
}

.share-message {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #D1FAE5;
    border-radius: 10px;
    text-align: center;
    color: #065F46;
    font-weight: 600;
    font-size: 0.9rem;
}

/* ==========================================
   PUZZLE DISPLAY
   ========================================== */

.puzzle-display {
    min-height: 400px;
}

.puzzle-content {
    background: white;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: #F7FAFC;
    border-radius: 20px;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.empty-state p {
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

.example-words {
    text-align: left;
    max-width: 400px;
    margin: 0 auto;
    padding: 1.5rem;
    background: white;
    border-radius: 15px;
}

.example-words p {
    margin-bottom: 0.5rem;
}

.example-words ul {
    margin-top: 0.5rem;
    padding-left: 1.5rem;
}

.example-words li {
    margin-bottom: 0.25rem;
    color: var(--text-light);
}

/* ==========================================
   CROSSWORD WRAPPER
   ========================================== */

.crossword-wrapper {
    background: white;
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
}

.puzzle-header {
    text-align: center;
    margin-bottom: 2rem;
}

.puzzle-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.puzzle-instructions {
    color: var(--text-light);
    font-size: 1rem;
}

/* ==========================================
   CROSSWORD GRID
   ========================================== */

.crossword-main {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.crossword-grid-container {
    display: flex;
    justify-content: center;
}

.crossword-grid {
    display: grid;
    gap: 0;
    border: 2px solid #2D3748;
    width: fit-content;
    margin: 0 auto;
}

.crossword-cell {
    width: 40px;
    height: 40px;
    border: 1px solid #2D3748;
    position: relative;
    font-family: 'Courier New', monospace;
    font-weight: 700;
    font-size: 1.25rem;
}

.crossword-cell-black {
    background: #2D3748;
}

.crossword-cell-white {
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.crossword-cell-number {
    position: absolute;
    top: 2px;
    left: 3px;
    font-size: 0.6rem;
    font-weight: 600;
    color: #2D3748;
}

.crossword-cell-letter {
    color: var(--primary);
    font-size: 1.25rem;
}

/* ==========================================
   CLUES SECTION
   ========================================== */

.crossword-clues {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 2rem;
}

.clues-section {
    background: #F7FAFC;
    padding: 1.5rem;
    border-radius: 15px;
}

.clues-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text);
}

.clues-list {
    list-style-position: inside;
    padding: 0;
}

.clues-list li {
    margin-bottom: 0.75rem;
    color: var(--text);
    line-height: 1.6;
    padding-left: 0.5rem;
}

/* ==========================================
   PRINT STYLES
   ========================================== */

.print-only {
    display: none;
}

@media print {
    /* Hide elements that shouldn't print */
    .nav,
    .page-header,
    .control-panel,
    .footer,
    .no-print {
        display: none !important;
    }
    
    /* Show print-only elements */
    .print-only {
        display: block !important;
    }
    
    /* Homework header styles for print */
    .homework-header {
        display: flex !important;
        justify-content: space-between;
        align-items: flex-start;
        padding: 1rem;
        margin-bottom: 1.5rem;
        border: 2px solid #333;
        border-radius: 8px;
        background: #f8f9fa;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .homework-branding h2 {
        margin: 0 0 0.25rem 0;
        font-size: 1.25rem;
        color: #1a1a1a;
    }
    
    .homework-source {
        margin: 0;
        font-size: 0.75rem;
        color: #666;
    }
    
    .homework-fields {
        display: flex;
        gap: 2rem;
        align-items: center;
    }
    
    .homework-field {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    
    .homework-field label {
        font-weight: 600;
        font-size: 0.9rem;
        color: #333;
        white-space: nowrap;
    }
    
    .homework-field .field-line {
        display: inline-block;
        width: 150px;
        border-bottom: 1px solid #333;
        height: 1px;
    }
    
    /* Reset page layout */
    body {
        background: white;
        margin: 0;
        padding: 0;
    }
    
    .crossword-page {
        min-height: auto;
    }
    
    .crossword-container {
        padding: 0;
    }
    
    .crossword-grid-layout {
        display: block;
    }
    
    .puzzle-display {
        min-height: auto;
    }
    
    .crossword-wrapper {
        box-shadow: none;
        padding: 0;
        border-radius: 0;
        page-break-inside: avoid;
    }
    
    /* Print header with logo and branding */
    .crossword-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1rem 0;
        border-bottom: 2px solid #E5E7EB;
        margin-bottom: 2rem;
    }
    
    .print-logo {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }
    
    .print-logo-icon {
        font-size: 2rem;
    }
    
    .print-logo-text {
        font-size: 1.5rem;
        font-weight: 700;
        color: var(--primary);
    }
    
    .print-url {
        font-size: 1rem;
        font-weight: 600;
        color: var(--text-light);
    }
    
    /* Optimize grid for printing */
    .crossword-grid {
        border: 3px solid #000;
        margin: 0 auto 2rem;
    }
    
    .crossword-cell {
        border: 1px solid #000;
        width: 35px;
        height: 35px;
    }
    
    .crossword-cell-black {
        background: #000;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .crossword-cell-white {
        background: white;
    }
    
    .crossword-cell-number {
        color: #000;
    }
    
    /* Clues section for print */
    .crossword-clues {
        page-break-inside: avoid;
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
    }
    
    .clues-section {
        background: white;
        padding: 0;
        page-break-inside: avoid;
    }
    
    .clues-title {
        font-size: 1.125rem;
        border-bottom: 2px solid #E5E7EB;
        padding-bottom: 0.5rem;
        margin-bottom: 0.75rem;
    }
    
    .clues-list li {
        margin-bottom: 0.5rem;
        font-size: 0.9rem;
        line-height: 1.4;
    }
    
    /* Ensure puzzle fits on one page if possible */
    .puzzle-header {
        margin-bottom: 1.5rem;
    }
    
    .puzzle-title {
        font-size: 1.75rem;
    }
    
    .puzzle-instructions {
        font-size: 0.95rem;
    }
    
    /* Add page break before solution if shown */
    .crossword-cell-letter {
        color: #000;
    }
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */

@media (max-width: 1024px) {
    .crossword-grid-layout {
        grid-template-columns: 1fr;
    }
    
    .control-panel {
        position: static;
        width: 100%;
        max-width: 600px;
        margin: 0 auto 2rem;
    }
    
    .crossword-clues {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .page-title {
        font-size: 2rem;
    }
    
    .crossword-wrapper {
        padding: 1.5rem;
    }
    
    .crossword-grid {
        gap: 0;
        transform: scale(0.9);
        transform-origin: top center;
    }
    
    .crossword-cell {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
    
    .crossword-cell-number {
        font-size: 0.55rem;
    }
    
    .clues-section {
        padding: 1rem;
    }
    
    .clues-title {
        font-size: 1.125rem;
    }
    
    .clues-list li {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 480px) {
    .crossword-wrapper {
        padding: 1rem;
        border-radius: 15px;
    }
    
    .crossword-grid {
        transform: scale(0.75);
    }
    
    .crossword-cell {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }
    
    .puzzle-title {
        font-size: 1.5rem;
    }
    
    .page-title {
        font-size: 1.75rem;
    }
}

/* ==========================================
   UTILITY CLASSES
   ========================================== */

@media print {
    .no-print {
        display: none !important;
    }
}
