/* ==========================================================================
   Imagine notifications — js/notifications.js
   The banner is liquid glass like the app's buttons: in Chromium the engine
   sets a refracting backdrop-filter on the element itself, everywhere else
   the blur below stays. Opacity and blur go on the element, never on a parent:
   a parent with either would become the glass's backdrop root and it would
   see nothing behind it (css/liquid-glass.css has the long version).
   ========================================================================== */

#imagine-notif-host {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    left: 0;
    right: 0;
    /* Above the loading screen, the fast-entry iframe and every modal */
    z-index: 2147480000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
    direction: ltr;
}

.inotif {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    color: var(--glass-text, #eef2ff);
    font-family: var(--glass-font, 'Open Sans', system-ui, sans-serif);
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}

/* ---- the banner ---- */

.inotif-banner {
    position: relative;
    width: min(408px, calc(100vw - 24px));
    height: 76px;
    padding: 0 14px;
    border-radius: 26px;
    pointer-events: auto;
    /* Every gesture on a banner is ours, including the swipe up */
    touch-action: none;
    background: linear-gradient(180deg, rgba(22, 26, 44, 0.4), rgba(12, 15, 30, 0.52));
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(26px) saturate(1.6);
    -webkit-backdrop-filter: blur(26px) saturate(1.6);
    will-change: transform, opacity, filter;
}

:root[data-theme="light"] .inotif-banner {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.6), rgba(244, 247, 255, 0.7));
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 16px 44px rgba(18, 30, 70, 0.2);
}

/* frost (Safari / iPhone / Firefox): no bend to show what's behind, so a
   little more tint keeps the text readable over a bright sky */
html[data-lg="frost"] .inotif-banner {
    background: linear-gradient(180deg, rgba(24, 28, 46, 0.58), rgba(12, 15, 28, 0.66));
}

html[data-lg="frost"][data-theme="light"] .inotif-banner {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(244, 247, 255, 0.8));
}

.inotif-banner:active {
    cursor: grabbing;
}

/* a banner is always "now" */
.inotif-banner .inotif-time {
    display: none;
}

/* ---- the icon disc ---- */

.inotif-icon {
    flex: 0 0 auto;
    position: relative;
    z-index: 1;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--inotif-tint);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.45),
        0 0 16px var(--inotif-glow);
}

.inotif-icon svg {
    width: 25px;
    height: 25px;
    display: block;
}

.inotif-t-green {
    --inotif-tint: linear-gradient(160deg, rgba(64, 220, 120, 0.9), rgba(24, 160, 78, 0.85));
    --inotif-glow: rgba(64, 220, 120, 0.32);
}

.inotif-t-blue {
    --inotif-tint: linear-gradient(160deg, rgba(90, 170, 255, 0.92), rgba(40, 100, 235, 0.88));
    --inotif-glow: rgba(90, 170, 255, 0.32);
}

.inotif-t-violet {
    --inotif-tint: linear-gradient(160deg, rgba(176, 124, 255, 0.92), rgba(120, 72, 232, 0.88));
    --inotif-glow: rgba(176, 124, 255, 0.32);
}

.inotif-t-amber {
    --inotif-tint: linear-gradient(160deg, rgba(255, 190, 92, 0.94), rgba(238, 134, 40, 0.9));
    --inotif-glow: rgba(255, 170, 70, 0.32);
}

.inotif-t-red {
    --inotif-tint: linear-gradient(160deg, rgba(255, 82, 82, 0.92), rgba(196, 32, 46, 0.88));
    --inotif-glow: rgba(255, 82, 82, 0.34);
}

.inotif-t-slate {
    --inotif-tint: linear-gradient(160deg, rgba(150, 162, 190, 0.7), rgba(92, 104, 134, 0.7));
    --inotif-glow: rgba(150, 162, 190, 0.18);
}

/* the diamond is the whole icon: no disc around it */
.inotif-t-gem {
    background: none;
    box-shadow: none;
}

.inotif-t-gem svg {
    width: 40px;
    height: 40px;
    filter: drop-shadow(0 0 9px rgba(72, 168, 255, 0.75));
}

/* the chat orb from the star chat (css/chat-orb.css): same palettes, same ink */
.inotif-t-orb {
    --orb-a: #9147ff;
    --orb-b: #ff7ad9;
    --orb-c: #4dd6ff;
    --orb-core: #ffd9ec;
    --inotif-glow: rgba(145, 71, 255, 0.5);
    color: #1d1128;
    background:
        radial-gradient(circle at 32% 30%, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0) 26%),
        radial-gradient(circle at 50% 58%, var(--orb-core) 0%, rgba(255, 255, 255, 0) 52%),
        radial-gradient(circle at 78% 22%, var(--orb-c) 0%, rgba(255, 255, 255, 0) 46%),
        radial-gradient(circle at 22% 80%, var(--orb-b) 0%, rgba(255, 255, 255, 0) 60%),
        radial-gradient(circle at 70% 78%, var(--orb-a) 0%, rgba(255, 255, 255, 0) 66%),
        linear-gradient(135deg, var(--orb-b), var(--orb-a));
}

