/* handbook.css: Captain's Handbook (onboarding) and Vesper's mentor styles. */
/* ============================================================
   Captain's Handbook (onboarding)
   templates/onboarding/*, partials/_dashboard_onboarding_card, _onboarding_welcome
   Vesper's signal mentor styles support the Handbook presentation; her art remains
   pending and the designed placeholder is the current presentation contract.
   ============================================================ */

/* ---------- Mentor persona (Vesper) ---------- */
.mentor { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.mentor__frame {
    position: relative;
    container-type: inline-size;
    /* Inline-size containment makes an auto-sized block collapse to its border
       box. Give each surface a real layout width, then let its max-width and
       aspect-ratio choose the compact displayed size. */
    width: 100%;
    aspect-ratio: 3 / 4;
    max-width: 260px;
    margin-inline: auto;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: linear-gradient(160deg,
        color-mix(in srgb, var(--color-primary) 16%, var(--bg-surface)) 0%,
        var(--bg-surface) 60%,
        color-mix(in srgb, var(--color-primary) 8%, var(--bg-subtle)) 100%);
    box-shadow: var(--shadow-md, 0 2px 8px rgba(0, 0, 0, 0.2)), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
/* contain, not cover: a hand-drawn 3:4 plate fills the 3:4 frame either way,
   but Vesper's square (500x500) server-generated portrait must letterbox over
   the frame's gradient rather than crop the Noodle Dragon's long body. */
.mentor__art { width: 100%; height: 100%; object-fit: contain; display: block; }

/* Placeholder until Vesper's plates land (personas/registry.py::art_ready): a
   stencilled navigator's plate, a designed placeholder, not a broken image. */
.mentor__stencil {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background-image: repeating-linear-gradient(135deg,
        color-mix(in srgb, var(--color-primary) 5%, transparent) 0 12px,
        transparent 12px 24px);
    color: color-mix(in srgb, var(--color-primary) 70%, var(--text-secondary));
}
.mentor__stencil { padding-inline: 7%; }
.mentor__stencil-mark { font-size: 30cqw; line-height: 1; opacity: 0.85; }
.mentor__stencil-name { font-family: var(--font-mono); font-size: 9cqw; font-weight: 700; letter-spacing: 0.14em; opacity: 0.7; max-width: 100%; text-align: center; overflow-wrap: anywhere; }
.mentor__stencil-sub { font-family: var(--font-mono); font-size: 5cqw; letter-spacing: 0.22em; opacity: 0.5; max-width: 100%; text-align: center; overflow-wrap: anywhere; }

.mentor__stencil--sm {
    position: static;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 1px solid color-mix(in srgb, var(--color-primary) 40%, var(--border-color));
    margin: 0 auto 4px;
    container-type: normal;
    background: var(--bg-subtle);
}
.mentor__stencil--sm .mentor__stencil-mark { font-size: 2.4rem; }

.mentor__speech {
    margin: 0;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--color-primary);
    background: var(--bg-subtle);
    font-size: 0.94rem;
    line-height: 1.5;
    color: var(--text-secondary);
}
.mentor__speech-name {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-primary);
    margin-bottom: 4px;
}
.mentor__speech-line { display: block; }

/* ---------- Vesper's live generated portrait ---------- */
/* Her portrait is a server-generated square composite that rerolls on a cadence:
   the rotation is her canon (a distributed, drifting VESPAR relay-mind), so the
   frame leans into a "live signal" read rather than hiding it. Size modifiers let
   the same frame serve the Handbook hero, the welcome modal, and the dashboard
   nudge. All motion below ends transparent/visible-at-rest so the global
   reduced-motion clamp (which jumps to the final keyframe) leaves it clean. */
.mentor__frame--signal { aspect-ratio: 1 / 1; }
.mentor__frame--md { max-width: 190px; }
.mentor__frame--sm { max-width: 120px; }

/* Each visit, her signal re-forms: a gentle fade-in of the freshly-loaded art. */
.mentor__frame--signal .mentor__art { animation: mentor-signal-in 0.8s ease both; }
@keyframes mentor-signal-in { from { opacity: 0; } to { opacity: 1; } }

