/**
 * Templar Cipher Tool CSS
 * White/Red/Black color scheme with medieval aesthetics
 */

/* Import Templar-appropriate fonts */
@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@400;700;900&family=Cinzel:wght@400;600;700&family=UnifrakturMaguntia&display=swap');

body.templar-theme {
    font-family: 'Cinzel', 'Georgia', serif;
    background-color: #FFFFFF;
    color: #1A1A1A;
}

/* Override common-styles green headings */
body.templar-theme h1,
body.templar-theme h2,
body.templar-theme h3,
body.templar-theme h4,
body.templar-theme h5,
body.templar-theme h6 {
    color: #1A1A1A;
    text-shadow: 2px 2px 4px rgba(139, 0, 0, 0.15);
}

/* ============================================
   TEMPLAR-THEMED SITE HEADER OVERRIDES
   ============================================ */

/* Templar Rain Controls - Top Right (FIXED POSITIONING) */
body.templar-theme #matrix-controls,
body.templar-theme .matrix-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999; /* Above everything */
    display: flex;
    gap: 10px;
}

body.templar-theme .matrix-control-btn {
    width: 44px;
    height: 44px;
    background: rgba(245, 245, 220, 0.95);
    border: 2px solid #8B0000;
    color: #8B0000;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2em;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(139, 0, 0, 0.3);
}

body.templar-theme .matrix-control-btn:hover {
    background: rgba(139, 0, 0, 0.1);
    border-color: #DC143C;
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(139, 0, 0, 0.5);
}

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

/* Disabled state */
body.templar-theme .matrix-control-btn.disabled {
    color: #666666;
    border-color: #999999;
    opacity: 0.5;
    cursor: not-allowed;
}

body.templar-theme .matrix-control-btn.disabled:hover {
    transform: none;
    background: rgba(245, 245, 220, 0.95);
    border-color: #999999;
}

/* Site header container - Templar colors - SEPARATE FROM CONTENT */
body.templar-theme .site-header {
    background: rgba(245, 245, 220, 0.95);
    border: 3px solid #8B0000;
    box-shadow: 0 2px 10px rgba(139, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    margin-bottom: 2rem;
    border-radius: 8px;
    padding: 2rem; /* Match tool-container padding */
}

/* Remove padding adjustment that caused border issues */
body.templar-theme .tool-container {
    /* Keep original padding */
}

/* Logo - Black with red glow */
body.templar-theme .site-header-logo a {
    font-family: 'Cinzel Decorative', 'Courier New', monospace;
    color: #1A1A1A;
    text-shadow: 0 0 10px rgba(139, 0, 0, 0.5), 0 0 20px rgba(139, 0, 0, 0.3);
}

body.templar-theme .site-header-logo a:hover {
    color: #8B0000;
    text-shadow: 0 0 15px rgba(139, 0, 0, 0.7), 0 0 30px rgba(139, 0, 0, 0.5);
}

/* Navigation links - Black with red hover */
body.templar-theme .nav-link {
    font-family: 'Cinzel', 'Courier New', monospace;
    color: #1A1A1A;
    border-color: transparent;
}

body.templar-theme .nav-link:hover {
    border-color: #8B0000;
    background: rgba(139, 0, 0, 0.1);
    box-shadow: 0 0 10px rgba(139, 0, 0, 0.3);
    text-shadow: 0 0 5px rgba(139, 0, 0, 0.5);
    color: #8B0000;
}

/* Premium nav styling (if applicable) */
body.templar-theme .nav-link.premium-nav {
    background: linear-gradient(135deg, rgba(139, 0, 0, 0.2), rgba(178, 34, 34, 0.2));
    border-color: #8B0000;
    font-weight: bold;
    color: #8B0000;
}

body.templar-theme .nav-link.premium-nav:hover {
    background: linear-gradient(135deg, rgba(139, 0, 0, 0.3), rgba(178, 34, 34, 0.3));
    box-shadow: 0 0 15px rgba(139, 0, 0, 0.5);
}

/* Mobile menu toggle - Red bars */
body.templar-theme .mobile-menu-toggle span {
    background-color: #8B0000;
}

body.templar-theme .mobile-menu-toggle:hover span {
    background-color: #B22222;
}

/* Mobile menu open state */
body.templar-theme .site-header-nav.mobile-open {
    background: rgba(245, 245, 220, 0.98);
    border: 2px solid #8B0000;
    box-shadow: 0 4px 20px rgba(139, 0, 0, 0.3);
}

@media (max-width: 768px) {
    body.templar-theme .site-header-nav.mobile-open .nav-link {
        border-bottom: 1px solid rgba(139, 0, 0, 0.2);
    }
    
    body.templar-theme .site-header-nav.mobile-open .nav-link:last-child {
        border-bottom: none;
    }
}

/* ============================================
   TEMPLAR-THEMED CONSOLE OVERRIDES
   ============================================ */

/* Console container */
body.templar-theme #consoleContainer {
    border-color: #8B0000;
}

