/**
 * Aphasia Inbox v2 — mini-logo trigger + one-drip popover
 *
 * Design intent: a friendly little message box, not a mail client.
 * One drip (fact / percentage / encouragement / nudge) per view;
 * zero panel chrome. Fleet grammar: cyan-ish = "hear it" (Listen),
 * green = "click here" (CTA), gold = premium (nudge accent, unread dot).
 * Tokens from design-tokens.css (registered dep). Touch targets ≥ 44px
 * on interactive chrome. No !important (house rule).
 */

/* ---- Wrap: takes over the bell's old hub-header placement so the
        popover can anchor to the trigger ---- */

.as-inbox-wrap {
    position: absolute;
    top: 12px;
    right: 12px;
    display: inline-flex;
}

/* ---- Trigger: the mini logo as a tappable app-icon button ---- */

.as-inbox-wrap .as-inbox-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    padding: 0;
    min-width: 0;
    min-height: 0;
    background: none;
    border: none;
    border-radius: 12px;
    box-shadow: none;
    cursor: pointer;
    position: relative;
    line-height: 1;
    transition: transform 0.12s ease;
}

.as-inbox-wrap .as-inbox-trigger svg {
    display: block;
    border-radius: 9px;
    box-shadow: 0 2px 8px rgba(27, 33, 64, 0.28);
}

.as-inbox-wrap .as-inbox-trigger:hover {
    transform: scale(1.06);
}

.as-inbox-wrap .as-inbox-trigger:active {
    transform: scale(0.96);
}

.as-inbox-wrap .as-inbox-trigger:focus-visible {
    outline: 3px solid var(--as-read-border-strong);
    outline-offset: 2px;
}

/* Gentle attention wiggle when unread — once, shortly after load. */
.as-inbox-wrap .as-inbox-trigger.has-unread svg {
    animation: as-inbox-hello 0.8s ease 0.6s 1;
}

@keyframes as-inbox-hello {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-7deg); }
    50% { transform: rotate(6deg); }
    75% { transform: rotate(-3deg); }
}

/* Unread dot: premium gold, ringed so it reads on any background. */
.as-inbox-dot {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #FFC93C;
    border: 2.5px solid var(--as-surface);
}

/* ---- Popover: one small drip card under the trigger ---- */

.as-inbox-pop {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: min(370px, 92vw);
    background: var(--as-surface);
    border: 1.5px solid var(--as-border);
    border-radius: 16px;
    box-shadow: 0 10px 32px rgba(15, 23, 42, 0.16);
    padding: 18px;
    z-index: 1200;
    font-family: var(--as-font);
    color: var(--as-text);
    text-align: left;
}

/* Little speech tail pointing up at the logo. */
.as-inbox-pop::before {
    content: '';
    position: absolute;
    top: -7px;
    right: 18px;
    width: 12px;
    height: 12px;
    background: var(--as-surface);
    border-left: 1.5px solid var(--as-border);
    border-top: 1.5px solid var(--as-border);
    transform: rotate(45deg);
}

.as-inbox-pop .as-inbox-close {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 32px;
    height: 32px;
    padding: 0;
    min-width: 0;
    background: none;
    border: none;
    border-radius: 8px;
    font-size: 22px;
    line-height: 1;
    color: var(--as-text-muted);
    cursor: pointer;
}

.as-inbox-pop .as-inbox-close:hover {
    color: var(--as-text);
    background: var(--as-surface-soft);
}

.as-inbox-pop .as-inbox-close:focus-visible {
    outline: 3px solid var(--as-read-border-strong);
    outline-offset: 1px;
}

/* ---- The drip: text-message layout ----
   Sender line → received-SMS bubble (tap anywhere on it = read aloud)
   → CTA button below. Familiar shape, generous spacing. */

.as-inbox-drip {
    padding-right: 26px; /* clear the × */
}

.as-inbox-sender {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 10px;
    font-size: var(--as-text-sm);
    font-weight: var(--as-weight-semibold);
    color: var(--as-text-muted);
}

.as-inbox-sender svg {
    border-radius: 5px;
}

