/* grimoire.css - The Documentation/Help modal */

/* Grimoire Icon Button (next to rule name) */
.rule-info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    padding: 2px 6px;
    margin-left: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    opacity: 0.5;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.rule-info-btn:hover {
    opacity: 1;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transform: scale(1.1);
}

[data-theme="light"] .rule-info-btn {
    color: #64748b;
}

[data-theme="light"] .rule-info-btn:hover {
    color: #0f172a;
    background: #f1f5f9;
}

/* Grimoire Overlay (Modal Container) */
.grimoire-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 1100; /* Higher than config modal (1000) */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
    animation: grimoireFadeIn 0.3s ease;
}

@keyframes grimoireFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Grimoire Content Container */
.grimoire-content {
    background: linear-gradient(135deg, #1e1b2e 0%, #2d1b3d 100%);
    border-radius: 16px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 
                0 0 40px rgba(168, 85, 247, 0.2),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(168, 85, 247, 0.3);
    width: 100%;
    max-width: 1100px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: grimoireUnfurl 0.4s ease;
}

@keyframes grimoireUnfurl {
    from {
        transform: scale(0.9) translateY(20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* Grimoire Header */
.grimoire-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 2px solid rgba(168, 85, 247, 0.3);
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.1) 0%, rgba(147, 51, 234, 0.05) 100%);
    flex-shrink: 0;
}

.grimoire-header h2 {
    margin: 0;
    color: #fbbf24; /* Gold/Amber */
    font-size: 1.5rem;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

.grimoire-close {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #cbd5e1;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.grimoire-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.3);
}

/* Grimoire Body */
.grimoire-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    color: #e2e8f0; /* Light slate */
    line-height: 1.6;
}

/* Grimoire Sections */
.grimoire-section {
    margin-bottom: 32px;
}

.grimoire-section:last-child {
    margin-bottom: 0;
}

.grimoire-section-title {
    color: #fbbf24; /* Gold/Amber */
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0 0 12px 0;
    text-shadow: 0 0 8px rgba(251, 191, 36, 0.4);
    display: flex;
    align-items: center;
    gap: 8px;
}

.grimoire-section-content {
    color: #e2e8f0;
    font-size: 0.9375rem;
}

.grimoire-section-content p {
    margin: 0 0 12px 0;
}

.grimoire-section-content p:last-child {
    margin-bottom: 0;
}

/* Grimoire Lists */
.grimoire-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.grimoire-list li {
    padding: 8px 0 8px 24px;
    position: relative;
    color: #e2e8f0;
}

.grimoire-list li::before {
    content: '✦';
    position: absolute;
    left: 0;
    color: #fbbf24;
    font-size: 0.875rem;
}

.grimoire-list li:not(:last-child) {
    border-bottom: 1px solid rgba(168, 85, 247, 0.2);
}

/* Code Blocks */
.grimoire-code-block {
    background: #0f172a; /* Dark slate */
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    overflow-x: auto;
    font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    color: #e2e8f0;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
}

.grimoire-code-block code {
    color: #e2e8f0;
    background: transparent;
    padding: 0;
    border: none;
}

/* Inline Code */
.grimoire-inline-code {
    background: rgba(168, 85, 247, 0.2);
    border: 1px solid rgba(168, 85, 247, 0.4);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
    font-size: 0.875em;
    color: #d8b4fe; /* Light purple */
}

/* --- Light Mode Grimoire Overrides --- */

/* 1. Main Container: Clean White Parchment */
[data-theme="light"] .grimoire-content {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.25);
    color: #1e293b; /* Dark Slate Text */
}

/* 2. Header: Subtle Light Gray/Purple */
[data-theme="light"] .grimoire-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

[data-theme="light"] #grimoire-title {
    color: #4c1d95; /* Deep Violet (instead of Gold) */
    text-shadow: none; /* Remove the magical glow */
}

/* 3. Section Headers (Why This Matters, etc) */
[data-theme="light"] .grimoire-section-title {
    color: #d97706; /* Dark Amber (Readable Orange) */
    text-shadow: none;
}

/* 4. Body Text */
[data-theme="light"] .grimoire-section-content {
    color: #334155; /* Slate 700 */
}

[data-theme="light"] .grimoire-list li {
    color: #334155;
}

[data-theme="light"] .grimoire-list li::before {
    color: #d97706; /* Dark Amber to match section titles */
}

[data-theme="light"] .grimoire-list li:not(:last-child) {
    border-bottom: 1px solid #e2e8f0;
}

/* 5. Code Blocks: KEEP DARK (Best Contrast) */
/* We keep the code dark because syntax highlighting is designed for it */
[data-theme="light"] .grimoire-code-block {
    background-color: #1e293b !important; /* Dark Slate */
    border: 1px solid #334155;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.2);
}

