/* ==================================================================
     notification bell (Components/NotificationBell.razor)
   ==================================================================
   The bell of a site's top bar and its panel: a head (title, "unread only" switch, settings), underlined category
   tabs, the list, and a foot (mark all as read, clear all). On computers and tablets the panel drops down under the
   bell; below 768px it fills the screen. */

.app-ntc {
    position: relative;
    display: inline-flex;
}

.app-ntc-bell {
    position: relative;
}

/* Red dot at the bell's top right while there are unread notifications; it pops when the island puts a notification into the bell */
.app-ntc-dot {
    position: absolute;
    top: 7px;
    right: 8px;
    width: 9px;
    height: 9px;
    border: 2px solid var(--app-surface);
    border-radius: 50%;
    background: var(--app-danger);
    animation: app-ntc-dot-in 0.3s var(--app-ease-spring) both;
}

@keyframes app-ntc-dot-in {
    from {
        transform: scale(0);
    }

    to {
        transform: none;
    }
}

/* Pointing at the bell swings it once, from its top like a hanging bell. The swing moves the glyph (the icon's ::before),
   so it never fights the swing a new notification gives the icon itself (app-ntc-ring below). */
.app-ntc-bell > i::before {
    display: inline-block;
    transform-origin: 50% 8%;
}

@media (hover: hover) {
    .app-ntc-bell:hover > i::before {
        animation: app-ntc-hover-swing 0.7s var(--app-ease-out);
    }
}

@keyframes app-ntc-hover-swing {
    0%,
    100% {
        transform: rotate(0);
    }

    20% {
        transform: rotate(14deg);
    }

    40% {
        transform: rotate(-11deg);
    }

    60% {
        transform: rotate(6deg);
    }

    80% {
        transform: rotate(-3deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-ntc-bell:hover > i::before {
        animation: none;
    }
}

/* The bell swings once when a notification arrives */
.app-ntc-ring {
    transform-origin: 50% 10%;
    animation: app-ntc-ring 0.9s var(--app-ease-out) both;
}

@keyframes app-ntc-ring {
    0% {
        transform: rotate(0);
    }

    15% {
        transform: rotate(16deg);
    }

    30% {
        transform: rotate(-14deg);
    }

    45% {
        transform: rotate(10deg);
    }

    60% {
        transform: rotate(-6deg);
    }

    75% {
        transform: rotate(3deg);
    }

    100% {
        transform: rotate(0);
    }
}

/* A click outside the panel closes it */
.app-ntc-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
}

/* Icons beside a label are centred on it, then moved by the platform's optical nudge (app-ui.css) */
.app-ntc-section .bx,
.app-ntc-foot-btn .bx,
.app-ntc-switch-label .bx,
.app-ntc-retention .bx,
.app-ntc-setting-warn .bx {
    position: relative;
    top: var(--app-icon-nudge);
}

/* ---------- panel ---------- */

.app-ntc-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    width: min(400px, calc(100vw - 32px));
    max-height: min(600px, calc(100vh - 110px));
    max-height: min(600px, calc(100dvh - 110px));
    border: 1px solid var(--app-line);
    border-radius: 20px;
    background: var(--app-surface);
    box-shadow: var(--app-shadow-menu);
    color: var(--app-text);
    font-family: var(--app-font-family);
    overflow: hidden;
    transform-origin: top right;
    animation: app-ntc-panel-in 0.24s var(--app-ease-out) both;
}

@keyframes app-ntc-panel-in {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ---------- head: title, "unread only", settings ---------- */

.app-ntc-head {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: none;
    min-height: 58px;
    padding: 8px 10px 8px 18px;
}

/* In the settings, the back button starts the head instead of the padding */
.app-ntc-head > .app-ntc-head-btn:first-child {
    margin-left: -10px;
}

.app-ntc-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--app-text-strong);
}

.app-ntc-title:focus {
    outline: none;
}

.app-ntc-head-btn {
    width: 38px;
    height: 38px;
    font-size: 20px;
}

/* The close button is only needed on phones, where the panel covers the page */
.app-ntc-close {
    display: none;
}

/* "Unread only": the label, then the shared switch */
.app-ntc-unread {
    flex: none;
    gap: 8px;
    min-height: 38px;
    margin-right: 4px;
    padding: 0 2px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    color: var(--app-text-muted);
    transition: color 0.2s ease;
}

.app-ntc-unread[aria-pressed="true"] {
    color: var(--app-accent);
}

