/* ── Device drawer (revamp version D: D1-D7, P2; DESIGN.md §6-§8) ───────────
   static/lib/assets/drawer.js + health.js. Floats over the list with a
   scrim, 16px radius on its leading edge, --shadow-3, slides in with the
   motion tokens (none with reduced motion). Focus is trapped and Escape
   closes it (page.js). Colours only via tokens. */

.ast-drawer-host { position: fixed; inset: 0; z-index: var(--z-drawer); }
.ast-drawer-host[hidden] { display: none; }
.ast-drawer-backdrop { position: absolute; inset: 0; background: var(--scrim); animation: ast-fade-in var(--dur-enter) var(--ease-out); }
.ast-drawer {
    position: absolute; top: 0; right: 0; bottom: 0;
    /* One width on every tab (docs/handoff.md 5.2): no tab resizes it; the
       device page ("Open full page") is the wide view. */
    width: 600px; max-width: 100vw;
    display: flex; flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    box-shadow: var(--shadow-3);
    outline: none;
    overflow: hidden;
    animation: ast-drawer-in var(--dur-enter) var(--ease-out);
}
@keyframes ast-drawer-in { from { transform: translateX(100%); } to { transform: none; } }
@keyframes ast-fade-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .ast-drawer, .ast-drawer-backdrop { animation: none; }
}

/* Head: ID chip, hero, meta, actions, tabs. */
.ast-drawer-head { flex: none; padding: 14px 18px 0; border-bottom: 1px solid var(--border-sub); }
.ast-drawer-top { display: flex; align-items: center; gap: 6px; }
.ast-spacer { flex: 1 1 auto; }
.ast-drawer-form-title { margin: 0; font-size: var(--fs-title); line-height: 28px; font-weight: 650; }
.ast-drawer-head:has(.ast-drawer-form-title) { padding-bottom: 12px; }
.ast-id-chip {
    display: inline-flex; align-items: center; gap: 2px;
    height: 26px; padding: 0 2px 0 9px;
    border-radius: var(--radius-sm);
    background: var(--sunken);
    font-size: var(--fs-13); color: var(--text-2);
}
.ast-id-copy {
    display: grid; place-items: center;
    width: 22px; height: 22px; padding: 0;
    border: 0; border-radius: var(--radius-xs);
    background: transparent; color: var(--text-3); cursor: pointer;
}
.ast-id-copy:hover { background: var(--hover); color: var(--text); }

.ast-hero { display: flex; align-items: center; gap: 12px; margin-top: 12px; min-width: 0; }
.ast-dev-ico-lg { width: 40px; height: 40px; border-radius: var(--radius-md); background: var(--accent-dim); color: var(--accent-text); }
.ast-hero-text { min-width: 0; }
.ast-hero h2 { margin: 0; font-size: var(--fs-18); line-height: 24px; font-weight: 650; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.ast-hero p { margin: 2px 0 0; font-size: var(--fs-13); color: var(--text-3); }
.ast-hero-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; font-size: var(--fs-13); }
.ast-region { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; border-radius: var(--radius-xs); background: var(--sunken); font-size: var(--fs-12); font-weight: 600; color: var(--text-2); }
.ast-drawer-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.ast-drawer-actions > .btn { flex: 1 1 0; }
.ast-drawer-actions .ast-menu { flex: none; }
.ast-drawer-actions .ast-menu-list { min-width: 220px; }
.tabs.ast-dtabs { margin: 12px -18px 0; padding: 0 12px; border-bottom: 0; }
.ast-dtabs .tab { height: 38px; }
.ast-dtabs .tab::after { bottom: 0; }

/* Body: one panel per tab. */
.ast-drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px 24px; }
.ast-panel-body { display: flex; flex-direction: column; gap: 20px; }
.ast-panel-body[hidden] { display: none; }
.ast-sec { min-width: 0; }
.ast-sec-title, .ast-drawer-body [data-tickets] > h3 {
    display: flex; align-items: center; gap: 8px;
    margin: 0 0 8px;
    font-size: var(--fs-13); font-weight: 600; letter-spacing: 0; text-transform: none;
    color: var(--text);
}
/* A section with nothing to show: its title and the one line saying so
   share a row. */