body.templar-theme .console-box {
    background: rgba(245, 245, 220, 0.98);
    border: 3px solid #8B0000;
    box-shadow: 0 4px 20px rgba(139, 0, 0, 0.5);
}

/* Console header */
body.templar-theme .console-header {
    background: linear-gradient(135deg, #8B0000, #B22222);
    border-bottom: 2px solid #5A0000;
}

body.templar-theme .console-title {
    color: #FFFFFF;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* Console buttons */
body.templar-theme .console-toggle,
body.templar-theme .console-close {
    color: #FFFFFF;
    border-color: rgba(255, 255, 255, 0.3);
}

body.templar-theme .console-toggle:hover,
body.templar-theme .console-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: #FFFFFF;
}

/* Console output */
body.templar-theme .console-output {
    background: rgba(255, 255, 255, 0.95);
    color: #1A1A1A;
}

/* Console lines - different types */
body.templar-theme .console-line.command {
    color: #8B0000;
    font-weight: bold;
}

body.templar-theme .console-line.success {
    color: #006400; /* Dark green for success */
}

body.templar-theme .console-line.error {
    color: #DC143C;
    font-weight: bold;
}

body.templar-theme .console-line.info {
    color: #8B4513; /* Saddle brown */
}

body.templar-theme .console-line.help {
    color: #4B0082; /* Indigo */
}

body.templar-theme .console-line.default {
    color: #1A1A1A;
}

/* Console input */
body.templar-theme .console-input-line {
    border-top: 2px solid #8B0000;
    background: rgba(255, 255, 255, 0.95);
}

body.templar-theme .console-prompt {
    color: #8B0000;
    font-weight: bold;
}

body.templar-theme .console-input {
    background: transparent;
    color: #228B22; /* Forest green for typing */
    caret-color: #8B0000;
}

body.templar-theme .console-input::placeholder {
    color: rgba(139, 0, 0, 0.5);
}

body.templar-theme .console-input:focus {
    outline: none;
    box-shadow: 0 0 5px rgba(139, 0, 0, 0.3);
}

/* Scrollbar in console */
body.templar-theme .console-output::-webkit-scrollbar {
    width: 8px;
}

body.templar-theme .console-output::-webkit-scrollbar-track {
    background: rgba(245, 245, 220, 0.5);
}

body.templar-theme .console-output::-webkit-scrollbar-thumb {
    background: #8B0000;
    border-radius: 4px;
}

body.templar-theme .console-output::-webkit-scrollbar-thumb:hover {
    background: #B22222;
}

/* Minimized console */
body.templar-theme .console-box.minimized .console-header {
    background: linear-gradient(135deg, #8B0000, #B22222);
}

/* Mobile console adjustments */
@media (max-width: 768px) {
    body.templar-theme .console-box {
        border-width: 2px;
    }
}

/* Main container */
.tool-container {
    max-width: calc(1200px + 4rem + 6px); /* content + padding + border */
    margin: 2rem auto;
    padding: 2rem;
    background-color: rgba(245, 245, 220, 0.95);
    border: 3px solid #8B0000;
    border-radius: 8px;
    box-shadow: 
        0 0 20px rgba(139, 0, 0, 0.3),
        inset 0 0 40px rgba(139, 0, 0, 0.05);
    position: relative;
    box-sizing: border-box;
}

/* Header wrapper - exact same width as tool-container */
.header-wrapper {
    max-width: calc(1200px + 4rem + 6px); /* content + padding + border */
    margin: 2rem auto 0 auto;
    padding: 0;
}

/* Site header inside wrapper - match tool-container exactly */
.header-wrapper .site-header {
    margin: 0;
    padding: 2rem;
    box-sizing: border-box;
}

/* Decorative corner elements */
.tool-container::before,
.tool-container::after {
    content: '✠';
    position: absolute;
    font-size: 2rem;
    color: #8B0000;
    font-family: 'Cinzel Decorative', serif;
}

.tool-container::before {
    top: -15px;
    left: -15px;
}

.tool-container::after {
    bottom: -15px;
    right: -15px;
}

/* Headers */
h1, h2, h3 {
    font-family: 'Cinzel Decorative', 'Georgia', serif;
    color: #1A1A1A;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(139, 0, 0, 0.15);
}

h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    letter-spacing: 2px;
    border-bottom: 3px double #8B0000;
    padding-bottom: 1rem;
}

h1::before,
h1::after {
    content: '✠';
    margin: 0 1rem;
    font-size: 2.5rem;
    color: #8B0000;
}

h2 {
    font-size: 2rem;
    margin: 2rem 0 1rem 0;
    color: #1A1A1A;
}

h3 {
    font-size: 1.5rem;
    margin: 1.5rem 0 0.75rem 0;
    color: #1A1A1A;
}

/* Description text */
.tool-description {
    text-align: center;
    font-size: 1.1rem;
    color: #333333;
    margin: 1rem 0 2rem 0;
    font-style: italic;
    line-height: 1.6;
}

/* Cipher grid display */
.cipher-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
    padding: 2rem;
    background-color: #FFFFFF;
    border: 2px solid #8B0000;
    border-radius: 8px;
}

