/* Web Updates: bell, unread badge, article feed surface and one-time launch
   card.

   Cyberpunk "information console" redesign. Everything is scoped under
   `.p3wu-*` / `#p3-web-updates-*` so it never reaches other chrome. The
   component carries its own LOCAL noir/cyan/teal token block (see
   `.p3wu-surface`) and only falls back to the site tokens for typography, so
   the feed looks the same in the legacy theme and in [data-design="modern"].

   Design rules honoured here:
   - No left accent rail anywhere: unread rows are marked by a small signal
     dot, never by a 3px orange border-left (the production defect this
     redesign removes). The row declares `border-left: 0` explicitly.
   - Restrained amber is kept for the genuinely-unread dot only; the rest of
     the surface is cool cyan/teal signal on near-black gunmetal.
   - Metadata is mono, body copy is the UI stack; icons are explicitly sized;
     focus rings are visible; nonessential motion dies under
     prefers-reduced-motion. No clip-path on interactive containers. */

/* ---- Bell + unread badge ------------------------------------------- */

.p3wu-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 28px;
    padding: 0;
    background: linear-gradient(180deg, rgba(18, 26, 32, 0.92), rgba(9, 13, 18, 0.92));
    border: 1px solid rgba(86, 218, 208, 0.24);
    border-radius: 6px;
    color: var(--text-secondary, #a0a0b8);
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.p3wu-bell:hover {
    color: var(--p3wu-cyan, #5ef2e6);
    border-color: rgba(94, 242, 230, 0.55);
    box-shadow: 0 0 0 1px rgba(94, 242, 230, 0.12), 0 4px 14px rgba(0, 0, 0, 0.45);
}

.p3wu-bell:focus-visible {
    color: var(--p3wu-cyan, #5ef2e6);
    border-color: rgba(94, 242, 230, 0.7);
    outline: 2px solid rgba(94, 242, 230, 0.75);
    outline-offset: 2px;
}

.p3wu-bell[aria-expanded="true"] {
    color: var(--p3wu-cyan, #5ef2e6);
    border-color: rgba(94, 242, 230, 0.7);
    box-shadow: inset 0 0 12px rgba(94, 242, 230, 0.14);
}

.p3wu-bell svg {
    width: 17px;
    height: 17px;
    display: block;
    flex-shrink: 0;
}

/* Amber stays here and only here: a genuinely unread badge. */
.p3wu-bell__badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: linear-gradient(180deg, #ffc46b, var(--accent-orange, #ff9f1c));
    box-shadow: 0 0 10px rgba(255, 159, 28, 0.4), 0 0 0 1px rgba(10, 12, 16, 0.9);
    color: #1a1207;
    font-family: var(--font-mono, monospace);
    font-size: 10px;
    font-weight: 800;
    line-height: 16px;
    text-align: center;
    box-sizing: border-box;
}

.p3wu-bell__badge[hidden] {
    display: none;
}

.p3wu-bell--touch {
    width: 40px;
    height: 34px;
}

/* ---- Overlay / surface --------------------------------------------- */

.p3wu-overlay {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 64px 16px 24px;
    background:
        radial-gradient(1100px 460px at 50% -10%, rgba(42, 224, 210, 0.1), transparent 70%),
        rgba(3, 6, 10, 0.72);
    box-sizing: border-box;
}

.p3wu-overlay[hidden] {
    display: none;
}

.p3wu-surface {
    /* Local noir/cyan/teal console tokens. Kept inside the surface so the
       component never leaks palette into the rest of the shell. */
    --p3wu-ink: #05070c;
    --p3wu-panel: #0a1016;
    --p3wu-panel-2: #0d151c;
    --p3wu-gunmetal: #141c24;
    --p3wu-cyan: #5ef2e6;
    --p3wu-teal: #2ad8c4;
    --p3wu-cyan-dim: rgba(94, 242, 230, 0.24);
    --p3wu-cyan-line: rgba(94, 242, 230, 0.38);
    --p3wu-amber: #ff9f1c;
    --p3wu-line: rgba(120, 164, 180, 0.2);
    --p3wu-text: #e8f6f7;
    --p3wu-text-2: #a8c1c9;
    --p3wu-text-3: #6d8894;

    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 96px);
    display: flex;
    flex-direction: column;
    position: relative;
    background: linear-gradient(180deg, var(--p3wu-panel-2), var(--p3wu-panel));
    border: 1px solid var(--p3wu-cyan-line);
    border-radius: 12px;
    box-shadow:
        0 0 0 1px rgba(4, 8, 12, 0.9),
        0 24px 64px rgba(0, 0, 0, 0.62),
        0 0 34px rgba(42, 216, 196, 0.12);
    color: var(--p3wu-text);
    font-family: var(--font-ui, var(--font-mono, sans-serif));
    overflow: hidden;
}

/* Ambient circuit frame: pure decoration, confined to the dialog edge and
   never hit-testable (so it can never eat a click or a focus ring). */
.p3wu-surface::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, transparent 0 14px, var(--p3wu-cyan-dim) 14px 15px, transparent 15px),
        linear-gradient(180deg, transparent 0 46px, rgba(94, 242, 230, 0.14) 46px 47px, transparent 47px),
        repeating-linear-gradient(90deg, rgba(94, 242, 230, 0.05) 0 1px, transparent 1px 46px);
    opacity: 0.85;
}

.p3wu-surface > * {
    position: relative;
    z-index: 1;
}

.p3wu-surface__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(180deg, rgba(42, 216, 196, 0.08), rgba(10, 16, 22, 0));
    border-bottom: 1px solid var(--p3wu-line);
}