.app-ntc-unread:focus-visible {
    outline: 2px solid var(--app-accent);
    outline-offset: 2px;
}

/* ---------- category tabs ---------- */

/* Underlined tabs; the underline slides to the chosen one (data-app-glide, app-ui.js measures it). They scroll sideways
   when the language makes them wider than the panel, with the cut-off side faded. */
.app-ntc-tabs {
    display: flex;
    flex: none;
    gap: 2px;
    padding: 0 10px;
    border-bottom: 1px solid var(--app-line);
    overflow-x: auto;
    scrollbar-width: none;
}

.app-ntc-tabs::-webkit-scrollbar {
    display: none;
}

.app-ntc-tabs[data-app-glide]::before {
    top: auto;
    bottom: 0;
    height: 2px;
    border-radius: 2px 2px 0 0;
    background: var(--app-accent);
    box-shadow: none;
    transform: translateX(var(--app-glide-x, 0px));
}

.app-ntc-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    gap: 6px;
    height: 42px;
    padding: 0 10px;
    border: 0;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    color: var(--app-text-muted);
    cursor: pointer;
    transition: color 0.2s ease;
}

/* Until the sliding underline is in place (and without JS), the chosen tab draws its own */
.app-ntc-tab[aria-pressed="true"] {
    color: var(--app-accent);
    box-shadow: inset 0 -2px 0 var(--app-accent);
}

.app-ntc-tabs[data-app-glide-ready] > .app-ntc-tab[aria-pressed="true"] {
    box-shadow: none;
}

.app-ntc-tab:focus-visible {
    outline: 2px solid var(--app-accent);
    outline-offset: -4px;
    border-radius: 10px;
}

@media (hover: hover) {
    .app-ntc-tab:not([aria-pressed="true"]):hover {
        color: var(--app-text-strong);
    }
}

.app-ntc-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--app-accent-soft);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    color: var(--app-accent);
}

/* ---------- body ---------- */

/* Only scrolls up and down: a deleted notification sliding out to the side never brings a sideways scroll bar */
.app-ntc-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.app-ntc-body::-webkit-scrollbar-track {
    margin: 10px 0;
}

/* While another filter's list loads, the current one dims a little */
.app-ntc-body[aria-busy="true"] .app-ntc-list {
    opacity: 0.55;
    transition: opacity 0.2s ease;
}

/* ---------- list ---------- */

.app-ntc-list {
    margin: 0;
    padding: 4px 6px 8px;
    list-style: none;
}

/* Group headings: "Needs attention", then one per day */
.app-ntc-section {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 12px 4px;
    color: var(--app-text-muted);
}

.app-ntc-section:first-child {
    padding-top: 8px;
}

.app-ntc-section-title {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    color: inherit;
}

.app-ntc-section-pinned {
    color: var(--app-danger);
}

.app-ntc-section-pinned .bx {
    font-size: 14px;
}

/* One notification: the link (or button) that opens it, and its own actions at the right end of its last line.
   --app-ntc-action-size: the actions' buttons; --app-ntc-actions-room: what the last line keeps free for them (from
   the actions' right edge to the item's text, plus a gap); --app-ntc-meta-height: the last line's height */
.app-ntc-row {
    --app-ntc-action-size: 30px;
    --app-ntc-actions-room: 66px;
    --app-ntc-meta-height: 20px;
    position: relative;
    transition: opacity 0.2s ease, transform 0.2s var(--app-ease-out);
}

/* A deleted notification slides out to the side before the list closes the gap (AppMotion.flipPlay) */
.app-ntc-row-leaving {
    opacity: 0;
    transform: translateX(24px);
    pointer-events: none;
}

/* One that arrives or comes back while the list is showing fades in */
.app-ntc-row-entering {
    animation: app-ntc-row-in 0.3s var(--app-ease-out) both;
}

@keyframes app-ntc-row-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* Icon on the left; beside it the title, the whole message, then the "important" badge and the time */
.app-ntc-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 12px;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.app-ntc-item:focus-visible {
    outline: 2px solid var(--app-accent);
    outline-offset: -2px;
}

/* The whole row lights up, so it stays lit while the pointer is on the notification's own actions */
@media (hover: hover) {
    .app-ntc-row:hover .app-ntc-item {
        background: var(--app-accent-soft);
        color: inherit;
    }
}

.app-ntc-item-skel {
    cursor: default;
}

.app-ntc-item-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--app-accent-soft);
    font-size: 18px;
    color: var(--app-accent);
}

.app-ntc-tone-success {
    background: var(--app-success-soft);
    color: var(--app-success);
}

