/**
 * Help System Styles for eclipsefan.org
 * Provides styles for help modal, inline help sections, and help buttons
 */

/* ==========================================================================
   CSS Variables
   ========================================================================== */
:root {
    --help-primary: #800080;
    --help-primary-light: #9932cc;
    --help-overlay: rgba(0, 0, 0, 0.6);
    --help-bg: #ffffff;
    --help-text: #333333;
    --help-text-light: #666666;
    --help-border: #e0e0e0;
    --help-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --help-radius: 8px;
    --help-transition: 0.25s ease;
}

/* ==========================================================================
   Help Modal - Overlay
   ========================================================================== */
.help-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--help-overlay);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--help-transition), visibility var(--help-transition);
}

.help-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   Help Modal - Dialog
   ========================================================================== */
.help-modal-dialog {
    background: var(--help-bg);
    border-radius: var(--help-radius);
    box-shadow: var(--help-shadow);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.9) translateY(-20px);
    transition: transform var(--help-transition);
    overflow: hidden;
}

.help-modal-overlay.active .help-modal-dialog {
    transform: scale(1) translateY(0);
}

/* ==========================================================================
   Help Modal - Header
   ========================================================================== */
.help-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--help-border);
    background: #fafafa;
    flex-shrink: 0;
}

.help-modal-title {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--help-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-modal-title::before {
    content: "?";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: var(--help-primary);
    color: white;
    border-radius: 50%;
    font-size: var(--text-base);
    font-weight: 700;
}

.help-modal-close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--help-text-light);
    border-radius: 4px;
    transition: background var(--help-transition), color var(--help-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.help-modal-close:hover,
.help-modal-close:focus {
    background: #eee;
    color: var(--help-text);
    outline: none;
}

.help-modal-close svg {
    width: 20px;
    height: 20px;
}

/* Language buttons in modal header */
.help-modal-langs {
    display: flex;
    gap: 6px;
    margin-left: auto;
    margin-right: 16px;
}

.help-modal-lang-btn {
    padding: 4px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: var(--text-xs);
    font-weight: 500;
    color: #666;
    transition: all 0.2s;
}

.help-modal-lang-btn:hover {
    border-color: var(--help-primary);
    background: #f9f0f9;
    color: var(--help-primary);
}

.help-modal-lang-btn.active {
    border-color: var(--help-primary);
    background: var(--help-primary);
    color: white;
}

/* Text size toggle button */
.help-text-size-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: var(--text-base);
    font-weight: 600;
    color: #666;
    transition: all 0.2s;
    margin-left: 8px;
    flex-shrink: 0;
}

.help-text-size-btn:hover {
    border-color: var(--help-primary);
    background: #f9f0f9;
    color: var(--help-primary);
}

.help-text-size-btn svg {
    width: 16px;
    height: 16px;
}

/* ==========================================================================
   Help Modal - Body
   ========================================================================== */
.help-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

/* Skeleton loader */
.help-skeleton {
    animation: help-pulse 1.5s ease-in-out infinite;
}

.help-skeleton-line {
    height: 16px;
    background: #e0e0e0;
    border-radius: 4px;
    margin-bottom: 12px;
}

.help-skeleton-line:nth-child(1) { width: 60%; height: 24px; margin-bottom: 16px; }
.help-skeleton-line:nth-child(2) { width: 100%; }
.help-skeleton-line:nth-child(3) { width: 90%; }
.help-skeleton-line:nth-child(4) { width: 95%; }
.help-skeleton-line:nth-child(5) { width: 40%; height: 20px; margin-top: 20px; }
.help-skeleton-line:nth-child(6) { width: 85%; }
.help-skeleton-line:nth-child(7) { width: 80%; }

@keyframes help-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Error state */
.help-error {
    text-align: center;
    padding: 40px 20px;
    color: var(--help-text-light);
}

.help-error-icon {
    font-size: 3rem; /* 48px - icône décorative */
    margin-bottom: 16px;
}

.help-error-message {
    font-size: var(--text-base);
    margin: 0;
}

/* ==========================================================================
   Help Content - Markdown Rendered Styles
   ========================================================================== */
.help-content {
    font-size: var(--text-base);
}

/* Text size variations */
.help-content.text-small {
    font-size: var(--text-xs);
}
.help-content.text-small h1 { font-size: var(--text-lg); }
.help-content.text-small h2 { font-size: var(--text-md); }
.help-content.text-small h3 { font-size: var(--text-sm); }
.help-content.text-small h4 { font-size: var(--text-xs); }

.help-content.text-large {
    font-size: var(--text-md);
}
.help-content.text-large h1 { font-size: var(--text-3xl); }
.help-content.text-large h2 { font-size: var(--text-2xl); }
.help-content.text-large h3 { font-size: var(--text-xl); }
.help-content.text-large h4 { font-size: var(--text-lg); }

.help-content h1,
.help-content h2,
.help-content h3,
.help-content h4 {
    color: var(--help-text);
    margin-top: 24px;
    margin-bottom: 12px;
    line-height: 1.3;
}

.help-content h1:first-child,
.help-content h2:first-child,
.help-content h3:first-child {
    margin-top: 0;
}

.help-content h1 { font-size: var(--text-2xl); }
.help-content h2 { font-size: var(--text-lg); border-bottom: 1px solid var(--help-border); padding-bottom: 8px; }
.help-content h3 { font-size: var(--text-base); color: var(--help-primary); }
.help-content h4 { font-size: var(--text-base); }

.help-content p {
    margin: 0 0 12px;
    line-height: 1.6;
    color: var(--help-text);
}

.help-content ul,
.help-content ol {
    margin: 0 0 16px;
    padding-left: 24px;
}