[data-theme="light"] .grimoire-code-block code {
    color: #e2e8f0; /* Light text inside code block */
}

/* 6. Inline Code (`var`): Purple Pill */
[data-theme="light"] .grimoire-inline-code {
    background-color: #f3e8ff;
    color: #6b21a8;
    border: 1px solid #d8b4fe;
    box-shadow: none;
}

/* 7. Close Button */
[data-theme="light"] .grimoire-close {
    color: #64748b;
    background: transparent;
}

[data-theme="light"] .grimoire-close:hover {
    background: #f1f5f9;
    color: #ef4444;
}

/* --- Grimoire Index View Styles --- */

.grimoire-index-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Search Bar */
.grimoire-search-container {
    margin-bottom: 8px;
}

.grimoire-search-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid rgba(168, 85, 247, 0.3);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.5);
    color: #e2e8f0;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
}

.grimoire-search-input:focus {
    outline: none;
    border-color: rgba(168, 85, 247, 0.6);
    background: rgba(15, 23, 42, 0.7);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.2);
}

.grimoire-search-input::placeholder {
    color: rgba(226, 232, 240, 0.5);
}

/* Rules Grid */
.grimoire-rules-grid {
    display: flex;
    flex-direction: column;
    gap: 32px;
    /* Remove max-height and overflow - let .grimoire-body handle scrolling */
}

/* Category Groups */
.grimoire-category-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.grimoire-category-title {
    color: #fbbf24;
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0;
    text-shadow: 0 0 8px rgba(251, 191, 36, 0.4);
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(168, 85, 247, 0.3);
}

.grimoire-category-rules {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
}

/* Rule Cards */
.grimoire-rule-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.grimoire-rule-card:hover {
    background: rgba(15, 23, 42, 0.8);
    border-color: rgba(168, 85, 247, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}

.grimoire-rule-card-name {
    color: #d8b4fe;
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.grimoire-rule-card-description {
    color: #cbd5e1;
    font-size: 0.875rem;
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Empty State */
.grimoire-empty-state {
    text-align: center;
    color: #94a3b8;
    padding: 40px 20px;
    font-size: 1rem;
}

/* Back Button in Header */
#grimoire-back-btn {
    cursor: pointer;
    color: #cbd5e1;
    transition: color 0.2s ease;
    user-select: none;
}

#grimoire-back-btn:hover {
    color: #fbbf24;
}

/* --- Light Mode Index View Overrides --- */

[data-theme="light"] .grimoire-search-input {
    background: #ffffff;
    border: 2px solid #cbd5e1;
    color: #1e293b;
}

[data-theme="light"] .grimoire-search-input:focus {
    border-color: #9333ea;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.1);
}

[data-theme="light"] .grimoire-search-input::placeholder {
    color: #94a3b8;
}

[data-theme="light"] .grimoire-category-title {
    color: #d97706;
    text-shadow: none;
    border-bottom-color: #e2e8f0;
}

/* =========================================
   LIGHT MODE: GRIMOIRE INDEX CARDS
   ========================================= */

/* 1. The Card Base: "Clean Parchment" Feel */
[data-theme="light"] .grimoire-rule-card {
    background: #ffffff;
    border: 1px solid #e2e8f0; /* Slate-200: Subtle border */
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); /* Soft, diffuse shadow */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

/* 2. Hover Interaction: "Lift & Glow" */
[data-theme="light"] .grimoire-rule-card:hover {
    transform: translateY(-3px); /* Physically lift the card */
    box-shadow: 
        0 12px 20px -5px rgba(0, 0, 0, 0.08), /* Deeper shadow below */
        0 0 0 1px rgba(124, 58, 237, 0.3);    /* Purple ring glow */
    border-color: #a78bfa; /* Purple-400 */
}

/* 3. The Title (Rule Name): Professional Violet */
[data-theme="light"] .grimoire-rule-card-name {
    color: #4c1d95; /* Deep Violet (instead of black) */
    font-weight: 700;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* 4. The Description: Readable Slate */
[data-theme="light"] .grimoire-rule-card-description {
    color: #475569; /* Slate-600 */
    font-size: 0.9rem;
    line-height: 1.5;
}

/* 5. A Subtle "Magical Accent" */
/* Adds a tiny purple bar at the top of the card on hover */
[data-theme="light"] .grimoire-rule-card::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #7c3aed, #c084fc); /* Purple gradient */
    opacity: 0;
    transition: opacity 0.2s ease;
}

[data-theme="light"] .grimoire-rule-card:hover::after {
    opacity: 1;
}

[data-theme="light"] .grimoire-empty-state {
    color: #64748b;
}

[data-theme="light"] #grimoire-back-btn {
    color: #64748b;
}

[data-theme="light"] #grimoire-back-btn:hover {
    color: #d97706;
}