.app-ntc-tone-warning {
    background: var(--app-warning-soft);
    color: var(--app-warning);
}

.app-ntc-tone-error {
    background: var(--app-danger-soft);
    color: var(--app-danger);
}

/* Unread: a brand dot on the icon's top right */
.app-ntc-item-dot {
    position: absolute;
    top: -1px;
    right: -1px;
    width: 11px;
    height: 11px;
    border: 2px solid var(--app-surface);
    border-radius: 50%;
    background: var(--app-accent);
}

.app-ntc-item-text {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    gap: 2px;
    min-width: 0;
}

.app-ntc-item-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    color: var(--app-text-strong);
    overflow-wrap: anywhere;
}

.app-ntc-item-unread .app-ntc-item-title {
    font-weight: 700;
}

/* The whole message, never cut off: it often says what to do next */
.app-ntc-item-message {
    font-size: 13px;
    line-height: 1.5;
    color: var(--app-text-muted);
    overflow-wrap: anywhere;
}

.app-ntc-item-unread .app-ntc-item-message {
    color: var(--app-text);
}

/* The "important" badge and the time share the last line, the same on every notification; its right end stays free
   for the notification's own actions */
.app-ntc-item-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-height: var(--app-ntc-meta-height);
    margin-top: 4px;
    padding-right: var(--app-ntc-actions-room);
}

.app-ntc-badge {
    height: 20px;
    padding: 0 8px;
    font-size: 11px;
}

.app-ntc-item-when {
    font-size: 12px;
    line-height: 20px;
    white-space: nowrap;
    color: var(--app-text-muted);
}

/* ---------- a notification's own actions: mark as read, delete ---------- */

/* Icon buttons named by tooltips, at the right end of the notification's last line and centred on it (the item's
   12px padding plus half of the line), where that line keeps room for them, so they never cover the text.
   With a mouse they fade in on hover or keyboard focus; on touch screens they always show, quietly. */
.app-ntc-actions {
    position: absolute;
    right: 8px;
    bottom: calc(12px + var(--app-ntc-meta-height) / 2 - var(--app-ntc-action-size) / 2);
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    opacity: 0;
    transform: translateX(4px);
    transition: opacity 0.18s ease, transform 0.18s var(--app-ease-out);
}

.app-ntc-action {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--app-ntc-action-size);
    height: var(--app-ntc-action-size);
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    font-size: 17px;
    color: var(--app-text-muted);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.app-ntc-action:focus-visible {
    outline: 2px solid var(--app-accent);
    outline-offset: 1px;
}

.app-ntc-action:disabled {
    cursor: default;
}

@media (hover: hover) {
    .app-ntc-row:hover .app-ntc-actions,
    .app-ntc-row:focus-within .app-ntc-actions {
        opacity: 1;
        transform: none;
    }

    .app-ntc-action:not(:disabled):hover {
        background: var(--app-accent-soft);
        color: var(--app-accent);
    }

    .app-ntc-action-delete:not(:disabled):hover {
        background: var(--app-danger-soft);
        color: var(--app-danger);
    }
}

/* Touch screens: a little larger and further apart, each with a 44px touch target around it; the last line is as
   tall as the buttons, so their touch targets stay off the message above */
@media (hover: none) {
    .app-ntc-row {
        --app-ntc-action-size: 32px;
        --app-ntc-actions-room: 80px;
        --app-ntc-meta-height: 32px;
    }

    .app-ntc-actions {
        right: 6px;
        gap: 14px;
        opacity: 1;
        transform: none;
    }

    .app-ntc-action::after {
        content: "";
        position: absolute;
        inset: -6px;
    }
}

/* ---------- empty, failed ---------- */

.app-ntc-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 40px 24px;
    text-align: center;
}

.app-ntc-state-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin-bottom: 6px;
    border-radius: 50%;
    background: var(--app-accent-soft);
    font-size: 24px;
    color: var(--app-accent);
}

.app-ntc-state-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--app-text-strong);
}

.app-ntc-state-text {
    max-width: 280px;
    margin: 0 0 6px;
    font-size: 13px;
    line-height: 1.55;
    color: var(--app-text-muted);
}

/* ---------- foot: mark all as read, clear all ---------- */

/* Two exact halves, mirrored around a short hairline in the middle; each label is centred in its half and only wraps
   where a half is too narrow for it */
.app-ntc-foot {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex: none;
    gap: 9px;
    padding: 6px 4px;
    border-top: 1px solid var(--app-line);
}

