/* ===========================================
   Help Window Styles
   JENS - Sound to Light
   =========================================== */

@import 'fonts.css';
@import 'variables.css';

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

body {
    font-family: var(--font-ui);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

/* ---- Layout ---- */
.help-container {
    display: flex;
    height: 100vh;
}

/* ---- Mobile top bar (hidden on desktop) ---- */
.help-mobile-bar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 30;
}

.help-menu-toggle {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.help-menu-toggle:active {
    background: var(--bg-secondary-alt);
}

.help-menu-icon,
.help-menu-icon::before,
.help-menu-icon::after {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform 0.2s ease, opacity 0.2s ease, top 0.2s ease;
    position: relative;
}

.help-menu-icon::before,
.help-menu-icon::after {
    content: '';
    position: absolute;
    left: 0;
}

.help-menu-icon::before { top: -6px; }
.help-menu-icon::after  { top: 6px; }

.help-menu-toggle[aria-expanded="true"] .help-menu-icon {
    background: transparent;
}

.help-menu-toggle[aria-expanded="true"] .help-menu-icon::before {
    top: 0;
    transform: rotate(45deg);
}

.help-menu-toggle[aria-expanded="true"] .help-menu-icon::after {
    top: 0;
    transform: rotate(-45deg);
}

.help-mobile-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.2px;
}

/* ---- Sidebar backdrop (mobile only) ---- */
.help-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.help-sidebar-backdrop.visible {
    opacity: 1;
}

/* ---- Sidebar ---- */
.help-sidebar {
    width: 260px;
    min-width: 200px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 16px 14px 10px;
    border-bottom: 1px solid var(--border-color);
}

#helpSearch {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}

#helpSearch:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.15);
}

#helpSearch::placeholder {
    color: var(--text-muted);
}

#helpToc {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

/* ---- TOC items ---- */
.toc-section {
    margin-bottom: 2px;
}

.toc-section-title {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    border-left: 3px solid transparent;
    transition: background 0.15s, color 0.15s;
}

.toc-section-title:hover {
    background: var(--bg-secondary-alt);
    color: var(--text-primary);
}

.toc-section-title.active {
    color: var(--accent-color);
    border-left-color: var(--accent-color);
}

.toc-section-title .chevron {
    font-size: 10px;
    transition: transform 0.2s;
    opacity: 0.5;
}

.toc-section-title.collapsed .chevron {
    transform: rotate(-90deg);
}

.toc-articles {
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.toc-articles.collapsed {
    max-height: 0 !important;
}

.toc-article-link {
    display: block;
    padding: 4px 14px 4px 28px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    border-left: 3px solid transparent;
    transition: background 0.15s, color 0.15s;
}

.toc-article-link:hover {
    background: var(--bg-secondary-alt);
    color: var(--text-primary);
}

.toc-article-link.active {
    color: var(--accent-color);
    border-left-color: var(--accent-color);
    font-weight: 500;
}

/* ---- Content ---- */
.help-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px 40px 80px;
}

.help-content section {
    margin-bottom: 56px;
}

/* ---- Article cards ---- */
.help-content article {
    margin-bottom: 28px;
    padding: 20px 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

/* ---- Typography ---- */
.help-content h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 2px solid transparent;
    border-image: linear-gradient(90deg, var(--accent-color), var(--accent-color-light), transparent) 1;
    color: var(--text-primary);
}

.help-content h2 {
    font-size: 17px;
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 14px;
    color: var(--text-primary);
}

.help-content h3 {
    font-size: 14px;
    font-weight: 600;
    margin-top: 18px;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.help-content h4 {
    font-size: 13px;
    font-weight: 600;
    margin-top: 14px;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.help-content p {
    font-size: 13px;
    line-height: 1.7;
    margin-bottom: 10px;
    color: var(--text-secondary);
    max-width: 800px;
}

/* ---- Lists ---- */
.help-content ul,
.help-content ol {
    font-size: 13px;
    line-height: 1.7;
    margin-bottom: 10px;
    padding-left: 20px;
    color: var(--text-secondary);
    max-width: 800px;
}

.help-content ul {
    list-style: none;
}

.help-content ul > li {
    position: relative;
    padding-left: 6px;
    margin-bottom: 4px;
}

.help-content ul > li::before {
    content: '';
    position: absolute;
    left: -14px;
    top: 8px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent-color);
}

/* Nested ul bullets - smaller, muted */
.help-content ul ul > li::before {
    width: 4px;
    height: 4px;
    background: var(--text-muted);
}

.help-content ol li {
    margin-bottom: 4px;
}

.help-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* ---- Inline code ---- */
.help-content code {
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 2px 6px;
    border-radius: var(--radius-xs);
    background: var(--bg-secondary-alt);
    border: 1px solid var(--border-color);
    color: var(--accent-color-light);
}

/* ---- Code blocks / signal flow diagrams ---- */
.help-content pre {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.6;
    padding: 14px 16px;
    margin-bottom: 14px;
    border-radius: var(--radius-md);
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-color);
    overflow-x: auto;
    max-width: 800px;
}