.inotif-t-orb[data-orb-theme="openai"] {
    --orb-a: #10a37f; --orb-b: #38bdf8; --orb-c: #7ef7d4; --orb-core: #d9fff2;
    --inotif-glow: rgba(16, 163, 127, 0.5);
    color: #0b2a22;
}

.inotif-t-orb[data-orb-theme="gemini"] {
    --orb-a: #4285f4; --orb-b: #ff5449; --orb-c: #9bb9ff; --orb-core: #e4ecff;
    --inotif-glow: rgba(66, 133, 244, 0.5);
    color: #171c33;
}

.inotif-t-orb[data-orb-theme="claude"] {
    --orb-a: #ff8a00; --orb-b: #d97757; --orb-c: #ffc879; --orb-core: #ffe8cf;
    --inotif-glow: rgba(255, 138, 0, 0.5);
    color: #33200f;
}

.inotif-t-orb svg {
    width: 27px;
    height: 23px;
}

/* ---- text ---- */

.inotif-main {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.inotif-top {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.inotif-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inotif-time {
    flex: 0 0 auto;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--glass-muted, rgba(226, 233, 255, 0.56));
}

.inotif-body {
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--glass-muted, rgba(226, 233, 255, 0.72));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

/* an engine message is one line: it sits in the middle of the banner */
.inotif-body:empty {
    display: none;
}

.inotif-banner .inotif-body {
    color: rgba(238, 242, 255, 0.8);
}

:root[data-theme="light"] .inotif-banner .inotif-body {
    color: rgba(10, 19, 48, 0.72);
}

/* ---- history rows inside Imagine Social ---- */

.inotif-list {
    display: flex;
    flex-direction: column;
}

.inotif-row {
    position: relative;
    margin-bottom: 8px;
    min-height: 66px;
    padding: 10px 14px;
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.045));
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.14),
        0 8px 22px rgba(0, 0, 0, 0.16);
    /* Sideways is ours, up and down still scrolls the panel */
    touch-action: pan-y;
    transition: background 160ms ease, border-color 160ms ease;
}

.inotif-row:hover {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.075));
    border-color: rgba(255, 255, 255, 0.24);
}

:root[data-theme="light"] .inotif-row {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.5));
    border-color: rgba(255, 255, 255, 0.9);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        0 8px 22px rgba(18, 30, 70, 0.08);
}

:root[data-theme="light"] .inotif-row:hover {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.66));
}

.inotif-row:focus-visible {
    outline: 2px solid var(--glass-accent-border, rgba(125, 243, 255, 0.42));
    outline-offset: 1px;
}

.inotif-row .inotif-icon {
    width: 40px;
    height: 40px;
}

.inotif-row .inotif-icon svg {
    width: 22px;
    height: 22px;
}

.inotif-row .inotif-t-gem svg {
    width: 35px;
    height: 35px;
}

.inotif-row .inotif-t-orb svg {
    width: 24px;
    height: 20px;
}

.inotif-row .inotif-title {
    font-size: 14px;
}

.inotif-row .inotif-body {
    font-size: 12.5px;
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

/* buttons own the row's right end: the time moves in beside the title */
.inotif-row.has-actions:not(.is-stale) .inotif-top {
    justify-content: flex-start;
    gap: 8px;
}

.inotif-row.has-actions:not(.is-stale) .inotif-title {
    flex: 0 1 auto;
}

/* a Join from an hour ago would promise something that's no longer true */
.inotif-row.is-stale .inotif-actions {
    display: none;
}

/* unread: a badge on the icon, the way an app shows it */
.inotif-row:not(.is-read) .inotif-icon::after {
    content: "";
    position: absolute;
    top: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff3b30;
    box-shadow: 0 0 0 2px rgba(16, 19, 34, 0.9);
}

:root[data-theme="light"] .inotif-row:not(.is-read) .inotif-icon::after {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.95);
}

/* read: quieter, but a button on the row must not look disabled */
.inotif-row.is-read .inotif-icon,
.inotif-row.is-read .inotif-main {
    opacity: 0.72;
}

.inotif-empty[hidden],
.inotif-more[hidden] {
    display: none;
}