.app-ntc-foot::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1px;
    height: 20px;
    margin: -10px 0 0 -0.5px;
    background: var(--app-line);
}

.app-ntc-foot-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    min-height: 38px;
    padding: 6px 4px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    color: var(--app-accent);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.app-ntc-foot-btn .bx {
    flex: none;
    font-size: 18px;
}

.app-ntc-foot-clear {
    color: var(--app-text-muted);
}

.app-ntc-foot-btn:focus-visible {
    outline: 2px solid var(--app-accent);
    outline-offset: -2px;
}

.app-ntc-foot-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

@media (hover: hover) {
    .app-ntc-foot-btn:not(:disabled):hover {
        background: var(--app-accent-soft);
    }

    .app-ntc-foot-clear:not(:disabled):hover {
        background: var(--app-danger-soft);
        color: var(--app-danger);
    }
}

/* ---------- settings ---------- */

.app-ntc-settings {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 6px 18px 18px;
}

.app-ntc-setting {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.app-ntc-setting + .app-ntc-setting {
    padding-top: 18px;
    border-top: 1px solid var(--app-line);
}

.app-ntc-switch {
    justify-content: space-between;
    width: 100%;
    min-height: 44px;
    text-align: left;
}

.app-ntc-switch:focus-visible {
    outline: 2px solid var(--app-accent);
    outline-offset: 4px;
    border-radius: 8px;
}

.app-ntc-switch-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.app-ntc-switch-label .bx {
    font-size: 20px;
    color: var(--app-accent);
}

.app-ntc-setting-hint {
    --app-ntc-hint-line: 20px;

    margin: 0;
    font-size: 13px;
    line-height: var(--app-ntc-hint-line);
    color: var(--app-text-muted);
}

/* The browser blocks notifications, or has none: what to do about it, in the warning colour */
.app-ntc-setting-warn {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    color: var(--app-warning);
}

/* The icon's box is one line of the hint high, so it is centred on the first line however many lines follow */
.app-ntc-setting-warn .bx {
    display: inline-flex;
    align-items: center;
    flex: none;
    height: var(--app-ntc-hint-line);
    font-size: 16px;
}

.app-ntc-retention {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding-top: 14px;
    border-top: 1px solid var(--app-line);
    font-size: 12px;
    color: var(--app-text-muted);
}

/* ---------- phones: the panel fills the screen ---------- */

@media (max-width: 767.98px) {
    .app-ntc-dot {
        top: 6px;
        right: 6px;
    }

    .app-ntc-backdrop {
        background: var(--app-scrim);
    }

    .app-ntc-panel {
        position: fixed;
        inset: 0;
        width: auto;
        max-height: none;
        border: 0;
        border-radius: 0;
        padding-top: env(safe-area-inset-top, 0px);
        transform-origin: top center;
        animation-name: app-ntc-sheet-in;
    }

    @keyframes app-ntc-sheet-in {
        from {
            opacity: 0;
            transform: translateY(16px);
        }

        to {
            opacity: 1;
            transform: none;
        }
    }

    /* Title, settings and close on the first line; "unread only" gets a line of its own, its switch on the right */
    .app-ntc-head {
        flex-wrap: wrap;
        padding: 6px 8px 6px 16px;
    }

    .app-ntc-head > .app-ntc-head-btn:first-child {
        margin-left: -8px;
    }

    .app-ntc-close {
        display: inline-flex;
    }

    .app-ntc-head-btn {
        width: 44px;
        height: 44px;
    }

    .app-ntc-unread {
        order: 1;
        flex: 1 0 100%;
        justify-content: space-between;
        min-height: 44px;
        margin-right: 0;
        padding-right: 8px;
        font-size: 14px;
    }

    .app-ntc-tabs {
        padding: 0 6px;
    }

    .app-ntc-tab {
        height: 44px;
    }

    .app-ntc-foot {
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    }

    .app-ntc-foot-btn {
        min-height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-ntc-ring,
    .app-ntc-dot,
    .app-ntc-row-entering {
        animation: none;
    }

    .app-ntc-row {
        transition: opacity 0.15s ease;
    }

    .app-ntc-actions {
        transform: none;
    }

    .app-ntc-row-leaving {
        transform: none;
    }

    .app-ntc-panel {
        animation: app-ntc-fade 0.15s ease both;
    }

    @keyframes app-ntc-fade {
        from {
            opacity: 0;
        }

        to {
            opacity: 1;
        }
    }
}
