/* The studio: what's happening, the call fitted to the window, what needs you, and your controls. */

/* ---------- The call fits the window ---------- */

/* The studio takes all the height the shell gives it: the heading, then the call in whatever is
   left, then your controls. Nothing is pushed out of sight, and the page never scrolls while the
   call is on, except on a window too small to hold a sensible call at all. */
.pod-studio {
    container: pod-studio / inline-size;
}

.pod-studio:not([hidden]) {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--space-6);
    min-height: 0;
    max-width: none;
}

.pod-stage-area {
    container: pod-area / size;
    position: relative;
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--space-6);
    min-height: calc(var(--space-24) * 3);
}

/* ---------- The heading ---------- */

/* The words and the actions share a line for as long as they fit. Narrower, the actions keep only
   their icons (their names stay for screen readers and in tooltips); narrower still, they take a
   line of their own. The line under the heading shows only where there's height to spare. */
.pod-studio .pod-head {
    flex-wrap: wrap;
    gap: var(--space-4) var(--space-8);
    padding-bottom: 0;
    border-bottom: 0;
}

.pod-studio .pod-head-text {
    flex: 1 1 auto;
    min-width: 0;
}

.pod-studio .pod-head h1 {
    font-size: var(--font-size-base);
    white-space: nowrap;
}

.pod-studio .pod-sub {
    display: none;
}

.pod-studio .pod-head-actions {
    flex: none;
    flex-wrap: nowrap;
}

@media (min-width: 600px) and (min-height: 700px) {
    .pod-studio .pod-head h1 {
        font-size: var(--font-size-lg);
    }

    .pod-studio .pod-sub {
        display: block;
    }
}

.pod-clock {
    font-weight: var(--font-weight-regular);
    font-variant-numeric: tabular-nums;
}

.pod-clock[hidden],
.pod-studio .pod-head h1 > .pod-dot[hidden] {
    display: none;
}

@container pod-studio (max-width: 520px) {
    .pod-head-actions .pod-action-name {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .pod-head-actions .bu-button:has(.pod-action-name) {
        padding-inline: 0;
        aspect-ratio: 1;
    }
}

/* ---------- The episode's name ---------- */

/* Text until you point at it or click it: then it shows it's a field. */
.pod-name {
    display: inline-flex;
    align-items: center;
    justify-self: start;
    gap: var(--space-3);
    max-width: 100%;
    margin-inline-start: calc(var(--space-3) * -1);
    padding: var(--space-1) var(--space-3);
    border: var(--border-width-hairline) solid transparent;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    cursor: text;
}

.pod-name[hidden] {
    display: none;
}

.pod-name:hover {
    border-color: var(--color-border-subtle);
}

.pod-name:focus-within {
    border-color: var(--color-border);
    background-color: var(--color-surface);
}

.pod-name:has(.pod-name-input:focus-visible) {
    outline: var(--focus-ring-width) solid var(--color-focus);
    outline-offset: var(--focus-ring-offset);
}

.pod-name svg {
    flex: none;
    width: var(--size-icon-sm);
    height: var(--size-icon-sm);
}

.pod-name-input {
    field-sizing: content;
    min-width: 16ch;
    max-width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-text);
    font: inherit;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    outline: none;
}

.pod-name-input::placeholder {
    color: var(--color-text-muted);
}

/* A guest sees the name, but only the host can change it. */
.pod-name-text {
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
}

.pod-name-text[hidden] {
    display: none;
}

.pod-name--title .pod-name-input {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
}

/* ---------- What needs you: notices and people asking to join ---------- */

.pod-alerts {
    display: grid;
    gap: var(--space-4);
}

.pod-alerts:empty {
    display: none;
}

/* Over the call's corner instead of pushing it down. */
.pod-stage-area:has(.pod-stage) > .pod-alerts {
    position: absolute;
    inset: var(--space-4) var(--space-4) auto auto;
    z-index: 1;
    width: min(calc(100% - var(--space-8)), 56ch);
}

.pod-notice,
.pod-request {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-6);
    padding: var(--space-5) var(--space-6);
    border: var(--border-width-hairline) solid var(--color-border);
    border-radius: var(--radius-md);
    background-color: var(--color-surface);
    box-shadow: var(--shadow-elevated);
    font-size: var(--font-size-md);
}

.pod-notice p,
.pod-request p {
    margin: 0;
}

.pod-notice > svg {
    width: var(--size-icon-md);
    height: var(--size-icon-md);
    color: var(--color-text-muted);
}

.pod-notice.is-problem {
    border-color: var(--color-danger-soft);
}

.pod-notice.is-problem > svg {
    color: var(--color-danger-text);
}

/* The close button sits at the end of the first row; any action goes under the words. */
.pod-notice-close {
    --bu-icon-button-size: calc(var(--space-12) + var(--space-2));
    --bu-icon-button-icon: var(--size-icon-sm);
    align-self: start;
    color: var(--color-text-muted);
}

.pod-notice > .pod-notice-actions {
    grid-column: 2 / -1;
}

.pod-notice-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
}

