/**
 * SCHEMA - Main Stylesheet
 * Version: 5.0 (Architect Protocol)
 * 
 * Aesthetic: Blueprint / Systems Architecture / Cassette Futurism
 */

/* =============================================================================
   CSS VARIABLES / THEME
   ============================================================================= */

:root {
    --bg: #050505;
    --panel: #0a0a0a;
    --border: #222;
    --text-main: #eee;
    --text-dim: #555;
    --accent: #00ffcc;
    --accent-dim: rgba(0, 255, 204, 0.1);
    --error: #ff3333;
    --warn: #ffaa00;
    --font-mono: 'Courier New', monospace;
}

/* =============================================================================
   BASE STYLES
   ============================================================================= */

* {
    box-sizing: border-box;
}

body {
    background: var(--bg);
    /* Blueprint grid pattern */
    background-image: 
        linear-gradient(rgba(0, 255, 204, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 204, 0.03) 1px, transparent 1px);
    background-size: 20px 20px;
    color: var(--text-main);
    font-family: var(--font-mono);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    user-select: none;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* =============================================================================
   HEADER
   ============================================================================= */

h1 {
    margin: 0 0 5px 0;
    letter-spacing: 12px;
    font-size: 42px;
    text-transform: uppercase;
}

.subtitle {
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 4px;
    margin-bottom: 30px;
    text-transform: uppercase;
}

#header-row {
    width: 700px;
    max-width: 95vw;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 10px;
}

/* =============================================================================
   SCHEMA BUTTON
   ============================================================================= */

.schema-btn {
    background: transparent;
    border: 1px solid var(--text-dim);
    color: var(--text-dim);
    font-size: 10px;
    padding: 5px 10px;
    cursor: pointer;
    letter-spacing: 1px;
    font-family: inherit;
    transition: all 0.2s;
}

.schema-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* =============================================================================
   INTEL PANEL (Clues)
   ============================================================================= */

#intel-panel {
    width: 700px;
    max-width: 95vw;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding-bottom: 15px;
    margin-top: 10px;
}

.clue-label {
    display: block;
    font-size: 10px;
    color: var(--text-dim);
    letter-spacing: 1px;
}

.clue-text {
    font-size: 14px;
    color: var(--accent);
    font-weight: bold;
    letter-spacing: 1px;
}

.clue-line {
    display: block;
    margin-bottom: 4px;
}

.clue-line:last-child {
    margin-bottom: 0;
}

.clue-tier {
    font-size: 10px;
    color: var(--text-dim);
    margin-right: 6px;
}

.clue-c1 { color: var(--accent); }
.clue-c2 { color: #88ddbb; }
.clue-c3 { color: #aaccaa; }

.clue-box-right {
    text-align: right;
}

#clue-level-display {
    color: var(--warn);
    font-weight: bold;
}

.reveal-clue-btn {
    background: transparent;
    border: 1px solid var(--text-dim);
    color: var(--text-dim);
    font-size: 9px;
    padding: 4px 8px;
    margin-top: 8px;
    cursor: pointer;
    font-family: inherit;
    letter-spacing: 1px;
    transition: all 0.2s;
}

.reveal-clue-btn:hover:not(:disabled) {
    border-color: var(--warn);
    color: var(--warn);
}

.reveal-clue-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Dev Console */
.dev-console {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--accent);
    font-family: 'Courier New', monospace;
    font-size: 11px;
    padding: 6px 10px;
    cursor: pointer;
    letter-spacing: 1px;
}

.dev-console:hover {
    border-color: var(--accent);
}

.dev-console option {
    background: var(--panel);
    color: var(--text-main);
}

/* =============================================================================
   GAME CONTAINER & CANVAS
   ============================================================================= */

#game-container {
    position: relative;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--panel);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
    max-width: 95vw;
    width: 820px;
}

canvas {
    display: block;
    background: #080808;
    border-radius: 2px;
    cursor: crosshair;
    touch-action: none; /* Prevent touch scrolling */
    width: 100%;
    height: auto;
}

/* =============================================================================
   UI LAYER (Stats)
   ============================================================================= */

#ui-layer {
    margin-top: 20px;
    width: 820px;
    max-width: 95vw;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.stat-card {
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 15px;
    text-align: center;
    border-radius: 4px;
}

.stat-label {
    font-size: 9px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 2px;
    display: block;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 28px;
    font-weight: bold;
    color: #fff;
}

/* =============================================================================
   STATUS BAR & PULSE
   ============================================================================= */

#status-bar {
    grid-column: span 4;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    position: relative;
}

#message {
    font-size: 14px;
    letter-spacing: 1px;
    color: var(--text-dim);
    z-index: 2;
}

#pulse-container {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    height: 20px;
    align-items: center;
    z-index: 2;
    opacity: 0;
    transition: opacity 1s ease-in;
}

/* Pulse Beat Dots */
.beat {
    width: 8px;
    height: 8px;
    background: #222;
    border-radius: 50%;
    transition: all 0.3s;
}

.beat.stable {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
    transform: scale(1.1);
}

.beat.error {
    background: var(--error);
    box-shadow: 0 0 5px var(--error);
    transform: scale(0.9);
}

.beat.drift {
    background: var(--warn);
    transform: scale(0.9);
}

.beat.limit {
    background: #fff;
}

.beat.empty {
    background: #222;
}

/* =============================================================================
   ACTION BAR (Undo / Restart)
   ============================================================================= */

#action-bar {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.action-btn {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 12px 30px;
    font-family: inherit;
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover:not(:disabled) {
    background: var(--accent);
    color: var(--bg);
}

.action-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.action-btn.secondary {
    border-color: var(--text-dim);
    color: var(--text-dim);
}

.action-btn.secondary:hover {
    border-color: var(--warn);
    color: var(--warn);
    background: transparent;
}

