/* Public "watching now" badge, viewer-name prompt and "who is watching"
   list on the live page (desktop + mobile). Markup:
   application/views/live/partials/_viewers_badge.tpl, behaviour:
   js/live-presence.js. Bottom-left: the reCAPTCHA badge is bottom-right.
   Stays under Bootstrap modals (z-index 1040+). */
.live-viewers {
    display: flex;
    font-family: inherit;
}

.live-viewers [hidden] {
    display: none !important;
}

/* The dock: one pill fixed bottom-left holding the "watching now" count and
   the follow bell. Bottom-left because the reCAPTCHA badge is bottom-right;
   under Bootstrap modals (z-index 1040+). No transform/filter here - the
   name prompt and viewers sheet inside are position:fixed to the viewport. */
.live-dock {
    position: fixed;
    left: 12px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    z-index: 1030;
    display: inline-flex;
    align-items: stretch;
    border-radius: 999px;
    background: rgba(15, 52, 96, 0.96);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.live-viewers-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin: 0;
    padding: 8px 12px 8px 13px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #fff;
    font: inherit;
    cursor: pointer;
}

.live-viewers-badge:hover {
    background: rgba(255, 255, 255, 0.06);
}

.live-viewers-badge:focus {
    outline: none;
}

.live-viewers-badge:focus-visible {
    outline: 2px solid #6fb0ff;
    outline-offset: 2px;
}

.live-dock__divider {
    width: 1px;
    margin: 7px 0;
    background: rgba(255, 255, 255, 0.22);
}

.live-dock__follow {
    display: inline-flex;
    align-items: center;
    padding: 4px;
}

/* Browsers without push support (e.g. iOS Safari outside a home-screen
   app): nothing to offer, so the bell and its divider disappear. */
.live-dock__follow[data-push-state="unsupported"],
.live-dock__divider:has(+ .live-dock__follow[data-push-state="unsupported"]) {
    display: none;
}

/* White "Follow" button that "rings" every few seconds - a wiggle plus a
   soft halo - as a "you can tap here" cue without constant motion. */
.live-dock__bell {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 5px 12px 5px 10px;
    border: 0;
    border-radius: 999px;
    background: #fff;
    color: #0f3460;
    font: inherit;
    font-weight: 800;
    white-space: nowrap;
    cursor: pointer;
    animation: live-dock-halo 3.2s ease-in-out infinite;
}

.live-dock__bell i {
    display: inline-block;
    transform-origin: 50% 8%;
    animation: live-dock-shake 3.2s ease-in-out infinite;
}

.live-dock__bell:hover {
    background: #e6eefb;
}

.live-dock__bell:focus {
    outline: none;
}

.live-dock__bell:focus-visible {
    outline: 2px solid #6fb0ff;
    outline-offset: 2px;
}

@keyframes live-dock-shake {
    0%, 62%, 100% { transform: rotate(0); }
    66% { transform: rotate(18deg); }
    70% { transform: rotate(-16deg); }
    74% { transform: rotate(12deg); }
    78% { transform: rotate(-8deg); }
    82% { transform: rotate(4deg); }
    86% { transform: rotate(0); }
}

@keyframes live-dock-halo {
    0%, 60%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
    72% { box-shadow: 0 0 0 7px rgba(255, 255, 255, 0.4); }
}

/* Loading: no ringing. */
.live-dock__follow[data-push-state="loading"] .live-dock__bell,
.live-dock__follow[data-push-state="loading"] .live-dock__bell i {
    animation: none;
    cursor: default;
}

/* Following: a quiet green check, no label, no ringing. The button is
   disabled by push-subscribe.js; pointer-events:none lets the tap reach
   the wrapper, which shows the confirmation toast. */
.live-dock__follow[data-push-state="subscribed"] {
    cursor: pointer;
}

.live-dock__follow[data-push-state="subscribed"] .live-dock__bell {
    padding: 5px 8px;
    background: #16a34a;
    color: #fff;
    pointer-events: none;
    animation: none;
}

.live-dock__follow[data-push-state="subscribed"] .live-dock__bell i {
    animation: none;
}

.live-dock__follow[data-push-state="subscribed"] .live-dock__bell span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.live-dock__toast {
    position: fixed;
    left: 12px;
    bottom: calc(66px + env(safe-area-inset-bottom, 0px));
    z-index: 1031;
    max-width: min(340px, calc(100% - 24px));
    padding: 10px 12px;
    border: 1px solid #dbe3ee;
    border-radius: 12px;
    background: #fff;
    color: #16233a;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
    box-shadow: 0 10px 26px rgba(10, 30, 60, 0.22);
}

.live-dock__toast strong {
    display: block;
    color: #166534;
    font-size: 14px;
}

.live-dock [hidden] {
    display: none !important;
}

.live-viewers-badge__chev {
    font-size: 16px;
    line-height: 1;
    opacity: 0.7;
}

.live-viewers-badge__dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ff4d4f;
    flex: none;
    animation: live-viewers-pulse 1.6s infinite;
}

@keyframes live-viewers-pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 77, 79, 0.6); }
    70% { box-shadow: 0 0 0 7px rgba(255, 77, 79, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 77, 79, 0); }
}

