/* ─── Coach help assistant ─────────────────────────────────────────────────
   The "?" in the topbar opens a chat panel on the right. "How do I…" answers
   come with a walkthrough: a spotlight box around each control, a simulated
   cursor that travels and clicks, and a step card. help-assistant.js owns the
   behavior; the panel and spotlight markup live at the end of index.html. */

:root {
    --coach-help-w: 384px;
    --coach-help-bg: #0e0e0e;
    --coach-help-surface: #171717;
    --coach-help-surface-2: #1f1f1f;
    --coach-help-line: rgba(255, 255, 255, 0.1);
    --coach-help-line-strong: rgba(255, 255, 255, 0.18);
    --coach-help-ink: #f7f7f4;
    --coach-help-muted: #a3a29c;
    --coach-help-dim: rgba(4, 8, 12, 0.42);
}

/* Topbar trigger, between the team switcher and the invite code. */
.topbar-help {
    display: flex;
    align-items: center;
    padding-right: 12px;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.coach-help-trigger {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 800;
    line-height: 1;
}

.coach-help-trigger:hover {
    border-color: rgba(255, 255, 255, 0.58);
    background: rgba(255, 255, 255, 0.12);
}

.coach-help-trigger[aria-expanded="true"] {
    border-color: var(--brand);
    background: var(--brand);
    color: #090909;
}

.coach-help-trigger:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.75);
    outline-offset: 3px;
}

/* ─── Panel ─── */

.coach-help-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 85;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    width: var(--coach-help-w);
    max-width: 100vw;
    border-left: 1px solid var(--coach-help-line-strong);
    background: var(--coach-help-bg);
    color: var(--coach-help-ink);
    box-shadow: -18px 0 48px rgba(0, 0, 0, 0.38);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 240ms cubic-bezier(0.22, 0.8, 0.26, 1), visibility 0s linear 240ms;
}

.coach-help-panel.is-open {
    transform: none;
    visibility: visible;
    transition: transform 240ms cubic-bezier(0.22, 0.8, 0.26, 1), visibility 0s;
}

/* Wide screens: the panel takes its own column instead of covering the page,
   so a walkthrough's targets are never hidden behind it. */
@media (min-width: 1180px) {
    .shell {
        transition: padding-right 240ms cubic-bezier(0.22, 0.8, 0.26, 1);
    }

    body.coach-help-docked .shell {
        padding-right: var(--coach-help-w);
    }

    body.coach-help-docked .modal,
    body.coach-help-docked .quick-import-confirm-bar {
        right: var(--coach-help-w);
    }

    body.coach-help-docked .coach-help-panel {
        box-shadow: none;
    }
}

.coach-help-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: var(--topbar-h, 64px);
    padding: 10px 14px 10px 18px;
    border-bottom: 1px solid var(--coach-help-line-strong);
}

.coach-help-head-copy {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.coach-help-badge {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--brand);
    color: #090909;
    font-size: 0.9rem;
    font-weight: 900;
}

.coach-help-head h2 {
    margin: 0;
    font-family: var(--display);
    font-size: 1.32rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    line-height: 1.05;
}

.coach-help-head p {
    margin: 2px 0 0;
    color: var(--coach-help-muted);
    font-size: 0.78rem;
}

.coach-help-head-actions {
    display: flex;
    gap: 4px;
}

.coach-help-icon-button {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--coach-help-muted);
    cursor: pointer;
}

.coach-help-icon-button:hover {
    border-color: var(--coach-help-line);
    background: rgba(255, 255, 255, 0.06);
    color: var(--coach-help-ink);
}

.coach-help-icon-button:focus-visible,
.coach-help-chip:focus-visible,
.coach-help-show-me:focus-visible,
.coach-help-step-link:focus-visible,
.coach-help-send:focus-visible,
.coach-help-card-actions button:focus-visible {
    outline: 2px solid rgba(20, 149, 218, 0.85);
    outline-offset: 2px;
}

/* ─── Conversation ─── */

.coach-help-log {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px 16px 12px;
    scrollbar-width: thin;
}

