/* The Waste Land III - Visualization Styles */
/* Digital poetry with two-font system */

:root {
    --font-poetic: 'Garamond', 'Baskerville', 'Georgia', serif;
    --font-technical: 'Courier New', monospace;
    --border-subtle: 1px solid rgba(0, 0, 0, 0.2);
    --border-radius: 4px;
}

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

body {
    background-color: #ffffff;
    color: #000000;
    font-family: var(--font-technical);
    font-size: 14px;
    overflow: hidden;
    line-height: 1.6;
}

.container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    position: relative;
    background-color: #ffffff;
    color: #000000;
    padding: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.15);
}

.header h1 {
    font-family: var(--font-poetic);
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 5px;
    margin-top: 25px;
}

/* Back to Terminal Link */
.back-to-terminal {
    position: absolute;
    left: 20px;
    top: 20px;
    color: #666666;
    text-decoration: none;
    font-family: var(--font-technical);
    font-size: 12px;
    transition: color 0.2s;
}

.back-to-terminal:hover {
    color: #000000;
    text-decoration: underline;
}

/* Subtitle as Mode Tabs */
.subtitle-modes {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
}

.subtitle-tab {
    background: none;
    border: none;
    padding: 4px 8px;
    font-family: var(--font-technical);
    font-size: 12px;
    color: #666666;
    cursor: pointer;
    transition: color 0.2s, font-weight 0.2s;
    text-decoration: none;
}

.subtitle-tab:hover {
    color: #000000;
}

.subtitle-tab.active {
    color: #000000;
    font-weight: 600;
}

.subtitle-separator {
    color: #cccccc;
    font-size: 12px;
    margin: 0 4px;
}

/* Mobile Controls Wrapper - Desktop styles */
.mobile-controls-wrapper {
    display: contents; /* On desktop, wrapper has no effect on layout */
}

.mobile-controls-content {
    display: contents; /* On desktop, content flows normally */
}

.mobile-control-toggle {
    display: none; /* Hidden on desktop */
}

.toggle-icon {
    font-size: 20px;
    line-height: 1;
}

/* Adjust subtitle-modes now that it's outside header on desktop */
.subtitle-modes {
    padding: 0 20px;
    background: #fff;
}

/* Language Switcher */
.language-switcher {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
}

/* Usage Policy Link */
.usage-link {
    position: absolute;
    top: 55px;
    right: 20px;
    font-family: var(--font-technical);
    font-size: 10px;
    color: #999;
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.2s;
}

.usage-link:hover {
    color: #666;
}

.lang-btn {
    background: transparent;
    color: #666;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    padding: 4px 10px;
    font-family: var(--font-technical);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.lang-btn:hover {
    color: #000;
    border-color: rgba(0, 0, 0, 0.4);
}

.lang-btn.active {
    background: #000;
    color: #fff;
    border-color: #000;
}

/* Main Content Area */
.main-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* Visualization and Word Display Container (Side by Side) */
.viz-word-container {
    display: flex;
    flex: 1;
    gap: 0;
    overflow: hidden;
}

.canvas-container {
    flex: 1;
    position: relative;
    background-color: #ffffff;
}

#poetryCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.loading-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    background-color: #ffffff;
    padding: 20px;
    border: var(--border-subtle);
    border-radius: var(--border-radius);
}