.live-viewers-x {
    position: absolute;
    top: 6px;
    right: 8px;
    margin: 0;
    padding: 2px 6px;
    border: 0;
    background: none;
    color: #8793a6;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

/* Name prompt: a small balloon above the badge. */
.live-viewers-prompt {
    position: fixed;
    left: 12px;
    bottom: calc(66px + env(safe-area-inset-bottom, 0px));
    z-index: 1031;
    width: calc(100% - 96px);
    max-width: 340px;
    padding: 12px;
    border: 1px solid #dbe3ee;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 10px 26px rgba(10, 30, 60, 0.22);
    color: #16233a;
    text-align: left;
    animation: live-viewers-up 0.25s ease;
}

.live-viewers-prompt::after {
    content: "";
    position: absolute;
    left: 28px;
    bottom: -7px;
    width: 12px;
    height: 12px;
    background: #fff;
    border-right: 1px solid #dbe3ee;
    border-bottom: 1px solid #dbe3ee;
    transform: rotate(45deg);
}

.live-viewers-prompt__title {
    padding-right: 22px;
    color: #0f3460;
    font-size: 14px;
    font-weight: 800;
}

.live-viewers-prompt__text {
    margin: 2px 0 8px;
    color: #5d6b80;
    font-size: 12px;
}

.live-viewers-prompt__row {
    display: flex;
    gap: 6px;
    margin: 0;
}

.live-viewers-prompt__row input {
    flex: 1;
    min-width: 0;
    height: 38px;
    margin: 0;
    padding: 0 10px;
    border: 1px solid #c9d5e4;
    border-radius: 9px;
    background: #fff;
    color: #16233a;
    font-size: 16px; /* 16px keeps iOS from zooming on focus */
    box-shadow: none;
}

.live-viewers-prompt__row input:focus {
    outline: none;
    border-color: #1a6fc8;
    box-shadow: 0 0 0 2px rgba(26, 111, 200, 0.25);
}

.live-viewers-go {
    height: 38px;
    margin: 0;
    padding: 0 14px;
    border: 0;
    border-radius: 9px;
    background: #0f3460;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.live-viewers-go[disabled] {
    opacity: 0.6;
    cursor: default;
}

.live-viewers-prompt__error {
    margin-top: 6px;
    color: #c4161c;
    font-size: 12px;
    font-weight: 600;
}

/* "Who is watching" list: bottom sheet on phones, panel above the badge
   on wider screens. */
.live-viewers-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1032;
    background: rgba(10, 20, 40, 0.45);
}

.live-viewers-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1033;
    display: flex;
    flex-direction: column;
    max-height: 72vh;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-radius: 18px 18px 0 0;
    background: #fff;
    color: #16233a;
    text-align: left;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.25);
    animation: live-viewers-up 0.25s ease;
}

@media (min-width: 768px) {
    .live-viewers-sheet {
        left: 12px;
        right: auto;
        bottom: calc(66px + env(safe-area-inset-bottom, 0px));
        width: 360px;
        max-height: 60vh;
        border-radius: 16px;
    }

    .live-viewers-sheet__grab {
        display: none;
    }
}

@keyframes live-viewers-up {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .live-dock__bell,
    .live-dock__bell i,
    .live-viewers-badge__dot,
    .live-viewers-prompt,
    .live-viewers-sheet {
        animation: none;
    }
}

.live-viewers-sheet__grab {
    width: 40px;
    height: 4px;
    margin: 8px auto 2px;
    border-radius: 4px;
    background: #d3dae5;
}

.live-viewers-sheet__head {
    position: relative;
    display: flex;
    align-items: center;
    padding: 10px 44px 10px 16px;
    border-bottom: 1px solid #eef1f5;
}

.live-viewers-sheet__head .live-viewers-x {
    top: 50%;
    transform: translateY(-50%);
}

.live-viewers-sheet__title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #0f3460;
    font-size: 16px;
    font-weight: 800;
}

.live-viewers-sheet__count {
    padding: 1px 9px;
    border-radius: 999px;
    background: #eaf3ff;
    color: #1a6fc8;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.live-viewers-list {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: 6px 8px;
    overflow-y: auto;
    list-style: none;
}

.live-viewers-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 8px;
    border-radius: 10px;
}

.live-viewers-list li.is-me {
    background: #f1f7ff;
}

.live-viewers-list li.is-note {
    color: #5d6b80;
    font-size: 13px;
}

.live-viewers-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex: none;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
}

.live-viewers-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    color: #16233a;
    font-size: 14px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.live-viewers-name small {
    display: block;
    color: #7a879a;
    font-size: 11px;
    font-weight: 500;
}

.live-viewers-you {
    padding: 2px 8px;
    border-radius: 999px;
    background: #eaf3ff;
    color: #1a6fc8;
    font-size: 11px;
    font-weight: 700;
}

.live-viewers-guests {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px 4px;
    color: #5d6b80;
    font-size: 13px;
}

.live-viewers-guests .live-viewers-avatar {
    width: 28px;
    height: 28px;
    background: #c3ccd9;
    color: #4a5668;
    font-size: 14px;
}

.live-viewers-sheet__foot {
    padding: 10px 16px 16px;
}

.live-viewers-name-btn {
    width: 100%;
    margin: 0;
    padding: 10px;
    border: 1px solid #0f3460;
    border-radius: 10px;
    background: #0f3460;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.live-viewers-name-btn.is-secondary {
    border-color: #c9d5e4;
    background: #fff;
    color: #0f3460;
}
