/**
 * SG Compendium Frontend Styles
 * Medieval parchment theme inspired by Craft and Conquer rulebook
 */

/* Main Wrapper */
.sgc-compendium-wrapper {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
    font-family: 'Georgia', 'Times New Roman', serif;
}

/* Game Selector */
.sgc-game-selector {
    margin-bottom: 40px;
}

.sgc-selector-title {
    font-size: 28px;
    color: #5c3317;
    margin-bottom: 25px;
    text-align: center;
    font-weight: 600;
    letter-spacing: 1px;
}

/* Game Cards */
.sgc-game-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.sgc-game-card {
    background: #f9f7f1;
    border: 3px solid #d4c5a9;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.sgc-game-card:hover {
    border-color: #8b4513;
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.2);
}

.sgc-game-card.sgc-game-selected {
    border-color: #8b4513;
    background: #fff8e7;
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.3);
}

.sgc-game-card-image {
    width: 100%;
    height: 180px;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 15px;
    background: #e0d8c8;
}

.sgc-game-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sgc-game-card-title {
    font-size: 18px;
    color: #5c3317;
    margin: 0;
    font-weight: 600;
}

/* Dropdown Selector */
.sgc-game-dropdown {
    width: 100%;
    max-width: 400px;
    padding: 12px 15px;
    font-size: 16px;
    border: 2px solid #d4c5a9;
    border-radius: 6px;
    background: #f9f7f1;
    color: #5c3317;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.sgc-game-dropdown:hover,
.sgc-game-dropdown:focus {
    border-color: #8b4513;
    outline: none;
    box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.1);
}

/* Toolbar */
.sgc-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    gap: 20px;
    flex-wrap: wrap;
}

.sgc-search-wrapper {
    position: relative;
    flex: 1;
    max-width: 500px;
}

.sgc-search-input {
    width: 100%;
    padding: 12px 45px 12px 15px;
    font-size: 16px;
    border: 2px solid #d4c5a9;
    border-radius: 6px;
    background: #f9f7f1;
    color: #333;
    font-family: inherit;
    transition: all 0.2s;
}

.sgc-search-input:focus {
    outline: none;
    border-color: #8b4513;
    box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.1);
}

.sgc-search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    pointer-events: none;
}

.sgc-print-btn {
    padding: 12px 20px;
    font-size: 16px;
    background: #8b4513;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.2s;
}

