/* D&D Campaign Wiki Styles */
:root {
    --dnd-burgundy: #8B2332;
    --dnd-gold: #B8860B;
    --dnd-parchment: #F4E8D0;
    --dnd-dark: #2C1810;
    --dnd-border: #8B7355;
    --shadow: rgba(0, 0, 0, 0.2);
}

/* Winter theme variables applied when body[data-theme="winter"] */
body[data-theme="winter"] {
    --dnd-burgundy: #0f5a83;    /* deep winter blue replaces burgundy */
    --dnd-gold: #9fbfdc;        /* muted icy accent */
    --dnd-parchment: #0b0f12;   /* very dark background */
    --dnd-dark: #e6f2fb;        /* light text on dark bg */
    --dnd-border: #16364a;      /* darker blue border */
    --shadow: rgba(0, 0, 0, 0.6);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Crimson Text', serif;
    background: var(--dnd-parchment);
    color: var(--dnd-dark);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Cinzel', serif;
    color: var(--dnd-burgundy);
    margin-bottom: 0.5em;
}

/* Navigation */
.main-nav {
    background: linear-gradient(135deg, var(--dnd-burgundy) 0%, #6B1825 100%);
    padding: 1rem 2rem;
    box-shadow: 0 2px 8px var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* When winter theme is active, adjust nav gradient for cold tones */
body[data-theme="winter"] .main-nav {
    background: linear-gradient(135deg, var(--dnd-burgundy) 0%, #07263a 100%);
}

.nav-brand h1 {
    color: var(--dnd-gold);
    font-size: 1.8rem;
    margin: 0;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--dnd-parchment);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: var(--dnd-gold);
}

/* Main content */
.content {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 2rem auto;
    padding: 2rem;
    background: white;
    box-shadow: 0 0 20px var(--shadow);
    border: 2px solid var(--dnd-border);
}

/* In winter theme, use darker page background */
body[data-theme="winter"] .content {
    background: #071118;
    color: var(--dnd-dark);
    border-color: var(--dnd-border);
}

/* Footer */
.main-footer {
    background: var(--dnd-dark);
    color: var(--dnd-parchment);
    text-align: center;
    padding: 1rem;
    margin-top: auto;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: var(--dnd-burgundy);
    color: white;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    transition: background 0.3s;
}

.btn:hover {
    background: #6B1825;
}

/* Winter button adjustments */
body[data-theme="winter"] .btn {
    color: var(--dnd-dark);
}

.btn-secondary {
    background: var(--dnd-gold);
}

.btn-secondary:hover {
    background: #9A7309;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--dnd-burgundy);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--dnd-border);
    border-radius: 4px;
    font-family: 'Crimson Text', serif;
    font-size: 1rem;
}

.form-group textarea {
    min-height: 150px;
    resize: vertical;
}

/* Cards */
.card {
    background: white;
    border: 2px solid var(--dnd-border);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px var(--shadow);
}

/* Winter card adjustments */
body[data-theme="winter"] .card {
    background: transparent;
    border-color: var(--dnd-border);
    box-shadow: 0 2px 10px rgba(0,0,0,0.6);
}

.card-title {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

/* Messages */
.error {
    background: #f8d7da;
    color: #721c24;
    padding: 1rem;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.success {
    background: #d4edda;
    color: #155724;
    padding: 1rem;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    margin-bottom: 1rem;
}

/* Visibility badges */
.visibility-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

.visibility-public { background: #28a745; color: white; }
.visibility-player { background: #007bff; color: white; }
.visibility-gm { background: var(--dnd-gold); color: white; }
.visibility-admin { background: var(--dnd-burgundy); color: white; }

/* Content blocks */
.content-block {
    position: relative;
    margin: 1.5rem 0;
    padding: 1rem;
    border-left: 3px solid var(--dnd-gold);
}

.content-block[data-visibility="gm"] {
    background: #fff3cd;
    border-left-color: var(--dnd-gold);
}

.content-block[data-visibility="admin"] {
    background: #f8d7da;
    border-left-color: var(--dnd-burgundy);
}

.block-edit-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
}

/* Page type badges */
.badge-wiki { background: #6c757d; color: white; }
.badge-npc { background: #8B2332; color: var(--gold); }
.badge-location { background: #2d5a3d; color: var(--parchment); }
.badge-beast { background: #8b4513; color: var(--parchment); }
.badge-quest { background: var(--gold); color: #2d2d2d; }
.badge-item { background: #4a4a6a; color: var(--gold); }
.badge-player { background: #1a5490; color: white; }
.badge-session { background: #663399; color: white; }

/* Campaigns grid */
.campaigns-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.campaign-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: #666;
}

/* Page cards */
.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.page-card h3 {
    margin-top: 0;
    font-size: 1.1rem;
}

.page-card h3 a {
    color: var(--burgundy);
    text-decoration: none;
}

.page-card h3 a:hover {
    color: var(--gold);
}

.page-excerpt {
    font-size: 0.9rem;
    color: #666;
    margin: 0.5rem 0;
    line-height: 1.5;
}

.page-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: #888;
}

/* Wiki content */
.wiki-content {
    line-height: 1.8;
    font-size: 1rem;
}

.wiki-content h1,
.wiki-content h2,
.wiki-content h3,
.wiki-content h4 {
    color: var(--burgundy);
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.wiki-content h1 { font-size: 2rem; border-bottom: 2px solid var(--gold); padding-bottom: 0.5rem; }
.wiki-content h2 { font-size: 1.5rem; }
.wiki-content h3 { font-size: 1.25rem; }
.wiki-content h4 { font-size: 1.1rem; }

.wiki-content a {
    color: var(--burgundy);
    text-decoration: underline;
}

.wiki-content a:hover {
    color: var(--gold);
}

/* Breadcrumbs */
.breadcrumbs {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 1rem;
}

.breadcrumbs a {
    color: var(--burgundy);
    text-decoration: none;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

/* Page header */
.page-header,
.campaign-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--gold);
}

.page-header h1,
.campaign-header h1 {
    margin: 0.5rem 0;
    color: var(--burgundy);
}

.page-actions {
    margin-top: 1rem;
}

.campaign-description {
    font-size: 1.1rem;
    color: #666;
    margin: 1rem 0;
}

.page-type-section {
    margin: 2rem 0;
}

.page-type-section h2 {
    color: var(--burgundy);
    border-bottom: 1px solid var(--gold);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

/* Block Edit Modal */
#block-edit-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: linear-gradient(135deg, #2a1810 0%, #1a1210 100%);
    border: 2px solid #B8860B;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    padding: 2rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #B8860B;
}

.modal-header h2 {
    color: #B8860B;
    font-family: 'Cinzel', serif;
    margin: 0;
    font-size: 1.8rem;
}

.modal-close {
    background: none;
    border: none;
    color: #B8860B;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(184, 134, 11, 0.2);
    transform: rotate(90deg);
}

#block-edit-form .form-group {
    margin-bottom: 1.5rem;
}

#block-edit-form label {
    display: block;
    color: #B8860B;
    font-weight: bold;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

#block-edit-form input[type="text"],
#block-edit-form textarea,
#block-edit-form select {
    width: 100%;
    padding: 0.75rem;
    background: rgba(26, 18, 16, 0.8);
    border: 1px solid #B8860B;
    border-radius: 4px;
    color: #F4E8D0;
    font-size: 1rem;
    font-family: inherit;
}

#block-edit-form textarea {
    font-family: 'Courier New', monospace;
    line-height: 1.6;
    resize: vertical;
}

#block-edit-form small {
    display: block;
    color: rgba(184, 134, 11, 0.7);
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(184, 134, 11, 0.3);
}

.btn-primary {
    padding: 0.75rem 2rem;
    background: #B8860B;
    color: #1a1210;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: #d4a027;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(184, 134, 11, 0.4);
}

.btn-secondary {
    padding: 0.75rem 2rem;
    background: rgba(139, 35, 50, 0.3);
    color: #F4E8D0;
    border: 1px solid #8B2332;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(139, 35, 50, 0.5);
}

/* Visibility Modal Styles */
.visibility-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.visibility-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(244, 232, 208, 0.05);
    border: 2px solid rgba(184, 134, 11, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.visibility-option:hover {
    background: rgba(244, 232, 208, 0.1);
    border-color: #B8860B;
}

.visibility-option.selected {
    background: rgba(184, 134, 11, 0.2);
    border-color: #B8860B;
    box-shadow: 0 0 12px rgba(184, 134, 11, 0.4);
}

.visibility-option input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.visibility-info {
    flex: 1;
}

.visibility-info strong {
    display: block;
    color: #B8860B;
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
    font-family: 'Cinzel', serif;
}

.visibility-info p {
    margin: 0;
    color: #F4E8D0;
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Visibility Modal Wrapper */
#visibility-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== SPELL INTEGRATION STYLES ===== */

/* Spell Autocomplete */
.spell-autocomplete {
    position: absolute;
    background: white;
    border: 2px solid var(--dnd-border);
    border-radius: 4px;
    box-shadow: 0 4px 12px var(--shadow);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    min-width: 250px;
}

.spell-autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--dnd-parchment);
    transition: background 0.2s;
}

.spell-autocomplete-item:hover {
    background: var(--dnd-parchment);
}

.spell-autocomplete-item:last-child {
    border-bottom: none;
}

.spell-autocomplete-item strong {
    display: block;
    color: var(--dnd-burgundy);
    font-family: 'Cinzel', serif;
    margin-bottom: 0.25rem;
}

.spell-autocomplete-item small {
    color: var(--dnd-dark);
    opacity: 0.7;
    font-size: 0.85rem;
}

.spell-autocomplete-item.no-results {
    cursor: default;
    text-align: center;
    color: var(--dnd-dark);
    opacity: 0.6;
}

.spell-autocomplete-item.no-results:hover {
    background: white;
}

/* Spell Link (hoverable spell names) */
.spell-link {
    color: var(--dnd-burgundy);
    text-decoration: underline;
    text-decoration-style: dotted;
    cursor: help;
    font-weight: 600;
    transition: color 0.2s;
}

.spell-link:hover {
    color: var(--dnd-gold);
}

/* Item Link (hoverable item/weapon names) */
.item-link {
    color: var(--dnd-burgundy);
    text-decoration: underline;
    text-decoration-style: dotted;
    cursor: help;
    font-weight: 600;
    transition: color 0.2s;
}

.item-link:hover {
    color: var(--dnd-gold);
}

/* Monster Link (hoverable monster names) */
.monster-link {
    color: var(--dnd-burgundy);
    text-decoration: underline;
    text-decoration-style: dotted;
    cursor: help;
    font-weight: 600;
    transition: color 0.2s;
}

.monster-link:hover {
    color: var(--dnd-gold);
}

/* Feat Link (hoverable feat/trait names) */
.feat-link {
    color: var(--dnd-burgundy);
    text-decoration: underline;
    text-decoration-style: dotted;
    cursor: help;
    font-weight: 600;
    transition: color 0.2s;
}

.feat-link:hover {
    color: var(--dnd-gold);
}

/* Spell Search Input */
.spell-search {
    position: relative;
}

/* Spell Tooltip (5eTools-style) */
.spell-tooltip {
    position: absolute;
    background: var(--dnd-parchment);
    border: 3px solid var(--dnd-border);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    max-width: 650px;
    width: 650px;
    color: var(--dnd-dark);
    font-size: 0.85rem;
    line-height: 1.4;
    pointer-events: none;
}

.spell-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.spell-tooltip-header h3 {
    font-family: 'Cinzel', serif;
    color: var(--dnd-burgundy);
    font-size: 1.3rem;
    margin: 0;
    flex: 1;
}

.spell-source {
    color: var(--dnd-dark);
    opacity: 0.6;
    font-size: 0.8rem;
    font-style: italic;
    white-space: nowrap;
    margin-left: 1rem;
}

.spell-level-school {
    font-style: italic;
    color: var(--dnd-dark);
    opacity: 0.8;
    margin-bottom: 0.75rem;
}

.spell-stat-block {
    background: rgba(139, 35, 50, 0.05);
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 0.75rem;
}

.spell-stat {
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.spell-stat:last-child {
    margin-bottom: 0;
}

.spell-stat strong {
    color: var(--dnd-burgundy);
    font-family: 'Cinzel', serif;
}

.spell-tooltip hr {
    border: none;
    border-top: 2px solid var(--dnd-border);
    margin: 0.75rem 0;
}

.spell-description p {
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.spell-description p:last-child {
    margin-bottom: 0;
}

/* @-Mention Autocomplete Dropdown */
.mention-dropdown {
    position: absolute;
    background: white;
    border: 2px solid var(--dnd-border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    max-height: 300px;
    overflow-y: auto;
    z-index: 10000;
    min-width: 300px;
    display: none;
}

.mention-item {
    padding: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--dnd-parchment);
    transition: background 0.2s;
}

.mention-item:hover,
.mention-item.selected {
    background: var(--dnd-parchment);
}

.mention-item:last-child {
    border-bottom: none;
}

.mention-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.mention-info {
    flex: 1;
}

.mention-info strong {
    display: block;
    color: var(--dnd-burgundy);
    font-family: 'Cinzel', serif;
    margin-bottom: 0.25rem;
}

.mention-info small {
    color: var(--dnd-dark);
    opacity: 0.7;
    font-size: 0.85rem;
}
}

.spell-higher-levels {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--dnd-border);
    font-style: italic;
}

.spell-higher-levels strong {
    color: var(--dnd-burgundy);
}

.spell-classes {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--dnd-border);
    font-size: 0.85rem;
    color: var(--dnd-dark);
    opacity: 0.8;
}

.spell-classes strong {
    color: var(--dnd-burgundy);
}

/* Print Styles for Character Sheet */
@media print {
    /* Hide everything except character sheet */
    body * {
        visibility: hidden;
    }
    
    #character-sheet,
    #character-sheet * {
        visibility: visible;
    }
    
    #character-sheet {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        display: block !important;
        background: white;
        color: black;
        margin: 0;
        padding: 0.5cm;
    }
    
    /* Optimize for one page */
    @page {
        size: letter;
        margin: 0.5cm;
    }
    
    /* Header compact */
    .sheet-header {
        margin-bottom: 0.3cm !important;
        padding-bottom: 0.2cm !important;
        border-bottom: 2px solid #8B2332 !important;
    }
    
    .sheet-header h2 {
        font-size: 1.5rem !important;
        margin-bottom: 0.1cm !important;
    }
    
    .sheet-header .sheet-row {
        gap: 0.3cm !important;
    }
    
    .sheet-field label {
        font-size: 0.7rem !important;
        margin-bottom: 0.1cm !important;
    }
    
    .sheet-field .sheet-value {
        font-size: 0.9rem !important;
        padding: 0.1cm !important;
    }
    
    /* Ability scores compact */
    .sheet-abilities {
        gap: 0.2cm !important;
        margin-bottom: 0.3cm !important;
    }
    
    .ability-score {
        padding: 0.2cm !important;
    }
    
    .ability-score label {
        font-size: 0.6rem !important;
    }
    
    .ability-score .score {
        font-size: 1.2rem !important;
    }
    
    .ability-score .modifier {
        font-size: 0.8rem !important;
    }
    
    /* Sections compact */
    .sheet-section {
        margin-bottom: 0.3cm !important;
        page-break-inside: avoid;
    }
    
    .sheet-section h3 {
        font-size: 0.9rem !important;
        margin-bottom: 0.2cm !important;
        padding-bottom: 0.1cm !important;
        border-bottom: 1px solid #8B2332 !important;
    }
    
    .sheet-section h4 {
        font-size: 0.8rem !important;
        margin-bottom: 0.15cm !important;
    }
    
    .stat-box {
        padding: 0.1cm !important;
        margin-bottom: 0.1cm !important;
    }
    
    .stat-box label {
        font-size: 0.65rem !important;
    }
    
    .stat-box .value {
        font-size: 0.85rem !important;
    }
    
    /* Tables compact */
    .wiki-table {
        font-size: 0.7rem !important;
        margin-bottom: 0.2cm !important;
    }
    
    .wiki-table th,
    .wiki-table td {
        padding: 0.05cm 0.1cm !important;
        border: 1px solid #ccc !important;
    }
    
    /* Two column layout */
    .sheet-row.two-col {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.3cm !important;
        margin-bottom: 0.3cm !important;
    }
    
    .sheet-row.three-col {
        display: grid !important;
        grid-template-columns: 1fr 1fr 1fr !important;
        gap: 0.2cm !important;
        margin-bottom: 0.3cm !important;
    }
    
    /* Spell list compact */
    .spell-link {
        color: #8B2332 !important;
        text-decoration: none !important;
        cursor: default !important;
    }
    
    /* Remove hover tooltips in print */
    .spell-tooltip {
        display: none !important;
    }
    
    /* Content rendering */
    p, li {
        font-size: 0.75rem !important;
        line-height: 1.3 !important;
        margin-bottom: 0.1cm !important;
    }
    
    strong {
        font-weight: bold !important;
    }
    
    /* Ensure no page breaks in critical sections */
    .sheet-abilities,
    .stat-box,
    table {
        page-break-inside: avoid;
    }
}

