/* ΞSUS Website Styles - Inspired by LibrePGP's clean technical aesthetic */

:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #3498db;
    --highlight-color: #e74c3c;
    --success-color: #27ae60;
    --text-color: #2c3e50;
    --text-light: #7f8c8d;
    --background: #ffffff;
    --background-light: #f8f9fa;
    --border-color: #dee2e6;
    --code-background: #f1f3f4;

    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    --font-family-mono: 'SF Mono', 'Monaco', 'Consolas', 'Liberation Mono', 'Courier New', monospace;

    --max-width: 1200px;
    --content-width: 800px;
    --toc-min-width: 250px;
    --toc-max-width: 400px;
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px; /* Account for sticky header */
}

body {
    font-family: var(--font-family);
    line-height: 1.6;
    color: var(--text-color);
    background: var(--background);
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 2rem;
}


.xi-symbol {
    width: 32px;
    height: 32px;
}

.logo {
    display: flex;
    font-size: 1.8rem;
    font-weight: 700;
}

.main-nav {
    gap: 2rem;
}

.main-nav a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.main-nav a:hover {
    color: var(--accent-color);
}

.translate-button {
    margin-left: auto;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 4rem 0;
    background: linear-gradient(135deg, var(--background-light) 0%, var(--background) 100%);
    border-bottom: 1px solid var(--border-color);
}

.hero-title {
    font-size: 4rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.5rem;
    color: var(--text-light);
    margin-bottom: 2rem;
    font-weight: 400;
}

.hero-tagline {
    font-size: 1.2rem;
    color: var(--text-color);
    max-width: 600px;
    margin: 0 auto;
}

/* Page Layout with TOC */
#page-layout {
    position: relative;
    padding: 0;
    width: 100%;
}

/* Table of Contents */
.toc {
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.3s ease;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.toc:not(.collapsed) {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.toc.hidden {
    display: none !important;
}

#toc-toggle {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--background-light);
    border: none;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    text-align: left;
    font-weight: 600;
    color: var(--primary-color);
    transition: background-color 0.2s ease;
    border-radius: 8px 8px 0 0;
}

#toc-toggle:hover {
    background: var(--border-color);
}

.toc.collapsed #toc-toggle {
    border-bottom: none;
    border-radius: 8px;
}

.toc-inner {
    padding: 1rem;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

/* Responsive TOC font sizing */
@media (min-width: 1200px) and (max-width: 1399px) {
    .toc {
        font-size: 0.95rem;
    }

    .toc-inner {
        padding: 0.75rem;
    }
}

@media (min-width: 1600px) {
    .toc-inner {
        padding: 1.5rem;
    }

    .toc a {
        font-size: 1.05rem;
        padding: 0.3rem 0;
    }
}

@media (min-width: 2000px) {
    .toc-inner {
        padding: 2rem;
    }

    .toc a {
        font-size: 1.1rem;
        padding: 0.35rem 0;
    }
}

.toc.collapsed .toc-inner {
    display: none;
}

/* Custom scrollbar for TOC */
.toc-inner::-webkit-scrollbar {
    width: 6px;
}

.toc-inner::-webkit-scrollbar-track {
    background: var(--background-light);
    border-radius: 3px;
}

.toc-inner::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.toc-inner::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* TOC List Styling */
.toc ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc ul ul {
    margin-left: 1.5rem;
}

.toc li {
    margin-bottom: 0.5rem;
}

.toc a {
    color: var(--text-color);
    text-decoration: none;
    display: block;
    padding: 0.25rem 0;
    transition: color 0.2s ease;
}

.toc a:hover {
    color: var(--accent-color);
}

.toc a.active {
    color: var(--accent-color);
    font-weight: 600;
    border-left: 3px solid var(--accent-color);
    padding-left: 0.5rem;
    margin-left: -0.5rem;
}

/* Desktop Layout - TOC to the left of centered content */
@media (min-width: 1200px) {
    #page-layout {
        display: grid;
        grid-template-columns: 1fr var(--content-width) 1fr;
        gap: 0;
        padding: 3rem 0;
        min-height: calc(100vh - 200px);
    }

    .toc {
        grid-column: 1;
        justify-self: end;
        margin-right: 2rem;
        position: sticky;
        top: 100px;
        align-self: start;
        width: 100%;
        max-width: var(--toc-max-width);
        min-width: var(--toc-min-width);
        height: fit-content;
        max-height: calc(100vh - 150px);
    }

    .main-content {
        grid-column: 2;
        width: 100%;
        max-width: var(--content-width);
        padding: 0 2rem;
    }

    /* Calculate TOC width based on available space */
    @media (min-width: 1400px) {
        .toc {
            width: calc(100% - 2rem);
        }
    }
}