.p3wu-surface__head-copy {
    flex: 1;
    min-width: 0;
}

.p3wu-eyebrow {
    font-family: var(--font-mono, monospace);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--p3wu-teal);
}

.p3wu-surface__title {
    margin: 3px 0 0;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.1px;
    line-height: 1.2;
    overflow-wrap: anywhere;
    color: var(--p3wu-text);
}

.p3wu-surface__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ---- Controls ------------------------------------------------------ */

.p3wu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 30px;
    padding: 5px 10px;
    background: linear-gradient(180deg, var(--p3wu-gunmetal), #0e161d);
    border: 1px solid var(--p3wu-line);
    border-radius: 6px;
    color: var(--p3wu-text-2);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.p3wu-btn:hover:not(:disabled) {
    color: var(--p3wu-cyan);
    border-color: rgba(94, 242, 230, 0.55);
    background: linear-gradient(180deg, #17222b, #101a22);
}

.p3wu-btn:focus-visible:not(:disabled) {
    color: var(--p3wu-cyan);
    border-color: rgba(94, 242, 230, 0.7);
    outline: 2px solid rgba(94, 242, 230, 0.75);
    outline-offset: 2px;
}

.p3wu-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.p3wu-btn__glyph {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    display: block;
}

.p3wu-btn--icon {
    padding: 5px 8px;
}

/* Close/Back SVGs do not carry the mark-all glyph class. Give them their own
   intrinsic size so the desktop flex button cannot collapse to an empty oval. */
.p3wu-btn--icon svg {
    width: 16px;
    height: 16px;
    display: block;
    flex-shrink: 0;
}

.p3wu-btn--primary {
    background: linear-gradient(180deg, #6ff8ec, var(--p3wu-teal));
    border-color: rgba(94, 242, 230, 0.7);
    color: #04211f;
    font-weight: 800;
    font-family: var(--font-mono, monospace);
    letter-spacing: 0.4px;
}

.p3wu-btn--primary:hover:not(:disabled),
.p3wu-btn--primary:focus-visible:not(:disabled) {
    background: linear-gradient(180deg, #6ff8ec, var(--p3wu-teal));
    color: #04211f;
    box-shadow: 0 0 18px rgba(42, 216, 196, 0.34);
}

/* ---- Status pills -------------------------------------------------- */

.p3wu-surface__status {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px 0;
}

.p3wu-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    font-family: var(--font-mono, monospace);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    background: rgba(42, 216, 196, 0.1);
    border: 1px solid rgba(94, 242, 230, 0.26);
    color: var(--p3wu-text-2);
}

/* ---- Feed body + rows --------------------------------------------- */

.p3wu-surface__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px 16px 18px;
    scrollbar-width: thin;
    scrollbar-color: rgba(94, 242, 230, 0.32) transparent;
}

.p3wu-surface__body::-webkit-scrollbar {
    width: 8px;
}

.p3wu-surface__body::-webkit-scrollbar-thumb {
    background: rgba(94, 242, 230, 0.28);
    border-radius: 999px;
}

.p3wu-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.p3wu-row {
    display: flex;
    gap: 11px;
    width: 100%;
    padding: 12px 12px;
    text-align: left;
    background: linear-gradient(180deg, rgba(12, 20, 26, 0.92), rgba(9, 14, 19, 0.92));
    border: 1px solid var(--p3wu-line);
    /* The production defect was a 3px orange border-left on every unread row. The
       row declares its left edge explicitly (zero width, transparent) so no
       rail can return here or in any later rule. */
    border-left: 0 solid transparent;
    border-radius: 8px;
    color: inherit;
    font: inherit;
    cursor: pointer;
    transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
    -webkit-tap-highlight-color: transparent;
}

.p3wu-row:hover {
    background: linear-gradient(180deg, rgba(18, 30, 38, 0.96), rgba(12, 20, 27, 0.96));
    border-color: var(--p3wu-cyan-line);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.46), inset 0 0 20px rgba(42, 216, 196, 0.06);
}

.p3wu-row:focus-visible {
    border-color: rgba(94, 242, 230, 0.7);
    outline: 2px solid rgba(94, 242, 230, 0.75);
    outline-offset: 2px;
    box-shadow: inset 0 0 20px rgba(42, 216, 196, 0.08);
}

/* Unread: signal dot + slightly brighter title only, no rail of any kind. */
.p3wu-row--unread {
    border-left: 0 solid transparent;
    background: linear-gradient(180deg, rgba(14, 24, 31, 0.95), rgba(10, 16, 22, 0.95));
}

.p3wu-row--unread .p3wu-row__title {
    color: #f2ffff;
}

.p3wu-row__dot {
    flex-shrink: 0;
    width: 7px;
    height: 7px;
    margin-top: 6px;
    border-radius: 50%;
    background: var(--p3wu-amber, #ff9f1c);
    box-shadow: 0 0 8px rgba(255, 159, 28, 0.5);
}

.p3wu-row__dot--read {
    background: transparent;
    border: 1px solid rgba(120, 164, 180, 0.45);
    box-shadow: none;
}

.p3wu-row__copy {
    flex: 1;
    min-width: 0;
    display: block;
}

.p3wu-row__date {
    display: block;
    font-family: var(--font-mono, monospace);
    font-size: 10px;
    letter-spacing: 1.1px;
    text-transform: uppercase;
    color: var(--p3wu-text-3);
}

.p3wu-row__title {
    display: block;
    margin: 3px 0 0;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.32;
    overflow-wrap: anywhere;
    color: var(--p3wu-text);
}

.p3wu-row__summary {
    display: block;
    margin: 4px 0 0;
    font-size: 12px;
    line-height: 1.5;
    color: var(--p3wu-text-2);
    overflow-wrap: anywhere;
}

.p3wu-state {
    padding: 30px 8px;
    text-align: center;
    color: var(--p3wu-text-2);
    font-size: 13px;
    line-height: 1.5;
}

.p3wu-state__title {
    margin: 0 0 6px;
    font-family: var(--font-mono, monospace);
    font-size: 13px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--p3wu-text);
}

.p3wu-state--error {
    color: var(--accent-red, #ef5350);
}

/* ---- Article (Learn) view ----------------------------------------- */

.p3wu-article__date {
    font-family: var(--font-mono, monospace);
    font-size: 10px;
    letter-spacing: 1.1px;
    text-transform: uppercase;
    color: var(--p3wu-text-3);
}

.p3wu-article__title {
    margin: 7px 0 0;
    font-size: 21px;
    font-weight: 800;
    line-height: 1.25;
    overflow-wrap: anywhere;
    color: var(--p3wu-text);
}

.p3wu-article__summary {
    margin: 12px 0 0;
    padding: 12px 14px;
    border-radius: 8px;
    background: rgba(42, 216, 196, 0.07);
    border: 1px solid rgba(94, 242, 230, 0.18);
    font-size: 14px;
    line-height: 1.6;
    color: #c8e2e6;
    overflow-wrap: anywhere;
}

.p3wu-article__meta {
    margin: 12px 0 0;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.p3wu-article__p {
    margin: 14px 0 0;
    font-size: 14px;
    line-height: 1.68;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: #dceef1;
}

/* ---- One-time launch card ----------------------------------------- */

.p3wu-launch-overlay {
    position: fixed;
    inset: 0;
    z-index: 12500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(900px 400px at 50% 0%, rgba(42, 224, 210, 0.1), transparent 70%),
        rgba(3, 6, 10, 0.78);
    box-sizing: border-box;
}

.p3wu-launch-overlay[hidden] {
    display: none;
}

/* WU10: the card is bounded to the available viewport (dvh, with a vh
   fallback) and lays out as a flex column so a long title/summary scrolls
   INSIDE the body while the close button and action buttons stay reachable. */
.p3wu-launch {
    --p3wu-cyan: #5ef2e6;
    --p3wu-teal: #2ad8c4;
    --p3wu-cyan-line: rgba(94, 242, 230, 0.38);
    --p3wu-line: rgba(120, 164, 180, 0.2);
    --p3wu-text: #e8f6f7;
    --p3wu-text-2: #a8c1c9;
    --p3wu-text-3: #6d8894;

    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 40px);
    max-height: calc(100dvh - 40px);
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 18px;
    background: linear-gradient(180deg, #0d151c, #0a1016);
    border: 1px solid var(--p3wu-cyan-line);
    border-radius: 12px;
    box-shadow:
        0 0 0 1px rgba(4, 8, 12, 0.9),
        0 24px 64px rgba(0, 0, 0, 0.66),
        0 0 34px rgba(42, 216, 196, 0.12);
    color: var(--p3wu-text);
    font-family: var(--font-ui, var(--font-mono, sans-serif));
    box-sizing: border-box;
    overflow: hidden;
}

.p3wu-launch::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: 12px;
    background:
        linear-gradient(90deg, transparent 0 14px, rgba(94, 242, 230, 0.24) 14px 15px, transparent 15px),
        repeating-linear-gradient(90deg, rgba(94, 242, 230, 0.05) 0 1px, transparent 1px 46px);
}

.p3wu-launch > * {
    position: relative;
    z-index: 1;
}

/* The scrollable content region owns the overflow; the pinned head (icon +
   close) and actions are flex items that never shrink away. */
.p3wu-launch__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(94, 242, 230, 0.32) transparent;
}

.p3wu-launch__body::-webkit-scrollbar {
    width: 8px;
}

.p3wu-launch__body::-webkit-scrollbar-thumb {
    background: rgba(94, 242, 230, 0.28);
    border-radius: 999px;
}

/* WU10: a legal max-length wide-glyph title scrolls TOGETHER with the summary
   inside .p3wu-launch__body, so the pinned head/actions always keep a
   non-zero, reachable footprint. */
.p3wu-launch__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.p3wu-launch__icon {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(42, 216, 196, 0.16), rgba(10, 16, 22, 0.9));
    border: 1px solid rgba(94, 242, 230, 0.3);
    color: var(--p3wu-cyan, #5ef2e6);
}

.p3wu-launch__icon svg {
    width: 21px;
    height: 21px;
    display: block;
    flex-shrink: 0;
}

.p3wu-launch__heading {
    flex: 1;
    min-width: 0;
}

.p3wu-launch__eyebrow {
    font-family: var(--font-mono, monospace);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1.7px;
    text-transform: uppercase;
    color: var(--p3wu-teal, #2ad8c4);
}

.p3wu-launch__title {
    margin: 4px 0 0;
    font-size: 19px;
    font-weight: 800;
    line-height: 1.25;
    overflow-wrap: anywhere;
    color: var(--p3wu-text, #e8f6f7);
}

.p3wu-launch__summary {
    margin: 14px 0 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--p3wu-text-2, #a8c1c9);
    overflow-wrap: anywhere;
}

.p3wu-launch__actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-top: 18px;
    flex-shrink: 0;
    flex-wrap: wrap;
    border-top: 1px solid var(--p3wu-line, rgba(120, 164, 180, 0.2));
    padding-top: 14px;
}

.p3wu-launch__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: -6px -6px 0 0;
    padding: 6px 8px;
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--p3wu-text-3, #6d8894);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.p3wu-launch__close svg {
    width: 18px;
    height: 18px;
    display: block;
    flex-shrink: 0;
}

.p3wu-launch__close:hover {
    color: var(--p3wu-cyan, #5ef2e6);
    background: rgba(94, 242, 230, 0.08);
}

.p3wu-launch__close:focus-visible {
    color: var(--p3wu-cyan, #5ef2e6);
    outline: 2px solid rgba(94, 242, 230, 0.75);
    outline-offset: 2px;
}

/* ---- Responsive ---------------------------------------------------- */

@media (max-width: 640px) {
    /* Narrow shell containment for the bell's mount host.
       At 320 the Dashboard header keeps an overall minimum-content width
       (brand + nav + clock + gear/Docs/+ Add Widget), so the actions cluster
       was pushed past the right edge and the bell ended up unreachable
       (native: bell right 375.03125 at viewport 320). Only the nonessential
       brand text is dropped here; the essential controls stay reachable and
       the row stays a single nowrap line that is never clipped. */
    .top-bar__brand {
        display: none;
    }

    .top-bar {
        flex-wrap: nowrap;
    }

    .top-bar__actions {
        flex-shrink: 0;
    }

    .p3wu-overlay {
        padding: 48px 10px 16px;
    }
    .p3wu-surface {
        max-height: calc(100vh - 64px);
        border-radius: 10px;
    }
    .p3wu-surface__head {
        flex-wrap: wrap;
        padding: 12px 13px;
    }
    .p3wu-surface__actions {
        gap: 6px;
    }
    .p3wu-surface__body {
        padding: 10px 12px 16px;
    }
    .p3wu-row {
        padding: 12px 11px;
        border-radius: 7px;
    }
    .p3wu-article__title {
        font-size: 19px;
    }
    .p3wu-article__summary {
        padding: 11px 12px;
    }
    .p3wu-launch {
        padding: 16px;
        border-radius: 10px;
    }
    /* Touch/narrow targets reach the 44px minimum while keeping the glyph. */
    .p3wu-btn {
        min-height: 44px;
        padding: 8px 12px;
    }
    .p3wu-btn--icon {
        min-width: 44px;
    }
    .p3wu-launch__close {
        min-width: 44px;
        min-height: 44px;
        margin: -6px -6px 0 0;
    }
    /* WU09: on narrow widths the text label collapses, but the button keeps its
       visible glyph + aria-label/title — never an empty hidden control. */
    .p3wu-btn__label {
        display: none;
    }
    .p3wu-btn--mark-all {
        min-width: 44px;
        justify-content: center;
    }
    .p3wu-btn__glyph {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .p3wu-bell,
    .p3wu-row,
    .p3wu-btn,
    .p3wu-launch__close {
        transition: none;
    }
}