/* Control Bar */
.control-bar {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 20px;
    align-items: center;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.mode-controls {
    display: flex;
    gap: 8px;
}

.axis-controls {
    flex: 1;
}

.axis-hint {
    font-size: 10px;
    color: #666;
    margin-bottom: 6px;
}

.axis-selectors {
    display: flex;
    gap: 15px;
    align-items: center;
}

.display-options {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Legend */
.legend-container {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-left: 20px;
    padding-left: 20px;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-symbol {
    font-size: 16px;
    font-weight: bold;
    line-height: 1;
}

.legend-aware {
    color: #000000;
}

.legend-agnostic {
    color: #808080;
}

.legend-label {
    font-size: 12px;
    color: #000000;
}

/* Current Word Display (side by side with visualization) */
.current-word-display-section {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 300px;
    padding: 30px 20px;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    background: #ffffff;
}

.word-display-centered {
    display: inline-block;
}

.word-display-centered .word-text {
    font-family: var(--font-poetic);
    font-size: 20px;
    font-weight: bold;
    color: #000;
    display: block;
    margin-bottom: 6px;
}

.word-display-centered .word-meta {
    font-family: var(--font-technical);
    font-size: 11px;
    color: #666;
    display: block;
}

/* Mode Buttons */
.mode-btn {
    background-color: #ffffff;
    color: #000000;
    border: 1px solid #000000;
    border-radius: 3px;
    padding: 6px 14px;
    font-family: var(--font-technical);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn:hover {
    background-color: #000000;
    color: #ffffff;
}

.mode-btn.active {
    background-color: #000000;
    color: #ffffff;
}

/* Axis Controls */
.axis-control {
    display: flex;
    align-items: center;
    gap: 6px;
}

#zAxisControl.hidden {
    display: none;
}

.axis-control label {
    font-size: 11px;
    font-weight: bold;
    min-width: 15px;
}

.axis-select {
    padding: 4px 8px;
    border: 1px solid rgba(0, 0, 0, 0.3);
    border-radius: 3px;
    background-color: #ffffff;
    color: #000000;
    font-family: var(--font-technical);
    font-size: 11px;
    cursor: pointer;
}

.axis-select:hover {
    background-color: #f0f0f0;
}

.axis-select:focus {
    outline: none;
    background-color: #000000;
    color: #ffffff;
}

/* Checkboxes */
.checkbox-label {
    display: block;
    margin-bottom: 10px;
    cursor: pointer;
    font-size: 12px;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 8px;
}

/* Checkbox styling */


/* Audio Controls */
.audio-controls {
    background-color: #ffffff;
    border-top: 1px solid rgba(0, 0, 0, 0.15);
    padding: 15px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.audio-info {
    font-size: 12px;
    text-align: center;
}

.playback-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.control-btn {
    background-color: #000000;
    color: #ffffff;
    border: 1px solid #000000;
    border-radius: 3px;
    padding: 8px 16px;
    font-family: var(--font-technical);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.control-btn:hover {
    background-color: #ffffff;
    color: #000000;
}

.control-btn:disabled {
    background-color: #cccccc;
    color: #666666;
    border-color: #cccccc;
    cursor: not-allowed;
}

.play-btn {
    min-width: 80px;
}

.time-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.time-controls span {
    font-size: 12px;
    min-width: 45px;
}

.scrubber {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: #000000;
    outline: none;
    cursor: pointer;
}

.scrubber::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #000000;
    cursor: pointer;
    border: 2px solid #ffffff;
}

.scrubber::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #000000;
    cursor: pointer;
    border: 2px solid #ffffff;
    border-radius: 0;
}

#audioPlayer {
    display: none;
}

/* Description Section */
.description-section {
    max-height: 20vh;
    overflow: hidden;
    background: #fafafa;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    transition: max-height 0.5s ease;
}

.description-section.expanded {
    max-height: 70vh;
    overflow-y: auto;
}

/* Scroll Indicator */
.scroll-indicator {
    text-align: center;
    padding: 10px;
    font-size: 16px;
    color: rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: opacity 0.3s, color 0.2s;
}

.scroll-indicator:hover {
    color: rgba(0, 0, 0, 0.6);
}

/* Change to up arrow when expanded */
.scroll-indicator::before {
    content: '↓';
}

.description-section.expanded .scroll-indicator::before {
    content: '↑';
}

/* Content Navigation (hidden when collapsed) */
.content-nav {
    display: none;
    justify-content: center;
    gap: 0;
    padding: 15px 0 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.description-section.expanded .content-nav {
    display: flex;
}

.nav-btn {
    background: transparent;
    color: #666;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 8px 20px;
    font-family: var(--font-technical);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-btn:hover {
    color: #000;
}

.nav-btn.active {
    color: #000;
    border-bottom-color: #000;
}

/* Content Panels */
.content-panel {
    display: none;
}

.content-panel.active {
    display: block;
}

.description-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 60px;
}

/* Manifesto Section */
.manifesto-section {
    font-family: var(--font-poetic);
    font-size: 16px;
    line-height: 1.9;
    color: #222;
}

.manifesto-section p {
    margin-bottom: 20px;
    text-indent: 2em;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow: auto;
}

.modal.active {
    display: block;
}

.modal-content {
    position: relative;
    background-color: #fff;
    margin: 5% auto;
    padding: 40px 50px;
    border: 1px solid #888;
    width: 90%;
    max-width: 700px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    font-family: var(--font-technical);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 25px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover,
.modal-close:focus {
    color: #000;
}

/* Usage Policy (in modal) */
.usage-policy {
    font-family: var(--font-technical);
    font-size: 13px;
    line-height: 1.7;
}

.usage-policy h3 {
    font-family: var(--font-technical);
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.usage-policy p {
    margin-bottom: 15px;
    color: #333;
}

.usage-policy .contact-info {
    font-family: var(--font-technical);
    font-weight: 600;
    color: #000;
    margin-top: 20px;
}

.usage-policy .citation-format {
    padding: 15px 20px;
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    font-family: var(--font-technical);
    font-size: 12px;
    margin-top: 10px;
    font-style: italic;
    color: #444;
}

.usage-policy a {
    color: #0066cc;
    text-decoration: underline;
    transition: color 0.2s;
}

.usage-policy a:hover {
    color: #003d99;
}

/* Poetic Passages */
.poetic-passage {
    font-family: var(--font-poetic);
    font-size: 18px;
    line-height: 1.8;
    margin-bottom: 30px;
    color: #222;
}

.poetic-passage p {
    margin-bottom: 15px;
}

.analysis-text {
    font-family: var(--font-technical);
    font-size: 13px;
    line-height: 1.7;
    color: #333;
    margin-bottom: 40px;
}

.analysis-text h3 {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 12px;
    color: #000;
}

.analysis-text p {
    margin-bottom: 10px;
}

/* Analysis Section - Axis Explanations */
.analysis-intro {
    margin-bottom: 40px;
}

.analysis-intro h3 {
    font-family: var(--font-technical);
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 15px;
}

.analysis-intro ul {
    margin: 15px 0;
    padding-left: 25px;
}

.analysis-intro li {
    margin: 8px 0;
    font-family: var(--font-technical);
    font-size: 13px;
    line-height: 1.6;
}

.axis-category {
    margin: 50px 0;
    padding: 30px 0;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.axis-category h2 {
    font-family: var(--font-poetic);
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 15px;
}

.axis-category > p {
    font-family: var(--font-technical);
    font-size: 13px;
    color: #666;
    margin-bottom: 30px;
}

.axis-explanation {
    margin-bottom: 40px;
}

.axis-explanation h3 {
    font-family: var(--font-technical);
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 10px;
}

.axis-range {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    background: #f5f5f5;
    border-radius: 4px;
    margin-bottom: 20px;
    font-family: var(--font-technical);
    font-size: 11px;
}

.axis-range .range-min {
    color: #000;
    font-weight: bold;
}

.axis-range .range-mid {
    color: #666;
}

.axis-range .range-max {
    color: #000;
    font-weight: bold;
}

.methodology-note {
    margin-top: 60px;
    padding: 30px;
    background: #fafafa;
    border-left: 4px solid #000;
}

.methodology-note h3 {
    font-family: var(--font-technical);
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 15px;
}

.methodology-note ul {
    margin: 15px 0;
    padding-left: 25px;
}

.methodology-note li {
    margin: 8px 0;
    font-family: var(--font-technical);
    font-size: 13px;
    line-height: 1.6;
}

.methodology-note p {
    margin-bottom: 15px;
}

/* GPT methodology section - special styling */
.gpt-methodology {
    background: #fff;
    border-left: 4px solid #666;
    margin-top: 80px;
}

.gpt-methodology p strong {
    font-weight: bold;
}

.gpt-methodology p em {
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 900px) {
    /* Header title - prevent overlap with language switcher */
    .header h1 {
        padding-right: 130px;
    }

    /* Mobile Controls Wrapper - Glassmorphism floating panel over visualization */
    .mobile-controls-wrapper {
        display: block;
        position: fixed;
        right: 15px;
        top: 180px;
        z-index: 1000;
        /* Glassmorphism effect */
        background: rgba(255, 255, 255, 0.7);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-radius: 12px;
        border: 1px solid rgba(255, 255, 255, 0.3);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
        max-width: calc(100vw - 30px);
        overflow: hidden;
    }

    .mobile-control-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        background: rgba(0, 0, 0, 0.8);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        color: #fff;
        border: none;
        border-radius: 12px;
        cursor: pointer;
        font-size: 18px;
        transition: all 0.2s;
    }

    .mobile-control-toggle:hover {
        background: rgba(0, 0, 0, 0.9);
    }

    /* Collapsed state - hide content */
    .mobile-controls-wrapper:not(.expanded) .mobile-controls-content {
        display: none;
    }

    /* Expanded state */
    .mobile-controls-wrapper.expanded {
        max-height: 50vh;
        overflow-y: auto;
        display: flex;
        flex-direction: column-reverse;
    }

    .mobile-controls-wrapper.expanded .mobile-control-toggle {
        width: 100%;
        border-radius: 0 0 12px 12px;
        justify-content: flex-end;
        padding-right: 15px;
    }

    .mobile-controls-content {
        display: block;
    }

    /* Subtitle modes in floating panel */
    .mobile-controls-wrapper .subtitle-modes {
        display: flex;
        flex-direction: column;
        padding: 12px 15px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
        gap: 4px;
        background: transparent;
    }

    .mobile-controls-wrapper .subtitle-separator {
        display: none;
    }

    .mobile-controls-wrapper .subtitle-tab {
        padding: 8px 12px;
        text-align: left;
        border-radius: 6px;
        background: transparent;
    }

    .mobile-controls-wrapper .subtitle-tab:hover {
        background: rgba(0, 0, 0, 0.05);
    }

    .mobile-controls-wrapper .subtitle-tab.active {
        background: rgba(0, 0, 0, 0.08);
    }

    /* Control bar in floating panel */
    .mobile-controls-wrapper .control-bar {
        display: flex;
        flex-direction: column;
        gap: 15px;
        padding: 15px;
        border-bottom: none;
        background: transparent;
    }

    .axis-selectors {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .axis-control {
        width: 100%;
    }

    .axis-select {
        flex: 1;
    }

    /* Main content layout */
    .main-content {
        display: flex;
        flex-direction: column;
    }

    /* Stack visualization and word display vertically */
    .viz-word-container {
        display: contents;
    }

    .canvas-container {
        order: 1;
        min-height: 30vh;
        flex: 1 1 auto; /* Can grow and shrink */
    }

    /* Compact word display - between canvas and audio */
    .current-word-display-section {
        order: 2;
        width: 100%;
        padding: 8px 15px;
        background: #f8f8f8;
        border-left: none;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
        flex-shrink: 0; /* Don't compress word display */
    }

    .current-word-display-section .word-display-centered {
        display: flex;
        align-items: baseline;
        gap: 12px;
        flex-wrap: wrap;
    }

    .current-word-display-section .word-text {
        font-size: 16px;
        margin-bottom: 0;
    }

    .current-word-display-section .word-meta {
        font-size: 10px;
    }

    /* Audio controls after word display */
    .audio-controls {
        order: 3;
        flex-shrink: 0; /* Don't compress audio controls */
        /* Safe area for Safari mobile */
        padding-bottom: 40px;
        padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
    }

    .description-content {
        padding: 30px 20px;
    }

    .content-nav {
        flex-wrap: wrap;
    }
}

@media (max-width: 600px) {
    .header {
        padding: 15px;
        padding-right: 120px; /* Make room for language switcher */
    }

    .header h1 {
        font-size: 16px;
    }

    .subtitle {
        font-size: 11px;
    }

    .language-switcher {
        top: 15px;
        right: 15px;
        gap: 6px;
    }

    .lang-btn {
        padding: 3px 8px;
        font-size: 10px;
    }

    .control-bar {
        padding: 10px 15px;
    }

    .current-word-display-section {
        padding: 12px;
    }

    .word-display-centered .word-text {
        font-size: 16px;
    }

    .word-display-centered .word-meta {
        font-size: 10px;
    }

    .manifesto-section {
        font-size: 15px;
        line-height: 1.8;
    }

    .poetic-passage {
        font-size: 16px;
        line-height: 1.6;
    }

    .analysis-text {
        font-size: 12px;
    }

    .nav-btn {
        padding: 6px 15px;
        font-size: 11px;
    }

    .playback-controls {
        gap: 10px;
    }

    .control-btn {
        padding: 6px 12px;
        font-size: 11px;
    }
}

/* Print Styles */
@media print {
    .control-bar,
    .audio-controls,
    .instructions,
    .description-section {
        display: none;
    }

    .canvas-container {
        width: 100%;
        height: 100vh;
    }
}

/* Accessibility */
:focus {
    outline: 2px solid rgba(0, 0, 0, 0.5);
    outline-offset: 2px;
}

button:focus,
select:focus,
input:focus {
    outline: 2px solid rgba(0, 0, 0, 0.6);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

/* Dark mode support (optional - maintains black/white) */
@media (prefers-color-scheme: dark) {
    /* Keep the same black/white scheme even in dark mode */
    /* This maintains consistency with the terminal aesthetic */
}
