/* ==========================================================================
   KTaNE Random Rules Manual -- Stylesheet
   ========================================================================== */

:root {
    --bg: #faf8f0;
    --text: #1a1a1a;
    --accent: #c0392b;
    --accent-light: #e74c3c;
    --border: #bbb;
    --header-bg: #2c3e50;
    --header-text: #ecf0f1;
    --section-bg: #fff;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --table-header-bg: #ecf0f1;
    --table-stripe: #f9f9f9;
    --code-bg: #eee;
    --input-bg: #34495e;
    --sidebar-bg: #2c3e50;
    --sidebar-text: #ecf0f1;
    --sidebar-hover: rgba(255, 255, 255, 0.1);
    --sidebar-active: rgba(255, 255, 255, 0.2);
    --link: #0077cc;
}

[data-theme="dark"] {
    --bg: #121212;
    --text: #e0e0e0;
    --accent: #e74c3c;
    --accent-light: #ff6b6b;
    --border: #444;
    --header-bg: #1e1e2e;
    --header-text: #e0e0e0;
    --section-bg: #1e1e1e;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    --table-header-bg: #2a2a2a;
    --table-stripe: #252525;
    --code-bg: #2a2a2a;
    --input-bg: #2a2a3a;
    --sidebar-bg: #1a1a2e;
    --sidebar-text: #ccc;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-active: rgba(231, 76, 60, 0.3);
    --link: #5dade2;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* Header */
header {
    background: var(--header-bg);
    color: var(--header-text);
    padding: 1.5rem 2rem;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
header h1 { font-size: 1.8rem; margin-bottom: 0.3rem; }
.subtitle { opacity: 0.8; font-size: 0.95rem; margin-bottom: 1rem; }

.controls {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.seed-form {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.seed-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.seed-group label { font-weight: 600; font-size: 0.9rem; }

#seedInput {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 1.1rem;
    padding: 0.4rem 0.75rem;
    border: 2px solid #555;
    border-radius: 4px;
    width: 160px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
    background: #34495e;
    color: #ecf0f1;
}
#seedInput::placeholder { color: #7f8c8d; text-transform: none; letter-spacing: normal; }

.btn {
    padding: 0.45rem 1rem;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.15s ease;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-light); }
.btn-secondary { background: #27ae60; color: white; }
.btn-secondary:hover { background: #2ecc71; }
.btn-outline { background: transparent; color: var(--header-text); border-color: var(--header-text); }
.btn-outline:hover { background: rgba(255,255,255,0.1); }

.seed-info {
    margin-top: 0.75rem;
    font-family: 'Consolas', monospace;
    font-size: 0.95rem;
    color: #f39c12;
}

/* Main content */
main.manual { max-width: 900px; margin: 2rem auto; padding: 0 1.5rem; }

.welcome {
    background: var(--section-bg);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.welcome h2 { color: var(--accent); margin-bottom: 1rem; }
.welcome h3 { margin-top: 1.5rem; margin-bottom: 0.5rem; }
.welcome ol { padding-left: 1.5rem; }
.welcome li { margin-bottom: 0.5rem; }
.welcome code { background: var(--code-bg); padding: 0.15rem 0.4rem; border-radius: 3px; font-size: 1rem; }
.welcome a { color: var(--link); text-decoration: none; }
.welcome a:hover { text-decoration: underline; }

/* Navigation Sidebar */
.page-layout { min-height: calc(100vh - 200px); }

.nav-sidebar {
    position: fixed;
    left: 0;
    width: 220px;
    background: var(--sidebar-bg);
    padding: 1rem 0;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    z-index: 100;
}
.nav-sidebar h3 {
    color: var(--accent);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.5rem 1rem;
    margin-bottom: 0.25rem;
}
.nav-sidebar a {
    display: block;
    color: var(--sidebar-text);
    text-decoration: none;
    padding: 0.4rem 1rem;
    font-size: 0.88rem;
    transition: background 0.15s;
    border-left: 3px solid transparent;
}
.nav-sidebar a:hover {
    background: var(--sidebar-hover);
    border-left-color: var(--accent);
}
.nav-sidebar a.active {
    background: var(--sidebar-active);
    border-left-color: var(--accent);
    font-weight: 600;
}

.page-content { min-width: 0; }
.page-layout .page-content { margin-left: 220px; }
.page-layout ~ footer { margin-left: 220px; }

/* Module sections */
.module-section {
    background: var(--section-bg);
    padding: 1.5rem 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    page-break-inside: avoid;
    scroll-margin-top: 12rem;
}
.module-section h2 {
    color: var(--accent);
    font-size: 1.4rem;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 0.4rem;
    margin-bottom: 1rem;
}
.module-section h3 { margin-top: 1.25rem; margin-bottom: 0.5rem; font-size: 1.05rem; }
.module-section ul, .module-section ol { padding-left: 1.5rem; margin-bottom: 0.75rem; }
.module-section li { margin-bottom: 0.35rem; }

/* Tables */
table { width: 100%; border-collapse: collapse; margin: 0.75rem 0; font-size: 0.9rem; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
th, td { border: 1px solid var(--border); padding: 0.4rem 0.6rem; text-align: left; }
th { background: var(--table-header-bg); font-weight: 600; }
tr:nth-child(even) { background: var(--table-stripe); }

/* Simon Says colors */
.simon-red { background: #e74c3c; color: white; font-weight: 600; }
.simon-blue { background: #3498db; color: white; font-weight: 600; }
.simon-green { background: #27ae60; color: white; font-weight: 600; }
.simon-yellow { background: #f1c40f; color: #333; font-weight: 600; }

/* Keypad */
.keypad-columns { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 1rem; }
.keypad-column { border: 1px solid var(--border); border-radius: 6px; padding: 0.75rem; text-align: center; }
.keypad-column h4 { margin-bottom: 0.5rem; color: var(--accent); }
.keypad-symbol { font-size: 1.5rem; margin: 0.25rem 0; }

/* Mazes */
.maze-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.maze-container { text-align: center; }
.maze-container h4 { margin-bottom: 0.5rem; }
.maze-svg { border: 1px solid var(--border); border-radius: 4px; }

/* LED (knobs) */
.led-grid { display: inline-block; background: #222; padding: 4px; border-radius: 4px; }
.led-row { display: flex; gap: 3px; margin: 2px 0; }
.led { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.led-on { background: #2ecc71; box-shadow: 0 0 4px #2ecc71; }
.led-off { background: #444; }

/* Morse columns */
.morse-columns { display: flex; gap: 1.5rem; }
.morse-columns table { flex: 1; }

/* Password grid */
.password-grid td {
    font-family: 'Consolas', monospace;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 2px;
    text-align: center;
}

/* Venn wire table */
.venn-table td:nth-child(-n+4) { text-align: center; width: 60px; }

/* Footer */
footer {
    text-align: center;
    padding: 1.5rem;
    color: #7f8c8d;
    font-size: 0.85rem;
}
footer a { color: var(--link); text-decoration: none; }
footer a:hover { text-decoration: underline; }
footer .credit { margin-top: 0.3rem; }

/* Dark mode toggle */
.theme-toggle {
    background: transparent;
    border: 2px solid var(--header-text);
    color: var(--header-text);
    border-radius: 20px;
    padding: 0.35rem 0.85rem;
    cursor: pointer;
    font-size: 0.88rem;
    transition: all 0.15s;
    white-space: nowrap;
}
.theme-toggle:hover { background: rgba(255, 255, 255, 0.1); }

/* Print */
@media print {
    .no-print { display: none !important; }
    .nav-sidebar { display: none !important; }
    .page-layout .page-content, .page-layout ~ footer { margin-left: 0; }
    body { background: white; }
    .module-section { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
    main.manual { max-width: 100%; margin: 0; padding: 0; }
}

/* Responsive */
@media (max-width: 900px) {
    .nav-sidebar { display: none; }
    .page-layout .page-content, .page-layout ~ footer { margin-left: 0; }
    .controls { flex-direction: column; }
    .seed-form { flex-direction: column; }
    .maze-grid { grid-template-columns: repeat(2, 1fr); }
    .keypad-columns { grid-template-columns: repeat(3, 1fr); }
    .morse-columns { flex-direction: column; }
}

@media (max-width: 600px) {
    header { padding: 0.75rem 1rem; }
    header h1 { font-size: 1.3rem; margin-bottom: 0.15rem; }
    .subtitle { font-size: 0.8rem; margin-bottom: 0.5rem; }
    .seed-info { font-size: 0.8rem; margin-top: 0.5rem; }
    .controls { gap: 0.5rem; }
    .btn { padding: 0.4rem 0.75rem; font-size: 0.82rem; }
    #seedInput { width: 130px; font-size: 0.95rem; padding: 0.3rem 0.5rem; }

    main.manual { padding: 0 0.75rem; margin: 1rem auto; }
    .module-section { padding: 1rem; border-radius: 6px; scroll-margin-top: 10rem; }
    .module-section h2 { font-size: 1.15rem; }
    .module-section h3 { font-size: 0.95rem; }

    table { font-size: 0.8rem; }
    th, td { padding: 0.3rem 0.4rem; }
    .venn-table td:nth-child(-n+4) { width: 40px; }

    .maze-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
    .maze-svg { max-width: 100%; height: auto; }

    .password-grid td { font-size: 0.85rem; letter-spacing: 1px; }
}