/* =============================================================================
   RESET BUTTON (legacy, used in modals)
   ============================================================================= */

button.reset-btn {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
    padding: 15px 40px;
    margin-top: 40px;
    font-family: inherit;
    font-size: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
}

button.reset-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* =============================================================================
   SCHEMA MODAL
   ============================================================================= */

#schema-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 100;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

#schema-modal h2 {
    color: var(--accent);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 5px;
}

#schema-content {
    background: #111;
    border: 1px solid var(--accent);
    padding: 20px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 15px;
}

.schema-char {
    border: 1px solid #333;
    padding: 10px;
    text-align: center;
}

.schema-label {
    display: block;
    margin-top: 5px;
    color: #555;
    font-size: 12px;
}

#close-schema {
    margin-top: 20px;
    border-color: var(--accent);
    color: var(--accent);
}

/* =============================================================================
   CONFIRMATION MODAL
   ============================================================================= */

#confirm-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.confirm-box {
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 40px;
    text-align: center;
    border-radius: 4px;
}

.confirm-box p {
    font-size: 18px;
    margin: 0 0 10px 0;
    color: var(--text-main);
}

.confirm-sub {
    font-size: 12px;
    color: var(--text-dim);
    display: block;
    margin-bottom: 30px;
}

.confirm-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* =============================================================================
   GAME CANVAS
   ============================================================================= */

#game-container {
    width: 700px;
    max-width: 95vw;
    display: flex;
    justify-content: center;
}

#glyphCanvas {
    max-width: 100%;
    height: auto;
    touch-action: none; /* Prevent browser handling of touch */
}

/* =============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================= */

@media (max-width: 740px) {
    h1 {
        font-size: 32px;
        letter-spacing: 8px;
    }

    .subtitle {
        font-size: 10px;
        letter-spacing: 2px;
    }

    #ui-layer {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    #status-bar {
        grid-column: span 2;
    }

    .stat-card {
        padding: 10px;
    }

    .stat-value {
        font-size: 22px;
    }

    .stat-label {
        font-size: 8px;
    }

    #intel-panel {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .clue-box {
        text-align: center !important;
    }

    #action-bar {
        flex-direction: column;
        width: 95vw;
    }

    .action-btn {
        width: 100%;
    }
    
    /* Mobile canvas sizing */
    #game-container {
        margin: 10px 0;
        width: 95vw;
        max-width: 95vw;
    }
    
    #schemaCanvas {
        width: 100%;
        height: auto;
        min-height: 180px;
    }
    
    /* Hide desktop controls, show mobile controls */
    .desktop-controls {
        display: none !important;
    }
    
    .mobile-controls {
        display: block !important;
    }
}

/* Default: show desktop, hide mobile */
.desktop-controls {
    display: block;
}

.mobile-controls {
    display: none;
}

/* =============================================================================
   HELP BUTTON
   ============================================================================= */

.help-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-family: 'Courier New', monospace;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.help-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* =============================================================================
   TUTORIAL MODAL
   ============================================================================= */

#tutorial-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 200;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

#tutorial-modal.active {
    display: flex;
}

.tutorial-content {
    background: var(--panel);
    border: 1px solid var(--border);
    max-width: 480px;
    width: 100%;
    padding: 30px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.tutorial-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
}

.tutorial-close:hover {
    color: var(--accent);
}

.tutorial-content h2 {
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 3px;
    margin: 0 0 5px 0;
    font-size: 20px;
}

.tutorial-subtitle {
    color: var(--text-dim);
    margin: 0 0 25px 0;
    font-size: 14px;
}

.tutorial-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.tutorial-section:last-of-type {
    border-bottom: none;
    margin-bottom: 25px;
}

.tutorial-section h3 {
    color: var(--text-main);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 0 0 10px 0;
}

.tutorial-section p {
    color: var(--text-dim);
    font-size: 13px;
    line-height: 1.6;
    margin: 0 0 10px 0;
}

.tutorial-highlight {
    color: var(--accent);
    font-family: 'Courier New', monospace;
}

.tutorial-example {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 15px 0;
    font-size: 13px;
}

.example-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-dim);
    flex-wrap: nowrap;
}

.example-row strong {
    color: var(--text-main);
}

.mass-example {
    font-family: 'Courier New', monospace;
    padding: 4px 10px;
    display: inline-block;
    margin-right: 10px;
    white-space: nowrap;
    min-width: 50px;
    text-align: center;
}

.mass-example.correct {
    color: var(--accent);
    border: 1px solid var(--accent);
}

.mass-example.wrong {
    color: var(--text-main);
    border: 1px solid var(--border);
}

.tutorial-tip {
    color: var(--warn) !important;
    font-style: italic;
}

.tutorial-controls {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tutorial-controls li {
    color: var(--text-dim);
    font-size: 13px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.tutorial-controls li:last-child {
    border-bottom: none;
}

.tutorial-controls strong {
    color: var(--text-main);
}

.tutorial-pulse {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
    font-size: 13px;
}

.pulse-example {
    font-size: 16px;
    margin-right: 8px;
}

.pulse-example.stable {
    color: var(--accent);
}

.pulse-example.drift {
    color: var(--warn);
}

.pulse-example.error {
    color: var(--error);
}

.tutorial-start {
    width: 100%;
    padding: 15px;
    font-size: 14px;
}

/* =============================================================================
   SHARE BUTTON
   ============================================================================= */

.share-btn {
    background: var(--accent) !important;
    color: var(--bg) !important;
    border-color: var(--accent) !important;
}

.share-btn:hover {
    background: transparent !important;
    color: var(--accent) !important;
}

.share-btn.copied {
    background: var(--accent) !important;
    color: var(--bg) !important;
}
