/* Homepage composer bar (PLAN 3.4, P2). Fixed to the bottom, centred; the
   result panel and the style list open above it. One layout for every width:
   the rows wrap on a phone instead of switching to a different component. */

.composer {
    position: fixed;
    left: 50%;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    width: min(820px, calc(100% - 16px));
    z-index: var(--z-composer, 85);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Several parts below set display:flex, which beats the hidden attribute. */
.composer [hidden] { display: none !important; }

/* Page room so the in-flow footer and ICP line are never under the bar.
   --composer-h is measured by composer.js; the fallback covers a no-JS load. */
body:has(.composer) { padding-bottom: calc(var(--composer-h, 128px) + 32px); }

/* Toasts sit bottom-right too: lift them above the bar. */
body:has(.composer) .rt-toasts { bottom: calc(var(--composer-h, 128px) + 28px + env(safe-area-inset-bottom, 0px)); }

/* The drawer and the work dialog each take the screen: the bar steps aside. */
body:has(#create-drawer:not([hidden])) .composer,
body:has([data-work-dialog]:not([hidden])) .composer { display: none; }

.composer-box,
.composer-panel,
.composer-styles {
    background: var(--bg-bar);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-float);
}

.composer-box {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color var(--dur-fast, 0.15s) ease;
}
.composer-box:focus-within { border-color: var(--accent); }

.composer-input {
    width: 100%;
    min-height: 24px;
    max-height: calc(1.5em * 4);
    resize: none;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 16px; /* iOS zooms into anything smaller */
    line-height: 1.5;
    overflow-y: auto;
}
.composer-input::placeholder { color: var(--text-muted); }

.composer-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.composer-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill, 999px);
    background: var(--content-bg);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-sm, 0.8rem);
    cursor: pointer;
    white-space: nowrap;
}
.composer-chip:hover { background: var(--bg-hover); }
.composer-chip:disabled { cursor: default; opacity: 0.6; }
.composer-chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent-text, var(--text)); background: var(--accent-soft); }
.composer-chip:focus-visible,
.composer-go:focus-visible,
.composer-link:focus-visible,
.composer-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The in-flight count (moved here from the retired top-bar create button). */
.composer-records { position: relative; }
.composer-records .notif-badge { top: -6px; right: -6px; }

.composer-style { max-width: 12rem; }
.composer-style span:first-of-type { overflow: hidden; text-overflow: ellipsis; }
.composer-style-cover { width: 20px; height: 20px; border-radius: 5px; object-fit: cover; flex: none; }

.composer-sizes { display: inline-flex; flex-wrap: wrap; gap: 6px; }
/* Our own arrow: the native one sat flush against the rounded right edge (Owner 2026-09-18). */
.composer-select {
    -webkit-appearance: none;
    appearance: none;
    padding: 0 30px 0 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa0b5' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    background-size: 12px 12px;
}

.composer-meta {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: var(--fs-xs, 0.72rem);
    white-space: nowrap;
}
.composer-price { display: inline-flex; align-items: center; gap: 3px; }
.composer-price b { font-weight: 600; font-variant-numeric: tabular-nums; }
/* "Which coin first" sits right after the number it decides. */
.composer-price .composer-coin { margin-left: 6px; font-size: inherit; }

.composer-go {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 18px;
    border: 0;
    border-radius: var(--radius-btn, 10px);
    background: var(--accent);
    color: var(--on-accent, #fff);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.composer-go:hover { background: var(--accent-hover); }
.composer-go[aria-busy="true"] { opacity: 0.85; }

.composer-spin {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: composer-spin 0.8s linear infinite;
}
.composer-go[aria-busy="true"] .composer-spin { display: inline-block; }
@keyframes composer-spin { to { transform: rotate(360deg); } }

.composer-error {
    margin: 0;
    padding: 0 6px;
    color: var(--danger);
    font-size: var(--fs-sm, 0.8rem);
}
.composer-error a { color: inherit; font-weight: 600; }

.composer-link {
    border: 0;
    background: none;
    color: var(--text-muted);
    font: inherit;
    font-size: var(--fs-sm, 0.8rem);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
}
.composer-link:hover { color: var(--text); background: var(--bg-hover); }

/* Result panel */
.composer-panel {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: min(70vh, 640px);
    overflow-y: auto;
}
.composer-panel-head { display: flex; align-items: center; gap: 8px; }
.composer-status { margin: 0; flex: 1; color: var(--text); font-size: var(--fs-sm, 0.85rem); }

.composer-progress { height: 4px; border-radius: 4px; background: var(--content-bg); overflow: hidden; }
.composer-progress span {
    display: block;
    width: 35%;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    animation: composer-progress 1.4s ease-in-out infinite;
}
@keyframes composer-progress { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

.composer-detail { color: var(--text-muted); font-size: var(--fs-sm, 0.8rem); line-height: 1.6; }

.composer-outputs {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}
.composer-outputs img,
.composer-outputs video {
    display: block;
    max-width: 100%;
    max-height: 46vh;
    border-radius: 10px;
    background: var(--content-bg);
}

.composer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.composer-actions a.composer-chip { text-decoration: none; }
.composer-cost { margin-left: auto; color: var(--text-muted); font-size: var(--fs-xs, 0.72rem); }

/* Style list */
.composer-styles { padding: 10px 12px 12px; max-height: min(60vh, 520px); display: flex; flex-direction: column; gap: 8px; }
.composer-styles-head { display: flex; align-items: center; justify-content: space-between; color: var(--text); font-size: var(--fs-sm, 0.85rem); font-weight: 600; }
.composer-styles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 8px;
    overflow-y: auto;
}
.composer-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 10px;
    background: none;
    color: var(--text);
    font: inherit;
    font-size: var(--fs-xs, 0.72rem);
    text-align: left;
    cursor: pointer;
}
.composer-card img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; background: var(--content-bg); }
.composer-card span.composer-card-name { padding: 0 2px 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-card[aria-pressed="true"] { border-color: var(--accent); }
.composer-card-tag {
    position: absolute;
    top: 4px;
    padding: 1px 6px;
    border-radius: var(--radius-pill, 999px);
    background: var(--overlay, rgba(0, 0, 0, 0.6));
    color: #fff;
    font-size: 0.65rem;
}
.composer-card-tag--video { left: 4px; }
.composer-card-tag--member { right: 4px; color: var(--vip); }

/* A strip card tapped on a phone: the chip flashes once instead of opening a keyboard. */
.is-flash { animation: composer-flash 0.9s ease-out; }
@keyframes composer-flash {
    0%, 100% { box-shadow: 0 0 0 0 transparent; }
    30% { box-shadow: 0 0 0 4px var(--accent); }
}

@media (max-width: 600px) {
    .composer { bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
    /* Style and sizes wrap on the first line; wait/price share the second with the button. */
    .composer-meta { margin-left: 0; order: 3; flex: 1 1 auto; white-space: normal; }
    .composer-go { order: 4; }
}

@media (prefers-reduced-motion: reduce) {
    .composer-spin,
    .composer-progress span { animation-duration: 3s; }
}