/* A notice can be swiped away on a touch screen, so it only scrolls the page up and down. */
.pod-notice {
    touch-action: pan-y;
}

@media (prefers-reduced-motion: no-preference) {
    .pod-notice:not(.is-dragging) {
        transition: translate var(--duration-color) var(--ease-standard), opacity var(--duration-color) var(--ease-standard);
    }
}

.pod-request-initial {
    display: grid;
    place-items: center;
    width: var(--space-16);
    height: var(--space-16);
    border-radius: var(--radius-full);
    background-color: var(--color-secondary);
    color: var(--color-secondary-text);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
}

.pod-request-text {
    min-width: 0;
    overflow-wrap: anywhere;
}

.pod-request-actions {
    display: flex;
    gap: var(--space-3);
}

/* Several asking at once: one card, a row for each. */
.pod-requests {
    display: grid;
    gap: var(--space-4);
    padding: var(--space-6);
    border: var(--border-width-hairline) solid var(--color-border);
    border-radius: var(--radius-md);
    background-color: var(--color-surface);
    box-shadow: var(--shadow-elevated);
}

.pod-requests[hidden] {
    display: none;
}

.pod-requests-title {
    margin: 0;
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold);
}

.pod-requests-note {
    margin: 0;
}

.pod-requests-note[hidden] {
    display: none;
}

.pod-requests-list {
    display: grid;
    gap: var(--space-3);
    margin: 0;
    padding: 0;
    list-style: none;
}

.pod-requests-row {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    font-size: var(--font-size-md);
}

.pod-requests-row > p {
    flex: 1;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 520px) {
    .pod-request {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .pod-request-actions {
        grid-column: 2;
        justify-self: start;
    }
}

/* Something that has just arrived, such as someone asking to join, settles into place. */
@media (prefers-reduced-motion: no-preference) {
    .pod-enter {
        animation: pod-enter var(--duration-move) var(--ease-settle);
    }

    @keyframes pod-enter {
        from {
            opacity: 0;
            translate: 0 calc(var(--space-4) * -1);
        }
    }
}

/* ---------- The notifications tray ---------- */

.pod-tray[popover] {
    position-area: block-end span-inline-start;
    width: min(calc(100vw - var(--space-8)), 44ch);
    margin-block-start: var(--space-4);
}

.pod-tray-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    min-height: var(--space-16);
}

.pod-tray-list {
    display: grid;
    gap: var(--space-6);
    margin: var(--space-2) 0 0;
    padding: 0;
    list-style: none;
}

.pod-tray-list:empty {
    display: none;
}

.pod-tray-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: var(--space-2) var(--space-5);
    font-size: var(--font-size-sm);
}

.pod-tray-item p {
    margin: 0;
}

.pod-tray-item > svg {
    width: var(--size-icon-sm);
    height: var(--size-icon-sm);
    margin-block-start: var(--space-1);
    color: var(--color-text-muted);
}

.pod-tray-item.is-problem > svg {
    color: var(--color-danger-text);
}

.pod-tray-item > .pod-notice-actions {
    grid-column: 2;
}

.pod-tray-empty {
    margin: var(--space-2) 0 0;
}

.pod-tray-empty[hidden] {
    display: none;
}

.pod-tray-switch {
    font-size: var(--font-size-sm);
}

/* ---------- On your own: your picture and the invite ---------- */

/* One above the other, or side by side when the room for them is wider than it's tall. The
   picture never grows past what fits. */
.pod-alone {
    display: grid;
    flex: 1;
    align-content: center;
    align-items: center;
    gap: var(--space-8);
}

.pod-alone[hidden] {
    display: none;
}

.pod-alone > .pod-stage-item {
    justify-self: center;
    width: min(100%, (100cqh - var(--space-24) * 5) * 16 / 9);
}

@container pod-area (min-aspect-ratio: 6 / 5) {
    .pod-alone {
        grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
        gap: var(--space-12);
    }

    .pod-alone > .pod-stage-item {
        width: min(100%, 100cqh * 16 / 9);
    }
}

.pod-seat {
    display: grid;
    gap: var(--space-4);
    padding: var(--space-10);
    border: var(--border-width-hairline) solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
    background-color: var(--color-surface);
}

.pod-seat > * {
    margin: 0;
}

.pod-invite-input {
    min-width: 0;
    text-overflow: ellipsis;
}

@media (max-width: 520px) {
    .pod-seat {
        padding: var(--space-8);
    }
}

/* ---------- Your controls: a dock under the call ---------- */

.pod-dock {
    display: flex;
    flex: none;
    align-items: center;
    align-self: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border: var(--border-width-hairline) solid var(--color-border-subtle);
    border-radius: var(--radius-full);
    background-color: var(--color-surface);
    box-shadow: var(--shadow-surface);
}

.pod-dock[hidden],
.pod-dock > [hidden] {
    display: none;
}

.pod-tool {
    width: calc(var(--space-16) + var(--space-4));
    height: calc(var(--space-16) + var(--space-4));
    border-radius: var(--radius-full);
    background-color: var(--color-secondary);
}

