/* Shared interaction primitives. Page styles keep ownership of color and layout. */
:root {
  --ui-ease-standard: cubic-bezier(.22, .8, .24, 1);
  --ui-duration-fast: 180ms;
  --ui-duration-dialog: 240ms;
}

button[data-ui-motion],
.upload-label[data-ui-motion],
.post-upload-button[data-ui-motion],
.profile-avatar-upload[data-ui-motion] {
  transition-duration: var(--ui-duration-fast) !important;
  transition-timing-function: var(--ui-ease-standard) !important;
}

.ui-dialog[open] {
  animation: ui-dialog-in var(--ui-duration-dialog) var(--ui-ease-standard) both;
}

.ui-dialog::backdrop {
  animation: ui-backdrop-in var(--ui-duration-dialog) var(--ui-ease-standard) both;
}

@keyframes ui-dialog-in {
  from { opacity: 0; transform: translateY(9px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ui-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Shared circular avatar cropper used by registration and profile editing. */
[data-ui-theme="space"] {
  --avatar-crop-surface: rgba(13, 16, 35, .98);
  --avatar-crop-ink: #f5f2e9;
  --avatar-crop-muted: #a9afbe;
  --avatar-crop-line: rgba(245, 242, 233, .2);
  --avatar-crop-accent: #dcff55;
  --avatar-crop-primary-bg: #f5f2e9;
  --avatar-crop-primary-ink: #070914;
  --avatar-crop-stage: #070914;
  --avatar-crop-shadow: 0 28px 70px rgba(0, 0, 0, .5);
}

[data-ui-theme="cloud"] {
  --avatar-crop-surface: rgba(247, 252, 255, .98);
  --avatar-crop-ink: #17355d;
  --avatar-crop-muted: #5f7f9f;
  --avatar-crop-line: rgba(104, 152, 201, .35);
  --avatar-crop-accent: #1677ff;
  --avatar-crop-primary-bg: #1677ff;
  --avatar-crop-primary-ink: #fff;
  --avatar-crop-stage: #dceeff;
  --avatar-crop-shadow: 0 28px 65px rgba(12, 57, 103, .28);
}

.avatar-crop-dialog {
  width: min(calc(100% - 32px), 430px);
  max-height: calc(100svh - 28px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--avatar-crop-line);
  border-radius: 24px;
  color: var(--avatar-crop-ink);
  background: var(--avatar-crop-surface);
  box-shadow: var(--avatar-crop-shadow);
}

.avatar-crop-dialog::backdrop {
  background: rgba(5, 12, 27, .58);
  backdrop-filter: blur(5px);
}

.avatar-crop-card { position: relative; padding: 27px 22px 22px; }
.avatar-crop-kicker { margin: 0 0 7px; color: var(--avatar-crop-accent); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.avatar-crop-title { margin: 0; font-size: 28px; font-weight: 900; letter-spacing: -.05em; }
.avatar-crop-copy { margin: 8px 36px 18px 0; color: var(--avatar-crop-muted); font-size: 12px; line-height: 1.65; }
.avatar-crop-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--avatar-crop-line);
  border-radius: 50%;
  place-items: center;
  color: var(--avatar-crop-muted);
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: color var(--ui-duration-fast), background var(--ui-duration-fast), transform var(--ui-duration-fast);
}
.avatar-crop-close:hover, .avatar-crop-close:focus-visible { color: var(--avatar-crop-ink); background: color-mix(in srgb, var(--avatar-crop-accent) 12%, transparent); }
.avatar-crop-close:active { transform: scale(.94); }
.avatar-crop-stage {
  position: relative;
  width: min(72vw, 292px);
  aspect-ratio: 1;
  margin: 0 auto;
  overflow: hidden;
  border: 3px solid color-mix(in srgb, var(--avatar-crop-accent) 72%, white);
  border-radius: 50%;
  background: var(--avatar-crop-stage);
  box-shadow: 0 0 0 7px color-mix(in srgb, var(--avatar-crop-accent) 9%, transparent), 0 18px 36px rgba(0, 0, 0, .18);
  touch-action: none;
}
.avatar-crop-canvas { display: block; width: 100%; height: 100%; cursor: grab; user-select: none; }
.avatar-crop-canvas.is-dragging { cursor: grabbing; }
.avatar-crop-ring { position: absolute; inset: 0; border: 1px solid rgba(255, 255, 255, .52); border-radius: 50%; pointer-events: none; }
.avatar-crop-zoom { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; margin: 19px 4px 0; color: var(--avatar-crop-muted); font-size: 11px; font-weight: 700; }
.avatar-crop-zoom input { width: 100%; accent-color: var(--avatar-crop-accent); cursor: pointer; }
.avatar-crop-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 18px; }
.avatar-crop-cancel, .avatar-crop-confirm { min-height: 44px; border-radius: 12px; font-size: 13px; font-weight: 800; cursor: pointer; transition: background var(--ui-duration-fast), border-color var(--ui-duration-fast), box-shadow var(--ui-duration-fast), transform var(--ui-duration-fast); }
.avatar-crop-cancel { border: 1px solid var(--avatar-crop-line); color: var(--avatar-crop-ink); background: transparent; }
.avatar-crop-cancel:hover, .avatar-crop-cancel:focus-visible { border-color: var(--avatar-crop-accent); background: color-mix(in srgb, var(--avatar-crop-accent) 9%, transparent); }
.avatar-crop-confirm { border: 0; color: var(--avatar-crop-primary-ink); background: var(--avatar-crop-primary-bg); box-shadow: 0 8px 18px color-mix(in srgb, var(--avatar-crop-accent) 25%, transparent); }
.avatar-crop-confirm:hover, .avatar-crop-confirm:focus-visible { box-shadow: 0 11px 24px color-mix(in srgb, var(--avatar-crop-accent) 34%, transparent); transform: translateY(-1px); }
.avatar-crop-cancel:active, .avatar-crop-confirm:active { transform: scale(.97); }

@media (prefers-reduced-motion: reduce) {
  button[data-ui-motion],
  .upload-label[data-ui-motion],
  .post-upload-button[data-ui-motion],
  .profile-avatar-upload[data-ui-motion],
  .ui-dialog[open],
  .ui-dialog::backdrop {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
