/*
 * static/css/placement.css — where a shown file appears: the switch (In chat / Side viewer; R-116: no Both) on cards
 * and side viewer tabs, a card shown in the side viewer only, the user's own cards from the file manager and the
 * file manager's open choices (batch 4 §2, lane placement; js: artifacts/placement.js).
 *
 * The UI overhaul (batch 4 §9 phase 2, brief §6.1/§6.17) draws the switch as the shared segmented control: a tonal
 * track and one clearly filled segment for the pick (gold with a black icon in dark, ink with a gold icon in light;
 * review: the old tint was barely visible). Tokens only (tokens.css, the profile's theme.css); every selector is
 * defined once here (I7).
 */

/* ---- the switch: one compact segmented group of two icon buttons ----------------------------------- */
.aiw-place {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border-radius: var(--radius-pill);
    background: var(--c-surface-high);
}

.aiw-place__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--c-on-2);
    cursor: pointer;
    transition: background-color var(--dur-2) var(--ease-standard), color var(--dur-2) var(--ease-standard);
}

.aiw-place__btn svg { display: block; width: 16px; height: 16px; }
.aiw-place__btn:hover { background: var(--c-hover); color: var(--c-on); }
.aiw-place__btn:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 1px; }
/* the pick: the primary fill, so it reads at a glance in both themes (>= 3:1 against the track) */
.aiw-place__btn[aria-pressed="true"],
.aiw-place__btn[aria-pressed="true"]:hover { background: var(--c-primary); color: var(--c-on-primary-accent); }

@media (pointer: coarse) {
    .aiw-place__btn { width: 40px; height: 36px; }
}

@media (forced-colors: active) {
    .aiw-place { border: 1px solid ButtonText; }
    .aiw-place__btn[aria-pressed="true"],
    .aiw-place__btn[aria-pressed="true"]:hover { forced-color-adjust: none; background: Highlight; color: HighlightText; }
    .aiw-place__btn[aria-pressed="true"]:focus-visible { outline-color: ButtonText; }
}

/* in the card's bar: before the actions, which then need no auto margin of their own; a hairline after it */
.aiw-card__place { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 6px; margin-left: auto; }
.aiw-card__place:empty { display: none; }
.aiw-card__place:not(:empty)::after { content: ''; width: 1px; height: 20px; background: var(--c-outline-variant); }
.aiw-card__place:not(:empty) + .aiw-card__actions { margin-left: 0; }

/* the switch takes ~70 px of the bar (two buttons since R-116; it was ~100 px): with it the actions fold into ⋯ 100 px
   earlier than FR §10.3's 480 px, so the title and the meta keep the room they had (V-6 Y34) */
@container aiw-card (max-width: 580px) {
    .aiw-card__place:not(:empty) ~ .aiw-card__actions > .aiw-btn { display: none; }
    .aiw-card__place:not(:empty) ~ .aiw-card__actions > .aiw-card__more { display: inline-flex; }
}

/* in the side viewer's header: before the downloads */
.aiw-stage__place { margin-left: auto; }

/* ---- Side viewer: the card keeps its bar and one line that opens the tab (a control-chip look) --------- */
.aiw-card[data-state="viewer"] .aiw-card__body { min-height: 0; }

.aiw-card__in-viewer {
    display: flex;
    justify-content: flex-start;
    width: calc(100% - 20px);
    height: auto;
    min-height: 36px;
    margin: 10px;
    padding: 0 14px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--c-surface-high);
    color: var(--c-accent-text);
    font: var(--t-label-m);
    text-align: left;
    cursor: pointer;
}

.aiw-card__in-viewer:hover { color: var(--c-accent-text); background: var(--c-surface-highest); }
.aiw-card__in-viewer:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }

/* ---- "Showing in side viewer": the still preview of an interactive page or svg its tab runs (one live copy) --- */
/* an interactive svg's picture, faint under the line that brings its tab forward (never a target itself) */
.aiw-card__still {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0.35;
    pointer-events: none;
    user-select: none;
}

/* the line's words sit on a chip of their own, so they read over a picture in both themes (WCAG AA) */
.aiw-card__staged .aiw-card__staged-text {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 14px;
    border-radius: var(--radius-pill);
    background: var(--c-surface-high);
    color: var(--c-accent-text);
    font: var(--t-label-m);
    box-shadow: var(--elev-1);
}

/* "Show in chat": the way back, above the line that fills the box */
.aiw-card__bring {
    position: absolute;
    right: var(--space-2);
    bottom: var(--space-2);
    z-index: 1;
    height: 32px;
    padding: 0 14px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--c-surface-high);
    color: var(--c-on);
    font: var(--t-label-m);
    box-shadow: var(--elev-1);
}

.aiw-card__bring:hover { background: var(--c-surface-highest); color: var(--c-on); }

@media (pointer: coarse) {
    .aiw-card__bring { height: 40px; }
}

/* ---- the user's own card (the file manager's "In chat"): on the user's side, like their messages ----- */
.shown-message {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    width: 100%;
    max-width: var(--col);
    margin: 0 auto;
}

.shown-body { width: min(100%, 620px); }
.shown-body > .aiw-card { margin: 0; }

.shown-actions {
    display: flex;
    justify-content: flex-end;
    min-height: 32px;
    margin-top: var(--space-1);
    opacity: 0;
    transition: opacity var(--dur-1) var(--ease-standard);
}

.shown-message:hover .shown-actions,
.shown-message:focus-within .shown-actions { opacity: 1; }

@media (hover: none) {
    .shown-actions { opacity: 1; }
}

/* ---- the file manager's open choices ------------------------------------------------------------------- */
.wsp-open { display: inline-flex; align-items: center; gap: 2px; }
.wsp-open__btn svg { display: block; flex: 0 0 auto; width: 18px; height: 18px; }
.wsp-open__word { display: none; }

/* a phone or another touch screen (no tooltips): with all three choices a row's buttons take their own line, so
   the file name keeps the width, and each choice shows its word beside its icon */
@media (max-width: 560px), (hover: none) {
    .wsp-file:has(.wsp-open__btn + .wsp-open__btn) { flex-wrap: wrap; row-gap: 2px; }
    .wsp-file:has(.wsp-open__btn + .wsp-open__btn) > .wsp-file__actions { flex: 1 0 100%; flex-wrap: wrap; justify-content: flex-end; }
    .wsp-open__btn:has(.wsp-open__word) { width: auto; gap: 4px; padding: 0 6px; }
    .wsp-open__word { display: inline; font: var(--t-label-m); font-size: 0.75rem; white-space: nowrap; }
}
