/* Pose Lab — responsive, busy-state-first */

.pose {
  --pose-pad-x: clamp(12px, 2.5vw, 20px);
  --pose-pad-bottom: clamp(88px, 12vw, 56px);
  --pose-gap: clamp(12px, 2vw, 22px);
  --pose-accent: var(--accent, #2dd4bf);
  --pose-busy: #f0b429;
  padding:
    calc(var(--header-h) + env(safe-area-inset-top, 0px) + 12px)
    max(var(--pose-pad-x), env(safe-area-inset-right, 0px))
    calc(var(--pose-pad-bottom) + env(safe-area-inset-bottom, 0px))
    max(var(--pose-pad-x), env(safe-area-inset-left, 0px));
  max-width: 1180px;
  margin: 0 auto;
  width: 100%;
}

/* site.css .btn { display:inline-flex } overrides UA [hidden] */
.pose [hidden] {
  display: none !important;
}

.pose-banner {
  background: #3a1520;
  border: 1px solid rgba(255, 107, 53, 0.45);
  color: #ffd7c8;
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 0.9rem;
  line-height: 1.45;
}

.pose-banner[data-kind="dns"] {
  background: #3a3010;
  border-color: rgba(240, 180, 41, 0.5);
  color: #ffe9b0;
}

.pose-banner .lab-reconnect-btn,
.lab-banner .lab-reconnect-btn {
  display: inline-flex;
  align-items: center;
  margin-top: 6px;
  margin-left: 0;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.35);
  color: inherit;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.pose-banner .lab-reconnect-btn:disabled,
.lab-banner .lab-reconnect-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* —— Sticky busy banner (impossible to miss) —— */
.pose-busy {
  position: sticky;
  top: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(240, 180, 41, 0.55);
  background: linear-gradient(135deg, rgba(60, 42, 8, 0.97), rgba(28, 24, 12, 0.97));
  color: #ffe9b0;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.pose-busy-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
  font-size: 0.82rem;
  line-height: 1.35;
}

.pose-busy-copy strong {
  font-size: 0.95rem;
  color: #fff6d6;
}

.pose-busy-timer {
  font-variant-numeric: tabular-nums;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  font-size: 0.95rem;
  color: var(--pose-busy);
  flex-shrink: 0;
}

.pose-busy-spin {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(240, 180, 41, 0.25);
  border-top-color: var(--pose-busy);
  border-radius: 50%;
  flex-shrink: 0;
  animation: pose-spin 0.75s linear infinite;
}

.pose-busy-spin-lg {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

@keyframes pose-spin {
  to { transform: rotate(360deg); }
}

/* —— Hero (compact on phones) —— */
.pose-hero {
  margin-bottom: clamp(10px, 2vw, 18px);
}

.pose-hero .section-label {
  margin: 0;
}

.pose-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 3.8vw, 2.2rem);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin: 4px 0 6px;
  line-height: 1.15;
}

.pose-hero-lede {
  color: var(--text-muted);
  max-width: 36rem;
  margin: 0;
  font-size: clamp(0.82rem, 0.78rem + 0.25vw, 0.95rem);
  line-height: 1.45;
}

@media (max-width: 639px) {
  .pose-hero-lede {
    display: none;
  }
}

/* —— Layout —— */
.pose-layout {
  display: grid;
  gap: var(--pose-gap);
  grid-template-columns: 1fr;
  align-items: start;
}

@media (max-width: 767px) {
  .pose-stage {
    order: -1;
  }
}

@media (min-width: 768px) and (max-width: 959px) {
  .pose-layout {
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  }
}

@media (min-width: 960px) {
  .pose-layout {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  }

  .pose {
    --pose-pad-bottom: clamp(24px, 5vw, 56px);
  }
}

.pose-controls {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(12px, 2vw, 16px);
  display: grid;
  gap: 12px;
  min-width: 0;
}

.pose.is-busy .pose-controls {
  border-color: rgba(240, 180, 41, 0.35);
}

/* Steps bar: shared .pipe-* styles live in ../assets/css/site.css */
.pose.is-busy .pipe-kicker {
  color: var(--pose-busy);
}

.pose-projects {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  padding: 0;
  margin: 0 0 14px;
  min-width: 0;
}

.pose-projects-list {
  display: grid;
  gap: 8px;
  padding: 10px 12px 12px;
  max-height: min(28vh, 220px);
  overflow: auto;
}

.pose-projects-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  font-family: var(--font-display);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: var(--text-muted);
  user-select: none;
}

.pose-projects-summary::-webkit-details-marker {
  display: none;
}

.pose-projects-summary-label {
  min-width: 0;
}

.pose-projects-summary-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.pose-projects-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-family: var(--font-body, inherit);
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  text-transform: none;
}

.pose-projects-chevron {
  width: 0.45em;
  height: 0.45em;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  margin-top: -0.15em;
}

.pose-projects[open] .pose-projects-chevron {
  transform: rotate(-135deg);
  margin-top: 0.12em;
}

