/* ---------------------------------------------------------------------------
   Announcement stack
   ---------------------------------------------------------------------------
   Announcements used to render as a vertical run of alert bars, one under the
   other, pushing the page down. They are now a deck: one card on top, the rest
   layered behind it, flicked through with the pager underneath.

   The layering trick worth knowing: the ACTIVE card is position:relative and
   therefore still in flow, so the deck's height is always the height of
   whatever is currently on top. Every other card is position:absolute with
   inset:0, so it matches that height exactly and can be pushed down a few
   pixels to peek out from under the edge. No JS height measurement anywhere.
--------------------------------------------------------------------------- */

.announcement-stack {
    position: relative;
    margin: 0 0 1rem;
}

.announcement-stack__deck {
    position: relative;
}

/* Room for the peeking layers to show below the active card. Margin, not
   padding: padding would grow the deck's box and the inset:0 cards with it. */
.announcement-stack.has-multiple .announcement-stack__deck {
    margin-bottom: 20px;
}

.announcement-card {
    position: absolute;
    inset: 0;
    overflow: hidden;
    margin: 0;
    padding: 0.85rem 1rem;
    border-radius: 0.5rem;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(10px) scale(0.96);
    transition:
        transform 0.35s cubic-bezier(0.2, 0.7, 0.3, 1),
        opacity 0.3s ease,
        visibility 0.3s;
    z-index: 1;
}

.announcement-card.is-active {
    position: relative;
    inset: auto;
    overflow: visible;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    z-index: 5;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

/* A peeking card is a coloured slab, not a second announcement: its own text
   sits at the top of a box the same height as the active card, so without this
   the strip showing below the active card is a stray line of somebody else's
   copy rather than the edge of a card. */
.announcement-card:not(.is-active) .announcement-card__inner,
.announcement-card:not(.is-active) .announcement-card__close,
.announcement-card:not(.is-active) .announcement-stack__progress {
    visibility: hidden;
}

/* The two layers immediately behind the active card. Anything deeper stays
   fully hidden — three visible edges is already plenty of texture. */
.announcement-card.is-peek-1 {
    visibility: visible;
    opacity: 0.6;
    transform: translateY(9px) scale(0.985);
    z-index: 4;
}

.announcement-card.is-peek-2 {
    visibility: visible;
    opacity: 0.32;
    transform: translateY(18px) scale(0.97);
    z-index: 3;
}

/* Leaving to the left / entering from the right, so flicking has a direction. */
.announcement-card.is-leaving-back {
    transform: translateX(-2%) scale(0.97);
}

.announcement-card.is-leaving-forward {
    transform: translateX(2%) scale(0.97);
}

.announcement-card__inner {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding-right: 1.75rem; /* clears the absolutely positioned close button */
}

.announcement-card__icon {
    flex: 0 0 auto;
    font-size: 1.5rem;
    line-height: 1;
    opacity: 0.85;
}

.announcement-card__body {
    flex: 1 1 auto;
    min-width: 0;
}

.announcement-card__title {
    font-weight: 600;
}

.announcement-card__text {
    opacity: 0.92;
}

.announcement-card__actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.announcement-card__close {
    position: absolute;
    top: 0.6rem;
    right: 0.7rem;
    z-index: 2;
}

/* Auto-rotate progress line, pinned to the bottom edge of the active card.
   Width is driven by a CSS transition JS restarts on each slide, so there is
   no timer painting frames. */
.announcement-stack__progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 100%;
    transform: scaleX(0);
    transform-origin: left center;
    background: currentColor;
    opacity: 0.35;
    border-bottom-left-radius: 0.5rem;
    pointer-events: none;
}

.announcement-card.is-active .announcement-stack__progress.is-running {
    transform: scaleX(1);
}

/* --- Pager ------------------------------------------------------------- */

.announcement-stack__controls {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.35rem;
}

.announcement-stack__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid rgba(128, 128, 128, 0.35);
    border-radius: 50%;
    background: transparent;
    color: inherit;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.announcement-stack__btn:hover:not(:disabled) {
    background: rgba(128, 128, 128, 0.15);
}

.announcement-stack__btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.announcement-stack__dots {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin: 0 0.2rem;
}

.announcement-stack__dot {
    width: 7px;
    height: 7px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.3;
    cursor: pointer;
    transition: width 0.2s ease, opacity 0.2s ease, border-radius 0.2s ease;
}

.announcement-stack__dot.is-active {
    width: 18px;
    border-radius: 4px;
    opacity: 0.9;
}

.announcement-stack__count {
    font-size: 0.78rem;
    opacity: 0.65;
    font-variant-numeric: tabular-nums;
}

.announcement-stack__all {
    font-size: 0.78rem;
    opacity: 0.75;
    text-decoration: none;
}

.announcement-stack__all:hover {
    opacity: 1;
    text-decoration: underline;
}

/* --- Small screens ----------------------------------------------------- */

@media (max-width: 767.98px) {
    .announcement-card__inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .announcement-card__icon {
        display: none;
    }

    .announcement-card__actions {
        width: 100%;
    }

    .announcement-card__actions .btn {
        flex: 1 1 auto;
    }
}

/* --- Motion preferences ------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
    .announcement-card,
    .announcement-stack__progress,
    .announcement-stack__dot,
    .announcement-stack__btn {
        transition: none !important;
    }

    .announcement-card.is-peek-1,
    .announcement-card.is-peek-2 {
        transform: none;
        opacity: 0;
        visibility: hidden;
    }

    .announcement-stack.has-multiple .announcement-stack__deck {
        margin-bottom: 0;
    }
}

/* --- Archive page ------------------------------------------------------ */

.announcement-list-item {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}

.announcement-list-item:last-child {
    border-bottom: 0;
}

.announcement-list-item__icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    font-size: 1.35rem;
}

.announcement-list-item__body {
    flex: 1 1 auto;
    min-width: 0;
}

.announcement-list-item.is-unread .announcement-list-item__title {
    font-weight: 700;
}

/* --- Header bell dropdown ---------------------------------------------- */

/* The theme pins .header-notifications-list to a fixed 400px with no
   overflow rule, which leaves a tall empty box under one or two items and
   clips anything past five. Height follows the content instead. */
.announcement-bell-list {
    height: auto;
    max-height: 360px;
    overflow-y: auto;
}

.announcement-bell-item {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.7rem 1rem;
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid rgba(128, 128, 128, 0.12);
}

.announcement-bell-item:last-child {
    border-bottom: 0;
}

.announcement-bell-item:hover {
    background: rgba(128, 128, 128, 0.12);
    color: inherit;
}

.announcement-bell-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 1.2rem;
    background: rgba(128, 128, 128, 0.14);
}

.announcement-bell-body {
    display: block;
    min-width: 0;
    flex: 1 1 auto;
}

.announcement-bell-title {
    display: block;
    font-weight: 600;
    font-size: 0.88rem;
    line-height: 1.3;
}

.announcement-bell-meta {
    display: block;
    font-size: 0.72rem;
    opacity: 0.6;
    margin-bottom: 0.15rem;
}

.announcement-bell-text {
    display: block;
    font-size: 0.8rem;
    opacity: 0.8;
    line-height: 1.35;
}
