/* ==========================================================================
   Help & Interactive Onboarding (v0.22.0-rc1)
   Help Center, contextual drawer, first-steps card, guided-tour overlay.
   Uses the shared tokens only; respects prefers-reduced-motion.
   ========================================================================== */

/* ---- Topbar "Pomoc" button ---------------------------------------------- */

.app-topbar__help {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2xs);
    padding: 0.4rem 0.75rem;
    border: var(--border-width) solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text-primary);
    font-size: var(--text-compact-size);
    font-weight: 600;
    text-decoration: none;
    min-height: var(--control-touch-min, 2.5rem);
}

.app-topbar__help:hover {
    background: var(--color-surface-sunken);
}

.app-topbar__help:focus-visible,
.help-drawer__close:focus-visible,
.help-tour :focus-visible,
.help-search input:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
}

/* ---- Contextual drawer -------------------------------------------------- */

.help-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1400;
    width: min(26rem, 100vw);
    padding: var(--space-lg);
    overflow-y: auto;
    background: var(--color-surface);
    border-left: var(--border-width) solid var(--color-border-strong);
    box-shadow: var(--shadow-lg);
    color: var(--color-text-primary);
}

.help-drawer[hidden] {
    display: none;
}

.help-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
}

.help-drawer__header h2 {
    margin: 0;
    font-size: var(--text-page-title-size);
}

.help-drawer__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--control-touch-min, 2.5rem);
    min-height: var(--control-touch-min, 2.5rem);
    border: var(--border-width) solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text-primary);
    cursor: pointer;
}

.help-drawer__search,
.help-search {
    display: flex;
    gap: var(--space-xs);
    margin: var(--space-md) 0;
}

.help-drawer__search input,
.help-search input {
    flex: 1;
    min-width: 0;
    padding: 0.55rem 0.75rem;
    border: var(--border-width) solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    font: inherit;
}

.help-drawer__topics,
.help-result-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.help-drawer__topics li,
.help-result-list li {
    padding: var(--space-sm) 0;
    border-bottom: var(--border-width) solid var(--color-border);
}

.help-drawer__footer {
    margin-top: var(--space-md);
}

/* ---- Help Center -------------------------------------------------------- */

.help-muted {
    margin: var(--space-2xs) 0;
    color: var(--color-text-secondary);
    font-size: var(--text-compact-size);
}

.help-section {
    margin: var(--space-xl) 0;
}

.help-chip {
    display: inline-block;
    margin-left: var(--space-xs);
    padding: 0 var(--space-xs);
    border-radius: var(--radius-full);
    background: var(--color-surface-sunken);
    color: var(--color-text-secondary);
    font-size: var(--text-caption-size);
    font-weight: 600;
}

.help-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr));
    gap: var(--space-md);
    list-style: none;
    margin: 0;
    padding: 0;
}

.help-card {
    padding: var(--space-md);
    background: var(--color-surface);
    border: var(--border-width) solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
}

.help-category {
    margin: var(--space-xs) 0;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-surface);
    border: var(--border-width) solid var(--color-border);
    border-radius: var(--radius-md);
}

.help-category summary {
    cursor: pointer;
    font-weight: 700;
}

.help-article {
    max-width: 48rem;
}

.help-content h3,
.help-content h4 {
    margin: var(--space-md) 0 var(--space-xs);
}

.help-content p,
.help-content li {
    line-height: var(--text-body-line);
}

.help-note {
    padding: var(--space-sm) var(--space-md);
    border-left: 4px solid var(--color-primary);
    background: var(--color-info-bg);
    border-radius: var(--radius-sm);
}

/* ---- First-steps card --------------------------------------------------- */

.help-onboarding__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.help-checklist {
    list-style: none;
    margin: var(--space-sm) 0;
    padding: 0;
}

.help-checklist li {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: var(--space-xs);
    padding: var(--space-xs) 0;
}

.help-checklist li.is-done > a {
    color: var(--color-text-secondary);
}

.help-checklist__mark {
    display: inline-flex;
    flex: none;
    color: var(--color-primary-text);
}

