/**
 * Substitution Cipher Solver - Styles
 * Location: assets/css/substitution-solver.css
 * Updated: Caesar-style header, rain toggles, mobile-friendly
 * Matrix Portal theme with interactive cryptanalysis workshop
 * NO INLINE STYLES - CSP Compliant
 */

/* ========================================
   MATRIX RAIN CONTROLS
   ======================================== */

#matrix {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.3;
}

#matrix-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    gap: 10px;
    flex-direction: column;
}

.matrix-control-btn {
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #0ff;
    border-radius: 50%;
    color: #0ff;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

.matrix-control-btn:hover {
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
    transform: scale(1.1);
}

.matrix-control-btn:active {
    transform: scale(0.95);
}

/* ========================================
   HIDDEN ELEMENTS
   ======================================== */

/* Hidden elements - for JavaScript-controlled visibility */
.hidden {
    display: none !important;
}

/* ========================================
   TOOL CONTAINER
   ======================================== */

.tool-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 30px 20px;
    position: relative;
    z-index: 10;
}

/* ========================================
   HEADER - CAESAR CIPHER STYLE
   ======================================== */

.tool-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 40px 20px;
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #0ff;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
}

.tool-header h1 {
    margin: 0 0 15px 0;
    font-size: 48px;
    color: #0ff;
    text-shadow: 0 0 10px #0ff, 0 0 20px #0ff;
    font-weight: bold;
    letter-spacing: 2px;
    animation: glitch-skew 2s infinite;
}

/* Glitch Effect for Title */
@keyframes glitch-skew {
    0% { transform: skew(0deg); }
    10% { transform: skew(-1deg); }
    20% { transform: skew(1deg); }
    30% { transform: skew(0deg); }
    100% { transform: skew(0deg); }
}

.tool-subtitle {
    font-size: 18px;
    color: #0f0;
    margin: 10px 0;
    font-style: italic;
}