.help-content li {
    margin-bottom: 8px;
    line-height: 1.5;
    color: var(--help-text);
}

.help-content a {
    color: var(--help-primary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--help-transition);
}

.help-content a:hover,
.help-content a:focus {
    border-bottom-color: var(--help-primary);
}

.help-content a[href^="http"]::after,
.help-content a[target="_blank"]::after {
    content: " \2197";
    font-size: 0.85em;
}

.help-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 16px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.help-content code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.9em;
    color: #c7254e;
}

.help-content pre {
    background: #f5f5f5;
    padding: 16px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 16px 0;
}

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

.help-content blockquote {
    margin: 16px 0;
    padding: 12px 20px;
    border-left: 4px solid var(--help-primary);
    background: #f9f5f9;
    color: var(--help-text-light);
    font-style: italic;
}

.help-content blockquote p:last-child {
    margin-bottom: 0;
}

.help-content hr {
    border: none;
    border-top: 1px solid var(--help-border);
    margin: 24px 0;
}

.help-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

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

.help-content th {
    background: #fafafa;
    font-weight: 600;
}

/* ==========================================================================
   Help Button - Leaflet Control
   ========================================================================== */
.leaflet-control-help {
    background: white;
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
}

.help-btn-leaflet {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: var(--help-primary);
    font-size: var(--text-lg);
    font-weight: 700;
    transition: background var(--help-transition), color var(--help-transition);
}

.help-btn-leaflet:hover,
.help-btn-leaflet:focus {
    background: var(--help-primary);
    color: white;
    outline: none;
}

/* ==========================================================================
   Help Button - Inline (Panel/Tab header)
   ========================================================================== */
.help-btn-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: transparent;
    border: 1.5px solid var(--help-primary);
    border-radius: 50%;
    cursor: pointer;
    color: var(--help-primary);
    font-size: var(--text-base);
    font-weight: 700;
    transition: all var(--help-transition);
    flex-shrink: 0;
    margin-left: 8px;
}

.help-btn-inline:hover,
.help-btn-inline:focus {
    background: var(--help-primary);
    color: white;
    outline: none;
}

/* ==========================================================================
   Inline Help - Collapsible Section
   ========================================================================== */
.inline-help {
    border-top: 1px solid var(--help-border);
    margin-top: 16px;
}

.inline-help-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--help-text);
    font-size: var(--text-base);
    font-weight: 500;
    text-align: left;
    transition: color var(--help-transition);
}

.inline-help-toggle:hover,
.inline-help-toggle:focus {
    color: var(--help-primary);
    outline: none;
}

.inline-help-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.inline-help-toggle-icon {
    width: 18px;
    height: 18px;
    color: var(--help-primary);
}

.inline-help-chevron {
    width: 16px;
    height: 16px;
    transition: transform var(--help-transition);
    color: var(--help-text-light);
}

.inline-help.open .inline-help-chevron {
    transform: rotate(180deg);
}

.inline-help-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.inline-help.open .inline-help-content {
    max-height: 2000px;
}

.inline-help-body {
    padding: 0 0 16px;
}

.inline-help-body .help-content {
    font-size: var(--text-sm);
}

.inline-help-body .help-content h1 { font-size: var(--text-lg); }
.inline-help-body .help-content h2 { font-size: var(--text-md); }
.inline-help-body .help-content h3 { font-size: var(--text-base); }
.inline-help-body .help-content h4 { font-size: var(--text-sm); }

/* ==========================================================================
   Mobile Responsive Styles
   ========================================================================== */
@media (max-width: 767px) {
    .help-modal-overlay {
        padding: 10px;
        align-items: flex-end;
    }

    .help-modal-dialog {
        max-height: 85vh;
        max-width: 100%;
        border-radius: var(--help-radius) var(--help-radius) 0 0;
    }

    .help-modal-header {
        padding: 8px 10px;
        gap: 6px;
    }

    .help-modal-title {
        font-size: 0;
        gap: 0;
    }

    .help-modal-title::before {
        width: 22px;
        height: 22px;
        font-size: var(--text-xs);
    }

    .help-modal-langs {
        gap: 3px;
        margin-left: auto;
        margin-right: 0;
    }

    .help-modal-lang-btn {
        padding: 4px 6px;
        font-size: var(--text-xs);
    }

    .help-text-size-btn {
        width: 26px;
        height: 26px;
        margin-left: 6px;
    }

    .help-text-size-btn svg {
        width: 14px;
        height: 14px;
    }

    .help-modal-body {
        padding: 16px;
    }

    .help-content h1 { font-size: var(--text-lg); }
    .help-content h2 { font-size: var(--text-md); }
    .help-content h3 { font-size: var(--text-base); }

    .help-btn-leaflet {
        width: 40px;
        height: 40px;
        font-size: var(--text-xl);
    }

    /* Touch target size */
    .help-modal-close {
        padding: 8px;
        min-width: 40px;
        min-height: 40px;
    }

    .inline-help-toggle {
        min-height: 44px;
    }
}

/* Mobile landscape */
@media (max-height: 500px) {
    .help-modal-dialog {
        max-height: 90vh;
    }
}

/* ==========================================================================
   Accessibility - Focus Visible
   ========================================================================== */
.help-btn-leaflet:focus-visible,
.help-btn-inline:focus-visible,
.help-modal-close:focus-visible,
.inline-help-toggle:focus-visible {
    outline: 2px solid var(--help-primary);
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .help-modal-overlay,
    .help-modal-dialog,
    .help-btn-leaflet,
    .help-btn-inline,
    .inline-help-chevron,
    .inline-help-content {
        transition: none;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
    .help-modal-overlay,
    .help-btn-leaflet,
    .help-btn-inline,
    .inline-help-toggle {
        display: none !important;
    }
}
