/* ============================================================
   shelf.css — "The Shelf": a persistent, sitewide prompt shelf
   Global component. Loaded on every page after launchpad.css.

   The Shelf holds prompts that exist nowhere else yet — the ones
   someone forged in the hero, built in the Builder, or grabbed as
   Prompt of the Day. It survives navigation AND return visits
   (localStorage, not sessionStorage like the compare tray), and
   converts into a real account library on signup.

   z-index ladder it has to live inside:
     60   .cmp-tray          (compare tray, /tools)
     100  .site-header
     8000 .shelf-pill
     8600 .shelf-scrim / .shelf-drawer
     9000 .lp-sheet          (AI chooser — must sit ABOVE the drawer)
     9100 .lp-toast
   Added 2026-11-18 (pass 005).
   ============================================================ */

/* ── The "+ Shelf" button injected beside every Run button ──── */

.shelf-add {
    appearance: none;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 11px 16px;
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    color: var(--text-muted);
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--transition-fast), border-color var(--transition-fast),
                background var(--transition-fast), transform var(--transition-fast);
}

.shelf-add:hover {
    color: var(--text);
    border-color: var(--accent-orange);
    background: color-mix(in srgb, var(--accent-orange) 12%, var(--surface-2));
    transform: translateY(-1px);
}

.shelf-add:focus-visible {
    outline: 2px solid var(--accent-orange);
    outline-offset: 2px;
}

.shelf-add-ic {
    font-size: 1em;
    line-height: 1;
}

.shelf-add.is-on {
    color: var(--accent-green);
    border-color: color-mix(in srgb, var(--accent-green) 55%, transparent);
    background: color-mix(in srgb, var(--accent-green) 12%, var(--surface-2));
}

/* Compact variant, injected next to the little ⚡ icon buttons on cards */
.shelf-add--icon {
    padding: 0;
    width: 34px;
    height: 34px;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: var(--text-md);
}

.shelf-add--icon .shelf-add-label { display: none; }

/* ── The floating pill ──────────────────────────────────────── */

.shelf-pill {
    position: fixed;
    right: var(--space-6);
    bottom: var(--space-6);
    z-index: 8000;
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    padding: 12px 18px 12px 16px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--grad-primary);
    color: #0b0710;
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: 800;
    letter-spacing: -0.01em;
    cursor: pointer;
    box-shadow: var(--shadow-glow-orange), var(--shadow-md);
    transition: transform var(--transition-fast), box-shadow var(--transition-base),
                opacity var(--transition-base);
}

.shelf-pill[hidden] { display: none; }

.shelf-pill:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 38px rgba(255, 92, 53, 0.5);
}

.shelf-pill:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 3px;
}

.shelf-pill-ic { font-size: 1.05rem; line-height: 1; }

.shelf-pill-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: var(--radius-pill);
    background: rgba(11, 7, 16, 0.82);
    color: #fff;
    font-size: var(--text-xs);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

/* A short bump when something lands on the shelf */
.shelf-pill.is-bump { animation: shelfBump 0.45s ease; }

@keyframes shelfBump {
      0% { transform: translateY(0)    scale(1);    }
     35% { transform: translateY(-6px) scale(1.09); }
     65% { transform: translateY(0)    scale(0.98); }
    100% { transform: translateY(0)    scale(1);    }
}

/* Guests get a quiet ring once there is something worth losing */
.shelf-pill.is-at-risk::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: var(--radius-pill);
    border: 1px solid color-mix(in srgb, var(--accent-orange) 55%, transparent);
    animation: shelfRing 2.6s ease-out infinite;
    pointer-events: none;
}

@keyframes shelfRing {
      0% { opacity: 0.85; transform: scale(1);    }
    100% { opacity: 0;    transform: scale(1.18); }
}

/* ── Scrim + drawer ─────────────────────────────────────────── */

.shelf-scrim {
    position: fixed;
    inset: 0;
    z-index: 8600;
    background: rgba(4, 5, 12, 0.66);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
}

.shelf-scrim.is-open {
    opacity: 1;
    pointer-events: auto;
}

.shelf-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 8600;
    width: min(420px, 100vw);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-left: 1px solid var(--border-hover);
    box-shadow: -18px 0 48px rgba(0, 0, 0, 0.55);
    transform: translateX(100%);
    transition: transform var(--transition-base);
    will-change: transform;
}

.shelf-drawer.is-open { transform: translateX(0); }

.shelf-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-5) var(--space-4);
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
}

.shelf-head-title {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
    margin: 0;
}

.shelf-head-sub {
    margin: 4px 0 0;
    font-size: var(--text-xs);
    color: var(--text-muted);
    line-height: 1.5;
}

.shelf-close {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    font-size: var(--text-md);
    line-height: 1;
    cursor: pointer;
    flex: 0 0 auto;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.shelf-close:hover { color: var(--text); border-color: var(--border-hover); }

/* ── The list ───────────────────────────────────────────────── */

.shelf-list {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--space-4) var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.shelf-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-2);
    padding: var(--space-4);
    transition: border-color var(--transition-fast);
    animation: shelfIn var(--transition-base) both;
}

