/* Entrada: como a pessoa chega, entra e volta para a sala (primeira vez, status, cartões com quem está na sala, prévia do código, dicas). */
/* Movimento: uma curva só (--ease-out), 150 ms para o que entra; "Reduzir animações" zera tudo (glass.css). */
@keyframes entrada-in { from { opacity: 0; translate: 0 4px; } }
@keyframes entrada-spin { to { rotate: 360deg; } }

/* ---- Primeira vez: "Como a galera te chama?" inline, acima do código ---- */
#home .home-top.first-run { flex-direction: column; align-items: stretch; }
#home .home-profile-d:not([open]) > .home-profile { display: none; }
#home .home-profile-d.first-run { width: 100%; }
#home .home-profile-d.first-run > summary { display: none; }
#home .home-profile-d.first-run[open] > .home-profile { position: static; width: auto; margin: 4px 0 0; box-shadow: none; padding: 20px 24px; display: grid; grid-template-columns: 64px minmax(200px, 1fr) auto; gap: 8px 16px; align-items: end; }
#home .welcome-ask { grid-column: 1 / -1; flex: 1 0 100%; margin: 0 0 4px; font-size: 18px; font-weight: 700; letter-spacing: -.01em; color: var(--text-hi); }
#home .welcome-ask[hidden], #home .welcome-go[hidden] { display: none; }
#home .welcome-go { min-height: 48px; padding: 0 22px; border-radius: 14px; font-size: 15px; font-weight: 700; flex: none; }
#home .home-profile-d.first-run .field.grow { min-width: 0; }
#home .home-profile-d:not(.first-run) .field.grow { min-width: min(140px, 100%); }
#home .welcome-visual[hidden] { display: none; }
#home .welcome-visual { grid-column: 1 / -1; min-width: 0; padding: 12px 0 0; margin: 6px 0 0; border-top: 1px solid var(--line); color: var(--text-hi); }
#home .welcome-visual-head { display: flex; align-items: center; justify-content: space-between; gap: 4px 12px; flex-wrap: wrap; margin-bottom: 8px; }
#home .welcome-visual-head h2 { font-size: 16px; margin: 0 0 2px; }
#home .welcome-visual-head p { font-size: .875rem; margin: 0; }
#home #welcome-more { min-height: 44px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-panel); color: var(--text-hi); font-size: .875rem; font-weight: 700; cursor: pointer; }
#home .welcome-theme-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.web-viewer #home .welcome-theme-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#home .welcome-theme-grid .theme-card { min-width: 0; min-height: 44px; padding: 4px; gap: 4px; align-items: stretch; border: 2px solid var(--line); background: var(--bg-panel); color: var(--text-hi); }
#home .welcome-theme-grid .theme-card img { width: 100%; height: auto; aspect-ratio: 288 / 150; object-fit: cover; border-radius: 8px; display: block; }
#home .welcome-theme-grid .tc-name { padding: 4px; font-size: .875rem; text-align: left; }
#home .welcome-theme-grid .theme-card:hover, #home .welcome-theme-grid .theme-card[aria-pressed=true], #home #welcome-more:hover { border-color: currentColor; }
#home .welcome-theme-grid .theme-card[aria-pressed=true] .tc-name::after { content: ' ✓' / ''; }
#home .welcome-theme-grid .theme-card:focus-visible, #home #welcome-more:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
#home .welcome-theme-grid .theme-card, #home #welcome-more, #home .welcome-go { transition: none; }
#home .welcome-go { grid-column: 1 / -1; justify-self: end; }
@media (max-width: 560px) {
  #home .home-profile-d.first-run[open] > .home-profile { grid-template-columns: 48px minmax(0, 1fr) auto; gap: 8px; padding: 16px; }
  #home .home-profile-d.first-run .avatar-edit { width: 48px; height: 48px; }
  #home .welcome-go { grid-column: 2 / -1; justify-self: end; }
}