.ast-sec.is-empty { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.ast-sec.is-empty > .ast-sec-title { margin: 0; }
.ast-sec.is-empty > p { margin: 0; font-size: var(--fs-13); }
.ast-sec-act { margin-left: auto; font-size: var(--fs-13); font-weight: 500; color: var(--accent-text); text-decoration: none; }
.ast-drawer .ast-dialog {
    max-width: none; margin-bottom: 16px; padding: 12px;
    border: 1px solid var(--border-sub); border-radius: var(--radius-md);
    background: var(--surface-2); box-shadow: none;
}
.ast-drawer .ast-dialog[hidden] { display: none; }
.ast-drawer .ast-form-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.ast-drawer .ph { padding: 4px 0; }

/* Holder card (D3). */
.ast-holder-card {
    display: flex; align-items: center; gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--border-sub);
}
.ast-holder-card > .btn { flex: none; }
/* The holder has left Okta: a word and a shape, never colour alone. */
.ast-holder-card.is-gone { flex-wrap: wrap; box-shadow: inset 0 0 0 1px var(--warn); }
.ast-holder-alert {
    display: flex; align-items: center; gap: 6px; flex-basis: 100%;
    margin: 0; padding: 6px 8px;
    border-radius: var(--radius-sm);
    background: var(--warn-dim); color: var(--warn);
    font-size: var(--fs-13); font-weight: 600;
}
.ast-holder-alert svg { flex: none; }
.ast-avatar-lg { width: 40px; height: 40px; font-size: var(--fs-14); }
.ast-holder-ico { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--sunken); color: var(--text-3); }
.ast-who { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; font-size: var(--fs-13); }
.ast-who b { font-size: var(--fs-14); font-weight: 600; }
.ast-who > span, .ast-who > .ast-link { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-3); }
.ast-who > .ast-link { color: var(--accent-text); }

/* Source health (D4): a shape and words for a problem, never colour alone. */
.ast-health { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ast-health-note { margin: 0 0 8px; }
.ast-src {
    display: flex; align-items: center; gap: 10px; min-width: 0;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    box-shadow: inset 0 0 0 1px var(--border-sub);
}
.ast-src-logo { display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: var(--radius-xs); background: var(--sunken); font-size: var(--fs-11); font-weight: 700; color: var(--text-2); }
.ast-src-t { display: flex; flex-direction: column; min-width: 0; }
.ast-src-t b { font-size: var(--fs-13); font-weight: 600; line-height: 17px; }
.ast-src-t span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-12); line-height: 16px; color: var(--text-3); }
.ast-src-st { display: grid; place-items: center; flex: none; width: 18px; height: 18px; margin-left: auto; border-radius: 50%; }
.ast-src.is-ok .ast-src-st { background: var(--success-dim); color: var(--success); }
.ast-src.is-warn { background: var(--warn-dim); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 35%, transparent); }
.ast-src.is-warn .ast-src-st, .ast-src.is-warn .ast-src-t span { color: var(--warn); }
.ast-src.is-unknown .ast-src-st { color: var(--text-3); box-shadow: inset 0 0 0 1.5px var(--border-strong); }

/* Device facts: vendor values carry a source tag (DESIGN.md §6). */
.ast-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin: 0; }
.ast-facts dt { font-size: var(--fs-12); color: var(--text-3); }
.ast-facts dd { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.ast-facts .ast-src-tag { margin-left: 0; }
.ast-facts .ast-copy { width: 24px; height: 24px; }
.ast-facts-note { margin: 10px 0 0; }

/* Sources disagree: every value with who says it; no winner picked. */
.ast-disagree {
    margin-top: 12px; padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--conflict-dim);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--conflict) 30%, transparent);
}
.ast-disagree-title { display: flex; align-items: center; gap: 6px; margin: 0; font-size: var(--fs-13); font-weight: 600; color: var(--conflict); }
.ast-disagree-rows { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; margin: 6px 0; font-size: var(--fs-13); }
.ast-disagree-rows .mono { overflow-wrap: anywhere; }
.ast-disagree-rows .is-truth { font-weight: 600; }
.ast-disagree-who { font-size: var(--fs-12); color: var(--text-2); text-align: right; }
.ast-disagree .ast-link { font-size: var(--fs-13); font-weight: 500; color: var(--accent-text); }

.ast-notes { margin: 0; white-space: pre-wrap; }

/* History as a vertical timeline (D5): also the person page. */
.ast-timeline, .ast-timeline-short { display: grid; margin: 0; padding: 0; list-style: none; }
.ast-timeline li, .ast-timeline-short li { position: relative; display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 10px; padding-bottom: 14px; }
.ast-timeline li:last-child, .ast-timeline-short li:last-child { padding-bottom: 0; }
.ast-timeline li::before, .ast-timeline-short li::before { content: ''; position: absolute; left: 8.5px; top: 16px; bottom: -2px; width: 1px; background: var(--border-strong); }
.ast-timeline li:last-child::before, .ast-timeline-short li:last-child::before { display: none; }
.ast-tl-dot { width: 10px; height: 10px; margin: 5px 0 0 4px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 2px var(--border-strong); }
.ast-tl-dot.is-on { background: var(--accent-dim); box-shadow: inset 0 0 0 2px var(--accent); }
.ast-tl-body { display: flex; flex-direction: column; min-width: 0; font-size: var(--fs-13); }
.ast-tl-text { color: var(--text); overflow-wrap: anywhere; }
.ast-tl-meta { font-size: var(--fs-12); color: var(--text-3); }
.ast-sec .ast-timeline-short + .ast-link { margin-top: 10px; font-size: var(--fs-13); }

/* Purchase (D6): read view, Edit swaps in the form. */
.ast-purchase-form { margin-top: 4px; }
.ast-purchase-form .ast-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 720px) {
    .ast-drawer { width: 100vw; border-radius: 0; }
    .ast-health, .ast-facts, .ast-purchase-form .ast-form-grid { grid-template-columns: minmax(0, 1fr); }
}