.as-inbox-bubble {
    position: relative;
    background: var(--as-surface-soft, #F1F5F9);
    border: 1.5px solid var(--as-border);
    border-left-width: 4px;
    border-radius: 4px 16px 16px 16px;
    padding: 14px 34px 14px 14px; /* right pads clear the 🔊 */
    cursor: pointer;
}

.as-inbox-bubble:hover {
    border-color: var(--as-read-accent);
    border-left-color: inherit;
}

.as-inbox-bubble:focus-visible {
    outline: 3px solid var(--as-read-border-strong);
    outline-offset: 2px;
}

/* Type accent on the bubble edge — fleet grammar: green is reserved for
   ACTIONS, so tips wear the audio/cyan family (spoken guidance), digest
   wears read/blue (info), nudge wears premium gold. */
.as-inbox-drip--tip    .as-inbox-bubble { border-left-color: var(--as-audio, #0E7490); }
.as-inbox-drip--digest .as-inbox-bubble { border-left-color: var(--as-read-accent); }
.as-inbox-drip--nudge  .as-inbox-bubble { border-left-color: #E8B931; }

.as-inbox-bubble-audio {
    position: absolute;
    right: 10px;
    bottom: 8px;
    font-size: 15px;
    opacity: 0.65;
}

.as-inbox-drip-body {
    font-size: var(--as-text-lg);
    line-height: var(--as-leading-relaxed);
    color: var(--as-text);
}

/* Each line of the drip gets real air between it and the next. */
.as-inbox-drip-body p {
    margin: 0 0 12px;
}

.as-inbox-drip-body p:last-child {
    margin-bottom: 0;
}

.as-inbox-pop .as-inbox-drip-cta,
.as-inbox-pop .as-inbox-drip-cta:visited {
    display: block;
    margin-top: 12px;
    padding: 12px 18px;
    min-height: 44px;
    box-sizing: border-box;
    text-align: center;
    background: var(--as-primary-bg);
    color: #FFFFFF;
    text-transform: none;
    font-size: var(--as-text-base);
    font-weight: var(--as-weight-semibold);
    text-decoration: none;
    border-radius: 10px;
    line-height: 1.5;
}

.as-inbox-pop .as-inbox-drip-cta:hover {
    filter: brightness(0.93);
    color: #FFFFFF;
}

.as-inbox-pop .as-inbox-drip-cta:focus-visible {
    outline: 3px solid var(--as-read-border-strong);
    outline-offset: 2px;
}

.as-inbox-navrow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
}

/* "← Back" / "Next tip →": quiet text links, never a nav bar. */
.as-inbox-pop .as-inbox-next {
    display: block;
    margin: 0;
    padding: 6px 4px;
    min-width: 0;
    min-height: 0;
    background: none;
    border: none;
    box-shadow: none;
    font-family: var(--as-font);
    font-size: var(--as-text-base);
    font-weight: var(--as-weight-semibold);
    text-transform: none;
    color: var(--as-action-deep);
    cursor: pointer;
}

.as-inbox-pop .as-inbox-next:hover {
    text-decoration: underline;
}

.as-inbox-pop .as-inbox-next:focus-visible {
    outline: 3px solid var(--as-read-border-strong);
    outline-offset: 1px;
}

.as-inbox-quiet {
    margin: 4px 24px 4px 0;
    font-size: var(--as-text-base);
    color: var(--as-text-muted);
}

.as-inbox-drip-body p.as-inbox-drip-head {
    font-size: var(--as-text-xl);
    font-weight: var(--as-weight-bold);
    line-height: var(--as-leading-tight);
    margin-bottom: 10px;
}

.as-inbox-gold {
    background: #FFF3D6;
    color: #7A5300;
    padding: 1px 6px;
    border-radius: 6px;
    font-weight: var(--as-weight-bold);
    white-space: nowrap;
}

/* ---- Confetti: one-shot emoji burst over the stats drip ---- */

.as-inbox-confetti {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    border-radius: 16px;
}

.as-inbox-confetti-bit {
    position: absolute;
    top: -22px;
    animation: as-inbox-confetti-fall 1.4s ease-in forwards;
}

@keyframes as-inbox-confetti-fall {
    0%   { transform: translateY(0) rotate(0deg);      opacity: 1; }
    80%  { opacity: 1; }
    100% { transform: translateY(300px) rotate(300deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .as-inbox-confetti {
        display: none;
    }
}

/* ---- Small screens: pin below the header, full usable width ---- */

@media (max-width: 480px) {
    .as-inbox-pop {
        position: fixed;
        top: 74px;
        left: 12px;
        right: 12px;
        width: auto;
    }

    .as-inbox-pop::before {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .as-inbox-trigger,
    .as-inbox-trigger.has-unread svg {
        transition: none;
        animation: none;
    }
}
