/* Catalog no-flicker + first-paint stability */

html[data-app-ready="0"] .app-shell {
  visibility: hidden;
}

/* Freeze only the post-login shell on first paint — never the auth hero. */
body[data-initial-mount="1"] .app-shell *,
body[data-initial-mount="1"] .app-shell *::before,
body[data-initial-mount="1"] .app-shell *::after {
  transition: none !important;
  animation-duration: 0s !important;
  animation-delay: 0s !important;
}

/* Artwork reserved square — no layout shift on load.
   List covers MUST match --cover-list (grid track). Never hardcode a larger
   square here — that overflows the artwork column into identity. */
html.ui-v2 .catalog-cover-art,
html.ui-v2 .cover-thumb.catalog-cover-art,
html.ui-v2 .catalog-list-cover .cover-thumb,
html.ui-v2 .catalog-list-cover .catalog-cover,
html.ui-v2 .catalog-list-cover .catalog-cover-art {
  aspect-ratio: 1 / 1;
  width: var(--cover-list, 76px);
  height: var(--cover-list, 76px);
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  display: block;
  background: #e8eaed;
  box-sizing: border-box;
}

html.ui-v2 .catalog-list-cover {
  width: var(--cover-list, 76px);
  height: var(--cover-list, 76px);
  max-width: 100%;
  overflow: hidden;
  position: relative;
  margin: 0;
  transform: none;
  inset: auto;
}

html.ui-v2 .catalog-grid-cover .cover-thumb,
html.ui-v2 .catalog-grid-art {
  aspect-ratio: 1 / 1;
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: cover;
  display: block;
  background: #e8eaed;
}

html.ui-v2 img.catalog-cover-art {
  opacity: 0;
  transition: opacity 180ms ease;
}

html.ui-v2 img.catalog-cover-art.cover-loaded,
html.ui-v2 img.catalog-cover-art.cover-loading {
  opacity: 1;
}

html.ui-v2 .catalog-surface-placeholder {
  min-height: 240px;
}

/* Strip dangerous global transitions on large containers */
html.ui-v2 .page-shell,
html.ui-v2 .catalog-surface,
html.ui-v2 .data-surface,
html.ui-v2 #workspace,
html.ui-v2 .catalog-list-row,
html.ui-v2 .catalog-grid-card {
  transition-property: opacity, transform, background-color, border-color, box-shadow;
}

html.ui-v2 .page-enter {
  animation: none;
}

/* Auth form spacing */
html.ui-v2 .auth-card-stage .auth-pane,
html.ui-v2 .auth-workspace .auth-pane {
  display: flex;
  flex-direction: column;
  gap: 0;
}

html.ui-v2 .auth-workspace .field + .field,
html.ui-v2 .auth-workspace .field + .button,
html.ui-v2 .auth-workspace .button + .button,
html.ui-v2 .auth-workspace .button + .field,
html.ui-v2 .auth-workspace [data-locale-select],
html.ui-v2 .auth-workspace .locale-select,
html.ui-v2 .auth-workspace .auth-actions,
html.ui-v2 .auth-workspace .auth-locale-combobox {
  margin-top: 0;
}

html.ui-v2 .auth-workspace .auth-actions,
html.ui-v2 .auth-workspace .modal-actions,
html.ui-v2 .auth-workspace .form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
}

html.ui-v2 .auth-workspace .auth-separator,
html.ui-v2 .auth-workspace .divider,
html.ui-v2 .auth-workspace hr {
  margin: 8px 0;
}

html.ui-v2 .auth-workspace {
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
}

/* Login egg actor sits behind the auth card */
.auth-locale-egg .login-egg-actor {
  position: absolute;
  right: 4%;
  bottom: 6%;
  width: min(42vw, 220px);
  max-height: 42vh;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.auth-card-stage {
  position: relative;
  z-index: 2;
}

@media (max-width: 767px) {
  .auth-locale-egg .login-egg-actor {
    width: min(36vw, 140px);
    right: 2%;
    bottom: max(8px, env(safe-area-inset-bottom, 0px));
  }
}

/* Legacy (non ui-v2) catalog: one representation per width.
   The table and the phone cards were both rendered and both visible, so every
   release appeared twice. Table above 720px, cards below. */
html:not(.ui-v2) .catalog-card-list { display: none; }
@media (max-width: 720px) {
  html:not(.ui-v2) .catalog-table-wrap { display: none; }
  html:not(.ui-v2) .catalog-card-list { display: grid; gap: 8px; padding: 8px; }
  html:not(.ui-v2) .catalog-card {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--line, #DDE1E7);
    border-radius: 10px;
    background: var(--surface, #fff);
    cursor: pointer;
  }
  html:not(.ui-v2) .catalog-card .cover-thumb { width: 56px; height: 56px; border-radius: 6px; }
  html:not(.ui-v2) .catalog-card-body { min-width: 0; display: grid; gap: 3px; }
  html:not(.ui-v2) .catalog-card-title,
  html:not(.ui-v2) .catalog-card-artist,
  html:not(.ui-v2) .catalog-card-meta { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  html:not(.ui-v2) .catalog-card-artist,
  html:not(.ui-v2) .catalog-card-meta { color: var(--muted, #69717D); font-size: 12px; }
  html:not(.ui-v2) .catalog-card-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 3px; }
  html:not(.ui-v2) .catalog-card-actions { display: flex; flex-direction: column; gap: 4px; }
}
