/* SPDX-License-Identifier: AGPL-3.0-only */
/* ---------- Controls ---------- */

.controls {
    height: var(--controls-h);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 12px env(safe-area-inset-bottom);
    flex-shrink: 0;
}

.ctrl-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 50%;
    background: var(--surface-2);
    transition: background 0.15s;
}

.ctrl-btn:hover {
    background: var(--surface-hover);
}

/* Icon-only buttons: the label stays for screen readers, sighted users get the tooltip. */
.ctrl-btn .label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Only generated while hovered/focused, so hidden tooltips never widen the page on small screens. */
.ctrl-btn[data-tooltip]:hover::after,
.ctrl-btn[data-tooltip]:focus-visible::after {
    content: attr(data-tooltip);
    content: attr(data-tooltip) / '';
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    padding: 6px 10px;
    border-radius: 6px;
    background: #3c4043;
    color: #fff;
    font-size: 12px;
    line-height: 1.3;
    white-space: nowrap;
    pointer-events: none;
    transform: translateX(-50%);
    animation: tooltip-in 0.12s 0.3s both;
    z-index: 40;
}

@keyframes tooltip-in {
    from {
        opacity: 0;
        transform: translate(-50%, 4px);
    }
}

@media (hover: none) {
    .ctrl-btn[data-tooltip]::after {
        display: none;
    }
}

#btn-mic:not(.on),
#btn-cam:not(.on) {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger-text);
}

.ctrl-btn.active {
    background: var(--primary);
    color: var(--on-primary);
}

.ctrl-btn.recording {
    background: var(--danger-fill);
    color: var(--on-danger);
}

.ctrl-btn.recording:hover {
    background: var(--danger-fill-hover);
}

.ctrl-btn:disabled {
    opacity: 0.6;
    cursor: progress;
}

/* Not allowed right now (e.g. screen sharing for hosts only), but still focusable so the reason can be read. */
.ctrl-btn[aria-disabled='true'] {
    opacity: 0.5;
    cursor: not-allowed;
}

.ctrl-btn.danger {
    width: 64px;
    border-radius: 24px;
    background: var(--danger-fill);
    color: var(--on-danger);
}

.ctrl-btn.danger:hover {
    background: var(--danger-fill-hover);
}

/* Meeting bar: room info on the left, call actions centred, panels and host tools on the right. */
.room-controls {
    display: grid;
    grid-template-columns: minmax(max-content, 1fr) auto minmax(max-content, 1fr);
    column-gap: 12px;
    padding: 0 16px env(safe-area-inset-bottom);
}

.controls-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.controls-left {
    justify-self: start;
}

.controls-right {
    justify-self: end;
}

.bar-clock {
    font-size: 15px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.bar-sep {
    width: 1px;
    height: 18px;
    background: var(--border);
}

.controls-left .invite-btn {
    width: auto;
    max-width: 280px;
    height: 40px;
    gap: 8px;
    padding-block: 0;
    padding-inline: 10px 14px;
    border-radius: 20px;
    background: transparent;
}

.controls-left .invite-btn:hover {
    background: var(--surface-2);
}

.controls-left .invite-btn svg {
    width: 20px;
    height: 20px;
    color: var(--muted);
}

.bar-room {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
}

/* Separates host tools from the panel toggles, only when the host tools are shown. */
.bar-divider {
    display: none;
    width: 1px;
    height: 28px;
    background: var(--border);
}

.controls-right:has(> #btn-lock:not([hidden]), > #btn-record:not([hidden]), > #btn-live:not([hidden])) .bar-divider {
    display: block;
}

/* Webinar attendees can't publish until a host brings them on stage. */
.room.is-attendee :is(#btn-mic, #btn-cam, #btn-switch-cam, #btn-screen, #btn-share-file) {
    display: none;
}

.more-wrap {
    position: relative;
    display: flex;
}

.more-btn[aria-expanded='true'] {
    background: var(--primary);
    color: var(--on-primary);
}

.more-btn[aria-expanded='true']::after {
    display: none;
}

.more-menu {
    display: none;
    position: absolute;
    bottom: calc(100% + 14px);
    left: 50%;
    min-width: 230px;
    max-width: calc(100vw - 16px);
    padding: 6px;
    flex-direction: column;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 10px 30px var(--shadow);
    transform: translateX(-50%);
    z-index: 35;
}

.more-menu.open {
    display: flex;
}

.more-menu .ctrl-btn {
    width: 100%;
    height: 44px;
    justify-content: flex-start;
    gap: 14px;
    padding: 0 12px;
    border-radius: 10px;
    background: transparent;
}

.more-menu .ctrl-btn:hover {
    background: var(--surface-2);
}

.more-menu .ctrl-btn.active {
    background: var(--primary);
}

.more-menu .ctrl-btn.recording {
    background: var(--danger-fill);
}

.more-menu .ctrl-btn .label {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    font-size: 15px;
    color: var(--text);
}

.more-menu .ctrl-btn.active .label {
    color: var(--on-primary);
}

.more-menu .ctrl-btn.recording .label {
    color: var(--on-danger);
}

.more-menu .ctrl-btn::after,
.more-menu .bar-room {
    display: none;
}

.badge {
    position: absolute;
    top: -4px;
    inset-inline-end: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--danger-fill);
    color: #fff;
    font-size: 11px;
    line-height: 18px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: center;
    /* A ring in the bar's colour separates the badge from its button. */
    box-shadow: 0 0 0 2px var(--badge-ring, var(--bg));
    pointer-events: none;
}

.more-menu {
    --badge-ring: var(--surface);
}

.badge.hand-badge {
    background: var(--hand);
    color: #1f1300;
}