/* ---- Linha de status: altura reservada, spinner de 14 px, vermelho só em falha confirmada ---- */
#home #home-error { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; min-height: 28px; margin: 4px 4px 0; font-size: 14px; line-height: 24px; white-space: pre-line; }
#home #home-error:empty { display: flex; }
html.reduce-motion #home #home-error.busy::before { animation: none; }
@media (prefers-reduced-motion: reduce) { #home #home-error.busy::before { animation: none; } }
#home #home-error.neutral { color: var(--muted); }
#home #home-error.busy:not(:empty)::before { content: ''; flex: none; width: 14px; height: 14px; box-sizing: border-box; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--muted) 30%, transparent); border-top-color: var(--muted); animation: entrada-spin .8s var(--ease-out) infinite; margin-right: -4px; }
#home #home-error .st-btn { min-height: 28px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); background: transparent; color: var(--text-hi); font: inherit; font-size: 13px; font-weight: 600; line-height: 1; cursor: pointer; transition: background-color var(--dur-press, 120ms) var(--ease-out); }
html.web-shell #home #home-error .st-btn { min-height: 44px; }
#home #home-error .st-btn:hover { background: var(--hover); }
#home #home-error .st-btn:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

/* ---- Recentes ---- */
#home .recent-item .x { cursor: pointer; border: 0; background: transparent; }
#home .recent-item .x:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }

/* ---- Quem está na sala: pilha de avatares, ponto e selo ---- */
.pv-stack { display: inline-flex; flex: none; padding-left: 6px; }
.pv-av, .pv-more { width: 22px; height: 22px; margin-left: -6px; box-sizing: border-box; border-radius: 50%; display: grid; place-items: center; overflow: hidden; font-style: normal; font-size: 10px; font-weight: 700; line-height: 1; color: #fff; background: var(--c, #5865f2); box-shadow: 0 0 0 2px var(--pv-ring, var(--bg-side)); text-shadow: 0 1px 1px rgba(0,0,0,.3); user-select: none; }
.pv-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pv-more { background: var(--bg-panel); color: var(--muted); text-shadow: none; font-size: 10px; }
.pv-dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--muted2, #8b8f9a); opacity: .7; display: inline-block; }
.pv-dot.on { background: var(--green); opacity: 1; }

/* Cartões de "Minhas salas" */
#home .saved-room-status::before { display: none; }
#home .saved-room-status { min-height: 18px; overflow: hidden; white-space: nowrap; }
#home .saved-room-status > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#home .saved-room-pv { display: flex; align-items: center; gap: 8px; min-height: 24px; min-width: 0; }
#home .saved-room.has-cover .saved-room-art img { position: static; width: 40px; height: 40px; border-radius: 8px; }
#home .saved-room-live, .join-preview .jp-live { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 8px; border-radius: 99px; background: rgba(0,0,0,.5); color: #fff; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; line-height: 1.2; }
#home .saved-room-live::before, .join-preview .jp-live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
#home .saved-room-live { position: absolute; left: 10px; bottom: 10px; z-index: 3; }
#home .saved-room-live[hidden] { display: none; }

/* ---- Prévia do código digitado ---- */
.join-preview { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 16px; background: var(--bg-side); border: 1px solid var(--line); animation: entrada-in var(--dur-menu, 150ms) var(--ease-out) both; --pv-ring: var(--bg-side); }
.join-preview[hidden] { display: none; }
.join-preview.note { color: var(--muted); font-size: 14px; padding: 10px 14px; }
.join-preview .jp-art { width: 96px; height: 48px; flex: none; border-radius: 10px; display: grid; place-items: center; overflow: hidden; background: var(--room-color, #4a4f5c); color: #fff; font-size: 16px; font-weight: 800; }
.join-preview .jp-art.has-cover { background: var(--room-cover) center / cover no-repeat; }
.join-preview .jp-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.join-preview .jp-info b { font-size: 15px; color: var(--text-hi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.join-preview .jp-counts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); min-width: 0; }

/* ---- Dicas da primeira vez ---- */
.first-tip { position: fixed; z-index: 9000; width: min(264px, calc(100vw - 16px)); box-sizing: border-box; padding: 12px 14px; border-radius: 14px; background: var(--bg-rail); color: var(--text-hi); border: 1px solid var(--line); box-shadow: 0 12px 32px rgba(0,0,0,.28); font-size: 13px; line-height: 1.4; animation: entrada-in var(--dur-menu, 150ms) var(--ease-out) both; }
.first-tip b { display: block; margin-bottom: 2px; font-size: 13.5px; }
.first-tip span { display: block; color: var(--muted); }
.first-tip .ft-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.first-tip em { font-style: normal; font-size: 12px; color: var(--muted); }
.first-tip button { min-height: 30px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--text-hi); color: var(--bg-rail); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; transition: opacity var(--dur-press, 120ms) var(--ease-out); }
.first-tip button:hover { opacity: .88; }
.first-tip button:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.first-tip[data-side]:not([data-side=""])::before { content: ''; position: absolute; width: 10px; height: 10px; background: var(--bg-rail); border: 1px solid var(--line); rotate: 45deg; }
.first-tip[data-side=right]::before { left: -6px; top: calc(var(--ft-y, 24px) - 5px); border-width: 0 0 1px 1px; }
.first-tip[data-side=top]::before { bottom: -6px; left: calc(var(--ft-x, 24px) - 5px); border-width: 0 1px 1px 0; }
.first-tip[data-side=bottom]::before { top: -6px; left: calc(var(--ft-x, 24px) - 5px); border-width: 1px 0 0 1px; }

.first-tip[hidden] { display: none; }
html.reduce-motion .first-tip, html.reduce-motion .join-preview { animation: none; }
html.reduce-motion .first-tip button { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .first-tip, .join-preview { animation: none; }
  .first-tip button { transition: none; }
}
@media (max-width: 720px) { .join-preview .jp-art { width: 64px; } }