.sgc-print-btn:hover {
    background: #6b3410;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Entries List */
.sgc-entries-list {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* Entry Card */
.sgc-entry-card {
    background: linear-gradient(to bottom, #f9f7f1 0%, #f5f3e7 100%);
    border: 3px solid #d4c5a9;
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.sgc-entry-card:hover {
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
    transform: translateX(5px);
}

.sgc-entry-highlighted {
    border-color: #8b4513;
    background: #fff8e7;
    box-shadow: 0 5px 20px rgba(139, 69, 19, 0.25);
    animation: sgc-pulse 2s ease-in-out;
}

@keyframes sgc-pulse {
    0%, 100% { box-shadow: 0 5px 20px rgba(139, 69, 19, 0.25); }
    50% { box-shadow: 0 8px 30px rgba(139, 69, 19, 0.4); }
}

.sgc-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.sgc-entry-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.sgc-entry-type {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sgc-type-errata {
    background: #ffebee;
    color: #c62828;
}

.sgc-type-clarification {
    background: #e3f2fd;
    color: #1565c0;
}

.sgc-type-faq {
    background: #fff3e0;
    color: #ef6c00;
}

.sgc-type-variant {
    background: #f3e5f5;
    color: #6a1b9a;
}

.sgc-type-future-content {
    background: #e8f5e9;
    color: #2e7d32;
}

.sgc-entry-reference {
    font-size: 14px;
    color: #666;
    font-style: italic;
}

.sgc-share-btn {
    padding: 6px 12px;
    background: transparent;
    border: 2px solid #d4c5a9;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.sgc-share-btn:hover {
    background: #8b4513;
    border-color: #8b4513;
    transform: scale(1.1);
}

.sgc-entry-title {
    font-size: 24px;
    color: #5c3317;
    margin: 0 0 15px 0;
    font-weight: 600;
    line-height: 1.4;
}

.sgc-entry-contributor {
    margin: 0 0 15px 0;
    padding: 10px 15px;
    background: rgba(139, 69, 19, 0.05);
    border-left: 3px solid #8b4513;
    border-radius: 4px;
    font-size: 14px;
}

.sgc-contributor-label {
    color: #6b3410;
    font-weight: 600;
    margin-right: 5px;
}

.sgc-contributor-name {
    color: #5c3317;
    font-weight: 500;
}

.sgc-contributor-link {
    color: #8b4513;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.sgc-contributor-link:hover {
    color: #6b3410;
    text-decoration: underline;
}

.sgc-entry-content {
    font-size: 16px;
    line-height: 1.8;
    color: #333;
}

.sgc-entry-content p {
    margin-bottom: 12px;
}

.sgc-entry-content p:last-child {
    margin-bottom: 0;
}

.sgc-entry-content strong {
    color: #5c3317;
}

/* Search Highlighting */
.sgc-highlight {
    background: #fff59d;
    padding: 2px 0;
    border-radius: 2px;
}

/* History */
.sgc-history-toggle {
    margin-top: 15px;
    padding: 8px 16px;
    background: transparent;
    border: 2px solid #8b4513;
    border-radius: 4px;
    color: #8b4513;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

.sgc-history-toggle:hover {
    background: #8b4513;
    color: #fff;
}

.sgc-entry-history {
    margin-top: 15px;
    padding: 15px;
    background: rgba(212, 197, 169, 0.2);
    border-left: 4px solid #8b4513;
    border-radius: 4px;
}

.sgc-history-item {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #d4c5a9;
}

.sgc-history-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

/* Empty States */
.sgc-empty-state,
.sgc-no-results {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 18px;
}

/* Print Styles */
@media print {
    /* Force visibility on everything first */
    * {
        visibility: visible !important;
    }
    
    /* Hide screen-only elements */
    .sgc-toolbar,
    .sgc-share-btn,
    .sgc-history-toggle,
    .sgc-game-selector,
    .screen-only,
    .sgc-filters,
    .sgc-header-actions,
    .sgc-share,
    .sgc-actions,
    .sgc-types,
    .sgc-search {
        display: none !important;
        visibility: hidden !important;
    }
    
    /* Show print-only elements */
    .print-only {
        display: block !important;
        visibility: visible !important;
    }
    
    /* Force wrapper and content visibility */
    .sgc-compendium-wrapper,
    .sgc-compendium,
    .sgc-content,
    .sgc-entries-list,
    .sgc-entries,
    .sgc-entry-card,
    .sgc-entry {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    /* Reset page */
    html, body {
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
        color: black !important;
    }
    
    .sgc-compendium-wrapper,
    .sgc-compendium {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 20pt !important;
    }
    
    /* Print title styles */
    .print-title,
    .sgc-print-title {
        font-size: 20pt !important;
        font-weight: bold !important;
        margin: 0 0 20pt 0 !important;
        padding-bottom: 10pt !important;
        border-bottom: 2pt solid black !important;
        color: black !important;
        text-align: left !important;
    }
    
    /* Entry cards for print */
    .sgc-entry-card,
    .sgc-entry {
        break-inside: avoid !important;
        page-break-inside: avoid !important;
        margin-bottom: 15pt !important;
        padding: 10pt !important;
        border: 1pt solid #999 !important;
        box-shadow: none !important;
        background: white !important;
    }
    
    .sgc-entry-header {
        margin-bottom: 5pt !important;
        display: block !important;
    }
    
    .sgc-entry-meta,
    .sgc-meta {
        font-size: 9pt !important;
        color: #666 !important;
        display: block !important;
        margin-bottom: 5pt !important;
    }
    
    .sgc-entry-type,
    .sgc-badge {
        display: inline-block !important;
        padding: 2pt 6pt !important;
        font-size: 8pt !important;
        border: 1pt solid #999 !important;
        background: #f5f5f5 !important;
        color: black !important;
        margin-right: 8pt !important;
    }
    
    .sgc-entry-reference,
    .sgc-ref {
        font-size: 9pt !important;
        color: #666 !important;
    }
    
    .sgc-entry-title {
        font-size: 13pt !important;
        font-weight: bold !important;
        margin: 5pt 0 !important;
        color: black !important;
    }
    
    .sgc-entry-contributor,
    .sgc-contributor {
        font-size: 9pt !important;
        font-style: italic !important;
        margin: 5pt 0 !important;
        color: #666 !important;
        background: none !important;
        border: none !important;
        padding: 0 !important;
    }
    
    .sgc-entry-content,
    .sgc-text {
        font-size: 10pt !important;
        line-height: 1.4 !important;
        color: black !important;
    }
    
    .sgc-entry-content p,
    .sgc-text p {
        margin: 0 0 8pt 0 !important;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .sgc-compendium-wrapper {
        padding: 0 15px;
    }
    
    .sgc-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .sgc-search-wrapper {
        max-width: 100%;
    }
    
    .sgc-game-cards {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .sgc-entry-title {
        font-size: 20px;
    }
    
    .sgc-entry-content {
        font-size: 15px;
    }
}

/* Print View Specific */
#sgc-print-view {
    padding: 40px;
}

.sgc-print-header {
    text-align: center;
    margin-bottom: 40px;
    border-bottom: 3px solid #8b4513;
    padding-bottom: 20px;
}

.sgc-print-title {
    font-size: 36px;
    color: #5c3317;
    margin: 0 0 10px 0;
}

.sgc-print-game {
    font-size: 24px;
    color: #6b3410;
    margin: 0;
}

.sgc-print-watermark {
    position: fixed;
    bottom: 20px;
    right: 20px;
    pointer-events: none;
}