.start-audio {
    position: fixed;
    top: 64px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    box-shadow: 0 10px 30px var(--shadow);
}

/* ---------- Reactions picker ---------- */

.reaction-picker {
    position: fixed;
    left: 50%;
    bottom: calc(var(--controls-h) + 8px);
    z-index: 36;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    width: max-content;
    max-width: calc(100vw - 16px);
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 28px;
    background: var(--surface);
    box-shadow: 0 10px 30px var(--shadow);
    transform: translateX(-50%);
}

.reaction-picker button {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    transition:
        transform 0.1s,
        background 0.15s;
}

.reaction-picker button:hover,
.reaction-picker button:focus-visible {
    background: var(--surface-2);
    transform: scale(1.15);
}

.reaction-picker button:active {
    transform: scale(0.95);
}

@media (prefers-reduced-motion: reduce) {
    .reaction-picker button {
        transition: none;
    }
}

/* ---------- "You're muted" hint ---------- */

.muted-hint {
    position: fixed;
    left: 50%;
    bottom: calc(var(--controls-h) + 8px);
    z-index: 34;
    display: flex;
    align-items: center;
    gap: 12px;
    width: max-content;
    max-width: calc(100vw - 16px);
    padding-block: 8px;
    padding-inline: 14px 8px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 10px 30px var(--shadow);
    transform: translateX(-50%);
    animation: muted-hint-in 0.2s ease-out;
}

/* Stacks above the reactions picker when both are open. */
.room:has(.reaction-picker:not([hidden])) .muted-hint {
    bottom: calc(var(--controls-h) + 70px);
}

.muted-hint > svg {
    flex-shrink: 0;
    color: var(--danger);
}

.muted-hint-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    font-size: 14px;
}

.muted-hint-text small {
    font-size: 12px;
}

.muted-hint .primary-btn {
    flex-shrink: 0;
    padding: 8px 14px;
}

.muted-hint .ghost-btn {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    height: 34px;
    min-width: 34px;
    padding: 0;
    border: 0;
    font-size: 14px;
}

@keyframes muted-hint-in {
    from {
        opacity: 0;
        transform: translate(-50%, 8px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .muted-hint {
        animation: none;
    }
}

/* ---------- Host: people asking to join ---------- */

.knock-card {
    position: fixed;
    inset-inline-end: 16px;
    bottom: calc(var(--controls-h) + 12px);
    z-index: 25;
    width: min(340px, calc(100vw - 32px));
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 20px 60px var(--shadow);
    animation: share-card-in 0.2s ease-out;
}

.knock-card h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.knock-card p {
    margin: 0;
    font-size: 14px;
    overflow-wrap: anywhere;
}

.knock-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

.knock-card-actions button {
    height: 38px;
    padding: 0 16px;
}

/* ---------- "Your meeting's ready" share card (the link row and QR code are shared with the Invite dialog) ---------- */

.share-card {
    position: fixed;
    inset-inline-start: 16px;
    bottom: calc(var(--controls-h) + 12px);
    z-index: 20;
    width: min(360px, calc(100vw - 32px));
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px 20px 20px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 20px 60px var(--shadow);
    animation: share-card-in 0.2s ease-out;
}

.share-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.share-card-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.share-card-header .ghost-btn {
    display: grid;
    place-items: center;
    height: 32px;
    min-width: 32px;
    padding: 0;
    border: 0;
    font-size: 14px;
}

.share-card-header .ghost-btn svg,
.muted-hint .ghost-btn svg {
    width: 18px;
    height: 18px;
}

.share-card-invite {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding-block: 10px;
    padding-inline: 16px 20px;
}

.share-card-text,
.share-card-note {
    margin: 0;
    font-size: 14px;
    line-height: 1.45;
    color: var(--muted);
}

.share-card-note {
    font-size: 13px;
}

.invite-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-block: 4px;
    padding-inline: 14px 4px;
    border-radius: 10px;
    background: var(--surface-2);
}

.invite-link span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    user-select: all;
}

.invite-link .ghost-btn {
    display: grid;
    place-items: center;
    height: 36px;
    min-width: 36px;
    padding: 0;
    border: 0;
    color: var(--muted);
}

.invite-link .ghost-btn:hover {
    background: var(--surface);
    color: var(--text);
}

.invite-link .ghost-btn.copied {
    color: var(--success);
}

.invite-link .ghost-btn.active {
    color: var(--primary);
}

.invite-link svg {
    width: 20px;
    height: 20px;
}

.invite-qr {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.invite-qr[hidden] {
    display: none;
}

.invite-qr img {
    width: 168px;
    height: 168px;
    padding: 6px;
    border-radius: 12px;
    background: #fff;
    image-rendering: pixelated;
}

.invite-qr figcaption {
    font-size: 13px;
    color: var(--muted);
}

.share-card-calendar {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 500;
    text-align: start;
    color: var(--text);
    cursor: pointer;
}

.share-card-calendar:hover {
    background: var(--surface-2);
}

.share-card-calendar span {
    flex: 1;
    min-width: 0;
}

.share-card-calendar svg {
    width: 20px;
    height: 20px;
    color: var(--primary);
}

.share-card-calendar .share-card-calendar-chevron {
    color: var(--muted);
}

[dir='rtl'] .share-card-calendar-chevron {
    transform: scaleX(-1);
}

/* Scanning your own screen makes no sense on a phone or tablet. */
@media (hover: none) and (pointer: coarse) {
    .invite-qr-toggle,
    .invite-qr {
        display: none;
    }
}

@keyframes share-card-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

@media (max-width: 560px) {
    .share-card,
    .knock-card {
        left: 12px;
        right: 12px;
        width: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .share-card,
    .knock-card {
        animation: none;
    }
}