.tool-badge {
    display: inline-block;
    margin-top: 15px;
    padding: 8px 20px;
    background: linear-gradient(135deg, #0f0, #0a0);
    border-radius: 20px;
    font-size: 14px;
    color: #000;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ========================================
   BREADCRUMB NAVIGATION
   ======================================== */

.breadcrumb {
    margin-bottom: 20px;
    padding: 12px 20px;
    background: rgba(0, 20, 0, 0.6);
    border: 1px solid #0f0;
    border-radius: 5px;
    font-size: 0.95em;
}

.breadcrumb a {
    color: #0ff;
    text-decoration: none;
    transition: all 0.3s;
}

.breadcrumb a:hover {
    color: #0f0;
    text-shadow: 0 0 5px #0f0;
}

.breadcrumb span {
    color: #0f0;
}

/* ========================================
   TOOL DESCRIPTION
   ======================================== */

.tool-description {
    background: rgba(0, 20, 0, 0.7);
    border: 1px solid #0f0;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
    line-height: 1.6;
}

.tool-description h2 {
    color: #0f0;
    margin-top: 0;
    font-size: 1.8em;
}

.feature-highlights {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.feature-item {
    background: rgba(0, 255, 0, 0.05);
    padding: 12px 15px;
    border-left: 3px solid #0f0;
    color: #0ff;
    font-size: 0.95em;
}

/* ========================================
   QUICK START GUIDE
   ======================================== */

.quick-start {
    background: rgba(0, 20, 0, 0.7);
    border: 1px solid #0ff;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
}

.quick-start h2 {
    color: #0ff;
    margin-top: 0;
}

.start-steps {
    margin: 20px 0 0 30px;
    padding: 0;
    color: #0f0;
}

.start-steps li {
    margin-bottom: 12px;
    line-height: 1.6;
}

.start-steps strong {
    color: #0ff;
}

/* ========================================
   TOOL WORKSPACE
   ======================================== */

.tool-workspace {
    background: rgba(0, 20, 0, 0.8);
    border: 2px solid #0f0;
    border-radius: 10px;
    padding: 30px;
    margin-bottom: 30px;
}

/* ========================================
   INPUT SECTION
   ======================================== */

.input-section {
    margin-bottom: 30px;
}

.input-section h3 {
    color: #0f0;
    margin-bottom: 15px;
    font-size: 1.5em;
}

.cipher-input {
    width: 100%;
    min-height: 180px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #0f0;
    border-radius: 8px;
    color: #0f0;
    font-family: 'Courier New', monospace;
    font-size: 1em;
    resize: vertical;
    transition: all 0.3s;
}

.cipher-input:focus {
    outline: none;
    border-color: #0ff;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

.cipher-input::placeholder {
    color: rgba(0, 255, 0, 0.4);
}

.input-info {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 0.9em;
    color: #0ff;
    padding: 0 5px;
    flex-wrap: wrap;
    gap: 10px;
}

.input-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

/* ========================================
   BUTTONS
   ======================================== */

.btn {
    padding: 12px 24px;
    border: 2px solid #0f0;
    border-radius: 5px;
    background: rgba(0, 255, 0, 0.1);
    color: #0f0;
    font-family: 'Courier New', monospace;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn:hover {
    background: rgba(0, 255, 0, 0.2);
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.5);
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: rgba(0, 255, 0, 0.2);
    border-color: #0f0;
    color: #0f0;
    font-weight: bold;
}

.btn-primary:hover {
    background: rgba(0, 255, 0, 0.3);
}

.btn-secondary {
    border-color: #0ff;
    color: #0ff;
}

.btn-secondary:hover {
    background: rgba(0, 255, 255, 0.2);
    border-color: #0ff;
}

.btn-ghost {
    border-color: rgba(0, 255, 0, 0.3);
    color: rgba(0, 255, 0, 0.6);
}

.btn-ghost:hover {
    border-color: #0f0;
    color: #0f0;
}

.btn-icon {
    padding: 8px 16px;
    font-size: 0.9em;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* ========================================
   FREQUENCY SUMMARY
   ======================================== */

.frequency-summary {
    background: rgba(0, 30, 0, 0.7);
    border: 2px solid #0ff;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
}

.frequency-summary h3 {
    color: #0ff;
    margin-top: 0;
}

#frequency-display {
    margin: 20px 0;
    padding: 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    font-family: 'Courier New', monospace;
}

.frequency-bar-container {
    margin-bottom: 8px;
}

.frequency-label {
    display: inline-block;
    width: 60px;
    color: #0f0;
    font-weight: bold;
}

.frequency-bar {
    display: inline-block;
    height: 20px;
    background: linear-gradient(to right, #0f0, #0ff);
    border-radius: 3px;
    margin: 0 10px;
    box-shadow: 0 0 5px rgba(0, 255, 0, 0.5);
}

.frequency-percent {
    color: #0ff;
    font-size: 0.9em;
}

.frequency-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* ========================================
   MAPPING WORKSPACE
   ======================================== */

.mapping-workspace {
    background: rgba(0, 30, 0, 0.7);
    border: 2px solid #0f0;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
}

.mapping-workspace h3 {
    color: #0f0;
    margin-top: 0;
}

.workspace-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.mapping-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 10px;
    margin: 20px 0;
}

.mapping-cell {
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid #0f0;
    border-radius: 8px;
    padding: 12px 8px;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
}

.mapping-cell:hover {
    background: rgba(0, 255, 0, 0.1);
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}

.mapping-cell.mapped {
    border-color: #0ff;
    background: rgba(0, 255, 255, 0.1);
}

.mapping-cell.selected {
    border-color: #ff0;
    background: rgba(255, 255, 0, 0.2);
    box-shadow: 0 0 15px rgba(255, 255, 0, 0.5);
}

.cipher-letter {
    font-size: 1.8em;
    color: #0f0;
    font-weight: bold;
    display: block;
    margin-bottom: 5px;
    font-family: 'Courier New', monospace;
}

.mapping-arrow {
    color: #0ff;
    font-size: 0.9em;
    margin: 3px 0;
}

.plain-letter {
    font-size: 1.5em;
    color: #0ff;
    font-weight: bold;
    display: block;
    min-height: 30px;
    line-height: 30px;
    font-family: 'Courier New', monospace;
}

.plain-letter.empty {
    color: rgba(0, 255, 255, 0.3);
}

.letter-frequency {
    font-size: 0.8em;
    color: #888;
    margin-top: 5px;
    display: block;
}

.mapping-hint {
    background: rgba(255, 255, 0, 0.1);
    border: 1px solid #ff0;
    border-radius: 5px;
    padding: 10px 15px;
    margin-top: 15px;
    color: #ff0;
    font-size: 0.9em;
}

/* ========================================
   PREVIEW SECTION
   ======================================== */

.preview-section {
    background: rgba(0, 30, 0, 0.7);
    border: 2px solid #0ff;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
}

.preview-section h3 {
    color: #0ff;
    margin-top: 0;
}

.preview-controls {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.checkbox-label {
    color: #0ff;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

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

.decoded-preview {
    min-height: 150px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #0f0;
    border-radius: 8px;
    color: #0f0;
    font-family: 'Courier New', monospace;
    font-size: 1.1em;
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.unmapped {
    color: #f00;
    font-weight: bold;
}

.potential-word {
    background: rgba(255, 255, 0, 0.2);
    border-radius: 3px;
    padding: 0 3px;
}

.preview-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* ========================================
   WORD HELPER
   ======================================== */

.word-helper {
    background: rgba(0, 30, 0, 0.7);
    border: 2px solid #0f0;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
}

.word-helper h3 {
    color: #0f0;
    margin-top: 0;
}

#word-patterns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.pattern-card {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #0ff;
    border-radius: 8px;
    padding: 15px;
}

.pattern-title {
    color: #0ff;
    font-weight: bold;
    margin-bottom: 10px;
}

.pattern-list {
    color: #0f0;
    font-size: 0.9em;
    line-height: 1.6;
}

.word-pattern-hint {
    color: #0ff;
    font-style: italic;
}

/* ========================================
   KEYWORD EXTRACTION
   ======================================== */

.keyword-section {
    background: rgba(0, 30, 0, 0.7);
    border: 2px solid #ff0;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
}

.keyword-section h3 {
    color: #ff0;
    margin-top: 0;
}

.keyword-description {
    color: #0ff;
    margin-bottom: 20px;
    line-height: 1.6;
}

.keyword-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.keyword-results {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #ff0;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    min-height: 100px;
}

/* No Pattern Detected */
.keyword-no-pattern {
    color: #f00;
    text-align: center;
    padding: 20px;
}

.keyword-no-pattern h4 {
    margin-top: 0;
}

.keyword-hint {
    margin-top: 15px;
    color: #0ff;
}

/* Keyword Found */
.keyword-found {
    background: rgba(255, 255, 0, 0.1);
    border: 2px solid #ff0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
}

.keyword-found-title {
    color: #ff0;
    margin-top: 0;
    text-align: center;
}

.keyword-display {
    font-size: 2em;
    color: #ff0;
    font-weight: bold;
    text-align: center;
    margin: 20px 0;
    letter-spacing: 5px;
    text-shadow: 0 0 10px #ff0;
}

.keyword-alphabet-section {
    margin-top: 20px;
}

.keyword-alphabet-title {
    color: #0ff;
    margin-bottom: 10px;
}

.keyword-alphabet {
    font-family: 'Courier New', monospace;
    color: #0f0;
    background: rgba(0, 0, 0, 0.5);
    padding: 15px;
    border-radius: 5px;
    margin: 15px 0;
    line-height: 1.8;
}

.keyword-confidence {
    color: #0ff;
    font-size: 0.9em;
    margin-top: 10px;
    text-align: center;
}

/* Keyword Explanation */
.keyword-explanation {
    margin-top: 20px;
    padding: 15px;
    background: rgba(0, 255, 255, 0.1);
    border-radius: 5px;
}

.keyword-explanation-title {
    color: #0ff;
}

.keyword-explanation-text {
    color: #0f0;
    margin: 10px 0 0 0;
    line-height: 1.6;
}

/* Keyword Warning */
.keyword-warning {
    margin-top: 15px;
    padding: 15px;
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid #f00;
    border-radius: 5px;
}

.keyword-warning-title {
    color: #f00;
}

.keyword-warning-text {
    color: #0ff;
    margin: 10px 0 0 0;
}

.keyword-warning-list {
    color: #0f0;
    margin: 10px 0 0 20px;
}

/* Keyword Test Result */
.keyword-test-result {
    background: rgba(0, 255, 255, 0.1);
    border: 2px solid #0ff;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.keyword-test-title {
    color: #0ff;
    margin-top: 0;
}

.keyword-test-label {
    color: #ff0;
}

.keyword-decode-section {
    margin: 15px 0;
}

.keyword-decode-result {
    background: rgba(0, 0, 0, 0.6);
    padding: 15px;
    border-radius: 5px;
    margin-top: 10px;
    color: #0f0;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    max-height: 300px;
    overflow-y: auto;
}

.keyword-apply-btn {
    padding: 10px 20px;
    background: rgba(0, 255, 0, 0.2);
    border: 2px solid #0f0;
    border-radius: 5px;
    color: #0f0;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 1em;
    margin-top: 10px;
    transition: all 0.3s ease;
}

.keyword-apply-btn:hover {
    background: rgba(0, 255, 0, 0.3);
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.5);
}

/* Frequency Bar Width via CSS Variable */
.frequency-bar {
    width: var(--bar-width, 0%);
}

/* ========================================
   EDUCATION SECTION
   ======================================== */

.education-section {
    margin-bottom: 40px;
}

.education-section h2 {
    color: #0f0;
    font-size: 2em;
    margin-bottom: 20px;
    text-align: center;
}

.education-card {
    background: rgba(0, 20, 0, 0.7);
    border: 1px solid #0f0;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 20px;
}

.education-card h3 {
    color: #0ff;
    margin-top: 0;
    font-size: 1.5em;
}

.education-card p {
    color: #0f0;
    line-height: 1.8;
    margin-bottom: 15px;
}

.edu-list {
    margin: 15px 0 15px 30px;
    padding: 0;
    color: #0f0;
    line-height: 1.8;
}

.edu-list li {
    margin-bottom: 10px;
}

.edu-list strong {
    color: #0ff;
}

/* ========================================
   CONSOLE SECTION
   ======================================== */

.console-section {
    background: rgba(0, 20, 0, 0.7);
    border: 2px solid #0f0;
    border-radius: 10px;
    padding: 30px;
    margin-bottom: 30px;
}

.console-section h2 {
    color: #0f0;
    margin-top: 0;
}

.console-help {
    margin-top: 20px;
}

.console-help p {
    color: #0ff;
    margin-bottom: 20px;
}

.command-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
}

.command-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #0f0;
    border-radius: 5px;
    transition: all 0.3s;
}

.command-item:hover {
    background: rgba(0, 255, 0, 0.1);
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}

.command-item code {
    color: #0f0;
    font-weight: bold;
    font-size: 0.95em;
}

.command-item span {
    color: #0ff;
    font-size: 0.85em;
}

/* ========================================
   RELATED TOOLS
   ======================================== */

.related-tools {
    margin-bottom: 40px;
}

.related-tools h2 {
    color: #0f0;
    font-size: 2em;
    margin-bottom: 20px;
    text-align: center;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.tool-card {
    background: rgba(0, 20, 0, 0.7);
    border: 2px solid #0f0;
    border-radius: 10px;
    padding: 25px;
    text-decoration: none;
    transition: all 0.3s;
    display: block;
}

.tool-card:hover {
    background: rgba(0, 30, 0, 0.9);
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
    transform: translateY(-5px);
    border-color: #0ff;
}

.tool-card h3 {
    color: #0f0;
    margin: 0 0 10px 0;
    font-size: 1.3em;
}

.tool-card p {
    color: #0ff;
    margin: 0;
    font-size: 0.95em;
    line-height: 1.6;
}

.tool-card-all {
    border-style: dashed;
}

.tool-card-all:hover {
    background: rgba(0, 255, 255, 0.1);
}

/* ========================================
   RESPONSIVE DESIGN - MOBILE FIRST
   ======================================== */

@media (max-width: 768px) {
    /* Matrix Controls - Mobile */
    #matrix-controls {
        top: 10px;
        right: 10px;
        gap: 8px;
    }
    
    .matrix-control-btn {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
    
    /* Header Mobile */
    .tool-header {
        padding: 30px 15px;
    }
    
    .tool-header h1 {
        font-size: 32px;
    }
    
    .tool-subtitle {
        font-size: 14px;
    }
    
    .tool-badge {
        font-size: 12px;
        padding: 6px 15px;
    }
    
    /* Input Actions Mobile */
    .input-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        text-align: center;
    }
    
    /* Mapping Grid Mobile */
    .mapping-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 8px;
    }
    
    .cipher-letter {
        font-size: 1.5em;
    }
    
    .plain-letter {
        font-size: 1.3em;
    }
    
    /* Workspace Controls Mobile */
    .workspace-controls {
        flex-direction: column;
    }
    
    .frequency-actions,
    .preview-actions {
        flex-direction: column;
    }
    
    /* Tool Grid Mobile */
    .tool-grid {
        grid-template-columns: 1fr;
    }
    
    .command-list {
        grid-template-columns: 1fr;
    }
    
    /* Feature Highlights Mobile */
    .feature-highlights {
        grid-template-columns: 1fr;
    }
    
    /* Word Patterns Mobile */
    #word-patterns {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    /* Extra Small Screens */
    .tool-header h1 {
        font-size: 24px;
        letter-spacing: 1px;
    }
    
    .tool-subtitle {
        font-size: 12px;
    }
    
    .mapping-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
        gap: 5px;
    }
    
    .mapping-cell {
        padding: 8px 4px;
    }
    
    .cipher-letter {
        font-size: 1.2em;
    }
    
    .plain-letter {
        font-size: 1em;
        min-height: 20px;
        line-height: 20px;
    }
    
    .letter-frequency {
        font-size: 0.7em;
    }
    
    .decoded-preview {
        font-size: 0.95em;
        padding: 15px;
    }
    
    .tool-container {
        padding: 20px 10px;
    }
}

/* Landscape Mobile Optimization */
@media (max-width: 768px) and (orientation: landscape) {
    .tool-header {
        padding: 25px 15px;
    }
    
    .tool-header h1 {
        font-size: 28px;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .mapping-cell {
        border-width: 1px;
    }
    
    .tool-workspace {
        border-width: 1px;
    }
}

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

@media print {
    .breadcrumb,
    .tool-badge,
    .input-actions,
    .workspace-controls,
    .preview-actions,
    .console-section,
    #matrix-controls {
        display: none;
    }
    
    body {
        background: #fff;
        color: #000;
    }
    
    .tool-header,
    .tool-workspace,
    .education-card {
        border-color: #000;
        background: #fff;
    }
    
    h1, h2, h3, h4, h5, h6 {
        color: #000;
        text-shadow: none;
    }
}