/* A faint sheen sweeping across, so the portrait reads as a live transmission
   rather than a still. Ends off-frame and transparent on purpose. */
.mentor__sheen {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: linear-gradient(115deg, transparent 42%,
        color-mix(in srgb, var(--color-primary) 22%, transparent) 50%, transparent 58%);
    mix-blend-mode: screen;
    transform: translateX(-120%);
    animation: mentor-sheen 6.5s ease-in-out 1.2s infinite;
}
@keyframes mentor-sheen {
    0% { transform: translateX(-120%); opacity: 0; }
    10% { opacity: 1; }
    26% { transform: translateX(120%); opacity: 0; }
    100% { transform: translateX(120%); opacity: 0; }
}

/* In-world "signal reformed <timesince> ago" readout along the bottom edge.
   Hidden on the compact dashboard frame, where there is no room for it. */
.mentor__readout {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    padding: 12px 8px 5px;
    pointer-events: none;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-align: center;
    color: color-mix(in srgb, var(--color-primary) 60%, #ffffff);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.62), transparent);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}
.mentor__frame--sm .mentor__readout { display: none; }

/* Welcome-modal introduction: centered portrait with her spoken welcome below. */
.mentor--intro { align-items: center; text-align: center; margin: 8px 0 14px; }
.mentor--intro .mentor__speech { text-align: left; max-width: 44ch; }

/* ---------- Handbook page ---------- */
.handbook { display: flex; flex-direction: column; gap: 18px; }
.handbook__hero {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 20px;
}
@media (min-width: 768px) {
    .handbook__hero { grid-template-columns: minmax(0, 240px) minmax(0, 1fr); align-items: center; }
    .handbook__hero.handbook__hero--neutral { grid-template-columns: 1fr; }
}
.handbook__progress { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.handbook-progress__bar {
    height: 12px;
    border-radius: var(--radius-pill);
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    overflow: hidden;
}
.handbook-progress__fill {
    display: block;
    height: 100%;
    background: var(--gradient-primary);
    border-radius: inherit;
    transition: width 0.4s ease;
}
.handbook-progress__label { margin: 0; color: var(--text-secondary); }
.handbook-progress__claim { color: var(--color-reward); font-weight: 700; }
.handbook-progress__done { margin: 0; color: var(--color-reward); font-weight: 700; }
.handbook-progress__note { margin: 0; color: var(--text-muted); font-size: 0.9rem; }

.handbook-reminder { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.handbook-reminder .hint { margin: 0; }
.handbook-reminder__note { margin: 0; }

/* ---------- Chapters ---------- */
.handbook-chapter {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 18px;
}
.handbook-chapter__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.handbook-chapter__title { margin: 0; font-size: 1.15rem; }
.handbook-chapter__intro { margin: 0 0 14px; color: var(--text-secondary); }
.handbook-chapter--locked { border-style: dashed; opacity: 0.72; }
.handbook-chapter__lockhint { margin: 0; color: var(--text-muted); font-size: 0.92rem; }
/* Facts-first checklist: every chapter after the first is a disclosure whose summary
   carries the title and the done chip; the summary's padding replaces the head row's. */
.handbook-chapter--folded { padding: 0; }
.handbook-chapter--folded > summary { padding: 14px 18px; margin: 0; font-size: 1rem; flex-wrap: wrap; }
.handbook-chapter--folded > summary .handbook-chapter__title { font-size: 1.05rem; }
.handbook-chapter--folded > .handbook-chapter__intro,
.handbook-chapter--folded > .handbook-steps { margin-left: 18px; margin-right: 18px; }
.handbook-chapter--folded > .handbook-steps { margin-bottom: 18px; }
.handbook-chapter__lockhint--summary { padding: 4px 6px; }
.handbook-step__learn { font-size: 0.9em; white-space: nowrap; }
/* Create-a-companion: the randomizer/palette disclosure under the Colors heading. */
.workbench-advanced { margin: 0 0 10px; }
.workbench-advanced > .workbench-section-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
/* Daily Wheel header status line: chips wrap, and a chip's countdown may wrap inside it
   at phone width rather than push the row wider than the page. */
.wheel-status { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; }
.wheel-status .state-chip { white-space: normal; text-transform: none; letter-spacing: 0; font-family: inherit; font-size: 0.82rem; }
/* Facts-first Command Post: the brief news list (headline + age, no excerpt) and the
   flux strip's full-effect disclosure. */
.news-card-list--brief { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.news-card--brief { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding: 0; }
.news-card--brief a { font-weight: 600; }
.conditions-strip__details { margin-top: 4px; }
.conditions-strip__details > summary { font-size: 0.82rem; }

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

/* ---------- Step card ---------- */
.handbook-step {
    display: flex;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
}
.handbook-step.is-done { border-color: color-mix(in srgb, var(--color-primary) 35%, var(--border-color)); }
.handbook-step.is-claimable {
    border-color: color-mix(in srgb, var(--color-reward) 55%, var(--border-color));
    box-shadow: var(--glow-reward);
}
.handbook-step__marker {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 700;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-muted);
}
.handbook-step.is-done .handbook-step__marker {
    color: #fff;
    background: var(--color-primary);
    border-color: var(--color-primary);
}
.handbook-step__body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.handbook-step__headrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.handbook-step__title { margin: 0; font-size: 1.02rem; }
.handbook-step__blurb { margin: 0; color: var(--text-secondary); font-size: 0.94rem; line-height: 1.5; }
.handbook-step__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 2px; }
.handbook-step__claim { margin: 0; }
.handbook-step__receipt { font-family: var(--font-mono); font-size: 0.82rem; color: var(--color-reward); font-weight: 700; }
.handbook-step__reward { font-family: var(--font-mono); font-size: 0.82rem; color: var(--text-muted); }

/* ---------- Dashboard nudge card (extends .starter-cta) ---------- */
.handbook-cta { position: relative; }
/* Mentor layout: Vesper's portrait as a left aside, the nudge copy (with her
   spoken line) as the body. Stacks on narrow screens. */
.handbook-cta--mentor {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}
.handbook-cta__aside { width: 120px; }
.handbook-cta__body { min-width: 0; }
.handbook-cta__body > p:last-child { margin-bottom: 0; }
.handbook-cta__voice {
    margin: 0 0 12px;
    padding: 9px 12px;
    border-left: 3px solid var(--color-primary);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.45;
}
.handbook-cta__voice-name {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-primary);
    margin-bottom: 3px;
}
@media (max-width: 560px) {
    .handbook-cta--mentor { grid-template-columns: 1fr; }
    .handbook-cta__aside { width: 100px; }
}
.handbook-cta__dismiss-form { position: absolute; top: 10px; right: 10px; margin: 0; }
.handbook-cta__dismiss {
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    padding: 6px;
    border-radius: var(--radius-sm, 6px);
    min-width: 44px;
    min-height: 44px;
}
@media (hover: hover) { .handbook-cta__dismiss:hover { color: var(--text-primary); background: var(--bg-hover); } }
.handbook-cta__bar {
    height: 10px;
    margin: 12px 0 6px;
    border-radius: var(--radius-pill);
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    overflow: hidden;
}
.handbook-cta__fill { display: block; height: 100%; background: var(--gradient-primary); border-radius: inherit; transition: width 0.4s ease; }
.handbook-cta__count { margin: 0 0 14px; color: var(--text-muted); font-size: 0.86rem; font-family: var(--font-mono); }

/* ---------- Welcome modal (revealModal / modalShell) ---------- */
.handbook-welcome {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.handbook-welcome__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); }
.handbook-welcome__card {
    position: relative;
    width: min(460px, 100%);
    max-height: 90dvh;
    overflow-y: auto;
    background: var(--bg-surface);
    border: 1px solid color-mix(in srgb, var(--color-primary) 40%, var(--border-color));
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg, 0 10px 40px rgba(0, 0, 0, 0.4));
    padding: 24px;
    text-align: center;
}
.handbook-welcome__title { margin: 6px 0 10px; }
.handbook-welcome__line { margin: 0 0 12px; color: var(--text-primary); font-size: 1.02rem; line-height: 1.5; }
.handbook-welcome__note { margin: 0 0 18px; color: var(--text-secondary); font-size: 0.92rem; line-height: 1.5; }
.handbook-welcome__actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.handbook-welcome__actions form { margin: 0; }

