/* Avatar Creator — Design Your Skier */

.avatar-page {
  min-height: auto;
  box-sizing: border-box;
  background: transparent;
  color: #333;
  font-family: 'Segoe UI', system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  margin: 0;
}

/* Avatar preview card — background set by JS from ACTIVE_AVATAR.schema.background */
.avatar-preview {
  position: relative;
  background: transparent;
  border-radius: 16px;
  padding: 20px 44px 20px;
  margin-bottom: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.avatar-preview__name {
  text-align: center;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  border-radius: 8px;
  padding: 2px 12px;
  min-height: 21px;
}

.avatar-preview__name--visible {
  background: rgba(255, 255, 255, 0.7);
}

/* Randomize button */
.avatar-randomize {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(to top right, #FF0000, #800031);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  margin-bottom: 16px;
  transition: opacity 0.15s;
}

.avatar-randomize:hover {
  opacity: 0.85;
}

.avatar-randomize__icon {
  font-size: 18px;
}

/* Form fields (email + name) */
.avatar-fields {
  width: 100%;
  max-width: 360px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.avatar-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.avatar-field__label {
  font-size: 11px;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.avatar-field__input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid #ccc;
  background: #fff;
  color: #333;
  font-size: 15px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.avatar-field__input:focus {
  border-color: #FF0000;
}

.avatar-field__input:disabled {
  background: #f5f5f5;
  color: #999;
  cursor: not-allowed;
}

.avatar-field__input::placeholder {
  color: #999;
}

.avatar-field__error {
  font-size: 11px;
  color: #e74c3c;
  min-height: 14px;
}

.avatar-field__hint {
  font-size: 11px;
  color: #888;
  line-height: 1.4;
}

.avatar-field__not-me {
  display: block;
  font-size: 11px;
  color: #888;
  text-decoration: none;
  margin-top: 2px;
}

.avatar-field__not-me:hover {
  color: #FF0000;
  text-decoration: underline;
}

/* Category tabs */
.avatar-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 420px;
}

.avatar-tab {
  padding: 8px 14px;
  border-radius: 10px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: #eee;
  color: #555;
  transition: all 0.12s;
}

.avatar-tab--active {
  background: linear-gradient(to top right, #FF0000, #800031);
  color: #fff;
  font-weight: 800;
}

/* Selector panel */
.avatar-selector {
  background: #f5f5f5;
  border-radius: 14px;
  padding: 14px 20px;
  width: 100%;
  max-width: 360px;
  margin-bottom: 20px;
  border: 1px solid #ddd;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.avatar-selector__section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.avatar-selector__label {
  font-size: 11px;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Color swatches */
.avatar-swatches {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: center;
}

.avatar-swatch {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid #ccc;
  box-shadow: none;
  transition: all 0.12s;
  padding: 0;
}

.avatar-swatch--selected {
  border: 3px solid #FF0000;
  box-shadow: 0 0 8px rgba(255, 0, 0, 0.4);
}

/* Cycle selector (arrows + label) */
.avatar-cycle {
  display: flex;
  align-items: center;
  gap: 20px;
}

.avatar-cycle__btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 2px solid #ccc;
  background: #fff;
  color: #333;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.12s;
}

.avatar-cycle__btn:hover {
  border-color: #FF0000;
}

.avatar-cycle__label {
  font-size: 15px;
  font-weight: 600;
  color: #333;
  min-width: 90px;
  text-align: center;
}

/* Save button */
.avatar-save {
  padding: 12px 48px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(to top right, #FF0000, #800031);
  color: #fff;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(255, 0, 0, 0.25);
  margin-bottom: 28px;
}

.avatar-save:disabled {
  background: #ddd;
  color: #999;
  cursor: not-allowed;
  box-shadow: none;
}

.avatar-save--saved {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: none;
}

.avatar-save--saving {
  opacity: 0.7;
  cursor: wait;
}

/* Status message */
.avatar-status {
  font-size: 12px;
  min-height: 16px;
  margin-bottom: 12px;
  text-align: center;
}

.avatar-status--error {
  color: #e74c3c;
}

.avatar-status--success {
  color: #10b981;
}

/* Crowd preview */
.avatar-crowd {
  width: 100%;
  max-width: 420px;
  border-top: 1px solid #ddd;
  padding-top: 16px;
}

.avatar-crowd__label {
  font-size: 12px;
  color: #888;
  text-align: center;
  margin-bottom: 10px;
}

.avatar-crowd__grid {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
  background: transparent; /* set by JS from ACTIVE_AVATAR.schema.background */
  border-radius: 12px;
  padding: 14px 10px 8px;
}

/* ─── Layout wrappers ─── */

.avatar-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.avatar-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.avatar-layout__left,
.avatar-layout__right {
  display: contents;
}

/* Mobile stacking order (via display:contents, children act as direct flex children) */
.avatar-preview         { order: 1; }
.avatar-randomize       { order: 2; }
.avatar-fields          { order: 3; }
.avatar-tabs            { order: 4; }
.avatar-selector        { order: 5; }
.avatar-status          { order: 6; }
.avatar-save            { order: 7; }
.avatar-crowd           { order: 8; }

/* ─── Desktop two-column layout ─── */

@media (min-width: 768px) {
  .avatar-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    max-width: 900px;
    align-items: start;
  }

  .avatar-layout__left,
  .avatar-layout__right {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .avatar-layout__left {
    position: sticky;
    top: 20px;
  }

  /* Reset order properties — grid columns handle placement */
  .avatar-preview,
  .avatar-randomize,
  .avatar-fields,
  .avatar-tabs,
  .avatar-selector,
  .avatar-status,
  .avatar-save,
  .avatar-crowd {
    order: unset;
  }

  /* Let elements fill their column */
  .avatar-fields,
  .avatar-tabs,
  .avatar-selector,
  .avatar-crowd {
    max-width: 100%;
  }
}

.avatar-status--loading {
  color: #888;
}

/* Overlay covers the preview card while avatar is loading */
.avatar-preview__overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #555;
  font-size: 13px;
  font-weight: 600;
}

.avatar-preview__spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #ddd;
  border-top-color: #FF0000;
  border-radius: 50%;
  animation: avatar-spin 0.8s linear infinite;
}

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

/* Loading overlay */
.avatar-loading {
  color: #888;
  font-size: 13px;
  padding: 40px;
  text-align: center;
}