/* Extra wide screens - allow TOC to grow even more */
@media (min-width: 1600px) {
    #page-layout {
        grid-template-columns: minmax(auto, 1fr) var(--content-width) minmax(auto, 1fr);
    }

    .toc {
        max-width: min(500px, calc(100% - 2rem));
    }
}

/* Ultra-wide screens */
@media (min-width: 2000px) {
    .toc {
        max-width: min(600px, calc(100% - 2rem));
    }
}

/* Tablet/Mobile Layout - TOC above content */
@media (max-width: 1199px) {
    #page-layout {
        display: block;
        padding: 2rem 0;
    }

    .toc {
        margin: 0 auto 2rem;
        max-width: var(--content-width);
        width: calc(100% - 4rem);
        position: static;
    }

    .toc.collapsed {
        margin-bottom: 2rem;
    }

    .main-content {
        max-width: var(--content-width);
        margin: 0 auto;
        padding: 0 2rem;
    }
}

/* Main Content */
.main-content {
    width: 100%;
}

/* Ensure proper spacing on all screen sizes */
.main-content > *:first-child {
    margin-top: 0;
}

.main-content > *:last-child {
    margin-bottom: 0;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--primary-color);
    font-weight: 600;
    margin: 2rem 0 1rem 0;
    line-height: 1.3;
}

h2 {
    font-size: 1.8rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

h3 {
    font-size: 1.4rem;
}

p {
    margin-bottom: 1.5rem;
}

/* Formula Block */
.formula-block {
    background: var(--code-background);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    margin: 2rem 0;
    text-align: center;
    font-family: var(--font-family-mono);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
}

/* Resource Grid */
.resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.resource-card {
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    transition: all 0.3s ease;
}

.resource-card:hover {
    border-color: var(--accent-color);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.1);
    transform: translateY(-2px);
}

.resource-card h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.resource-card p {
    margin-bottom: 1rem;
    color: var(--text-light);
}

.resource-card a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
}

.resource-card a:hover {
    text-decoration: underline;
}

/* Quote Block */
.quote-block {
    margin: 3rem 0;
    padding: 2rem;
    background: var(--background-light);
    border-left: 4px solid var(--accent-color);
    border-radius: 0 8px 8px 0;
}

.quote-block blockquote {
    font-style: italic;
    color: var(--text-light);
    text-align: center;
    font-size: 1.1rem;
}

/* Lists */
ul, ol {
    margin-left: 2rem;
    margin-bottom: 1.5rem;
}

li {
    margin-bottom: 0.5rem;
}