.grid-section {
    text-align: center;
    padding: 1rem;
    background-color: rgba(245, 245, 220, 0.5);
    border: 1px solid #DC143C;
    border-radius: 4px;
}

.grid-section h4 {
    font-family: 'Cinzel Decorative', serif;
    color: #1A1A1A;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.pigpen-grid {
    display: inline-grid;
    grid-template-columns: repeat(3, 60px);
    grid-template-rows: repeat(3, 60px);
    gap: 4px;
    margin: 1rem auto;
}

.pigpen-cell {
    width: 60px;
    height: 60px;
    border: 2px solid #8B0000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    color: #1A1A1A;
    background-color: #FFFFFF;
    position: relative;
}

.pigpen-cell::after {
    content: attr(data-symbol);
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 0.7rem;
    color: #8B0000;
}

/* X-grid styling */
.x-grid {
    display: inline-grid;
    grid-template-columns: repeat(2, 60px);
    grid-template-rows: repeat(2, 60px);
    gap: 4px;
    margin: 1rem auto;
    transform: rotate(45deg);
}

.x-grid .pigpen-cell {
    border-radius: 4px;
}

/* Input/Output sections */
.input-section,
.output-section {
    margin: 2rem 0;
    padding: 1.5rem;
    background-color: #FFFFFF;
    border: 2px solid #8B0000;
    border-radius: 8px;
    box-shadow: inset 0 0 10px rgba(139, 0, 0, 0.1);
}

.section-label {
    font-family: 'Cinzel Decorative', serif;
    font-size: 1.3rem;
    color: #1A1A1A;
    margin-bottom: 0.75rem;
    display: block;
    text-transform: uppercase;
    letter-spacing: 1px;
}

textarea,
input[type="text"] {
    width: 100%;
    padding: 1rem;
    font-family: 'Cinzel', 'Courier New', monospace;
    font-size: 1.1rem;
    background-color: rgba(245, 245, 220, 0.8);
    color: #1A1A1A;
    border: 2px solid #8B0000;
    border-radius: 4px;
    resize: vertical;
    min-height: 120px;
}

