/* ============================================================
   TOOL CHROME — shared breadcrumb bar for interactive tools
   ------------------------------------------------------------
   Styles for the bar injected by js/tool-chrome.js. Token
   fallbacks are provided so the bar renders sensibly even on a
   tool page that doesn't load design-system/styles.css.
   ============================================================ */

.tool-chrome {
    display: flex;
    align-items: center;
    gap: var(--space-3, 12px);
    padding: 10px clamp(16px, 4vw, 32px);
    background: var(--surface-1, #14161a);
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
    font-family: var(--font-sans, 'Inter', system-ui, sans-serif);
    font-size: var(--text-body-sm, 0.875rem);
    line-height: 1.4;
}

.tool-chrome-logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary, #f2f4f8);
    text-decoration: none;
    font-weight: var(--fw-medium, 500);
    white-space: nowrap;
}

.tool-chrome-sep {
    color: var(--text-tertiary, #6b7280);
    flex: none;
}

.tool-chrome a:not(.tool-chrome-logo) {
    color: var(--text-secondary, #9aa3b2);
    text-decoration: none;
    white-space: nowrap;
    transition: color var(--dur-fast, 150ms) var(--ease-out, ease-out);
}

.tool-chrome a:hover {
    color: var(--text-primary, #f2f4f8);
}

.tool-chrome-current {
    color: var(--text-primary, #f2f4f8);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* On narrow screens keep the bar to logo + library link + title. */
@media (max-width: 480px) {
    .tool-chrome-logo span {
        display: none;
    }
}

/* ============================================================
   AI LEARNING COACH — floating widget injected by tool-chrome.js
   (only when the server reports the coach enabled)
   ============================================================ */

.coach-widget {
    position: fixed;
    right: clamp(12px, 3vw, 24px);
    bottom: clamp(12px, 3vw, 24px);
    z-index: 60;
    font-family: var(--font-sans, 'Inter', system-ui, sans-serif);
    font-size: var(--text-body-sm, 0.875rem);
}

.coach-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
    border-radius: 999px;
    background: var(--surface-1, #14161a);
    color: var(--text-primary, #f2f4f8);
    font: inherit;
    font-weight: var(--fw-medium, 500);
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.coach-toggle:hover { border-color: var(--accent, #3D8BFF); }
.coach-toggle span { color: var(--accent, #3D8BFF); }

.coach-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    width: min(340px, calc(100vw - 32px));
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
    border-radius: 12px;
    background: var(--surface-1, #14161a);
    color: var(--text-primary, #f2f4f8);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.coach-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    font-weight: var(--fw-medium, 500);
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
}

.coach-close {
    border: none;
    background: none;
    color: var(--text-secondary, #9aa3b2);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
}
.coach-close:hover { color: var(--text-primary, #f2f4f8); }

.coach-messages {
    max-height: 280px;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.coach-msg {
    padding: 8px 12px;
    border-radius: 10px;
    line-height: 1.5;
    max-width: 90%;
    overflow-wrap: break-word;
}

.coach-msg-user {
    align-self: flex-end;
    background: var(--accent, #3D8BFF);
    color: #fff;
}

.coach-msg-assistant {
    align-self: flex-start;
    background: var(--surface-2, rgba(255, 255, 255, 0.06));
}

.coach-msg a { color: var(--accent, #3D8BFF); }

.coach-form {
    display: flex;
    gap: 8px;
    padding: 10px 14px 12px;
    border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
}

.coach-form textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font: inherit;
    padding: 8px 10px;
}

.coach-send {
    border: none;
    border-radius: 8px;
    background: var(--accent, #3D8BFF);
    color: #fff;
    font: inherit;
    font-weight: var(--fw-medium, 500);
    padding: 0 14px;
    cursor: pointer;
}
.coach-send:disabled { opacity: 0.6; cursor: default; }

.coach-widget .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

@media (prefers-reduced-motion: no-preference) {
    .coach-panel { animation: coach-pop 140ms ease-out; }
    @keyframes coach-pop {
        from { opacity: 0; transform: translateY(6px); }
        to { opacity: 1; transform: none; }
    }
}

/* ============================================================
   MODULE RATING — "Was this useful?" (signed-in learners)
   ============================================================ */
.rate-widget {
    max-width: 640px;
    margin: 32px auto;
    padding: 18px 20px;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
    border-radius: 12px;
    background: var(--surface-1, #14161a);
    font-family: var(--font-sans, 'Inter', system-ui, sans-serif);
    text-align: center;
}
.rate-title { margin: 0 0 8px; color: var(--text-primary, #f2f4f8); font-weight: var(--fw-medium, 500); }
.rate-stars { display: inline-flex; gap: 4px; }
.rate-star {
    border: none;
    background: none;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-tertiary, #6b7280);
    padding: 2px 4px;
    transition: color var(--dur-fast, 120ms) var(--ease-out, ease-out);
}
.rate-star.is-on { color: #f5b301; }
.rate-star:hover { color: #f5b301; }
.rate-comment { display: flex; gap: 8px; margin-top: 12px; }
.rate-comment textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
    border-radius: 8px;
    background: transparent;
    color: var(--text-primary, #f2f4f8);
    font: inherit;
    padding: 8px 10px;
}
.rate-save {
    border: none;
    border-radius: 8px;
    background: var(--accent, #3D8BFF);
    color: #fff;
    font: inherit;
    font-weight: var(--fw-medium, 500);
    padding: 0 16px;
    cursor: pointer;
}
.rate-thanks { margin: 10px 0 0; color: var(--accent, #3D8BFF); }
.rate-widget .visually-hidden {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.rate-widget .hidden { display: none; }

/* ============================================================
   MODULE DISCUSSION — company-scoped comments + social proof
   ============================================================ */
.discuss-widget {
    max-width: 640px;
    margin: 24px auto 40px;
    padding: 20px 22px;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
    border-radius: 12px;
    background: var(--surface-1, #14161a);
    font-family: var(--font-sans, 'Inter', system-ui, sans-serif);
    color: var(--text-primary, #f2f4f8);
}
.discuss-title { font-size: 1.1rem; margin: 0 0 8px; }
.discuss-proof { margin: 0 0 14px; color: var(--text-secondary, #9aa3b2); font-size: var(--text-body-sm, 0.875rem); }
.discuss-form { display: flex; gap: 8px; margin-bottom: 16px; }
.discuss-form textarea {
    flex: 1; resize: vertical; min-height: 42px;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
    border-radius: 8px; background: transparent; color: inherit; font: inherit; padding: 8px 10px;
}
.discuss-post {
    border: none; border-radius: 8px; background: var(--accent, #3D8BFF); color: #fff;
    font: inherit; font-weight: var(--fw-medium, 500); padding: 0 16px; cursor: pointer; align-self: flex-start; height: 42px;
}
.discuss-post:disabled { opacity: 0.6; cursor: default; }
.discuss-list { display: flex; flex-direction: column; gap: 12px; }
.discuss-comment { padding: 10px 12px; border-radius: 8px; background: var(--surface-2, rgba(255, 255, 255, 0.05)); }
.discuss-comment p { margin: 4px 0 0; line-height: 1.5; overflow-wrap: break-word; }
.discuss-meta { display: flex; align-items: center; gap: 8px; font-size: var(--text-body-sm, 0.875rem); }
.discuss-meta span { color: var(--text-tertiary, #6b7280); }
.discuss-del { margin-left: auto; border: none; background: none; color: var(--text-tertiary, #6b7280); font-size: 1.1rem; line-height: 1; cursor: pointer; padding: 0 4px; }
.discuss-del:hover { color: var(--danger, #e5534b); }
.discuss-empty { color: var(--text-tertiary, #6b7280); margin: 0; }
.discuss-widget .visually-hidden {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