.pose-projects[open] .pose-projects-toggle-text {
  font-size: 0;
}

.pose-projects[open] .pose-projects-toggle-text::after {
  content: "Hide";
  font-size: 0.68rem;
}

.pose-projects-summary:hover .pose-projects-toggle {
  border-color: rgba(45, 212, 191, 0.45);
  color: var(--pose-accent);
}

.pose-projects[open] .pose-projects-summary {
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.pose-projects-count {
  min-width: 1.4em;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(45, 212, 191, 0.18);
  color: var(--pose-accent);
  font-size: 0.7rem;
  text-align: center;
}

.pose-projects-hint {
  margin: 0;
  padding: 8px 12px 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.pose-projects-empty {
  margin: 0;
  padding: 8px 12px 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.pose-projects-empty[hidden] {
  display: none !important;
}

.pose-project-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
}

.pose-project-row.is-current {
  border-color: rgba(45, 212, 191, 0.35);
  background: rgba(45, 212, 191, 0.06);
}

.pose-project-thumb {
  width: 44px;
  height: 56px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
}

.pose-project-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pose-project-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.pose-project-meta strong {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pose-project-meta span {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pose-project-open,
.pose-project-del {
  min-height: 34px !important;
  padding: 4px 10px !important;
  font-size: 0.75rem !important;
  width: auto !important;
}

.pose-rail-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.pose-approved {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.pose-approved-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.pose-thumb {
  margin: 0;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  min-height: 88px;
  display: grid;
  align-content: end;
  position: relative;
}

.pose-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

.pose-thumb-empty {
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 4;
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.55;
}

.pose-thumb img:not([hidden]) ~ .pose-thumb-empty {
  display: none;
}

.pose-thumb figcaption {
  padding: 3px 6px;
  font-size: 0.65rem;
  color: var(--text-muted);
}

.pose-thumb-dl {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.pose-thumb-dl:hover {
  background: var(--pose-accent);
  color: #041016;
}

.pose-thumb-dl[hidden] {
  display: none !important;
}

.pose-drop {
  position: relative;
  display: grid;
  gap: 8px;
  justify-items: stretch;
  align-content: start;
  min-height: 96px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 10px;
  cursor: pointer;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(45, 212, 191, 0.08), transparent 55%),
    rgba(0, 0, 0, 0.18);
  transition: border-color 0.2s ease, opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.pose-drop.is-drag {
  border-color: var(--pose-accent);
}

.pose.is-busy .pose-drop {
  pointer-events: none;
  opacity: 0.55;
}

.pose-drop #drop-label {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  pointer-events: none;
}

.pose-ref-count {
  margin: 0;
  font-size: 0.72rem;
  color: var(--pose-accent);
  text-align: center;
  pointer-events: none;
}

.pose-ref-previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 8px;
  width: 100%;
}

.pose-ref-item {
  position: relative;
  margin: 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  aspect-ratio: 3 / 4;
}

.pose-ref-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pose-ref-item button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.pose-hint-refs {
  margin-top: -4px;
}

.pose-panel {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.pose-panel-title {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.pose-panel-lede {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.pose-panel-lede strong {
  color: var(--text);
  font-weight: 600;
}

.pose-panel-edit {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(45, 212, 191, 0.28);
  background:
    linear-gradient(160deg, rgba(45, 212, 191, 0.08), transparent 55%),
    rgba(0, 0, 0, 0.22);
}

.pose-panel-edit[hidden] {
  display: none !important;
}

.pose-next {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.22);
}

.pose-next-label {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.65rem;
  color: var(--pose-accent);
}

.pose-next-text {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.35;
  color: var(--text);
}

.pose[data-mode="review"] .pose-panel-refs {
  opacity: 0.72;
}

.pose[data-mode="review"] .pose-panel-refs .pose-hint-refs,
.pose[data-mode="ready"] .pose-panel-refs .pose-hint-refs {
  display: none;
}

.pose[data-mode="ready"] .pose-panel-refs {
  display: none;
}

.pose-field {
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
}

.pose-field em {
  font-style: normal;
  color: var(--text-muted);
  font-weight: 400;
}

.pose-field textarea {
  width: 100%;
  resize: vertical;
  min-height: 52px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
}

.pose-panel-edit .pose-field textarea:focus {
  outline: none;
  border-color: var(--pose-accent);
  box-shadow: 0 0 0 1px rgba(45, 212, 191, 0.35);
}

.pose.is-busy .pose-field textarea {
  opacity: 0.6;
  pointer-events: none;
}

.pose-credits {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* —— Actions —— */
.pose-actions,
.pose-edit-actions {
  display: grid;
  gap: 8px;
}

.pose-actions .btn,
.pose-edit-actions .btn {
  min-height: 48px;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}

.pose-actions .btn .btn-label,
.pose-edit-actions .btn .btn-label {
  font-weight: 600;
}

.pose-actions .btn .btn-meta,
.pose-edit-actions .btn .btn-meta {
  font-size: 0.72rem;
  opacity: 0.8;
  font-weight: 500;
}

.pose-actions .btn-primary .btn-meta {
  opacity: 0.9;
}

.pose-actions .btn:disabled,
.pose-edit-actions .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-accent {
  background: linear-gradient(90deg, #1f8f9a, #2dd4bf);
  color: #041016;
  border: 0;
}

.btn-accent:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-quiet {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-muted);
  min-height: 42px !important;
  font-size: 0.85rem;
}

.btn-quiet:hover:not(:disabled) {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.04);
}

.btn-reset {
  justify-self: start;
  min-height: 40px;
}

.pose-hint,
.pose-status {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.pose-status:empty {
  display: none;
}

.pose-status.is-error {
  color: #ffb4a2;
}

.pose-status.is-busy {
  color: var(--pose-busy);
  font-weight: 600;
}

/* Sticky primary CTA on phones */
@media (max-width: 767px) {
  .pose-actions-primary {
    position: sticky;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    z-index: 30;
    margin: 4px -4px 0;
    padding: 10px 8px;
    border-radius: 12px;
    background: rgba(10, 12, 18, 0.94);
    border: 1px solid var(--border);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(10px);
  }

  .pose.is-busy .pose-actions-primary {
    border-color: rgba(240, 180, 41, 0.45);
  }
}

/* —— Stage —— */
.pose-stage {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.pose-stage-title {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pose.is-ready .pose-stage-head,
.pose.is-ready .pose-hero-lede {
  display: none;
}

.pose.is-ready .pose-hero h1 {
  font-size: clamp(1.35rem, 3.5vw, 1.85rem);
}

.pose-stage-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
}

.pose-dl-btn {
  min-height: 32px !important;
  padding: 4px 10px !important;
  font-size: 0.75rem !important;
  width: auto !important;
  flex: 0 0 auto;
}

.pose-dl-btn[hidden] {
  display: none !important;
}

.pose-stage-frame {
  position: relative;
  min-height: min(56dvh, 460px);
}

.pose-stage-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  border-radius: var(--radius);
  background: rgba(6, 8, 12, 0.78);
  backdrop-filter: blur(4px);
  color: #ffe9b0;
  font-size: 1rem;
  font-weight: 600;
}

.pose-stage-overlay-sub {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 400;
  color: rgba(255, 233, 176, 0.75);
  max-width: 16rem;
}

.pose-grid {
  --pose-preview-w: min(100%, calc(min(72dvh, 600px) * 3 / 4));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: var(--pose-preview-w);
  max-width: 100%;
  gap: 10px;
  min-height: 200px;
  justify-self: center;
}

@media (min-width: 480px) {
  .pose-grid {
    --pose-preview-w: min(100%, calc(min(74dvh, 640px) * 3 / 4));
  }
}

@media (min-width: 768px) {
  .pose-grid {
    --pose-preview-w: min(100%, calc(min(76dvh, 700px) * 3 / 4));
    justify-self: start;
  }

  .pose-stage-frame {
    min-height: min(62dvh, 520px);
  }
}

@media (min-width: 960px) {
  .pose-grid {
    --pose-preview-w: min(100%, calc(min(78dvh, 760px) * 3 / 4));
  }
}

@media (min-width: 1200px) {
  .pose-grid {
    --pose-preview-w: min(100%, calc(min(80dvh, 800px) * 3 / 4));
  }
}

/* Short phones / landscape: keep the figure on-screen */
@media (max-height: 700px) {
  .pose-grid {
    --pose-preview-w: min(100%, calc(min(62dvh, 440px) * 3 / 4));
  }
}

.pose-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 48px 16px;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.15);
}

.pose-tile {
  position: relative;
  margin: 0;
  border: 2px solid transparent;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  width: 100%;
}

.pose-tile.is-selected {
  border-color: var(--pose-accent);
}

.pose-tile.is-error {
  border-color: rgba(255, 107, 53, 0.55);
  min-height: 140px;
  display: grid;
  place-items: center;
  padding: 12px;
  color: #ffd7c8;
  font-size: 0.8rem;
  text-align: center;
  cursor: default;
}

.pose-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

.pose-tile-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
}

.pose-history-wrap {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.pose-history {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  min-height: 72px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}

.pose-history-item {
  flex: 0 0 auto;
  width: 56px;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.25);
  position: relative;
  padding: 0;
  scroll-snap-align: start;
  -webkit-tap-highlight-color: transparent;
}

.pose-history-item.is-selected {
  border-color: var(--pose-accent);
}

.pose-history-item img {
  display: block;
  width: 100%;
  height: 72px;
  object-fit: cover;
}

.pose-history-item .pose-hist-badge {
  position: absolute;
  bottom: 2px;
  left: 2px;
  right: 2px;
  font-size: 0.55rem;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  padding: 1px 0;
}

@media (prefers-reduced-motion: reduce) {
  .pose-busy-spin {
    animation: none;
  }
}
