/* Profile Switcher & Select Screen (Perfiles múltiples locales, Parte 2)

   Layout only - every visual building block (Avatar, Button) still comes
   from js/components/*.js (Fase 8). These rules arrange the profile
   grid/cards, the boot-time full-screen gate, and the avatar picker used
   by the create-profile form. Tokens only, no raw colors/shadows/radii/
   durations (CLAUDE.md reglas 79/80/81). */

/* ============ Boot gate ("¿Quién va a estudiar?") ============ */
.profile-select-screen {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  padding: var(--space-6) var(--space-4);
  padding-top: calc(var(--space-6) + var(--safe-area-top));
  padding-bottom: calc(var(--space-6) + var(--safe-area-bottom));
  background: linear-gradient(135deg, var(--color-ocean-dark) 0%, var(--color-ocean-deep) 100%);
  overflow-y: auto;
  animation: fade var(--duration-normal) var(--ease-smooth);
}

.profile-select-screen__title {
  margin: 0;
  text-align: center;
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-light);
}

/* ============ Profile switcher (grid of profile tiles) ============ */
.profile-switcher {
  width: 100%;
  max-width: var(--max-width-sm);
}

.profile-switcher__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-4);
}

.profile-switcher__tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-4) var(--space-2);
  background-color: var(--color-glass-bg-light);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
}

@media (hover: hover) {
  .profile-switcher__tile:hover {
    transform: translateY(-2px);
    border-color: var(--color-primary);
  }
}

.profile-switcher__tile:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.profile-switcher__tile--active {
  border-color: var(--color-primary);
}

.profile-switcher__tile--add {
  justify-content: center;
  border-style: dashed;
  border-color: var(--color-divider);
}

.profile-switcher__add-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-circle);
  background-color: var(--color-bg-secondary);
  color: var(--color-text-secondary);
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
}

.profile-switcher__name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  text-align: center;
  overflow-wrap: anywhere;
}

/* Inside .profile-select-screen, tile text sits on the dark ocean
   gradient instead of the app's regular light background - swap to the
   light-on-dark text tokens the loading screen already uses there. */
.profile-select-screen .profile-switcher__name {
  color: var(--color-text-light);
}

.profile-select-screen .profile-switcher__add-icon {
  background-color: var(--color-white-translucent);
  color: var(--color-text-light);
}

/* Not color-only (CLAUDE.md regla 42): the active profile also gets a
   text label, not just a colored border. */
.profile-switcher__active-badge {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-primary);
  background-color: var(--color-info-bg-soft);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-pill);
}

/* ============ Create-profile form ============ */
.profile-switcher__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.profile-switcher__form label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

.profile-select-screen .profile-switcher__form label,
.profile-select-screen .profile-switcher__hint {
  color: var(--color-text-light);
}

.profile-switcher__name-input {
  min-height: 44px;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-divider);
  font-size: var(--font-size-base);
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
}

.profile-switcher__name-input:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.profile-switcher__hint {
  margin: 0;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.avatar-picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.avatar-picker__option {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: var(--space-1);
  background: transparent;
  border: 2px solid transparent;
  border-radius: var(--radius-circle);
  cursor: pointer;
}

.avatar-picker__option:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.avatar-picker__option--selected {
  border-color: var(--color-primary);
}

.profile-switcher__error {
  margin: 0;
  min-height: 1em;
  font-size: var(--font-size-sm);
  color: var(--color-error);
}

.profile-switcher__actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  flex-wrap: wrap;
}

@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) .profile-select-screen,
  :root:not([data-motion="full"]) .profile-switcher__tile {
    animation: none;
    transition: none;
  }
}