.coach-help-msg {
    max-width: 92%;
    font-size: 0.875rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.coach-help-msg p {
    margin: 0 0 8px;
}

.coach-help-msg p:last-child,
.coach-help-msg ul:last-child,
.coach-help-msg ol:last-child {
    margin-bottom: 0;
}

.coach-help-msg ul,
.coach-help-msg ol {
    margin: 0 0 8px;
    padding-left: 20px;
}

.coach-help-msg li + li {
    margin-top: 3px;
}

.coach-help-msg strong {
    color: #ffffff;
    font-weight: 700;
}

.coach-help-msg.is-user {
    align-self: flex-end;
    padding: 9px 13px;
    border-radius: 14px 14px 4px 14px;
    background: linear-gradient(135deg, #1495da, #0e78b5);
    color: #06121b;
    font-weight: 500;
}

.coach-help-msg.is-user strong {
    color: inherit;
}

.coach-help-msg.is-assistant {
    align-self: flex-start;
    padding: 11px 13px;
    border: 1px solid var(--coach-help-line);
    border-radius: 14px 14px 14px 4px;
    background: var(--coach-help-surface);
    color: #e8e8e3;
}

.coach-help-msg.is-error {
    border-color: rgba(251, 113, 133, 0.38);
    background: rgba(251, 113, 133, 0.08);
    color: #fecdd3;
}

.coach-help-msg.is-welcome {
    max-width: 100%;
}

.coach-help-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.coach-help-chip {
    padding: 7px 11px;
    border: 1px solid var(--coach-help-line-strong);
    border-radius: 999px;
    background: transparent;
    color: var(--coach-help-ink);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    text-align: left;
}

.coach-help-chip:hover {
    border-color: rgba(20, 149, 218, 0.7);
    background: rgba(20, 149, 218, 0.1);
}

.coach-help-steps {
    display: grid;
    gap: 2px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
    counter-reset: coach-help-step;
}

.coach-help-step-link {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 6px 8px 6px 4px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #d9d9d4;
    cursor: pointer;
    font-size: 0.82rem;
    text-align: left;
}

.coach-help-step-link::before {
    counter-increment: coach-help-step;
    content: counter(coach-help-step);
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    border: 1px solid var(--coach-help-line-strong);
    border-radius: 50%;
    color: var(--coach-help-muted);
    font-size: 0.68rem;
    font-weight: 800;
}

.coach-help-step-link:hover {
    background: rgba(255, 255, 255, 0.05);
}

.coach-help-step-link.is-current {
    background: rgba(20, 149, 218, 0.12);
    color: #ffffff;
}

.coach-help-step-link.is-current::before {
    border-color: var(--brand);
    background: var(--brand);
    color: #06121b;
}

.coach-help-step-link.is-done::before {
    border-color: rgba(52, 211, 153, 0.6);
    color: #34d399;
}

.coach-help-show-me {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 10px;
    padding: 7px 12px;
    border: 1px solid var(--brand);
    border-radius: 999px;
    background: var(--brand);
    color: #06121b;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 800;
}

.coach-help-show-me.is-secondary {
    background: transparent;
    color: var(--blue-300, #73c8ec);
}

.coach-help-show-me:hover {
    filter: brightness(1.08);
}

.coach-help-show-me:disabled {
    cursor: default;
    opacity: 0.55;
}

.coach-help-typing {
    display: inline-flex;
    gap: 4px;
    padding: 4px 2px;
}

.coach-help-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--coach-help-muted);
    animation: coach-help-typing 1s infinite ease-in-out;
}

.coach-help-typing span:nth-child(2) { animation-delay: 0.15s; }
.coach-help-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes coach-help-typing {
    0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

/* ─── Composer ─── */

.coach-help-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin: 0 14px;
    padding: 8px 8px 8px 14px;
    border: 1px solid var(--coach-help-line-strong);
    border-radius: 14px;
    background: var(--coach-help-surface);
}

.coach-help-form:focus-within {
    border-color: rgba(20, 149, 218, 0.72);
    box-shadow: 0 0 0 3px rgba(20, 149, 218, 0.14);
}

.coach-help-form textarea {
    flex: 1 1 auto;
    min-width: 0;
    max-height: 120px;
    padding: 6px 0;
    border: 0;
    background: transparent;
    color: var(--coach-help-ink);
    font: inherit;
    font-size: 0.875rem;
    line-height: 1.4;
    resize: none;
}

.coach-help-form textarea:focus {
    outline: none;
}

.coach-help-form textarea::placeholder {
    color: #77766f;
}

.coach-help-send {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: var(--brand);
    color: #06121b;
    cursor: pointer;
}

.coach-help-send:disabled {
    background: var(--coach-help-surface-2);
    color: #66655f;
    cursor: default;
}

.coach-help-meta {
    min-height: 1.2em;
    margin: 8px 16px 14px;
    color: #77766f;
    font-size: 0.72rem;
    text-align: center;
}

.coach-help-meta-out {
    color: #fb7185;
    font-weight: 600;
}

/* ─── Walkthrough ─── */

.coach-help-spotlight {
    position: fixed;
    z-index: 80;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border: 2px solid var(--brand);
    border-radius: 10px;
    box-shadow:
        0 0 0 4px rgba(20, 149, 218, 0.22),
        0 0 26px rgba(20, 149, 218, 0.5),
        0 0 0 100vmax var(--coach-help-dim);
    opacity: 0;
    pointer-events: none;
    transition: top 280ms ease, left 280ms ease, width 280ms ease, height 280ms ease, opacity 200ms ease;
}

.coach-help-spotlight.is-visible {
    opacity: 1;
}

.coach-help-spotlight.is-pulsing {
    animation: coach-help-pulse 1.6s ease-in-out infinite;
}

@keyframes coach-help-pulse {
    0%, 100% { border-color: var(--brand); }
    50% { border-color: #73c8ec; }
}

/* Sample text "typed" over an empty field. It is drawn on top of the field,
   never written into it, so the coach's form stays untouched; the field's own
   placeholder steps aside while it plays. */
.coach-help-ghost-target::placeholder {
    color: transparent !important;
}

.coach-help-ghost {
    position: fixed;
    z-index: 81;
    display: flex;
    align-items: center;
    overflow: hidden;
    color: rgba(20, 149, 218, 0.95);
    font-style: italic;
    pointer-events: none;
    white-space: pre;
}

.coach-help-ghost::after {
    content: "";
    width: 2px;
    height: 1.15em;
    margin-left: 1px;
    background: var(--brand);
    animation: coach-help-caret 0.9s steps(1) infinite;
}

@keyframes coach-help-caret {
    50% { opacity: 0; }
}

.coach-help-cursor {
    position: fixed;
    z-index: 91;
    top: 0;
    left: 0;
    width: 26px;
    height: 26px;
    opacity: 0;
    pointer-events: none;
    transform: translate3d(-40px, -40px, 0);
    transition: transform 720ms cubic-bezier(0.22, 0.8, 0.26, 1), opacity 200ms ease;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.45));
}

