/* ==========================================================================
   The handbook (AI-1897): the pages on the left (the skills page's master-detail),
   the open page on the right with "What the team knows": what waits for a colleague
   first, tinted, then the rules that hold. Plus the two places the handbook reaches
   into the rest of the app: the "Remember for next time?" card after a send, and the
   "Why didn't it fit?" line after clearing a proposal.
   ========================================================================== */

.handbook-banner {
    margin-bottom: 16px;
}

.handbook-pages__divider {
    margin: 0 12px;
}

/* ---------- Rules -------------------------------------------------------- */

.handbook-rules {
    gap: 10px;
}

.handbook-rules__list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.handbook-rule {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px 14px;
    padding: 12px 14px;
    border: 1px solid var(--ui-glass-line);
    border-radius: var(--ui-radius);
    background: var(--ui-glass-thin);
}

.handbook-rule.is-waiting {
    border-color: color-mix(in srgb, var(--ui-tone-warning) 45%, transparent);
    background: color-mix(in srgb, var(--ui-tone-warning) 7%, var(--ui-glass-thin));
}

.handbook-rule__statement {
    grid-column: 1;
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.handbook-rule__change {
    grid-column: 1;
    margin: 0;
    color: var(--ui-text);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.4;
}

.handbook-rule__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    grid-column: 1;
    color: var(--ui-text-3);
    font-size: 0.78rem;
}

.handbook-rule__numbers {
    font-variant-numeric: tabular-nums;
}

.handbook-rule__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    grid-row: 1 / span 2;
    grid-column: 2;
}

@media (max-width: 599.98px) {
    .handbook-rule {
        grid-template-columns: minmax(0, 1fr);
    }

    .handbook-rule__actions {
        grid-row: auto;
        grid-column: 1;
        justify-content: flex-start;
    }
}

.handbook-rule-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--ui-glass-line);
    border-radius: var(--ui-radius);
    background: var(--ui-glass-thin);
}

.handbook-rule-form__row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
    gap: 12px;
}

.handbook-rule-form__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.handbook-rules__earlier-list {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    list-style: none;
}

.handbook-rules__earlier-list > li {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 0;
    border-top: 1px solid var(--ui-divider);
}

.handbook-rules__earlier-list > li:first-child {
    border-top: 0;
}

.handbook-rules__earlier-statement {
    color: var(--ui-text-2);
    font-size: 0.875rem;
    overflow-wrap: anywhere;
}

/* ---------- Remember for next time? ------------------------------------ */
/* Bottom-right above the dock's launcher, wherever the colleague is in the app; on a
   phone full width above the navigation bar. */

.handbook-remember {
    position: fixed;
    right: 20px;
    bottom: 90px;
    z-index: 1150;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: min(430px, calc(100vw - 40px));
    max-height: calc(100dvh - 140px);
    padding: 16px;
    overflow: auto;
    border: 1px solid var(--ui-glass-line);
    border-radius: var(--ui-radius-lg);
    background: var(--ui-glass-strong);
    box-shadow: var(--ui-glass-edge), var(--ui-shadow-raised);
    color: var(--ui-text);
    -webkit-backdrop-filter: var(--ui-glass-filter-strong);
    backdrop-filter: var(--ui-glass-filter-strong);
    animation: handbook-remember-in 200ms var(--ui-ease);
}

@keyframes handbook-remember-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .handbook-remember {
        animation: none;
    }
}

.handbook-remember__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.handbook-remember__title {
    margin: 0;
    font-family: var(--ui-font-display, var(--ui-font));
    font-size: 1.05rem;
    font-weight: 600;
}

.handbook-remember__subtitle {
    margin: 2px 0 0;
    color: var(--ui-text-2);
    font-size: 0.8125rem;
}

.handbook-remember__rules {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.handbook-remember__rule {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--ui-glass-line);
    border-radius: var(--ui-radius);
    background: var(--ui-glass-thin);
}

.handbook-remember__statement {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.handbook-remember__where {
    display: block;
    margin-top: 3px;
    color: var(--ui-text-3);
    font-size: 0.75rem;
}

.handbook-remember__answers {
    display: flex;
    gap: 6px;
}

.handbook-remember__footer {
    margin: 0;
    color: var(--ui-text-3);
    font-size: 0.78rem;
}

@media (max-width: 767.98px) {
    .handbook-remember {
        right: 8px;
        bottom: calc(var(--app-mobile-nav-reserve, 68px) + 8px);
        left: 8px;
        width: auto;
        max-height: calc(100dvh - var(--app-mobile-nav-reserve, 68px) - 80px);
    }
}

/* ---------- Why didn't it fit? ------------------------------------------ */
/* One line above the composer after clearing a proposal: a tap or skip, never in the way. */

.composer-reject-reason {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--ui-glass-line);
    border-radius: var(--ui-radius);
    background: var(--ui-glass-thin);
}

.composer-reject-reason__question {
    margin-right: 4px;
    color: var(--ui-text-2);
    font-size: 0.84rem;
}

/* A page's row fills its button: a long title ends in an ellipsis next to its source chip instead of being cut at both ends. */
.handbook-page .agents-list__item {
    align-items: stretch;
    text-align: left;
}

.handbook-page .agents-list__row {
    width: 100%;
}