.pod-tool--sm {
    --bu-icon-button-icon: var(--size-icon-md);
    width: calc(var(--space-16) + var(--space-2));
    height: calc(var(--space-16) + var(--space-2));
}

.pod-tool.is-off {
    background-color: var(--color-danger-soft);
    color: var(--color-danger-text);
}

.pod-leave {
    color: var(--color-danger-text);
}

.pod-dock-rule {
    width: var(--border-width-hairline);
    height: var(--space-12);
    margin-inline: var(--space-1);
    background-color: var(--color-border);
}

/* Record and stop: red, the one colour every recorder shares, filled so it reads at a glance. */
.bu-icon-button.pod-record {
    background-color: var(--color-danger);
    color: var(--color-on-status);
}

.bu-icon-button.pod-record:hover:not(:disabled) {
    background-color: var(--color-danger-hover);
}

.bu-icon-button.pod-record:disabled {
    background-color: var(--color-surface-muted);
    color: var(--color-text-soft);
}

/* A narrow phone: the dock's buttons a little smaller, so all of them fit. */
@media (max-width: 400px) {
    .pod-dock {
        gap: var(--space-2);
    }

    .pod-dock .pod-tool {
        width: calc(var(--space-16) + var(--space-2));
        height: calc(var(--space-16) + var(--space-2));
    }
}

/* A split button: the button, and an arrow for its menu, as one pill. */
.pod-split {
    display: inline-flex;
    flex: none;
    align-items: center;
    border-radius: var(--radius-full);
    background-color: var(--color-secondary);
    color: var(--color-secondary-text);
}

.pod-split.is-off {
    background-color: var(--color-danger-soft);
    color: var(--color-danger-text);
}

.pod-split > .pod-tool {
    background-color: transparent;
    color: inherit;
}

.pod-split-more {
    display: grid;
    place-items: center;
    align-self: stretch;
    padding: 0 var(--space-4) 0 var(--space-1);
    border: 0;
    border-radius: 0 var(--radius-full) var(--radius-full) 0;
    background-color: transparent;
    color: inherit;
    cursor: pointer;
}

.pod-split-more svg {
    width: var(--size-icon-sm);
    height: var(--size-icon-sm);
}

.pod-split-more:hover {
    background-color: var(--color-secondary-hover);
}

.pod-split.is-off > .pod-split-more:hover {
    background-color: var(--color-danger-soft);
    color: var(--color-text);
}

.pod-split-more:focus-visible {
    outline: var(--focus-ring-width) solid var(--color-focus);
    outline-offset: calc(var(--focus-ring-offset) * -1);
}

/* Menus opening upward from a button in the dock: the layout, your mic, your camera. */
.pod-pop-menu[popover] {
    position-area: block-start;
    margin-block-end: var(--space-4);
    transform-origin: 50% 100%;
}

.pod-pop-menu .bu-menu-item {
    gap: var(--space-5);
}

.pod-pop-menu .bu-menu-item > span {
    flex: 1;
}

.pod-pop-menu .bu-menu-item:disabled {
    color: var(--color-text-soft);
    cursor: default;
}

.pod-pop-menu .bu-menu-item.is-current {
    font-weight: var(--font-weight-semibold);
}

.pod-pop-check {
    color: var(--color-success);
}

.pod-pop-check[hidden] {
    visibility: hidden;
}

.pod-pop-hint {
    max-width: 24ch;
    margin: 0;
}

/* ---------- A phone on its side, or any short window ---------- */

@media (orientation: landscape) and (max-height: 540px) {
    /* The studio in one row over the call: what's happening, your controls, and its action. */
    .pod-studio:not([hidden]):has(> .pod-dock:not([hidden])) {
        display: grid;
        grid-template-areas:
            "text dock actions"
            "stage stage stage";
        grid-template-columns: minmax(0, 1fr) auto auto;
        grid-template-rows: auto minmax(0, 1fr);
        align-items: center;
        gap: var(--space-4) var(--space-6);
    }

    .pod-studio:has(> .pod-dock:not([hidden])) > .pod-head {
        display: contents;
    }

    .pod-studio:has(> .pod-dock:not([hidden])) .pod-head-text {
        grid-area: text;
    }

    .pod-studio:has(> .pod-dock:not([hidden])) .pod-head-actions {
        grid-area: actions;
    }

    .pod-studio:has(> .pod-dock:not([hidden])) > .pod-stage-area {
        grid-area: stage;
        align-self: stretch;
    }

    .pod-studio > .pod-dock {
        grid-area: dock;
        padding: 0;
        border: 0;
        background: none;
        box-shadow: none;
    }

    .pod-studio > .pod-dock .pod-tool {
        width: calc(var(--space-16) + var(--space-2));
        height: calc(var(--space-16) + var(--space-2));
    }

    /* The dock is at the top here, so its menus open downward, and the arrows say so. */
    .pod-studio > .pod-dock .pod-pop-menu[popover] {
        position-area: block-end;
        margin-block: var(--space-4) 0;
        transform-origin: 50% 0;
    }

    .pod-studio > .pod-dock .pod-split-more svg {
        rotate: 180deg;
    }
}