@keyframes shelfIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0);   }
}

.shelf-item:hover { border-color: var(--border-hover); }

.shelf-item-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-2);
}

.shelf-item-title {
    font-family: var(--font-display);
    font-size: var(--text-base);
    font-weight: 700;
    line-height: 1.35;
    color: var(--text);
    margin: 0;
    overflow-wrap: anywhere;
}

.shelf-item-drop {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--text-faint);
    font-size: var(--text-md);
    line-height: 1;
    padding: 2px 4px;
    cursor: pointer;
    flex: 0 0 auto;
    transition: color var(--transition-fast);
}

.shelf-item-drop:hover { color: var(--accent-orange); }

.shelf-item-text {
    font-family: var(--font-body);
    font-size: var(--text-xs);
    line-height: 1.6;
    color: var(--text-muted);
    margin: 0 0 var(--space-3);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.shelf-item-meta {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.shelf-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: var(--radius-pill);
    background: var(--surface-3);
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.01em;
}

.shelf-item-actions {
    display: flex;
    gap: var(--space-2);
    margin-left: auto;
}

.shelf-mini {
    appearance: none;
    border: 1px solid var(--border-hover);
    background: var(--surface-3);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    padding: 5px 11px;
    font-family: var(--font-display);
    font-size: var(--text-xs);
    font-weight: 700;
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast),
                background var(--transition-fast);
}

.shelf-mini:hover {
    color: var(--text);
    border-color: var(--accent-orange);
    background: color-mix(in srgb, var(--accent-orange) 14%, var(--surface-3));
}

.shelf-mini--run {
    color: #0b0710;
    background: var(--grad-primary);
    border-color: transparent;
}

.shelf-mini--run:hover {
    color: #0b0710;
    background: var(--grad-primary);
    border-color: transparent;
    filter: brightness(1.08);
}

/* ── Empty state ────────────────────────────────────────────── */

.shelf-empty {
    margin: auto 0;
    text-align: center;
    padding: var(--space-8) var(--space-4);
    color: var(--text-muted);
}

.shelf-empty-ic {
    font-size: 2.2rem;
    display: block;
    margin-bottom: var(--space-3);
    opacity: 0.55;
}

.shelf-empty-title {
    font-family: var(--font-display);
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--text);
    margin: 0 0 var(--space-2);
}

.shelf-empty p {
    font-size: var(--text-sm);
    line-height: 1.6;
    margin: 0;
}

/* ── Foot: the conversion ask ───────────────────────────────── */

.shelf-foot {
    flex: 0 0 auto;
    padding: var(--space-4) var(--space-5) calc(var(--space-5) + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.shelf-foot[hidden] { display: none; }

.shelf-warn {
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
    padding: var(--space-3) var(--space-4);
    border: 1px solid color-mix(in srgb, var(--accent-yellow) 38%, transparent);
    border-left: 3px solid var(--accent-yellow);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--accent-yellow) 9%, var(--surface-2));
    margin-bottom: var(--space-4);
}

.shelf-warn-ic {
    font-size: 1rem;
    line-height: 1.5;
    flex: 0 0 auto;
}

.shelf-warn p {
    margin: 0;
    font-size: var(--text-xs);
    line-height: 1.6;
    color: var(--text-muted);
}

.shelf-warn strong { color: var(--text); font-weight: 700; }

.shelf-cta {
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

.shelf-cta .btn { flex: 1 1 auto; justify-content: center; }

.shelf-foot-note {
    margin: var(--space-3) 0 0;
    text-align: center;
    font-size: var(--text-xs);
    color: var(--text-faint);
}

.shelf-foot-note a { color: var(--text-muted); text-decoration: underline; text-underline-offset: 2px; }
.shelf-foot-note a:hover { color: var(--accent-orange); }

.shelf-clear {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--text-faint);
    font-size: var(--text-xs);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
    padding: 0;
}

.shelf-clear:hover { color: var(--accent-orange); }

/* ── Small screens ──────────────────────────────────────────── */

@media (max-width: 600px) {
    .shelf-pill {
        right: var(--space-4);
        bottom: var(--space-4);
        padding: 11px 16px 11px 14px;
    }

    .shelf-drawer {
        width: 100vw;
        border-left: 0;
    }

    .shelf-add { padding: 10px 14px; }
}

/* The compare tray owns the bottom edge on /tools — step over it */
body:has(.cmp-tray:not([hidden])) .shelf-pill {
    bottom: calc(var(--space-6) + 76px);
}

@media (prefers-reduced-motion: reduce) {
    .shelf-pill,
    .shelf-drawer,
    .shelf-scrim,
    .shelf-item,
    .shelf-add {
        transition: none;
        animation: none;
    }

    .shelf-pill.is-at-risk::after { animation: none; }
}