.inotif-more {
    display: block;
    width: 100%;
    padding: 7px 0 2px;
    background: none;
    border: 0;
    font: 700 12px var(--glass-font, system-ui, sans-serif);
    color: var(--glass-accent, #7df3ff);
    cursor: pointer;
}

/* ---- buttons on a notification ---- */

.inotif-actions {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.inotif-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    padding: 0 15px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.08));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
    color: inherit;
    font: 700 13px var(--glass-font, system-ui, sans-serif);
    cursor: pointer;
    transition: filter 150ms ease, transform 150ms ease;
}

.inotif-btn:hover {
    filter: brightness(1.18);
}

.inotif-btn:active {
    transform: scale(0.94);
}

.inotif-btn.has-icon {
    width: 34px;
    padding: 0;
}

.inotif-btn svg {
    width: 17px;
    height: 17px;
    display: block;
}

.inotif-btn.is-primary {
    border-color: rgba(170, 255, 205, 0.55);
    background: linear-gradient(180deg, rgba(70, 224, 128, 0.95), rgba(26, 164, 82, 0.92));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        0 3px 10px rgba(24, 160, 78, 0.34);
    color: #fff;
}

:root[data-theme="light"] .inotif-btn:not(.is-primary) {
    border-color: rgba(12, 26, 64, 0.14);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(236, 240, 250, 0.7));
    box-shadow: inset 0 1px 0 #fff, 0 2px 6px rgba(18, 30, 70, 0.08);
}

/* ---- settings (the gear in Imagine Social) ---- */

.inotif-prefs {
    margin-bottom: 12px;
    padding: 6px 15px;
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.045));
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.14),
        0 8px 22px rgba(0, 0, 0, 0.16);
}

:root[data-theme="light"] .inotif-prefs {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.5));
    border-color: rgba(255, 255, 255, 0.9);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        0 8px 22px rgba(18, 30, 70, 0.08);
}

.inotif-prefs[hidden] {
    display: none;
}

.inotif-pref {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 40px;
    padding: 5px 0;
    cursor: pointer;
    font: 600 13.5px var(--glass-font, system-ui, sans-serif);
    color: var(--glass-text, #eef2ff);
}

.inotif-pref-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.inotif-pref-text small {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--glass-muted, rgba(226, 233, 255, 0.56));
}

.inotif-pref-divider {
    height: 1px;
    margin: 4px 0;
    background: var(--glass-border, rgba(150, 178, 255, 0.14));
}

.inotif-pref input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.inotif-switch {
    flex: 0 0 auto;
    position: relative;
    width: 40px;
    height: 24px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.28);
    transition: background 160ms ease;
}

:root[data-theme="light"] .inotif-switch {
    background: rgba(12, 24, 60, 0.14);
    box-shadow: inset 0 1px 2px rgba(18, 30, 70, 0.14);
}

.inotif-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(180deg, #fff, #eef1f7);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.36);
    transition: transform 160ms cubic-bezier(0.3, 0.9, 0.3, 1);
}

.inotif-pref input:checked + .inotif-switch {
    background: linear-gradient(180deg, #3ddc72, #2bb65a);
}

.inotif-pref input:checked + .inotif-switch::after {
    transform: translateX(16px);
}

.inotif-pref input:focus-visible + .inotif-switch {
    outline: 2px solid var(--glass-accent-border, rgba(125, 243, 255, 0.42));
    outline-offset: 2px;
}

/* ---- the badge: a red iPhone circle over the social button ---- */

.imagine-notif-badge {
    /* !important: the world row forces position + z-index on every child of
       the counter, which is what turned the old badge into an ellipse */
    position: absolute !important;
    top: -5px !important;
    right: -5px !important;
    bottom: auto !important;
    left: auto !important;
    z-index: 30 !important;
    box-sizing: border-box;
    min-width: 21px;
    height: 21px;
    padding: 0 6px;
    border-radius: 999px;
    background: #ff3b30;
    color: #fff;
    font: 700 12.5px/21px -apple-system, 'SF Pro Text', 'Inter', 'Segoe UI', sans-serif !important;
    letter-spacing: -0.02em;
    text-align: center;
    direction: ltr;
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
    pointer-events: none;
}

.imagine-notif-badge[hidden] {
    display: none !important;
}

/* the edge handle is a thin strip: the circle hangs off its corner */
.social-feed-handle > .imagine-notif-badge {
    top: -10px !important;
    right: -11px !important;
}

@media (max-width: 480px) {
    .inotif-banner {
        height: 72px;
        border-radius: 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .inotif-row {
        transition: none;
    }
}
