/**
 * Spell Highlighter Styles
 *
 * Visual styles for spelling/grammar error highlighting in quiz textareas
 * Part of F-030 Enhanced Quiz System - Quality Validation Layer
 */

/* ===== HIGHLIGHT CONTAINER ===== */

.spell-highlight-container {
    position: relative;
    display: block;
    width: 100%;
}

.spell-highlight-container textarea {
    position: relative;
    z-index: 2;
    background: rgba(26, 34, 45, 0.6); /* Semi-transparent to show underlines */
    color: var(--text-primary, #e2e8f0); /* Keep text visible */
    caret-color: var(--text-primary, #e2e8f0); /* Ensure cursor is visible */
}

/* ===== OVERLAY ===== */

.spell-highlight-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    pointer-events: none;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-primary, #e2e8f0); /* Make text visible */
    z-index: 1; /* Behind textarea */
    background: var(--bg-secondary, #1a222d); /* Solid background */
    padding: inherit;
    margin: 0;
    border: 1px solid transparent;
    border-radius: inherit;
    font: inherit;
    line-height: inherit;
    letter-spacing: inherit;
    word-spacing: inherit;
}

/* ===== ERROR HIGHLIGHTING ===== */

.spell-error {
    position: relative;
    display: inline;
    color: inherit; /* Inherit text color from parent */
}

/* Spelling errors - red wavy underline */
.spell-error-spelling {
    text-decoration: underline wavy #ff5555;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    background-color: rgba(255, 85, 85, 0.1); /* Subtle red highlight */
}

/* Typo errors - red dotted underline */
.spell-error-typo {
    text-decoration: underline dotted #ff4444;
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
}

/* Grammar errors - blue wavy underline */
.spell-error-grammar {
    text-decoration: underline wavy #4444ff;
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
}

/* ===== FALLBACK FOR OLDER BROWSERS ===== */

@supports not (text-decoration: underline wavy) {
    .spell-error-spelling,
    .spell-error-typo {
        border-bottom: 2px solid #ff4444;
    }

    .spell-error-grammar {
        border-bottom: 2px solid #4444ff;
    }
}

/* ===== TOOLTIP (OPTIONAL ENHANCEMENT) ===== */

.spell-error::before {
    content: attr(data-word);
    position: absolute;
    bottom: 100%;
    left: 0;
    background: rgba(255, 68, 68, 0.95);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 1000;
}

.spell-error:hover::before {
    opacity: 0; /* Disabled by default - enable if needed */
}

/* ===== ACCESSIBILITY ===== */

/* High contrast mode */
@media (prefers-contrast: high) {
    .spell-error-spelling,
    .spell-error-typo {
        text-decoration-color: #ff0000;
        text-decoration-thickness: 3px;
    }

    .spell-error-grammar {
        text-decoration-color: #0000ff;
        text-decoration-thickness: 3px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .spell-error::before {
        transition: none;
    }
}

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

@media print {
    .spell-highlight-overlay {
        display: none;
    }

    .spell-error {
        text-decoration: none;
    }
}
