/* ==========================================================================
   Hedger Pro Help page (standalone, no build).
   Modern tabbed layout: Contact form + Q&A assistant.

   All page styles are nested under #app (native CSS nesting) so they only touch
   the app root (<main class="hp-help" id="app">) and its descendants - never the
   shared header (#hp-ext-header) or the page frame. Shared layers load first:
     - lib/theme.css      :root tokens (--font, --radius, palette, ...)
     - lib/page-frame.css body backdrop + centred .hp-page column
     - lib/ui.css         base #app typography + .error-message/.settings-message

   The page's semantic --hp-* tokens are sourced from the shared palette so a
   change at :root cascades here too. rgba() shadows and the deliberately large
   --hp-radius are kept literal.
   ========================================================================== */

:root {
    --hp-bg: var(--gray-brighter);
    --hp-surface: var(--white);
    --hp-border: var(--gray-lightest);
    --hp-text: var(--gray-darkest);
    --hp-muted: var(--gray-mid);
    --hp-primary: var(--blue-accent-light);
    --hp-primary-dark: var(--blue-accent);
    --hp-ok-bg: var(--green-lightest);
    --hp-ok-text: var(--green-dark);
    --hp-err-bg: var(--red-lightest);
    --hp-err-text: var(--red-dark);
    --hp-radius: 12px;
    --hp-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px rgba(16, 24, 40, 0.08);

    /* Shared page frame (lib/page-frame.css): slate backdrop + centred light
       column with grey side borders, matching /reports/. */
    --hp-frame-bg: #3e4a5e;
    --hp-frame-surface: var(--hp-bg);
    --hp-frame-max-width: 1600px;
    --hp-frame-border: 3px solid var(--gray-lightest);
}