.help-checklist li.is-done .help-checklist__mark {
    color: var(--color-success-solid);
}

/* ---- Inline field hint ("?") ------------------------------------------- */

.field-help {
    display: inline-block;
    margin-left: var(--space-2xs);
    vertical-align: middle;
}

.field-help > summary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: var(--radius-full);
    border: var(--border-width) solid var(--color-border-strong);
    background: var(--color-surface);
    color: var(--color-primary-text);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}

.field-help > summary::-webkit-details-marker {
    display: none;
}

.field-help[open] > summary {
    background: var(--color-primary-subtle);
}

.field-help__body {
    max-width: 22rem;
    margin-top: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-surface);
    border: var(--border-width) solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    font-size: var(--text-compact-size);
    font-weight: 400;
    white-space: normal;
}

/* ---- Guided tour overlay ------------------------------------------------ */

.help-tour-highlight {
    position: fixed;
    z-index: 1450;
    pointer-events: none; /* the user can still use the highlighted element themselves */
    border-radius: var(--radius-sm);
    outline: 3px solid var(--color-primary);
    outline-offset: 0;
    box-shadow: 0 0 0 9999px rgba(20, 33, 61, 0.45);
    transition: top 150ms ease, left 150ms ease, width 150ms ease, height 150ms ease;
}

.help-tour-highlight[hidden] {
    display: none;
}

.help-tour {
    position: fixed;
    z-index: 1460;
    width: min(22rem, calc(100vw - 1.5rem));
    padding: var(--space-md);
    background: var(--color-surface);
    color: var(--color-text-primary);
    border: 2px solid var(--color-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.help-tour--centered {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.help-tour--sheet {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    top: auto;
    width: auto;
    max-height: 60vh;
    overflow-y: auto;
}

.help-tour--sheet-top {
    top: 0.75rem;
    bottom: auto;
}

.help-tour__progress {
    margin: 0;
    color: var(--color-text-secondary);
    font-size: var(--text-caption-size);
    font-weight: 700;
}

.help-tour__title {
    margin: var(--space-2xs) 0 var(--space-xs);
    font-size: var(--text-section-title-size);
}

.help-tour__title:focus {
    outline: none;
}

.help-tour__body {
    margin: 0 0 var(--space-xs);
}

.help-tour__hint {
    margin: 0 0 var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: var(--color-info-bg);
    border-left: 4px solid var(--color-primary);
    font-size: var(--text-compact-size);
}

.help-tour__status {
    margin: 0 0 var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: var(--color-warning-bg);
    border-left: 4px solid var(--color-warning-border);
    color: var(--color-warning-text);
    font-size: var(--text-compact-size);
}

.help-tour__hint[hidden],
.help-tour__status[hidden] {
    display: none;
}

.help-tour__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-top: var(--space-sm);
}

@media (prefers-reduced-motion: reduce) {
    .help-tour-highlight {
        transition: none;
    }
}

@media (max-width: 640px) {
    .help-drawer {
        width: 100vw;
    }

    .help-drawer__search,
    .help-search {
        flex-wrap: wrap;
    }
}

/* ---- Category chips (v0.22 UX polish: "Caly dorobek") -------------------------
   The default .tabs strip scrolls horizontally, which showed a scrollbar on wide
   screens once twelve category tabs were present. Chips wrap onto further rows. */

.tabs--chips {
    flex-wrap: wrap;
    overflow-x: visible;
    gap: var(--space-xs);
    padding-bottom: 0;
    border-bottom: 0;
}

.tabs--chips .tabs__link {
    margin-bottom: 0;
    padding: 0.4rem 0.8rem;
    border: var(--border-width) solid var(--color-border-strong);
    border-radius: var(--radius-full);
    background: var(--color-surface);
    white-space: normal;
    text-align: center;
}

.tabs--chips .tabs__link.active,
.tabs--chips .tabs__link[aria-selected="true"] {
    border-color: var(--color-primary);
    background: var(--color-primary-subtle);
}