textarea:focus,
input[type="text"]:focus {
    outline: none;
    border-color: #DC143C;
    box-shadow: 0 0 10px rgba(220, 20, 60, 0.3);
}

/* ============================================
   TEMPLAR SYMBOL KEYBOARD
   ============================================ */

.templar-keyboard {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background-color: #FFFFFF;
    border: 2px solid #8B0000;
    border-radius: 8px;
    box-shadow: inset 0 0 10px rgba(139, 0, 0, 0.1);
}

.keyboard-label {
    font-family: 'Cinzel Decorative', serif;
    font-size: 1.2rem;
    color: #8B0000;
    text-align: center;
    margin-bottom: 1rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.keyboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 0.5rem;
    max-width: 100%;
}

.symbol-key {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 0.5rem;
    background-color: rgba(245, 245, 220, 0.8);
    border: 2px solid #8B0000;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 70px;
    font-family: 'Cinzel', serif;
}

.symbol-key:hover {
    background-color: rgba(139, 0, 0, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(139, 0, 0, 0.2);
    border-color: #DC143C;
}

.symbol-key:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(139, 0, 0, 0.2);
    background-color: rgba(139, 0, 0, 0.2);
}

.symbol-key .symbol {
    font-size: 1.5rem;
    color: #8B0000;
    margin-bottom: 0.25rem;
    font-weight: bold;
    line-height: 1;
}