/* Panel fade-in (keyframes can't be nested, so it stays at the top level). */
@keyframes hp-fade {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

#app {
    box-sizing: border-box;
    /* This page intentionally uses the system UI font (overrides lib/ui.css). */
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--hp-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;

    & * { box-sizing: border-box; }

    /* ---- Help content -------------------------------------------------- */
    /* App-shell layout: fill the remaining height under the pinned header but
       DON'T scroll here - the head + tabs stay fixed and the .hp-card scrolls
       internally instead. The .hp-page--fixed wrapper clips overflow; min-height:0
       lets each flex item shrink below its content so the scroll lands on the card. */
    &.hp-help {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
        width: 100%;
        padding: 8px 8px;
        display: flex;
        flex-direction: column;
    }

    .hp-help-inner {
        max-width: 760px;
        width: 100%;
        margin: 0 auto;
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }

    .hp-help-head {
        flex: 0 0 auto;
        text-align: center;
        margin-bottom: 8px;
    }

    .hp-help-head h1 {
        font-size: 28px;
        line-height: 1.2;
        margin: 0 0 6px;
        font-weight: 700;
    }

    .hp-help-head p {
        margin: 0;
        color: var(--hp-muted);
        font-size: 15px;
    }

    /* ---- Tabs ---------------------------------------------------------- */
    .hp-tabs {
        flex: 0 0 auto;
        display: flex;
        gap: 6px;
        background: var(--gray-bright);
        padding: 6px;
        border-radius: var(--hp-radius);
        margin-bottom: 8px;
    }

    .hp-tab {
        flex: 1 1 0;
        appearance: none;
        border: 0;
        background: transparent;
        color: var(--hp-muted);
        font-size: 15px;
        font-weight: 600;
        padding: 10px 14px;
        border-radius: 8px;
        cursor: pointer;
        transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    }

    .hp-tab .fa { margin-right: 6px; }

    .hp-tab:hover {
        color: var(--hp-text);
    }

    .hp-tab.active {
        background: var(--hp-surface);
        color: var(--hp-primary);
        box-shadow: var(--hp-shadow);
    }

    /* ---- Panels & cards ------------------------------------------------ */
    /* The active panel (v-show toggles the other to display:none) fills the
       remaining height so its card can scroll. */
    .hp-panel {
        flex: 1 1 auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
        animation: hp-fade 0.18s ease;
    }

    /* The card is the scroll container: it fills the panel and scrolls its own
       content (title, form, answer, feedback) while the head + tabs stay put. */
    .hp-card {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        background: var(--hp-surface);
        border: 1px solid var(--hp-border);
        border-radius: var(--hp-radius);
        box-shadow: var(--hp-shadow);
        padding: 28px;
    }

    .hp-card h2 {
        font-size: 20px;
        margin: 0 0 4px;
    }

    .hp-card-sub {
        margin: 0 0 20px;
        color: var(--hp-muted);
        font-size: 14px;
    }

    /* ---- Forms --------------------------------------------------------- */
    .hp-form { display: block; }

    .hp-field {
        margin-bottom: 16px;
    }

    .hp-field label {
        display: block;
        font-size: 13px;
        font-weight: 600;
        margin-bottom: 6px;
        color: var(--hp-text);
    }

    .hp-field input[type="text"],
    .hp-field input[type="email"],
    .hp-field select,
    .hp-field textarea {
        width: 100%;
        padding: 11px 13px;
        font-size: 15px;
        font-family: inherit;
        color: var(--hp-text);
        background: var(--gray-brightest);
        border: 1px solid var(--hp-border);
        border-radius: 9px;
        transition: border-color 0.15s ease, box-shadow 0.15s ease;
    }

    .hp-field select {
        appearance: none;
        -webkit-appearance: none;
        background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2012%208'%3E%3Cpath%20fill%3D'%2364748b'%20d%3D'M1.5%201.5L6%206l4.5-4.5'%2F%3E%3C%2Fsvg%3E");
        background-repeat: no-repeat;
        background-position: right 14px center;
        background-size: 12px;
        padding-right: 36px;
        cursor: pointer;
    }

    .hp-field input:focus,
    .hp-field select:focus,
    .hp-field textarea:focus {
        outline: none;
        border-color: var(--hp-primary);
        box-shadow: 0 0 0 3px rgba(30, 99, 214, 0.15);
        background: var(--white);
    }

    .hp-field textarea {
        resize: vertical;
        min-height: 96px;
    }

    .hp-field input[type="range"] {
        width: 100%;
        accent-color: var(--hp-primary);
    }

    /* Honeypot: visually hidden but still in the DOM for bots. */
    .hp-hp {
        position: absolute;
        left: -9999px;
        width: 1px;
        height: 1px;
        overflow: hidden;
    }

    .hp-actions {
        margin-top: 4px;
    }

    .hp-btn {
        appearance: none;
        border: 0;
        background: var(--hp-primary);
        color: var(--white);
        font-size: 15px;
        font-weight: 600;
        padding: 11px 22px;
        border-radius: 9px;
        cursor: pointer;
        transition: background 0.15s ease, transform 0.05s ease;
    }

    .hp-btn .fa { margin-right: 6px; }

    .hp-btn:hover:not(:disabled) { background: var(--hp-primary-dark); }
    .hp-btn:active:not(:disabled) { transform: translateY(1px); }

    .hp-btn:disabled {
        opacity: 0.6;
        cursor: default;
    }

    .hp-btn-ghost {
        background: transparent;
        color: var(--hp-primary);
        border: 1px solid var(--hp-primary);
    }

    .hp-btn-ghost:hover:not(:disabled) {
        background: rgba(30, 99, 214, 0.08);
    }

    /* ---- Notes (success / error) --------------------------------------- */
    .hp-note {
        margin: 16px 0 0;
        padding: 11px 14px;
        border-radius: 9px;
        font-size: 14px;
    }

    .hp-note.ok {
        background: var(--hp-ok-bg);
        color: var(--hp-ok-text);
    }

    .hp-note.err {
        background: var(--hp-err-bg);
        color: var(--hp-err-text);
    }

    .hp-note.info {
        background: var(--gray-brighter);
        color: var(--black);
    }

    .hp-members-note {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .hp-members-note a {
        color: var(--blue-accent);
        font-weight: 600;
    }

    .hp-smiley {
        font-size: 18px;
        margin-left: 6px;
        vertical-align: middle;
    }

    /* ---- Answer & feedback --------------------------------------------- */
    .hp-answer {
        margin-top: 24px;
    }

    .hp-answer > h3,
    .hp-feedback > h3 {
        font-size: 16px;
        margin: 0 0 10px;
    }

    .hp-feedback {
        margin-top: 24px;
        padding-top: 20px;
        border-top: 1px solid var(--hp-border);
    }

    .answer-content {
        background: var(--gray-brightest);
        border: 1px solid var(--hp-border);
        border-radius: 10px;
        padding: 18px;
    }

    .answer-content img {
        max-width: 100%;
        height: auto;
        display: block;
        margin: 12px 0;
        border-radius: 8px;
    }

    .answer-content h1,
    .answer-content h2,
    .answer-content h3 {
        margin: 1em 0 0.5em;
        line-height: 1.3;
    }

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

    .answer-content p { margin: 0 0 1em; }

    .answer-content ul,
    .answer-content ol {
        margin: 0 0 1em 1.4em;
        padding: 0;
    }

    .answer-content code {
        background: var(--gray-brighter);
        padding: 2px 5px;
        border-radius: 4px;
        font-size: 0.9em;
    }

    .answer-content pre {
        background: var(--gray-brighter);
        padding: 14px;
        border-radius: 8px;
        overflow-x: auto;
        margin: 0 0 1em;
    }

    .answer-content a {
        color: var(--hp-primary);
    }

    /* ---- Responsive ---------------------------------------------------- */
    @media (max-width: 560px) {
        &.hp-help { padding: 20px 12px 48px; }
        .hp-card { padding: 20px; }
        .hp-help-head h1 { font-size: 23px; }
        .hp-tab { font-size: 14px; padding: 9px 8px; }
        .hp-tab .fa { margin-right: 4px; }
    }
}
