/* Floating generation-in-progress pill.
   Lives in the bottom-right corner and persists across page navigation by reading
   sessionStorage on every page load (see generation-pill.js). */

.gen-pill {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 1090;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 220px;
    max-width: 340px;
    padding: 0.7rem 0.85rem 0.7rem 0.95rem;
    background: #fff;
    border: 1px solid var(--rule, #E2E5EC);
    border-radius: 999px;
    box-shadow: 0 10px 28px rgba(14, 37, 64, 0.16);
    font-size: 0.88rem;
    color: var(--ink, #0E2540);
    transform: translateY(8px);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease, box-shadow 0.2s ease;
}

.gen-pill.is-visible {
    transform: translateY(0);
    opacity: 1;
}

.gen-pill--ready {
    cursor: pointer;
}

.gen-pill--ready:hover {
    box-shadow: 0 14px 32px rgba(14, 37, 64, 0.22);
}

.gen-pill--leaving {
    opacity: 0;
    transform: translateY(8px);
}

.gen-pill-spinner {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    border: 2px solid var(--blueSoft, #C8D5EB);
    border-top-color: var(--blueDeep, #1A3A6B);
    border-radius: 50%;
    animation: gen-pill-spin 0.8s linear infinite;
}

@keyframes gen-pill-spin {
    to { transform: rotate(360deg); }
}

.gen-pill--ready .gen-pill-spinner {
    border: none;
    border-radius: 50%;
    background: #1F5236;
    animation: none;
    position: relative;
}

.gen-pill--ready .gen-pill-spinner::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 10px;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(45deg);
}

.gen-pill--error .gen-pill-spinner {
    border: none;
    background: #7A1E1E;
    animation: none;
}

.gen-pill--failed {
    cursor: pointer;
    background: #FBECEC;
    border-color: #F0CFCF;
}

.gen-pill--failed:hover {
    box-shadow: 0 14px 32px rgba(122, 30, 30, 0.22);
}

.gen-pill--failed .gen-pill-spinner {
    border: none;
    background: #7A1E1E;
    animation: none;
    position: relative;
}

.gen-pill--failed .gen-pill-spinner::after {
    content: "!";
    position: absolute;
    inset: 0;
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.gen-pill--failed .gen-pill-text {
    color: #7A1E1E;
}

.gen-pill-text {
    flex: 1;
    font-weight: 500;
    line-height: 1.3;
}

.gen-pill--ready .gen-pill-text {
    color: #1F5236;
}

.gen-pill--error .gen-pill-text {
    color: #7A1E1E;
}

.gen-pill-dismiss {
    flex-shrink: 0;
    appearance: none;
    background: none;
    border: none;
    padding: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 1.05rem;
    line-height: 1;
    color: var(--inkMuted, #6B7689);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s ease, color 0.12s ease;
}

.gen-pill-dismiss:hover {
    background: #F1F3F7;
    color: var(--ink, #0E2540);
}

/* ── Failure modal (opened by clicking the failed pill) ───────────────── */

.gen-fail-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(14, 37, 64, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1120;
    padding: 16px;
    animation: gen-fail-fade-in 0.18s ease;
}

@keyframes gen-fail-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.gen-fail-card {
    background: var(--surface, #F7F7F4);
    border-radius: 14px;
    width: 100%;
    max-width: 440px;
    padding: 1.6rem 1.7rem 1.3rem;
    box-shadow: 0 24px 60px rgba(14, 37, 64, 0.22);
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.gen-fail-banner {
    background: #FBECEC;
    color: #7A1E1E;
    border: 1px solid #F0CFCF;
    border-radius: 10px;
    padding: 0.55rem 0.8rem;
    font-size: 0.82rem;
    font-weight: 500;
    align-self: flex-start;
}

.gen-fail-title {
    font-family: 'Forum', serif;
    font-size: 1.45rem;
    font-weight: 400;
    margin: 0.25rem 0 0;
    color: var(--ink, #0E2540);
    line-height: 1.2;
}

.gen-fail-heading {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--ink, #0E2540);
    line-height: 1.45;
}

.gen-fail-detail {
    margin: 0;
    font-size: 0.88rem;
    color: var(--inkSoft, #4A5568);
    line-height: 1.55;
}

.gen-fail-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.95rem;
}

.gen-fail-btn {
    appearance: none;
    border: none;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    padding: 0.55rem 1.15rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.gen-fail-btn--secondary {
    background: transparent;
    color: var(--inkSoft, #4A5568);
    border: 1px solid var(--rule, #E2E5EC);
}

.gen-fail-btn--secondary:hover {
    background: #fff;
    border-color: var(--inkMuted, #6B7689);
    color: var(--ink, #0E2540);
}

.gen-fail-btn--primary {
    background: var(--navy, #0E2540);
    color: #fff;
}

.gen-fail-btn--primary:hover {
    background: var(--blueDeep, #1A3A6B);
}