.coach-help-cursor.is-visible {
    opacity: 1;
}

.coach-help-cursor.is-parked {
    transition: opacity 200ms ease;
}

.coach-help-cursor svg {
    display: block;
    width: 26px;
    height: 26px;
    transition: transform 120ms ease;
}

.coach-help-cursor.is-clicking svg {
    transform: scale(0.84);
}

/* Centered on the arrow's tip (3px, 2.5px). */
.coach-help-cursor-ring {
    position: absolute;
    top: -12.5px;
    left: -12px;
    width: 30px;
    height: 30px;
    border: 2px solid var(--brand);
    border-radius: 50%;
    opacity: 0;
}

.coach-help-cursor.is-clicking .coach-help-cursor-ring {
    animation: coach-help-ripple 620ms ease-out;
}

@keyframes coach-help-ripple {
    0% { opacity: 0.95; transform: scale(0.3); }
    100% { opacity: 0; transform: scale(1.7); }
}

.coach-help-card {
    position: fixed;
    z-index: 90;
    top: 0;
    left: 0;
    width: min(310px, calc(100vw - 24px));
    padding: 14px 14px 12px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    background: #121212;
    color: var(--coach-help-ink);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
    transition: top 280ms ease, left 280ms ease, opacity 180ms ease;
}

.coach-help-card[hidden] {
    display: none;
}

.coach-help-card-count {
    margin: 0 0 4px;
    color: var(--blue-300, #73c8ec);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.coach-help-card h3 {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 800;
    line-height: 1.3;
}

.coach-help-card-detail {
    margin: 5px 0 0;
    color: #c9c8c2;
    font-size: 0.83rem;
    line-height: 1.45;
}

.coach-help-card-detail:empty {
    display: none;
}

.coach-help-card-hint {
    margin: 8px 0 0;
    color: #8f8e88;
    font-size: 0.74rem;
}

.coach-help-card-hint:empty {
    display: none;
}

.coach-help-card-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
}

.coach-help-card-actions button {
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid var(--coach-help-line-strong);
    border-radius: 8px;
    background: transparent;
    color: var(--coach-help-ink);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 700;
}

.coach-help-card-actions button:hover {
    background: rgba(255, 255, 255, 0.07);
}

.coach-help-card-actions button:disabled {
    cursor: default;
    opacity: 0.4;
}

.coach-help-card-actions [data-help-guide="exit"] {
    margin-right: auto;
    border-color: transparent;
    color: var(--coach-help-muted);
}

.coach-help-card-actions [data-help-guide="next"] {
    border-color: var(--brand);
    background: var(--brand);
    color: #06121b;
}

.coach-help-card-actions [data-help-guide="next"]:hover {
    background: #3faee2;
}

@media (max-width: 640px) {
    :root {
        --coach-help-w: 100vw;
    }

    .topbar-help {
        padding-right: 8px;
    }

    .coach-help-trigger {
        width: 32px;
        height: 32px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .coach-help-panel,
    .coach-help-panel.is-open,
    .shell,
    .coach-help-spotlight,
    .coach-help-cursor,
    .coach-help-card {
        transition: none;
    }

    .coach-help-spotlight.is-pulsing,
    .coach-help-typing span {
        animation: none;
    }
}