.symbol-key .letter {
    font-size: 0.75rem;
    color: #1A1A1A;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Special keys */
.space-key {
    grid-column: span 2;
    background-color: rgba(220, 20, 60, 0.1);
}

.space-key .symbol {
    font-size: 1rem;
    color: #1A1A1A;
}

.backspace-key {
    background-color: rgba(178, 34, 34, 0.1);
}

.backspace-key .symbol {
    font-size: 1.8rem;
    color: #B22222;
}

.backspace-key:hover {
    background-color: rgba(178, 34, 34, 0.2);
}

/* Keyboard pressed state animation */
@keyframes keyPress {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

.symbol-key.pressed {
    animation: keyPress 0.1s ease;
    background-color: rgba(139, 0, 0, 0.3);
}

/* Mobile responsive keyboard */
@media (max-width: 768px) {
    .keyboard-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 0.4rem;
    }
    
    .symbol-key {
        min-height: 60px;
        padding: 0.5rem 0.25rem;
    }
    
    .symbol-key .symbol {
        font-size: 1.2rem;
    }
    
    .symbol-key .letter {
        font-size: 0.65rem;
    }
    
    .backspace-key .symbol {
        font-size: 1.5rem;
    }
}

/* Buttons */
.button-group {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

button {
    padding: 0.75rem 2rem;
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    font-weight: 600;
    background-color: #8B0000;
    color: #FFFFFF;
    border: 2px solid #5A0000;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

button:hover {
    background-color: #B22222;
    border-color: #8B0000;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

button.secondary {
    background-color: #FFFFFF;
    color: #8B0000;
    border: 2px solid #8B0000;
}

button.secondary:hover {
    background-color: rgba(139, 0, 0, 0.1);
}

/* Tool button links (styled as buttons) */
a.tool-button {
    display: inline-block;
    padding: 0.75rem 2rem;
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    font-weight: 600;
    background-color: #8B0000;
    color: #FFFFFF;
    border: 2px solid #5A0000;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    text-decoration: none;
    text-align: center;
}

a.tool-button:hover {
    background-color: #B22222;
    border-color: #8B0000;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

a.tool-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

a.tool-button.secondary {
    background-color: #FFFFFF;
    color: #8B0000;
    border: 2px solid #8B0000;
}

a.tool-button.secondary:hover {
    background-color: rgba(139, 0, 0, 0.1);
}

/* Output display */
.output-display {
    font-family: 'Cinzel', 'Courier New', monospace;
    font-size: 1.2rem;
    padding: 1.5rem;
    background-color: rgba(245, 245, 220, 0.8);
    border: 2px solid #8B0000;
    border-radius: 4px;
    min-height: 120px;
    word-wrap: break-word;
    color: #1A1A1A;
    line-height: 1.8;
    letter-spacing: 1px;
}

/* Historical context section */
.historical-context {
    margin: 3rem 0;
    padding: 2rem;
    background-color: rgba(255, 255, 255, 0.95);
    border: 3px double #8B0000;
    border-radius: 8px;
}

.historical-context h3 {
    text-align: left;
    border-bottom: 2px solid #DC143C;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.historical-context p {
    line-height: 1.8;
    margin-bottom: 1rem;
    color: #333333;
    text-align: justify;
}

/* Symbol reference table */
.symbol-reference {
    margin: 2rem 0;
    padding: 1.5rem;
    background-color: #FFFFFF;
    border: 2px solid #8B0000;
    border-radius: 8px;
}

.symbol-table {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.symbol-item {
    text-align: center;
    padding: 0.75rem;
    background-color: rgba(245, 245, 220, 0.5);
    border: 1px solid #DC143C;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.symbol-item:hover {
    background-color: rgba(139, 0, 0, 0.1);
    transform: scale(1.05);
}

.symbol-display {
    font-size: 2rem;
    color: #8B0000;
    margin-bottom: 0.5rem;
    font-family: 'Cinzel Decorative', serif;
}

.symbol-letter {
    font-size: 1rem;
    color: #1A1A1A;
    font-weight: 600;
}

/* Loading animation */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #8B0000;
    border-top-color: transparent;
    border-radius: 50%;
    animation: templar-spin 1s linear infinite;
}

@keyframes templar-spin {
    to { transform: rotate(360deg); }
}

/* Responsive design */
@media (max-width: 768px) {
    .tool-container {
        margin: 1rem;
        padding: 1rem;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    h1::before,
    h1::after {
        font-size: 1.5rem;
        margin: 0 0.5rem;
    }
    
    .cipher-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1rem;
    }
    
    .pigpen-grid {
        grid-template-columns: repeat(3, 50px);
        grid-template-rows: repeat(3, 50px);
    }
    
    .pigpen-cell {
        width: 50px;
        height: 50px;
        font-size: 1rem;
    }
    
    .x-grid {
        grid-template-columns: repeat(2, 50px);
        grid-template-rows: repeat(2, 50px);
    }
    
    .button-group {
        flex-direction: column;
    }
    
    button {
        width: 100%;
    }
}

/* Print styles */
@media print {
    body.templar-theme {
        background-color: #FFFFFF;
    }
    
    #templarRain,
    .tool-container::before,
    .tool-container::after,
    body.templar-theme::before,
    body.templar-theme::after {
        display: none;
    }
    
    .tool-container {
        box-shadow: none;
        border: 2px solid #000000;
    }
}

/* ============================================
   HISTORICAL DISCLAIMER BOX
   ============================================ */

.disclaimer-box {
    background: rgba(220, 20, 60, 0.1);
    border: 2px solid #DC143C;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.disclaimer-box h4 {
    color: #DC143C;
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.disclaimer-box p {
    margin: 0;
    color: #1A1A1A;
    line-height: 1.6;
}

.disclaimer-box strong {
    color: #DC143C;
}

.disclaimer-box em {
    font-weight: 600;
    color: #8B0000;
    font-style: italic;
}

/* Historical context section enhancements */
.historical-context h4 {
    color: #8B0000;
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    border-bottom: 2px solid rgba(139, 0, 0, 0.3);
    padding-bottom: 0.5rem;
}

.historical-context ul {
    list-style: none;
    padding-left: 1.5rem;
    margin: 1rem 0;
}

.historical-context ul li {
    position: relative;
    margin: 0.75rem 0;
    padding-left: 1.5rem;
}

.historical-context ul li:before {
    content: "✠";
    position: absolute;
    left: 0;
    color: #8B0000;
    font-weight: bold;
}

.historical-context code {
    background: rgba(139, 0, 0, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: #8B0000;
}

@media (max-width: 768px) {
    .disclaimer-box {
        padding: 1rem;
    }
    
    .disclaimer-box h4 {
        font-size: 1rem;
    }
    
    .historical-context h4 {
        font-size: 1rem;
    }
}