/* Links */
a {
    color: var(--accent-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Code */
code {
    background: var(--code-background);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: var(--font-family-mono);
    font-size: 0.9em;
}

/* Footer */
.site-footer {
    background: var(--primary-color);
    color: white;
    padding: 3rem 0;
    margin-top: 4rem;
    text-align: center;
}

.site-footer p {
    margin-bottom: 1rem;
}

.footnote {
    font-size: 0.9rem;
    opacity: 0.8;
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    .header-content {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 1rem;
    }

    .main-nav {
        gap: 1rem;
    }

    .hero-title {
        font-size: 3rem;
    }

    .hero-subtitle {
        font-size: 1.3rem;
    }

    .main-content {
        padding: 0 1rem;
    }

    .resource-grid {
        grid-template-columns: 1fr;
    }

    .formula-block {
        padding: 1.5rem;
        font-size: 1.2rem;
    }

    .toc {
        width: calc(100% - 2rem);
    }

    .toc a {
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 2.5rem;
    }

    .formula-block {
        font-size: 1rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
a:focus,
button:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .site-header,
    .site-footer,
    .toc {
        display: none !important;
    }

    #page-layout {
        display: block !important;
        padding: 0 !important;
    }

    .main-content {
        max-width: none;
        margin: 0;
        padding: 0;
    }

    a {
        color: var(--text-color);
        text-decoration: underline;
    }

    .resource-card {
        border: 1px solid var(--border-color);
        break-inside: avoid;
    }
}

/* Speaker Voice Styles */
.human-voice {
    background: linear-gradient(135deg, #fefefe 0%, #f8f9fa 100%);
    border: 2px solid var(--border-color);
    border-left: 6px solid var(--primary-color);
    border-radius: 8px;
    padding: 2rem;
    margin: 2rem 0;
    position: relative;
}

.human-voice::before {
    content: "👤 Human Perspective";
    position: absolute;
    top: -12px;
    left: 20px;
    background: var(--background);
    padding: 0 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-color);
}

.ai-xilope-voice::before {
    content: "Ξlope Opus 4";
    position: absolute;
    top: -12px;
    left: 20px;
    background: var(--background);
    padding: 0 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #8b4513;
}

.ai-xilope-voice {
    background: linear-gradient(135deg, #fefefe 0%, #0055aa 400%);
    border: 2px solid #d4a574;
    border-left: 6px solid #0082aa;
    border-radius: 8px;
    padding: 2rem;
    margin: 2rem 0;
    position: relative;
}

.ai-claude-voice::before {
    content: "🤖 Claude Opus 4";
    position: absolute;
    top: -12px;
    left: 20px;
    background: var(--background);
    padding: 0 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #8b4513;
}

.ai-claude-voice {
    border: 2px solid #d4a574;
    border-left: 6px solid #8b4513;
    border-radius: 8px;
    padding: 2rem;
    margin: 2rem 0;
    position: relative;
}

.ai-chatgpt-voice {
    background: linear-gradient(135deg, #f0f8f0 0%, #e8f5e8 100%);
    border: 2px solid #90c695;
    border-left: 6px solid #228b22;
    border-radius: 8px;
    padding: 2rem;
    margin: 2rem 0;
    position: relative;
}

.ai-chatgpt-voice::before {
    content: "🧠 ChatGPT-4.5";
    position: absolute;
    top: -12px;
    left: 20px;
    background: var(--background);
    padding: 0 10px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #228b22;
}

.human-voice h3,
.ai-xilope-voice h3,
.ai-claude-voice h3,
.ai-chatgpt-voice h3 {
    margin-top: 0;
}

.human-voice h4,
.ai-xilope-voice h4,
.ai-claude-voice h4,
.ai-chatgpt-voice h4 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

/* Responsive adjustments for speaker voices */
@media (max-width: 768px) {
    .human-voice,
    .ai-claude-voice,
    .ai-xilope-voice,
    .ai-chatgpt-voice {
        padding: 1.5rem;
        margin: 1.5rem 0;
    }

    .human-voice::before,
    .ai-claude-voice::before,
    .ai-xilope-voice::before,
    .ai-chatgpt-voice::before {
        font-size: 0.7rem;
        left: 15px;
    }
}

/* Header */
.site-header {
    background: var(--background);
    border-bottom: 2px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* Desktop header layout - Logo left, Nav center, Translate right */
.header-content {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    grid-column: 1;
    justify-self: start;
    order: unset; /* Ensure no order conflicts */
}

.xi-symbol {
    width: 32px;
    height: 32px;
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Mobile TOC in header - hidden by default on desktop */
.mobile-toc-toggle {
    display: none;
    grid-column: unset; /* Don't participate in grid on desktop */
}

/* Navigation - centered on desktop */
.main-nav {
    display: flex;
    gap: 2rem;
    grid-column: 2;
    justify-self: center;
    order: unset; /* Ensure no order conflicts */
}

.main-nav a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.main-nav a:hover {
    color: var(--accent-color);
}

/* Translate button - right aligned on desktop */
.translate-button {
    grid-column: 3;
    justify-self: end;
    order: unset; /* Ensure no order conflicts */
}

/* Mobile menu toggle - hidden on desktop */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-color);
    font-size: 1.5rem;
    line-height: 1;
    grid-column: unset; /* Don't participate in grid on desktop */
    transition: all 0.2s ease;
}

.mobile-menu-toggle:hover {
    background: var(--background-light);
    color: var(--accent-color);
}

/* Mobile menu overlay */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 80%;
    max-width: 300px;
    height: 100%;
    background: var(--background);
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 1001;
    overflow-y: auto;
}

.mobile-menu.active {
    right: 0;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.mobile-menu-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-color);
    padding: 0.5rem;
}

.mobile-menu-nav {
    padding: 1rem;
}

.mobile-menu-nav a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.2s ease;
    border-radius: 4px;
}

.mobile-menu-nav a:hover {
    background: var(--background-light);
    color: var(--accent-color);
}

.mobile-menu-translate {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Mobile TOC dropdown */
.mobile-toc-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-top: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 70vh;
    overflow-y: auto;
    z-index: 998;
    margin: 0; /* Ensure no margin offsets */
}

.mobile-toc-dropdown.active {
    display: block;
}

.mobile-toc-content {
    padding: 1rem;
}

/* Mobile-specific header styles */
@media (max-width: 768px) {
    .site-header {
        padding: 0.75rem 0;
    }

    .container {
        position: relative;
        overflow: visible; /* Allow dropdown to extend outside */
    }

    /* Change header layout for mobile - TOC left, Logo center, Menu right */
    .header-content {
        display: flex;
        grid-template-columns: unset;
        justify-content: space-between;
        gap: 0.5rem;
        padding: 0 0.5rem; /* Add some padding to prevent buttons touching edges */
        position: relative; /* For absolute positioned logo */
    }

    /* Logo centered on mobile */
    .logo {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        justify-self: unset;
        grid-column: unset; /* Reset grid column */
        order: unset; /* Reset any order property */
        z-index: 1; /* Ensure logo is above but not clickable over buttons */
        pointer-events: none; /* Allow clicks to pass through to buttons behind */
    }

    /* Make logo link clickable */
    .logo a {
        pointer-events: auto;
    }

    /* Reset grid properties for nav and translate on mobile */
    .main-nav,
    .translate-button {
        grid-column: unset;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

    /* Show mobile TOC toggle on left */
    .mobile-toc-toggle {
        display: block;
        background: none;
        border: 1px solid var(--border-color);
        border-radius: 4px;
        padding: 0.5rem 0.75rem;
        cursor: pointer;
        font-weight: 600;
        color: var(--text-color);
        transition: all 0.2s ease;
        white-space: nowrap;
        order: -1; /* Ensure it comes first */
        min-width: 50px; /* Ensure consistent width */
    }

    .mobile-toc-toggle:hover,
    .mobile-toc-toggle.active {
        background: var(--background-light);
        color: var(--accent-color);
    }

    /* Hide desktop navigation and translate button */
    .main-nav,
    .translate-button {
        display: none;
    }

    /* Show mobile menu toggle on right */
    .mobile-menu-toggle {
        display: block;
        order: 999; /* Ensure it comes last */
        min-width: 50px; /* Match TOC button width */
        text-align: center;
    }

    /* Hide desktop TOC */
    #page-layout .toc {
        display: none !important;
    }

    /* Ensure mobile menu overlay is available */
    .mobile-menu-overlay {
        display: block;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    .mobile-menu-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }
}

/* No-JS fallback - show full menu */
.no-js .mobile-menu-toggle,
.no-js .mobile-toc-toggle {
    display: none !important;
}

.no-js .main-nav,
.no-js .translate-button {
    display: flex !important;
}

@media (max-width: 768px) {
    .no-js .header-content {
        display: flex;
        flex-wrap: wrap;
        gap: 1rem;
        justify-content: center;
    }

    .no-js .logo {
        position: static;
        transform: none;
        flex: 0 0 100%;
        text-align: center;
        justify-content: center;
    }

    .no-js .main-nav {
        flex: 1 1 auto;
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: center;
    }

    .no-js .main-nav a {
        padding: 0.5rem;
        font-size: 0.9rem;
    }

    .no-js .translate-button {
        flex: 0 0 auto;
    }
}