.help-content pre code {
    padding: 0;
    background: none;
    border: none;
    color: var(--text-secondary);
}

/* ---- Tables ---- */
.help-content table {
    width: 100%;
    max-width: 800px;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 14px;
    font-size: 12.5px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.help-content th,
.help-content td {
    padding: 7px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.help-content th {
    background: var(--bg-secondary-alt);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.help-content td {
    color: var(--text-secondary);
}

.help-content tr:last-child td {
    border-bottom: none;
}

.help-content tbody tr:nth-child(even) td {
    background: var(--bg-secondary);
}

.help-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 20px 0;
    max-width: 800px;
}

/* ---- Keyboard shortcut badges ---- */
.help-content kbd {
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: var(--radius-xs);
    background: var(--bg-secondary-alt);
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 0 var(--border-color);
    color: var(--text-primary);
    white-space: nowrap;
}

/* ---- Help tip callout boxes ---- */
.help-tip {
    padding: 10px 14px;
    margin: 12px 0;
    border-radius: var(--radius-md);
    background: rgba(139, 92, 246, 0.06);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-left: 3px solid var(--accent-color);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    max-width: 800px;
}

.help-tip strong {
    color: var(--accent-color-light);
}

/* ---- Search highlight ---- */
.help-content section.hidden {
    display: none;
}

.help-content article.hidden {
    display: none;
}

/* ---- Scrollbar ---- */
.help-content::-webkit-scrollbar,
#helpToc::-webkit-scrollbar {
    width: 6px;
}

.help-content::-webkit-scrollbar-track,
#helpToc::-webkit-scrollbar-track {
    background: transparent;
}

.help-content::-webkit-scrollbar-thumb,
#helpToc::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.help-content::-webkit-scrollbar-thumb:hover,
#helpToc::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---- Responsive ---- */

/* Tablet — keep sidebar but slim it down */
@media (max-width: 900px) and (min-width: 769px) {
    .help-sidebar {
        width: 220px;
        min-width: 180px;
    }
    .help-content {
        padding: 28px 28px 60px;
    }
}

/* Mobile — sidebar becomes slide-in overlay */
@media (max-width: 768px) {
    body {
        overflow: hidden;
    }

    .help-mobile-bar {
        display: flex;
    }

    .help-container {
        height: calc(100vh - 61px); /* minus mobile bar */
        height: calc(100dvh - 61px);
        position: relative;
    }

    .help-sidebar {
        position: fixed;
        top: 61px;
        left: 0;
        bottom: 0;
        width: 82%;
        max-width: 320px;
        min-width: 0;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.25);
    }

    .help-sidebar.open {
        transform: translateX(0);
    }

    .help-sidebar-backdrop.visible {
        display: block;
    }

    .sidebar-header {
        padding: 14px 16px 12px;
    }

    #helpSearch {
        padding: 10px 12px;
        font-size: 16px; /* prevents iOS auto-zoom on focus */
    }

    /* Larger touch targets in TOC */
    .toc-section-title {
        padding: 12px 16px;
        font-size: 13px;
    }

    .toc-section-title .chevron {
        font-size: 11px;
    }

    .toc-article-link {
        padding: 10px 16px 10px 32px;
        font-size: 13px;
    }

    .help-content {
        width: 100%;
        padding: 20px 16px 80px;
        -webkit-overflow-scrolling: touch;
    }

    .help-content section {
        margin-bottom: 36px;
    }

    .help-content article {
        padding: 16px 16px;
        margin-bottom: 18px;
    }

    .help-content h1 {
        font-size: 20px;
        margin-bottom: 14px;
        padding-bottom: 8px;
    }

    .help-content h2 {
        font-size: 16px;
        margin-bottom: 12px;
    }

    .help-content h3 {
        font-size: 14px;
        margin-top: 16px;
    }

    .help-content p,
    .help-content ul,
    .help-content ol {
        font-size: 14px;
        line-height: 1.65;
    }

    /* Tables: wrap in horizontal scroll container behavior */
    .help-content table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        font-size: 12.5px;
    }

    .help-content th,
    .help-content td {
        padding: 8px 10px;
        white-space: normal;
    }

    /* Code blocks: keep horizontal scroll, slightly smaller */
    .help-content pre {
        font-size: 11.5px;
        padding: 12px 14px;
    }

    .help-content code {
        font-size: 12px;
        word-break: break-word;
    }

    .help-tip {
        font-size: 13px;
        padding: 10px 12px;
    }

    /* Prevent text from being too narrow */
    .help-content p,
    .help-content ul,
    .help-content ol,
    .help-content pre,
    .help-content table,
    .help-content hr,
    .help-content .help-tip {
        max-width: 100%;
    }
}

/* Very narrow phones */
@media (max-width: 380px) {
    .help-content {
        padding: 16px 12px 80px;
    }
    .help-content article {
        padding: 14px 12px;
    }
    .help-mobile-title {
        font-size: 14px;
    }
}
